akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
}Node;

Node *T;

void insert(int);
void print(Node *);
void inorder(Node *);
void preorder(Node *);
Node *find(Node *,int);
void Delete(Node *);
Node *TreeSuccessor(Node *);
Node *treeMinimum(Node *);

int main()
{
  int n,i,k,j;
  char command[10];
  Node *z;

  //T->l=NIL;
  //T->r=NIL;
  
  scanf("%d",&n);
  if(n>500000) exit(1);
  for(i=0;i<n;i++){
    scanf("%s",command); //コマンド検出
    if(command[0] == 'i'){ //insert
      scanf("%d",&k);
      insert(k);
    }
    else if(command[0] == 'p') //print
      print(T);
    else if(command[0] == 'f'){ //find
      scanf("%d",&k);
      z = find(T,k);
      if(z!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else{ //delete
      scanf("%d",&k);
      Delete(find(T,k));
    }
  }
  return 0;
}

void insert(int k)
{
  Node *x,*y,*z;

  y = NIL; //xの親(rootの親だからNIL)
  x = T; //root

  z = (Node *)malloc(sizeof(Node));
  
  z->key = k;
  z->l=NIL;
  z->r=NIL;
  
  while(x != NIL){
    y = x; //親を設定
    if(z->key < x->key) x = x->l; //左の子に移動
    else x = x->r; //右の子に移動
  }
  z->p = y;
  
  if(y==NIL) //Tが空の場合
    T = z;
  else if(z->key < y->key)
    y->l = z; //zをyの左の子にする
  else
    y->r = z; //zをyの右の子にする
  //printf(" %d",x->p);
}

void print(Node *root)
{
  if(root==NIL) return;
  
  inorder(root); //左→上→右
  printf("\n");
  preorder(root); //左→右→上
  printf("\n");
}

void inorder(Node *root)
{
  if(root==NIL) return;
  inorder(root->l); //左
  printf(" %d",root->key); //上
  inorder(root->r); //右
}

void preorder(Node *root)
{
  if(root==NIL) return;
  printf(" %d",root->key); //上
  preorder(root->l); //左
  preorder(root->r); //右
}

Node *find(Node *x,int k)
{
  while(x != NIL && k != x->key){ //insertのとこと同じ要領で探していく
    if(k < x->key) x = x->l;
    else x = x->r;
  }
  return x;
}

void Delete(Node *z)
{
  Node *y; //削除するやつ
  Node *x; //yの子

  if(z->l == NIL || z->r == NIL) y=z; //zが子を持たない or 一つ子持ちならそのままもってくる
  else y = TreeSuccessor(z); //二つ子持ちの場合、zの右側の木から一番小さいやつをもってくる

  if(y->l != NIL) x = y->l; //
  else x = y->r;

  if(x != NIL) x->p = y->p; //yに子がいた場合その子とyの親を繋げる
  if(y->p == NIL) T = x; //yに親がいないということはrootなのでxがrootになる
  else if(y == y->p->l) y->p->l = x; //yの親の左の子か右の子かを判断して繋げる
  else y->p->r = x; //同上

  if(y != z) z->key = y->key; //zの次節点が削除されたらyのデータをzにコピーする

  free(y);
}

Node *TreeSuccessor(Node *x) 
{
  Node *y; //xの親
  
  if(x->r != NIL) return treeMinimum(x->r); 
  y = x->p;
  while(y != NIL && x == y->r){ //xがyの右側の子である限りyの方が小さいからyを辿っていく
    x = y;
    y = y->p;
  }
  return y;
}

Node *treeMinimum(Node *x) //xから一番数字の小さいやつを探す
{
  while(x->l != NIL)
    x = x->l; 
  return x;
}



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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rep2(i,a,b,c) for(i=a;i<=b;i+=c)
#define maxn 100000
#define ll long long
ll mod=(ll)1000000007;
ll fact[maxn+1];

void prekom(){
	fact[0]=1;
	int i;
	rep(i,1,maxn){
		fact[i]=(fact[i-1]*(ll)i)%mod;
	}
}

int main(){
	prekom();
	int N,M;
	cin>>N>>M;
	if(abs(N-M) > 1){
		cout<<"0\n";
	}
	else if(N==M){
		cout<<(fact[N]*fact[M]*(ll)2)%mod<<"\n";
	}
	else{
		cout<<(fact[N]*fact[M])%mod<<"\n";
	}
}


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

 int main() {
   ll H, k = 0;
   cin >> H;

   while(H > 0) {
     k++;
     H /= 2;
   }

   cout << (ll)pow(2, k) - 1 << endl;
 }


Measured memory_bytes: 512
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (B % A == 0) {
      System.out.println(A + B);
    } else {
      System.out.println(B - A);
    }
  }
}

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 3e5 + 10;

int sum[N], a[N], n, s[2];

bool check(int mid) {
	int res = 0;
	for (int i = 2; i <= n; ++ i) {
		if (sum[i - 1] - res >= mid) res = std::min(sum[i], res);
	}
	return sum[n] - res >= mid;
}

int main() {
	read(n);
	for (int i = 1; i <= n; ++ i) {
		read(a[i]); sum[i] = sum[i - 1] + (i & 1 ? a[i] : -a[i]);
		s[i & 1] += a[i];
	}
	if (!(n & 1)) { printf("%d %d\n", std::max(s[0], s[1]), std::min(s[0], s[1])); return 0; }
	int l = 0, r = s[0] + s[1];
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid + 1;
		else r = mid - 1;
	}
	int ans = std::max(s[0] + l - 1, s[1]);
	printf("%d %d\n", ans, s[0] + s[1] - ans);
	return 0;
}


Measured memory_bytes: 2560
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

S = [0]*(n+1)
ans = 0

for i in range(n):
    S[i+1] = S[i] + A[i]

for i in range(1,n):
    ans += A[i-1]*(S[-1] - S[i])
    ans %= (10**9 + 7)

print(ans % (10**9 + 7))

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

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

  rep(i, s.size()) {
    s[i] = (s[i] - 'A' + n) % 26 + 'A';
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
S=int(input())
x=S//100
y=S%100
yymm=1<=y<=12
mmyy=1<=x<=12
ans=""
if yymm and mmyy:
    ans="AMBIGUOUS"
elif yymm:
    ans="YYMM"
elif mmyy:
    ans="MMYY"
else:
    ans="NA"
print(ans)

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

ll lay[55],pat[55];

ll func(int n, ll x)
{
  if(n==0) return (x<=0 ? 0 : 1);
  else if(x<=lay[n-1]+1) return func(n-1,x-1);
  else return pat[n-1] + 1 + func(n-1,x-2-lay[n-1]);
  
}
  
int main()
{
  int n;
  ll x;
  cin >> n >> x;
  lay[0]=1;
  pat[0]=1;
  FOR(i,1,n){
    lay[i] = 2*lay[i-1]+3;
    pat[i] = 2*pat[i-1]+1;
  }
  cout << func(n,x) << '\n';

}


Measured memory_bytes: 256
s = input()
n = len(s)
idx = 0
while idx < n:
    if idx+5 > n:
        break
    if s[idx:idx+5] == 'dream':
        idx += 5
        if idx+2 <= n and s[idx:idx+2] == 'er' and (idx+2 == n or s[idx+2:idx+3] != 'a'):
            idx += 2
    elif s[idx:idx+5] == 'erase':
        idx += 5
        if idx+1 <= n and s[idx:idx+1] == 'r':
            idx += 1
    else:
        break

if idx == n:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];

    vec d;
    d.push_back(abs(a[0]));
    rep(i, n-1) d.push_back(abs(a[i] - a[i+1]));
    d.push_back(abs(a[n-1]));

    lint s = accumulate(all(d), 0LL);

    rep(i, n) {
        lint o = s;
        o -= d[i];
        o -= d[i+1];
        if (i == 0) {
            o += abs(a[1]);
        }
        else if (i == n-1) {
            o += abs(a[n-2]);
        }
        else {
            o += abs(a[i-1] - a[i+1]);
        }
        cout << o << endl;
    }
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>

using namespace std;

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

    int lot[w + 1][n];
    fill(lot[0], lot[w + 1], 0);

    int a, b;
    char c;
    for (int i = 0; i < n; i++) {
        cin >> a >> c >> b;
        lot[a][i] = b;
        lot[b][i] = a;
    }

    int ans[w + 1];
    for (int i = 1; i <= w; i++) {
        int i_ = i;
        for (int j = 0; j < n; j++) {
            if (lot[i_][j] != 0) i_ = lot[i_][j];
        }
        ans[i_] = i;
    }
    for (int i = 1; i <= w; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(3*n); rep(i, 3*n) cin >> A[i];
  multiset<ll> s1, s2, s3;
  ll sum1=0, sum2=0;
  rep(i, n) {
    s1.insert(A[i]);
    sum1 += A[i];
  }
  REP(i, n, 3*n) {
    s2.insert(A[i]);
    sum2 += A[i];
  }
  while((int)s2.size() > n) {
    ll mx = *s2.rbegin();
    s3.insert(mx);
    s2.erase(s2.find(mx));
    sum2 -= mx;
  }
  ll ans = sum1-sum2;
  REP(i, n, 2*n) {
    if(s3.count(A[i])) {
      s3.erase(s3.find(A[i]));
      s1.insert(A[i]);
      ll mn = *s1.begin();
      sum1 += A[i]-mn;
      s1.erase(s1.find(mn));
    } else {
      s2.erase(s2.find(A[i]));
      ll mn = *s3.begin();
      sum2 += mn-A[i];
      s3.erase(s3.find(mn));
      s2.insert(mn);
      s1.insert(A[i]);
      mn = *s1.begin();
      sum1 += A[i]-mn;
      s1.erase(s1.find(mn));
    }
    ans = max(sum1-sum2, ans);
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

int main(){

	string data;
	int count[26];


	for (int i = 0; i < 26; i++){
		count[i] = 0;

	}

	while (getline(cin, data)){
		

		for (int i = 0; data[i]; i++){
			if (isupper(data[i])){
				data[i] = tolower(data[i]);
			}
	
			switch (data[i]){
			case 'a':
				count[0]++; break;
			case 'b':
				count[1]++; break;
			case 'c':
				count[2]++; break;
			case 'd':
				count[3]++; break;
			case 'e':
				count[4]++; break;
			case 'f':
				count[5]++; break;
			case 'g':
				count[6]++; break;
			case 'h':
				count[7]++; break;
			case 'i':
				count[8]++; break;
			case 'j':
				count[9]++; break;
			case 'k':
				count[10]++; break;
			case 'l':
				count[11]++; break;
			case 'm':
				count[12]++; break;
			case 'n':
				count[13]++; break;
			case 'o':
				count[14]++; break;
			case 'p':
				count[15]++; break;
			case 'q':
				count[16]++; break;
			case 'r':
				count[17]++; break;
			case 's':
				count[18]++; break;
			case 't':
				count[19]++; break;
			case 'u':
				count[20]++; break;
			case 'v':
				count[21]++; break;
			case 'w':
				count[22]++; break;
			case 'x':
				count[23]++; break;
			case 'y':
				count[24]++; break;
			case 'z':
				count[25]++; break;
			}



		}




	}		
	for (int i = 0; i < 26; i++){

		cout << char(i + int('a')) << " : " << count[i] << endl;

	}


	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    vector<int> dp(205, 0);
    FOR(i, 1, 205){
        FOR(j, 1, i+1){
            if(i % j == 0) dp[i]++;
        }
    }
    int ans = 0;
    REP(i, n) if((i+1) & 1 && dp[i+1] == 8) {
    ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

N = int(input())
L = list(int(x) for x in input().split())

counter = 0

for i in range(1, N - 1):
    if L[i - 1] > L[i] and L[i] > L[i + 1]:
        counter += 1
    elif L[i - 1] < L[i] and L[i] < L[i + 1]:
        counter += 1

print(counter)


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

int main(void) {
    int x;
    cin >> x;
    if (400 <= x && x < 600)
        cout << 8 << endl;
    else if (600 <= x && x < 800)
        cout << 7 << endl;
    else if (800 <= x && x < 1000)
        cout << 6 << endl;
    else if (1000 <= x && x < 1200)
        cout << 5 << endl;
    else if (1200 <= x && x < 1400)
        cout << 4 << endl;
    else if (1400 <= x && x < 1600)
        cout << 3 << endl;
    else if (1600 <= x && x < 1800)
        cout << 2 << endl;
    else
        cout << 1 << endl;
    return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int l, r; scanf("%d%d", &l, &r);
	if(r - l >= 2018)
		printf("%d", 0);
	else {
		int min = 2018;
		for(int i = l; i < r; i++) {
			for(int j = i + 1; j <= r; j++) {
				uin(min, ((j % 2019) * (i % 2019)) % 2019);
			}
		}
		printf("%d", min);
	}





	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = Integer.parseInt(readInputLine())
    val a = readInputLine().toCharArray()
    val b = readInputLine().toCharArray()
    val c = readInputLine().toCharArray()
    
    var ans = 0
    
    for (i in 0 until n) {
        ans += setOf<Char>(a[i], b[i], c[i]).count() - 1
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 35944
n=int(input())
l=list(map(int,input().split()))
z,flag=1,0
m=10**18
mi=min(l)
if mi==0:
  print(0)
else:
  for i in l:
    z*=i  
    if z>m:
      flag=1
      break
  if flag==1:
    print(-1)
  else:
    print(z)


Measured memory_bytes: 21656
#include<stdio.h>

int main() {
        char input[11];
        char *input_ptr;
        char output[11];
        scanf("%s", input);
        input_ptr = input;
        for (int j = 0; ;input_ptr++) {
                if (*input_ptr == '\0') {
                        *(output + j) = '\0';
                        break;
                }
                switch (*input_ptr) {
                        case '0':
                                *(output + j) = '0';
                                j++;
                                break;
                        case '1':
                                *(output + j) = '1';
                                j++;
                                break;
                        case 'B':
                                if (j == 0) break;
                                *(output + j) = '\0';
                                j--;
                                break;
                }
        }
        printf("%s\n", output);
        return 0;
}


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

int main(){
	int N;
	cin>>N;
	double v[1000],a;
	for(int i=0;i<N;i++){
		cin>>v[i];
	}
	sort(v,v+N);
	for(int i=1;i<N;i++){
		v[i]=(v[i]+v[i-1])/2;
		a=v[i];
	}
	cout<<a;;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>



int main(){
    int n;
    std::cin >> n;
    typedef struct {
        int d;
        int i;
        int r;
    } t;
    std::vector<t> d(n);
    
    for( int i=0; i<n; ++i ){
        std::cin >> d[i].d;
        d[i].i = i;
    }
    std::sort( d.begin(), d.end(), [](const t& lhs,const t& rhs){return (lhs.d)<(rhs.d); } );
    for( int i=0; i<n; ++i ){ d[i].r=i; }
    int m1 = d[n/2-1].d;
    int m2 = d[n/2].d;
    std::sort( d.begin(), d.end(), [](const t& lhs,const t& rhs){return (lhs.i)<(rhs.i); } );

    for( t v : d ){
        if ( v.r < n/2 ){
            std::cout << m2 << std::endl;
        } else {
            std::cout << m1 << std::endl;
        }
    }
    return 0;



}

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

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

 

const int mod = 1e9;
const int N = 3e5 + 5;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

template <typename T>
long long myrand(T m) {
    long long mod = m;
    long long x = mt()%mod;

    return x;
}

int main() {
    io();
    ll x;
    cin >> x;
    ll y = 100;
    int cnt = 0;
    while(y < x) {
        ll add = y / 100;
        y += add;
        cnt++;
    }
    cout << cnt;
}




Measured memory_bytes: 3612
#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[i];
    }
    sort(a.begin(), a.end());

    int ans = 0;
    for(int i = 0; i < N; ){
        int count = 0;
        int checkDuplicationValue = a[i];
        while(i < N && a[i] == checkDuplicationValue ){
            count++;
            i++;
        }
        ans += count % 2;
        // cout << i<<' '<<ans <<endl;
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

#define FOR(i, a, b) for(int i=(int)a; i < (int)b; ++i)
#define REP(i, n) FOR(i,0,n)
#define RFOR(i, a, b) for(int i=(int)b-1; i >= (int)a; --i)
#define RREP(i, n) RFOR(i,0,n)
#define IN(a,x,b) (a<=x && x < b)
template<class T> inline void chmax(T& a, const T& b){if(a<b) a = b;}
template<class T> inline void chmin(T& a, const T& b){if(a>b) a = b;}

using namespace std;
using ll = long long;
template<class T> using V = std::vector<T>;
template<class T> using VV = V<V<T>>;

int data[1003][12][22];

void precalc() {
  int y = 1, m = 1, d = 1;
  int now = 0;
  const int M = 196470;
  while(now <= M) {
    data[y][m][d] = M - now;
    ++now;
    ++d;
    bool f = false;
    if(y % 3 == 0) {
      if(d == 21) f = true;
    }
    else {
      if(m % 2 == 0 && d == 20) f = true;
      if(m % 2 == 1 && d == 21) f = true;
    }

    if(f) {
      d = 1;
      ++m;
      if(m == 11) {
        m = 1;
        ++y;
      }
    }
  }
}

signed main(){
  int n;
  std::cin >> n;
  precalc();
  REP(_, n) {
    int y, m, d;
    std::cin >> y >> m >> d;
    std::cout << data[y][m][d] << std::endl;
  }
  return 0;
}



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

ll findpow(ll a,ll b){
    ll cnt=0,i,j;
    while(a>1){
        a=a/b;
        cnt++;
    }
    return cnt;
}

int main(){
    ll i,j,k,sum,flag=0,t,m,n;
   string s1,s2,s;
   cin>>k>>n;
   ll a[n];
   for(i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a,a+n);
   t=a[n-1]-a[0];
   for(i=1;i<n;i++){
       if(k-(a[i]-a[i-1])<t){
           t=k-(a[i]-a[i-1]);
       }
   }
   cout<<t<<endl;
   
   
   
       
    
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n;

int main() {
  cin >> n;
  cout << "ABC" + to_string(n) << endl;
}

Measured memory_bytes: 3676
n,x = [],[]
while True:
	a,b = map(int,input().split())
	if a == 0 and b == 0:
		break
	else:
		n.append(a)
		x.append(b)
for i in range(len(n)):
	counter = 0
	for k in range(n[i]):
		kk = k+1
		for s in range(n[i]-kk):
			ss = s + kk + 1
			for f in range(n[i]-ss):
				ff = f + ss + 1
				if kk + ss + ff == x[i]:
					counter +=1
	print(counter)


Measured memory_bytes: 5596
url = "https://atcoder.jp/contests/abc092/tasks/arc093_a"
import copy
def main():
    n = int(input())
    tmp = list(map(int, input().split()))
    ma = [0]
    ma.extend(tmp)
    ma.append(0)
    all_num = 0
    for i in range(len(ma) - 1):
        all_num += abs(ma[i] - ma[i + 1])
    for i in range(1, len(ma) - 1):
        print(all_num - abs(ma[i - 1] - ma[i]) - abs(ma[i] - ma[i + 1]) + abs(abs(ma[i - 1] - ma[i + 1])))


if __name__ == '__main__':
    main()




Measured memory_bytes: 14560
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	while (cin >> H >> W, W > 0)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    int sum = 0;
    for (int i=0; i<K; i++)
        sum += A[i];
    cout << sum << endl;
    return 0;
}


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

typedef pair<int, int> P;

int main() {

    int n;
    cin >> n;
    vector<ll> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());

    if(d[n/2]==d[n/2-1]){
        cout << 0 << endl;
    }else{
        ll ans;
        ans = d[n/2] - d[n/2-1];
        cout << ans << endl;
    }
    

    return 0;
}

Measured memory_bytes: 1024
# 入力
N,K = list(map(int, input().split()))
D = list(map(int, input().split()))

availbale_numbers = [0,1,2,3,4,5,6,7,8,9]

for i in D:
    availbale_numbers.remove(i)

for i in range(N,99999):
    if(set(str(i)) <= set([str(a) for a in availbale_numbers])):
        print(i)
        break

Measured memory_bytes: 9076
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll f(ll x, ll y) {
	if (!x) return -y;
	return y / x * x * 2 + f(y % x, x);
}

int main() {
	ll N, X; cin >> N >> X;
	ll x = X, y = N - X;
	if (x > y) swap(x, y);
	cout << N + f(x, y) << endl;
}


Measured memory_bytes: 256
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


# adjacent_2
def adjacent_2(h, w, H, W):
    ret = []
    for (dh, dw) in [(0, 1), (1, 0)]:
        h_ = h + dh
        w_ = w + dw
        if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):
            ret.append((h_, w_))
    return ret


H, W = map(int, readline().split())
A = [list(readline().decode().rstrip()) for _ in range(H)]
cnt = [[1000 for _ in range(W)] for _ in range(H)]

if A[0][0] == '.':
    cnt[0][0] = 0
else:
    cnt[0][0] = 1

for h in range(H):
    for w in range(W):
        acc = adjacent_2(h, w, H, W)
        for h_, w_ in acc:
            if (A[h][w] == ".") & (A[h_][w_] == "#"):
                cnt[h_][w_] = min(cnt[h][w] + 1, cnt[h_][w_])
            else:
                cnt[h_][w_] = min(cnt[h][w], cnt[h_][w_])

print(cnt[H - 1][W - 1])


Measured memory_bytes: 27168
(n,s),a,b=$<.map{_1.split.map &:to_i}
b.reverse!
n.times{|i|$*[v=a[i]]||=i;$*[w=b[i]]||=i;v!=w||(s=v;$r=i)}
s&&b=(t=[s])*(k=[$*[s],b[0..$r].count(s),c=b.count(s)].min)+(b-t)+t*=c-k
puts (0...n).any?{a[_1]==b[_1]}?:No:[:Yes,b]
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################

Measured memory_bytes: 55416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=301,INF=1<<30;

int main(){
    
    ll N;cin>>N;
    int ans=0;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int j=0;j<N;j++){
        cin>>B[j];
    }
    int div=1;
    
    for(int k=1;k<=29;k++){
        div*=2;
        vector<int> C(N),D(N);
        for(int i=0;i<N;i++){
            C[i]=A[i]%div;
        }
        for(int i=0;i<N;i++){
            D[i]=B[i]%div;
        }
        sort(all(C));
        sort(all(D));
        
        ll cnt=0;
        
        for(int i=0;i<N;i++){
            auto left=lower_bound(all(D),div/2-C[i]);
            auto right=lower_bound(all(D),div-C[i]);
            cnt+=distance(left,right);
            left=lower_bound(all(D),div+div/2-C[i]);
            right=lower_bound(all(D),div+div-C[i]);
            cnt+=distance(left,right);
        }
        
        if(cnt%2!=0) ans+=div/2;
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
set<int> s, dup;

vector<bool> sieve;
void sieve_init(int n) {
    sieve = vector<bool>(n + 1, true);
    for (int i = 1; i <= n; i++) {
        if (sieve.at(i) && s.count(i) == 1) {
            for (int mul = i * 2; mul <= n; mul += i) {
                sieve.at(mul) = false;
            }
        }
    }
}

int main() {
    cin >> n;
    rep(i, n) {
        int k;
        cin >> k;
        if (s.count(k) == 1) {
            dup.insert(k);
        }
        s.insert(k);
    }
    sieve_init(2000000);
    int ans = 0;
    reps(i, 2000000) {
        if (sieve.at(i) && s.count(i) == 1 && dup.count(i) == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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


dp = {}
for i in range(M):
    a = ab[i][0]
    b = ab[i][1]
    if a not in dp:
        dp[a] = 1
    else:
        dp[a] += 1

    if b not in dp:
        dp[b] = 1
    else:
        dp[b] += 1

for i in range(1, N + 1):
    if i in dp:
        print(dp[i])
    else:
        print(0)

Measured memory_bytes: 3064
#include<stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
int main(){
    int n,m,x,c[12]={0},a[12][12]={0},y,z[12],b,d=2e9;
    scanf("%d%d%d",&n,&m,&x);
    rep(i,n){
    scanf("%d",&c[i]);
        rep(j,m){
            scanf("%d",&a[i][j]);
        }
    }
    rep(i,2){rep(j,2){rep(k,2){rep(l,2){rep(o,2){rep(p,2){rep(q,2){rep(r,2){rep(s,2){rep(t,2){rep(u,2){rep(v,2){
        y=i*c[0]+j*c[1]+k*c[2]+l*c[3]+o*c[4]+p*c[5]+q*c[6]+r*c[7]+s*c[8]+t*c[9]+u*c[10]+v*c[11];
        for(b=0;b<m;b++){
            z[b]=i*a[0][b]+j*a[1][b]+k*a[2][b]+l*a[3][b]+o*a[4][b]+p*a[5][b]+q*a[6][b]+r*a[7][b]+s*a[8][b]+t*a[9][b]+u*a[10][b]+v*a[11][b];
            if(z[b]<x)break;
        }
        if(b==m&&y<d)d = y;
    }}}}}}}}}}}}
    if(d==(int)2e9)puts("-1");
    else printf("%d",d);
    return 0;
}

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

int main()
{
	int n, a, b;
	int dist;

	scanf("%d %d %d", &n, &a, &b);

	dist = abs(a - b);
	if (dist & 1) {
		puts("Borys");
	} else {
		puts("Alice");
	}

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	char input[200001];
	string str;
	long long sum = 0, cnt = 0;
	int i;

	scanf("%s", input);

	str = input;

	for (i = 0; i < str.size(); i++)
	{
		if (input[i] == 'W')
		{
			cnt++;

			sum += i;
		}
	}

	sum -= cnt*(cnt - 1) / 2;

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

	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N;

int main()
{
    cin >> N;
    ll prev_x = 0, prev_y = 0;
    ll prev_t = 0;
    REP(i, N) {
        ll t, x, y;
        cin >> t >> x >> y;
        ll diff_d = abs(x - prev_x) + abs(y - prev_y);
        ll diff_t = abs(t - prev_t);
        if(diff_d > diff_t) {
            printf("No\n");
            return 0;
        } else if((diff_t - diff_d) % 2 == 1) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    string s;
    cin>>s;
    if(s.size()==3) reverse(all(s));
    cout<<s<<endl;
    return 0;
}

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

int main() {
    using namespace std;
    string s;
    cin >> s;
    unsigned long N{s.size()}, a{0};
    for(unsigned long i = 0; i < N; ++i){
        a += s[i] != s[N - i - 1];
    }
    cout << a / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n;
signed main()
{
	scanf("%d",&n);
	puts(((n<1200)?("ABC"):("ARC")));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

map<string, int> ret;

void run_case() {
    int n;
    cin >> n;
    while(n--) {
        string str;
        cin >> str;
        ret[str]++;
    }
    int mx = 0;
    for(auto i = ret.begin(); i != ret.end(); ++i) {
        mx = max(mx, i->second);
    }
    for(auto i = ret.begin(); i != ret.end(); ++i) {
        if(i->second == mx) cout << i->first << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 23808
n,m=map(int,input().split())
A=[int(i) for i in input().split()]

A.sort()
A.reverse()
#print(A)
if n==1:
    ans=A[0]//(2**m)
    print(ans)
else:
    A.append(0)
    big=A[0]
    stc=0
    now=0
    while m>0:
        A[now]=A[now]//2
        m-=1
        big=A[0]
        for i in range(n-1):
            if A[i+1]>=big and m>0:
                A[i+1]=A[i+1]//2
                m-=1
            else:
                A.sort()
                A.reverse()
                break
        #print(A)
    else:
        print(sum(A))
        

Measured memory_bytes: 14484
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,cnt[3],c[100005],_;
ll ans;
bool ok;
vector<int> v[100005],rv[100005];
void dfs(int x,int y){
    if(c[x]!=-1){
        if(c[x]!=y)ok=0;
        return;
    }
    ++cnt[c[x]=y],_+=v[x].size();
    for(int i=0;i<v[x].size();++i)dfs(v[x][i],(y+1)%3);
    for(int i=0;i<rv[x].size();++i)dfs(rv[x][i],(y+2)%3);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].pb(y),rv[y].pb(x);
    }
    memset(c,-1,sizeof(c));
    for(int i=1;i<=n;++i){
        if(c[i]!=-1) continue;
        ok=1,_=0,cnt[0]=cnt[1]=cnt[2]=0;
        dfs(i,0);
        if(!ok){
            int o=cnt[0]+cnt[1]+cnt[2];
            ans+=o*1ll*o;
        }
        else if(cnt[1]&&cnt[2])ans+=cnt[0]*1ll*cnt[1]+cnt[1]*1ll*cnt[2]+cnt[2]*1ll*cnt[0];
        else ans+=_;
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 17792
#ABC157B
def judge(A):
    flag = 'No'
    for j in range(3):
        if A[0][j]==0 and A[1][j]==0 and A[2][j]==0:
            flag = 'Yes'
            break
        if A[j][0]==0 and A[j][1]==0 and A[j][2]==0:
            flag = 'Yes'
            break
    if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
        flag = 'Yes'
    elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
        flag = 'Yes'
    print(flag)
    
def main():
    import sys
    A = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
    N = int(sys.stdin.readline())
    B = [int(sys.stdin.readline()) for _ in range(N)]
    #print(A)
    #print(B)
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                A[i][j] =0
    #print(A)
    judge(A)



        


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main()
{
   int n,m,i,j;
   int k=0;
   int a[10010];
   scanf("%d %d",&n,&m);

   for(i=0;i<m;i++)
   {
       scanf("%d",&a[i]);
       k += a[i];
   }

   if(k>n)
   {
       printf("-1");
       return 0;
   }else{
       printf("%d",n-k);
       return 0;
   }

}

Measured memory_bytes: 1748
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
int main() {
  int N; cin >> N;
  vector<int> B(N-1); cin >> B;
  int sum = B[0] + B[N-2];
  for (int i = 0; i < N-2; ++i) {
    sum += min(B[i], B[i+1]);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3584
import javax.sql.XAConnection;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        if (A + B < C * 2) {
            System.out.println(X * A + Y * B);
        } else {
            int ans;
            if (X > Y) {
                ans = Y * 2 * C + (X - Y) * A;
            } else {
                ans = X * 2 * C + (Y - X) * B;
            }
            System.out.println(Math.min(ans, Math.max(X, Y) * 2 * C));
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF (1<<30);

int main() {
  ll a;
  double b;
  cin >> a >> b;

  ll bb = round(b * 100.0);

  ll c = a * bb;

  cout << (ll)(c/100) << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


#define rep(i, n) for(int i = 0, end = (int)(n); i < end; i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    ll d;
    cin >> d;
    if (d == 22) {
        cout << "Christmas Eve Eve Eve" << endl; 
    } else if (d == 23) {
        cout << "Christmas Eve Eve" << endl; 
    } else if (d == 24) {
        cout << "Christmas Eve" << endl; 
    } else if (d == 25) {
        cout << "Christmas" << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000000000000
ll n,m,v,p,a[100005],s;
int main(void){
    scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1,greater<ll>());
    for(int i=p;i<=n;i++)s+=m-a[i];
    for(ll i=n;i>=1;i--){
		s-=(m-a[i]);
		if(a[p]<=a[i]+m&&(p+n-i)*m+s+(i-p)*a[i]>=v*m){
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
int main(){
	long long n,ans,i,j,k;
	scanf("%lld",&n);
	if(n<=2ll){
    	puts("0");
    	return 0;
    }
	k=sqrt(n+0.5);ans=n-1;
	for(i=2;i<=k;++i)if(!(n%i)){
		j=n/i-1;
		if(n%j==i)ans+=j;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define mp make_pair
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int N = 2010;
const int INF = 1e9 + 7;

int n, low[N], high[N], cnt[N];
bool hasPices[N];
vector <int> adj[N];

void dfs(int u, int p){
    cnt[u] = hasPices[u];
    high[u] = 0;
    int maxLow = 0;
    priority_queue <int, vector<int>, greater<int> > Q;
    for(int v : adj[u])
        if (v != p){
            dfs(v, u);
            Q.push(high[v] + cnt[v]);
            if (Q.size() > 2)
                Q.pop();
            cnt[u] += cnt[v];
            high[u] += high[v] + cnt[v];
            maxLow = max(maxLow, low[v] + cnt[v]);
        }
    if (Q.empty()){
        low[u] = 0;
    } else {
        int x = maxLow;
        int sum = 0;
        for(int v : adj[u])
            if (v != p)
                sum += min(high[v] + cnt[v], x - abs(high[v] + cnt[v] - x) % 2);
        if (x * 2 > sum)
            low[u] = x * 2 - sum;
        else
            low[u] = sum % 2;
    }
}

int main(){
//    freopen("inp.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    string s;
    cin >> s;
    FOR(i, 1, n)
        hasPices[i] = (s[i - 1] == '1');
    FOR(i, 1, n - 1){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans = INF;
    FOR(i, 1, n){
        dfs(i, i);
        if (low[i] == 0)
            ans = min(ans, high[i] / 2);
    }
    cout << (ans == INF? -1 : ans);

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()

int main() {
    int n;
    vector<pair<string,int> > v;
    map<pair<string,int>, int > m;
    cin >> n;
    string s;
    int p;

    REP(i, n) {
        cin >> s >> p;
        v.push_back(make_pair(s, 100-p));
        m[make_pair(s, 100-p)] = i+1;
    }


    sort(v.begin(), v.end());
    REP(i,v.size()) {
        cout << m[v[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine().replace("\n", "");
        sc.close();

        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>

using namespace std;

int N;
int preorder[41], inorder[41], postorder[41];
void make_postorder(int pre[], int in[], int post[], int num) {
    if (num == 0) return;
    if (num == 1) {
        post[0] = pre[0];
        return;
    }
    int v1[41],v2[41];
    int num1 = find(in, in+num, pre[0]) - in;
    int num2 = num - num1 - 1;
    make_postorder(pre+1, in, v1, num1);
    make_postorder(pre+1+num1, in+num1+1, v2, num2);
    copy(v1, v1+num1, post);
    copy(v2, v2+num2, post+num1);
    post[num1+num2] = pre[0];
}

int main() {
    cin>>N;
    for (int n = 0; n < N; n++) cin>>preorder[n];
    for (int n = 0; n < N; n++) cin>>inorder[n];
    make_postorder(preorder, inorder, postorder, N);
    for (int n = 0; n < N-1; n++) cout<<postorder[n]<<" ";
    cout<<postorder[N-1]<<endl;
}

Measured memory_bytes: 3148
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int MAX = 10000;
int n, color[MAX], indeg[MAX];
vector<int> v, DAG[MAX];

void bfs(int s);

void topologicalSort(){
  for(int i=0;i<n;i++){
    color[i] = 0;
  }
  for(int i=0;i<n;i++){
    if(color[i] == 0 && indeg[i] == 0){
      bfs(i);
    }
  }
}

void bfs(int s){
  queue<int> q;
  q.push(s);
  color[s] = 1;

  while(!q.empty()){
    int u = q.front(); q.pop();
    v.push_back(u);

    for(int i=0;i<DAG[u].size();i++){
      int w = DAG[u][i];
      indeg[w]--;
      if(indeg[w] == 0 && color[w] == 0){
        q.push(w);
        color[w] = 1;
      }
    }
  }
}

int main(){
  int e;
  cin >> n >> e;
  int s, t;
  for(int i=0;i<e;i++){
    cin >> s >> t;
    DAG[s].push_back(t);
    indeg[t]++;
  }

  topologicalSort();

  for(int i=0;i<n;i++) cout << v[i] << endl;
  return 0;
}



Measured memory_bytes: 3576
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];

    priority_queue<pl> q;
    rep(i,n)q.emplace(b[i],i);
    ll ans=0;
    while(q.size()){
        pl p=q.top();q.pop();
        ll idx=p.second;
        if(b[idx]<=a[idx])continue;
        ll sum=b[(idx-1+n)%n]+b[(idx+1)%n];
        ll cnt=(b[idx]-a[idx])/sum;
        if(!cnt){
            cout<<-1<<endl;
            return;
        }
        ans+=cnt;
        b[idx]-=cnt*sum;
        if(a[idx]>b[idx]){
            cout<<-1<<endl;
            return;
        }
        q.emplace(b[idx],idx);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9712