akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAXN 300005
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
int n,m,sum[MAXN];
struct node{
    int l,r;
}a[MAXN];
vector<int>v[MAXN];
int lowbit(int x){
    return x&-x;
}
void add(int x,int y){
    while(x<=m){
        sum[x]+=y;
        x+=lowbit(x);
    }
}
int query(int x){
    int ans=0;
    while(x){
        ans+=sum[x];
        x-=lowbit(x);
    }
    return ans;
}
int main(){
    while(~scanf("%d%d",&n,&m)){
        memset(sum,0,sizeof(sum));
        rep(i,1,m){
            v[i].clear();
        }
        rep(i,1,n){
            scanf("%d%d",&a[i].l,&a[i].r);
            int temp=a[i].r-a[i].l+1;
            v[temp].push_back(i);
        }
        rep(i,1,m){
            int ans=0,len=v[i].size();
            rep(j,0,len-1){
                int pos=v[i][j];
                add(a[pos].l,1);
                add(a[pos].r+1,-1);
            }
            for(int j=i;j<=m;j+=i){
                ans+=query(j);
            }
            n-=len;
            printf("%d\n",ans+n);
        }
    }
    return 0;
}

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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll=long long;

const int INF = 100000000;

int main(){
    string s,t;
    cin >> s >> t;
    for (int i = 0; i <s.size() ; ++i) {
        if (s[i]!=t[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int a;
  cin >> a;
  int ans = a + pow(a, 2) + pow(a, 3);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 4024
N,M = map(int,input().split())
H = list(map(int,input().split()))
H.insert(0,0)
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
cnt = 0
for i in range(1,N+1):
    flag = 0
    for j in G[i]:
        if H[j]>=H[i]:
            flag=1
            break
    if flag==0:
        cnt += 1
print(cnt)

Measured memory_bytes: 94688
def check(first,second)
  amari = (first*second)%2
  if amari == 1 then
    judge = "Odd"
  else
  	judge = "Even"
  end
  return judge
end

inputstr=gets
one,two=inputstr.strip.split.map(&:to_i)
answer = check(one,two)
print(answer)

Measured memory_bytes: 1788
# ABC074 D - Restoring Road Network
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if a[i][j]>a[i][k]+a[k][j]:
                print(-1)
                exit()
"""
a[i][j]が、i,kを除く全てのkについて
a[i][j]<a[i][k]+a[k][j]なら
a[i][j]は最短経路となる。
"""
ans=0
for i in range(n):
    for j in range(i+1,n):
        # iとjの間に辺が存在する場合True
        flg=True
        for k in range(n):
            if i==k or j==k:
                continue
            if a[i][j]==a[i][k]+a[k][j]:
                flg=False
                break
        if flg:
            ans+=a[i][j]
print(ans)

Measured memory_bytes: 44252
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int ans;
        for(int i = 0, a; i < 5; i++){
            cin >> a;
            if(!a){
                ans = i + 1;
            }
        }
        cout << ans << '\n';
    }
}

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

#define ll long long
#define pb push_back

int ans[2003][2003];
deque < int > v;
int sti1, sti2, fii1, fii2;

main() {
    int n = 37 * 38 + 1;
//    freopen("inp.in", "w", stdout);
    int k = 38;
    printf ("%d %d\n", n, k);
    int cnt = 2;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            if (j == 1) {
                ans[i][j] = 1;
            } else {
                ans[i][j] = cnt++;
            }
        }
    }
    int add = k - 1;
    sti1 = 2, fii1 = k;
    for (int i = 2; i <= k; i++) {
        for (int j = 2; j <= k; j++) {
            v.pb(ans[j][i]);
        }
    }
    for (int i = k + 1; i <= k + add; i++) {
        ans[i][1] = 2;
        for (int j = 2; j <= k; j++) {
            ans[i][j] = v.front();
            v.pop_front();
        }
    }
    sti1 = k + 1, fii1 = sti1 + add - 1;
    sti2 = sti1 + add, fii2 = sti2 + add - 1;
    cnt = 3;
    int xi = sti1;
    int res = 0;
    int cn = 0;
//    cout << sti1 << ' ' << fii1 << endl;
//    cout << sti2 << ' ' << fii2 << endl;
    for (int i = sti2; i <= n; i++) {
        ans[i][1] = cnt;
        res++;
        v.clear();
        int ri = sti1 + cn;
        int rj = 2;
        for (int j = 2; j <= k; j++) {
            v.pb(ans[ri][j]);
            ri++;
            if (ri > fii1) {
                ri = sti1;
            }
        }
        for (int j = 2; j <= k; j++) {
            ans[i][j] = v[j - 2];
        }
        cn++;
        if (res >= add) {
            sti1 = sti2;
            fii1 = fii2;
            sti2 = fii1 + 1;
            fii2 = sti2 + add - 1;
            res = 0;
            cnt++;
            cn = 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            printf ("%d ", ans[i][j]);
        }
        puts("");
    }
}


Measured memory_bytes: 11776
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 

using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define vi vector<int> 
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}

const int INF = 1e18, MAXN = 2e5 + 10, MOD = 1e9 + 7;

void solve() {
 	int n, cnt = 0, sum = 0, _min = INF; 
 	cin >> n;
 	vi a(n);
 	for (int i = 0; i < n; ++i) {
 	 	cin >> a[i];
 	 	if (a[i] < 0) {
 	 	    cnt++;
 	 	}
 	 	sum += abs(a[i]);
 	 	_min = min(_min, abs(a[i]));
 	}

    if (cnt % 2 == 0) {
     	cout << sum << endl;
	}
	else {
	 	cout << sum - 2 * _min << endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
// #define mdfs
string N,M;

int main(void){
    // Your code here!
    cin >> N >> M;
    string s = N + M;
    int t = stoi(s);
    int rt = sqrt(t);
    if ((rt*rt) == t) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , m , ok[N] , remain[N];

int main(){
  cin >> n >> m;
  rep(i,1,n+1) remain[i] = 1;
  ok[1] = 1;
  rep(i,0,m) {
    int x,y;
    cin >> x >> y;
    ok[y] |= ok[x];
    remain[y]++;
    if(!--remain[x]) ok[x] = 0;
  }
  int ans = 0;
  rep(i,1,n+1) ans += ok[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
h = [int(i) for i in input().split()]
dp = [10 ** 5 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[1] - h[0])
    else:
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i])
                    , dp[i-1] + abs(h[i-1] - h[i]))
print(dp[n-1])

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

int p;
bool aceFlg; //ツエツーツスツつェ11ツづつオツづカツウツδ督トツつウツづェツづづゥツフツδ可グ
bool printFlg;
char card[128];

void add(char ch){
	if(ch == 'A'){
		if(p+11 <= 21){
			p += 11;
			aceFlg = true;
		}else{
			p++;
		}
	} else{
		p += card[ch];
	}
}

int main(void){
	for(int i=2;i<10;i++) card['0'+i] = i;
	card['T'] = card['J'] = card['Q'] = card['K'] = 10;

	int n;
	cin>>n;

	while(n--){
		p = aceFlg = 0;
		printFlg = true;
		char a,b;
		cin>>a>>b;

		add(a);
		add(b);
		if(p == 21){
			cout<<"blackjack\n";
			printFlg = false;
		}

		for(int i=0;i<8;i++){
			char ch;
			cin>>ch;
			if(!printFlg) continue;

			if(p <= 16 || p == 17 && aceFlg){
				add(ch);
				if(p > 21 && aceFlg){
					p -= 10;
					aceFlg = false;
				}
				if(p > 21){
					cout<<"bust\n";
					printFlg = false;
				}
			}
		}

		if(printFlg){
			cout<<p<<endl;
		}
	}

	return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'

/* gdc(a,b,c) = gcd(a, (gcd(b,c))) */

int main () {
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n;
	// stops reading at the first non-numeric character, which is the newline
	cin >> n;

	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				sum += gcd(i, gcd(j, k));
			}
		}
	}

	cout << sum;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int f(int a,int b){
    if(a<b) return 0;
    if(a%b==0) return a/b;
    ll can=(a-a/b*b)/(a/b+1)+1,can2;
    ll c=a/b+1,d=a%b;
    if(d%c==0) can2=d/c;
    else{
        ll g=gcd(c,d);
        c/=g;
        d/=g;
        can2=d*rui(c,b-2);
    }
    return f(a-(a/b+1)*min(can,can2),b);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int grundy=0;
    
    while(N--){
        int a,b;cin>>a>>b;
        grundy^=f(a,b);
    }
    
    if(!grundy) cout<<"Aoki"<<endl;
    else cout<<"Takahashi"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline
import itertools

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a = [0] + list(itertools.accumulate(a))
b = [0] + list(itertools.accumulate(b))


ans = 0
for i in range(n+1):
    if a[i] > k:
        break
    else:
        idx = bisect.bisect_right(b, k-a[i])
        # print(i, k-a[i], idx)
        ans = max(ans, i+idx-1)

print(ans)



Measured memory_bytes: 131220
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<int(n);i++)

const ll MOD=1000000007;

int n;
int a[3][3];
int b[20];
bool bin[3][3];
void input() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0;j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
}

void solve(){
	for (int i = 0; i < n; i++) {
		for (int p = 0; p < 3; p++) {
			for (int q = 0; q < 3; q++) {
				if (b[i] == a[p][q]) bin[p][q] = true;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		if (bin[i][0] && bin[i][1] && bin[i][2]) {
			cout << "Yes" << endl;
			return;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (bin[0][i] && bin[1][i] && bin[2][i]) {
			cout << "Yes" << endl;
			return;
		}
	}
	if (bin[0][0] && bin[1][1] && bin[2][2]) {
		cout << "Yes" << endl;
		return;
	}
	if (bin[0][2] && bin[1][1] && bin[2][0]) {
		cout << "Yes" << endl;
		return;
	}
		cout << "No" << endl;
}


int main() {
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=305;

int n;
double dp[N][N][N];
double dfs(int a,int b,int c)
{
	if(!a && !b && !c) return 0;
	if(dp[a][b][c]) return dp[a][b][c];
	if(a) dp[a][b][c]+=a/(a+b+c+0.0)*dfs(a-1,b,c);
	if(b) dp[a][b][c]+=b/(a+b+c+0.0)*dfs(a+1,b-1,c);
	if(c) dp[a][b][c]+=c/(a+b+c+0.0)*dfs(a,b+1,c-1);
	dp[a][b][c]+=n/(a+b+c+0.0);
	return dp[a][b][c];
}

int main()
{
	
	scanf("%d",&n);
	int a=0,b=0,c=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x==1) a++;
		if(x==2) b++;
		if(x==3) c++; 
	}
	printf("%.15f\n",dfs(a,b,c));
	
	return 0;
}

Measured memory_bytes: 219520
#include<bits/stdc++.h>
using namespace std;
int a,b,k;
int main()
{
    vector<int>v;
    cin>>a>>b>>k;
    for(int i=1;i<=100;i++){
        if((a%i==0)&&(b%i==0)){v.push_back(i);}
    }
    sort(v.begin(),v.end(), greater<int>());
    cout<<v[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long N = sc.nextLong();

    long ret = Integer.MAX_VALUE;
    for (long i = 1; i <= Math.sqrt(N) + 0.1; i ++) {
      if (N % i == 0) {
        ret = Math.min(ret, (int)Math.log10(N / i));
      }
    }
    System.out.println(ret + 1);
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a;
    cin, a;
    print(a + a * a + a * a * a);
    return 0;
}


Measured memory_bytes: 3632
#define A scanf("%"
t[128],a,b;main(n){for(;A"d",&n),n;puts("")){for(;b<128;t[b]=b++);for(;n--;t[a]=b)A"s%s",&a,&b);for(A"d",&n);b=n--;printf("%c",t[a]))A"s",&a);}return 0;}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S, T; cin >> S >> T;
  int ans = 0;
  rep(i, S.length()){
    int res = 0;
    rep(j, T.length()){
      if(i+j >= S.length()){res = 0; break;}
      if(S[i+j] == T[j]) res++;
    }
    ans = max(ans, res);
  }
  cout << T.length()-ans << endl;
  return 0;
}

Measured memory_bytes: 3576
def prime?(a)
  for i in Range.new(2,a,true)
    if a%i == 0 then
      return false
    end
  end
  true  
end

while i=gets 
  i=i.to_i
  buf=i-1
  loop{
    if prime?(buf) 
      print buf 
      break
    end
    buf-=1
  }
  buf=i+1
  loop{
    if prime?(buf) 
      puts ' ' + buf.to_s 
      break
    end 
    buf+=1
  }
end

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    ll x, y, z;
    scanf("%lld %lld %lld", &x, &y, &z);
    ll ans;
    ans = (x-z) / (y+z);
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

int main(){
    int n,m;
    while(cin>>n>>m, n|m){
        vector<bool> infected(n, false);
        vector<pair<int, pair<int, int> > > vec;

        rep(i,m){
            int t,s,d;
            scanf("%d %d %d", &t, &s, &d);
            s--; d--;
            vec.pb(mp(t, mp(s,d)));
        }

        sort(all(vec));

        infected[0]=true;
        int res=1;
        rep(i,m){
            if(infected[vec[i].second.first]){
                int d = vec[i].second.second;
                if(infected[d]) continue;
                infected[d] = true;
                res++;
            }
        }
        cout << res<< endl;
    }

    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
 
using namespace std;
 
int main() {
    int n, m;
    cin >> n; cin >> m;
 
    int ans = 1;
    for(int i=1; i<=m && i * i <= m; i++)
    {
        int k = m / i;
        if(m % k == 0 && m / k >= n)
        {
            ans = max(k, ans);
        }
        if(m % i == 0 && m / i >= n)
        {
            ans = max(i, ans);
        }
    }
 
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

int sum[100100];
int bprime[1000100];

int main() {
  memset(bprime, true, sizeof(bprime));
  bprime[0] = bprime[1] = false;
  for (int i = 2; i < 1000000; i++) {
    if (!bprime[i]) { continue; }
    for (int j = i + i; j < 1000000; j += i) {
      bprime[j] = false;
    }   
  }
  sum[0] = 0;
  for (int i = 1; i < 1000000; i++) {
    sum[i] = sum[i - 1] + (bprime[i] ? 1 : 0); 
  }
  int n;
  while (scanf("%d", &n) > 0) {
    printf("%d\n", sum[n]);
  }
}

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

using namespace std;

typedef long long LL;
const int len = 60;
LL n,a[len],k;

int main() {
	ios :: sync_with_stdio(false);
	cin >> k;
	n = 50;
	for (int i=1;i<=n;i++) {
		a[i] = n-1+k/n;
	}
	LL sum = k%n;
	for (int i=1;i<=sum;i++) {
		LL mx = 1e18+10;
		int p;
		for (int j=1;j<=n;j++) {
			if (a[j] < mx) {
				mx = a[j];
				p = j;
			}
		}
		a[p] += n;
		for (int j=1;j<=n;j++) {
			if (j != p) a[j] -= 1;
		}
	}
	cout << n << endl;
	for (int i=1;i<=n;i++) {
		cout << a[i] << ' ';
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s; cin >> s;
    int len = s.size();
    int sum=0;
    for(int i=0; i<len; i++){
        sum+=s[i]-'0';
    }
    if(sum%9==0){cout << "Yes\n";}
    else{cout << "No\n";}
    return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define INF 1e9
#define MAX_N 100001

using namespace std;

struct Card{
  char c;
  int num;
};

int n;
Card A[100001], B[100001];
int comp;
Card l[MAX_N/2+2];
Card r[MAX_N/2+2];

void merge(int left, int right, int mid){
  rep(i, mid-left){
    l[i] = B[left + i];
  }
  rep(i, right-mid){
    r[i] = B[mid + i];
  }

  l[mid-left].num = r[right-mid].num = INF;
  
  int left_idx, right_idx;
  left_idx = right_idx = 0;
  REP(i,left,right){
    comp++;
    if(l[left_idx].num <= r[right_idx].num){
      B[i] = l[left_idx];
      left_idx++;
    }else{
      B[i] = r[right_idx];
      right_idx++;
    }
  }
}

void mergeSort(int left, int right){
  if(right - left > 1){
    int mid = (right + left)/2;
    mergeSort(left, mid);     // 左
    mergeSort(mid, right);    // 右
    merge(left, right, mid);  // マージ
  }
}

int partition(int p, int r){
  int i;
  i = p-1;
  REP(j, p, r){
    if(A[j].num <= A[r].num){
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  
  return i+1;
}

void quickSort(int p, int r){
  if(r - p > 0){
    int ret = partition(p, r);
    quickSort(p, ret-1);
    quickSort(ret+1, r);
  }
}

bool compare(Card l, Card r){
  return (l.num <= r.num);
}

signed main(){

  cin >> n;
  rep(i, n){
    cin >> A[i].c >> A[i].num;    
    B[i].c = A[i].c;
    B[i].num = A[i].num;
  }
  
  quickSort(0, n-1);
  mergeSort(0, n);

  bool flag = false;
  rep(i, n){
    if(A[i].c != B[i].c) flag = true;
  }
  
  if(flag) cout << "Not stable" << endl;
  else cout << "Stable" << endl;

  rep(i, n){
    cout << A[i].c << " " << A[i].num << endl;
  }

}


Measured memory_bytes: 5452
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+5;
const double eps=1e-10;
int tot;
int head[MAXN];
int n,m;

struct Edge
{
    int from,to,nxt;
}e[MAXN];

void addedge(int u,int v)
{
    e[tot].from=u;
    e[tot].to=v;
    e[tot].nxt=head[u];
    head[u]=tot++;
}

bool dfs(int s,int t,int k)
{
    if(s==n&&k==2) return true;
    for(int i=head[s];i!=-1;i=e[i].nxt)
    {
        int to=e[i].to;
        if(dfs(to,n,k+1)) return true;
    }
    return false;
}

int main()
{
    int d,k;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(head,-1,sizeof(head));
        int u,v;
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d",&u,&v);
            addedge(u,v);
        }
        if(dfs(1,n,0))
            printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int main() {
    ll n,m;
    cin>>n>>m;
    UnionFind<int> uf(n+1);
    rep(i,m){
        ll l,r,d;
        cin>>l>>r>>d;
        if (uf.root(r)!=uf.root(l)){
            uf.merge(l,r,d);
        }
        else{
            if (uf.diff(l,r)!=d){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}
//...

Measured memory_bytes: 1408
int main()
{
	char s[10];
	scanf("%s",s);
	if (strcmp(s, "Sunny") == 0)
		printf("Cloudy");
	else if (strcmp(s, "Cloudy") == 0)
		printf("Rainy");
	else if (strcmp(s, "Rainy") == 0)
		printf("Sunny");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

double dp[305][305][305];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int cnt[4] = {0};
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	for(int k = 0; k <= cnt[3]; k++) {
		for(int j = 0; j <= cnt[2] + cnt[3]; j++) {
			for(int i = 0; i <= n; i++) {
				if(i + j + k == 0) {
					dp[i][j][k] = 0;
				}
				else {
					dp[i][j][k] = 1;
					if(i >= 1) {
						dp[i][j][k] += (1.0 * i / n) * dp[i - 1][j][k];
					}
					if(j >= 1) {
						dp[i][j][k] += (1.0 * j / n) * dp[i + 1][j - 1][k];
					}
					if(k >= 1) {
						dp[i][j][k] += (1.0 * k / n) * dp[i][j + 1][k - 1];
					}
					dp[i][j][k] /= (1 - (1.0 * (n - i - j - k) / n));
				}
			}
		}
	}
	cout << fixed << setprecision(12) << dp[cnt[1]][cnt[2]][cnt[3]];

	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	multiset<int> S;

	int n;
	scanf("%d", &n);
	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);
		S.insert(x);
	}

	int m;
	scanf("%d", &m);
	FOR (i, 0, m)
	{
		int x;
		scanf("%d", &x);
		if (S.find(x) == S.end())
		{
			cout<<"NO"<<endl;
			return 0;
		}

		S.erase(S.find(x));
	}

	cout<<"YES"<<endl;

}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] str = sc.nextLine().split(" ");
    int[] ans = new int[N];
    ans[0] = 0;
    for (int i = 1; i < N; i++) {
      ans[i] = Integer.MAX_VALUE;
    }

    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j <= i + 2 && j < N; j++) {
        ans[j] = Math.min(ans[j], Math.abs(Integer.parseInt(str[j]) - Integer.parseInt(str[i]))+ans[i]);
      }
    }
    System.out.println(ans[N - 1]);
  }
}


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

int main(){
    int k,x;cin >> k >> x;
    int ans;

    if((x - k + 1) >= -1000000){
        for(int i = x-k+1 ; i <= x ; i++ ){
            cout << i;
            cout << " ";
        }
    }else if((x-k+1) < -1000000){
        for(int i = -1000000 ; i <= x; i++){
            cout << i;
            cout << " ";
        } 
    }
     if((x + k - 1) <= 1000000){
        for(int i = x + 1 ; i <= x + k -1 ; i++ ){
            cout << i;
            cout << " ";
        }
    }else if((x+k-1) > 1000000){
        for(int i = x + 1 ; i <= 1000000; i++){
            cout << i;
            cout << " ";
        } 
    }
    cout << "\n";
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int cnt0 = 0, cnt1 = 0;
vector<int> chr;

void depth(int now, int prev, int d, const vvi &g) {
  if(d%2) {
    cnt1++;
    chr[now] = 1;
  } else {
    cnt0++;
    chr[now] = 0;
  }

  for(int i=0;i<SZ(g[now]);++i) {
    int nxt = g[now][i];
    if(nxt == prev) continue;
    depth(nxt, now, d+1, g);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  chr.resize(n, 0);
  vvi g(n);
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  depth(0, -1, 0, g);

  int val0 = n/3, val1 = n/3 + (n%3 >= 1), val2 = n/3 + (n%3 >= 2);

  if(val1 < val2 != cnt0 < cnt1) {
    for(int i=0;i<n;++i) {
      chr[i] = !chr[i];
    }
  }

  if(min(val1, val2) > min(cnt1, cnt0)) {
    int id1 = 1, id2 = 2, id0 = 3;
    int use0 = 0, use1 = 0, use2 = 0;
    if(val1 < val2) {
      for(int i=0;i<n;++i) {
        if(chr[i] == 0) chr[i] = 2;
      }
    } else {
      for(int i=0;i<n;++i) {
        if(chr[i] == 1) chr[i] = 2;
      }
    }

    for(int i=0;i<n;++i) {
      if(chr[i] == 2) {
        cout << id0 << " ";
        id0 += 3;
      } else {
        if(use1 < val1) {
          cout << id1 << " ";
          id1 += 3;
          use1++;
        } else if(use2 < val2) {
          cout << id2 << " ";
          id2 += 3;
          use2++;
        } else {
          cout << id0 << " ";
          id0 += 3;
        }
      }
    }
    return 0;
  }
  
  

  //cerr << val1 << " " << val2 << endl;
  //cerr << cnt0 << " " << cnt1 << endl;

  int id1 = 1, id2 = 2, id0 = 3;
  int use1 = 0, use2 = 0;
  for(int i=0;i<n;++i) {
    if(chr[i]) {
      if(use2 < val2) {
        cout << id2 << " ";
        id2 += 3;
        use2++;
      } else {
        cout << id0 << " ";
        id0 += 3;
      }
    } else {
      if(use1 < val1) {
        cout << id1 << " ";
        id1 += 3;
        use1++;
      } else {
        cout << id0 << " ";
        id0 += 3;
      }
    }
  }
  cout << endl;
  //cout << use1 << " " << use2 << endl;

}


Measured memory_bytes: 19712
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<list>
#include<numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vint;
typedef vector<char> vchar;

#define intmax 2000000014;
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define intn(n, a) rep(i, n)scanf("%d", &a[i]);
#define int2n(n, a, b) rep(i, n)scanf("%d%d", &a[i], &b[i]);
#define pfi(x) printf("%d\n", x)
#define pfii(x, y) printf("%d %d\n", x, y)
#define pfiii(x, y, z) printf("%d %d %d\n", x, y, z)
#define pfl(x) printf("%lld\n", x)
#define pfll(x, y) printf("%lld %lld\n", x, y)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------");
#define debug(x) cout << " --- " << x << "\n"
#define debugi(x) printf(" --- %d\n", x)
#define debugii(x, y) printf(" --- %d %d\n", x, y)
#define debugin(i, n, a) rep(i, n)printf(" --- %d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define debugl(x) printf(" --- %lld\n", x)

int i, j;
signed main(void){
  int(m);
  rep(i, m){
    string s;
    cin >> s;
    set<string> ss;
    rep1(j, s.size()){
      string a, b, ar, br;
      a = s.substr(0, j); ar = a; reverse(all(ar));
      b = s.substr(j); br = b; reverse(all(br));
      ss.insert(a + b); ss.insert(b + a);
      ss.insert(ar + b); ss.insert(b + ar);
      ss.insert(a + br); ss.insert(br + a);
      ss.insert(ar + br); ss.insert(br + ar);
    }
    cout << ss.size() << "\n";
  }

  return 0;
}

Measured memory_bytes: 1316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
    public static void main (String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int[] cntValues = new int[101];
	String line;
	int value, max = 0;
	while ((line = br.readLine()) != null) {
	    value = Integer.parseInt(line);
	    cntValues[value]++;
	    if (cntValues[value] > max) {
		max = cntValues[value];
	    }
	}
	for (int i = 1; i < 101; i++) {
	    if (cntValues[i] == max) {
		System.out.println(i);
	    }
	}
    }
}

Measured memory_bytes: 24264
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	vector<int>A(3);
	for (int i = 0; i < 3; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	
	cout << (A[1] - A[0]) + (A[2] - A[1]) << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

#define MAX 100001

typedef struct{
  int parnodnm;
  int sibling;
  int degree;
  int child[2];
  int depth;
  int height;
  int typ;
}Node;

Node T[MAX];

int calcudepth(int u){
  int d = 0;
  while(T[u].parnodnm != -1){
    u = T[u].parnodnm;
    d++;
  }
  return d;
}

int calcuheight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].child[0] != -1)
    h1 = calcuheight(T[u].child[0]) + 1;
  if(T[u].child[1] != -1)
    h2 = calcuheight(T[u].child[1]) + 1;
  
  return h1 > h2 ? h1 : h2;
}

int main(){
  int nm, i, j, nodnm;
  int flag = 0;
  int D[MAX];
  
  scanf("%d", &nm);
  
  for(i = 0; i < nm; i++){
    T[i].parnodnm = -1;
    T[i].sibling = -1;
    T[i].typ = 2;
  }
  for(i = 0; i < nm; i++){
    scanf("%d", &nodnm);
    T[nodnm].degree = 2;
    flag = 0;
    for(j = 0; j <2; j++){
      scanf("%d", &T[nodnm].child[j]);
      if(T[nodnm].child[j] == -1){
	flag++;
	T[nodnm].degree--;
      }
      T[T[nodnm].child[j]].parnodnm = nodnm;
    }
    if(flag == 2) T[nodnm].typ = 1;
    T[T[nodnm].child[0]].sibling = T[nodnm].child[1];
    T[T[nodnm].child[1]].sibling = T[nodnm].child[0];
  }
  
  for(i = 0; i < nm; i++)
    if(T[i].parnodnm == -1) T[i].typ = 0;
  
  for(i = 0; i < nm; i++) T[i].depth = calcudepth(i);
  
  for(i = 0; i < nm; i++){
    if(T[i].typ == 0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, T[i].parnodnm, T[i].sibling, T[i].degree, T[i].depth, calcuheight(i));
    else if(T[i].typ == 1)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", i, T[i].parnodnm, T[i].sibling, T[i].degree, T[i].depth, calcuheight(i));
    else if(T[i].typ == 2)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", i, T[i].parnodnm, T[i].sibling, T[i].degree, T[i].depth, calcuheight(i)); 
  }
  
  return 0;
}



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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0;
    for(int i = 1; i <= n; i++){
        if(i < 10){
            if(i >= a && i <= b){
                sum += i;
            }
        }else if(i >= 10 && i < 100){
            int tmp = (i / 10) + (i % 10);
            if(tmp >= a && tmp <= b){
                sum += i;
            }
        }else if(i >= 100 && i < 1000){
            int tmp = (i / 100) + ((i % 100) / 10) + (i % 10);
            if(tmp >= a && tmp <= b){
                sum += i;
            }
        }else if(i >= 1000 && i < 10000){
            int tmp = (i / 1000) + ((i % 1000) / 100) + ((i % 100) / 10) + (i % 10);
            if(tmp >= a && tmp <= b){
                sum += i;
            }
        }else if(i >= 10000){
            int tmp = (i / 10000) + ((i % 10000) / 1000) + ((i % 1000) / 100) + ((i % 100) / 10) + (i % 10);
            if(tmp >= a && tmp <= b){
                sum += i;
            }
        }
    }
    cout << sum << '\n';
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int n;
	cin >> n;

	int old = 0;
	int flg = 0;
	int cnt = 1;

	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		if (i == 0)
		{
			old = a;
			continue;
		}

		if (old == a)
		{

		}
		else if (old < a)
		{
			if (flg == -1)
			{
				cnt++;
				flg = 0;
			}
			else
			{
				flg = 1;
			}
		}
		else
		{
			if (flg == 1)
			{
				cnt++;
				flg = 0;
			}
			else 
			{
				flg = -1;
			}
		}

		old = a;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main { 
public static void main(String args[]) { 
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
if(n>m){
   System.out.println("a > b"); 
}
if(n<m){
   System.out.println("a < b"); 
}
if(n==m){
   System.out.println("a == b"); 
}
 } }


Measured memory_bytes: 26276
#include<bits/stdc++.h>
using namespace std;
typedef pair< int , int >PII;
const int MAXN = 1<<18;

int V[MAXN], W[MAXN];
int bap[MAXN];
vector<PII>options[MAXN];
//vector<PII>options[MAXN];

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

    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
    int z = sqrt(N); z = max(z, 1);

    options[1].emplace_back(0, 0);
    options[1].emplace_back(W[1], V[1]);
    for (int i = 2; i <= z; i++) {
        int par = i/2;
        options[i] = options[par];
        for (PII p : options[par]) {
            options[i].emplace_back(p.first+W[i], p.second+V[i]);
        }
        sort(options[i].begin(), options[i].end());
    }
    for (int i = z+1; i <= N; i++) {
        int par = i/2;
        if (par > z) {
            bap[i] = bap[par];
            vector< PII >with = options[par];
            for (PII &p : with) {
                p.first += W[i];
                p.second += V[i];
            }
            merge(options[par].begin(), options[par].end(), with.begin(), with.end(), back_inserter(options[i]));
//            sort(options[i].begin(), options[i].end());
        } else {
            bap[i] = par;
            options[i].emplace_back(0, 0);
            options[i].emplace_back(W[i], V[i]);
        }
    }
    for (int i = 1; i <= N; i++) {
//        cout << i;
//        if (i <= z) cout << " inside" << endl;
//        else cout << " outside" << endl;
//        for (PII p : options[i]) {
//            cout << p.first << "," << p.second << ":";
//        }
//        cout << endl;
        for (int j = 1; j < options[i].size(); j++) {
            options[i][j].second = max(options[i][j].second, options[i][j-1].second);
        }
    }

    int q;
    cin >> q;
    while (q--) {
        int v, L;
        cin >> v >> L;

        if (v <= z) {
            int idx = lower_bound(options[v].begin(), options[v].end(), PII(L+1, -1))-options[v].begin();
            idx--;
            assert(idx >= 0);
            cout << options[v][idx].second << "\n";
        } else {
            int p = bap[v];
            int mx = 0;
            for (int i = 0, j = options[p].size()-1; i < options[v].size() && options[v][i].first <= L; i++) {
                while (options[v][i].first+options[p][j].first > L) {
                    j--;
                }
                mx = max(mx, options[v][i].second+options[p][j].second);
            }
            cout << mx << "\n";
        }
    }


    return 0;
}


Measured memory_bytes: 717152
N, M = map(int, input().split())
Food = [0] * M
for i in range(N):
  A = [int(j) for j in input().split()]
  for j in range(1, A[0] + 1):
    Food[A[j] - 1] += 1
count = 0
for i in range(M):
  if Food[i] == N:
    count += 1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
  
int main(void) {
    int a, b;
    int sum, diff, mul;
    int max;
    scanf("%d%d", &a, &b);

    sum = a + b;
    diff = a - b;
    mul = a * b;

    max = sum;
    if (diff > max) max = diff;
    if (mul > max) max = mul;

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
	int n,x,i,j,k,sum;
	while(scanf("%d %d\n",&n,&x)!=EOF && (n>0 || x>0)){
		sum=0;
		for(i=n;i>=x/3+1;i--){
			j=x-i;
			if(j<3){continue;}
			if(j>i){
				sum+=i-j/2-1;
			}else{
				sum+=j/2-1+j%2;
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 604