akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    la = [None] * (n + 1)
    xt = [None] * len(dat)
    j = 0
    for i in xrange(m):
        x, y = dat[j:j+2]
        xt[j] = la[y]
        xt[j+1] = la[x]
        la[y] = j
        la[x] = j + 1
        j += 2
    done = [None] * (n + 1)
    x = 1
    po = []
    while 1:
        po.append(x)
        done[x] = 1
        y = la[x]
        while y is not None:
            z = dat[y]
            if done[z] is None:
                x = z
                break
            y = xt[y]
        else:
            break
    x = 1
    pa = []
    while 1:
        pa.append(x)
        done[x] = 1
        y = la[x]
        while y is not None:
            z = dat[y]
            if done[z] is None:
                x = z
                break
            y = xt[y]
        else:
            break
    po = po[::-1] + pa[1:]
    print len(po)
    print ' '.join(map(str, po))
main()


Measured memory_bytes: 24048
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;

int main()
{
 ll a,b;
 cin>>a>>b;
 ll x=a%b;
 ll y=abs(x-b);
 if(x<y)
 cout<<x<<endl;
 else
 {
    cout<<y<<endl;
 }
 
 
}


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

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

    int n;
    string s;
    cin >> n >> s;

    string t(s);
    sort(t.begin(), t.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    cout << (ans + 1) / 2 << endl;
}


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

using namespace std;

int main(){
  int N, Y;
  cin >> N >> Y;
  
  for (int i = 0; i <= N; i++)
    for (int j = 0; j <= N; j++)
        if((N - i - j) >= 0 &&  (10000 * i + 5000 * j + 1000 * (N - i - j)) == Y){
          cout << i << " " << j << " " << N - i - j << endl;
          return 0;
        } 
      
  cout << -1 << " " << -1 << " " << -1 << endl; 
}


Measured memory_bytes: 256
S = input()
T = input()
s1 = list(S)
t1 = list(T)
a = len(s1); b = len(t1)
z = []
for i in range(a-b+1):
    x = []
    y = 0
    for j in range(b):
        x.append(s1[i+j])
    for k in range(b):
        if t1[k]==x[k]:
            y += 1
    z.append(y)
print(b-max(z))

Measured memory_bytes: 9156
#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int INF = (1e9);

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> X(2*N), Y(2*N), Z(2*N), X2, Y2, Z2;
  map<int,int> X_, Y_, Z_;
  for(int i = 0; i < N; ++i){
    cin >> X[2*i] >> Y[2*i] >> Z[2*i] >> X[2*i+1] >> Y[2*i+1] >> Z[2*i+1];
    X_[X[2*i]] = 1;
    X_[X[2*i+1]] = 1;
    Y_[Y[2*i]] = 1;
    Y_[Y[2*i+1]] = 1;
    Z_[Z[2*i]] = 1;
    Z_[Z[2*i+1]] = 1;
  }
  int t = 0;
  for(auto &x : X_) x.second = t,++t,X2.push_back(x.first);
  t = 0;
  for(auto &y : Y_) y.second = t,++t,Y2.push_back(y.first);
  t = 0;
  for(auto &z : Z_) z.second = t,++t,Z2.push_back(z.first);
  int n = X_.size(), m = Y_.size(), o = Z_.size();
  vector< vector< vector<int> > > S(n+1,vector< vector<int> >(m+1,vector<int>(o+1,0)));
  
  for(int i = 0; i < N; ++i){
    int x = X_[X[2*i]], x2 = X_[X[2*i+1]], y = Y_[Y[2*i]], y2 = Y_[Y[2*i+1]], z = Z_[Z[2*i]], z2 = Z_[Z[2*i+1]];
    ++S[x][y][z];
    --S[x2][y][z];
    --S[x][y2][z];
    --S[x][y][z2];
    ++S[x2][y2][z];
    ++S[x][y2][z2];
    ++S[x2][y][z2];
    --S[x2][y2][z2];
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      for(int k = 0; k < o; ++k){
        S[i][j][k+1] += S[i][j][k];
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int k = 0; k < o; ++k){
      for(int j = 0; j < m; ++j){
        S[i][j+1][k] += S[i][j][k];
      }
    }
  }
  for(int k = 0; k < o; ++k){
    for(int j = 0; j < m; ++j){
      for(int i = 0; i < n; ++i){
        S[i+1][j][k] += S[i][j][k];
      }
    }
  }
  long long ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      for(int k = 0; k < o; ++k){
        if(S[i][j][k] < K) continue;
        ans += (long long)(X2[i+1]-X2[i])*(Y2[j+1]-Y2[j])*(Z2[k+1]-Z2[k]);
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 7348
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


typedef tuple<int,int,int> P;


int X,Y,Z,K;
int A[1145],B[1419],C[19810];




signed main(){
    auto l = [](const P F, const P G){
        int a=0,b=0;
        a=A[get<0>(F)]+B[get<1>(F)]+C[get<2>(F)];
        b=A[get<0>(G)]+B[get<1>(G)]+C[get<2>(G)];
        return a < b;
    };
    
    
    cin >> X >> Y >> Z >> K;
    REP(i,X){cin >> A[i];}sort(A,A+X,greater<>());
    REP(i,Y){cin >> B[i];}sort(B,B+Y,greater<>());
    REP(i,Z){cin >> C[i];}sort(C,C+Z,greater<>());
    
    priority_queue<P,vector<P>,decltype(l)> Q(l);
    Q.push(make_tuple(0,0,0));
    map<P,int> al;
    al[make_tuple(0,0,0)]=1;
    
    
    int r;
    P p;
    REP(w,K){
        p=Q.top();
        Q.pop();
        int i,j,k;
        i=get<0>(p);
        j=get<1>(p);
        k=get<2>(p);
        r=A[i]+B[j]+C[k];
        //cout << i << " " << j << " " << k << " ";
        cout << r << endl;
        
        if(i!=X-1 && al[make_tuple(i+1,j,k)]==0){
            Q.push(make_tuple(i+1,j,k));
            //cout << i+1 << " " << j << " " << k << endl;
            al[make_tuple(i+1,j,k)]=1;
        }
        if(j!=Y-1 && al[make_tuple(i,j+1,k)]==0){
            Q.push(make_tuple(i,j+1,k));
            //cout << i << " " << j+1 << " " << k << endl;
            al[make_tuple(i,j+1,k)]=1;
        }
        if(k!=Z-1 && al[make_tuple(i,j,k+1)]==0){
            Q.push(make_tuple(i,j,k+1));
            //cout << i << " " << j << " " << k+1 << endl;
            al[make_tuple(i,j,k+1)]=1;
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 896
import math
from functools import reduce

def getD(num):
    input_list = [2 if i % 2 == 0 else i for i in range(num+1)]
    input_list[0] = 0
    bool_list = [False if i % 2 == 0 else True for i in range(num+1)]
    sqrt = int(math.sqrt(num))
    
    for serial in range(3, sqrt + 1, 2):
        if bool_list[serial]:
            for s in range(serial ** 2, num+1, serial):
                if bool_list[s]:
                    input_list[s] = serial
                    bool_list[s] = False
    return input_list

N = int(input())
A = list(map(int, input().split()))

D = getD(max(A))
pairwise_coprime = True
use_divnum = set()
for i in range(N):
    k = A[i]
    while k != 1:
        if D[k] in use_divnum:
            pairwise_coprime = False
            break
        else:
            use_divnum.add(D[k])
        div = D[k]
        while k % div == 0 and k > 1:
            k = k // div
if pairwise_coprime: 
    print("pairwise coprime")
    exit()
from math import gcd
gcd_of_a = A[0]
for i in range(N):
    gcd_of_a = gcd(gcd_of_a, A[i])
if gcd_of_a == 1:
    print("setwise coprime")
else:
    print("not coprime")


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<string> split(const string &s, const char& sep) {
  vector<string> res;
  stringstream ss(s);
  string buffer;
  while (getline(ss, buffer, sep)) res.emplace_back(buffer);
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  int prev[1010] = {}, next[1010] = {};
  bool flag = false;
  while (getline(cin, s)) {
    if (s.find(',') == string::npos) flag = true;
    else {
      auto v = split(s, ',');
      int id = stoi(v[0]);
      if (flag) next[id] += (prev[id] > 0);
      else prev[id]++;
    }
  }
  for (int i = 1; i <= 1000; i++) {
    if (prev[i] && next[i]) cout << i << " " << prev[i] + next[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3140
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
int main()
{
    int x;
    cin>>x;
    if(x<=599)
        cout<<8<<endl;
    else if(x>=600&&x<=799)
        cout<<7<<endl;
    else if(x>=800&&x<=999)
        cout<<6<<endl;
    else if(x>=1000&&x<=1199)
        cout<<5<<endl;
    else if(x>=1200&&x<=1399)
        cout<<4<<endl;
        else if(x>=1400&&x<=1599)
        cout<<3<<endl;
        else if(x>=1600&&x<=1799)
        cout<<2<<endl;
        else if(x>=1800&&x<=1999)
        cout<<1<<endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if(A == B) {
    cout << "Draw" << endl;
  } else if(A == 1) {
    cout << "Alice" << endl;
  } else if(B == 1) {
    cout << "Bob" << endl;
  } else {
    cout << (A > B ? "Alice" : "Bob") << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <algorithm>
using namespace std;
int n, m, T;
#define Maxn 50010
int x[Maxn << 1], y[Maxn << 1];
bitset<Maxn> b[Maxn];
bool ap[Maxn];
int seq[Maxn << 1];
int to[Maxn], B[Maxn];

inline void rd(int &x)
{
	x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')
		ch = getchar();
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
}

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int main()
{
	rd(n);
	rd(m);
	rd(T);
	for (int i = 1; i <= m; ++i)
	{
		rd(x[i]);
		rd(y[i]);
	}
	if (T == 1)
	{
		for (int i = 1; i <= n; ++i)
			b[i][i] = 1;
		bitset<Maxn> res;
		for (int i = m; i >= 1; --i)
		{
			res = b[x[i]] | b[y[i]];
			b[x[i]] = b[y[i]] = res;
		}
		res = b[1];
		for (int i = 2; i <= n; ++i)
			res &= b[i];
		int flag = -1;
		for (int i = 1; i <= n; ++i)
			if (res[i])
			{
				flag = i;
				break;
			}
		if (flag == -1)
		{
			puts("-1");
			return 0;
		}
		ap[flag] = true;
		for (int i = m; i >= 1; --i)
		{
			if (ap[x[i]] == false && ap[y[i]] == false)
				seq[i] = 0;
			else if (ap[x[i]] == true && ap[y[i]] == true)
				seq[i] = 0;
			else if (ap[x[i]])
				seq[i] = 0;
			else
				seq[i] = 1;
			bool tmp = ap[x[i]] | ap[y[i]];
			ap[x[i]] = ap[y[i]] = tmp;
		}
		for (int i = 1; i <= m; ++i)
			if (seq[i] == 0)
				printf("^");
			else
				printf("v");
	}
	else
	{
		if (n == 2)
		{
			puts("-1");
			return 0;
		}
		for (int i = 1; i <= n; ++i)
		{
			B[i] = i;
			to[i] = 1;
		}
		for (int i = 1; i <= n; ++i)
		{
			B[i] = i;
			to[i] = 1;
		}
		for (int i = m; i >= 1; --i)
		{
			if (B[x[i]] == B[y[i]])
			{
				seq[i] = 0;
				continue;
			}
			if (to[B[x[i]]] >= 2)
			{
				seq[i] = 1;
				to[B[x[i]]]--;
				B[x[i]] = B[y[i]];
				to[B[y[i]]]++;
			}
			else
			{
				seq[i] = 0;
				to[B[y[i]]]--;
				B[y[i]] = B[x[i]];
				to[B[x[i]]]++;
			}
		}
		for (int i = 1; i <= m; ++i)
			if (seq[i] == 0)
				printf("^");
			else
				printf("v");
	}
	return 0;
}


Measured memory_bytes: 307072
#include<stdio.h>
#include<stdlib.h>

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;

    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }
    else{
        if(z->key < y->key){
            y->left = z;
        }
        else{
            y->right = z;
        }
    }
}

void inorder(Node u){
    if(u == NIL){
        return;
    }
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node u){
    if(u == NIL){
        return;
    }
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    char com[20];
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s",com);
        if(com[0] == 'i'){
            scanf("%d",&x);
            insert(x);
        }
        else if(com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


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

map<int, vector<pair<int, int> > > v1, v2;
map<int, set<pair<int, int> > > d1, d2;
int x[100005], y[100005], n, D;
bool vis[100005];
long long ans;

void slv(vector<pair<int, int> >& hv, int lo, int hi)
{
	auto it1 = lower_bound(hv.begin(), hv.end(), make_pair(lo, -1)), it2 = lower_bound(hv.begin(), hv.end(), make_pair(hi+1, -1));
	ans += (it2-it1);
}

void check(set<pair<int, int> >& hv, int lo, int hi, queue<int>& q)
{
	auto it = hv.lower_bound(make_pair(lo, -1));
	while (it != hv.end() && it->first <= hi)
	{
		if (!vis[it->second]) q.push(it->second);
		vis[it->second] = true;
		it = hv.erase(it);
	}
}

void bfs(int st)
{
	queue<int> q;
	q.push(st); vis[st] = true;
	while (!q.empty())
	{
		int at = q.front(); q.pop();
		map<int, set<pair<int, int> > >::iterator it;
		it = d1.find(x[at]+y[at]-D); if (it != d1.end()) check(it->second, x[at]-D, x[at], q);
		it = d1.find(x[at]+y[at]+D); if (it != d1.end()) check(it->second, x[at], x[at]+D, q);
		it = d2.find(x[at]-y[at]-D); if (it != d2.end()) check(it->second, x[at]-D+1, x[at]-1, q);
		it = d2.find(x[at]-y[at]+D); if (it != d2.end()) check(it->second, x[at]+1, x[at]+D-1, q);
	}
}

int main()
{
	int a, b; scanf("%d%d%d", &n, &a, &b);
	--a, --b;
	for (int i = 0;i < n;i++)
	{
		scanf("%d%d", x+i, y+i);
		v1[x[i]+y[i]].emplace_back(x[i], i);
		v2[x[i]-y[i]].emplace_back(x[i], i);
		d1[x[i]+y[i]].emplace(x[i], i);
		d2[x[i]-y[i]].emplace(x[i], i);
	}
	for (auto it = v1.begin();it != v1.end();it++) sort(it->second.begin(), it->second.end());
	for (auto it = v2.begin();it != v2.end();it++) sort(it->second.begin(), it->second.end());
	D = abs(x[a]-x[b])+abs(y[a]-y[b]);
	bfs(a); bfs(b);
	for (int i = 0;i < n;i++) if (vis[i])
	{
		map<int, vector<pair<int, int> > >::iterator it;
		it = v1.find(x[i]+y[i]-D); if (it != v1.end()) slv(it->second, x[i]-D, x[i]);
		it = v1.find(x[i]+y[i]+D); if (it != v1.end()) slv(it->second, x[i], x[i]+D);
		it = v2.find(x[i]-y[i]-D); if (it != v2.end()) slv(it->second, x[i]-D+1, x[i]-1);
		it = v2.find(x[i]-y[i]+D); if (it != v2.end()) slv(it->second, x[i]+1, x[i]+D-1);
	}
	printf("%lld\n", ans/2);
	return 0;
}


Measured memory_bytes: 45696
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b=LI()
    G[a-1]+=[b-1]
    G[b - 1] += [a - 1]


def dfs(v, visited):
    """
    :param v: X側の未マッチングの頂点の1つ
    :param visited: 空のsetを渡す（外部からの呼び出し時）
    :return: 増大路が見つかればTrue
    """
    for u in G[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            matched[v] = u
            return True
    return False

cnt = 0
matched = [-1] * n
for i in range(n):
    if matched[i] != -1:
        continue
    cnt += int(dfs(i, set())) * 2

if cnt == n:
    print("Second")
else:
    print("First")





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

int main() {
  int n;
  cin >> n;
  long long int takahashi = 0;
  long long int aoki = 0;
  for(int i=0;i<n;i++) {
    long long int t, a;
    cin >> t >> a;
    if(i == 0) {
      takahashi = t;
      aoki = a;
      continue;
    }
    long long int taka, ao;
    if(takahashi % t == 0) {
      taka = takahashi;
      ao = a * (takahashi / t);
    } else {
      taka = t * (takahashi / t + 1LL);
      ao = a * (takahashi / t + 1LL);
    }
    if(ao >= aoki) {
      takahashi = taka;
      aoki = ao;
      continue;
    }
    if(aoki % a == 0) {
      ao = aoki;
      taka = t * (aoki / a);
    } else {
      ao = a * (aoki / a + 1LL);
      taka = t * (aoki / a + 1LL);
    }
    takahashi = taka;
    aoki = ao;
  }

  cout << takahashi + aoki << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<string> s(H, string(W, 'X'));
    rep(i, H - B) {
        rep(j, A) s[i][j] = '0';
        REP(j, A, W) s[i][j] = '1';
    }
    REP(i, B, H) {
        rep(j, A) s[i][j] = '1';
        REP(j, A, W) s[i][j] = '0';
    }

    rep(i, H) cout << s[i] << endl;

    return 0;
}

Measured memory_bytes: 2304
n, k = map(int, input().split())


A = [i for i in range(n+1)]
left = [A[0]]
right = [0 for i in range(n+1)]
right[-1] = A[-1]
for i in range(1, n+1):
    left.append(left[i-1] + A[i])
for i in range(n-1, -1, -1):
    right[i] = right[i+1]+A[i]
#print (left, right)
ans = 0
M = 10**9+7
for i in range(k, n+2):
    #print (ans, A[:i], A[n+1-i:])
    ans = (ans + right[-i]) % (10**9+7)
    #print (ans, right[-i], left[i-1]-1)
    #print (left[i-1])
    #print (ans - left[i-1]+1)
    ans = (ans - left[i-1]+1) % (10**9+7)
print (ans)

Measured memory_bytes: 110224
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x1,x2,x3,x4,x5;
	int ans;
	cin>>x1>>x2>>x3>>x4>>x5;
	if(x1 == 0)
		ans = 1;
	if(x2 == 0)
		ans = 2;
	if(x3 == 0)
		ans = 3;
	if(x4 == 0)
		ans = 4;
	if(x5 == 0)
		ans = 5;
	cout<<ans<<"\n";
	return 0;
}

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

int main(){
    int N;
    int d[110];
    cin >> N;
    for (int i=1; i<N+1; i++) cin >> d[i];
    
    set<int> omochi;
    for (int i=1; i<N+1; i++) {
        omochi.insert(d[i]);
    }
    cout << omochi.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vii v(n); multiset <int> ml;
	for(int i =0; i < n; i++) {
		cin >> v[i];
		ml.insert(v[i]);
	}
	for(int i = 0; i < n; i++){
		ml.erase(ml.find(v[i]));
		auto it = ml.rbegin();
		cout << *it << "\n";
		ml.insert(v[i]);
	}

	return 0;
}


Measured memory_bytes: 11776
main :: IO ()
main = do
  [n,k] <- map (read :: String -> Int) . words <$> getLine
  bs <- app <$> getLine
  print $ ans (2*k+1) bs

ans :: Int -> (Int, [Int]) -> Int
ans k (n,bs) = if k > n then head bs else func bs (drop k bs) where
  func (a:xs) [p] = a-p
  func (a:_:xs) (p:_:ys) = max (a-p) $ func xs ys

app :: String -> (Int, [Int])
app bs = finfunc $ foldl func ('1',0,1,[0]) bs where
  finfunc (c,n,l,ns) = if c == '0' then (l+2,n:n:ns) else (l+1,n:ns)
  func (c,n,l,ns) k
    | c == k = (c,n+1,l,ns)
    | c /= k = (k,n+1,l+1,n:ns)

Measured memory_bytes: 10620
from collections import deque
N, X, Y=map(int, input().split())
ans=[0 for _ in range(N)]
link=[[]]+[[2]]+[[i-1, i+1] for i in range(2, N)]+[[N-1]]
link[X].append(Y)
link[Y].append(X)

def f(p, length, moto):
  ans[length]+=1
  for data in link[p]:
    if kisyutu[data]==0:
      kisyutu[data]=1
      q.append([data, length+1, p])

for i in range(1, N+1):
  kisyutu=[1]+[0 for i in range(N)]
  kisyutu[i]=1
  q=deque()
  for data in link[i]:
    q.append([data, 1, i])
    kisyutu[data]=1
  while len(q)>0:
    data=q.popleft()
    f(data[0], data[1], data[2])
    
ans=[ans[i]//2 for i in range(N)]
print(*ans[1:], sep='\n')

Measured memory_bytes: 57820
N,M = map(int,input().split())
C = {i:[1,0] for i in range(1,N+1)}
C[1][1] = 1
for _ in range(M):
    x,y = map(int,input().split())
    C[x][0] -= 1
    C[y][0] += 1
    if C[x][1]==1:
        C[y][1]=1
        if C[x][0]==0:
            C[x][1]=0
cnt = 0
for i in range(1,N+1):
    cnt += C[i][1]
print(cnt)

Measured memory_bytes: 89172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  string s;
  cin >> s;
  int t = 0;
  for (int i = 1; i < s.size() - 1; ++i)  t += 1;
  cout << s[0] << t << s.back() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;

//STRUCTS


//OPERATORS


//GLOBALS


//FUNCTIONS


//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
		string s;
		cin >> s;
		if (s == "Sunny") cout << "Cloudy";
		else if (s == "Cloudy") cout << "Rainy";
		else cout << "Sunny";




	return 0;
}

Measured memory_bytes: 256
/*
 	安部NANA先輩大好き

 */
#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    str s;
    int a=-1,b=-1;
    cin >> s;
    rep(i,0,s.size()){
        if(s[i]=='C'&&a==-1)a=i;
        else if(s[i]=='F')b=i;
    }
    if(a<b&&(a!=-1)&&(b!=-1)){
        //cout << a << " " << b;
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

struct edge { int from, to, cost; };

template <typename T>
void warshallFloyd(T& d){
    for (int i = 0; i < d.size(); i++) d[i][i] = 0;

    for (int k = 0; k < d.size(); k++) {
		for (int i = 0; i < d.size(); i++) {
	    	for (int j = 0; j < d.size(); j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	    	}
		}
    }
}

int main(){
	const int INF = 1e9;
	int N, M;
	cin >> N >> M;
	vector<vector<int>> d(N, vector<int>(N, INF));
	vector<edge> edges(M);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		d[a - 1][b - 1] = c;
		d[b - 1][a - 1] = c;
		edges[i].from = a - 1;
		edges[i].to = b - 1;
		edges[i].cost = c;
	}

	warshallFloyd(d);
	int res = M;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			if (d[j][edges[i].from] + edges[i].cost == d[j][edges[i].to]) {
				res--;
				break;
			}
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
"""
https://atcoder.jp/contests/abc063/submissions/5538114
"""

from numpy import ceil,array,sum
import sys

def input():
    return sys.stdin.readline().strip()

def is_ok(m):
    tmp = h - m*B
    tmp[tmp<0] = 0
    
    if ceil(tmp/(A-B)).sum() > m:
        return False
    return True

N,A,B = map(int,input().split())
h = array(list(int(input()) for _ in range(N)))
##二分散策

r = 10**9
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

    if is_ok(m):
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 31444
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split()))[::-1] for _ in range(m)]
a.sort()
d=[]
e=0

bc.sort(reverse=True)
for c,b in bc:
    d+=[c]*b
    e+=b
    if e>n:
        break
for i ,(x,y) in enumerate(zip(a,d)):
    if x<y:
        a[i]=y

print(sum(a))

Measured memory_bytes: 26732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		char c0 = N.charAt(0);
		char c1 = N.charAt(1);
		char c2 = N.charAt(2);
		char c3 = N.charAt(3);
		if((c0 == c1 && c1 == c2) || (c1 == c2 && c2 == c3)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Heap struct {
	data []int
}

func (h *Heap) Len() int           { return len(h.data) }
func (h *Heap) Less(i, j int) bool { return h.data[i] < h.data[j] }
func (h *Heap) Swap(i, j int)      { h.data[i], h.data[j] = h.data[j], h.data[i] }
func (h *Heap) Push(i interface{}) { h.data = append(h.data, i.(int)) }
func (h *Heap) Pop() interface{} {
	i := h.data[len(h.data)-1]
	h.data = h.data[:len(h.data)-1]
	return i
}

type Data struct {
	b, c int
}
type DataSlice struct {
	data []*Data
}

func (s DataSlice) Len() int           { return len(s.data) }
func (s DataSlice) Swap(i, j int)      { s.data[i], s.data[j] = s.data[j], s.data[i] }
func (s DataSlice) Less(i, j int) bool { return s.data[i].c > s.data[j].c }

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0) 
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n, m := oneInt(), oneInt()
	input := scanNums(n)

	dataSlice := &DataSlice{[]*Data{}}
	for i := 0; i < m; i++ {
		b, c := oneInt(), oneInt()
		dataSlice.data = append(dataSlice.data, &Data{b, c})
	}

	h := calc(input, dataSlice)

	sum := 0
	for _, v := range h.data {
		sum += v
	}
	fmt.Println(sum)

}

func calc(input []int, dataSlice *DataSlice) *Heap {
	h := &Heap{}
	heap.Init(h)
	for _, a := range input {
		heap.Push(h, a)
	}

	sort.Sort(dataSlice)
	for _, d := range dataSlice.data {
		for i := 0; i < d.b; i++ {
			if m, ok := heap.Pop(h).(int); ok {
				if m < d.c {
					heap.Push(h, d.c)
				} else {
					heap.Push(h, m)
					return h
				}
			}
		}
	}
	return h
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}


Measured memory_bytes: 9856
using System;

public class Hello
{
    public static void Main()
    {
        var a = new double[] { 165, 170, 175, 180, 185 };
        var b = new int[a.Length+1];
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var h = double.Parse(Console.ReadLine().Trim());
            for (int j = 0; j < a.Length; j++)
                if (h < a[j]) { b[j]++; goto next; }
            b[b.Length -1]++;
            next:;
        }
        for (int i = 0; i < b.Length; i++)
            Console.WriteLine("{0}:{1}", i + 1, new string('*', b[i]));
    }
}


Measured memory_bytes: 9220
fun main(arg: Array<String>) {
    val (H, W, N) = listOfInt()
    val M = java.util.HashMap<Pair<Int, Int>, Int>()
    repeat(N) {
        val (a, b) = listOfInt(-1)
        for (h in -1 .. 1) {
            for (w in -1 .. 1) {
                val key = a + h to b + w
                M.set(a + h to b + w, M.getOrElse(a + h to b + w, {0}) + 1)
            }
        }
    }
    val ans = LongArray(10)
    ans[0] = 1L * (H - 2) * (W - 2)
    for ((key, cnt) in M) {
        if (1 <= key.first && key.first < H - 1 && 1 <= key.second && key.second < W - 1) {
            ans[cnt] = ans[cnt] + 1
            ans[0] = ans[0] - 1
        }
    }
    ans.forEach { println(it) }
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }




Measured memory_bytes: 201984
#include <cstdio>
#include <algorithm>
int A[100],v,j;

int main(){
    int N;
    scanf("%d",&N);
    for(int i = 0;i < N;i++)
        scanf("%d",&A[i]);
    for(int k = 0;k < N;k++){
        if(k)
            printf(" ");
        printf("%d",A[k]);
    }
    printf("\n");
    for(int i = 1;i < N;i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int k = 0;k < N;k++){
            if(k)
                printf(" ");
            printf("%d",A[k]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2708
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	m := scanInt()
	k := scanInt()

	ma := pow(2, m)
	if ma-1 < k || m == 1 && k != 0 {
		fmt.Fprintln(wr, -1)
		return
	}

	if k == 0 {
		for i := 0; i < ma; i++ {
			fmt.Fprint(wr, i, i, " ")
		}
		return
	}

	isUsed := make([]bool, ma)

	for i := 0; i < ma; i++ {
		if isUsed[i] {
			continue
		}

		c1, c2 := i, k^i
		isUsed[c1], isUsed[c2] = true, true

		for ; isUsed[i]; i++ {
		}
		d1, d2 := i, k^i
		isUsed[d1], isUsed[d2] = true, true

		fmt.Fprint(wr, c1, c2, d1, d2, c2, c1, d2, d1, " ")
	}
}

func pow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res *= a
		}
		a *= a
		n >>= 1
	}
	return res
}


Measured memory_bytes: 6400
#include <stdio.h>
#include <string.h>

int main(void){
	int i,j,k,l,ti,flg;
	int plen,cnum,width,cspace;
	char out[512][50];
	char s[1004];

	while(1){
		scanf("%d",&plen);
		if(plen == 0) break;

		scanf("%d%d%d ",&cnum,&width,&cspace);
		memset(out,'.',sizeof(out));

		i = 0;
		while(1){
			fgets(s,1004,stdin);
			if(strcmp(s,"?\n") == 0) break;
			if(strcmp(s,"\n") == 0){i++;continue;}

			k = 0;
			flg = 1;
			for(;flg;i++){
				if(s[k] == '\n') break;
				for(j=0;j<width;j++){
					if(s[k] == '\n'){flg=0;break;}
					out[i][j] = s[k++];
				}
			}
		}

		ti = i;
		for(l=0;l<ti;l+=plen*cnum){
			for(i=l;i<l+plen;i++){
				for(k=0;k<cnum;k++){
					for(j=0;j<width;j++)putchar(out[i+k*plen][j]);
					if(k!=cnum-1) for(j=0;j<cspace;j++) printf(".");
				}
				printf("\n");
			}
			printf("#\n");
		}
		printf("?\n");
	}

	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#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>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;

int gcd2(int a, int b){
  if(a < b)
    swap(a, b);

  int r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

  int a, b, k;
  cin >> a >> b >> k;
  int gcd = gcd2(a, b);
  if(k == 1){
    cout << gcd << endl;
    return 0;
  }
  int out = gcd;
  for(int i=1; k>0; ++i){
    if(gcd % i == 0){
      out = gcd / i;
      k--;
    }
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int n, d;
	ll sum = 0;
	cin >> n >> d;
	int ar[100];
	for (int i = 0; i < n; i++)
	{
		cin >> ar[i];
		sum += ar[i];
	}
	d -= sum;
	int k = d / *min_element(ar, ar + n);
	cout << n + k;
/* 999*/
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		long[] l = new long[n+1];
		
		l[0] = 2;
		l[1] = 1;
		
		for(int i = 2; i < n+1; i++) {
			l[i] = l[i - 2] + l[i - 1];
		}

		System.out.println(l[n]);
	}

}


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

int main() {
    int n;
    cin >> n;
    int a[15][15];
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            a[i][j] = i * j;
        }
    }

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (a[i][j] == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], ans;
int32_t main(){_


   map<char, char> M;

   M['A'] = 'T';
   M['T'] = 'A';
   M['C'] = 'G';
   M['G'] = 'C';

   char c;
   cin>>c;

   cout<<M[c];

   #warning make sure N size is correct!
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
int main() {
	int s,w;
	cin >>s>>w ;
	string ans ="safe";
	if (w>=s) ans="unsafe";
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int n;
VI x(55),y(55);

signed main(){
  cin>>n;
  rep(i,n) cin>>x[i]>>y[i];

  if(n==1) return cout<<1<<endl, 0;
  int ans = n;
  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      int dx=x[j]-x[i], dy=y[j]-y[i];
      int sub = 0;

      rep(k,n){
        rep(l,n){
          if(k==l) continue;
          if(dx==x[l]-x[k] && dy==y[l]-y[k]) sub++;
        }
      }
      ans = min(ans,n-sub);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
  int N, L;
  int i;
  int taste=0, min=0;

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

  min = L;
  for (i=0;i<N;i++){
    taste += L+i;
    if(abs(L+i)<=abs(min))
    min = L+i;
  }
  taste -= min;
  printf("%d\n", taste);
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;

unordered_set<char> m;

int main(void)
{
	int a, b;
	cin >> a >> b;
	cout << max(0, (a - 2 * b)) << endl;
	return 0;
}

Measured memory_bytes: 256
# D
K = int(input())

N = 50

L = K // 50
R = K % 50

a_list = []

if R != 0:
    for i in range(50):
        if i >= 50 - R:
            a_list.append(str(99 - R + 1 + L))
        else:
            a_list.append(str(49 - R + L))
else:
    for i in range(50):
        a_list.append(str(49 + L))
        
print(len(a_list))
print(" ".join(a_list))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int dp[3010][3010];

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

    string s,t;
    cin>>s>>t;

    dp[0][0]=0;
    if(s[0]==t[0])
        dp[0][0]=1;

    for(int i=1;i<s.size();i++)
        dp[i][0]=(s[i]==t[0]?1:dp[i-1][0]);

    for(int j=1;j<t.size();j++)
        dp[0][j]=(t[j]==s[0]?1:dp[0][j-1]);

    for(int i=1;i<s.size();i++)
    {
        for(int j=1;j<t.size();j++)
        {
            if(s[i]==t[j])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    //cout<<dp[s.size()-1][t.size()-1]<<endl;

    string sol;
    int i=s.size()-1;
    int j=t.size()-1;
    while(i>=0 && j>=0)
    {
        if(s[i]==t[j])
            sol+=s[i], i--, j--;
        else if(i==0)
            j--;
        else if(j==0)
            i--;
        else if(dp[i][j-1]>dp[i-1][j])
            j--;
        else
            i--;
    }
 /*   if(dp[i][j]==1)
        sol+=(i<j?s[i]:t[j]);
*/
    for(int i=sol.size()-1;i>=0;i--)
        cout<<sol[i];


	return 0;
}


Measured memory_bytes: 35584
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    if (A >= 13) {
      System.out.println(B);
    }
    else if (A <= 5) {
      System.out.println(0);
    }
    else{
      B = B / 2;
      System.out.println(B);
    }
  }
}


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

int main() {
  string S;
  cin >> S;
  bool n = S.find('N') != string::npos;
  bool s = S.find('S') != string::npos;
  bool e = S.find('E') != string::npos;
  bool w = S.find('W') != string::npos;
  if ((n && !s) || (!n && s) || (e && !w) || (!e && w)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <chrono>

using namespace std;

int t[100001], x[100001], y[100001];

int main(){
	int N = 0;
	cin >> N;
	for (int i = 0; i < N; ++i){
		cin >> t[i] >> x[i] >> y[i];
	}
	bool isRootCheck = true;
	for (int i = 0; i < N; ++i){
		if (!(t[i] >= abs(x[i] + y[i]) && t[i] % 2 == abs(x[i] + y[i]) % 2)){
			isRootCheck = false;
			break;
		}
	}
	if (isRootCheck) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	long long k , a , b;
	cin >> k >> a >> b; 
	if(b - a > 1)
		cout << (k-a+1)/2 * (b-a) + (k-a+1)%2 + a;
	else
		cout << k + 1;
}


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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    ll n,k;
    cin >> n >>k;
    if(k==1){
        cout << n << endl;
        return 0;
    }
    combination com = combination(1000000);
    if(k>=n){
        k=n-1;
    }
    mint ans =1;
    for(int i=1;i<=k;i++){
        // cerr << com(n,i)*com(n-1,n-i) << endl;
        ans  = ans + com(n,i)*com(n-1,i);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 15872
s = list(input())

ans = 0
for i in range(1,len(s)):
    if len(s[:-i]) % 2 == 0:
        if s[:-i][:len(s[:-i]) // 2] == s[:-i][len(s[:-i]) // 2:]:
            ans = len(s[:-i])
            break
print(ans)

Measured memory_bytes: 3060
while(1):
    str = input()
    if(str=="-"):
        break
    str = list(str)
    n=int(input())
    for i in range(0,n):
        m=int(input())
        x=[str[j] for j in range(0,m)]
        str.extend(x)
        del str[0:m]
    print("".join(str))


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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(2,vector<int>(N));
  for(int i=0;i<2;++i){
    for(int j=0;j<N;++j){
      cin>>A.at(i).at(j);
    }
  }

  vector<int> S0(N+1),S1(N+1);
  S0.at(0)=0;
  S1.at(0)=0;
  for(int i=1;i<=N;++i){
    S0.at(i)=S0.at(i-1)+A.at(0).at(i-1);
    S1.at(i)=S1.at(i-1)+A.at(1).at(i-1);
  }

  vector<int> Candy(N);
  for(int i=0;i<N;++i){
    Candy.at(i)=S1.at(N)+S0.at(i+1)-S1.at(i);
  }

  sort(Candy.begin(),Candy.end(),greater<int>());
  cout<<Candy.at(0)<<endl;


}

Measured memory_bytes: 256
edges = {}

for ns in (0..7).to_a.permutation(8)
  key = ns.join("")
  edges[key] = []

  i = ns.index(0)
  x = i % 4
  y = i / 4

  if x > 0
    ns0 = ns.clone
    tmp = ns0[i]; ns0[i] = ns0[i - 1]; ns0[i - 1] = tmp
    edges[key].push ns0.join("")
  end
  if x < 3
    ns0 = ns.clone
    tmp = ns0[i]; ns0[i] = ns0[i + 1]; ns0[i + 1] = tmp
    edges[key].push ns0.join("")
  end
  if y > 0
    ns0 = ns.clone
    tmp = ns0[i]; ns0[i] = ns0[i - 4]; ns0[i - 4] = tmp
    edges[key].push ns0.join("")
  end
  if y < 1
    ns0 = ns.clone
    tmp = ns0[i]; ns0[i] = ns0[i + 4]; ns0[i + 4] = tmp
    edges[key].push ns0.join("")
  end
end

start = "01234567"

dists = {start => 0}
queue = [start]

while ! queue.empty?
  v = queue.shift

  for i in edges[v]
    if dists[i].nil?
      dists[i] = dists[v] + 1
      queue.push i
    end
  end
end

while (line = gets)
  key = line.chomp.gsub(/ /, '')

  d = dists[key]
  puts d.nil? ? "NA" : d
end

Measured memory_bytes: 56028
// atcoder_dp_a.cpp
#include <iostream>
#include <vector>
using namespace std;

const int inf = 1e9 + 5;

int main() {
	int n;
	scanf("%d", &n);
	vector<int> h(n, 0);
	for (auto& v : h)
		scanf("%d", &v);

	vector<int> dp(n, inf);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (auto j : {i + 1, i + 2}) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(A[K-1])

Measured memory_bytes: 3316