akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqD = new int[n][];
        for (int i = 0; i < seqD.Length; ++i)
        {
            seqD[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        }

        for (int i = 2; i < seqD.Length; ++i)
        {
            var same0 = seqD[i - 2][0] == seqD[i - 2][1];
            var same1 = seqD[i - 1][0] == seqD[i - 1][1];
            var same2 = seqD[i - 0][0] == seqD[i - 0][1];
            if (same0 && same1 && same2)
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 28284
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  REP(i, 2) {
    if(a >= b) {
      ans += a;
      a -= 1;
    }
    else {
      ans += b;
      b -= 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  int tmp;
  int max = 0;
  int count = 0;
  for (int i = 0; i < n; i ++)
  {
    cin >> tmp;
    if (tmp >= max)
    {
      max = tmp;
      count ++;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

//------------------------------------------------
int main(){
  int n,k,count;
  count=0;
  cin>>n>>k;
  string str;
  cin>>str;
  rep(i,1,n){
    if(str.at(i)==str.at(i-1)) count+=1;
}
count+=2*k;
  if(count<n-1) cout<<count<<endl;
  else cout<<n-1<<endl;
}


Measured memory_bytes: 512
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,k,s = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

for i in range(k):
    print(s, end=" ")

if s == 10**9:
    for i in range(n-k):
        if i == n-k-1:
            print(1)
            exit()
        else:
            print(1, end=" ")

else:
    for i in range(n-k):
        if i == n-k-1:
            print(s+1)
            exit()
        else:
            print(s+1, end=" ")


Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int r,c,i,j,csum;
        r=scan.nextInt();
        c=scan.nextInt();
        int array[][]=new int[r][c],rsum[]=new int[c+1];
        for(i=0;i<c;i++) {
        	rsum[i]=0;
        }
        for(i=0;i<r;i++) {
        	for(j=0;j<c;j++) {
        		array[i][j]=scan.nextInt();
        	}
        }
        for(i=0;i<=r;i++) {
        	csum=0;
        	if(i<r) {
        		for(j=0;j<=c;j++) {
        			if(j<c) {
        				System.out.print(array[i][j] + " ");
        				csum+=array[i][j];
        				rsum[j]+=array[i][j];
        			}
        			else {
        				System.out.println(csum);
        				rsum[j]+=csum;
        			}
        		}
        	}
        	else {
        		for(j=0;j<=c;j++) {
        			if(j<c) {
        				System.out.print(rsum[j] + " ");
        			}
        			else {
        				System.out.println(rsum[j]);
        			}
        		}
        	}
        }
    }
}



Measured memory_bytes: 42176
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  const int vx = x2 - x1, vy = y2 - y1;
  const int ux = -vy, uy = vx;
  const int x4 = x1 + ux, y4 = y1 + uy;
  const int x3 = x4 + vx, y3 = y4 + vy;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}


Measured memory_bytes: 3632
n, m = map(int, input().split())

from collections import deque

l = deque([i for i in range(1, n + 1)])

if n % 2 ==0:
    for i in range(1, m + 1):
        a, b = l.popleft(), l.pop()
        if (b - a) == n / 2 or (len(l) < n // 2 and (b-a) % 2 == 1):
            b = l.pop()
        print(a, b)
else:
    for i in range(1, m + 1):
        print(i, n - i)

Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,n,ans=123456789;
    cin>>h>>w>>n;
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            if(i*w+j*h-i*j>=n){
                ans=min(ans,i+j);
            }
        }
    }
    cout<<ans;
    return 0;
}

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

int main(void) {
   long long int N, M, l1, l2;
   long long int ans = 0;
   long long int cnt = 0;
   cin >> N >> M;
   vector<pair<long long int, long long int>> pairs;
   for (long long int i = 0; i < N; i++) {
      cin >> l1 >> l2;
      auto p = make_pair(l1, l2);
      pairs.push_back(p);
   }
   sort(pairs.begin(), pairs.end(), [](const pair<long long int,long long  int>& x, const pair<long long int,long long  int>& y){return x.first < y.first;});
   for (long long int i = 0; i < N; i++) {
      auto p = pairs[i];
      if (p.second + cnt < M) {
         ans += p.second * p.first;
         cnt += p.second;
      } else {
         ans += (M - cnt) * p.first;
         break;
      }
   }
   cout << ans << endl;
   return 0;
}


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

int main() {
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;++i){
        cin>>A[i];
    }
    int q;
    cin>>q;
    int m[q];
    for(int i=0;i<q;++i){
        cin>>m[i];
    }

    vector<int> S;
    map<int, int> ansmap;
    int tmp;
    for(int bit=0;bit<(1<<n);++bit){
        S.clear();
        for(int i=0;i<n;++i){
            if(bit&(1<<i))S.push_back(i);
        }
        tmp = 0;
        for(int i=0;i<S.size();++i){
            tmp += A[S[i]];
        }
        ansmap[tmp]++;
    }
    for(int i=0;i<q;++i){
        if(ansmap[m[i]]>0)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007


int n, a;
int ans;
signed main(){
	cin >> n;
	cin >> ans;
	for(int i = 2 ; i <= n ; i ++){
		cin >> a;
		ans = __gcd(ans, a);
	}
	cout << ans;
	
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
   int h,w,i,m,n;
   char a[1000][1000];
   scanf("%d %d",&h,&w);
   getchar();
   for(m=0;m<h;m++)
   {
   gets(a[m]);
   }
   for(i=0;i<w+1;i++)
   printf("#");
   printf("#\n");
   for(m=0;m<h;m++)
   {
   	printf("#");
   	printf("%s",a[m]);
   	printf("#\n");
   }
   for(i=0;i<w+1;i++)
   printf("#");
   printf("#\n");
   return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m,f,r;
    char rank;
    while(1){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1){
            rank='F';
        }else if(m+f>=80){
            rank='A';
        }else if(m+f>=65){
            rank='B';
        }else if(m+f>=50||(m+f>=30&&r>=50)){
            rank='C';
        }else if(m+f<30){
            rank='F';
        }else{
            rank='D';
        }
        cout<<rank<<endl;
    }
    return 0;
}

Measured memory_bytes: 3080
/**
  *  Worg
  */
#include <cstdio>

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

int main() {
    long long N; scanf("%lld", &N);
    long long a, b, c;

    for(a = 1; a <= 3500; a++) {
        for(b = 1; b <= 3500; b++) {
            long long x = a * b * N;
            long long y = 4 * a * b - b * N - a * N;

            if(y > 0 && x % y == 0) {
                c = x / y;
                printf("%lld %lld %lld\n", a, b, c); return 0;
            }
        }
    }
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	a = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,k,a[225816],b[225816];
ll l,bitree[225816];

ll query(int p){
	int v = 0;
	++p;
	while(p){
		v += bitree[p];
		p -= (p&(-p));
	}
	return v;
}

void update(int p, int v=1){
	++p;
	while(p<225816){
		bitree[p] += v;
		p += (p&-p);
	}
}

bool judge(int x){
	int i;
	ll cnt=0ll;
	b[0] = 0; bitree[0] = 0;
	for(i=0; i<n; ++i){
		bitree[i] = 0;
		b[i+1] = b[i] + ((a[i]<x)?1:0);
	}
	for(i=0; i<=n; ++i){
		update(b[i]);
		if(b[i]<k){
			continue;
		}
		cnt += query(b[i]-k);
	}
	return (cnt<l);
}

int main(void){
	int i,ok=0,ng=200000,m;
	cin >> n >> k >> l;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	while(ng-ok>1){
		m = (ok+ng)/2;
		if(judge(m)){
			ok = m;
		}else{
			ng = m;
		}
	}
	cout << ok << endl;
	return 0;
}



Measured memory_bytes: 6208
import itertools

n, m, q = map(int, input().split())
li = []
for _ in range(q):
    abcd = list(map(int, input().split()))
    li.append(abcd)

ans = 0
for c in list(itertools.combinations_with_replacement(range(1, m+1), n)):
    total = 0
    for i in range(q):
        if c[li[i][1]-1] - c[li[i][0]-1] == li[i][2]:
            total += li[i][3]
    if total > ans:
        ans = total
print(ans)

Measured memory_bytes: 84520
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> a(n + 1);
    for(int i = 1; i <= m; ++i) {
        int p, y;
        cin >> p >> y;
        a[p].push_back({y, i});
    }
    for(int i = 1; i <= n; ++i) sort(begin(a[i]), end(a[i]));
    vector<string> sts = {"", "0", "00", "000", "0000", "00000", "000000"};
    auto id = [&](int p, int i) {
        string fp = to_string(p);
        string sp = to_string(i);
        return sts[6 - fp.size()] + fp + sts[6 - sp.size()] + sp;
    };
    vector<pair<int, string>> ans;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < a[i].size(); ++j) {
            ans.push_back({a[i][j].se, id(i, j + 1)});
        }
    }
    sort(begin(ans), end(ans));
    for(auto& x : ans) cout << x.se << '\n';
}

Measured memory_bytes: 13168
n, k = map(int, input().split())
P = list(map(int, input().split()))

E = [(p + 1) / 2 for p in P]

answer = temporary = sum(E[:k])
for i in range(n - k):
    temporary += E[i + k] - E[i]
    answer = max(answer, temporary)

print(answer)


Measured memory_bytes: 25060
import math
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
"""
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
"""
X1, Y1 = map(int, input().split())

if X1 >= Y1:
  X = X1
  Y = Y1
  pass
else:
  X = Y1
  Y = X1
if X > 2 * Y:
  print(0)
  exit()
else:
  pass

m = (2 * X - Y) // 3
n = (2 * Y - X) // 3 

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
  print(0)
  exit()
else:
  ans = cmb(m + n, n, 10 ** 9 + 7)
print(ans)

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

const int N = 100005;
int n, k, ans, fa[N], dep[N];
int tot, lnk[N], nxt[N], son[N];
void add (int x, int y) {
    nxt[++tot] = lnk[x], lnk[x] = tot, son[tot] = y;
}
void dfs (int x) {
    dep[x] = 1;
    for (int j = lnk[x]; j; j = nxt[j]) {
        dfs(son[j]);
        dep[x] = max(dep[x], dep[son[j]] + 1);
    }
    if (dep[x] >= k && fa[x] != 1) ++ans, dep[x] = 0;
}
int main () {
    cin >> n >> k, ans = 0;
    for (int i = 1; i <= n; ++i) scanf("%d", &fa[i]);
    if (fa[1] != 1) fa[1] = 1, ans = 1;
    for (int i = 2; i <= n; ++i) add(fa[i], i);
    dfs(1);
    printf("%d\n", ans);
    return 0;
}

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

#define MAX_N 500
#define MAX_M 500

using namespace std;

int n, m, d;

int noui(int i, int j)
{
    return i + j - 1;
}

int nouj(int i, int j)
{
    return (n - 1 + m) - (i - j + m) + 1;
}

int cd[2][2] = {{1, 2},
                {3, 4}
};

int cod(int i, int j)
{
    int loci = (i / d + ((i % d) != 0)) % 2;
    int locj = (j / d + ((j % d) != 0)) % 2;

    //printf("AVEM %d %d  si codul %d %d\n", i, j, loci, locj);
//
    return cd[loci][locj];
}

char codul[] = {0, 'R', 'Y', 'G', 'B'};

char charul(int nr)
{
    return codul[nr];
}

int a[MAX_N + 1][MAX_M + 1];

int main()
{
    scanf("%d%d%d", &n, &m, &d);

    int i, j;
    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j <= m; j ++)
        {
            a[i][j] = cod(noui(i, j), nouj(i, j));
        }
    }

    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j <= m; j ++)
        {
            printf("%c", charul(a[i][j]));
        }

        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 1408
N,M = list(map(int,input().split()))
list = []
for i in range(N):
    a,b=(input()).split()
    list.append((int(a),int(b)))

list.sort()
ans = 0

for i in range(len(list)):
    if M <= list[i][1]:
        ans += M * list[i][0]
        break
    else:
        M = M - list[i][1]
        ans += list[i][1] * list[i][0]

print(ans)

Measured memory_bytes: 16976
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    cout << (abs(a - b) <= (v - w) * t? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	int n,m;
	cin >> n >> m;
	vii graph (n,vector<int>());
	for(int i = 0; i < m; i++) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	queue<int> q;
	q.push(0);
	vector<bool> visited (n,false);
	visited[0] = true;
	vector<int> lvl (n,0);
	while(!q.empty()) {
		int v = q.front();
		if(v == n-1) {
			cout << "POSSIBLE";
			return 0;
		}
		q.pop();
		for(int u : graph[v]) {
			if(!visited[u] && lvl[v] < 2) {
				lvl[u] = lvl[v]+1;
				q.push(u);
				visited[u] = true;
			}
		}
	}
	cout << "IMPOSSIBLE";
	return 0;
}



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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
//constexpr double INF = 1e10;
constexpr double EPS = 1e-10;
constexpr double PI = 3.14159265358979;
using number = long long;

#define rad_to_deg(rad) (((rad)/2/PI)*360)

int main() {
    double a, b, x; cin >> a >> b >> x;
    if (x >= a * a * b / 2 ) {
        cout << rad_to_deg(atan2(2 * (a * a * b - x), a * a * a)) << endl;
    }
    else {
        cout << rad_to_deg(atan2(a * b * b, 2 * x)) << endl;
    }

}


Measured memory_bytes: 256
k=int(input())
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]

print(a[k-1])

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	private static final int origin = 100000;
	private static final double interest = 1.05;

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int num = sc.nextInt();
		double ans = origin;

		for(int count = 0; count < num; count++) {
			ans = ans * interest / 1000;
			ans = Math.ceil(ans) * 1000;
		}

		System.out.println((int)ans);
	}

}

Measured memory_bytes: 26216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *next, *prev;
};

struct Node *nil;

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

void init(){
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  struct 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(struct Node *t){
  if(t == nil)
    return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

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

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

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(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();
        else if(com[6] == 'L')
          deleteLast();
      }
      else{
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33024
import sys
sys.setrecursionlimit(10**6)
def f(x,dic,i):
    p=dic1[x]
    if p in dic:
        return [dic,p]
    else:
        dic[p]=i
        return f(p,dic,i+1)

def inv(x,dic):
    for k,v in dic.items():
        if v==x:
            return k

n,k=map(int,input().split())
m=[i for i in range(n)]
l=list(map(int,input().split()))
for i in range(n):
    l[i]-=1
dic1=dict(zip(m,l))
d={0:0}
trace1=f(0,d,1)
u=trace1[0]
i=len(u)
if k<i:
    print(inv(k,u)+1)
else:
    d={trace1[1]:0}
    trace2=f(trace1[1],d,1)
    v=trace2[0]
    j=len(v)
    k=k-i
    k=k%j
    print(inv(k,v)+1)

Measured memory_bytes: 228204
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n, b, sum2;
	float y, r, t, joe;
	float sum = 0, math, s, d;
	while (1) {
		scanf("%d", &n);
		if (n == 0)return 0;
		cin >> y;
		for (int i = 0; i < n; i++) {
			cin >> b >> r >> t;
			if (t == 1) {
				math = 10000 * (1 + y*(r / 100));
				s = math;
			}
			else if (t == 2) {
				math = 1 + (r / 100);
				joe = math;
				//cout<<math;
				for (int i = 0; i < y - 1; i++) {
					joe = joe*math;
				}
				//cout << math;
				math = 10000 * joe;
				d = math;
			}
			if (i == 0) {
				sum = math;
				sum2 = b;
				continue;
			}

			if (sum < math) {
				sum = math;
				sum2 = b;
			}

		}
		printf("%d\n", sum2);
		sum = sum2 = 0;
	}
}

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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a + b >= 10) {
            System.out.println("error");
        } else {
            System.out.println(a + b);
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main() {
    int x, y, group[] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    cin >> x >> y;
    cout << (group[x-1] == group[y-1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

import bisect
print(sum(bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b)) for b in B))

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef vector<int> vi;

const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<ll> a(N);
	rep(i, N) cin >> a[i];
	ll ans = 0;
	rep(t, 10000) {
		rep(i, N) if (a[i] > N - 1) {
			ll x = a[i] / N;
			a[i] -= x * N;
			rep(j, N) if (j != i) a[j] += x;
			ans += x;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main(void){
  int n,i,j,x,y;
  vector<P> r,b;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> x >> y;
    r.push_back(P(y,x));
  }
  for (i=0;i<n;i++){
    cin >> x >> y;
    b.push_back(P(x,y));
  }
  
  sort(r.begin(),r.end(),greater<P>());
  sort(b.begin(),b.end());
  
  int ans=0,cx,cy;
  bool ru[105]={false};
  for (i=0;i<n;i++){
    cx=b[i].first;
    cy=b[i].second;
    j=0;
    while (j<n && (ru[j] || r[j].second>cx || r[j].first>cy)) j++;
    if (j<n){
      ans++;
      ru[j]=true;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;

int fct[200005], ifct[200005];

int N, pos1, pos2;
int pos[100005];
int sol[100005];

int power(int x, int y)
{
    if(y <= 0)  return 1;
    int ans = power( (1LL * x * x) % mod, y >> 1 );
    if(y & 1) ans = (1LL * ans * x) % mod;
    return ans;
}

int cmb(int N, int K)
{
    if(K > N)   return 0;
    int ans = fct[N];
    ans = (1LL * ans * ifct[N - K]) % mod;
    ans = (1LL * ans * ifct[K]) % mod;
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    int M = 200000;
    fct[0] = 1;
    for(int i = 1; i <= M; i++)
        fct[i] = (1LL * fct[i - 1] * i) % mod;
    ifct[M] = power(fct[M], mod - 2);
    for(int i = M - 1; i >= 0; i--)
        ifct[i] = (1LL * ifct[i + 1] * (i + 1)) % mod;


    scanf("%d", &N);
    for(int i = 1; i <= N + 1; i++)
    {
        int x;
        scanf("%d", &x);
        if(pos[x])
        {
            pos1 = pos[x];
            pos2 = i;
        }
        pos[x] = i;
    }

    for(int i = 1; i <= N + 1; i++)
        sol[i] = cmb(N + 1, i);

    int L = pos1 - 1 + (N + 1) - pos2;
    for(int i = 1; i <= N + 1; i++)
        sol[i] = (sol[i] - cmb(L, i - 1) + mod) % mod;

    for(int i = 1; i <= N + 1; i++)
        printf("%d\n", sol[i]);

    return 0;
}


Measured memory_bytes: 3584
l = list(input())
n = len(l) - 1

for i in range(2**n):
    op = ["-"] * n
    for j in range(n):
        if i>>j & 1 :
            op[j] = "+"
    formula = ""
    for p, q in zip(l, op + [""]):
        formula += p + q
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x,m,s=0,a,a_,lp=1;cin>>n>>x>>m;
  if(n<=m) {
    s+=x;a=x;
    rep(i,n-1) {
      a_=(a*a)%m;s+=a_;a=a_;
    }
  }
  else {
    lvector v,appeared(m,0);
    s+=x;appeared[x]=1;
    a=x;v.emplace_back(x);
    bool zero=(x==0),one=(x==1);
    rep(i,m+1) {
      a_=(a*a)%m;
      if(appeared[a_]==0) {
        appeared[a_]=1;
        v.emplace_back(a_); 
        s+=a_;a=a_;lp++;
      }
      else break;
      if(a_==0) {zero=true;break;}
      if(a_==1) {one=true;break;}
    }
    if(!zero&&!one) {
      ll t=0,l=v.size(),num=0,pos;
      bool ok=false;
      rep(i,l) {
        if(ok) {t+=v[i];num++;}
        else {if(v[i]==a_) {t+=v[i];num++;pos=i;ok=true;}}
      }
      ll q=(n-lp)/num,rem=(n-lp)%num;
      s+=t*q;
      rep(i,rem) s+=v[pos+i];
    }
    if(!zero&&one) s+=(n-lp);
  }
  print(s);
  return 0;
}

Measured memory_bytes: 4636
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

n=i1()
a=i2()
from collections import defaultdict
d = defaultdict(int)
for i in a:
 d[i]+=1
a.sort()
import math
f=0
for i in range(n)[::-1]:
 if d[a[i]]>0:
  x=2**(int(math.log2(a[i]))+1)-a[i]
  d[a[i]]-=1
  if d[x]>0:
    d[x]-=1
    f+=1
  else:
    d[a[i]]+=1
print(f)

Measured memory_bytes: 56820
#include <cstdio>
#include <functional>
#include <algorithm>

using namespace std;

int main() {
    int n, k, l[50] = {0}, ret = 0;
    scanf("%d %d", &n, &k);
    for (int i=0; i<n; i++)
        scanf(" %d", &l[i]);
    sort(l, l+50, greater<int>());
    for (int i=0; i<k; i++)
        ret += l[i];
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 128
#include <string> 
#include <sstream>
#include <iostream>

using namespace std;

int main(){
	int n, k, x, y; 
	
	cin>> n >> k >> x>> y;
	
	int ans = n>k?k*x+(n-k)*y:n*x;
	cout << ans;

	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 #define N 1000
 #define S 150
int LCSLength(char *,char *);

int main(){
  int q,i;
  char X[N];
  char Y[N];
  int LCS[S];
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",X);
    scanf("%s",Y);
    LCS[i]=LCSLength(X,Y);
  }

  for(i=0;i<q;i++){
    printf("%d\n",LCS[i]);
  }

  return 0;
}//main

int LCSLength(char *X, char *Y){
  int m,n,i,j;
  int c[N+1][N+1];
  m = strlen(X);
  n = strlen(Y);
  for(i=1;i<=m;i++){
    c[i][0]= 0;
  }
  for(j=0;j<=n;j++){
    c[0][j]= 0;
  }

  for(i=1;i<=m;i++){
   for(j=1;j<=n;j++){
     if(X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
     else if(c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
     else c[i][j]=c[i][j-1];
    }
   }
   return c[m][n];
  }

Measured memory_bytes: 4524
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin>>a>>b;
	while(b--){
		int sayi; cin>>sayi;
		a -= sayi;
	}
	if(a <= 0) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N,0);
    REP(i,N){
        cin >> A[i];}
    ll sum = 0;
    ll ans = 0;
    ll l = 0, r = 0;
    while(r<N){
        if((sum^A[r])==(sum+A[r])){
            sum += A[r];
            r++;
            ans += r-l;
        }else if(l==r){
            r++;
        }else{
            sum -= A[l];
            l++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n, d[10005];

	cin >> n;

	fill(d, d + 10005, 0);

	for (i = 0; i < n; i++) {
		cin >> d[i];
	}



	sort(d, d + 10005, greater<int>());

	int num = 9999999;
	int cnt = 0;

	for (i = 0; i < n; i++) {
		if (num > d[i]) {
			cnt++;
			num = d[i];
		}
	}

	cout << cnt << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
<?PHP
$single_line_input = fgets(STDIN);
// 取得した入力値を半角スペースで分解します
$array = explode(" ", $single_line_input);
//複数の変数に値を一括代入する
list($item_num, $weight_upper) = $array;

for ($i = 0; $i < $item_num; ++$i) {
    fscanf(STDIN, "%d %d ", $x, $y);
    $weight[$i] = $x;
    $value[$i] = $y;
}

$dp = [];
foreach (range(0, $item_num - 1) as $item_index) {
    $i_value = $value[$item_index];
    $i_weight = $weight[$item_index];
    foreach (range(1, $weight_upper) as $weight_index) {
        $current_value = $dp[$item_index - 1][$weight_index] ?? 0;
        if ($weight[$item_index] <= $weight_index) {
            $new_value = (($dp[$item_index - 1][$weight_index - $weight[$item_index]] ?? 0 )+ $i_value);
            $dp[$item_index][$weight_index] = $current_value >= $new_value ? $current_value : $new_value;
        } else {
            $dp[$item_index][$weight_index] = $current_value;
        };
    }
}
echo $dp[(int)$item_num - 1][(int)$weight_upper];



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int x;
bool dp[100001];

signed main() {
    cin >> x;
    dp[0] = true;
    rep(i,6) {
        repo(j,100+i,100001) {
            dp[j] |= dp[j-100-i];
        }
    }
    if (dp[x]) cout << 1 << endl;
    else cout << 0 << endl;
}





Measured memory_bytes: 384
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

r, D, x = rl()

for i in range(1, 11):
	x = r*x-D
	print(x)

Measured memory_bytes: 68144
from collections import defaultdict
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = tuple(map(int, input().split()))

    ball = defaultdict(int)
    for i in A:
        ball[i] += 1
    total = 0
    sel = defaultdict(int)
    for k, v in ball.items():
        n = v * (v - 1) // 2
        sel[k] = n
        total += n
    for a in A:
        n = ball[a] - 1
        x = (n * (n - 1)) // 2
        print(total - (sel[a] - x))


main()


Measured memory_bytes: 32156
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, k] = li()
    a_list = li()
    mod = 10 ** 9 + 7

    tentou = 0
    b = k * (k + 1) // 2 % mod
    c = k * (k - 1) // 2 % mod
    for index in range(n):
        num1 = len([0 for a in a_list[index + 1:] if a_list[index] > a])
        num2 = len([0 for a in a_list[:index] if a_list[index] > a])
        tentou = tentou + num1 * b + num2 * c
        tentou = tentou % mod
    print(tentou)

# i=0系に対する転倒数
# a1, ..., an-1の中でa0より小さい数の個数 * (k + k-1 + ... + 1)
# i=1
# a2, ..., an-1の中でa1より小さい数の個数 * (k + k-1 + ... + 1) + a0の中でa1より小さい数の個数 * (k-1 + ... + 1)
# i=m
# am+1, ..., an-1の中でamより小さい数の個数 * (k + k-1 + ... + 1) + a0, ..., am-1の中でa1より小さい数の個数 * (k-1 + ... + 1)


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

ll p[5010];
ll c[5010];

const ll INF = 10000000000LL;

ll search(ll s, ll k, ll n){
    vector<bool> visited(n, false);
    ll cnt = 0LL;
    ll next = p[s];
    ll score = 0LL, max_score = -INF;

    // 1回のループの走査
    while((!visited[next]) && cnt < k){
        visited[next] = true;
        score += c[next];
        next = p[next];
        cnt++;
        max_score = max(max_score, score);
    }

    // ループ途中の場合
    if(cnt >= k) return max_score;
    
    // ループ全体が負の場合
    if(score <= 0) return max_score;
    
    // ループで余った部分の最大値
    ll res_max_score = -INF;
    ll res_score = 0LL;
    next = p[s];
    rep(i, cnt){
        res_score += c[next];
        next = p[next];
        res_max_score = max(res_max_score, res_score + score*((k-i-1)/cnt));
    }

    return res_max_score;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; ll k; cin >> n >> k;
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];

    ll ans = -INF;
    rep(i,n) ans = max(ans, search(i, k, n));
    cout << ans << endl;
}

Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var B = ReadArrayInt();
            var C = ReadArrayInt();
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                ans += B[A[i] - 1];
                if (i < N - 1 && A[i] + 1 == A[i + 1]) ans += C[A[i] - 1];
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	/** 選ぶ人数 */
	private static final int N = 3;
	/** 対象となる頭文字 */
	private static final Set<Character> MARCHS = Set.of('M', 'A', 'R', 'C', 'H');

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Map<Character, Integer> map = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				String s = scanner.next();
				char c = s.charAt(0);
				if (MARCHS.contains(c)) {
					map.put(c, map.getOrDefault(c, 0) + 1);
				}
			});
			int[] count = map.values().stream().mapToInt(Integer::intValue).toArray();
			System.out.println(IntStream.range((1 << N) - 1, (1 << count.length)).filter(i -> N == Integer.bitCount(i))
					.mapToLong(i -> IntStream.range(0, count.length).filter(j -> 0 != (i & (1 << j)))
							.mapToLong(j -> (long) count[j]).reduce(1L, (a, b) -> a * b))
					.sum());
		}
	}
}


Measured memory_bytes: 59348
#include <iostream>


using namespace std;

int main(void) {

	while(true) {
		int x, y;
		cin >> x >> y;
		if(x == 0 && y == 0)	break;

		if(x < y) {
			cout << x << " " << y << endl;
		} else {
			cout << y << " " << x << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector <int> v(m);
    int left=0,right=0;
    for(int i = 0; i < m; i++){
        cin >> v[i];
        if(v[i]<x){
            left++;
        }else{
            right++;
        }
    }
    int ans = min(left,right);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3504
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;

bool desc(int i, int j) { return i > j; }
map<char, int>mappp;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int out = 0;
	int arr[1000];
	for (int i = 0; i < n; i++)cin >> arr[i];
	sort(arr, arr + n, desc);
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)out += arr[i];
		if (i % 2 != 0)out -= arr[i];
	}
	cout << out << "\n";

}




Measured memory_bytes: 256
//
// Created by Daiki Kuyoshi on 2020/05/02.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>

using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

ll f(ll x, ll A, ll B){
    return floor((A*x)/B) - floor(A*(x/B));
}

int main(){
    ll A, B, N;
    cin >> A >> B >> N;


    cout <<f(min(N, B-1), A, B) << endl;

}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
  string S; 
  cin>>S;
  int N=S.size();
  vector<int> black(N);
  vector<int> white(N);
  vector<int> tile(N);
  for(int i=0; i<N; i++){
    tile.at(i)=ctoi(S.at(i));
    if(i%2==0){
      black.at(i)=0; //黒スタート
      white.at(i)=1; //白スタート
    }
    if(i%2==1){
      black.at(i)=1; //010101
      white.at(i)=0; //101010
    }
  } //i;
  int countblack=0;
  int countwhite=0;
  for(int i=0; i<N; i++){
    countblack+=abs(tile.at(i)-black.at(i));
    countwhite+=abs(tile.at(i)-white.at(i));
  }
  cout<<min(countblack, countwhite)<<endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,s,n) for (int i = s; i < n; ++i)
#define drep(i,s,n) for (int i = n; i >= s; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, 0, n)
  {
    cout << '[';
    rep(p, 0, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}

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

//------------------------------------------------------------
void solve() {
  int N, sum=0;
  cin >> N;
  vector<ll> v(N);
  rep(i,0,N) cin>>v.at(i);

  sum = accumulate(all(v), 0);

  if(sum%2==0) print("YES");
  else print("NO");

  return;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, h, a = 0;
  vector<i64> b(1, 0);
  cin >> n >> h;
  for (i64 i = 0; i < n; ++i) {
    i64 x, y;
    cin >> x >> y;
    a = max(a, x);
    b.push_back(y);
  }
  sort(begin(b), end(b));
  i64 ans = 0;
  while (h > 0) {
    if (b.back() > a) {
      h -= b.back();
      b.pop_back();
      ++ans;
    } else {
      break;
    }
  }
  ans += (max(h, i64(0)) + a - 1) / a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  for (int i = 0; i < N; i++)
  {
    int K;
    cin >> K;
    for (int i = 0; i < K; i++)
    {
      int A;
      cin >> A;
      mp[A]++;
    }
  }
  int ans = 0;
  for (auto a : mp)
  {
    if (a.second == N)
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

  int cnt = 0;
  for (int i = 0; i < N; i++) if (A.at(i) % 2) cnt++;

  cout << ((cnt % 2 == 0) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val t = sc.nextInt()
  val a = sc.nextInt()
  val h = (1..n).map { sc.nextInt() }.toIntArray()

  var ans = 0
  var diff = Double.MAX_VALUE
  for (i in 0 until n) {
    val tmp = t - (h[i] * 6 / 1000.0)
    val tmpdiff = Math.abs(a.toDouble() - tmp)
    if (tmpdiff < diff) {
      diff = tmpdiff
      ans = i
    }
  }

  println(ans + 1)
}


Measured memory_bytes: 31656
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
    int a, b; cin >> a >> b;

    if (0 >= a && 0 <= b) {
        cout << "Zero" << endl;
    }
    else if (a > 0 && b > 0){
        cout << "Positive" << endl;
    }
    else if ((a%2 && b%2) || (!(a%2) && !(b%2))) {
        cout << "Negative" << endl;
    }
    else {
        cout << "Positive" << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	int A[10];
	REP(i, 5)
	{
		cin >> A[i];
	}

	vector<int> v;
	v.push_back(0);
	v.push_back(1);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);

	int m = INT_MAX;
	do
	{
		int cur = 0;
		for (int i = 0; i < 4; i++)
		{
			int a = ceil(A[v[i]] / 10.0) * 10;
			cur += a;
		}
		cur += A[v[4]];
		m = min(cur, m);
	} while (next_permutation(v.begin(), v.end()));

	cout << m << endl;
}



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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!p)
#define until(p) while(!p)

using ll = long long;
using P = std::tuple<int,int>;

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

ll A[200000];

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

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

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

    ll res = std::numeric_limits<ll>::max();
    for(int i=0;i+1<N;++i){
        res = min(res, std::abs(A[i] - (A[N-1] - A[i])));
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
  
int main(void){
    int n, i;
    int sum = 100000;
      
    scanf("%d", &n);
      
    for (i = 0; i < n; i++){
        sum += sum * 0.05;
		
		if (sum % 1000 > 0){
			sum = sum - sum % 1000 + 1000;
    	}
    }
	
	printf("%d\n", sum);
     
    return (0);
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;

int a = 0, c = 1, g = 2, t = 3;
ll dp[MAX_N][4][4][4];

ll ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int j = 0; j < 4; ++j)
    for (int k = 0; k < 4; ++k)
      for (int l = 0; l < 4; ++l) {
        if (j == a && k == g && l == c) continue;
        if (j == a && k == c && l == g) continue;
        if (j == g && k == a && l == c) continue;

        dp[3][j][k][l] = 1LL;
      }

  // dp[0][t][t][t] = 1LL;

  for (int i = 3; i < n; ++i) {
    for (int j = 0; j < 4; ++j)
      for (int k = 0; k < 4; ++k)
        for (int l = 0; l < 4; ++l) {
          for (int m = 0; m < 4; ++m) {
            if (j == a && k == g && l == c) continue;
            if (j == a && k == c && l == g) continue;
            if (j == g && k == a && l == c) continue;
            if (k == a && l == g && m == c) continue;
            if (k == a && l == c && m == g) continue;
            if (k == g && l == a && m == c) continue;
            if (j == a && k == g && m == c) continue;
            if (j == a && l == g && m == c) continue;

            dp[i + 1][k][l][m] += dp[i][j][k][l];
            dp[i + 1][k][l][m] %= MOD;
          }
        }
  }

  ans = 0;

  for (int k = 0; k < 4; ++k)
    for (int l = 0; l < 4; ++l)
      for (int m = 0; m < 4; ++m) {
        // printf("%d %d %d: %lld\n", k, l, m, dp[3][k][l][m]);
        ans += dp[n][k][l][m];
        ans %= MOD;
      }

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

  return 0;
}


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

int main() {
  int N;cin >> N;
  vector<vector<int>> A(N,vector<int>(2));
  for (int i=0;i<N;i++) {
    cin >> A.at(i).at(0) >> A.at(i).at(1);
  }
  long double sum_len=0;
  for (int i=0;i<N;i++) {
    for (int j=i+1;j<N;j++) {
      int x = A.at(j).at(0)-A.at(i).at(0);
      int y = A.at(j).at(1)-A.at(i).at(1);
      long double d = sqrt(x*x + y*y);
      sum_len += d;
    }
  }
  long double mean_d = 2*sum_len / N;
  cout << setprecision(13) << mean_d << endl;
}

Measured memory_bytes: 256