akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==5 && b==5 && c==7) printf("YES\n");
  else if(a==5 && b==7 && c==5) printf("YES\n");
  else if(a==7 && b==5 && c==5) printf("YES\n");
  else printf("NO\n");
  return(0);
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    long long int  a,b,c,d;
    long long int p,q,r,s;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    p=(a*c);
    q=(a*d);
    r=(b*c);
    s=(b*d);
    if(p>q && p>r && p>s) printf("%lld\n",p);
   else if(q>p && q>r && q>s) printf("%lld\n",q);
   else if(r>q && r>p && r>s) printf("%lld\n",r);
   else
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 1732
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = S()
    for i in n:
        if i == "1":
            print(9, end="")
        else:
            print(1, end="")
    print()
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include<iostream>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m, n) {
		int a[100] = {};
		for (int i = 0; i < n; i++) {
			int b, c; cin >> b >> c;
			if (a[b] < c)a[b] = c;
		}
		int ans = 0;
		for (int i = 1; i <= m; i++)ans += a[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3088
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    s = list(input())

    cnt = 0
    happy = 0
    for i in range(1, n):
        if s[i - 1] != s[i]:
            cnt += 1
        else:
            happy += 1

    kaisu = (cnt + 1) // 2
    tmp = -1 if cnt % 2 else 0

    ans = min(2 * kaisu + tmp, 2 * k)

    print(ans + happy)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n;
	cin >> n;
	int i,j;
	string s;
	char trans[10][5];
	for (int i = 0; i < 4; i++)trans[0][i] = '0';
	trans[1][0] = '.'; trans[1][1] = ','; trans[1][2] = '!'; trans[1][3] = '?';
	for (i = 2; i < 10; i++) {
		for (j = 0; j < 4; j++) {
			if (i != 9 &&i!=7&& j == 3)trans[i][j] = '0';
			else if(i<8) trans[i][j] = 'a' + (i - 2) * 3 + j;
			else trans[i][j] = 't' + (i - 8) * 3 + j;
		}
	}
	char trans1[5] = { '.',',','!','?',' ' };
	for (i = 0; i < n; i++) {
		cin >> s;
		int len = s.length();
		int check = 0;
		int memo = 0;
		for (j = 0; j < len; j++) {
			if (check > 0 && s[j] == '0') {
				if (memo == 1) cout << trans1[(check - 1) % 5];
				else if (memo == 7 || memo == 9) {
					cout << trans[memo][(check-1) % 4];
				}
				else cout << trans[memo][(check-1) % 3];
				check = 0;
			}
			else if (s[j] != '0') {
				memo = s[j] - '0'; check++;
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
# include <stdio.h>
# include <algorithm>


long long N, A, B;

int main(void){
    // Here your code !
    scanf("%lld%lld%lld",&N,&A,&B);

    long long D = B - A;

    if (D < 0) {printf("%d\n", 0); return 0;}

    if (N == 1) {
        if (D == 0) {printf("%d\n", 1); return 0;}
        else {printf("%d\n", 0); return 0;}
    }

    printf("%lld\n", std::max<long long>((1 + (N - 2) * D), 0));
    return 0;
}

Measured memory_bytes: 128
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B) {
    return max(A - 2 * B, 0);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++){
    cin >> X[i];
  }
  vector<int> Y = X;
  sort(Y.begin(), Y.end());
  int a = Y[N / 2 - 1];
  int b = Y[N / 2];
  for (int i = 0; i < N; i++){
    if (X[i] <= a){
      cout << b << endl;
    } else {
      cout << a << endl;
    }
  }
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n";

int main() {
    int x;
    cin >> x;
    OUT(x<1200?"ABC":"ARC")
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  long long n,q;
  cin>>n>>q;
  vector<vector<long long>>c(n+1);
  for(int i=0;i<n-1;i++){
    long long a,b;
    cin>>a>>b;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  vector<long long>ans(n+1);
  for(int i=0;i<q;i++){
    long long a,b;
    cin>>a>>b;
    ans[a]+=b;
  }
  vector<bool>p(n+1);
  p[1]=true;
  queue<long long>qq;
  qq.push(1);
  while(!qq.empty()){
    long long x=qq.front();
    qq.pop();
    for(int i=0;i<c[x].size();i++){
      if(!p[c[x][i]]){
        p[c[x][i]]=true;
        qq.push(c[x][i]);
        ans[c[x][i]]+=ans[x];
      }
    }
  }
  for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 17904
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//scanf("%lld", &h);
    while(h--){ 
            long double h, w, n;
            cin >> h >> w >> n;
            cout << min(ceil(n / h), ceil(n / w)) << endl;     
        }
    }       

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<int> p,t,tl;
    p.resize(n);
    t.resize(n);
    tl.resize(n);
    REP(i,n){
      cin >> p[i];
      cin >> t[i];
      tl[i]=t[i]-p[i];
    }
    tl.push_back(33554432);
    int dp[64][4];
    REP(i,64) REP(j,4) dp[i][j]=1048576;
    
    dp[0][0]=0;
    REP(i,n){
      REP(bal,3){
	if(i && bal && abs(p[i]-p[i-1])*(bal+1)<=t[i]-t[i-1]) dp[i+1][bal+1]=min(dp[i+1][bal+1],dp[i][bal]+abs(p[i]-p[i-1]));
	if(i && !bal && p[i]<=t[i]-t[i-1]) dp[i+1][1]=min(dp[i+1][1],dp[i][bal]+p[i]);
	if(!i && !bal && p[i]<=t[i]) dp[i+1][1]=min(dp[i+1][1],dp[i][bal]+p[i]);
	if(t[i]+p[i]*(bal+2)<=tl[i+1]){
	  dp[i+1][0]=min(dp[i+1][0],dp[i+1][bal+1]+p[i]);
	}
      }
    }
    /*
    REP(i,n+1){
      REP(bal,4){
	if(bal)cout << ' ';
	cout << dp[i][bal];
      }
      cout << endl;
      }*/
    int col;
    for(col=0;col<n+1;col++){
      bool flag=true;
      REP(i,4) if(dp[col][i]<1048576) flag=false;
      if(flag) break;
    }
    if(col==n+1){
      cout << "OK " << dp[n][0] << endl;
    }
    else cout << "NG " << col << endl;
  }
}

Measured memory_bytes: 1220
#include<stdio.h>
int main(void){
int h, w, i, j;
	for(;;){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;
		}
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(i==1||i==h||j==1||j==w){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 1984
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,a,b=map(int,readline().split())
    x=list(map(int,readline().split()))

    ans=0
    for i in range(n-1):
        if b<=a*(x[i+1]-x[i]):
            ans+=b
        else:
            ans+=a*(x[i+1]-x[i])
    
    print(ans)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 14168
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const int MAX_V = 205;

int V;
vector<int> to[MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int x){
    used[x] = true;
    for(auto& y : to[x]){
        int z = match[y];
        if(z < 0 || (!used[z] && dfs(z))){
            match[x] = y;
            match[y] = x;
            return true;
        }
    }
    return false;
}

int largest_matching(){
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v = 0; v < V; v++){
        if (match[v] < 0){
            memset(used, false, sizeof(used));
            if(dfs(v)) res++;
        }
    }
    return res;
}

void display_matching(){
    rep(v, V){
        if(match[match[v]] == v){
            cout << "M: " << v << " & " << match[v] << endl;
        }
    }
}

int main(){
    int n; cin >> n;
    V = n * 2;

    vector<pair<int, int> > red, blue;
    rep(i, n){
        int a, b; cin >> a >> b;
        red.push_back(make_pair(a, b));
    }
    rep(i, n){
        int a, b; cin >> a >> b;
        blue.push_back(make_pair(a, b));
    }

    rep(i, n) rep(j, n){
        if(red[i].first < blue[j].first && red[i].second < blue[j].second){
            to[i].push_back(j + n);
            to[j + n].push_back(i);
        }
    }

    int res = largest_matching();
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <queue>


int main() {

	std::priority_queue<int> q;

	int a;
	int ans = 0;
	int n;
	scanf("%d", &n);


	for (int i = 0; i < n; i++){
		scanf("%d", &a);
		ans += a - 1;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL dp[101][100005];
int a[101];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	REP(i, n)scanf("%d", &a[i]);
	REP(i, k+1)dp[0][i+1] = 1;
	REP(i, n) {
		REP(j, k+1) {
			dp[i + 1][j + 1] = (dp[i + 1][j] + (dp[i][j+1] - dp[i][max(j - a[i], 0)]+MOD)) % MOD;
		}
	}
	cout << (dp[n][k+1] - dp[n][k] + MOD)%MOD << endl;
	return 0;
}

Measured memory_bytes: 79104
n,m = map(int, input().split())
h = list(map(int, input().split()))

good = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if h[a]>=h[b]:
        good[b]=0
    if h[b]>=h[a]:
        good[a]=0
print(good.count(1))

Measured memory_bytes: 84768
#include <cstdio>

#define NMAX 200000
#define SENTINEL 2000000000

typedef long long llong;

int A[NMAX], L[(NMAX / 2) + 2], R[(NMAX / 2) + 2];

llong merge(int left, int mid, int right) {
	llong cnt = 0;
	int nl = mid - left;
	int nr = right - mid;
	for (int i = 0; i < nl; i++) L[i] = A[left + i];
	for (int i = 0; i < nr; i++) R[i] = A[mid + i];
	L[nl] = R[nr] = SENTINEL;
	int j = 0, k = 0;
	for (int i = left; i < right; i++) {
		if (L[j] < R[k]) {
			A[i] = L[j++];
		}
		else {
			A[i] = R[k++];
			cnt += nl - j;
		}
	}
	return cnt;
}

llong mergeSort(int left, int right) {
	llong c1, c2, c3;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		c1 = mergeSort(left, mid);
		c2 = mergeSort(mid, right);
		c3 = merge(left, mid, right);
		return c1 + c2 + c3;
	}
	else {
		return 0;
	}
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", A + i);

	llong cnt = mergeSort(0, n);
	printf("%lld\n", cnt);

	return 0;
}


Measured memory_bytes: 4244
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    string S, T;
    cin>>S>>T;
    bool ans = true;
    for(int i=0;i<S.size();++i){
        if(S[i]!=T[i]) ans = false;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3616
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,m=map(int,input().split())
class UnionFind(): #集合の取り扱い、辺に重み、階層を意識するときは使えない
    def __init__(self,n):
        self.n=n
        self.par = [-1]*n
    def find(self,x):
        if self.par[x] <0: #負なら親、要素数
            return x
        else: #正なら親の番号
            self.par[x]=self.find(self.par[x]) #一回調べたら根を繋ぎ変える、経路圧縮
            return self.par[x]
    def union(self,x,y):
        x=self.find(x) #x,yの親
        y=self.find(y)

        if x==y: #親が同じなら何もしない
            return 
        if self.par[x]>self.par[y]: #要素数が大きい方をxにする
            x,y=y,x
        self.par[x]+=self.par[y] #xがある集合にyが入った集合をくっつける
        self.par[y]=x

    def size(self,x):
        return -self.par[self.find(x)] #親のサイズ
    
    def same(self,x,y): #親が同じ、すなわち同じ集合か
        return self.find(x)==self.find(y)

    def member(self,x): #同じ木（集合）にある要素全部リストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root ]
    
    def roots(self): #集合の根になってる要素をリストで返す
        return [i for i , x in enumerate(self.par) if x<0]
    
    def group_count(self): #集合の数、木の数
        return len(self.roots())

    def all_member(self): #辞書型で返す
        return {r: self.member(r) for r in self.roots()}
    def __str__(self):
        return "\n".join('{}:{}'.format(r,self.member(r)) for r in self.roots)

tree=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    tree.union(a-1,b-1)
print(tree.group_count()-1)

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


using namespace std;
int K;
#define MAXN 200010
int N;
int A[MAXN];


bool can(int target)
{
	int cnt = 0;
	for(int i = 1; i <= N; ++i)
	{
		cnt += ceil((double)A[i] / target) - 1;
	}
	return (cnt <= K);
}

int main()
{
	cin>>N>>K;
	int Max = 0;
	for(int i = 1; i <= N; ++i)
	{
		cin>>A[i];
		Max = max(Max, A[i]);
	}
	int begin = 1;
	int end = Max;
	while(begin < end)
	{
		int mid = (begin + end) /2;
		if(can(mid))
		{
			end = mid;
		}
		else
		{
			begin = mid + 1;
		}
	}
	cout<<begin<<endl;
}


Measured memory_bytes: 4328
r1,c1,r2,c2 = map(int,input().split())

mod = 10**9 + 7
l = 2*10**6 + 3

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

# print(inv(8,13))

MI = [0] * (l-1) +[inv(M[l-1], mod)]  # i!の逆元
for i in range(l-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション
    if y < 0 or y > x:
        return 0
    ans = M[x]
    ans = (ans * MI[y]) % mod
    return (ans * MI[x-y]) % mod

ans = 0
for i in range(r1, r2+1):
    ans = (ans + C(i+1+c2, c2) - C(i+c1, c1-1)) % mod
print(ans)

Measured memory_bytes: 108448
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int n; cin >> n;
	vector <int> v(n);
	rep(i,n) cin >> v[i];
	int counter=0;
	bool flag=true;
	while(flag){
		rep(i,n){
			if(v[i]%2==1) {
				flag=false;
				counter--;
				break;
			}else{
				v[i]/=2;
			}
		}
		counter++;
	}
	cout << counter << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  long a[200001] = {0};
  long b[200001] = {0};
  for(int i = 1;i <= n;i++) {
    scanf("%ld", a + i);
  }
  for(int i = 1;i < n;i++) {
    b[i-1] = a[i] ^ a[i+1];
}
  long x = 0;
  for(int i = 0;i < n;i += 2) {
    x ^= b[i];
  }
  for(int i = 1;i <= n;i++) {
    printf("%ld ", a[i] ^ x);
  }
  puts("");
}

Measured memory_bytes: 5636
#include <stdio.h>
long long t[2], a[2], b[2];
long long w, x, y, z, e, f;
long long ans;
int main() {
	scanf("%lld%lld", t, t + 1);
	scanf("%lld%lld", a, a + 1);
	scanf("%lld%lld", b, b + 1);
	if (t[0] * a[0] + t[1] * a[1] == t[0] * b[0] + t[1] * b[1]) {
		printf("infinity\n");
		return 0;
	}
	x = t[0]; y = t[1];
	if (t[0] * a[0] + t[1] * a[1] > t[0] * b[0] + t[1] * b[1]) {
		w = b[0] - a[0];
		z = b[1] - a[1];
	}
	else {
		w = a[0] - b[0];
		z = a[1] - b[1];
	}
	if (w < 0) {
		printf("0\n");
		return 0;
	}
	e = w * x + z * y;
	f = w * x;
	e = -e;
	ans = f / e * 2;
	if (f % e)ans++;
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	private void solve() throws IOException {
		char[] a = ns().toCharArray();
		int sum = 0;
		for (char c : a) {
			sum += c - '0';
		}

		out.println(sum > 1 ? sum : 10);
		out.close();
	}


	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 23380
#include<stdio.h>
int main(void){
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;

}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long K,N;
    long long A[2000000],B[2000000];
    cin >>K>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        B[i]=A[i+1]-A[i];
        
    }
    B[N-1]=K-A[N-1]+A[0];
    long long bmax=0;
    long long S=0;
    for(int i=0;i<N;i++){
        if(B[i]>bmax){
            bmax=B[i];
        }
        S+=B[i];
    }
    cout<<S-bmax;
    return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

#define MAX 4010


void make_table(string &a, string &b, bool a_b[]) {
    int al = a.size(), bl = b.size();
    for (int i=0; i<MAX; i++) {
        a_b[i] = true;
        for (int j=0; j<bl && i+j<al; j++) {
            if (a[i+j] != '?' && b[j] != '?' && b[j] != a[i+j]) {
                a_b[i] = false;
                break;
            }
        }
    }
}

int solve(int &ans, string &a, string &b, string &c, bool a_b[], bool a_c[], bool b_c[]) {
    int al = a.size(), bl = b.size(), cl = c.size();
    for (int i=0; i<=al; i++) {
        for (int j=0; j<=bl || i+j<=al; j++) {
            if (a_b[i] && b_c[j] && a_c[i+j]) {
                ans = min(ans, max({i + j + cl, i + bl, al}));
            }
        }
    }
    return ans;
}

bool table[3][3][MAX];

int main() {
    string str[3];
    cin >> str[0] >> str[1] >> str[2];
    vector<int> id{0, 1, 2};
    int ans = str[0].size() + str[1].size() + str[2].size();
    do {
        make_table(str[id[0]], str[id[1]], table[id[0]][id[1]]);
    } while (next_permutation(id.begin(), id.end()));
    do {
        solve(ans, str[id[0]], str[id[1]], str[id[2]], table[id[0]][id[1]], table[id[0]][id[2]], table[id[1]][id[2]]);
    } while (next_permutation(id.begin(), id.end()));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    int n;
    cin>>n;
    vector<int>a(n+1),b(n+1),c(n+1);
    int ans=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<=n-1;i++)cin>>c[i];
    int p = -1;
    for(int i=1;i<=n;i++){

         ans+=b[a[i]];
         if(a[i]==p+1)ans+=c[a[i]-1];
           p =a[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3616
N = int(input())
A = list(map(int, input().split()))
nA = []
for i in range(N):
    nA.append([A[i], i + 1])
nA.sort(key=lambda x: x[0])
ans = list(map(list, zip(*nA)))[1]
ans = list(map(str, ans))
print(' '.join(ans))


Measured memory_bytes: 29796
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<String>();
    let N = N.chars().collect::<Vec<char>>();

    if (N[0] == N[1] && N[1] == N[2]) ||
        (N[1] == N[2] && N[2] == N[3]) {
            println!("Yes");
        } else{
            println!("No");
        }
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;
public class Main {
    
    public static void main(String args[]) {
        String a = null, b = null;
        try (Scanner scanner = new Scanner(System.in)) {
            a = scanner.nextLine();
            b = scanner.nextLine();
        }
        
        int an = a.length();
        int bn = b.length();
        
        int[][] dp = new int[an + 1][bn + 1];
        for(int i = 1; i <= an; i++) {
            for(int j = 1; j <= bn; j++) {
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
                if(a.charAt(i - 1) == b.charAt(j -1))
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1] + 1);
            }
        }
        
        // for(int[] d : dp)
        //     System.out.println(Arrays.toString(d));
        
        int i = an;
        int j = bn;
        StringBuilder sb = new StringBuilder();
        while(i >= 1 && j >= 1) {
            int cur = dp[i][j];
            int left = dp[i - 1][j];
            int up = dp[i][j -1];
            
            if(cur > Math.max(left, up)) {
                sb.append(a.charAt(i - 1));
                i--;
                j--;
            } 
            else if (left > up) {
                i--;
            } else {
                j--;
            }
        }
        
        // System.out.println(dp[an][bn]);
        System.out.println(sb.reverse().toString());
        
    }
}

Measured memory_bytes: 80204
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int main() {
	cin>>n>>m;
	if(n==m) cout<<"Yes\n";
	else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b; cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll unsigned long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int n;
	cin >> n;
	if (n&1)
	{
		cout << n/2 + 1 << '\n';
	}
	else
	{
		cout << n/2 << '\n';
	}

	return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/*(._.)*/
/* verify at AOJ : https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/1/DPL_1_D
   最長増加部分列（狭義） */
int main(){
	int N; cin >> N;
	vector<int> A(N);
	REP(i,N){
	    cin >> A[i];
	}

	vector<int> last(N+5);

	REP(i,N+5){
	    last[i] = 1e9+1;
	}
	last[0] = -1;
	REP(i,N){
	    auto it = lower_bound(ALL(last),A[i]);
	    auto index = it - last.begin();
	    last[index] = A[i];
	}

	int ans = -1;
	REP(i,N+1){
		if (last[i] == 1e9+1) continue;
	    chmax(ans,i);
	}

	cout << ans << "\n";


    return 0;
}



Measured memory_bytes: 3580
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=s[s.size()-1-i])
            cnt++;
    }
    cout << cnt/2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << W*H/2 << ' ';
    if((x==W/2)&&(y==H/2)){
        cout << 1;
    } else {
        cout << 0;
    }
}

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

using namespace std;

const int MAX = 1000000;

int dp[MAX + 1] = {};

void check(int a, int b, int c) {
  int mul = 1;
  for (int i = 0; i < a; i++) {
    mul *= 2;
    if (mul > MAX) return;
  }
  for (int i = 0; i < b; i++) {
    mul *= 3;
    if (mul > MAX) return;
  }
  for (int i = 0; i < c; i++) {
    mul *= 5;
    if (mul > MAX) return;
  }
  dp[mul] = 1;
}

int main(void) {
  int m, n;

  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 13; j++) {
      for (int k = 0; k < 9; k++) {
        check(i, j, k);
      }
    }
  }
  for (int i = 1; i <= MAX; i++) {
    dp[i] += dp[i - 1];
  }

  while (cin >> m, m) {
    cin >> n;
    cout << dp[n] - dp[m - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 6908
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    ll n,d; cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout << ans << endl;
} 



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    ll n;
    cin >> n;
    ll sum = n*(n+1)/2;
    ll nump = 2;
    while(sum%nump != 0){
        nump++;
    }
    ll sump = sum/nump;
    vector <ll> lis;
    for (ll i=1;i<=n;i++){
        lis.push_back(i);
    }
    reverse(lis.begin(), lis.end());
    vector <ll> part[100];
    ll partidx = -1;
    while(!lis.empty()) {
        partidx++;
        ll tmpsum = sump;
        auto itr = lis.begin();
        for (ll i=0;i<n;i++) {
            if(tmpsum >= *itr){
                part[partidx].push_back(*itr);
                tmpsum -= *itr;
                itr = lis.erase(itr);
            }else{
                itr++;
            }
        }
    }

    ll nume = 0;
    for(ll i=0;i<100;i++){
        if(part[i].empty()){
            break;
        }
        nume += part[i].size() * (n - part[i].size());
    }
    nume /= 2;
    cout << nume << endl;
    lis.clear();
    for(ll j=1;j<=n;j++){
        lis.push_back(j);
    }
    for(ll i=0;i<100;i++){
        if(part[i].empty()){
            break;
        }
        auto itr = lis.begin();
        while(itr != lis.end()){
            if(find(part[i].begin(), part[i].end(), *itr) != part[i].end()) {
                itr = lis.erase(itr);
            }else{
                itr++;
            }
        }


        for (ll j=0;j<part[i].size();j++){
            for(ll k=0;k<lis.size();k++){
                cout << part[i][j] << " ";
                cout << lis[k] << endl;
            }
        }
    }
//    for(ll i=0;i<100;i++){
//        if(!part[i].empty()){
//            for (ll j=0;j<part[i].size();j++){
//                cout << part[i][j] << " ";
//            }
//            cout << endl;
//        }
//    }


}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)


def Treemake(node,parent,root,num):
    A.append([node,parent,root,num])
    for i,j in root:
        Treemake(i,node,Tree[i],j)


n=int(input())
AB=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
Tree=[[] for _ in range(n)]
A=[]
for a,b,c in AB:
    Tree[a-1].append([b-1,c])
Treemake(0,-1,Tree[0],0)

color=[0]*n
for node,parent,root,num in A:
    flag=0
    for i,j in enumerate(root):
        i=i+1
        if color[num]==i:flag=1
        color[j[1]]=i+flag

print(max(color))
for i in range(1,n):
    print(color[i])

Measured memory_bytes: 88664
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [Double] -> Double
solve n ps = pw
  where
    res = foldl' op (VU.fromList [1]) ps
    op vec p = VU.zipWith (+)
               (VU.snoc (VU.map (* p) vec) 0)
               (VU.cons 0 (VU.map (* (1-p)) vec))
    pw = VU.sum (VU.take ((n+1) `div` 2) res)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Double
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      ps = map (read . B.unpack) line2
  in solve n ps

outAnswer :: Double -> IO ()
outAnswer x = putStrLn (show x)

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 2556
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main ()
{
  int A , B , C , D;
  scanf("%d %d %d %d",&A,&B,&C,&D);


  while(1)
  {
  	C=C-B;
  	if (C<=0)
	{
		printf("Yes");
		break;
	}

  	A=A-D;
  	if (A<=0)
	{
		printf("No");
		break;
	}
  }


 return 0;
}


Measured memory_bytes: 1732
/*
 * Author : Sadi
 * Mon 20/07/2020
 * 14:20:25.63
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, m;
    cin >> n >> m;
    string num(n, 'X');
    bool flag = true;
    for(int i = 0; i < m; ++i) {
        int s;
        char c;
        cin >> s >> c;
        s--;
        if(num[s] != 'X' && num[s] != c) { // contradiction
            flag = false;
            break;
        }
        num[s] = c;
    }
    if(n != 1 && num[0] == '0') {
        flag = false;
    }
    for(int i = 0; i < n; ++i) {
        if(num[i] == 'X') {
            if(n != 1 && i == 0) {
                num[i] = '1';
            }
            else {
                num[i] = '0';
            }
        }
    }
    if(flag) cout << num << "\n";
    else cout << -1 << "\n";
    return 0;
}


Measured memory_bytes: 3632
n,m=map(int,input().split())
s,t=0,100001
for i in range(m):
    l,m=map(int,input().split())
    if l>s:
        s=l
    if m<t:
        t=m

ans=t-s+1
if ans<0:
    ans=0
print(ans)

Measured memory_bytes: 9068
# ??\???????????????
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]

# N*N?????£??\??????????????°?????????
graph_table = [[0]*n for i in range(n)]

# ??£??\??????????????£??\???????????????
for d in data:
    node_id = d[0]
    num_of_e = d[1]
    for e in d[2:]:#?????????????????????????????£?????????
        graph_table[node_id-1][e-1] = 1

# ??????
for g in graph_table:
    print(*g)

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
bool comp(pair<pair<string,int>,int> &a,pair<pair<string,int>,int> &b){
  if(a.first.first==b.first.first) return a.first.second>b.first.second;
  else return a.first.first<b.first.first;
}

int main() {
  int N;
  cin >> N;
  vector<pair<pair<string,int>,int>> X(N); //[(string,int),int]...
  rep(i, N) {
    string S; int P;
    cin >> S >> P;
    X.at(i) = {{S,P},i+1}; //((街,点),ID)の配列X
  }
  sort(X.begin(), X.end(),comp); //ユーザー定義関数compでソート
  // comp関数は、街が同じだった場合、点数の大きい方を返す。その他は、街の降順
  rep(i, N) {
    cout << X.at(i).second << endl; //配列XのIDを出力
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N, X;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> X;
  vector<int> v(N);
  for(int i=0; i<N; ++i) cin >> v[i];
  sort(all(v));
  for(int i=0; i<N; ++i)
    v[i] = abs(v[i] - X);
  int res = 0;
  for(int i=0; i<N; ++i)
    res = __gcd(res, v[i]);
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;


	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();


		//-------------------------------------------------------------------------------------

		for(int i = a; i <= b; i++) {
			if(i % n == 0) {
				f = true;
			}
		}

		//-------------------------------------------------------------------------------------

//		for(int i = 0; i < n; i++) {
//			System.out.println(ans[i]);
//		}

		if(f) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}

//		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 35720
#include<iostream>
#include<cstdio>
using namespace std;
string s;
struct TREE{
	int from,to,nxt;
}t[200500];
int cnt;
void build(int u,int v){
	t[++cnt].to=v;t[cnt].from=u;
}
int main(){
	int i,j,k,m,n;bool flag=0;
	cin>>s;
	int len=s.size();
	s="!"+s;
	for(i=1;i<=len;i++){
		if(s[i]=='1'){
			if(s[len-i]!='1'){
				flag=1;
			}
		}
	}
	if(s[1]!='1'||s[len]!='0'||flag){
		printf("-1");
		return 0;
	}
	int root=1;
	for(i=1;i<len;i++){
		build(root,i+1);
		if(s[i]=='1') root=i+1;
	}
	for(i=1;i<=cnt;i++){
		printf("%d %d\n",t[i].from,t[i].to);
	}
	return 0;
}

Measured memory_bytes: 2812
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    long long N, K; cin >> N >> K;
    vector<vector<long long> > s(N);
    for (int i = 0; i < N; ++i) {
        long long t, d; cin >> t >> d; --t;
        s[t].push_back(d);
    }
 
    int inf = 1e9;
    for (auto &v : s) {
        sort(v.begin(), v.end(), greater<long long>());
        if (v.empty()) v.push_back(-inf);
    }
 
    sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) {
            return a[0] > b[0];
        });
 
    long long cur = 0;
    priority_queue<long long> que;
    for (int i = 0; i < K; ++i) {
        cur += s[i][0];
        for (int j = 1; j < s[i].size(); ++j) que.push(s[i][j]);
    }
    for (int i = K; i < N; ++i) for (int j = 0; j < s[i].size(); ++j) que.push(s[i][j]);
 
    long long res = cur + K*K;
    for (long long x = K-1; x >= 1; --x) {
        long long v = s[x][0];
        long long w = que.top();
        if (v < w) {
            que.pop(); cur += w;
            que.push(v); cur -= v;
        }
        res = max(res, cur + x*x);
    }
    cout << res << endl;
}

Measured memory_bytes: 8696
#include <stdio.h>

#define MAXK 100000
#define MAXN 100

int S[2][MAXK+1]; //0行目が先手
int A[MAXN];

int stones ( int p, int k, int n )
{
	if ( k > -(MAXK+1) && k < 0 ) return 1;
	if ( S[p][k] != -(MAXK+1) ) return S[p][k];
	if ( k == 0 ) return S[p][k] = 0;

	int i;
	if ( p ==  0 ) {
		for ( i = 0; i < n; i++ ) if ( stones(1,k-A[i],n) == 0 ) return S[p][k] = 1;
		return S[p][k] = 0;
	} else {
		for ( i = 0; i < n; i++ ) if ( stones(0,k-A[i],n) == 0 ) return S[p][k] = 1;
		return S[p][k] = 0;
	}
}

int main(void)
{
	int n, k,min,i;

	scanf("%d%d",&n,&k);
	for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
	for ( i = 0; i <= k; i++ ) S[0][i] = S[1][i] = -(MAXK+1);

	if ( stones(0,k,n) == 1 ) printf("First\n");
	else printf("Second\n");


	return 0;
}


Measured memory_bytes: 7168
package main

import "fmt"

type path struct {
	p1 int
	p2 int
}

func main() {
	routes := make([]path, 3)
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d %d\n", &routes[i].p1, &routes[i].p2)
	}
	passes := make([]int, 4)
	for _, r := range routes {
		passes[r.p1-1]++
		passes[r.p2-1]++
	}
	var cnt1, cnt2 int
	for _, p := range passes {
		if p == 1 {
			cnt1++
		} else if p == 2 {
			cnt2++
		}
	}
	if cnt1 == 2 && cnt2 == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#ifndef _WIN32
#include<iostream>
#endif
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

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

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;

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

	cout << fixed << setprecision(30);

	while (true){
		int N, M;
		cin >> N >> M;
		if (N == 0) break;
		int r; cin >> r;

		vvi students(M, vi(1262, 0));

		REP(i, r){
			int t, n, m, s;
			cin >> t >> n >> m >> s; m--;
			if (s == 1){
				students[m][t]++;
			}
			else {
				students[m][t]--;
			}
		}

		REP(i, M) {
			FOR(j, 1, 1262){
				students[i][j] += students[i][j - 1];
			}
		}

		int q;
		cin >> q;

		REP(i, q){
			int ts, te, m;
			cin >> ts >> te >> m; m--;
			int cnt = 0;
			FOR(j, ts, te){
				if (students[m][j] >= 1) cnt++;
			}
			cout << cnt << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 50848
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn fact(n: u32) -> u32 {
    if n == 0 {
        1
    } else {
        n * fact(n - 1)
    }
}

fn f(v: Vec<u32>, n: usize, check: &mut Vec<bool>) -> u32 {
    let mut ret = 0;
    for i in 0..n {
        check[v[i] as usize] = true;
        let mut cnt = 0;
        for j in 0..v[i] as usize {
            if check[j] {
                cnt += 1;
            }
        }
        ret += (v[i] - cnt) * fact((n - 1 - i) as u32);
        // println!("({} - {}) * {}!", v[i], cnt, n - 1 - i);
    }
    ret
}

fn main() {
    let n: usize = read();
    let pv: Vec<u32> = read_vec();
    let pv: Vec<u32> = pv.iter().map(|x| x - 1).collect();
    let qv: Vec<u32> = read_vec();
    let qv: Vec<u32> = qv.iter().map(|x| x - 1).collect();

    // println!("{:?}", pv);
    // println!("{:?}", qv);

    let mut check = vec![false; n];
    let a = f(pv, n, &mut check);
    // println!("{}", a);

    let mut check = vec![false; n];
    let b = f(qv, n, &mut check);
    // println!("{}", b);

    let ans;
    if a > b {
        ans = a - b
    } else {
        ans = b - a
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352