akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
const int64_t INF = 1000000000000000;
const int64_t MOD = 1000000007;

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

int64_t N , M; cin >> N >> M;
if (N < M) swap(N, M);

int64_t ans = 1;
if (N == M){
    rep(i, 1, N+1) {
        ans *= i;
        ans %= MOD;
    }
    ans *= ans * 2;
}
else if (N - M == 1){
    rep(i, 1, M+1) {ans *= i; ans %= MOD;}
    ans *= (ans * N) % MOD;
}
else ans = 0;

cout << ans % MOD << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

template<typename T> 
T dig_sum(T n){
   if(n < 10)  return n;
   return dig_sum(n/10) + n%10;
}
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int count = 0;
    for(int i = 1; i <= N; i++){
        if(A <= dig_sum(i) and dig_sum(i) <= B){
            count += i;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if(a * b < n || a + b > n + 1){
        cout << -1 << endl;
        return 0;
    }
    int h = 0;
    int l = 0;
    for(int i = 0; i < a - 1; i++){
        l = (n - b) / (a - 1) + 1;
        if(i >= (n - b) % (a - 1)) l--;
        h += l;
        for(int j = 0; j < l; j++) cout << h - j << " ";
    }
    for(int i = n; i > n - b; i--) cout << i << " ";
}

Measured memory_bytes: 2176
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]

    dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
    for j in range(1, w + 1):
        for i in range(1, n + 1):
            w, v = goods[i - 1]
            if j - w >= 0:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
            else:
                dp[i][j] = dp[i - 1][j]

    print(dp[-1][-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 171400
import numpy as np
import itertools
import sys
input = sys.stdin.readline  #文字列入力では注意！

N,C = map(int,input().split())
D = np.array([list(map(int,input().split()))for _ in range(C)], dtype=np.int64)
c = np.array([list(map(int,input().split()))for _ in range(N)], dtype=np.int64)
c0 = np.zeros(C,dtype=np.int64)
c1 = np.zeros(C,dtype=np.int64)
c2 = np.zeros(C,dtype=np.int64)
for i in range(N):
    for j in range(N):
        if (i+j)%3 == 0:
            c0[c[i,j]-1] += 1
        if (i+j)%3 == 1:
            c1[c[i,j]-1] += 1
        if (i+j)%3 == 2:
            c2[c[i,j]-1] += 1
# c0~2はXの情報
lis = itertools.permutations(range(C),3)
ans = float("inf")
for l0,l1,l2 in lis:    # l0~2はYの情報
    tmp = np.sum(D[:,l0]*c0+D[:,l1]*c1+D[:,l2]*c2)
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 17620
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define wuyt main
typedef long long ll;
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
vector< set<int> >q(30);

int main(){
    int n,i,j,t,l,r,k,u,ans;
    string s;
    char c;
    cin>>n>>s;
    for(int i=0;i<26;i++) q[i]={n};//先存入n，防止后续查找越界
    for(int i=0;i<n;i++) q[s[i]-'a'].insert(i);
    cin>>t;
    while(t--){
        cin>>u;
        if(u==1){
            cin>>k>>c;k--;
            if(s[k]!=c) q[s[k]-'a'].erase(k);
            s[k]=c;q[c-'a'].insert(k);
        }
        else{
            ans=0;
            cin>>l>>r;l--;r--;
            for(int j=0;j<26;j++) if(*q[j].lower_bound(l)<=r) ans++;
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24196
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = 0;
        while (k <= n){
            if((n - k) % 4 == 0){
                System.out.println("Yes");
                return;
            }
            k += 7;
        }
        System.out.println("No");

    }





























}


Measured memory_bytes: 21844
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    string judge;
    int N,M,T = 0,F = 0;
    cin >> N >> M;
    vector<pair<bool, int>> p(N);

    rep(i, M){
        int num;
        cin >> num >> judge;

        if(judge == "AC"){
            p.at(num - 1).first = true;
        }

        if(judge == "WA" && p.at(num - 1).first == false){
            p.at(num - 1).second++;
        }
    }

    rep(i, N){
        if(p.at(i).first){
            T++;
            F += p.at(i).second;
        }
    }

    cout << T << " " << F << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	boolean[][] M;
	int n;
	boolean color[];
	int d[];
	int f[];

	private void run() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		M = new boolean[n][n];
		color = new boolean[n];
		d = new int[n];
		f = new int[n];
		for (int i = 0; i < n; i++) {
			int u = scanner.nextInt();
			int k = scanner.nextInt();
			u--;
			for (int j = 0; j < k; j++) {
				int v = scanner.nextInt();
				v--;
				M[u][v] = true;
			}
		}
		dfs();
	}

	private void dfs() {
		for (int u = 0; u < n; u++) {
			if (!color[u])
				dfs_visit(u);
		}
		for (int u = 0; u < n; u++) {
			System.out.printf("%d %d %d\n", u + 1, d[u], f[u]);
		}
	}

	int tt = 1;

	private void dfs_visit(int u) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.push(u);
		loop: while (!deque.isEmpty()) {
			int t = deque.peek();
			if (!color[t]) {
				color[t] = true;
				d[t] = tt++;
			}
			for (int v = 0; v < n; v++) {
				if (M[t][v] && !color[v]) {
					deque.push(v);
					continue loop;
				}
			}
			deque.poll();
			f[t] = tt++;
		}

	}
}

Measured memory_bytes: 20992
#include <stdio.h>
int main(){

   int a , b , c;
   scanf("%d%d" , &a , &b );
   if ( a < b ) {
   printf("a < b\n");
   } else if ( a > b ){   
   printf("a > b\n");
   } else if ( a == b ){   
   printf("a == b\n");


   }
  return 0;
}






Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  string s; cin >> s;
  int n;
  if (s == "MON") n = 6;
  if (s == "TUE") n = 5;
  if (s == "WED") n = 4;
  if (s == "THU") n = 3;
  if (s == "FRI") n = 2;
  if (s == "SAT") n = 1;
  if (s == "SUN") n = 7;
  
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll x; cin >> x;
    ll now = 100;
    ll ans = 0;
    while(now < x){
        now += now/100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define RANGE(i, x, n) for(int i = x; i < n; ++i)
using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(3*n, 0);
    ll ans = 0;
    REP(i, 3*n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    while(cnt < n) {
        ans += a[3*n - 1 - cnt * 2 - 1];
        ++cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
int32_t main(){
CODE_START;
cin>>n;
cout<<n*(n+1)/2;
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
int m, n, w[N], v[N];
ll dp[N];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) scanf("%d %d", w + i, v + i);
	for (int i = 1; i < N; ++i) dp[i] = 2e9;
	for (int i = 1; i <= n; ++i) {
		for (int j = N - 1; j >= v[i]; --j) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]); 
		}
	}
	ll ans = 0;
	for (int i = 0; i < N; ++i) 
		if (dp[i] <= m) ans = i;
	cout << ans;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

map<vector<int>,int>mp;
int ask(vector<int>&v){
	if(mp.count(v))return mp[v];
	cout<<"?";
	for(int i:v)cout<<" "<<i+1;
	cout<<endl;
	fflush(stdout);
	string res;cin>>res;
	if(res=="-1")abort();
	if(res=="Red")return mp[v]=1;
	return mp[v]=-1;
}
char ans[200];

int main(){
	int n;cin>>n;
	random_device rnd;
	vector<int>v;
	rep(i,2*n)v.push_back(i);
	shuffle(v.begin(),v.end(),rnd);
	vector<int>a(v.begin(),v.begin()+n),b(v.begin()+n,v.begin()+2*n);
	if(ask(a)<0)swap(a,b);
	int ok=n,ng=0;
	while(ok-ng>1){
		int md=(ok+ng)/2;
		rep(i,md)swap(a[i],b[i]);
		if(ask(a)<0){
			ok=md;
		}
		else ng=md;
		rep(i,md)swap(a[i],b[i]);
	}
	rep(i,ok)swap(a[i],b[i]);
	int red=ok-1,blue=ok-1;
	int val=a[red];
	set<int>as;
	rep(i,a.size())as.insert(a[i]);
	rep(i,2*n){
		if(as.count(i))continue;
		a[red]=i;
		if(ask(a)>0)ans[i]='R';
		else ans[i]='B';
		a[red]=val;
	}
	val=b[blue];
	rep(i,2*n){
		if(!as.count(i))continue;
		b[blue]=i;
		if(ask(b)<0)ans[i]='B';
		else ans[i]='R';
		b[blue]=val;
	}
	cout<<"! "<<ans<<endl;
}

Measured memory_bytes: 852
import math
MOD = 10**9+7
X, Y = map(int, input().split())
ans = 1
div = 1

a = (-X+2*Y)//3
b = Y-2*a

if (X+Y) % 3 != 0 or a < 0 or b < 0:
    print(0)
    exit()

if a < b:
    a, b = b, a

for i in range(a+b, a, -1):
    ans = ans*i
    ans %= MOD

for i in range(1, b+1):
    div = div*i
    div %= MOD

ans *= pow(div, MOD-2, MOD)
print(ans % MOD)


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
            bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

void solve(long long N, std::vector<long long> A){
    if (N == 0) {
        cout << (A[0] == 1 ? 1 : -1) << endl;
        return;
    }
    if (A[0] != 0) {
        cout << -1 << endl;
        return;
    }
    BIT bit(N+2);
    bit.add(1,2);
    bit.add(2,-2);
    ll answer = 1;
    int top = 1;
    rep(i,1,N+1) {
        if (A[i] == 0) continue;
        while (A[i] > 0) {
            while (top <= i && bit.sum(top) <= 0) {
                top++;
            }
            if (top > i) {
                cout << -1 << endl;
                return;
            }
            ll cnt = min<ll>(bit.sum(top), A[i]);
            answer += cnt * (i - top + 1);
            bit.add(top, -cnt);
            bit.add(top+1, 2*cnt);
            bit.add(i+1,-cnt);
            A[i] -= cnt;
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-0+1);
    for(int i = 0 ; i < N-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int sums[N],sumt[N],len,q,vs,vt;
char tmp[N];
int main() {
  int a,b,c,d;
  scanf("%s",tmp+1);
  len = strlen(tmp+1);
  for (int i = 1 ; i <= len ; ++ i)
    sums[i] += 2 - (tmp[i] == 'A');
  for (int i = 1 ; i <= len ; ++ i)
    sums[i] += sums[i-1];
  scanf("%s",tmp+1);
  len = strlen(tmp+1);
  for (int i = 1 ; i <= len ; ++ i)
    sumt[i] += 2 - (tmp[i] == 'A');
  for (int i = 1 ; i <= len ; ++ i)
    sumt[i] += sumt[i-1];
  scanf("%d",&q);
  for (int i = 1 ; i <= q ; ++ i) {
    scanf("%d%d%d%d",&a,&b,&c,&d);
    vs = sums[b] - sums[a-1];
    vt = sumt[d] - sumt[c-1];
    if (vs % 3 == vt % 3) puts("YES");
    else puts("NO");
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll,P>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0;i<s.size();i++){
        s[i] = 'A' + (s[i] - 'A' + n)%26;
    }
    cout << s << endl;
    return 0;
}

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

int main(void)
{
	vector<int> point(5);
	int sum = 0, ans;
	int last_order = 10;
	for (int i = 0; i < 5; i++) {
		cin >> point[i];
		int tmp = point[i] % 10;
		if (tmp < last_order && tmp != 0) {
			last_order = tmp;
		}
		if (tmp == 0)sum += point[i];
		else sum += (point[i] + 10 - tmp);
	}
	ans = sum - (10 - last_order);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int x, a, b; cin >> x >> a >> b;
    if(b - a <= 0) cout << "delicious" << endl;
    else {
        if(x >= b - a) cout << "safe" << endl;
        else cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
 int n;
 cin >> n;
 int ans = 100000;;
 rep(i,n){
  int x = ans/20;
  ans += x;
  if(ans%1000) ans += (1000-(ans%1000));
 }
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 3100
//
// Created by yamunaku on 2019/12/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

ll gcd(ll x, ll y){
    while(x % y){
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return y;
}

ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main(){
    // CFS;
    ll x,y;
    cin >> x >> y;
    cout << lcm(x,y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n; cin >> n;
    char a[120];
    pair<pair<string,int>,int> p[110];
    
    for (int i=0; i<n; i++){
        int t;
        cin >> a >> t;
        p[i] = make_pair(make_pair(a,-t),i);
    }
    sort(p,p+n);
    for (int i=0; i<n; i++) cout << p[i].second+1 << endl;
}

Measured memory_bytes: 256
time = 1
K = int(input())
sev = 7
while True:
    if K % 2 == 0 or time > K:
        print(-1)
        break
    elif sev % K == 0:
        print(time)
        break
    else:
        sev = sev % K * 10 + 7
        time += 1

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

int main(void){
	string s, t;
	cin >> s >> t;
	map<char, char> t_map;
	map<char, char> s_map;


	bool f = true;
	for(int i=0; i<s.size(); i++){
		if(!t_map.count(t[i])){
			t_map[t[i]] = s[i];
		}else{
			if(t_map[t[i]] != s[i]){
				f = false;
				break;
			}
		}
		if(!s_map.count(s[i])){
			s_map[s[i]] = t[i];
		}else{
			if(s_map[s[i]] != t[i]){
				f = false;
				break;
			}
		}
	}

	if(f) puts("Yes");
	else puts("No");
	
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int n, x , t; cin >> n >> x >> t;
    int ans = 0;
    if (n % x == 0) {
        ans = t * (n/x);
    } else {
        int tmp =  n / x + 1;
        ans = tmp * t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	if(b-a>x)cout<<"dangerous"<<endl;
	else if(a>=b)cout<<"delicious"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var N = parseInt(input[0], 10);
    var A = parseInt(input[1], 10);
    var B = parseInt(input[2], 10);

    var result = 0;

    for (var i = 1; i <= N; i++) {
        var numStr = i.toString();
        var numList = numStr.split('');
        var sum = 0;
        for (var j = 0; j < numList.length; j++) {
            sum += parseInt(numList[j], 10);
        }
        if (sum >= A && sum <= B) {
            result += i;
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 8368
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N, T;
    io.read(N, T);
    vector<int> c(N);
    vector<int> t(N);
    for(int i = 0; i < N; i++){
        io.read(c[i], t[i]);
    }
    int ans = 10000;
    for(int i = 0; i < N; i++){
        if(t[i] <= T) ans = min(ans, c[i]);
    }
    if(ans == 10000) cout << "TLE";
    else cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 2e5 + 7;
vector<int> graph[maxn];

int dp[maxn], fact[maxn], sz[maxn], ans[maxn];

int modexpo(int b, int p, int m)
{
    int res = 1;
    b %= m;
    while(p)
    {
        if(p & 1)
            res *= b;
        res %= m;
        b *= b;
        b %= m;
        p >>= 1;
    }
    return res;
}

int modinv(int a, int p)
{
    return modexpo(a, p - 2, p);
}

int ncr(int n, int r)
{
	int res = 1;
	if(n < r)
		return 1;
	for(int i = r; i >= 1; i--)
	{
		res *= n;
		res %= mod;
		res *= modinv(i, mod);
		res %= mod;
		n--;
	}
	return res;
}

int fac(int n)
{
	fact[0] = 1;
	for(int i = 1; i <= n; i++)
		fact[i] = fact[i-1] * i, fact[i] %= mod;
}

int dfs(int u, int p)
{
	sz[u] = 1;
	int den = 1;
	int num = 1;
	for(int &v: graph[u])
	{
		if(v != p)
		{
			dfs(v, u);
			sz[u] += sz[v];
			den *= fact[sz[v]];
			den %= mod;
			num *= dp[v];
			num %= mod;
		}
	}
	num *= fact[sz[u]-1];
	num %= mod;
	dp[u] = num * modinv(den, mod);
	dp[u] %= mod;
}

int get_ans(int u, int p, int pval, int n)
{
	int den = 1, num = 1;
	for(int &v: graph[u])
	{
		if(v != p)
		{
			den *= fact[sz[v]];
			den %= mod;
			num *= dp[v];
			num %= mod;
		}
	}
	int psz = n - sz[u];
	num *= pval;
	num %= mod;
	den *= fact[psz];
	den %= mod;
	ans[u] = ((fact[n-1] * num) % mod * modinv(den, mod)) % mod;
	for(int &v: graph[u])
	{
		if(v != p)
		{
			int tmpnum = num * modinv(dp[v], mod);
			tmpnum %= mod;
			int tmpden = den * modinv(fact[sz[v]], mod);
			tmpden %= mod;
			int tmpans = ((fact[n-sz[v]-1] * tmpnum) % mod * modinv(tmpden, mod)) % mod;
			get_ans(v, u, tmpans, n);		
		}
	}
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
    	int u, v;
    	cin >> u >> v;
    	graph[u].pb(v);
    	graph[v].pb(u);
    }
    fac(n);
    dfs(1, 1);
    get_ans(1, 1, 1, n);
    for(int i = 1; i <= n; i++)
    	cout << ans[i] << endl;
    return 0;
}

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

int f(int h, int m){
	return h * 60 + m;
}

int main(){
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << max(0, (f(h2, m2) - f(h1, m1)) - k);
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n,x,y;
    cin >> n;
    ll curX = 1;
    ll curY = 1;
    rp(i,n){
        cin >> x >> y;
        ll quantile = max((curX+x-1)/x,(curY+y-1)/y);
        curX = x*quantile;
        curY = y*quantile;


    }
    cout << curX+curY<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main() {
  int N, i, max;
  string s;
  map<string, int> mp;
  max = 1;
  vector<string> vec;

  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> s;
    if (mp.count(s) == 0) {
      mp[s] = 1;
      if (max == 1) {
        vec.push_back(s);
      }
    } else {
      mp[s]++;
      if (mp[s] > max) {
        max = mp[s];
        vec.clear();
        vec.push_back(s);
      } else if (mp[s] == max) {
        vec.push_back(s);
      }
    }
  }
  sort(vec.begin(), vec.end());
  for (i = 0; i < vec.size(); i++) {
    cout << vec[i] << "\n";
  }
  cout << endl;
}

Measured memory_bytes: 26864
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem144a(a, b))
}

fun problem144a(a: Int, b: Int): Int {
    return if (a >= 10 || b >= 10) -1 else a * b
}

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

#define pb push_back

using namespace std;

vector<int>vec;

int ans;

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

    vec.pb(0);
    for (int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);

        vec.pb(a);
    }

    vec.pb(0);

    for (int i = 0; i < vec.size() - 1; i++)
    {
        ans += abs(vec[i] - vec[i + 1]);
    }

    for (int i = 1; i < vec.size() - 1; i++)
    {
        cout << ans - (abs(vec[i] - vec[i + 1]) + abs(vec[i] - vec[i - 1]) - abs(vec[i + 1] - vec[i - 1])) << endl;
    }
}




Measured memory_bytes: 1784
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

dp=[[0]*3 for i in range(N)]

for i in range(K):
  for j in range(i,N,K): 
    if j>=K:
      if T[j]=="r":
        dp[j][0]=max(dp[j-K][1],dp[j-K][2])
        dp[j][1]=max(dp[j-K][0],dp[j-K][2])
        dp[j][2]=max(dp[j-K][0],dp[j-K][1])+P
      elif T[j]=="s":
        dp[j][0]=max(dp[j-K][1],dp[j-K][2])+R
        dp[j][1]=max(dp[j-K][0],dp[j-K][2])
        dp[j][2]=max(dp[j-K][0],dp[j-K][1])
      else:
        dp[j][0]=max(dp[j-K][1],dp[j-K][2])
        dp[j][1]=max(dp[j-K][0],dp[j-K][2])+S
        dp[j][2]=max(dp[j-K][0],dp[j-K][1])
           
    else:
      if T[j]=="r":
        dp[j][2]=P
      elif T[j]=="s":
        dp[j][0]=R
      else:
        dp[j][1]=S
ans=0
for i in range(K): 
  ans+=max(dp[-i-1])
    
print(ans)
    
    

Measured memory_bytes: 69868
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i = l; i <= r; i++){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String[] array = scanner.nextLine().split(" ");
    int A = Integer.parseInt(array[0]);
    int B = Integer.parseInt(array[1]);
    int T = Integer.parseInt(array[2]);
    
   	int now = A;
    int num = 0;
    while(now <= T) {
      now += A;
      num += B;
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
void solve()
{
 ll n,i;
    cin>>n;
    vector<ll>a(n),suf(n);
    for(ll &x:a)cin>>x;
    suf[n-1]=a[n-1]%mod;
    for(i=n-2;i>=0;i--)
        suf[i]=(suf[i+1]+a[i])%mod;
    
    ll ans=0;
    for(i=0;i<n-1;i++)
        ans=(ans+a[i]%mod*suf[i+1]%mod)%mod;
    
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 6344
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    string s3(s1 + s1);
    if((int)s3.find(s2)!=-1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
    
    



Measured memory_bytes: 3212
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[][] countar = new int[2][n];
		for (int i = 0; i < n; i++) {
			if (i != 0) {
				countar[0][i] += countar[0][i - 1];
			}
			if (s.charAt(i) == 'W') {
				countar[0][i]++;
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			if (i != n - 1) {
				countar[1][i] += countar[1][i + 1];
			}
			if (s.charAt(i) == 'E') {
				countar[1][i]++;
			}
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int count = 0;
			if (i > 0) {
				count += countar[0][i - 1];
			}
			if (i < n - 1) {
				count += countar[1][i + 1];
			}
			if (min > count) {
				min = count;
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 32036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}
ll combination(ll n, ll r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1)%MOD + combination(n - 1, r)%MOD);
}
ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}
ll a[110];

int main() {
    int N; cin >> N;
    int maxV=0;
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    for(int i=2; i<N; ++i){
        int t=i;
        while(1){
            if(t*i>N) break;
            t=t*i;
        }
        if(t!=i)maxV = max(maxV, t);
    }
    cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int a = sc.nextInt();
		
		// 計算
		int result = (h + a - 1)/a;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

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

  int h, a;
  cin >> h >> a;

  int x = 0;
  if(h%a!=0) x = 1;
  cout << h/a + x << endl; 

  return 0;
}



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

#define endl '\n' 
#define pb push_back             
#define fi first 
#define se second 
#define pll pair<long long, long long> 
#define all(v) v.begin(), v.end() 
  
using namespace std; 
   
typedef long long int ll; 
   
mt19937 rnd(1337); 

ostream& operator<< (ostream& a, const pll& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

ostream& operator<< (ostream &a, const vector<ll>& b) {
    for (auto& k : b) cout << k << " ";
    return a;
}

ostream& operator<< (ostream &a, const vector<pll>& b) {
    for (auto& k : b) cout << k << " ";
    return a;
}

#ifdef HOME 
  #define dbg(x) cout << #x << " : " << (x) << '\n';
#else
  #define dbg(x)
#endif                 
   
const ll INF = (ll)1e18; 
const ll MOD = 1000 * 1000 * 1000 + 7, MOD2 = 274876858367;                                                                                    
const ll maxn = (ll)3e5 + 10, L = 10;

int main() { 
  #ifdef HOME 
    freopen("input.txt", "r", stdin);                                                            
    freopen("output.txt", "w", stdout); 
  #else 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    //freopen("olympiad.in", "r", stdin); 
    //freopen("olympiad.out", "w", stdout); 
  #endif                    
  ll x, n;
  cin >> x >> n;
  set<ll> st;
  for (ll t; cin >> t;)
    st.insert(t);
  for (ll i = 0;;++i) {
    if (st.find(x - i) == st.end())
      return cout << x - i, 0;
    if (st.find(x + i) == st.end())
      return cout << x + i, 0;
  }
  return 0;                    
}   















                  

Measured memory_bytes: 3656
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    map<int, int> a;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if(a.count(tmp)) a[tmp]++;
        else a[tmp] = 1;
    }
    int ans = 0;
    for(auto x : a) ans += x.second % 2;
    cout << ans << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll A, B;
ll bitA[64];
ll bitB[64];

void bitSum(ll N, ll bit[64]) {
  for (ll i = 0; i < 60; ++i) {
    bit[i] = ((N+1ll)/(1ll<<(i+1ll))*(1ll<<i));
    ll t = N+1ll - ((N+1ll)/(1ll<<(i+1ll))*(1ll<<(i+1ll)));
    if (t > (1ll<<i)) {
      bit[i] += t - (1ll<<i);
    }
  }
}

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

  cin >> A >> B;
  bitSum(A-1, bitA);
  bitSum(B, bitB);

  ll ans = 0;
  for (ll i = 0; i < 60; ++i) {
    if (mod((bitB[i]-bitA[i]),2) == 1) {
      ans += 1ll << i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;  cin>>n;
  vector<int>A(n+1);
  A[0]=0;
  for(int i=0; i<n; i++){
    int a; cin>>a;
    A[i+1]=a;
  }
  int sum=abs(A[n]);
  for(int i=0;i<n;i++){
    sum+=abs(A[i+1]-A[i]);
  }
  for(int i=1;i<=n;i++){
    if(i<n) cout<<sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])<<endl;
    else cout<<sum-abs(A[n]-A[n-1])-abs(A[n])+abs(A[n-1]);
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<long long> a(n+1, 0), b(m+1, 0);
    for(int i=1;i<=n;i++){ cin >> a[i]; a[i] += a[i-1];}
    for(int i=1;i<=m;i++){ cin >> b[i]; b[i] += b[i-1];}
    for(int i=0;i<=n;i++){
        if(a[i] > k) break;
        int ok = 0, ng = m+1;
        while(ok + 1 < ng){
            int mid = (ok+ng)/2;
            if(a[i]+b[mid] <= k) ok = mid;
            else ng = mid;
        }
        ans = max(ans, i+ok);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>


using namespace std;

using ll=long long int;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;


bool cmp(const pii& l, const pii& r)
{
	return l.first<r.first;
}


int main(void)
{
	int n;
	ll k;
	vector<pii> ab;

	while(scanf("%d%lld", &n, &k)==2)
	{
		ab.clear();
		ab.reserve(n);
		for(int i=0;i<n;i++)
		{
			int a, b;

			scanf("%d%d", &a, &b);
			ab.push_back(make_pair(a, b));
		}
		sort(ab.begin(), ab.end(), cmp);
		for(int i=0;i<n;i++)
		{
			k-=ab[i].second;
			if(k<=0)
			{
				printf("%d\n", ab[i].first);
				break;
			}
		}
	}

	return 0;
}


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

int sgcd(long long int a, long long int b)
{

    if (a < b)
        swap(a, b);

    if (a % b == 0)
        return b;
    else
        return sgcd(b, a % b);
}

int main()
{
    int n, s;
    cin >> n >> s;
    vector<long long int> x(n);
    long long int k;
    for (int i = 0; i < n; i++)
    {
        cin >> k;
        x[i] = abs(k - s);
    }

    long long int d;
    
    if (n >= 2)
    {
        d = sgcd(x[0], x[1]);

        for (int i = 2; i < n; i++)
        {
            d = sgcd(d, x[i]);
        }
    }
    else
    {
        d = x[0];
    }

    cout << d << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;


int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    if (x == 1 || x == 2 * n - 1)
        puts("No");
    else
    {
        vector<int>A(2 * n, -1);

        A[n - 2] = x - 1;
        A[n - 1] = x;
        A[n] = x + 1;

        int now = 1;

        for (int i = 0; i < 2 * n - 1; i++)
        {
            if (A[i] == -1)
            {
                while (abs(now - x) <= 1)
                    now++;
                A[i] = now++;
            }
        }

        puts("Yes");

        for (int i = 0; i < 2 * n - 1; i++)
            printf("%d\n", A[i]);
    }
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;
typedef vector<pi> vp;

int n,y[9],x[9],K,u[111],v[111],Y,X;
int b[111][111];

int dy[]={0,-1,-1,0,1,1};
int dx[]={1,1,0,-1,-1,0};

map<vp,int> M;
queue<vp> Q;

inline int majadist(const pair<int,int> &a, const pair<int,int> &b) {
	int dx = abs(a.first - b.first);
	int dy = abs(a.second - b.second);
	int dz = abs(a.first+a.second-b.first-b.second);
	return min(dx+dy, min(dx+dz, dy+dz));
}

int dist;
void f(int cur,vp v){
	if(cur>=n){
		int ok=1;
		rep(i,n)rep2(j,i+2,n){
			if(majadist(v[i],v[j])<=1){ok=0;break;}
		}
		if(ok && M.find(v)==M.end()){
			M[v] = dist+1;
			Q.push(v);
		}
		return;
	}
	f(cur+1,v);
	int y=v[cur].fir,x=v[cur].sec;
	rep(dir,6){
		int ny=y+dy[dir],nx=x+dx[dir];
		if(b[ny][nx])continue;
		//if(cur==0 && majadist(mp(ny,nx),mp(50,50)) > 20-dist-1)continue;
		if(cur-1>=0 && majadist(mp(ny,nx),v[cur-1])!=1)continue;
		if(cur+1<n  && majadist(mp(ny,nx),v[cur+1])!=1)continue;
		vp w=v;
		w[cur].fir=ny;
		w[cur].sec=nx;
		f(cur+2,w);
	}
}

void main2(){
	M.clear();
	while(sz(Q))Q.pop();
	
	vp v;
	rep(i,n)v.pb(mp(y[i],x[i]));
	Q.push(v);
	M[v]=0;
	while(sz(Q)){
		vp v=Q.front();Q.pop();
		dist=M[v];
		if(v[0].fir==Y && v[0].sec==X){
			cout<<M[v]<<endl;
			break;
		}
		f(0,v);
	}
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>n && n){
		memset(b,0,sizeof(b));
		rep(i,n)cin>>y[i]>>x[i];
		cin>>K;
		rep(i,K)cin>>u[i]>>v[i];
		cin>>Y>>X;
		rep(i,n)y[i]-=Y-50,x[i]-=X-50;
		rep(i,K){
			u[i]-=Y-50,v[i]-=X-50;
			if(0<=u[i] && u[i]<=100 && 0<=v[i] && v[i]<=100){
				b[u[i]][v[i]]=1;
			}
		}
		Y-=Y-50,X-=X-50;
		main2();
	}
}

Measured memory_bytes: 39428