akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//BEGIN CUT HERE
template<typename T>
map<T, T> factorize(T x){
  map<T, T> res;
  for(T i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

template<typename T>
T mpow(T x,T n,T MOD){
  T res(1);
  while(n){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

template<typename T>
T order(T x,T MOD){
  static map<T, vector<T>> dp;
  vector<T> &ps=dp[MOD];
  if(ps.empty()){
    auto fs=factorize(MOD-1);
    for(auto p:fs) ps.emplace_back(p.first);
  }

  T res=MOD-1;
  for(T p:ps){
    while(res%p==0){
      if(mpow(x,res/p,MOD)!=1) break;
      res/=p;
    }
  }
  return res;
}
//END CUT HERE
//INSERT ABOVE HERE
signed AOJ_3062(){
  using ll = long long;
  ll MOD;
  cin>>MOD;

  int T;
  cin>>T;
  while(T--){
    ll n;
    cin>>n;

    vector<ll> g(n);
    for(ll i=0;i<n;i++) cin>>g[i];

    ll a;
    cin>>a;

    if(a==1){
      cout<<1<<"\n";
      continue;
    }

    sort(g.rbegin(),g.rend());
    if(g[0]==1){
      cout<<0<<"\n";
      continue;
    }
    while(g.back()==1) g.pop_back();

    auto mlcm=[&](ll a,ll b){return a/__gcd(a,b)*b;};

    ll res=order(g[0],MOD);
    for(ll x:g) res=mlcm(res,order(x,MOD));

    cout<<(res%order(a,MOD)==0?1:0)<<"\n";
  }
  cout<<flush;
  return 0;
}
/*
  verified on 2019/06/16
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=3062
*/

signed main(){
  AOJ_3062();
  return 0;
}



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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n,g;
	long long zb=0;
	cin >> n;
	for (int i=1;i<=n;i++)
	    for (int j=1;j<=n;j++)
        {
            g=__gcd(i,j);
            for (int k=1;k<=n;k++)
                zb+=(long long)(__gcd(g,k));
        }
    cout << zb;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int MAXN = 3e5+5;
const LL INF = 1LL<<30;
const double eps = 1e-9;
const double PI=3.1415926535897932;

int v[200009];

int main(){
	DRII(n,t);
	LL ans=0;
	REP(i,n){
		RI(v[i]);
	}
	REP(i,n){
		if(i==n-1||v[i]+t<v[i+1])ans+=t;
		else{
			ans+=v[i+1]-v[i];
		}
	}
	printf("%lld",ans);
}


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

int main(){
  int N;
  ll sum=0;
  cin >> N;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  sum += vec.at(i);
  }
  sort(vec.begin(), vec.end());
  cout << vec.at(0) << " " << vec.at(N-1) << " " << sum << endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main(){
	int W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << fixed << setprecision(6) << double(W)*double(H)/2.0 << " ";
	if(double(x) == double(W)/2.0 && double(y) == double(H)/2.0)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 256
// abc102_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i] -= i+1;
    }

    sort(ALL(A));

    ll med1 = A[(N+1)/2-1];
    ll tmp1 = 0;
    REP(i, N) {
        tmp1 += abs(A[i] - med1);
    }

//    ll med2 = A[(N+1)/2];
//    ll tmp2 = 0;
//    REP(i, N) {
//        tmp2 += abs(A[i] - med2);
//    }
//    ll ans = min(tmp1, tmp2);
    ll ans = tmp1;
    print(ans);

    return 0;
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n, k;
	cin >> n >> k;
	vll a(n + 1, 0);
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = k + 1; i <= n; i ++)
		if(a[i] > a[i - k])
			cout << "Yes\n";
		else
			cout << "No\n";





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 4840
import java.util.*;

public class Main {
	static int[] U;
	static long[] T;
	static long[] S;
	static int[] D;
	static int N;
	static int[][] g;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		g = new int[N][];
		for (int i = 0; i < N - 1; ++i) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			g[i] = new int[] { a, b };
		}

		U = new int[N];
		T = new long[N];
		S = new long[N];
		D = new int[N];

		U[N - 1] = 1;
		for (int i = N - 2; i >= 0; --i) {
			for (int dst : g[i]) {
				U[i] += U[dst];
			}
		}
		for (int i = N - 2; i >= 0; --i) {
			for (int dst : g[i]) {
				T[i] += T[dst] + U[dst];
			}
		}
		for (int i = 0; i < N - 1; ++i) {
			for (int dst : g[i]) {
				D[dst] = D[i] + 1;
			}
		}
		for (int i = N - 2; i >= 0; --i) {
			int l = g[i][0];
			int r = g[i][1];
			S[i] = U[l] + U[r] + T[l] + T[r];
			S[i] = Math.min(S[i], U[l] + T[l] + 1 + S[r]);
			S[i] = Math.min(S[i], U[r] + T[r] + 1 + S[l]);
			S[i] = Math.min(S[i], S[l] + S[r] + 1 + D[r]);
			S[i] = Math.min(S[i], S[l] + S[r] + 1 + D[l]);
		}

		System.out.println(S[0]);

	}
}

Measured memory_bytes: 309292
import sys

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(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.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M,K = map(int,input().split())
friend =[0]*N
block = {}
for i in range(N):
  block[i] = []
uf = UnionFind(N)
for i in range(M):
  a,b = map(int,input().split())  
  a -= 1;b-=1
  friend[a]+=1
  friend[b]+=1
  uf.union(a,b)
  
for i in range(K):
  c,d = map(int,input().split())
  c -= 1
  d -= 1
  block[c].append(d)
  block[d].append(c)
res = [0]*N
for i in range(N):
  ans = uf.size(i)-1-friend[i]
  for u in block[i]:
    if uf.same(i,u):
      ans -= 1
      
  res[i] = ans
  
print(*res)
      
    
  
          

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

using namespace std;

int main(){
  int N;
  
  int a[100010],b[100010];
  
  cin >> N;
  
 
  for(int i=0;i<N;i++)
  cin >> a[i] ;
    
   sort(a,a+N,greater<int>());
  
  long long int bmin = 2e9;
  int ans ;
  
  for(int i=1;i<N;i++){
    if(abs(a[i]-(a[0]+1)/2) > bmin ){
      continue;
    }
    else{
      bmin = abs(a[i]-(a[0]+1)/2);
      
      ans = a[i];
    }
  }
  
  cout << a[0] << " " << ans << endl;
}
      
              
  
  


Measured memory_bytes: 640
#include<cstdio>
using namespace std;
int main(void)
{
	long long int n,a,b;
	scanf("%lld %lld %lld",&n,&a,&b);
	if((n==1&&a!=b)||a>b)
	{
		printf("0\n");
	}
	else
	{
	printf("%lld\n",(n-2)*(b-a)+1);
	}
	return 0;
} 

Measured memory_bytes: 128
MAX = 10**5


def parent(i):
    return i // 2

def left(i):
    return 2 * i

def right(i):
    return 2 * i + 1


H = int(input())
A = list(map(int, input().split()))
A.append(10*12)


for i in range(1,H+1):
    print("node %d: key = %d, " %(i, A[i-1]), end = "")
    if parent(i) >= 1:
        print("parent key = %d, " %(A[parent(i)-1]), end = "")

    if left(i) <= H:
        print("left key = %d, " %(A[left(i)-1]), end = "")

    if right(i) <= H:
        print("right key = %d, " %(A[right(i)-1]), end = "")
    print()


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mem(a, b) memset(a, b, sizeof(a))
#define INF 0X3f3f3f3f
const ll MAXN = 2e5 + 7;
const ll MOD = 1e9 + 7;
//-------------------------------------------//
char s[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    int b=0,w=0,ans=n,B=0,W=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='#')
        {
            b++;
        }
        else
        {
            w++;
        }
    }
    ans=min(B+w-W,ans);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='#')
        {
            B++;
        }
        else
        {
            W++;
        }
        ans=min(B+w-W,ans);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 384
A, B, K = map(int, input().split())

while True:
    if K == 0:
        break
    else:        
        if A%2 !=0:
            A -= 1
        B += A//2
        A = A//2
        K -= 1

    if K == 0:
        break
    else:       
        if B%2 !=0:
            B -= 1
        A += B//2
        B = B//2
        K -= 1
    
print(A,B)

Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
void func(int,int);
int a,b;
int sima[51][51];
int cnt;
int main(void)
{
	int i,j,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	while(!(b==0 && a==0)){
		
		for(i=0;i<b;i++){
			for(j=0;j<a;j++){
				scanf("%d",&sima[i][j]);
			}
		}
		cnt=0;
		for(i=0;i<b;i++){
			for(j=0;j<a;j++){
				if(sima[i][j]==1){
					func(i,j);
					cnt++;
				}
			}
		}
		printf("%d\n",cnt);
		scanf("%d",&a);
		scanf("%d",&b);
	}
	return 0;
}
void func(int y,int x)
{
	if(y-1>=0){
		if(sima[y-1][x]==1){
			sima[y-1][x]=0;
			func(y-1,x);
		}
	}
	if(x-1>=0){
		if(sima[y][x-1]==1){
			sima[y][x-1]=0;
			func(y,x-1);	
		}
	}
	if(y+1<=b){
		if(sima[y+1][x]==1){
			sima[y+1][x]=0;
			func(y+1,x);
		}
	}
	if(x+1<=a){
		if(sima[y][x+1]==1){
			sima[y][x+1]=0;
			func(y,x+1);
		}
	}
	if(y-1>=0 && x+1<=a){
		if(sima[y-1][x+1]==1){
			sima[y-1][x+1]=0;
			func(y-1,x+1);
		}
	}
	if(y-1>=0 && x-1>=0){
		if(sima[y-1][x-1]==1){
			sima[y-1][x-1]=0;
			func(y-1,x-1);
		}
	}
	if(y+1<=b && x+1<=a){
		if(sima[y+1][x+1]==1){
			sima[y+1][x+1]=0;
			func(y+1,x+1);
		}
	}
	if(y+1<=b && x-1>=0){
		if(sima[y+1][x-1]==1){
			sima[y+1][x-1]=0;
			func(y+1,x-1);
		}
	}
}
	

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

int main(){
    int n; cin>>n;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin>>l[i];
    sort(l.begin(),l.end());
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int m=l[i]+l[j];
            int r=lower_bound(l.begin(),l.end(),m)-l.begin();
            int l=j+1;
            ans+=r-l;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
	
X, Y, A, B, C = MAP()
p = deque(sorted(LIST(), reverse=True) + [0])
q = deque(sorted(LIST(), reverse=True) + [0])
r = deque(sorted(LIST(), reverse=True) + [0])

x = 0
y = 0
z = 0
ans = 0
while x+y+z < X+Y:
	compare = (p[0], q[0], r[0])

	if p[0] == max(compare):
		x += 1
		ans += p.popleft()
		if x == X:
			p = [0]
	elif q[0] == max(compare):
		y += 1
		ans += q.popleft()
		if y == Y:
			q = [0]
	else:
		z += 1
		ans += r.popleft()

print(ans)

Measured memory_bytes: 30968
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << ab * bc / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    #define pb push_back
    #define eb emplace_back
    #define mk make_pair
    #define fi first
    #define sec second
    #define fori(i, a, b) for(int i = int(a); i < int(b); i++)
    #define cc(x)	cout << #x << " = " << x << endl
    #define ok		cout << "ok" << endl
     
    typedef pair<int,int> ii;
    typedef long long ll;
    const int INF = 0x3f3f3f3f;
    const double PI = acos(-1.0);
     
    const long long N = 1e5 + 10; 
    long long n, cost[N];
   	long long dp[N];
     
    long long pog(long long at, long long n, long long cost[]){
    	if(at >= n) return 0;
    	if(dp[at] != -1) return dp[at];
     
    	long long L = pog(at+1, n, cost) + abs(cost[at+1]-cost[at]);
    	long long R = pog(at+2, n, cost) + abs(cost[at+2]-cost[at]);
     
    	return dp[at] = min(L, R);
    }
     
    int main(){
    	ios_base::sync_with_stdio(false);
    	
    	memset(dp, -1, sizeof dp);
    	cin >>n;
     
    	for(int i = 0; i < n; i++)
    		cin >>cost[i];
     	
    	cost[n] = INF;
      
    	cout <<pog(0, n-1, cost) <<endl;
    	return 0;
    }

Measured memory_bytes: 9600
#include <stdio.h>
int main(void){
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    N=N*A;
    if(N<B){
        printf("%d\n",N);
    }
    else{
        printf("%d\n",B);
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,Q;
    cin >> N >> Q;
    multiset<ll> st;
    st.insert(INF);
    priority_queue<P,vector<P>,greater<P>> pq0,pq1;
    rep(i,N){
        ll S,T,X;
        cin >> S >> T >> X;
        S-=X;
        T-=X;
        pq0.push({S,X});
        pq1.push({T,X});
    }//1,3,2と//3,4,2
    rep(i,Q){
        ll D;
        cin >> D;
        while(pq0.size()&&pq0.top().first<=D){
            P p=pq0.top();
            pq0.pop();
            st.insert(p.second);
        }
        while(pq1.size()&&pq1.top().first<=D){
            P p=pq1.top();
            pq1.pop();
            st.erase(st.find(p.second));
        }
        ll ans=*st.lower_bound(0);
        if(ans==INF){
            cout << -1 << endl;
        }
        else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 18684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    const int m = 3;
    int a[m][m];
    bool ok[m][m];
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            ok[i][j] = false;
        }
    }
    
    int n;
    cin >> n;
    for (int _ = 0; _ < n; _++) {
        int b;
        cin >> b;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i][j] == b) ok[i][j] = true;
            }
        }
    }
    
    bool flag = false;
    for (int i = 0; i< m; i++) {
        flag |= (ok[i][0] && ok[i][1] && ok[i][2]);
        flag |= (ok[0][i] && ok[1][i] && ok[2][i]);
    }
    flag |= (ok[0][0] && ok[1][1] && ok[2][2]);
    flag |= (ok[2][0] && ok[1][1] && ok[0][2]);
    
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}
    

Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {
            int age;
            int a;
            int b;
            if (int.TryParse(Console.ReadLine(), out age))
            {
                if(age == 1)
                {
                    Console.WriteLine("Hello World");
                }
                else if(age == 2)
                {
                    var A = Console.ReadLine();
                    var B = Console.ReadLine();

                    if(int.TryParse(A,out a) && int.TryParse(B,out b))
                    {
                        if(a > 0 && a < 10 && b > 0 && b < 10)
                        {
                            Console.WriteLine(a + b);
                        }
                    }
                }
            }          
        }
    }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N, K;
    cin >> N >> K;
    int h[100010];
    ll dp[100010];

    rep(i, N)
    {
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i, N)
    {
        rep1(k, K)
        {
            if (i+k<N) dp[i+k] = min(dp[i+k], dp[i]+abs(h[i+k]-h[i]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n,N;
multiset<int> a;
multiset<int> s;
multiset<int>::iterator it,IT;
int tmp[1000005],ptr;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;N=1<<n;
	for (int i=1;i<=N;++i){
		int x;cin>>x;a.insert(x);
	}
	it=a.end();--it;IT=it;--IT;
	if (*IT==*it){
		cout<<"No"<<endl;return 0;
	}
	s.insert(*it);a.erase(it);
	while(n--){
		it=s.end();--it;
		IT=a.end();--IT;
		ptr=0;bool flag=0;
		while(1){
			while(IT!=a.begin()&&*IT>=*it) --IT;
			if (IT==a.begin()&&*IT>=*it){
				cout<<"No"<<endl;return 0;
			}
			tmp[++ptr]=*IT;
			if (a.size()==1) a.erase(IT),flag=1;
			else IT=a.erase(IT);
			if (!flag) --IT;
			if (it==s.begin()) break;
			else --it;
			if (flag){
				cout<<"No"<<endl;return 0;
			}
		}
		for (int i=1;i<=ptr;++i) s.insert(tmp[i]);
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 13056
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

x = int(input())
t = 1
while t*(t+1)//2<x:
    t += 1
print(t)

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


int main() {

  int n,k;
  cin>>n>>k;

  map<int, int> A;
  for(int i=0;i<n;i++){
    int wk;
    cin>>wk;

    if(A.count(wk))
      A.at(wk)++;
    else
    {
      A[wk]=1;
    }
  }

  vector<int> values;
  for(auto p:A){
    auto value = p.second;
    values.push_back(value);
  }

  sort(values.begin(),values.end());

  int cnt=0;
  int type_n=values.size();
  for(int i=0;i<values.size();i++){

      if(type_n<=k){
        break;
      }else{
        cnt+=values.at(i);
        type_n--;
      }
  }

  cout<<cnt<<endl;

  return 0;
}



Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    rep(i, len(s) - 1) {
        if (s[i] == s[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
N = int(input())
ans = [0] * (N - 1)
G = [list() for _ in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append([b,i])
    G[b].append([a,i])

def dfs(v,c = -1,p = -1):
    k = 1
    for i in range(len(G[v])):
        u = G[v][i][0];ei = G[v][i][1]
        if u == p:continue
        if k == c:
            k += 1
        ans[ei] = k
        k += 1
        dfs(u,ans[ei],v)

dfs(0)
mx = 0

for i in range(N):
    mx = max(mx,len(G[i]))
print(mx)

for i in range(N-1):
    print(ans[i])

Measured memory_bytes: 88824
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

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

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    SPEED;
    cout.precision(8);
    cout << fixed;
    ll n;
    cin>>n;
    if(n) cout<<0;
    else cout<<1;   
    
    purvansh11();
    return 0;
}

Measured memory_bytes: 8492
s = gets.chomp
t = gets.chomp

n = s.length

sh = Hash.new()
th = Hash.new()
("a".."z").each do |c|
  x = c.ord
  sh[x] = -1
  th[x] = -1
end

n.times do |i|
  x = s[i].ord
  y = t[i].ord
  if sh[x] >= 0
    if sh[x] != y
      puts "No"
      exit
    end
  else
    sh[x] = y
  end
  if th[y] >= 0
    if th[y] != x
      puts "No"
      exit
    end
  else
    th[y] = x
  end
end

puts "Yes"

Measured memory_bytes: 3836
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
s = input()
c = n
ans = []
while c>0:
    val = None
    for i in range(1,m+1):
        if c-i>=0 and s[c-i]=="0":
            val = i
    if val is None:
        ans = -1
        break
    c = c-val
    ans.append(val)
if ans==-1:
    print(ans)
else:
    write(" ".join(map(str, ans[::-1])))

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n%2!=0) {
    cout << "No" << endl;
    return 0;
  }
  string a = s.substr(0, n/2);
  string b = s.substr(n/2);
  cout << (a==b ? "Yes" : "No");
}


Measured memory_bytes: 256
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
a = LIST()
b = [LIST() for i in range(m)]
b.sort(key=itemgetter(1), reverse=True)

c = []
for i in range(m):
    c += [b[i][1]]*b[i][0]
    if len(c) > n:
        break

a += c
a.sort(reverse=True)
print(sum(a[:n]))

Measured memory_bytes: 36800
S = input()

S = S[::-1]


def solve(S):
    point = 0
    while S:
        if len(S) == point:
            print('YES')
            return False
        if S[point:point + 7] in {'remaerd'}:
            point += 7
        elif S[point:point + 6] in {'resare'}:
            point += 6
        elif S[point:point + 5] in {'esare', 'maerd'}:
            point += 5
        else:
            return True


if solve(S):
    print('NO')

Measured memory_bytes: 3316
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
long long x[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%lld",x+i);
	int cn=0;
	long long ret=0;
	for(int i=0;i<a;i++){
		if(x[i]<0)cn++;
		x[i]=ABS(x[i]);
		ret+=x[i];
	}
	std::sort(x,x+a);
	if(cn%2)ret-=x[0]*2;
	printf("%lld\n",ret);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int r[2002][2002]={};
int l[2002][2002]={};
int u[2002][2002]={};
int d[2002][2002]={};
bool s[2002][2002]={};

int main() {
	string str;
	cin>>str;
	if(str[0]==str[1]||str[1]==str[2]||str[2]==str[3]){
		cout<<"Bad"<<endl;
	}else{
		cout<<"Good"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




void rec(int d, ll val, vector<ll> &v) {
  v.push_back(val);
  if(d == 10) return;
  for(ll i =-1; i <= 1; i++) {
    ll add = i + val%10;
    if(add > 9 || add < 0) continue;
    rec(d+1,val * 10 + add, v);
  }
}




int main() {
  int K;
  cin >> K;
  vector<ll> v;

  for(ll i = 1; i <= 9; i++) {
    rec(1,i,v);
  }
  sort(all(v));
  cout << v[K-1] << endl;
  return 0;
}





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

int main() {
  ll N, K; cin >> N >> K;
  ll a[N];
  set<ll> s;
  map<ll,ll> count;
  for (ll i = 0; i < N; i++) {
    cin >> a[i]; s.insert(a[i]); count[a[i]]++;
  }
  vector<ll> cs;
  for (auto it = s.begin(); it != s.end(); it++) {
    cs.push_back(count[*it]);
  }
  if (cs.size() <= K) {cout << 0 << endl; return 0;}
  sort(cs.begin(), cs.end());
  ll res = 0;
  for (ll i = 0; i < cs.size()-K; i++) {
    res += cs[i];
  }
  cout << res << endl;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<vector<unsigned long>> edge(N);
    vector<unsigned long> ans(N), used(N);
    for(auto& i : edge){
        string S;
        cin >> S;
        for(unsigned long j = 0; j < N; ++j)if(S[j] & 1)i.push_back(j);
    }
    unsigned long res{0};
    const auto bfs = [&ans, &edge, &used](unsigned long begin) -> unsigned long{
        queue<pair<unsigned long, unsigned long>> q;
        q.emplace(begin, 1);
        unsigned long ret{0};
        while(!q.empty()){
            auto t = q.front();
            q.pop();
            ret = max(ret, t.second);
            if(used[t.first])continue;
            used[t.first] = 1;
            ans[t.first] = t.second;
            for(const auto& i : edge[t.first]){
                if(used[i]){
                    if(~(ans[i] ^ t.second) & 1)return -1;
                }else{
                    q.emplace(i, t.second + 1);
                }
            }
        }
        return ret;
    };
    for(unsigned long i = 0; i < N; ++i){
        fill(ans.begin(), ans.end(), 0UL);
        fill(used.begin(), used.end(), 0UL);
        auto t = bfs(i);
        if(!~t)return 0 & puts("-1");
        res = max(res, t);
    }
    cout << static_cast<long>(res) << endl;
    return 0;
}

Measured memory_bytes: 676
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int q;
    int c,a,n;
    int ans;
    cin>>q;
    for(int i=0;i<q;i++){
        ans = 0;
        cin>>c>>a>>n;
        if(n > 0){
            ans += min(c,min(a,n));
            c -= ans;
            a -= ans;
            n -= ans;
        }
        if(a > 0){
            ans += min(c/2,a);
            c -= min(c/2,a)*2;
            a -= min(c/2,a);
        }
        ans += c/3;
        cout<<ans<<"\n";
    }
    return 0;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
 
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	for (int i=0;i<=10000;i ++)
		if (a*i%b==c%b) {
			puts("YES");
			return 0;
		}
	puts("NO");
	return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    int s = 0;
    for (int i = 1; i * (i + 1) <= 2 * n; i++) {
        if (i * (i + 1) == 2 * n) s = i;
    }
    // cout << s << endl;
    if (s == 0) {
        cout << "No" << endl;
        return 0;
    }


    int k = n * 2 / s;

    cout << "Yes" << endl;
    cout << k << endl;

    int rem = 1, idx = -1;
    vvi v;
    rep(i, k) {
        vi x;
        rep(j, v.size()) {
            x.push_back(v[j][idx]);
        }
        // cout << i << " : " << x.size() << endl;
        int sz = x.size();
        rep(j, s - sz) x.push_back(rem++);
        idx++;

        v.push_back(x);
        cout << s << " ";
        rep(j, x.size()) cout << x[j] << " ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N, M = map(int, input().split())
    return N * M


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll n;
    cin >> n;
    vector<array<ll, 3>> ab(n);
    REP(i, n){
        ll ai, bi;
        cin >> ai >> bi;
        ab.at(i) = {ai + bi, ai, bi};
    }
    sort(ALL(ab));
    ll ans = 0;
    REP(i, n){
        if(i % 2 == 0){
            ans += ab.at(n - i - 1).at(1);
        }else{
            ans -= ab.at(n - i - 1).at(2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int A, B, K;

int main(){
  cin >> A >> B >> K;
  int i;
  for(i=100;i>0 && K>0;i--){
    K-=(A%i==0 && B%i==0)?1:0;
  }
  cout << i+1 << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

ll conv3(ll x){
  return x * (x-1) * (x-2) / (6);
}

ll conv2(ll x){
  return x * (x-1) / (2);
}

int main() {

  ll N; cin >> N;
  vector<ll> a(N);
  REP(i, N)cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll al=0, b=0;
  REP(i, N){
    if(i % 2){
      b += a[i];
    }else{
      al += a[i];
    }
  }
  cout << al-b << endl;

 
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 2000000009
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b;
	cout<<b*2-a;
}

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

typedef long long ll;

int main(){
    ll s = 0;
    ll n, tmp;
    ll a[100002] = {0};
    cin >> n;
    for(ll i = 1; i <= n; ++i){
        cin >> tmp;
        ++a[tmp];
        s += tmp;
    }

    ll q;
    cin >> q;
    ll b, c;
    for(ll i = 0; i < q; ++i){
        cin >> b >> c;
        s = s - a[b]*b + a[b]*c;
        a[c] += a[b];
        a[b] = 0;
        cout << s << endl;
    }
    return 0;
}

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

int main()
{
	int n;	
	cin>>n;
	vector<int> dp(3);
	for(int i=0;i<n;i++){
		vector<int> c(3);
		for(int j =0;j<3;j++)
			cin>>c[j];
		vector<int> new_dp(3,0);
		for(int k =0;k< 3;k++)
		{
			for(int j =0;j<3;j++)
			{
				if(k!=j)
				{
					new_dp[j] = max(new_dp[j],dp[k]+c[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]})<<"\n";	
	
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  ////////
  vector<int> b(n),ans(n);
  rep(i,n) b[i]=a[i];
  sort(all(b));
  int M=b[n-1];
  rep(i,n){
    if(a[i]!=M){
      ans[i]=M; 
    }
    else{
      ans[i]=b[n-2];
    }
   
  }
  rep(i,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long h = sc.nextLong();
        long w = sc.nextLong();
        long[] a = new long[n];
        long[] b = new long[n];
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
            cnt += Math.min(a[i] / h, b[i] / w);
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 24148
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
int n,k,store[1010];
ll ans=0;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>store[i];
	sort(store,store+n);
	for(int i=0;i<k;i++){
		ans+=store[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define N 101
#define INF 10000000
#define NIL -1

int main()
{
  int n, i, j, v, u, min=0, sum=0;
  int G[N][N];
  int d[N], pi[N], color[N];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &G[i][j]);
      if(G[i][j] == -1) G[i][j] = INF;
    }
  }

  for(u = 0; u < n; u++){
    d[u] = INF;
    pi[u] = NIL;
    color[u] = 1;
  }

  d[0] = 0;

  while(1){
    min = INF;
    for(i = 0; i < n; i++){
      if(color[i] != 2 && d[i] < min){
  	min = d[i];
  	u = i;
      }
    }

    if(min == INF) break;

    color[u] = 2;
    for(v = 0; v < n; v++){
      if(color[v] != 2 && G[u][v] < d[v]){
  	pi[v] = u;
  	d[v] = G[u][v];
      }
    }
  }

  for(u = 0; u <n; u++){
    if(pi[u] != NIL) sum += G[u][pi[u]];
  }

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

  return 0;
}

Measured memory_bytes: 640
n = int(input())
b = list(map(int , input().split()))

def f(c):
    for i in reversed(range(len(c))):
        if c[i] == i+1:
            return (c[i], c[:i] + c[i+1:])
    return (-1, c)

ans = []
for i in range(n):
    (a, b) = f(b)
    if a == -1:
        print(-1)
        exit()
    ans.append(a)
    #print(ans, b)

print('\n'.join(map(str, reversed(ans))))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint d(n);
    rep(i, n) cin >> d[i];
    int m;
    cin >> m;
    vint t(m);
    rep(i, m) cin >> t[i];

    map<int, int> mp;
    rep(i, n) {
        mp[d[i]]++;
    }

    rep(i, m) {
        if (mp[t[i]] == 0) {
            puts("NO");
            return 0;
        }
        mp[t[i]]--;
    }
    
    puts("YES");
    return 0;
}

Measured memory_bytes: 11136