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

#define io              ios_base::sync_with_stdio(false),cin.tie(NULL);
#define ll              long long
#define vi              vector<int>
#define pii             pair<int, int>
#define vii             vector<pii>
#define mii             map<int, int>

#define pb              push_back
#define ff              first
#define ss              second
#define sz              size()
#define all(a)          a.begin(), a.end()
#define mem(a, b)       memset(a, b, sizeof(a))
#define mod             1000000007
#define inf             1e9
#define c               1.00

int main()
{
    ll n,k;
    double ans = 0.0;
    cin >> n >> k;
    for(ll i = 1; i <= n; i++)
    {
        ll x = i;
        int steps = 0;
        while(x < k)
        {
            steps++;
            x *= 2;
        }
        ans += pow((1.00/2.00),steps);
    }
    ans /= (n*c);
    printf("%0.12f\n",ans);
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int h, a; cin>>h>>a;
    int ans = 0;
    while (h > 0) {
        h -= a;
        ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,i2,i3,i4;
	int t;
	
	while(scanf("%d", &n) != EOF){
		t = 0;
		if (n > 36);
		
		for (i=0; i < 10; i++){
			for (i2=0; i2 < 10; i2++){
				for (i3=0; i3 < 10; i3++){
					for (i4=0; i4 < 10; i4++){
						if (i+i2+i3+i4 == n)t++;
					}
				}
			}
		}
		
		printf("%d\n", t);
	}
	return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
    string ss; cin>>ss;
    map<char,int> mp;
    int k=0;
    for(int i=0;i<ss.size();i++){
        mp[ss[i]]++;
        if(mp[ss[i]]==2) k++;
    }
    if(k==2){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }

}


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

NO = "IMPOSSIBLE"  # type: str


def solve(A: int, B: int):
    if (A + B) % 2 == 0:
        print((A + B) // 2)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
string s;
int main(){
	cin>>s;
	while(s.size()){
		if(s.size()<5){cout<<"5NO\n";return 0;}
		if(s.substr(s.size()-5,5)=="dream"||s.substr(s.size()-5,5)=="erase")s.erase(s.end()-5,s.end());
		else if(s.size()<6){cout<<"6NO\n";return 0;}
		else if(s.substr(s.size()-6,6)=="eraser")s.erase(s.end()-6,s.end());
		else if(s.size()<7){cout<<"7NO\n";return 0;}
		else if(s.substr(s.size()-7,7)=="dreamer")s.erase(s.end()-7,s.end());
		else {cout<<"NO\n";return 0;}
	}
	cout<<"YES\n"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N,M;
    cin >> N >> M;
    cout << N * (N-1) / 2 + M * (M-1) / 2 << endl;
}
    


Measured memory_bytes: 256
#include <iostream>

int main()
{
  long int x, a, b;

  std::cin >> x >> a >> b;

  if (b-a <= 0) {
    std::cout << "delicious" << std::endl;
  } else if (b-a <= x) {
    std::cout << "safe" << std::endl;
  } else {
    std::cout << "dangerous" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin >> h >> w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
      cin >> s[i];
    }
    vector<vector<ll>> dp(h,vector<ll>(w,INF));
    dp[0][0]=(s[0][0]=='#');
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i<h-1){
          if(s[i][j]=='.'&&s[i+1][j]=='#'){
            chmin(dp[i+1][j],dp[i][j]+1);
          }
          else{
            chmin(dp[i+1][j],dp[i][j]);
          }
        }
        if(j<w-1){
          if(s[i][j]=='.'&&s[i][j+1]=='#'){
            chmin(dp[i][j+1],dp[i][j]+1);
          }
          else{
            chmin(dp[i][j+1],dp[i][j]);
          }
        }
      }
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 384
def bb
    n = gets.chomp.to_i

    i = 1
    o = [n]
    for i in 1..1000000
        no = o[i-1]%2 == 0 ? o[i-1]/2 : 3*o[i-1]+1
        break if o.index(no)
        o.push(no)
    end

    puts i+1
end

bb


Measured memory_bytes: 1788
# A[i]が採用されるとき、A[i-1]も採用されるという単調性があるので二分探索で解く
N, M, V, P = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)


def isOK(i):  # i番目が採用されるかどうかを確かめる
    # 上位P-1問には上限いっぱいM票ずつ投票可能
    need = M * (P-1)
    # 今見ているi問目には上限いっぱいM票入れるのが妥当
    need += M
    # 今見ているi問目よりもスコアの小さいN-i-1問は上限いっぱいM票入れる
    # N=10, i=7の場合は後ろは残り2問
    need += M * (N-i-1)
    ai = A[i]+M  # 基準値
    s = 0
    for j in range(P-1, i):
        d = ai - A[j]
        if d < 0:
            return False
        s += d
    
    if need + s >= M*V:
        return True
    else:
        return False


left = -1
right = N
while right - left > 1:
    mid = (right+left)//2
    if isOK(mid):  # 中央値が満たすなら下界をあげる
        left = mid
    else:  # 中央値が満たさないなら上界を下げる
        right = mid

print(left + 1)


Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()
using namespace std;

ll N, a[400], dp[400][400], cum[400];

ll fn (int i, int j) {
	if (dp[i][j] != -1) return dp[i][j];
	dp[i][j] = 1e18;
	ll x, y;
	for (int k=i; k<j; ++k) {
		x = cum[k];
		if (i) x -= cum[i-1];
		y = cum[j];
		y -= cum[k];
		dp[i][j] = min(x + y + fn(i, k) + fn(k + 1, j), dp[i][j]);
	}
	return dp[i][j];
}

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> N;
	memset(dp, -1, sizeof(dp));
	ll prev= 0;
	for (int i=0; i<N; ++i) {
		cin >> a[i];
		dp[i][i] = 0;
		prev += a[i];
		cum[i] = prev;
	}
	cout << fn(0, N - 1) << '\n';
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> list(N, vector<pair<int, int>>());
  for (int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    list[a].push_back({b, c % 2});
    list[b].push_back({a, c % 2});
  }
  
  vector<int> ans(N, -1);
  queue<int> q;
  ans[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front(); q.pop();
    for (int i = 0; i < list[v].size(); i++) {
      int u = list[v][i].first;
      if (ans[u] != -1) continue;
      ans[u] = ans[v] ^ list[v][i].second;
      q.push(u);
    }
  }
  for (auto a : ans) {
    cout << a << endl;
  }
  return 0;
}


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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________


int32_t main()
{ 
  io;
 
  
  int n,k;
  cin>>n>>k;

  bool ugly[10];

  for(int i=0;i<10;i++)
   ugly[i]=true;

  for(int i=0;i<k;i++)
  {
   int x;
   cin>>x;
   ugly[x]=false;
  }
  int cur;
  for(int i=n;i<(int)1e7;i++)
  {
    bool ok=true;
    cur=i;

    while(cur)
    {
      ok&=ugly[cur%10];
      cur/=10;
    }

    if(ok) 
    { 
      cur=i;
      break;
    }
  }

  cout<<cur;

 return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

int N, M;
int req[MAXN];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    memset(req, 0x3f, sizeof req);

    cin >> N >> M;

    while(M--){
        int a, b;
        cin >> a >> b;

        req[a] = min(req[a], b);
    }

    int ans = 0;
    for(int a = 1, b = 1e9; a <= N; a++){
        if(b == a){
            ans++;
            b = 1e9;
        }

        b = min(b, req[a]);
    }

    cout << ans;
}


Measured memory_bytes: 640
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(1, 100):
            if num % i == 0:
                divisor_list.append(i)
                divisor_list.append(num//i)
        for i in range(2, num // 100 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return sorted(divisor_list)


n,m = ai()
d = make_divisor_list(m)
d = d[::-1]
for k in d:
    if m/k == m//k and m//k >= n:
        print(k)
        exit()
print(1)

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, K;

	cin >> N >> K;
	set<ll> A;
	rep(i,N){
		int a;
		cin >> a;
		A.insert(a);
	}
	//sort( all(A) );
	
	ll mx = *A.rbegin();
	if( mx < K ){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int mn = *A.begin(), bf = -1;
//	while( mn != b ){
//		int nx = mn;
//		reps(k,1,mn) rep(i,A.size()){
//			if( A[i] % mn == k ){
//				nx = k;
//				break;
//			}
//		}
//		rep(i,min( A.size(), mn*k)){
//			A.push_back( A[i] % mn );
//		}
//		sort( all(A) );
//		if(  )
//	}
	auto nx = A;
	bool ans = false;
	while( mn != bf ){
		int b = -1;
		for(auto t: A){
			if( t == K ){
				ans = true;
				break;
			}
			if( b >= 0 ){
				nx.insert( abs(t-b) );
			}
			b = t;
		}
		if( ans ) break;
		A = nx;
		bf = mn;
		mn = *A.begin();
	}
//	cout << A.size() << endl;
//	for(auto t: A) cout << t << " "; cout << endl;
	if( A.count(1) ) ans = true;

//	bool f[1000005]={};
//	for(auto t: A){
//		if( t > sqrt(mx-K) ) break;
//		if( f[t] ) continue;
//		for(ll i=t; i<=sqrt(mx-K); i+=t){
//			f[i] = true;
//		}
//	}
//	reps(i,2,sqrt(mx-K)+1){
//		if( f[i] &&  )
//		ans |= f[mx-K];
//	}
//
//	reps(i,1,mx-K) if( A.count(i) && !ans ) for(auto t: A) if( t > K ){
//		if( (t-K) % i == 0 ){
//			ans = true;
//			break;
//		}
//	}
	if( !ans ) for(auto t: A) if( t > K ){
		ll d = t-K;
		if( d % mn == 0 ) ans = true;
		if( A.count(d) ) ans = true;
		//reps( i, 2, sqrt(d) ){
		//	if( (t-K) % i == 0 && A.count(i) ){
		//		ans = true;
		//		break;
		//	}
		//}
	}

	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE" ) << endl;

	return 0;
}


Measured memory_bytes: 12288
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

int add(int a, int b, int m = MOD){
	return a + b < m? a + b : a + b - m;
}

int mul(ll a, ll b, int m = MOD){
	return (a * b) % m;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 200000+5;

int n;
vi G[N];
int f[N];
int fi[N];
int in[N];
int out[N];
int subtree[N];

void init(){
	f[0] = 1;
	for(int i=1; i<N; i++) f[i] = mul(i,f[i-1]);
	fi[N-1] = pow_mod(f[N-1],MOD-2);
	for(int i=N-2; i>=0; i--){
		fi[i] = mul(i+1,fi[i+1]);
	}
}

int C(int n, int k){
	return mul(f[n],mul(fi[n-k],fi[k]));
}

void DFS(int u, int id, int p = 0){
	if(id == 0){
		subtree[u] = 1;
		in[u] = 1;
		for(int v : G[u]){
			if(v == p) continue;
			DFS(v,id,u);
			subtree[u] += subtree[v];
			in[u] = mul(in[u],mul(C(subtree[u]-1,subtree[v]),in[v]));
		}
	}
	else{
		int totalout = out[u];
		int sizesout = n - subtree[u];
		for(int v : G[u]){
			if(v == p) continue;
			sizesout += subtree[v];
			totalout = mul(totalout,mul(C(sizesout, subtree[v]),in[v]));
		}
		for(int v : G[u]){
			if(v == p) continue;
			out[v] = mul(totalout, pow_mod(mul(C(sizesout,subtree[v]),in[v]),MOD-2));
		}
		for(int v : G[u]){
			if(v == p) continue;
			DFS(v,id,u);
		}
	}
}

int main(){
	init();
	ri(n);
	for(int i=1; i<n; i++){
		int u, v;
		ri2(u,v);
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	DFS(1,0);
	out[1] = 1;
	DFS(1,1);
	for(int i=1; i<=n; i++){
		printf("%d\n",mul(C(n-1,subtree[i]-1),mul(in[i],out[i])));
	}
	return 0;
}


Measured memory_bytes: 17908
dic = ["0","1","2","3","4","5","6","7","8","9"]

A,B = map(int,input().split())
S = list(input())

ok = True
for i in range(A):
    if not(S[i] in dic):
        ok=False

if S[A]!="-":
    ok=False

for i in range(A+1,A+B+1,1):
    if not(S[i] in dic):
        ok =False

print("Yes" if ok else"No")


Measured memory_bytes: 61920
#include <stdio.h>

int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a%b;
	f = 1.0*a / b;
	printf("%d %d %f", d, r, f);

	return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int cnt  = 0;
int shell(int A[],int n,int g){
	int v,j;
	for(int i = g;i<n;i++){
		 v = A[i];
		 j = i-g;
		while(j>= 0 && A[j] >v ){
			A[j+g] = A[j];
			j = j-g;
			cnt++;
			A[j+g] = v;
		}
	}
	return 0;
}
int main(){
	int n,m = 0;
	cin>>n;
	int A[n];
	int g[13] = {1,4,13,40,121,364,1093,3280,9841,29524,88573,265720,797161};
	for(int  i = 12;i>=0;i--){
		if(n/g[i] >=1){
			m = i;
			break;

		}
		
	}
	for(int i = 0;i<n;i++){
		cin>>A[i];
	}
	
	for(int i = 0;i<=m;i++){
		shell(A,n,g[m-i]);
	}
	cout<<m+1<<endl;
	for(int i = m;i>0;i--){
		cout<<g[i]<<" ";
	}
	cout<<g[0]<<endl;

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


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  int mi  = 10000;
  int sum = 0;
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    if ( a%2 ) mi = min(mi, a);
    sum += a;
  }

  if ( sum % 2 ) sum -= mi;
  if ( sum == 0 ) cout << 0 << endl;
  else cout << sum/2 << endl;  
  
  return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>
typedef long long ll;
int main() {
	int n;
	scanf("%d", &n);
	ll ans[10000] = {0};
	for (int x = 1; x <= n; x++) {
		for (int y = 1; y <= n; y++) {
			for (int z = 1; z <= n; z++) {
				int t = x * x + y * y + z * z + x * y + y * z + z * x;
				if (t <= n) {
					ans[t - 1]++;
				} else {
					break;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%lld\n", ans[i]);
	}
	return 0;
}

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

A = 'Christmas'
B = 'Eve'
if N == 25:
    print(A)
elif N == 24:
    print(A+' '+B)
elif N == 23:
    print(A+' '+B+' '+B)
elif N == 22:
    print(A+' '+B+' '+B+' '+B)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//アルファベットを０〜２５に対応させる
int main(){
  string S;
  cin >> S;
  vector<int> num(101);//num[i]はiがいくつあるか
  vector<int> d(S.size());//文字列の文字を数値に変換したものを要素とする列

  for(int i = 0;i<S.size();i++){
    d[i] = (int)(S[i]-97);
  }
 
  for(int i = 0;i<S.size();i++){
    num[d[i]]++;
  }
  char ans;
  bool flag = false;
  for(int i = 0;i<=25;i++){
    if(num[i] == 0){
      ans = char(i + 97);
      flag = true;
      break;
    }
  }
  if(flag) cout << ans << endl;
  else cout << "None" <<endl;
}

Measured memory_bytes: 896
n = int(input())
t_point = h_point = 0
for i in range(n):
    t_card,h_card = [x for x in input().split( )]
    if t_card > h_card:
        t_point += 3
    elif t_card < h_card:
        h_point += 3
    else:
        t_point += 1
        h_point += 1
print(t_point,h_point)




Measured memory_bytes: 5604
//n >= 2, so, n/2 < n
#include <iostream>
#include <algorithm>
using namespace std;

int n;
int t[10000];			//t[i] = pos i's(1 <= i <= N-1) cutting time
int dp[2][2][10001];	//dp[length (0:now -> 1:new)][cutCount(mod 2)][a's treat length]

int main() {
	int i, j, k;
	
	cin >> n;
	t[0] = 0;
	for (i = 1; i < n; i++) cin >> t[i];
	
	for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) for (k = 0; k < n; k++) dp[i][j][k] = 1145141919;
	
	dp[0][0][0] = 0;
	//you may choose cut point equal or more than i.
	for (i = 0; i < n; i++) {
		for (j = 0; j < 2; j++) {
			for (k = 0; k < n; k++) {
				//cut
				dp[1][!j][k + j] = min(dp[1][!j][k + j], dp[0][j][k] + t[i]);
				//no cut
				dp[1][j][k + !j] = min(dp[1][j][k + !j], dp[0][j][k]);
			}
		}
		for (j = 0; j < 2; j++) for (k = 0; k < n; k++) dp[0][j][k] = dp[1][j][k];
		for (j = 0; j < 2; j++) for (k = 0; k < n; k++) dp[1][j][k] = 1145141919;
	}
	
	int ans = min(dp[0][0][n/2], dp[0][1][n/2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1360
import java.util.Scanner;

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

		if ((A + B) % 2 == 0) {
			System.out.println((A + B) / 2);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, Y;
    cin >> n >> Y;
    Y /= 1000;
    int ansx = -1;
    int ansy = -1;
    int ansz = -1;
    rep(x, n + 1) {
        rep(y, n - x + 1) {
            if(9 * x + 4 * y == Y - n) {
                ansx = x;
                ansy = y;
                break;
            }
        }
    }
    if(n - ansx - ansy >= 0 && ansx != -1 && ansy != -1) {
        ansz = n - ansx - ansy;
    }
    cout << ansx << " " << ansy << " " << ansz << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<cstdlib>
#include<iostream>
using namespace std;

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

node *NIL;

void init(){
    NIL = (node*)malloc(sizeof(node));
    NIL->prev = NIL;
    NIL->next = NIL;
}

void ins(int x){
    node *nd = (node*)malloc(sizeof(node));
    nd->key = x;
    nd->next = NIL->next;
    NIL->next->prev = nd;
    NIL->next = nd;
    nd->prev = NIL;
}


void del(int x){
    node *nd = NIL->next;
    while (nd->key != x && nd != NIL)
    {
        nd = nd->next;
    }
    if(nd == NIL) return;
    nd->next->prev = nd->prev;
    nd->prev->next = nd->next; 
}

void delF(){
    NIL->next = NIL->next->next;
    NIL->next->prev = NIL;
}

void delL(){
    NIL->prev = NIL->prev->prev;
    NIL->prev->next = NIL;
}
int main(){
    int n; scanf("%d", &n);
    init();
    char str[12];
    str[6] = 'x';
    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%s", str);
        
        if (str[0] == 'i')
        {
            scanf("%d", &x);
            ins(x);
        }
        else if (str[6] == 'F')
        {
            delF();
        }
        else if (str[6] == 'L')
        {
            delL();
        }
        else
        {
            scanf("%d", &x);
            del(x);
        }
        str[6] = 'x';
    }

    node *nd = (NIL -> next);
    if(nd == NIL)return 0;
    while (nd->next != NIL)
    {
        cout << nd->key << " ";
        nd = nd->next;
    }
    cout << nd->key << endl;
}


Measured memory_bytes: 37524
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int g[2020][2020];
int ans[2020];

int main(){
    
    // 1. 入力情報.
    int N, X, Y;
    scanf("%d %d %d", &N, &X, &Y);
    
    // 2. 最短距離を保存(頂点 i -> 頂点 j).
    repx(i, 1, N + 1){
        repx(j, i + 1, N + 1){
            g[i][j] = min(j - i, abs(X - i) + abs(Y - j) + 1);
        }
    }
    
    // 3. 最短距離 k を 集計.
    repx(i, 1, N + 1) repx(j, i + 1, N + 1) ans[g[i][j]]++;
    
    // 4. 出力.
    repx(k, 1, N) printf("%d\n", ans[k]);
    return 0;
    
}

Measured memory_bytes: 15360
#include<iostream>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;
#include <map>

using ll = long long;
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    int k, n; n=3;
    int count=0;
    cin >> k;
    for(int f=1; f<=k; f++){
        for(int g=1; g<=k; g++){
            for(int h=1; h<=k; h++){
                int c_s=f;
                c_s = gcd(c_s, g);
                c_s = gcd(c_s, h);
                count+= c_s;
            }
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>



int main()
{

	int N, A;
	scanf("%d%d", &N, &A);

	printf("%d\n", N * N - A);


	return 0;
}

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

int main() {
    char C;
    cin >> C;
    char Cn = ' ';

    //判定用文字列
    string S = "abcdefghijklmnopqrstuwvxyz";

    for(int i = 0; i < 26; ++i){
        if(S[i] == C) Cn = S[i+1];
    }
    cout << Cn << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e17
int va=10e8+7;
ll int dp[1000004]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
  //  cin>>t;
    while(t--){
        int n;
        cin>>n;
        ll int arr[n];
        for(int i=0;i<n;i++)
            cin>>arr[i];
        sort(arr,arr+n);
        ll int ans{0};
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                ll int sum=arr[i]+arr[j];
                for(int k=j+1;k<n;k++){
                    if(arr[k]<sum&&arr[i]!=arr[j]&&arr[i]!=arr[k]&&arr[j]!=arr[k]) ans++;
                }
            }
        }
        cout<<ans<<endl;
        
    }
 return 0;
}

Measured memory_bytes: 3612
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = ns().strip()
a = [int(_) for _ in s]
# print(a)
for i in range(8):
    t = a[0]
    for j in range(3):
        if i>>j&1:
            t += a[j+1]
        else:
            t -= a[j+1]
    if t == 7:
        print("{}{}{}{}{}{}{}=7".format(
            a[0], "+" if i>>0&1 else "-",
            a[1], "+" if i >> 1 & 1 else "-",
            a[2], "+" if i >> 2 & 1 else "-",
            a[3],
        ))
        break


Measured memory_bytes: 3444
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();

		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		MathContext mc = new MathContext(25, RoundingMode.HALF_EVEN);

		// BigDecimal[] p = new BigDecimal[n];
		// for (int i = 0; i < n; i++)
		// p[i] = (new BigDecimal(sc.nextInt())).divide(BigDecimal.valueOf(100),
		// mc);
		int[] p = new int[n];
		for (int i = 0; i < n; i++)
			p[i] = sc.nextInt();

		long[] cnt = new long[1 << n];
		for (int i = 1; i < (1 << n); i++) {
			long l = 1;
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					l = lcm(l, a[j]);
					if (l == 0)
						break;
				}
			}
			if (l != 0)
				cnt[i] += m / l;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < (1 << n); j++) {
				if (((j >> i) & 1) == 1) {
					cnt[j] -= cnt[j ^ (1 << i)];
				}
			}
		}
		double ans = 0;
		// BigDecimal ans = new BigDecimal(0);
		for (int i = 0; i < (1 << n); i++) {
			// BigDecimal pro = BigDecimal.valueOf(Math.abs(cnt[i]));
			double pro = Math.abs(cnt[i]);
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					// pro = pro.multiply(p[j], mc);
					pro *= p[j] / 100.0;
				} else {
					pro *= (100 - p[j]) / 100.0;
					// pro = pro.multiply(BigDecimal.ONE.subtract(p[j], mc),
					// mc);
				}
			}
			ans += pro;
//			ans = ans.add(pro, mc);

		}
		System.out.printf("%.10f\n", ans);
	}

	long gcd(long a, long b) {
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}

	long lcm(long a, long b) {
		a /= gcd(a, b);
		if (a * b / b != a)
			return 0;
		else
			return a * b;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 35940
S: str = input()
n = len(S)

if not S == S[::-1]:
    print('No')
    exit()

end = (n-1)//2
SS = S[:end]

if not SS == SS[::-1]:
    print('No')
    exit()

start = (n+3)//2 - 1
SSS = S[start:n]

if not SSS == SSS[::-1]:
    print('No')
    exit()

print('Yes')


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

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x)
{
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

P dequeue()
{
  P x = Q[head];
  head = (head+1)%LEN;
  return x;
}

int min(int a,int b){return a<b?a:b;}


int main(void)
{
  int elaps =0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++)
  {
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head =1;
  tail =n+1;

  while(head!=tail)
  {
    u = dequeue();
    c = min(q,u.t);
    u.t-=c;
    elaps +=c;
    if(u.t>0)enqueue(u);
    else{printf("%s %d\n",u.name,elaps);}
  }
  return 0;
}



Measured memory_bytes: 11852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n;
cin >> n;
ll arr[n];
for(int i =0; i<n; i++){
	cin >> arr[i];
}

for(int i = n-1; i>0; i--){
	if(arr[i-1]>arr[i]){
		arr[i-1]= arr[i-1]-1;
		if(arr[i-1]>arr[i] || (i!= n-1 && arr[i]>arr[i+1])){
			cout << "No";
			return 0;
		}
	}

}

cout << "Yes" << endl;
return 0;
}



Measured memory_bytes: 1024
def route_num(stairs):
    if stairs <= 1:
        return 1
    else:
        return route_num(stairs - 1) + route_num(stairs - 2)

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

broken = {i:False for i in range(n + 1)}
for a_i in a:
    broken[a_i] = True

route_num = {}
for i in range(n + 1):
    if broken[i]:
        route_num[i] = 0
    elif i <= 1:
        route_num[i] = 1
    else:
        route_num[i] = route_num[i-1] + route_num[i-2]

print(route_num[n] % 1000000007)


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

D = []

for i in range(N):
    D.append(input().split())

mxn = 0
num = 0

for i in range(N):
    if D[i][0]==D[i][1]:
        num += 1
        mxn = max(num,mxn)
    else:
        num = 0

if mxn >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int n; cin >> n;
    map<string, int> m;
    queue<string> buff;
    REP(i,n)
    {
        string tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        if(tmp1 == "insert")
        {
            if(m.find(tmp2) == m.end())
            {
                m[tmp2] = 1;
            }
        }
        else // find
        {
            if(m.find(tmp2) == m.end()) buff.push("no");
            else buff.push("yes");
        }
    }
    while(!buff.empty())
    {
        string ans = buff.front();
        cout << ans << endl;
        buff.pop();
    }


}



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

const int MAX_N = 90, MAX_M = 90;
int n, m, max_depth;

void dfs(int used[MAX_M][MAX_N], int x, int y, int depth){
	used[y][x] = 1;
	
	max_depth = std::max(max_depth, depth);

	if(x-1 >= 0 && !used[y][x-1]){
		dfs(used, x-1, y, depth+1);	
	}
	if(x+1 < n && !used[y][x+1]){
		dfs(used, x+1, y, depth+1);
	}
	if(y-1 >= 0 && !used[y-1][x]){
		dfs(used, x, y-1, depth+1);
	}
	if(y+1 < m && !used[y+1][x]){
		dfs(used, x, y+1, depth+1);
	}

	used[y][x] = 0;
}

int main(){
	while(std::cin >> n >> m, n){
		int used[MAX_M][MAX_N];
		for(int j=0;j<n;j++){
			for(int i=0;i<m;i++){
				int m;
				std::cin >> m;
				used[i][j] = !m;
			}
		}

		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(!used[i][j]){
					dfs(used, j, i, 1);
				}
			}
		}

		std::cout << max_depth << std::endl;
		max_depth = 0;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

bool solve();

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

bool solve() {
    int n;
    cin >> n;
    if(n == 0) {
        return false;
    }
    set<P> se;
    for(int i = 0; i < n; i++) {
        P tmp;
        cin >> tmp.first >> tmp.second;
        se.insert(tmp);
    }
    P now = P(10, 10);
    int m, ans = 0;
    cin >> m;
    for(int _ = 0; _ < m; _++) {
        char d;
        int l;
        cin >> d >> l;
        // cout << d << " " << l << endl;
        P dir;
        if(d == 'N') {
            dir = P(0, 1);
        } else if(d == 'S') {
            dir = P(0, -1);
        } else if(d == 'E') {
            dir = P(1, 0);
        } else {
            dir = P(-1, 0);
        }
        // cout << dir.first << " " << dir.second << endl;
        for(int i = 0; i < l; i++) {
            now.first += dir.first;
            now.second += dir.second;
            // cout << now.first << " " << now.second << endl;
            if(se.count(now)) {
                ans++;
                se.erase(now);
            }
        }
    }
    cout << (n == ans ? "Yes" : "No") << endl;
    return 1;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int main(){
	vector<int> sosu(100009, true);
	sosu[1]=0;
	for(int i=2;i<sosu.size();++i){
		if(sosu[i]){
			for(int j=i*2;j<sosu.size();j+=i)sosu[j]=false;
		}
	}
	vector<int> sum(sosu.size(), 0);
	sosu[0]=0;
	REPA(i, sosu.size()){
		sum[i]=sum[i-1]+((1&i)&&sosu[i]&&sosu[(i+1)/2]);
	}
	int Q;
	cin>>Q;
	REP(i, Q){
		int l, r;
		cin>>l>>r;
		cout << sum[r]-sum[l-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
  int n; cin >> n;
  string s[n];
  int m[n][26] = {};
  REP(i,n) {
    cin >> s[i];
    for (int j = 0; s[i][j] != '\0'; ++j) {
      ++m[i][s[i][j] - 'a'];
    }
  }
  REP(i,26) {
    int cnt = 50;
    REP(j,n) {
      cnt = min(cnt, m[j][i]);
    }
    cout << string(cnt, 'a' + i);
  }
  cout << endl;
  return 0;
}

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

using namespace std;

#define ull unsigned long long int
#define ll long long int 

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    int bingo[3][3];

    for(int i=0; i<3; i++){
        cin >> bingo[i][0] >>  bingo[i][1] >>  bingo[i][2];
    }

    int n;
    int x;
    cin >> n;

    for(int i=0; i<n; i++){

        cin >> x;

        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(bingo[j][k] == x) bingo[j][k] = -1;
            }
        }

    }

    for(int j=0; j<3; j++){
        for(int k=0; k<3; k++){
            if((bingo[j][k] == -1 && (bingo[j][k] == bingo[j][k-1]) && (bingo[j][k]== bingo[j][k+1]))  && (k-1 >=0 && k+1 <3)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j+1][k] && bingo[j][k] == bingo[j-1][k]) && (j+1<3 && j-1>=0)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j-1][k-1] && bingo[j][k] == bingo[j+1][k+1]) && (j-1>=0 && k-1 >=0 && j+1<3 && k+1<3)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j-1][k+1] && bingo[j][k] == bingo[j+1][k-1]) && (j-1>=0 && k-1 >=0 && j+1<3 && k+1<3)){ 
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    

   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a[4][3][10];
	int n, b, f, r, v, i, j, k;
	cin >> n;
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				a[i][j][k] = 0;
			}
		}
	}
	for (i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) {
			cout << "####################" << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
ll m,n,k,i,j;
ll pa[200005];
ll pb[200005];
int foo(ll x)
{
	ll t=0;
	for(i=0;i<=min(x,n);i++)
	{
		if(x-i>m)
		{
			continue;
		}
		t=pa[i]+pb[x-i];
		if(t<=k)
		{
			return 1;
		}
		
	}
	return 0;
}

int main(){

    fast;
    
    cin>>n>>m>>k;
    ll a[n+1];
    ll b[m+1];
    
    for(i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
	for(i=1;i<=m;i++)
	{
		cin>>b[i];
	}
	mem(pa,0);
	mem(pb,0);
	for(i=1;i<=n;i++)
	{
		pa[i]=pa[i-1]+a[i];
	}
	for(i=1;i<=m;i++)
	{
		pb[i]=pb[i-1]+b[i];
	}
	ll lr=0,r=n+m;
	while(r>=lr)
    {
    	ll mid=(lr+r)/2;
    	if(foo(mid))
    	{
    		lr=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	cout<<r;
	
    
}

Measured memory_bytes: 9896
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	int n = s.size();
	LL ans = 0;

	int i = n - 1;
	int cntbc = 0;
	while (i >= 0) {

		if (s[i] == 'A') {
			ans += cntbc;
			i--;
		}
		else if (i > 0) {
			if (s[i - 1] == 'B'&&s[i] == 'C') {
				cntbc++;
				i = i - 2;
			}
			else {
				cntbc = 0;
				i--;
			}
		}
		else {
			cntbc = 0;
			i--;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using ll = long long int;

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

int n, l;

ll ans;

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

  ll whole = (0 + n - 1) * n / 2;
  whole += l * n;

  ll cur = INF;
  ans = whole;

  for (int i = 0; i < n; ++i) {
    if (cur > abs(whole - (whole - (i + l)))) {
      ans = whole - (i + l);
      cur = abs(whole - (whole - (i + l)));
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    int arr[m];
    for(int i=0;i<m;i++){
        arr[i]=0;
    }

    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int x;
            cin >> x;
            arr[x-1]+=1;
        }
    }
    int cnt = 0;
    for(int i=0;i<m;i++){
        if(arr[i]==n){
            cnt++;
        }
    }
    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			var n = firstLine[0];
			var m = firstLine[1];

			var heights = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();

			var dictionary = new Dictionary<int, List<int>>();

			for(var i = 0; i < n; i++)
			{
				dictionary.Add(i, new List<int>());
			}

			for(var i = 0; i < m; i++)
			{
				var path = Console.ReadLine().Split(' ').Select(value => int.Parse(value) - 1).ToArray();
				dictionary[path[0]].Add(path[1]);
				dictionary[path[1]].Add(path[0]);
			}

			var count = 0;

			foreach(var keyValuePair in dictionary)
			{
				var height = heights[keyValuePair.Key];

				if(keyValuePair.Value.Count == 0)
				{
					count++;
					continue;
				}

				var isGood = true;

				foreach (var adjacent in keyValuePair.Value)
				{
					if(height <= heights[adjacent])
					{
						isGood = false;
						break;
					}
				}

				if(isGood)
				{
					count++;
				}
			}

			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 46456
X, K, D = list(map(int, input().split()))
    
min_X = abs(X) // D
if min_X >= K:
    ans = abs(X) - K * D
else:
    if abs(X) % D == 0:
        res_D = K - min_X
        if res_D % 2 == 0:
            ans = 0
        else:
            ans = D
    else:
        res_D = K - min_X
        if res_D % 2 == 1:
            ans = (min_X + 1) * D - abs(X)
        else:
            ans = abs(X) - min_X * D
print(ans)        


Measured memory_bytes: 9192
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<utility>
#include<deque>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int n,a[510][510];

void dfs(vector<int> v , int x){
    if(v.size()==1||v.size()==0){
        return ;
    }
    vector<int> v1,v2;
    for(int i=0;i<v.size();i++){
        if(i%2){
            v1.push_back(v[i]);
        }
        else{
            v2.push_back(v[i]);
        }
    }
    for(int i=0;i<v1.size();i++){
        for(int j=0;j<v2.size();j++){
            a[min(v1[i],v2[j])][max(v1[i],v2[j])]=x;
        }
    }
    dfs(v1,x+1);
    dfs(v2,x+1);
}

int main(){
    scanf("%d",&n);
    vector<int> v;
    for(int i=1;i<=n;i++){
        v.push_back(i);
    }
    dfs(v,1);
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            printf("%d ",a[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1536
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main (a b c)
  (format t "~a ~a ~a~%" c a b))

(let ((a (read))
      (b (read))
      (c (read)))
  (main a b c))


Measured memory_bytes: 14772