akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 200001
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define se1 se.fi
#define se2 se.se
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

map<P, int> mp;
pair<int,int> g[MAX];
vector<int> G[MAX];
int used[MAX], d[MAX], ti[MAX];
int n, m, qn, ans[MAX+1];

void dijkstra(){
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	d[1] = 0;
	while(!q.empty()){
		P p = q.top();q.pop();
		if(d[p.se] < p.fi)continue;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i];
			if(d[to] > d[from]+1){
				d[to] = d[from]+1;
				q.push(P(d[to], to));
			}
		}
	}
}

void dijkstra2(){
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	used[1] = 1;
	while(!q.empty()){
		P p = q.top();q.pop();
		if(p.fi >= ti[p.se])continue;
		ti[p.se] = p.fi;
		ans[qn-p.fi]++;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i];
			if(d[from]+1 == d[to] && p.fi >= ti[p.se]){
				if(mp[P(from,to)] <= p.fi)q.push(P(p.fi, to));
				else q.push(P(mp[P(from,to)], to));
			}
		}
	}
}

int main(){
	int t, t1, t2;
	scanf("%d%d%d", &n, &m, &qn);
	fill(d, d+MAX, inf);
	fill(ti, ti+MAX, inf);
	rrep(i,m){
		scanf("%d%d", &t1, &t2);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
		g[i] = (P(t1, t2));
	}
	rrep(i,qn){
		scanf("%d", &t);
		t1 = g[t].fi;
		t2 = g[t].se;
		mp[P(t1, t2)] = qn-i+1;
		mp[P(t2, t1)] = qn-i+1;
	}
	
	dijkstra();
	dijkstra2();
	for(int i = 0;i < qn;i++){
		printf("%d\n", ans[i]);
		ans[i+1] += ans[i];
	}
	return 0;
}



Measured memory_bytes: 41216
#include<iostream>
using namespace std;

bool isPalindrome(int x){
    string s = to_string(x);
    int len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1])    return false;
    }
    return true;
}

int main(){
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for(int i = a; i <= b; i++){
        if(isPalindrome(i)) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=0;i<k;i++){
        if(i%2==0){
        if(a%2==1)a-=1;
        a/=2;
        b+=a;}
        else{
        if(b%2==1)b-=1;
        b/=2;
        a+=b;
    }
    }
    cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B, C, D; cin >> A >> B >> C >> D;
	while (true) {
		C -= B;
		if (C <= 0) {
			cout << "Yes\n";
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No\n";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3620
<?php

    $data = explode(" ", trim(fgets(STDIN)));
    $H = $data[0];
    $W = $data[1];
    $h = $data[2];
    $w = $data[3];
    $ans = true;
    if($W%$w==0 && $H%$h==0) $ans = false;
    
    $x = floor(10*($W*$H)/($w*$h));
    $y = (1-$w*$h)*$x-1;
    for($i=1; $i<=$H; $i++){
        $z[$i] = array_fill(0, $W+1, 0);
        for($j=1; $j<=$W; $j++){
            $z[$i][$j] = $x;
            if($i%$h==0 && $j%$w==0) $z[$i][$j] = $y;
        }
    }
    
    if($ans){
        echo "Yes\n";
        for($i=1; $i<=$H; $i++){
            for($j=1; $j<=$W; $j++){
                echo $z[$i][$j]." ";
            }
            echo "\n";
        }
    }
    else echo "No";
    
?>

Measured memory_bytes: 16888
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

bool canStringBePIN(std::string s, std::string pin) {

    int j = 0;
    for (int i = 0; i < pin.size(); ++i) {
        char t = pin[i];
        bool found = false;
        for (int k = j; k < s.length(); ++k) {
            if (s[k] == t) {
                found = true;
                j = k+1;
                break;
            }
        }
        if (!found) {
            return false;
        }
    }

    return true;
}

int main() {

    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    int cnt = 0;
    for (int i = 0; i < 1000; ++i) {

        std::string pin = std::to_string(i);

        if (pin.length() < 3) {
            pin.insert(pin.begin(), 3 - pin.length(), '0');
        }

        if (canStringBePIN(S, pin)) {
            cnt += 1;
        }
    }

    std::cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 384
num = gets.chomp.split(" ").map(&:to_i);

if num[0] < num[1] && num[2] < num[1] && num[2] > num[0]
  print "Yes"
elsif num[0] > num[1] && num[2] > num[1] && num[2] < num[0]
  print "Yes"
else
  print "No"
end

Measured memory_bytes: 1788
public class Main {

  private static void solve() {
    int n = ni();
    int k = ni();
    

    long x = 0;
    for (int b = 1; b <= k; b ++) {
      x += n;
    }
    
    for (int b = k + 1; b <= n; b ++) {
      int y = n / b;
      int z = Math.min(n - y * b + 1, k);
      
      x += z;
      if (y >= 1 && k >= 1) {
        x += y * k;
        x --;
      }
    }
    
    long ret = (long)n * n - x;
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  long long ans=0;
  vector <int> a(S.length()+1,0);  
  for(int i=1;i<S.length()+1;i++){
    if(S.at(i-1)=='<'){
      a.at(i)=a.at(i-1)+1;
    }
  }
  for(int i=S.length();i>0;i--){
    if(S.at(i-1)=='>'){
      a.at(i-1)=max(a.at(i-1),a.at(i)+1);
    }
  }  
  for(int i=0;i<S.length()+1;i++){
    //cout<<a.at(i);
    ans=ans+a.at(i);
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 2820
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int a,b,x;
    cin >> a >> b >>x;
    if(a>x){
        cout<<"NO"<<endl;
    }else if(a+b<x){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
}
   

Measured memory_bytes: 256
n = int(input())

minv = int(input())
maxv = -1000000000

for _ in range(1, n):

    R = int(input())

    maxv = max(maxv, R - minv)   # Rtにおける最大のRj - Riを取得
    minv = min(minv, R)          # 入力されたRの中の最小を取得


print(maxv)



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;

int main()
{
	//freopen("1.in","r",stdin);
	int n;
	cin>>n;
	bool cnt=0;
	while(n--)
	{
		int x;scanf("%d",&x);
		cnt^=x%2;
	}
	puts(cnt?"NO":"YES");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

long long solve(long long H) {
    if (H == 1) return 1;
    return 1 + 2 * solve(H / 2);
}

int main(int argc, char *argv[])
{
    long long H;
    cin >> H;
    cout << solve(H) << "\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int h[N], dp[N][2];
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;  cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
        if(i == 1)
            dp[1][0] = dp[1][1] = 1;
        else{
            if(h[i] >= h[i-1] && dp[i-1][0])
                dp[i][0] = 1;
            if(h[i] >= h[i-1]-1 && dp[i-1][1])
                dp[i][0] = 1;
            if(h[i]-1 >= h[i-1] && dp[i-1][0])
                dp[i][1] = 1;
            if(h[i]-1 >= h[i-1]-1 && dp[i-1][1])
                dp[i][1] = 1;
        }
    }
    if(dp[n][0] | dp[n][1])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
string s[1000000];
int main()
{
	map <string, long long int> a;
	long long n,i,j,k,mx;
	mx=-1;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>s[i];
		a[s[i]]=0;
	}
	sort(s,s+n);
	for (i=0;i<n;i++)
	{
		a[s[i]]++;
	}
	for (i=0;i<n;i++)
	{
		mx=max(mx,a[s[i]]);
	}
	for (i=0;i<n;i++)
	{
		if (a[s[i]]==mx)
		{
			cout<<s[i]<<endl;
			a[s[i]]=-1;
		}
	}
}

Measured memory_bytes: 33408
h,w = map(int,input().split())
map_ = list()
for i in range(h):
    map_.append(list(input()))
flag = True
while flag:

    flag = False

    for ii in range(len(map_)):
        if set(map_[ii]) == {"."}:
            del map_[ii]
            flag = True
            break

    map_t = [list(x) for x in zip(*map_)]

    for ii in range(len(map_t)):
        if set(map_t[ii]) == {"."}:
            del map_t[ii]
            flag = True
            map_ = [list(x) for x in zip(*map_t)]
            break

    map_ = [list(x) for x in zip(*map_t)]

for iiii in map_:
    print(*iiii,sep="")

Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    string S;
    cin >> S;
    
    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; ++i) reverse(divide[i].begin(),divide[i].end());
    bool can = true;
    for(int i = 0; i < S.size();){
        bool can2 = false;
        for(int j = 0; j < 4; ++j){
            string d = divide[j];
            if(S.substr(i,d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    class Program
    {

        static void Triangle(int a, int b, int c)
        {
            int[] data =  { a, b, c};

            Array.Sort(data);

            if(Math.Pow(data[0], 2) + Math.Pow(data[1], 2) == Math.Pow(data[2], 2))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
    
        }

        
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string[] input;

            int a = 0;
            int b = 0;
            int c = 0;

            for(int i = 0; i < n; i++)
            {
                input= Console.ReadLine().Split(' ');

                a = int.Parse(input[0]);
                b = int.Parse(input[1]);
                c = int.Parse(input[2]);

                Triangle(a, b, c);

            }


        }
    }
}



Measured memory_bytes: 13888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

bool on_segment(int x, int y, int w, int h)
{
    return (x==0 || x==w || y==0 || y==h);
}

int val(int x, int y, int w, int h)
{
    if(y==0) return x;
    if(x==w) return w+y;
    if(y==h) return w+h+(w-x);
    return w+h+w+h-y;
}

string solve()
{
    int W,H,n;
    cin >>W >>H >>n;

    vector<pi> e;
    rep(i,n)
    {
        int px,py,qx,qy;
        cin >>px >>py >>qx >>qy;
        if(on_segment(px,py,W,H) && on_segment(qx,qy,W,H))
        {
            e.pb({val(px,py,W,H),i});
            e.pb({val(qx,qy,W,H),i});
        }
    }
    sort(all(e));

    stack<int> st;
    vector<bool> vis(n);
    rep(i,e.size())
    {
        int id = e[i].se;
        if(vis[id])
        {
            if(st.empty() || st.top()!=id) return "NO";
            st.pop();
        }
        else
        {
            st.push(id);
            vis[id]=true;
        }
    }

    return "YES";
}

int main()
{
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 2420
# 出力の器
ary = [0,0,0,0]
flag = true

while flag
  flag = false
  tmp = gets.chomp.split.map(&:to_i)
  tmp.sort!
  if tmp[-1] < tmp[0]+tmp[1]
    # 三角形が存在するときの処理
    flag = true
    ary[0] += 1
    case  tmp[0]**2+tmp[1]**2 <=> tmp[-1]**2
    when -1
      # 鈍角
      ary[3] += 1
    when 0
      # 直角
      ary[1] += 1
    when 1
      # 鋭角
      ary[2] += 1
    end
  end
end
puts("#{ary[0]} #{ary[1]} #{ary[2]} #{ary[3]}")



Measured memory_bytes: 6876
from itertools import permutations
import sys
input = sys.stdin.readline

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N)]
count = [[0] * C for _ in range(3)]
for i in range(N):
    for j in range(N):
        count[(i+j) % 3][c[i][j]] += 1
ans = float('inf')
for p in permutations(range(C), 3):
    tmp = 0
    for i in range(3):
        for j in range(C):
            tmp += count[i][j] * D[j][p[i]]
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 44508
#include <iostream>
struct Node {
    int index;
    Node *parent, *left, *right;
};
Node* NIL;
Node* getNil()
{
    Node* node = (Node*)malloc(sizeof(Node));
    node->index = -1;
    node->parent = node;
    node->left = node;
    node->right = node;
    return node;
}
Node* getNewNode()
{
    Node* node = (Node*)malloc(sizeof(Node));
    node->index = -1;
    node->parent = NIL;
    node->left = NIL;
    node->right = NIL;
    return node;
}
Node* insertNode(Node* rootNode, int index)
{
    Node* node = rootNode;
    Node* parentNode = NIL;
    Node* indexNode = getNewNode();
    indexNode->index = index;
    if (node->index == -1) {
	return indexNode;
    }
    while (node->index != -1) {
	parentNode = node;
	if (node->index > index) {
	    node->left->parent = node;
	    node = node->left;
	} else {
	    node->right->parent = node;
	    node = node->right;
	}
    }
    indexNode->parent = parentNode;
    if (parentNode->index > index) {
	parentNode->left = indexNode;
    } else {
	parentNode->right = indexNode;
    }
    return rootNode;
}
void printNodeIn(Node* node)
{
    if (node->index == -1) {
	return;
    }
    std::cout << " " << node->index;
    printNodeIn(node->left);
    printNodeIn(node->right);
}
void printNodePre(Node* node)
{
    if (node->index == -1) {
	return;
    }
    printNodePre(node->left);
    std::cout << " " << node->index;
    printNodePre(node->right);
}
std::string findNode(Node* node, int index)
{

    while (node->index != -1) {
	if (node->index == index) {
	    return "yes";
	}
	if (node->index > index) {
	    node = node->left;
	} else {
	    node = node->right;
	}
    }
    return "no";
}
int main()
{
    NIL = getNil();
    Node* node = NIL;
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
	std::string command;
	std::cin >> command;
	if (command == "insert") {
	    int index;
	    std::cin >> index;
	    node = insertNode(node, index);
	} else if (command == "print") {
	    printNodePre(node);
	    std::cout << std::endl;
	    printNodeIn(node);
	    std::cout << std::endl;
	} else if (command == "find") {
	    int index;
	    std::cin >> index;
	    std::string answer = findNode(node, index);
	    std::cout << answer << std::endl;
	}
    }
}

Measured memory_bytes: 21872
import sys
input = sys.stdin.buffer.readline

from collections import deque

N, M = map(int, input().split())

X = [-10**9, 0, 10**9]
Y = [-10**9, 0, 10**9]

tate = []
yoko = []

for _ in range(N):
    a, b, c = map(int, input().split())
    X.append(a)
    X.append(b)
    Y.append(c)
    tate.append((a, b, c))

for _ in range(M):
    d, e, f = map(int, input().split())
    X.append(d)
    Y.append(e)
    Y.append(f)
    yoko.append((d, e, f))

X = sorted(set(X))
Y = sorted(set(Y))

Cx = {val: idx * 2 for idx, val in enumerate(X)}
Cy = {val: idx * 2 for idx, val in enumerate(Y)}

H = len(X) * 2 - 1
W = len(Y) * 2 - 1

G = [0] * (H * W)

for a, b, c in tate:
    j = Cy[c]
    for i in range(Cx[a], Cx[b] + 1):
        G[i * W + j] = -1

for d, e, f in yoko:
    i = Cx[d]
    for j in range(Cy[e], Cy[f] + 1):
        G[i * W + j] = -1

for i in range(1, H, 2):
    for j in range(1, W, 2):
        G[i * W + j] = (X[(i + 1) // 2] - X[(i - 1) // 2]) * (Y[(j + 1) // 2] - Y[(j - 1) // 2])

queue = deque([Cx[0] * W + Cy[0]])

visited = [0] * (H * W)
visited[Cx[0] * W + Cy[0]] = 1

res = 0

while queue:
    z = queue.popleft()
    
    nz = z + W
    if G[nz] != -1 and not visited[nz]:
        nx = nz // W
        if nx == H - 1:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)
        
    nz = z - W
    if G[nz] != -1 and not visited[nz]:
        nx = nz // W
        if nx == 0:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)
        
    nz = z + 1
    if G[nz] != -1 and not visited[nz]:
        ny = nz % W
        if ny == W - 1:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)
        
    nz = z - 1
    if G[nz] != -1 and not visited[nz]:
        ny = nz % W
        if ny == 0:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)
else:
    print(res)

Measured memory_bytes: 814564
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int w,a,b;
  cin >> w >> a >> b;

  int c,d;
  c = a + w;
  d = b + w;
  int ans;

  if((a <= b && b <= c)
    || (a <= d && d <= c))
  {
    cout << 0 << endl;
  }
  else
  {
    ans = min(abs(b - c),abs(a - d));
    cout << ans << endl;
  }
  
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int N(111111);
int bt[N];
int n;
void inc(int x) {
	for(int i(x); i <= n; i += i & -i) {
		bt[i] += 1;
	}
}
int getSum(int x) {
	int res(0);
	for(int i(x); i; i -= i & -i) {
		res += bt[i];
	}
	return res;
}
int main() {
	scanf("%d", &n);
	vector<pair<int, int> > vec;
	for(int qq(1); qq <= n; qq++) {
		int x;
		scanf("%d", &x);
		vec.push_back(make_pair(x, qq));
	}
	sort(vec.begin(), vec.end());
	int ans(0);
	for(int i(1); i <= n; i++) {
		ans += i % 2 != vec[i - 1].second % 2;
	}
	printf("%d\n", ans / 2);
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
using namespace std;

int main(){
	string a;
	cin >> a;

	if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]){
		cout << "Bad" << endl;
	}
	else{
		cout << "Good" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int x = 0;
  int n, i, j = 0;
  cin>>n;
  int a[n];
  for(i = 0; i<n; i++)
  {
      char a;
      cin>>a;
      if(a == 'I') x++;
      else x--;

      j = max(j, x);
  }
  cout<<j<<endl;



  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(c - (a - b), 0) << endl;
}


Measured memory_bytes: 3600
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int a = scan.nextInt(), b = scan.nextInt();
			for(int i = Math.max(b-a+1, -1000000); i <= Math.min(b+a-1, 1000000); i++) {
				out.print(i + " ");
			}
		}
	}
	
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 25044
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using Weight = int;

struct Edge {
  int to;
  Weight w;
};

using P = pair<int, int>;

vec<Edge, 2> rebuild(const vec<Edge, 2>& G) {
  vec<Edge, 2> newG(G.size());
  auto issueId = [&]() {
    newG.push_back({});
    return newG.size() - 1;
  };
  map<P, int> sup;
  auto getOrIssueId = [&](int v, int w) {
    auto key = P(v, w);
    if (!sup.count(key)) sup[key] = issueId();
    return sup[key];
  };
  for (int v = 0; v < G.size(); v++) {
    for (auto& e : G[v]) {
      int u = e.to, w = e.w;
      int from = getOrIssueId(v, w);
      int to = getOrIssueId(u, w);
      newG[from].push_back({to, 0});
    }
  }
  for (auto& entry : sup) {
    auto key = entry.fst;
    int v = key.fst;
    int id = entry.snd;
    newG[id].push_back({v, 0});
    newG[v].push_back({id, 1});
  }
  return newG;
}

const int INF = numeric_limits<Weight>::max();

vector<Weight> dijkstra(const vec<Edge, 2>& G, const int s) {
  vector<Weight> dist(G.size(), INF);
  using P = pair<Weight, int>;
  priority_queue<P, vector<P>, greater<P>> q;
  dist[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    const P p = q.top();
    q.pop();
    const Weight w = p.first;
    const int v = p.second;
    if (dist[v] < w) continue;
    for (const auto& e : G[v]) {
      const Weight nw = w + e.w;
      if (dist[e.to] <= nw) continue;
      dist[e.to] = nw;
      q.emplace(nw, e.to);
    }
  }
  return dist;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vec<Edge, 2> G(N);
    for (int i = 0; i < M; i++) {
      int a, b, w;
      cin >> a >> b >> w;
      --a;
      --b;
      G[a].push_back({b, w});
      G[b].push_back({a, w});
    }
    auto newG = rebuild(G);
    auto dist = dijkstra(newG, 0);
    if (dist[N - 1] >= INF) {
      cout << -1 << endl;
    } else {
      cout << dist[N - 1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 69852
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int INF = 1000000000;

int n;
vector<int> graph[10010];
bool done[10010];
int deg[10010];
vector<int> labels;

int output[10010];
int score;
int main(){
  cin >> n;
  REP(i, n-1) {
    int a, b;
    cin >> a >> b;
    graph[a-1].push_back(b-1);
    graph[b-1].push_back(a-1);
  }

  REP(i, n) {
    int c;
    cin >> c;
    labels.push_back(c);
  }

  sort(labels.begin(), labels.end(), greater<int>());
  score = 0;
  REP(i, n) {
    if (i==0) continue;
    score += labels[i];
  }

  int max_deg = 0;
  REP(i, n) {
    if (graph[i].size() > graph[max_deg].size()) {
      max_deg = i;
    }
  }

  REP(i, n) {
    done[i] = false;
  }
  done[max_deg] = true;
  output[max_deg] = labels[0];

#ifdef DEBUG
  cout << score << endl;
#endif

  int label_idx = 1;
  queue<int> que;
  que.push(max_deg);
  while(!que.empty()) {
    int q = que.front(); que.pop();
    REP(i, graph[q].size()) {
      int next = graph[q][i];
      if (!done[next]) {
        done[next] = true;
        output[next] = labels[label_idx];
        que.push(next);
        label_idx++;
      }
    }
  }

  cout << score << endl;
  REP(i, n) {
    cout << output[i];
    if (i != n-1) {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

int main(){
    int A,B; cin >> A >> B;
    // string B; cin >> B;
    // int n; cin >> n;
    // int C[n]; rep(i,n) cin >> C[i];
    int res = 0;
    int a = max(A,B);
    if(A!=B){
      rep(i,2){
        res += a;
        a--;
        }
    }
    else res = A+B;
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
  int x,y,i,j;
  bool sosu;
  scanf("%d",&x);
  for(i=x;i>0;i++){//iが素数であるか
    sosu=true;
    y=sqrt(x)+1;
    for(j=2;j<y;j++){//s[i-1]以下のjで割り切れるか
      if(i%j==0){
        sosu=false;
        break;
      }
    }
    if(sosu) break;
  }
  printf("%d",i);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
typedef long long ll;

const int MAXN=505,MAXD=7919;
const int movx[4]={-1,0,1,0},movy[4]={0,1,0,-1};

int n; ll a[MAXN][MAXN];
bool vis[MAXD]; ll prime[MAXN<<1];

inline ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}

inline ll lcm(ll a,ll b){
	if(!a||!b) return a|b;
	return a/gcd(a,b)*b;
}

inline void judge(){
	int x,a[505][505];
	scanf("%d",&x); lor(i,1,x) lor(j,1,x) scanf("%d",&a[i][j]);

}

int main(){
	scanf("%d",&n);

	if(n==2) return printf("4 7\n23 10\n"),0;

	lor(i,2,MAXD){
		if(!vis[i]) prime[++prime[0]]=i;
		for(register int j=1;j<=prime[0]&&i*prime[j]<=MAXD;++j) vis[i*prime[j]]=true;
	}

	lor(i,1,n) lor(j,1,n) if(!((i+j)&1)){
		a[i][j]=prime[(i+j)>>1]*prime[n+(n+1)/2+(i-j)/2];
	}
	lor(i,1,n) lor(j,1,n) if((i+j)&1){
		a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	}
	lor(i,1,n){
		lor(j,1,n) printf("%lld ",a[i][j]); printf("\n");
	}

	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;




int main(){
  int n;


  while (std::cin >> n) {
    int weight[10]={0};

    for(int j=9;j>=0;j--){
      if(n>=pow(2,j)){
        weight[j]=1;
        n-=pow(2,j);
      }
    }

    // for(int i=0;i<9;i++){
    //   if(weight[i]==1){
    //     std::cout << pow(2,i)<<" ";
    //   }
    // }
    // if(weight[9]==1){
    //   std::cout << "512" << '\n';
    // }

    int flag;
    int count=0;
    for(int i=9;i>=0;i--){
      if(count==2)break;
      if(weight[i]==1){
        flag=i;
        count++;
      }
    }

    if(count==1){
      std::cout << pow(2,flag) << '\n';
    }else{
      for(int i=0;i<=flag;i++){
        if(weight[i]==1){
          std::cout << pow(2,i) << " ";
        }
      }
      for(int i=9;i>=0;i--){
        if(weight[i]==1){
          std::cout << pow(2,i) << '\n';
          break;
        }
      }

    }



  }
}


Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int H, W; cin >> H >> W;
    vector<string> G(H);
    rep(i, H) {
        cin >> G.at(i);
    }
    int x = 0, y = 0;
    int dir = 0; // 0: right 1: down
    set<pair<int,int>> S;
    S.insert({0,0});
    bool possible = true;
    while (1) {
        if (x < W - 1 && y < H - 1 && G[y][x + 1] == '#' && G[y+1][x] == '#') {
            possible = false;
            break;
        } 
        if ((dir == 0 && y > 0 && G[y - 1][x] == '#') ||
            (dir == 1 && x > 0 && G[y][x - 1] == '#')) {
            possible = false;
            break;
        }
        if (x == W - 1 && y == H - 1) {
            possible = true;
            break;
        } else if (x >= W || y >= H) {
            possible = false;
            break;
        }
        if (x < W - 1 && G[y][x + 1] == '#') {
            x = x + 1;
            dir = 0;
        } else if (y < H - 1 && G[y+1][x] == '#') {
            y = y + 1;
            dir = 1;
        } else {
            possible = false;
            break;
        }
    }
    if (possible) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin,(x).end()

int main(){
  int n;
  cin >> n;
  cout << ((1+n)*n)/2 << endl;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] l = new int[10000001];
        int s = sc.nextInt();
        int now = s;
        l[s]++;
        for(int i = 2;;i++){
            int tmp = 0;
            if(now % 2 == 0){
                tmp = now/2;
            }else{
                tmp = (3*now)+1;
            }
            if(l[tmp] > 0){
                System.out.println(i);
                break;
            }else{
                l[tmp]++;
                now = tmp;
            }
        }
    }
}


Measured memory_bytes: 62804
#include <bits/stdc++.h>

using namespace std;

const int N = 100500;

int p[N];
int sz[N];


int find(int t) {
  if (p[t] == t)
    return t;
  return p[t] = find(p[t]);
}

void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    p[a] = b;
    sz[b] += sz[a];
  }
}

vector<int> gb[N];

int res[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  iota(p, p + N, 0);
  fill(sz, sz + N, 1);

  int n; cin >> n;

  int nf, nb; 
  cin >> nf >> nb;

  int a, b;
  while(nf-- ) {
    cin >> a >> b;
    --res[a];
    --res[b];
    unite(a, b);
  }
  while(nb-- ) {
    cin >> a >> b;
    gb[a].push_back(b);
    gb[b].push_back(a);
  }

  for (int i = 1; i <= n; ++i) {
    int id = find(i);
    res[i] += sz[id] - 1;

    for (int b : gb[i])
      if (id == find(b))
        --res[i];
  }

  cout << res[1];
  for (int i = 2; i <= n; ++i)  cout << " " << res[i];
  cout << endl;
}


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>

#define ll long long

using namespace std;

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    int sum=0;
    sum = 100*r + 10 * g + b;
    if(sum % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;
    cin >> n;
    int t[n],x[n],y[n];

    rep(i,n) cin >> t[i] >> x[i] >> y[i];

    bool ans = true;

    if(t[0]<abs(x[0])+abs(y[0])){
        cout << "No" << endl;
        return 0;
    }else{
        int p = t[0]-(abs(x[0])+abs(y[0]));
        if(p%2!=0){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i=1;i<n;i++){
        int time = t[i]-t[i-1];
        if(time<abs(x[i]-x[i-1])+abs(y[i]-y[i-1])){
            ans = false;
            break;
        }else{
            int z = time - (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
            if(z%2!=0){
                ans = false;
                break;
            }
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

char str[21][21];
int vis[21][21];
struct node{
    int x;
    int y;
    int step;
}dot[21];
int dir[][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int n,m;
int ans = 0,res = 0;

int bfs(int x,int y){
    memset(vis,0,sizeof(vis));
    int cnt = 0;
    queue<node> q;
    node n1;
    n1.x = x;
    n1.y = y;
    n1.step = 0;
    vis[x][y] = 1;
    q.push(n1);
    while(!q.empty()){
        n1 = q.front();
        q.pop();
        cnt = max(cnt,n1.step);
        for(int i = 0;i < 4;i++){
            int xt = n1.x+dir[i][0];
            int yt = n1.y+dir[i][1];
            if(xt>=1&&xt<=n&&yt>=1&&yt<=m){
                if(!vis[xt][yt]&&str[xt][yt]=='.'){
                    node n2;
                    n2.x = xt;
                    n2.y = yt;
                    n2.step = n1.step+1;
                    q.push(n2);
                    vis[xt][yt] = 1;
                }
            }
        }
    }
    return cnt;
}

int main(){

    cin >> n >> m;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            cin >> str[i][j];
        }
    }

    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(str[i][j]=='.'){
                res = bfs(i,j);
                ans = max(ans,res);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 764
#include <iostream>
using namespace std;
long long N, A[87], CurrentMoney = 1000;
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N - 1; i++) {
		long long Stocks = 0;
		if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
		CurrentMoney += (A[i + 1] - A[i]) * Stocks;
	}
	cout << CurrentMoney << endl;
}


Measured memory_bytes: 3616
<?php
	$n = trim( fgets( STDIN ) );
	$nums = explode( " ", trim( fgets( STDIN ) ) );
	$output = [];
	for( $i=0; $i<$n; $i++ ) {
		$key = $nums[$i];
		$j = $i - 1;
		while( 0 <= $j && $key < $nums[$j] ) {
			$nums[$j+1] = $nums[$j];
			$j--;
		}
		$nums[$j+1] = $key;
		array_push( $output, implode( ' ', $nums ) );
	}
	print implode( PHP_EOL, $output );
?>

Measured memory_bytes: 15496
#include<bits/stdc++.h>
using namespace std;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }
  int bnum = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (c[i][j] == '#')
        bnum++;
    }
  }
  int ans = 0;
  for (int i = 0; i < (1<<h); i++) {
    for (int j = 0; j < (1<<w); j++) {
      int b = bnum;
      for (int col = 0; col < h; col++) {
        for (int row = 0; row < w; row++) {
          if (!(j>>row&1) && !(i>>col&1)) continue;
          if (c[col][row] == '#')
            b--;
          }
      }
      if (b == k) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3580
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
	string s;
	cin >> s;
	for (int i = 0;i < s.length() - 1;++i) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 764
import Data.Array.IArray

f :: Char -> (Int, [(Int,Int)]) -> (Int,Char) -> (Int, [(Int,Int)])
f c (a, r) (i,x) =
    if c == x then (a+1, r) else (0, (i, a):r) 

ceilDiv :: Integral a => a -> a -> a
ceilDiv t s = (t + s - 1) `div` s

solve :: String -> [Int]
solve s = zipWith (+) (elems ar) (elems al)
  where
    n = length s
    rs = snd . foldl (f 'R') (0,[]) $ zip [0..] s
    ls = snd . foldr (flip (f 'L')) (0,[]) $ zip [0..] s
    rs' = concatMap (\(i,v) -> [(i-1,v `ceilDiv` 2),(i,v `div` 2)]) rs
    ls' = concatMap (\(i,v) -> [(i,v `div` 2),(i+1,v `ceilDiv` 2)]) ls
    ar = accumArray (+) 0 (0,n-1) rs' :: Array Int Int
    al = accumArray (+) 0 (0,n-1) ls' :: Array Int Int

main :: IO ()
main = getLine >>= mapM_ print . solve


Measured memory_bytes: 27132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll A[2010];
ll dp[2010][2010];
vector<pll> as;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        as.push_back(pll{A, i});
    }
    sort(as.begin(), as.end());
    ll ans = 0;
    for(int len = N - 1; len >= 0; len--){
        for(int l = 0; l + len < N; l++){
            ll r = l + len;
            ll val = as[len].first;
            ll idx = as[len].second;
            chmax(dp[l + 1][r], dp[l][r] + val * abs(l - idx));
            chmax(dp[l][r - 1], dp[l][r] + val * abs(r - idx));
            chmax(ans, dp[l + 1][r]);
            chmax(ans, dp[l][r - 1]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26364
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int n,m,cnt;

main()
{
        cin>>n>>m;
        vector<pair<int,int>> p(n+10);
        p[0].second=1;
        for(auto &it : p)it.first=true;

        int t;
        rep(i,m)
        {
                cin>>t;
                p[t].first=false;
        }

        rep(i,n)
        {
                if(!p[i].first)continue;

                p[i+1].second=(p[i+1].second+p[i].second%mod)%mod;
                p[i+2].second=(p[i+2].second+p[i].second%mod)%mod;
        }

        //debug
        //for(auto it : p)printf("%d %d %d\n",cnt++,it.first,it.second);

        cout<<p[n].second<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;

int main(){
  int a, b, c, t;
  cin >> a >> b >> c;
  if (a>b){
    t = a; a = b; b = t;
  }
  if (b>c){
    t = b; b = c; c = t;
  }
  if (a>b){
    t = a; a = b; b = t;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	vector<int> v{A,B,C};
	sort(ALL(v),greater<int>());
	int counter =0;
	while(v[1]!=v[0] && v[1] != v[0] - 1){
		v[1]+= 2;
		counter++;
	}
	while(v[2]!=v[0] && v[2] != v[0] - 1){
		v[2]+= 2;
		counter++;
	}
	if (v[0] == v[1] && v[0] == v[2]){
		cout << counter <<endl;
	}
	else if (v[0] == v[1] || v[0] == v[2]){
		cout << counter+2 << endl;
 	}
	else{
		cout << counter+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<(N);I++)
#define REPP(I, N) for(int I=1;I<=(N);I++)
#define SZ(x) (int)(x).size()
#define P pair<int, int>
#define F first
#define S second
#define PB(x) push_back(x)
#define endl "\n"
#define ll long long
//#define int long long

//===================================================//

#define N 100000
#define modn 1000000007

using namespace std;
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
int a,b,c;
int32_t main(void){
    scanf("%d%d%d",&a,&b,&c);
    for(int i=0;i<=a;++i) for(int j=0;j<=b;++j){
        if( i*(b-j) + j*(a-i) == c ){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
int main(){
	LL x,y;
	int i;
	scanf("%lld",&x);
	y=100;
	for(i=1;i<=4000;i++){
		y=y+y*0.01;
		if(y>=x)break;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 1696