akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int n;
int m;
bool one[200001];
bool nn[200001];

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

  for(int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    if(a == 1) one[b] = true;
    if(b == n) nn[a] = true;
  }

  bool ok = false;

  for(int i = 0; i < n; i++) {
    if(one[i] && nn[i]) {
      ok = true;
      break;
    }
  }

  if(ok) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}
    
  


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define READ(A, N) REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << ans << endl;

int 
getGDC(int a, int b)
{
  if (b % a) return getGDC(b % a, a);

  return a;
}

int
main()
{
  int A, B, K; cin >> A >> B >> K;

  int gdc;
  if (A < B) gdc = getGDC(A, B);
  else gdc = getGDC(B, A);

  int ans;
  int index = 0;
  for (int i = gdc; i >= 1; i--) {
    if (!(gdc % i)) {
      index++; 
      if (index == K) { ans = i; break; }
    }
  }

  ANS(ans);

  return 0;
}


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

pt = {
  "r": P,
  "s": R,
  "p": S
}

ans = 0
l = [False] * N

for i in range(K):
  ans += pt[T[i]]
  l[i] = True

for i in range(K, N):
  if T[i] == T[i-K] and l[i-K]: continue
  ans += pt[T[i]]
  l[i] = True
    
print(ans)

Measured memory_bytes: 4084
#include<iostream>
#include<memory>
#include<cstdlib>
#include<cstdio>
#include<cstring>

using namespace std;

struct node {
	unsigned int key;
	struct node* next;
	struct node* prev;

};

typedef struct node* NodePointer;

NodePointer nil;

void init() {
	nil = (NodePointer) malloc(sizeof(node));
	nil->next = nil;
	nil->prev = nil;

}



node* listSearch(int key) {
	node* cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void printList() {
	node* cur = nil->next;
	int isf = 0;
	while (1) {
		if (cur == nil)break;
		if (isf++ > 0)printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}
void deleteNode(node* t) {
	if (t == nil)return;
	t->next->prev = t->prev;
	t->prev->next = t->next;
	free(t);
}

void deleteFirst() {
	node* t = nil->next;
	if (t == nil)return;
	deleteNode(t);
}
void deleteLast() {
	node* t = nil->prev;
	if (t == nil)return;
	deleteNode(t);

}
void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
	node* x = (node*)malloc(sizeof(node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main() {

	int n,key,i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (int i = 0; i < n; i++) {
		scanf("%s%d", com, &key);
			if (com[0] == 'i') {
				insert(key);
				np++;
				size++;
			}
			else if (com[0] == 'd') {
				if (strlen(com) > 6) {
					if (com[6] == 'F')deleteFirst();
					if (com[6] == 'L')deleteLast();
				}
				else {
					deleteKey(key); nd++;
				}
				size--;
			}

			
		
	}
	printList();
	return 0;




}


Measured memory_bytes: 34480
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=K%N
ANS=[-1 for i in range(N)]
a=0
count=1
for i in range(N):
  a=A[a]-1
  if ANS[a]==-1:
    ANS[a]=count
    count+=1
  else:
    roop=count-ANS[a]
    break
if K<count:
  ans=ANS.index(K)+1
else:
  b=(K-ANS[a])%roop+ANS[a]
  ans=ANS.index(b)+1
print(ans)

Measured memory_bytes: 32380
A, B, C, D, E, F = map(int,input().split())

a = set()
for i in range(0, F+1, 100*A):
  for j in range(0, F+1-i, 100*B):
    a.add(i+j)
b = set()
for i in range(0, F+1, C):
  for j in range(0, F+1-i, D):
    b.add(i+j)
tmp = -1
for aa in a:
  for bb in b:
    if(0 < aa+bb <= F and bb <= aa*E//100):
      if(tmp < bb/(aa+bb)):
        ans = aa+bb, bb
        tmp = bb/(aa+bb)
print(ans[0], ans[1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

bool prime_num(ll x) {
    if (x == 1) return false;
    else if (x == 2) return true;
    else if (x % 2 == 0) return false;
    else {
        for (ll i = 3; i*i <= x; i += 2) {
            if (x % i == 0) return false;
        }
    }
    return true;
}

int main()
{
    ll n, p;
    cin >> n >> p;

    ll ans = 1;
    bool x[1000003] = {};
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    if (n >= 40) {
        cout << 1 << endl;
        return 0;
    }
    if (prime_num(p)) {
        if (n == 1) ans = p;
        else ans = 1;
        cout << ans << endl;
        return 0;
    } else {
        for (int i = 1; i <= 1000002; i++) {
            ll y = pow(i, n);
            if (y > p) break;
            if (p % y == 0) x[i] = true;
        }
        for (int i = 1000002; i >= 1; i--) {
            if (x[i]) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
        return 0;
    }


}


Measured memory_bytes: 1280
N = int(input())

P = []

S = 0

for i in range(N):
   P.append(list(map(int,input().split())))


for i in range(N-1):
   for j in range(i+1,N):
       
       S += ((P[i][0] - P[j][0])**2 + (P[i][1] - P[j][1])**2)**0.5
       
print(S*(2/N))  


Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1: #素数の場合はここ
        arr.append([temp, 1])
 
    if arr==[]: #1の場合はここ
        arr.append([n, 1])
 
    return arr

def count(X):
  cnt = 0
  now = 1
  while cnt+now <=X:
    cnt += now
    now += 1
  return now-1
#print(count(3))    

N = int(input())
if N == 1:
  print(0)
  exit()
A = factorization(N)
#print(A)
ans = 0
for i in range(len(A)):
  ans += count(A[i][1])
print(ans)


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


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

int n,m;
vector<int> g[100000],r[100000];
bool used[100000],ok[2];

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

	cin>>n>>m;
	REP(i,m) {
		int a,b;cin>>a>>b;a--,b--;
		g[a].pb(b),g[b].pb(a);
	}
	deque<int> dq;
	int l=0,r=g[0][0];
	used[l]=used[r]=true;
	dq.pf(l),dq.pb(r);
	do {
		//cout<<"l,r "<<l<<' '<<r<<endl;
		if(!ok[0]) {
			int nxt=-1;
			for(auto u:g[l]) {
				//cout<<"u,used "<<u<<' '<<used[u]<<endl;
				if(!used[u]) {
					nxt=u;
					break;
				}
			}
			if(nxt!=-1) {
				used[nxt]=true;
				l=nxt;
				dq.pf(l);
			}
			else ok[0]=true;
		}
		if(!ok[1]) {
			int nxt=-1;
			for(auto u:g[r]) {
				if(!used[u]) {
					nxt=u;
					break;
				}
			}
			if(nxt!=-1) {
				used[nxt]=true;
				r=nxt;
				dq.pb(r);
			}
			else ok[1]=true;
		}
	} while(!ok[0]||!ok[1]);

	cout<<dq.size()<<endl;
	for(auto v:dq) cout<<v+1<<' ';
	cout<<endl;

	return 0;
}


Measured memory_bytes: 9216
#input
N, T = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

#output
import numpy as np
A = np.array(A, np.int)
B = np.array(B, np.int)

idx = np.argsort(A)

A = A[idx]
B = B[idx]

dp = np.zeros((N, T), np.int)
#dp[品物][時間]

for i in range(N-1):
    dp[i+1, :A[i]] = dp[i, :A[i]]
    dp[i+1, A[i]:] = np.maximum(dp[i, A[i]:], dp[i, :-A[i]]+B[i])

print(np.max(dp[:, -1] + B))

Measured memory_bytes: 84816
#include <iostream>

using namespace std;
    int p[100][11];
int main(){
    int n;
    cin >> n;
    int f[n][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin >> f[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin >> p[i][j];
        }
    }
    int count[n];
    int ans = -1000000000;
    for(int i=1;i<1024;i++){
        //cout << int(i&f[0])<<endl;
        for(int j=0;j<n;j++){
            count[j] = 0;
        }
        for(int j=0;j<10;j++){
            for(int k=0;k<n;k++){

           // cout << int((i&j)&f[k]) << endl;
                if( ((i>>j)&1)&&f[k][j]){

                    //cout << "count[" << k << "] is" << count[k]<<endl;
                    count[k] ++;
                }
            }
        }
        //cout << count[0] << endl;
        int tmp=0;
        for(int j=0;j<n;j++){
            tmp += p[j][int(count[j])];
            /*cout << count[j]<<endl;
            cout << p[j][count[j]]<<endl;*/
        }
        if(tmp > ans){
            ans = tmp;
        }
    }
    cout << ans <<endl;return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    mid = n//2
    print(d[mid]-d[mid-1])
    return

if __name__=='__main__':
    n = I()
    d = sorted(list(IL()))
    solve()

Measured memory_bytes: 38868
from collections import deque


n,m = map(int,input().split())

ab_list = [list(map(int,input().split())) for _ in range(m)]

ab_count = {key:[] for key in range(1,n+1)}

for i in range(m):
    ab_count[ab_list[i][0]].append(ab_list[i][1])
    ab_count[ab_list[i][1]].append(ab_list[i][0])


#print(ab_count)

que = deque()

#始点は1、階層は0からスタート
que.append([1,0])

checked_dict = {key:[] for key in range(1,n+1)}
#temp_dict = {key:[] for key in range(1,n+1)}
where = 0

while que:
    x_pop = que.popleft()
    x = x_pop[0]
    if where != x_pop[1]:
        pass
        ##階層が代わったから、temp_dictをchecked_dictへ反映させる処理
        #for k in range(1,n+1):
        #    if len(checked_dict[k]) == 0:
        #        checked_dict[k] = temp_dict[k]
        #    else:
        #        aaa = set(checked_dict[k]) & set(temp_dict[k])
        #        if aaa != set():
        #            checked_dict[k] = list(aaa)

    where = x_pop[1]

    for j in ab_count[x]:
        if len(checked_dict[j]) == 0:
            #OK,temp_dictに入れて、queに入れる。
            #temp_dict[j].append(x)
            checked_dict[j].append(x)
            que.append([j,where+1])
        else:
            continue

    

print("Yes")
for i in range(2,n+1):
    print(checked_dict[i][0])



Measured memory_bytes: 141332
#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ull a;
	string b;
	cin >> a >> b;
	ull c = 0;
	for (char x : b) {
		if (x == '.') continue;
		c *= 10;
		c += (x-'0');
	}
	cout << (a*c)/100ll << '\n';
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define emp emplace
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 210000;
const ll MAXK = 17;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int A[MAXN];
int B[MAXN];
int N,K;

int main(){
	cin>>N>>K;
	for (int i=1;i<=N;++i)cin>>A[i];
	if(K>50)K=50;
	for (int w=0;w<K;++w){
		memset(B,0,sizeof(B));
		for (int t=1;t<=N;++t){
			int l = max(1, t-A[t]);
			int u = min(N, t+A[t]);
			B[u+1]--;
			B[l]++;
		}
		for (int i=1;i<=N;++i)B[i]+=B[i-1];
		int fail = 0;
		for(int i=1;i<=N;++i){
			// cout<<B[i]<<' ';
			if(B[i]!=N)fail=1;
			A[i]=B[i];
		}
	}
	for (int i=1;i<=N;++i){
		cout<<A[i]<<' ';
	}
}

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

int main() {

  int a,b,h,m,d10;
  double c,d,r,ans;

  cout << fixed << setprecision(10);

  cin >> a >> b >> h >> m;

  d10 = (55*(h*60+m))%3600;
  d = d10/10.0;
  r = d*3.14159265358979/180.0;
  c = a*a+b*b-2.0*a*b*cos(r);
  ans = sqrt(c);

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


Measured memory_bytes: 4228
import java.util.*;
import java.lang.*;

class Main
{
    public static void main (String[] args) throws java.lang.Exception
	{
	    for (int i = 1; i <= 9; i++){
            for (int j = 1; j <= 9; j++){
                System.out.println(i + "x" + j +"=" + i * j);
            }   
	    }
	}
}

Measured memory_bytes: 17048
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define pqueue priority_queue
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    //typedef pair<int,int> P;
    int N;
    cin>>N;
    vin X(N);
    fin(N,X);
    ldouble sum1=0,sum2=0;
    rep(0,N){
        sum1+=X.at(i);
        sum2+=X.at(i)*X.at(i);
    }
    double temP=sum1/N;
    int P=sum1/N;
    if(temP-P>0.5) P++;
    cout<<sum2-2*P*sum1+N*P*P<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << -1 << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int A[25],B[25],C[25];
    cin >> N;
    REP(i,N){
        cin >> A[i];
        A[i]--;
    }
    REP(i,N){
        cin >> B[i];
    }
    REP(i,N-1){
        cin >> C[i];
    }
    int Ans=0;
    int prea=114514;
    REP(i,N){
        int a=A[i];
        Ans+=B[a];
        if(prea+1==a){
            Ans+=C[prea];
        }
        prea=a;
        //cout << Ans << endl;
    }
    cout << Ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N, K;

    scanf("%d%d", &N, &K);

    int A[N];
    long long c[N+1];

    for(int i = 1; i <= N; i++){
        c[i] = 0;
    }

    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        c[A[i]]++;
    }

    mergeSort(c, 1, N+1);

    long long ans = 0;
    int t = 0;

    for(int i = 1; i <= N - K; i++){
        if(c[i] > 0){
            ans += c[i];
            t++;
        }
    }

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

    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B), x(M), y(M), c(M);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    rep(i, M) cin >> x[i] >> y[i] >> c[i], x[i]--, y[i]--;

    int minA = a[0];
    rep(i, A) chmin(minA, a[i]);
    int minB = a[0];
    rep(i, B) chmin(minB, b[i]);

    int ans = minA + minB;
    rep(i, M) chmin(ans, a[x[i]] + b[y[i]] - c[i]);

    cout << ans << endl;
}


Measured memory_bytes: 2176
N = input()
n = int(N)

if len(N) <= 1:
	print(n)
elif len(N) <= 2:
	print(9)
elif len(N) <= 3:
	print(9+n-99)
elif len(N) <= 4:
	print(9+999-99)
elif len(N) <= 5:
	print(9+999-99+n-9999)
else:
	print(90909)

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
a.sort()
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:ma-=i
  else:mi-=i
print(ma-mi)
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:print(ma,i);ma-=i
  else:print(mi,i);mi-=i
print(ma,mi)

Measured memory_bytes: 14264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

string N;ll K,n;

ll nCr(ll nn,ll r){
    if(r>n)return 0;
    if(r==1)return nn;
    if(r==2)return nn*(nn-1)/2;
    if(r==3)return nn*(nn-1)*(nn-2)/6;
    return 0;
}

ll dp(ll i,ll k,bool smaller){
    if(k==0)return 1;
    else if(i==n)return 0;

    if(smaller)return nCr(n-i,k)*pow(9,k);
    else {
        if (N[i] == '0') return dp(i+1, k, false);
        else {
            ll oxx = dp(i+1, k, true);
            ll xxx = dp(i+1, k-1, true) * (N[i] - '1');
            ll nxx = dp(i+1, k-1, false);
            return oxx+xxx+nxx;
        }
    }
}

void solve() 
{
    cin>>N>>K;
    n=N.size();
    cout<<dp(0,K,0)<<endl;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long mod = 1000000007;
        long res = 1;
        int[] p = new int[3];
        Arrays.fill(p, -1);
        for(int i=0; i<n; i++) {
            int a = sc.nextInt();
            int c = 0;
            for(int j=0; j<3; j++) {
                if (p[j] + 1 == a) {
                    c++;
                }
            }
            if(c == 1) {
                //
            } else if (c==2) {
                res *= 2;
            } else if (c==3) {
                res *= 3;
            } else {
                System.out.println(0);
                return;
            }
            res %= mod;
            for(int j=0; j<3; j++) {
                if (p[j] + 1 == a) {
                    p[j]++;
                    break;
                }
            }

        }
        System.out.println(res);
    }

}




Measured memory_bytes: 49012
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
// #define modd 2019

#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>

#include <cassert>
// #include <algorithm>
#include <functional>
using namespace std;

int euk(int a, int b){
    if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
//   printf("最大公約数 = %d\n", b);
 
  return b;

}

int main(){
  int a; string s;
  cin >> a; cin >> s;
  if(a < 3200){
    cout << "red";
    return 0;
  }  
  else{
    cout << s;
    return 0;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;


int main()
{
	long long e[4];
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	e[0] = a * c;
	e[1] = a * d;
	e[2] = b * c;
	e[3] = b * d;

	sort(e, e + 4);

	cout << e[3];

}

Measured memory_bytes: 3672
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");
   //  String nyu=sc.nextLine();

int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);

if(A>B){
System.out.println(A+A-1);

}else if(A<B){
System.out.println(B+B-1);

}else{
System.out.println(B+A);

}




	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(){
    long double a,b,c;
    cin >> a >> b >>c;
    if(c-a-b>0){
        if(a*a+b*b+c*c+2*(a*b-b*c-a*c)>4*a*b){
            cout <<"Yes";
        }else{
            cout <<"No";
        }
    }else{
        cout << "No";
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int h,k,i=1,cnt=0;
	cin>>h;
	cnt=1;
	i=1;
	while(h!=1){
		h=h/2;
		cnt+=2*i;
		i*=2;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}

bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

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

vl v[100005];
bool vis[100005];

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   	ll n,W;
   	cin>>n>>W;
   	ll w[n],v[n];
   	ll S=0;
   	for(ll i=0;i<n;i++){
   		cin>>w[i]>>v[i];
   		S+=v[i];
   	}
   	ll dp[n+1][S+1];
   	memset(dp,INF,sizeof dp);
   	for(ll i=0;i<=n;i++){
   		dp[i][0]=0;
   	}
   	for(ll i=1;i<=n;i++){
   		for(ll j=1;j<=S;j++){
   			//dp[i][j]=INF;
   			if(v[i-1]<=j){
				dp[i][j]=min(dp[i-1][j-v[i-1]]+w[i-1],dp[i-1][j]);
   			}
   			else{
   				dp[i][j]=dp[i-1][j];
   			}
   			//cout<<dp[i][j]<<" ";
   		}
   		//cout<<endl;
   	}
   	ll ans=0;
   		for(ll j=1;j<=S;j++){
   			if(dp[n][j]<=W){
   				ans=max(ans,j);
   			}
   		}
   	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 84816
// dp の遷移は定式化！！

// 題意の整理
// S^i:=<S[0],S[1],...,S[i]>   i=0 ~ N-1
// p\in Sym_{i+1};  S^i(p):=<S[p(0)],S[p(1)],...,S[p(i)]>
// rmod(x,vec):= x mod vec[0] mod ... mod vec[n-1]
// dp[i][x]:= \sum_{p\in Sym_{i+1}} rmod(x,S^i(p))

// dp の遷移
// p \in Sym_{i}, 0<=t<=i ; p+t:=<p(0),p(1),...,p(t-1),i+1,p(t),...,p(i-1)>
// Sym_{i+1}= {p' | <p'(0),p'(1),...,p'(i)>}
//          = \bigcup_{0<=t<=i} {p+t| p\in Sym_i}
// Sが昇順のとき、
// rmpd(x,S^i(p+t))=  rmod(x%S[i],S^{i-1}(p))      t  =  i
//                    rmod(x,S^{i-1}(p))           t\neq i
// dp[i][x]= \sum_{p\in Sym_{i}}\sum_{0<=t<=i} rmod(x,S^i(p+t))
//         = \sum_{p\in Sym_{i}} (rmod(x%S[i],S^{i-1}(p))
//                                + i*rmod(x,S^{i-1}(p)))
//         = dp[i-1][x%S[i]]+i*dp[i-1][x]

#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) ((i)?"Yay!":":(")
#define MOD 1000000007
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
li inv(li a){
  // unordered_map 必須
  static unordered_map<li,li> f;
  f[1]=1;
  a%=MOD;
  if(f.find(a)!=f.end())return f[a];
  return f[a]=MOD-MOD/a*inv(MOD%a)%MOD;
}
li fact(li a){
  // vector,repa 必須
  static vector<li> f(1,1);

  if(f.size()>a)return f[a];
  if(df)print(a,"!");
  int n=f.size();
  repa(i,n,a+1){
    f.push_back(f[i-1]*i%MOD);
    if(df)print(i,a+1,f[i]);
  }
  return f[a];
}

int main(){
  int n,x; cin >>n >>x;
  vector<int> s(n); rep(i,n) cin >>s[i];
  sort(s.begin(),s.end());
  vector<vector<li>> dp(n,vector<li>(x+1,0));
  rep(j,x+1) dp[0][j]=j%s[0];
  repa(i,1,n){
    rep(j,x+1){
      dp[i][j]=(dp[i-1][j%s[i]]+i*dp[i-1][j]%MOD)%MOD;
    }
  }
  print(dp[n-1][x]);
}

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

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,r;
    cin>>n>>r;
    int rating = 0;
    if(n<10){
        rating = 100 * (10-n);
        rating+=r;
        cout<<rating<<endl;;
    }else{
        rating = r;
        cout<<rating<<endl;
    }
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 20:01:31
*/

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


int main(){
    int n,a;
    cin >> n >> a;
    n %= 500;
    if(n>a) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>
#define N 10000
int Prime(int);

int main(){
  int A[N], i, j, n, c=0;

  scanf("%d", &n);

  for (i = 0; i < n; i++){
    scanf("%d", &A[i]);
    c += Prime(A[i]);
  }
  printf("%d\n", c);

  return 0;
}

int Prime(int a)
{
  int i;
  if(a < 2) return 0;
  else if (a == 2) return 1;
  else if (a % 2 == 0) return 0;
  for(i = 3; i <= sqrt(a); i += 2){
    if(a % i == 0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2108
from collections import Counter
N=int(input())
A=[0]+list(map(int,input().split()))

def fast_factorization_init(N):
    res=list(range(N))
    for i in range(2,N):
        if i*i>N:
            break
        for j in range(i*i,N,i):
            if res[j]==j:
                res[j]=i
        if res[i]<i:
            continue
    return res            
    
min_factors=fast_factorization_init(2*10**5+10)
def fast_factorization(n):
    res=[]
    while n>1:
        res.append(min_factors[n])
        n//=min_factors[n]
    return res

def factors(n):
    res=[1]
    for i,j in Counter(fast_factorization(n)).items():
        res+=[r*i**(b+1) for r in res for b in range(j)]
    return res

res=[0]*(N+1)
num=0
for n in reversed(range(N)):
    res[n+1]=A[n+1]
    if A[n+1]:
        num+=1
        for m in factors(n+1):
            A[m]=(A[m]+1)%2
print(num)
print(*[i+1 for i in range(N) if res[i+1]>0],sep='\n')

Measured memory_bytes: 102676
A, B, C, X, Y = map(int, input().split())

ans = 10**9
for i in range(max(X, Y)+1):
    price = 2*C*i
    p_A, p_B = X, Y
    p_A -= i
    p_B -= i
    if p_A > 0:
        price += p_A*A
    if p_B > 0:
        price += p_B*B
    ans = min(ans, price)

print(ans)


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

int main() {
    string N; cin >> N;
    if((N[0]==N[1] && N[1]==N[2]) || (N[1]==N[2] && N[2]==N[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin>>A>>B;
  int sum=0;
  for(int i=A;i<B+1;i++){
    int s,t,u,v;
    s=i%10;//11111_11110+1
    t=i/10%10;//1111_1110+1
    u=i/1000%10;//111_110
    v=i/10000;
    if(s==v&&t==u){
      sum+=1;
    }
  }
  cout<<sum<<endl;
}
    
      

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

int main()
{
	long n = 0, a = 0, min = 1000000, max = -1000000, s = 0;
	cin >> n ;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (min > a)
			min = a;
		if (max < a)
			max = a;
		s += a;
		
	}
	cout << min << " " << max << " " << s << endl;
	return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
int main()
{
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=n;
    if(n>=b-1)x=b-1;
    ll ans=a*(x%b)/b;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3592
/* ex4_3 Stone Monument
    dada__              */
#include<stdio.h>
int depth(int height_W, int height_E); //プロトタイプ宣言

int main(void){
    int height_W, height_E;

    scanf("%d %d", &height_W, &height_E); //入力
    printf("%d", depth(height_W, height_E)); //出力
    
    return 0;
}

//depth関数の定義
int depth(int height_W, int height_E){
    int height_dif, ans;
    
    height_dif = height_E - height_W; //塔の高さの差の算出
    ans = height_dif*(height_dif+1)/2 - height_E; //東側の塔の本当の高さから雪の深さの算出
    return(ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  q*=4;
  h*=2;
  ll sum=0;
  if(d/2<q && d/2<h && d/2<s){
    while(n>=2){
      n-=2;
      sum+=d;
    }
  }
  if(q<s && q<h){
    sum+=n*q;
  }
  else if(s<q && s<h){
    sum+=n*s;
  }
  else{
    sum+=n*h;
  }
  cout<<sum<<'\n';
  return(0);
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int a=0,b=0,c=0,d=0,m=0,n=0,h=0,w=0,count=0,ans=0;
  string s;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  m=round((double)(vec_sum(v))/n);
  for(int i=0;i<n;i++){
    ans+=(int)pow(m-v[i],2);
  }
  cout<<ans<<endl;
  
}
///////////////////////////

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;cin >> n;
    vvl g(n,vl(n)), emp(n,vl(n,1));
    rep(i,n){
        rep(j,n){
            g[i][j]=min({i+1,j+1,n-i,n-j});
        }
    }
    ll ans=0;
    rep(i,n*n){
        ll t;cin >> t;t--;
        ll x=t%n,y=t/n;
        queue<pl> que;
        que.push({y,x});
        g[y][x]--;emp[y][x]--;
        ans+=g[y][x];
        while(!que.empty()){
            pl v=que.front();que.pop();
            rep(i,4){
                ll ny=v.fi+dy[i],nx=v.se+dx[i];
                if(ny<0||nx<0||ny>=n||nx>=n)continue;
                if(emp[ny][nx]){
                    if(chmin(g[ny][nx],g[v.fi][v.se]+1))que.push({ny,nx});
                }
                else {
                    if(chmin(g[ny][nx],g[v.fi][v.se]))que.push({ny,nx});
                }
            }
        }
        /*cout << ans <<" "<<t <<endl;
        rep(i,n){
            rep(j,n){
                cout << g[i][j];
            }
            cout << " ";
            rep(j,n){
                cout << emp[i][j];
            }
            cout << endl;
        }
        cout << endl;*/
    }
    cout << ans <<endl;
}


Measured memory_bytes: 7568
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


void solve(){
  int n, m; cin >> n >> m;
  vector<bool> a(n, true);
  for(int i = 0; i < m; i++){
    int x; cin >> x;
    a[x] = false;
  }
  vector<unsigned long long int> dp(n + 1, 0);
  dp[0] = 1;
  for(int now = 0; now < n; now++){
    for(int next = now + 1; next <= min(n, now + 2); next++){
      if(a[next] == true){
        dp[next] += dp[now];
        dp[next] %= 1000000007;
      }
    }
  }
  cout << dp[n] << endl;
  return;
}

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


Measured memory_bytes: 1024
import sys

n, y = map(int, input().split())
money = 0
a = 0
b = 0
c = 0

for i in range(n+1) :
  for j in range(n-i,-1,-1) :
    a = i
    b = j
    c = n - i - j
    money = 10000*a + 5000*b + 1000*c
    if money == y :
      print(a,b,c)
      sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 3064
import java.io.*;

import java.util.*;
import java.math.*;



class Main{

	private static ArrayList<Integer> sum_check(int a){

		int count = 0;
		ArrayList<Integer> s = new ArrayList<Integer>();
		
		for(int i=0;i<=a;i++){
			s.add(0);
		}
		s.set(2,1);
		for(int i=3;i<=a;i=i+2) s.set(i,1);
		for(int i=3;i<=Math.sqrt(a);i=i+2){
			if(s.get(i) == 0) continue;
			for(int j=i+i;j<=a;j=j+i)s.set(j,0);
		}		
		return s;

	}

	

		public static void main(String args[]) throws IOException{

			Scanner scan = new Scanner(System.in);

			int n,count;
			ArrayList<Integer> a = new ArrayList<Integer>();

			ArrayList<Integer> res = new ArrayList<Integer>();


			while(scan.hasNext()){
				count = 1;

				String str1 = scan.next();

				n = Integer.valueOf(str1).intValue();

				if(n == 1)res.add(0);
				else{
					a = sum_check(n);
					for(int i=3;i<=n;i=i+2){
						if(a.get(i) == 1)count++;
					}
					res.add(count);
				}

			}
			for(int i=0;i<res.size();i++){
				System.out.println(res.get(i));
			}

		}

}

Measured memory_bytes: 22000
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N, M;
	cin >> N >> M;
	VVI A(N);
	REP(i, M){
		int a, b;
		cin >> a >> b;
		a--;b--;
		A[a].push_back(b);
		A[b].push_back(a);
	}

	int Q;
	cin >> Q;
	VI V(Q), D(Q), C(Q);
	REP(i, Q){
		cin >> V[i] >> D[i] >> C[i];
		V[i]--;
	}

	VI ret(N, 0);
	VI done(N, -1);

	REP(i, Q){
		int v = V[Q - 1 - i];
		int d = D[Q - 1 - i];
		int c = C[Q - 1 - i];

		queue<PII> que;
		que.push(MP(v, d));
		while(!que.empty()){
			auto next = que.front();
			que.pop();
			if(next.second <= done[next.first]) continue;

			if(ret[next.first] == 0) ret[next.first] = c;
			done[next.first] = next.second;

			if(next.second == 0) continue;
			EACH(a, A[next.first]){
				que.push(MP(a, next.second - 1));
			}
		}
	}

	EACH(r, ret) cout << r << endl;

	return 0;
}


Measured memory_bytes: 8988
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

int main(){
	ll h,n;
	P p[10010];
	cin>>h>>n;
	ll dp[M];
	rep(i,0,M)dp[i]=inf;
	rep(i,0,n){
		cin>>p[i].first>>p[i].second;
	}
	dp[0]=0;
	rep(i,0,h+1){
		rep(j,0,n){
			ll hp=p[j].first,mp=p[j].second;
			dp[i+hp]=min(dp[i+hp],dp[i]+mp);
		}
	}
	rep(i,h,h+10001)dp[h]=min(dp[h],dp[i]);
	//rep(i,1,h+p[0].first+1)cout<<dp[i]<<" ";
	//cout<<endl;
	print(dp[h]);


}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <climits>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

int N;
string s[1000];
int blank[1000];
int a,b;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> s[i];
    for(int j=0;j<N;j++){
      if(s[i][j] == '.'){
        blank[i]++;
        a++;
      }
      else{
        b++;
      }
    }
  }
  if(a == N*N){
    cout << "-1" << endl;
    return 0;
  }
  else if( b == N*N){
    cout << "0" << endl;
    return 0;
  }

  int ans = 1001001001;
  for(int i=0;i<N;i++){
    if(blank[i] == 0){
      ans = 0;
    }
    bool f = false;
    for(int j=0;j<N;j++){
      if(s[j][i] == '#'){
        f=true;
        break;
      }
    }
    if(f && ans > blank[i]){
      ans = blank[i];
    }
    else if(!f && ans > blank[i] + 1){
      ans = blank[i]+1;
    }
  }
  for(int j=0;j<N;j++){
    int f=0;
    for(int i=0;i<N;i++){
      if(s[i][j] == '.'){
        f=1;
        break;
      }
    }
    if(f==0) ans--;
  }
  cout << ans+N << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 300002;

ll n,ru[N];
string s;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>s;
	ru[0]=0;
	if(s[0]=='E')ru[0]=1;
	FOR(i,1,s.size()){
		if(s[i]=='E')ru[i]=ru[i-1]+1;
		else ru[i]=ru[i-1];
	}
	ll ans=ru[n-1]-ru[0];
	FOR(i,1,s.size()){
		ll k=(i-ru[i-1])+ru[n-1]-ru[i];
		ans=min(k,ans);
	}
	pri(ans);
	return 0;
}


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

using namespace std;

const int N=100000+10;
const int inf=0x3f3f3f3f;

int n,k;
int dis[N];

int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>dis[i];
	}
	int ret=inf;
	for(int i=1;i+k-1<=n;++i)
	{
		int x,y;
		x=min(abs(dis[i]),abs(dis[i+k-1]));
		y=dis[i+k-1]-dis[i];
		ret=min(ret,x+y);
		//cout<<x<<" "<<y<<" ";
		//cout<<abs(dis[i])<<" "<<abs(dis[i+k-1])<<endl;;
	}
	cout<<ret<<endl;
	//for(int i=1;i<=n;++i)cout<<dis[i];
	return 0;
}

Measured memory_bytes: 640
n = int(input())
d = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
}

for _ in range(n):
    judge = input()
    d[judge] += 1

for k, v in d.items():
    print('{} x {}'.format(k, v))

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

main()
{
    int n; cin>>n;
    int ans=0;
    for(int i=0; i<n; ++i)
    {
        int a; cin>>a;
        if(i&1) continue;
        if(a&1) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

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

            if (a < b && b < c)
            {
                Console.WriteLine ("Yes");
            }
            else
            {
                Console.WriteLine ("No");
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


Measured memory_bytes: 15952
import sys
def input(): return sys.stdin.readline().strip()

def main():
    s = input()
    for i in range(26):
        a = chr(97 + i)
        cnt = 10**10
        for i, c in enumerate(s):
            if c == a and cnt <= 1:
                print("{} {}".format(i - cnt, i + 1))
                return
            if c == a:
                cnt = 0
            else:
                cnt += 1
    print("-1 -1")



if __name__ == "__main__":
    main()


Measured memory_bytes: 73372
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)

class Node():
    def __init__(self, ID, parent=-1, left=-1, right=-1, depth=0, children=[]):
        self.id = ID
        self.parent = parent
        self.left = left
        self.right = right
        self.depth = depth
        self.children = children


if __name__ == '__main__':

    n = int(input())
    tree = [Node(i) for i in range(n)]

    for _ in range(n):
        line = [int(l) for l in input().split(" ")]
        ID = line[0]
        d = line[1]
        if d == 0:
            continue
        else:
            children = line[2:]
            tree[ID].children = children
            tree[ID].left = children[0]
            for j in range(0, d):
                tree[children[j]].parent = ID
                if j < d - 1:
                    tree[children[j]].right = children[j + 1]

    def setDepth(u, p):
        tree[u].depth = p
        if tree[u].right != -1:
            setDepth(tree[u].right, p)
        if tree[u].left != -1:
            setDepth(tree[u].left, p + 1)

    for node in tree:
        if node.parent == -1:
            root = node.id

    setDepth(root, 0)

    for node in tree:
        if node.parent == -1:
            n_type = "root"
        elif node.left != -1:
            n_type = "internal node"
        else:
            n_type = "leaf"

        print("node {}: parent = {}, depth = {}, {}, {}".format(
            node.id, node.parent, node.depth, n_type, node.children))
        


Measured memory_bytes: 132900
#include <stdio.h>

int main(){

  int	N, i, j;
  
  scanf("%d", &N);
  
  for(i=1; i<=9; i++){
    if( N%i==0 && N/i<=9 ){
      for(j=1; j<=9; j++){
        if((N/i) % j == 0){ printf("Yes"); return 0; }
      }
    }
  }
  printf("No");
  return 0;
}

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

int main() {
    int N, K, temp = 1;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        if (temp < K) {
            temp = temp * 2;
        } else {
            temp = temp + K;
        }
    }
    cout << temp << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

def gcd(a, b) :
    while b != 0 :
        a, b = b, a % b
    return a
    
ret = gcd(A[0], A[1])
for i in range(2, N) :
    ret = gcd(ret, A[i])
print(ret)

Measured memory_bytes: 62704
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<long long>plus;
	vector<long long>minus;
	while(n--){
		long long x,y;
		cin>>x>>y;
		plus.push_back(x+y);
		minus.push_back(x-y);
	}
	sort(plus.begin(),plus.end());
	sort(minus.begin(),minus.end());
	long long ret = 0;
	ret = max(ret,plus[plus.size()-1]-plus[0]);
	ret = max(ret,minus[minus.size()-1]-minus[0]);
	cout<<ret;
}

Measured memory_bytes: 6652