akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <ctype.h>

int mystrcmp(char* a, char* b) {
	while(1) {
		if(*a == '\0' && *b == '\0') {
			return 0;
		} else if(toupper(*a)!=toupper(*b)){
			return -1;
		}
		a++;
		b++;
	}
}

int main(void) {
	char keyword[100];
	char buff[1024];
	char* ptr;
	int count=0;
	
	gets(keyword);
	while((gets(buff))!=NULL) {
		ptr = strtok(buff, " \n");
		while(ptr!=NULL) {
			if(strcmp(ptr, "END_OF_TEXT") == 0) {
				printf("%d\n", count);
				return 0;
			} else if(mystrcmp(ptr, keyword) == 0) {
				count++;
			}
			ptr = strtok(NULL, " \n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];
int check(llong P){
int i = 0;
for(int j = 0; j < k; j++){
llong s = 0;
while(s + T[i] <= P){
s += T[i];
i++;
if(i == n) return n;
}
}
return i;
}
int solve(){
llong left = 0;
llong right = 100000 * 10000;
llong mid;
while(right - left > 1){
mid = (left + right) / 2;
int v = check(mid);
if(v >= n) right = mid;
else left = mid;
}
return right;
}
main(){
cin >> n >> k;
for(int i = 0; i < n; i++) cin >> T[i];
llong ans = solve();
cout << ans << endl;
}


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

int main() {
    vector<int> a(5);
    for(int i = 0; i < 5; ++i) cin >> a[i];
    for(int i = 0; i < 5; ++i) {
        if(a[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>

int main() {
  int N, K, Q;
  std::cin >> N >> K >> Q;
  std::vector<int> A(Q);
  for (int i = 0; i < Q; i++) std::cin >> A[i];

  std::vector<int> C(N);
  for (auto a : A) C[a - 1]++;
  for (int i = 0; i < N; i++) {
    if (K - Q + C[i] > 0)
      std::cout << "Yes" << std::endl;
    else
      std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
  int x,y;
  while(1){
  scanf("%d %d", &x, &y);
  if (x == 0 && y == 0){
    break;
  }
  if (x < y){
    printf("%d %d\n", x,y);
  }
  else{
    printf("%d %d\n", y,x);
  }
 }
 return(0);
}

Measured memory_bytes: 600
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    for (ll b = K + 1; b <= N; b++) {
        ans += (N / b) * (b - K);
        ans += max(0LL, (N % b) + 1 - K);
        // printf("b: %lld, ans: %lld\n", b, ans);
        if (K == 0) {
            ans--; // for a = 0
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, k;
    cin >> n >> k;
    if((n + 1) / k > 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
int dp[1100000];
int main() {
	int n;
	cin >> n;
	REPO(i, 1099999) dp[i] = INF;
	REP(i, n) {
		int a6 = 1, a9 = 1;
		dp[i + 1] = min(dp[i + 1],dp[i] + 1);
		REP(j, INF) {
			a6 *= 6;
			if (i + a6 > 100000) break;
			dp[i + a6] = min(dp[i + a6], dp[i] + 1);
		}
		REP(j, INF) {
			a9 *= 9;
			if (i + a9 > 100000) break;
			dp[i + a9] = min(dp[i + a9], dp[i] + 1);
		}
	}
	cout << dp[n] << endl;
}

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

int main(){
    string s;
    unordered_map<char, int> mp;
    cin >> s;

    sort(s.begin(), s.end());
    for(int i=0; i<s.size(); i++){
        mp[s[i]]+=1;
    }
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        if(((itr->second)%2)==1){ 
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
	int a,b,x,y;
	char c[100];
	scanf("%d", &a);
	getchar();
	scanf("%[^\n]", &c);
	
	x=strlen(c);
	y=x-a;
	if(x>a){
		for(int i=0;i<a;i++){
			printf("%c", c[i]);
		}
		puts("...");
	}
	
	else{
		for(int i=0;i<x;i++){
			printf("%c", c[i]);		}
	}
	
	return 0;
}

Measured memory_bytes: 1644
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    X = input().decode()
    K = int(X, 2)
    X = list(X)

    def popcount(x):
        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f  # 8bitごと
        x = x + (x >> 8)  # 16bitごと
        x = x + (x >> 16)  # 32bitごと
        x = x + (x >> 32)  # 64bitごと = 全部の合計
        return x & 0x0000007f

    # X = ['']*N
    # for i in range(N):
    #     X[i] = str(random.randint(0, 1))
    # print("".join(X))
    C = X.count("1")
    dpL = [0]*N
    dpR = [0]*N
    tmp = 1
    dpL[0] = 1 % (C+1)
    L = K % (C+1)

    if C == 1:
        R = 0
    else:
        R = K % (C-1)
        dpR[0] = 1 % (C-1)

    for i in range(1, N):
        dpL[i] = dpL[i-1]*2 % (C+1)
        if C > 1:
            dpR[i] = dpR[i-1]*2 % (C-1)

    dp = [0]*N
    dp[0] = 0
    for i in range(1, N):
        k = i % popcount(i)
        dp[i] = 1 + dp[k]

    # def solve(n, d):

    for i in range(N):
        if X[i] == "0":
            print(dp[(L + dpL[N-i-1]) % (C+1)] + 1)
        else:
            if C == 1:
                print(0)
                continue
            X[i] = '0'
            print(dp[(R - dpR[N-i-1]) % (C-1)] + 1)
            #tmp = dp[int((''.join(X)), 2) % (C-1)] + 1
            X[i] = '1'


main()
# print(dp)


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


int main(){
    int N;
    vector<int> num;
    cin>>N;

    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        num.push_back(a);
    }

    vector<int> copy(num);
    sort(copy.begin(),copy.end());
    int center = N/2-1;

    for(int i=0;i<N;i++){
        if(num[i]<=copy[center]) cout<<copy[N/2]<<"\n";
        else cout<<copy[center]<<"\n";
    }

}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 15
#define INF 1e9
 
int N,M,light,swt[MAX];
vector<int> G[MAX];
 
void init()
{
    for (int i = 0; i < MAX; i++) {
	G[i].clear();
	swt[i] = 0;
    }
}
 
struct State {
    int v, l;
    State(){}
    State(int v, int l) : v(v), l(l) {}
};
 
void solve()
{
    int d[MAX][1<<MAX];
    State path[MAX][1<<MAX];
    fill(d[0], d[0]+MAX*(1<<MAX), INF);
 
    bool found = false;
    d[0][light] = 0;
    queue<State> Q;
    Q.push(State(0, light));
    while (!Q.empty()) {
	State s = Q.front(); Q.pop();
	int v = s.v;
	if (v == N-1 && s.l == (1<<(N-1))) {
	    found = true;
	    break;
	}
	for (int i = 0; i < (int)G[v].size(); i++) {
	    int to = G[v][i];
	    if (d[v][s.l] + 1 < d[to][s.l] && (s.l >> to & 1)) {
		d[to][s.l] = d[v][s.l] + 1;
		path[to][s.l] = s;
		Q.push(State(to,s.l));
	    }
	}
	for (int i = 0; i < N; i++) {
	    if (i == v) continue;
	    if (swt[v] >> i & 1) {
		int nl = s.l;
		if (s.l >> i & 1) {
		    nl -= (1<<i);
		} else {
		    nl |= (1<<i);
		}
		if (d[v][s.l] + 1 < d[v][nl]) {
		    d[v][nl] = d[v][s.l] + 1;
		    path[v][nl] = s;
		    Q.push(State(v,nl));
		}
	    }
	}
    }
    if (found) {
	cout << "You can go home in " << d[N-1][1<<(N-1)] << " steps." << endl;
	int v = N-1,l = 1<<(N-1);
	vector<State> vec;
	vec.push_back(State(N-1,(1<<(N-1))));
	while (true) {
	    if (v == 0 && l == light) break;
	    State next = path[v][l];
	    vec.push_back(next);
	    v = next.v; l = next.l;
	}
	reverse(vec.begin(), vec.end());
	int size = vec.size();
	for (int i = 0; i < size-1; i++) {
	    State cs = vec[i],ns = vec[i+1];
	    if (cs.v == ns.v) {
		int j;
		bool on = false, off = false;
		for (j = 0; j < N; j++) {
		    if ((cs.l >> j & 1) && !(ns.l >> j & 1)) {
			off = true;
			break;
		    }
		    if (!(cs.l >> j & 1) && (ns.l >> j & 1)) { 
			on = true;
			break;
		    }
		}
		if (on) {
		    cout << "Switch on room " << j+1 << "." << endl;
		} else if (off) {
		    cout << "Switch off room " << j+1 << "." << endl;
		}
	    } else {
		cout << "Move to room " << ns.v+1 << "." << endl;
	    }
	}
    } else {
	for (int i = 0; i < (1<<N); i++) {
	    if (d[N-1][i] != INF) {
		cout << "You can not switch off all lights." << endl;
		return;
	    }
	}
	cout << "Help me!" << endl;
    }
}
 
int main()
{
    int s, t, k, r;
    while (cin >> N >> M, (N | M)) {
	init();
	for (int i = 0; i < M; i++) {
	    cin >> s >> t; s--; t--;
	    G[s].push_back(t);
	    G[t].push_back(s);
	}
	int x;
	light = 0;
	for (int i = 0; i < N; i++) {
	    cin >> x;
	    if (x == 1) light |= (1<<i);
	}
	for (int i = 0; i < N; i++) {
	    cin >> k;
	    for (int j = 0; j < k; j++) {
		cin >> r; r--;
		swt[i] |= (1<<r);
	    }
	}
	solve();
    }
    return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const ll INF = 1e18;
const int N = 5005;
ll dp[N][N];
int a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, A, B;
    cin >> n >> A >> B;

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

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j < a[i]) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + A);
            }
            else if (j > a[i]) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + B);
            }
        }
        for (int j = 0; j < a[i]; j++)  {
            dp[i + 1][a[i]] = min(dp[i + 1][a[i]], dp[i][j]);
        }
    }

    ll ans = INF;

    for (int i = 0; i <= n; i++) {
        ans = min(ans, dp[n][i]);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 196096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007

int main() {
  int h, n, a;
  int suma = 0;
  string ans;
  cin >> h >> n;
  rep(i, n) {
    cin >> a;
    suma += a;
  }
  if (suma >= h) ans = "Yes";
  else ans = "No";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
L = list(map(int, input().split()))
A = np.zeros(1<<18)
for i in L:
  A[i] += 1
C = (np.fft.irfft(np.fft.rfft(A) * np.fft.rfft(A)) + .5).astype(np.int64)
G = C.cumsum()
count = np.searchsorted(G, N*N-M)
rest = N*N-M - G[count-1]
temp = (C[:count]*np.arange(count, dtype=np.int64)).sum() + count*rest
ans = sum(L)*2*N - temp
print(ans)

Measured memory_bytes: 31664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main() {
    string n ; cin >> n;
    int sum = 0;
    for(int i = 0;i < n.length();i++){
        sum += n[i]-'0';
    }
    if(sum % 9 == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}




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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    int len = s.size() % 2;

    if (s[0] == s[s.size() - 1]) {
        cout << ((len == 0) ? "First" : "Second") << endl;
    } else {
        cout << ((len == 0) ? "Second" : "First") << endl;
    }

    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  for(int i=0; i<m; ++i){
    int x;
    cin >> x;
    n -= x;
    if(n < 0){ cout << -1 << endl; return 0;}
  }
  cout << n << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;


int main(){
    int n;
    int m;
    vector <int> mochi;
    cin>>n;
    for (int i=0; i<n; ++i){
        cin>>m;
        mochi.push_back(m);
    }
    sort(mochi.begin(), mochi.end());
    int res=1;
    for(int i=0; i<n-1; ++i){
        if(mochi[i+1]>mochi[i]){
            ++res;
        }
    }
    cout<<res<<endl;

}

Measured memory_bytes: 256
#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;

char cake[300][300];
int ans[300][300];

int main()
{
  int h,w,k;
  cin >> h >> w >> k;
  vector<int> st(h,0);
  REP(i,h) REP(j,w){
    cin >> cake[i][j];
    if(cake[i][j]=='#') st[i]++;
  }
  int cnt = 0;
  REP(i,h){
    if(st[i]==0) continue;
    int sub_cnt = 0;
    cnt++;
    REP(j,w){
      ans[i][j] = cnt;
      if(cake[i][j]=='#'){
        sub_cnt++;
        if(sub_cnt<st[i]) cnt++;
      }
    }
  }
  if(st[h-1]==0){
    int p = h-1;
    while(ans[p][0]==0) p--;
    FOR(i,p+1,h) REP(j,w) ans[i][j] = ans[p][j];
  }
  REP(i,h){
    if(st[i]==0){
      int p = i;
      while(ans[p][0]==0) p++;
      FOR(i2,i,p) REP(j,w) ans[i2][j] = ans[p][j];
    }
    REP(j,w) cout << ans[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 1152
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n = int(input().strip())
    print(n//500*1000+n%500//5*5)


if __name__ == '__main__':
    main()

Measured memory_bytes: 60012
a = list(map(int, input().split()))
print(min(abs(a[2] - a[1]) + abs(a[1] - a[0]),
          abs(a[1] - a[0]) + abs(a[2] - a[0]),
          abs(a[0] - a[1]) + abs(a[2] - a[0]),
          abs(a[2] - a[0]) + abs(a[1] - a[0]),
          abs(a[0] - a[1]) + abs(a[1] - a[2]),
          abs(a[0] - a[2]) + abs(a[2] - a[1])
))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,m,memo[102][102][3][2];
int f(int x,int y,int t,int u){
    if(memo[x][y][t][u]>-1){
        return memo[x][y][t][u];
    }if(x>n||y>m){
       return memo[x][y][t][u]=0;
    }else if(x==n&&y==m){
        return 1;
    }else{
        if(t==1&&u==1)return memo[x][y][t][u]=f(x,y+1,t,0)%100000;
        //else if(t==1&&u==0&&(x+1)>=n)return memo[x][y][t][u]=f(x,y+1,t,0)%100000;
        else if(t==1&&u==0)return memo[x][y][t][u]=(f(x,y+1,t,0)+f(x+1,y,2,1))%100000;
        else if(t==2&&u==1)return memo[x][y][t][u]=f(x+1,y,t,0)%100000;
        //else if(t==2&&u==0&&(y+1)>=n)return memo[x][y][t][u]=f(x+1,y,t,0)%100000;
        else if(t==2&&u==0)return memo[x][y][t][u]=(f(x+1,y,t,0)+f(x,y+1,1,1))%100000;
        else if(t==0)return memo[x][y][t][u]=(f(x,y+1,1,0)+f(x+1,y,2,0))%100000;
        else return memo[x][y][t][u]=0;
    }
}
int main(){
    while(1){
    cin >> n >> m;
    if(n==0&&m==0)break;
    for(int i=0;i<102;i++)for(int j=0;j<102;j++){for(int k=0;k<3;k++)for(int b=0;b<2;b++)memo[i][j][k][b]=-1;}
    int ans;
    ans = f(1,1,0,0);
    cout << ans << endl;
    }
return 0;
}

Measured memory_bytes: 3332
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

typedef pair<pair<int, int>, pair<int, int>> P;


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

    int H, W;
    cin >> H >> W;

    vvi a(H, vi(W, 0));
    rep(i, H)
    {
        rep(j, W) cin >> a[i][j];
    }

    vector<P> v;

    int dh[2] = { 0, 1 };
    int dw[2] = { 1, 0 };

    rep(h, H)
    {
        rep(w, W)
        {
            if (a[h][w] % 2 == 0) continue;

            rep(i, 2)
            {
                int next_h = h + dh[i];
                int next_w = w + dw[i];

                if (next_h >= 0 && next_h < H && next_w >= 0 && next_w < W)
                {
                    a[h][w]--;
                    a[next_h][next_w]++;
                    v.push_back(make_pair(make_pair(h + 1, w + 1), make_pair(next_h + 1, next_w + 1)));
                    break;
                }
            }

        }
    }

    cout << v.size() << endl;
    for (auto x : v)
    {
        cout << x.first.first << " " << x.first.second << " " << x.second.first << " " << x.second.second << endl;
    }

    return 0;
}

Measured memory_bytes: 6308
import sys

def main():
    input = sys.stdin.readline
    N, A, B, C, D = map(int, input().split())
    S = input().strip()
    S = S[A-1:max(C, D)]

    if '##' in S:
        return 'No'

    if D > C:
        return 'Yes'

    if '...' in S[B-2:D+1]:
        return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    unordered_map<long long int, int> um;
    long long int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        um[a]++;
    }
    vector<long long int> v1, v2;
    for (auto p : um) {
        if (p.second >= 2) v1.push_back(p.first);
        if (p.second >= 4) v2.push_back(p.first);
    }
    sort(v1.begin(), v1.end(), greater<long long int>());
    sort(v2.begin(), v2.end(), greater<long long int>());
    long long int res = 0;
    if (v1.size() >= 2) {
        res = max(res, v1[0] * v1[1]);
    }
    if (v2.size() > 0) {
        res = max(res, v2[0] * v2[0]);
    }
    cout << res << endl;
}




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

int main() {
  string text;
  cin >> text;

  bool match = true;
  while(match && text.size() > 0) {
    if (text.size() >= 5 && text.compare(text.size() - 5, 5, "dream") == 0){
      text.replace(text.size() - 5, 5, "");
    }else if (text.size() >= 7 && text.compare(text.size() - 7, 7, "dreamer") == 0) {
      text.replace(text.size() - 7, 7, "");
    }else if (text.size() >= 5 && text.compare(text.size() - 5, 5, "erase") == 0) {
      text.replace(text.size() - 5, 5, "");
    }else if (text.size() >= 6 && text.compare(text.size() - 6, 6, "eraser") == 0) {
      text.replace(text.size() - 6, 6, "");
    }else{
      match = false;
      break;
    }
  }
  if (match && text.compare("") == 0) {
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}



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

int main(){
  int n;
  vector<int>a(100);
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int c=0;

  for(int i=0;i<n;i++){
    if(a.at(i)%2==0){
      if(a.at(i)%3==0||a.at(i)%5==0){
        c++;
      }
    }
    else{
      c++;
    }
  }

  if(c==n)
  cout << "APPROVED"<<endl;
  else
  cout<<"DENIED"<<endl;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;

    vector<pair<int, int>> V;
    for (int i = 1; i < N + 1; i++) {
        int p;
        cin >> p;
        V.emplace_back(p, i);
    }

    sort(begin(V), end(V));
    reverse(begin(V), end(V));

    multiset<int> S{0, 0, N + 1, N + 1};

    int64_t ans = 0;
    for (auto& v : V) {
        int64_t value = v.first;
        int index = v.second;

        auto it = S.lower_bound(index);

        int r1 = *it++;
        int r2 = *it--;

        it--;

        int l1 = *it--;
        int l2 = *it;

        ans += value * (r2 - r1) * (index - l1);
        ans += value * (l1 - l2) * (r1 - index);

        S.insert(index);
    }

    cout << ans << '\n';
}


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

#define DIR_CNT 4
int next_dir4[DIR_CNT][2] = {
  {-1, 0},
  {0, -1},
  {0, 1},
  {1, 0},
};

void get_int3(char *line, int size, int *a1, int *a2, int *a3) {
  if(!fgets(line, size, stdin)) return;
  sscanf(line, "%d %d %d", a1, a2, a3);
}

#define LEN_MAX 1000
#define BUF_SIZE LEN_MAX+3
#define ROW_MAX (LEN_MAX+2)
#define COL_MAX (LEN_MAX+2)


struct point {
  int x;
  int y;
  int dist;
};

struct point stack[ROW_MAX*COL_MAX];
int start = 0;;
int end = 0;

int is_empty(void) {
  return start == end;
}

void enqueue(struct point p) {
  stack[start++] = p;
}

struct point dequeue(void) {
  return stack[end++];
}

int main(void) {
  char line[BUF_SIZE];
  int row, col, cheeses;
  get_int3(line, BUF_SIZE, &row, &col, &cheeses);

  char map[ROW_MAX][COL_MAX];
  char checked[ROW_MAX][COL_MAX];
  int i, j;
  for(i = 0; i < ROW_MAX; i++) {
    memset(map[i], 'X', COL_MAX);
  }
  struct point ps[10];
  for(i = 1; i <= row; i++) {
    if(!fgets(line, BUF_SIZE, stdin)) return 0;
    for(j = 1; j <= col; j++) {
      map[i][j] = line[j-1];
      if(map[i][j] == 'S') {
        ps[0].x = i; ps[0].y = j; ps[0].dist = 0;
      }
      if(map[i][j] >= '1' && map[i][j] <= '9') {
        int idx = map[i][j] - '0';
        ps[idx].x = i; ps[idx].y = j;
      }
    }
  }

  for(i = 1; i <= cheeses; i++) {
    for(j = 0; j < ROW_MAX; j++) memset(checked[j], 0, COL_MAX);
    start = end = 0; // initialize queue
    enqueue(ps[i-1]);
    checked[ps[i-1].x][ps[i-1].y] = 1;
    while(!is_empty()) {
      struct point p = dequeue();
      if(map[p.x][p.y] == (i+'0')) {
        ps[i].dist = p.dist;
        break;
      }
      int ndist = p.dist + 1;
      for(j = 0; j < DIR_CNT; j++) {
        int next_x = p.x + next_dir4[j][0];
        int next_y = p.y + next_dir4[j][1];
        if(checked[next_x][next_y]) continue;
        if(map[next_x][next_y]=='X') continue;
        struct point np = {next_x, next_y, ndist};
        enqueue(np);
        checked[next_x][next_y] = 1;
      }
    }
  }
  printf("%d\n", ps[cheeses].dist);

  return 0;
}


Measured memory_bytes: 9048
import collections
N = int(input())
S = input()

def mojisu(s1, s2):
    c = collections.Counter(s1)
    cnt = 0
    for c in c.keys():
        if c in s2:
            cnt += 1
    return cnt

m = 0
for i in range(1,N):
    _ = mojisu(S[:i], S[i:])
    if m < _:
        m = _
print(m)

Measured memory_bytes: 3316
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

N = int(input())
p = 10**9 + 7
rlt = 0
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

i = 1
while N - 3*i >= 0:
  rlt += cmb(N - 3*i + i-1, i-1, p)
  rlt %= p
  i += 1
  
print(rlt)

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

using namespace std;

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

	int r;
	cin >> r;

	if(r<1200)
	{
		cout << "ABC" << '\n';
	}
	else if(r<2800)
	{
		cout << "ARC" << '\n';
	}
	else
	{
		cout << "AGC" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
def main():
	n = int(input())
	r = [int(a) for a in input().split()]
	ct = bubbleSort(r, n)
	printlist(r)
	print(ct)

def bubbleSort(a , n):
	cnt = 0
	flag = True
	while flag:
		flag = False
		for i in range(1, n)[::-1]:
			if a[i] < a[i-1]:
				cnt += 1
				a[i], a[i-1] = a[i-1], a[i]
				flag = True
	return cnt


def printlist(a):
	values = map(str, a)
	print(' '.join(values))

main()


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<P> p(n);
    p[0] = P(0, 0);
    P tmp;
    FOR(i, 1, n) {
      cin >> tmp.fi >> tmp.se;
      int tmpx = p[tmp.fi].fi, tmpy = p[tmp.fi].se;
      switch(tmp.se) {
      case 0:
        p[i] = P(tmpx-1, tmpy);
        break;
      case 1:
        p[i] = P(tmpx, tmpy-1);
        break;
      case 2:
        p[i] = P(tmpx+1, tmpy);
        break;
      default:
        p[i] = P(tmpx, tmpy+1);
        break;
      }
    }

    int xmi = 0, xma = 0, ymi = 0, yma = 0;
    REP(i, n) {
      xmi = min(xmi, p[i].fi);
      xma = max(xma, p[i].fi);
      ymi = min(ymi, p[i].se);
      yma = max(yma, p[i].se);
    }

    cout << xma - xmi + 1 << " " << yma - ymi + 1 << endl;
  }
}



Measured memory_bytes: 3072
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()
A, B = MAP()

flag = 0
for i in range(A, B+1):
    if i % K == 0:
        flag = 1

if flag == 1:
    print('OK')
else:
    print('NG')


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    if(n%1000==0){
    	cout<<"0";
	}
	else{
		long long int k=n/1000;
		k++;
		cout<<(1000*k)-n;
	}
	return 0;
}

Measured memory_bytes: 3612
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())

count = 0
for i in range(count_500+1):
    for j in range(count_100+1):
        for k in range(count_50+1):
            if target == 500 * i + 100 * j + 50 * k:
                count += 1
print(count)

Measured memory_bytes: 3060
use std::io::*;
use std::str::*;

fn read_usize(s: &mut StdinLock) -> usize {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as usize + a * 10)
}

fn main(){
    let s = stdin();
    let mut s = s.lock();

    let n: usize = read_usize(&mut s);
    let m: usize = read_usize(&mut s);
    let mut from1 = vec![false; n + 1];
    let mut fromn = vec![false; n + 1];
    for _ in 0..m {
        let a: usize = read_usize(&mut s);
        let b: usize = read_usize(&mut s);
        from1[b] |= a == 1;
        from1[a] |= b == 1;
        fromn[b] |= a == n;
        fromn[a] |= b == n;
    }
    let flg = from1.iter().zip(fromn.iter()).fold(false, |acc, (&a, &b)| acc || a && b);
    println!("{}", if flg { "POSSIBLE" } else { "IMPOSSIBLE" });
}


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

int main(){
  char s[5]; int t[4];
  std::cin >> s;
  for( int i=0; i < 4; ++i ){ t[i] = static_cast<int>(s[i]) - '0'; }
  bool s1 = ( ( t[0]*10 + t[1] ) < 1 ) || ( 12 < ( t[0]*10 + t[1] ) );
  bool s2 = ( ( t[2]*10 + t[3] ) < 1 ) || ( 12 < ( t[2]*10 + t[3] ) );
  if (s1){
    if (s2){
      std::cout << "NA" << std::endl;
    }
    else{
      std::cout << "YYMM" << std::endl;
    }
  }
  else{
    if (s2){
      std::cout << "MMYY" << std::endl;
    }
    else{
      std::cout << "AMBIGUOUS" << std::endl;
    }
  }
  return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int> > lang(m), people(n);
    vector<int> flag(n, 0), flag2(m, 0);
    flag[0] = 1;
    REP(i, 0, n){
        int k; cin >> k;
        REP(l, 0, k){
            int a; cin >> a;
            a--;
            lang[a].pb(i);
            people[i].pb(a);
        }
    }
    queue<Pii> q;
    q.push(Pii(0, 0));
    while(!q.empty()){
        Pii a = q.front();
        q.pop();
        int num = a.first;
        if(a.second == 0){
            REP(i, 0, people[num].size()){
                int next = people[num][i];
                if(flag2[next] == 0){
                    flag2[next] = 1;
                    q.push(Pii(next, 1));
                }
            }
        }else{
            REP(i, 0, lang[num].size()){
                int next = lang[num][i];
                if(flag[next] == 0){
                    flag[next] = 1;
                    q.push(Pii(next, 0));
                }
            }
        }
    }
    REP(i, 0, n){
        if(flag[i] == 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main() {
  
  int N, K;
  cin >> N >> K;
  int l[N];
  for(int i = 0; i < N; i++) {
    cin >> l[i];
  }
  
  sort(l, l + N);
  
  int result = 0;
  for(int i = 0; i < K; i++) {
    result += l[N - 1 - i];
  }
  
  cout << result << endl;
  
  return 0;
}

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

int main() {
  int a;
  cin >> a;
  if(a==22)
    cout << "Christmas Eve Eve Eve"<<endl;
  else if(a==23)
     cout << "Christmas Eve Eve"<<endl;
  else if(a==24)
    cout << "Christmas Eve"<<endl;
  else
     cout << "Christmas"<<endl;
    
 
}




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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

bool box[200000];
int boxn[200000];

int main(){
	for (int i = 0; i < 200000; i++){
		box[i]=false;
		boxn[i]=1;
	}
	box[0]=true;

	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		boxn[x]--;
		boxn[y]++;
		if(box[x])box[y]=true;
		if(boxn[x]==0)box[x]=false;
	}

	int ans=0;
	for (int i = 0; i < n; i++){
		if(box[i]){ans++;}
	}

	cout<<ans<<endl;


	return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;
    vector<llint> a(n);
    for(int in=0;in<n;in++) {
        cin >> a[in];
    }
    
    llint m = 1000, s = 0;
    for(int in=0;in<n-1;in++) {
        if(a[in]<a[in+1]) s = m / a[in];
        m += (a[in+1] - a[in])*s;
        s = 0;
    }

    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <iomanip>

using namespace std;

typedef long long ll;

array<array<ll, 51>, 51> comb_table;

ll comb(int a, int b) 
{
    if (comb_table[a][b] == -1)
    {
        if(b == 0 || b == a) 
        {
            comb_table[a][b] = 1;
        }
        else
        {
            comb_table[a][b] = comb(a - 1, b) + comb(a - 1, b - 1);
        }
    }
    return comb_table[a][b];
}

int main()
{
    for (auto &v : comb_table) fill(v.begin(), v.end(), -1);

    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> vs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vs[i];
    }
    sort(vs.begin(), vs.end(), greater<ll>());

    double ans = 0;
    for (int i = 0; i < a; i++) {
        ans += vs[i];
    }
    ans /= a;
    cout << fixed << setprecision(7) << ans << endl;
    
    int num = 0;
    int min_start = n - 1;
    int min_end = 0;
    for (int i = 0; i < n; i++)
    {
        if (vs[i] == vs[a - 1])
        {
            num++;
            min_start = min(min_start, i);
            min_end = max(min_end, i);
        }
    }
    ll c = 0;
    const int lim = (min_start == 0 ? min(min_end, b - 1) : a - 1);
    for (int i = a - 1; i <= lim; i++)
    {
        const int rest = i - min_start + 1;
        c += comb(num, rest);
    }
    cout << c << endl;
}

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

using namespace std;

using Graph = vector<vector<int>>;

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int duration = (60 * H2 + M2) - (60 * H1 + M1) - K;
    if (duration < 0) {
        cout << 0 << endl;
        return 0;
    } else {
        cout << duration << endl;
        return 0;
    }
}

Measured memory_bytes: 3632
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut output = Vec::with_capacity(10);
    for c in input.chars() {
        if c == '0' {
            output.push('0');
        } else if c == '1' {
            output.push('1');
        } else if c == 'B' && output.len() > 0 {
            output.pop();
        }
    }
    for c in output {
        print!("{}", c);
    }
    println!("");
}


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

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

int main(){
  int N,ans,tmp;
  cin>>N;
  rep(i,N){
    cin>>tmp;
    ans+=tmp-1;
  }
  cout<<ans<<endl;
}

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

int a, b, c;

void read(){
    cin >> a >> b >> c;
}

void solv(){
    cout << b + min(a + b + 1, c);
}

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

    read();
    solv();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,ac=0,wa=0,tle=0,re=0;
    char s[100005][5];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }

    for(int i=0;i<n;i++){
        if(s[i][0]=='A'){ac++;}
        else if(s[i][0]=='W'){wa++;}
        else if(s[i][0]=='T'){tle++;}
        else {re++;}
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
    

}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[3];
signed main(){
	rep(i,3)scanf("%lld", &a[i]);
	sort(a, a+3);
	printf("%lld\n", a[2]-a[0]);
	return 0;
}






Measured memory_bytes: 256
N,X,M = map(int,input().split())
A = set()
ans = []
a = X
flg = 0
while True:
    k = len(A)
    A.add(a)
    if len(A) == k:
        break
    if a == 0:
        flg =1
        ans.append(a)
        break
    ans.append(a)
    a = a**2%M

g = ans.index(a)
ans_first = ans[:g]
ans = ans[g:]
ans_cum = [ans[0]]
for i in range(len(ans)-1):
    ans_cum.append(ans_cum[i]+ans[i+1])
check = len(ans_cum)
N -= len(ans_first)
if N < 0:
    final = ans_first[:N]
    print(sum(final))
    exit()
loop = N//check
spare = N%check
res = 0
if flg == 0:
    if spare > 0:
        res=loop*ans_cum[-1]+ ans_cum[spare-1]+sum(ans_first)
    else:
        res=loop*ans_cum[-1]+sum(ans_first)
    print(res)
else:
    print(sum(ans_first))

Measured memory_bytes: 79948
import java.io.*;
import java.util.*;
public class Main {

    public static void main(String args[]) throws Exception {
        int minCnt = Integer.MAX_VALUE;

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long target = sc.nextLong();
        
        int[] numArr = new int[n];
        int[] scores = new int[n];
        for(int i = 0; i < n; i++) {
            numArr[i] = sc.nextInt();
            scores[i] = sc.nextInt();
        }
        for(int i = 0; i < Math.pow(2, n); i++) {
            long sum = 0;
            int cnt = 0;
            for(int j = 0; j < n; j++) {
                if((i >> j & 1) == 1) {
                    sum += scores[j];
                    sum += numArr[j] * (j + 1) * 100;
                    cnt += numArr[j];
                }
            }
            if(sum < target) {
                int j = n - 1;
                for(; j >=0; j--)
                    if((i >> j & 1) == 0)
                        break;

                for(int k = 0; k < numArr[j]; k++) {
                    sum += (j + 1) * 100;
                    cnt++;
                    if(sum >= target)
                        break;
                }
            }
            if(sum >= target) {
                minCnt = Math.min(minCnt, cnt);
            }
        }
        System.out.println(minCnt);
    }

}

Measured memory_bytes: 23380
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


n = ni()
a = []
for _ in range(n):
    a.append(ni())
    
res = 0
ans = 0
for ai in a:
    if ai == 0:
        ans += res//2
        res = 0
    else:
        res += ai
        
ans += res//2
    
print(ans)

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

using namespace std;

void maxi(int &a, int b) {
	a = max(a,b);
}


int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if ((b-a) % 2 == 0) {
		cout << (b-a)/2 << "\n";	
	} else {
		long long val1 = a-1 + (b-1-a)/2 + 1;
		long long val2 = n-b + (b-a-1)/2 + 1;
		cout << min(val1, val2) << "\n";
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 10000005
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
map<int,int> mp;
main(){
	IO;
	ll k,a,b;
	cin>>k>>a>>b; 
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    map<string,ll> dict;
    rep(i,n){
        string s,t; cin>>s>>t;
        if(s=="insert") dict[t]++;
        else{
            if(dict[t]>0) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }

  return 0;
}


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

int main()
{
    std::map<std::string, int> words{};
    int n;
    std::cin >> n;
    for (auto i = 0; i < n; ++i)
    {
        std::string s;
        std::cin >> s;
        ++words[s];
    }
    int m;
    std::cin >> m;
    for (auto i = 0; i < m; ++i)
    {
        std::string s;
        std::cin >> s;
        --words[s];
    }
    using elm_t = std::pair<std::string, int>;
    auto max_elm = std::max_element(words.begin(), words.end(), [](const elm_t &a, const elm_t &b) { return a.second < b.second; });
    std::cout << std::max(max_elm->second, 0) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);

    bool ok = true;

    if(k*d>x)ok=false;
    if(log10(k)+log10(d)>17)ok=false;


    if (ok)
    {
        ll ans = x;
        rep(i, k) ans -= d;
        cout << ans << endl;
        return 0;
    }

    if ((k - (x / d)) % 2 == 0)
    {
        cout << x - (x / d) * d << endl;
    }
    else
    {
        cout << abs(x - ((x / d) + 1) * d) << endl;
    }
}

Measured memory_bytes: 3820
from collections import Counter

n, *v = map(int, open(0).read().split())
vo = Counter(v[::2])
ve = Counter(v[1::2])
vo_mc = vo.most_common()[0]
ve_mc = ve.most_common()[0]
if vo_mc[0] == ve_mc[0]:
    ans = n
    if ve_mc[1] != n//2:
        ans = min(n//2 - vo_mc[1] + n//2 - ve.most_common()[1][1], ans)
    if vo_mc[1] != n//2:
        ans = min(n//2 - vo.most_common()[1][1] + n//2 - ve_mc[1], ans)
    ans = min(n//2 - vo_mc[1] + n//2, ans)
else:
    ans = n//2 - vo_mc[1] + n//2 - ve_mc[1]
print(ans)

Measured memory_bytes: 22956