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

int main(void){
  int a[5],i;
  while(scanf("%d",&a[0]),a[0]!=0){
    int used[3];
    used[0]=used[1]=used[2]=0;
    used[a[0]-1]=1;
    for(i=1;i<5;i++)scanf("%d",&a[i]),used[a[i]-1]=1;
    int sum=used[0]+used[1]+used[2];
    if(sum!=2){
      for(i=0;i<5;i++)printf("3\n");
      continue;
    }
    for(i=0;i<5;i++){
      switch(a[i]){
      case 1:
	if(used[1])printf("1\n");
	else printf("2\n");
	break;
      case 2:
	if(used[2])printf("1\n");
	else printf("2\n");
	break;
      case 3:
	if(used[0])printf("1\n");
	else printf("2\n");
	break;
      }
    }
  }
}

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

struct Q
{
	char name[11];
	int time;
};


Q que[100002];
int start = 0,end_q = 0;

void push(Q a) {
	que[end_q] = a;
	end_q++;
	if (end_q == 100002)end_q = 0;
}

Q pop() {
	Q ret = que[start];
	start++;
	if (start == 100002)start = 0;
	return ret;
}


int main() {
	int n, q,time = 0;
	cin >> n >> q;
	Q task[100000];
	for (int i = 0; i < n; i++) {
		cin >> task[i].name;
		cin >> task[i].time;
		push(task[i]);
	}
	while (start != end_q) {
		Q now;
		now = pop();
		time += min(now.time, q);
		if (now.time - q > 0) {
			now.time -= q;
			push(now);
		}
		else {
			cout << now.name << " " << time << endl;
		}
	}
}



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

int main() {
    int n, d, ans;
    cin >> n >> d;
    ans = (n + 2 * d) / (2 * d + 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
const ll N = 1e6;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =998244353;
// #define x first
// #define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll fact[N],facti[N];
ll ncr(ll n,ll r){
    if(n==r){
        return 1;
    }
    // cout<<fact[n]<<" "<<facti[r]<<" "<<facti[n-r]<<'\n';
    ll ans = (((fact[n]*facti[r])%mod)*facti[n-r])%mod;
    return ans;
}
int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif                           
    ll T= 1;
    // cin >> T;
    fact[0] = 1;
    facti[0] = 1;
    for(ll i = 1;i<N;i++){
        fact[i]=i*fact[i-1];
        fact[i]%=mod;
        ll im = powm(i,mod-2);
        facti[i] = im*facti[i-1];
        facti[i]%=mod;
    }
    // for(ll i = 0;i<10;i++){
    //     cout<<fact[i]<<" "<<facti[i]<<'\n';
    // }
    while(T--){
        ll n,m,k;cin>>n>>m>>k;
        ll ans = (m*powm(m-1,n-1))%mod;
        // cout<<ans<<'\n';
        for(ll i = 1;i<=k;i++){
            ll te = (((ncr(n-1,i)*powm(m,1))%mod)*powm(m-1,n-i-1))%mod;
            ans+=te;
            // cout<<te<<'\n';
            ans%=mod;
        }
        ll ans2 = 0;
        
        cout<<ans<<'\n';
    }
}   

Measured memory_bytes: 19280
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
#define INF 999999999999999999
#define mod 998244353
using namespace std;

void solve()
{
    string a,b;
    cin>>a>>b;
    int n = a.size();
    int m = b.size();

    pair<pair<int, int> ,int> dp[n+1][m+1];
    for(int i=n;i>=0;i--)
        for(int j = m;j>=0;j--)
        {
            if(i==n or j==m)
            {
                dp[i][j]= {{-1,-1} , 0};
                continue;
            }
            
            if(a[i]==b[j])
                {dp[i][j].first = {i+1,j+1};
                dp[i][j].second = dp[i+1][j+1].second + 1;}
            else
            {
                if(dp[i+1][j].second>=dp[i][j+1].second)
                   {dp[i][j].first = {i+1,j}; 
                    dp[i][j].second = dp[i+1][j].second;}
                    else
                    {dp[i][j].first = {i,j+1}; 
                    dp[i][j].second = dp[i][j+1].second;}
            }
            
        }

        pair<int, int> c={0,0};

        while(c.first<n and c.second<m)
        {
            if(a[c.first]==b[c.second])
                cout<<a[c.first]<<"";
            c = dp[c.first][c.second].first;
        }
        cout<<endl;
        // for(int i=0;i<=n;i++)
        // {
        //     for(int j=0;j<=m;j++)
        //         cout<<dp[i][j]<<"q ";
        //     cout<<endl;
        // }

        // cout<<dp[0][0]<<endl;
}
signed main()

{
    FAST_IO;
    int t = 1;

    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 211328
#include<bits/stdc++.h>
using namespace std;
int n,x,sum;
bitset<2000007>f;
int main(){
    cin>>n;
    f[0]=1;
    for(int i=1;i<=n;i++)
	{
        cin>>x;
        f|=f<<x;
        sum+=x;
    }
    for(int i=(sum+1)/2;i<=sum;i++)
	{
        if(f[i])
		{
			cout<<i<<endl;
			break;
		}
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int k,s;
int main() {
  cin>>k>>s;
  int cnt=0;
  for (int x = 0; x <= k; ++x) {
  	for (int y = 0; y <= k; ++y) {
    	if (s-x-y>=0 &&s-x-y<=k) cnt++;
    }
  }
  cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;

vector<vector<int>> A;
ll dp[22][1<<21];

int main(void) {
   ll N;
   cin>>N;
   A.resize(N);
   rep(i,0,N) A[i].resize(N,0);
   rep(i,0,N) rep(j,0,N) {
      cin>>A[i][j];
   }

   dp[0][0] = 1;
   rep(i,0,N) rep(msk, 0, 1<<N) {
      if (i != __builtin_popcount(msk)) continue;
      rep(j,0,N) {
         if ((msk<<j)%2) continue;
         if (!A[i][j]) continue;
         dp[i+1][msk | (1<<j)] += dp[i][msk];
         dp[i+1][msk | (1<<j)] %= MOD;
      }
   }
   cout<<dp[N][(1<<N)-1]%MOD<<endl;




   return 0;
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define int long long

using namespace std;

int tests, a, b;

int check (int x)
{
    int l = 1, r = x;
    while (r - l > 2)
    {
        int md1 = l + (r - l + 1) / 3, md2 = r - (r - l + 1) / 3;
        if ( md1 * (b + x - md1 + 1) > md2 * (b + x - md2 + 1) )
            r = md2;
        else
            l = md1;
    }
    int ans = l * (b + x - l + 1);

    for (int i = l; i <= r; i++)
        ans = max(ans, i * (b + x - i + 1) );

    return ans;
}

main()
{
    cin >> tests;
    while (tests--)
    {
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        int l = 1, r = b;

        while (r - l > 1)
        {
            int md = (l + r) >> 1;
            if ( (a + 1) * md < a * b )
                l = md;
            else
                r = md;
        }
        int left = b - l - 1;

        l = 0, r = a - left;

        while (r - l > 1)
        {
            int md = (l + r) >> 1;
            if ( check(md) < a * b )
                l = md;
            else
                r = md;
        }
        cout << l + b - 1<< endl;
    }
}


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


bool chk[200005];

int main()
{
    int n,m;
    cin>>n>>m;
    bool ans=false;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(a>b)swap(a,b);
        if(a==1){
            if(chk[b]) ans=true;
            chk[b]=true;
        }
        else if(b==n){
            if(chk[a]) ans=true;
            chk[a]=true;
        }


    }
    if(ans)cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";




}


Measured memory_bytes: 384
n = int(input())
a = [int(v) for v in input().split()]
limit = 1000000000000000000
if 0 in a:
    print (0)
else:
    ans = 1
    num = 1
    for i in a:
        num *= i
        if num > limit:
            num = -1
            break
    ans = num
    print(ans)

Measured memory_bytes: 21776
#include<bits/stdc++.h>
using namespace std;
int par[10000], rank[10000];
int find(int x){
	while(x != par[x]) x = par[x];
	return x;
}
int main(void){
	int n, q;
	cin >> n >> q;
	for(int i = 0; i < n; i++) par[i] = i, rank[i] = 0;
	for(int i = 0; i < q; i++){
		int com, x, y;
		cin >> com >> x >> y;
		if (com) cout << (find(x) == find(y)) << endl;
		else {
			x = find(x); y = find(y);
			if(rank[x] > rank[y]) par[y] = x;
			else if(rank[x] < rank[y]) par[x] = y;
			else par[y] = x, rank[x]++;
		}
	}
	return 0;
}


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

main(){
	int h,w,m; cin>>h>>w>>m;
	
	vector<pair<int,int>> v;
	vector<int> hcnt(h+1),wcnt(w+1),markh(h+1),markw(w+1);
	for(int i=0; i<m; i++){
		int c,d; cin>>c>>d;
		v.emplace_back(c,d);
		hcnt[c]++;
		wcnt[d]++;
	}
	int hmax=0, wmax=0;
	for(int i=1; i<=h; i++) hmax = max(hmax,hcnt[i]);
	for(int i=1; i<=w; i++) wmax = max(wmax,wcnt[i]);
	
	int cnth = 0;
	for(int i=1; i<=h; i++){
		if(hcnt[i]==hmax){
			markh[i] = 1;
			cnth++;
		}
	}
	int cntw = 0;
	for(int i=1; i<=w; i++){
		if(wcnt[i]==wmax){
			markw[i] = 1;
			cntw++;
		}
	}
	int cnt = cnth*cntw;
	for(auto x : v){
		if(markh[x.first] && markw[x.second]) cnt--;
	}
	if(cnt) cout<<hmax + wmax;
	else cout<<hmax + wmax - 1;
}

Measured memory_bytes: 12132
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int[]h = new int[N];
        int total = 0;
        for(int i=0; i<N; i++){
        h[i]=sc.nextInt();
        if(h[i]>=K){
            total++;
        }
       }
		System.out.println(total);
	}
}

Measured memory_bytes: 50212
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int k;
  cin >> k;
  cout << (k / 2) * (k - k / 2) << '\n';
  return 0;
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/arc061/tasks/arc061_a

s=input()
n=len(s)

num=0
for i in range(2**(n-1)):
    flag=[]

    for j in range(n-1):
        if (i>>j)&1:
            flag.append(j)

    if len(flag)==0:
        num+=int(s)
        #print(int(s))
    else:
        for i in range(len(flag)):
            flag[i]+=1
        flag.insert(0,0)
        flag_num=len(flag)
        for k in range(flag_num-1):
            num+=int(s[flag[k]:flag[k+1]])
            #print(int(s[flag[k]:flag[k+1]]))
        num+=int(s[flag[-1]:])
        #print(int(s[flag[-1]:]))

print(num)



Measured memory_bytes: 40560
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}

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

int main()
{
    string S,T;
    cin >> S >> T;
    if ( S == T.substr(0,S.size()))
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
    // vector<char> S(10),T(11);
    // for( int i = 0; i < 20; i++)
    // {
    // cin >> S.at(i) >> T.at(i);
    // }
    // int count = 0;
    // for( int i = 0; i < T.size(); i++)
    // {
    //     if ( S.at(i) == T.at(i))
    //         count++;
    //     if ( count - 1 == S.size())
    //     {
    //         cout << "Yes" << endl;
    //         return 0;
    //     }
    // }
    //cout << "No" << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h1=scan.nextInt();
		int w1=scan.nextInt();
		int h2=scan.nextInt();
		int w2=scan.nextInt();
		System.out.println(Math.abs(h1-h2)*Math.abs(w1-w2));

	}

}


Measured memory_bytes: 27012
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
	while(b){
		int t = a % b;
		a = b;
		b = t;
	}
	return a;
}

bool canWin(vector<int> dat) {
	sort(dat.begin(), dat.end());
	int n = dat.size();
	if (n == 1) return false;
	if (n == 2) return dat[0] != dat[1];
	int parity = 0;
	for (int i = 0; i < n; i++) {
		parity ^= (dat[i] - 1)%2;
	}
	if (parity) {
		return true;
	}
	if (dat[0] == 1) {
		return false;
	}
	int ocnt = 0;
	for (int i = 0; i < n; i++){
		if (dat[i]%2) {
			ocnt++;
		}
	}
	if (ocnt >= 2) return false;
	for (int i = 0; i < n; i++) {
		if (dat[i]%2) {
			dat[i]--;
			int totgcd = dat[0];
			for (int j = 0; j < n; j++) {
				totgcd = gcd(totgcd, dat[j]);
			}
			for (int j = 0; j < n; j++){
				dat[j] /= totgcd;
			}

			return !canWin(dat);
		}
	}
	return false;
}

int main() {
	int n;
	scanf("%d", &n);
	vector<int> dat(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &dat[i]);
	}
	if (canWin(dat)) {
		printf("First\n");
	} else {
		printf("Second\n");
	}
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
	int a,b;
	cin>>a>>b;
	if(a-2*b<0) cout<<"0"<<endl;
	else cout<<a-2*b<<endl;
	return 0;
}

Measured memory_bytes: 256
/*Anup Ghosh*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi acos(-1)
#define ull unsigned long long
#define nl printf("\n")
#define MAXN 1000005
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define     all(x)      x.begin() , x.end()
#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sp(n)  fixed<<setprecision(n)
int main()
{
	fio();
	int n;
	cin>>n;
	string s="ACL";
	for(int i=0;i<n;i++)
	cout<<s;
	return 0;
}


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

long long phi(long long n) {
	//素数10個の積が ~ 6*10^9程度なのでintなら最悪でも2^10程度の計算量
	auto m = n;
	vector<long long> vec;
	long long sq = sqrt(n);
	for(long long i = 2; i <= sq; i++) {
		if(n % i == 0) {
			vec.push_back(i);
			while(n % i == 0) {
				n /= i;
			}
		}
	}
	if(n > 1) vec.push_back(n);
	n = m;
	int k = vec.size();
	long long res = 0;
	for(int b = 0; b < (1 << k); b++) {
		long long a = 1;
		int cnt = 0;
		for(int j = 0; j < k; j++)
			if(b & (1 << j)) a *= -vec[j];
		res += n / a;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	cout << phi(n) << endl;
}


Measured memory_bytes: 3168
a, b = map(int, input().split())
ans = ''
if a > 0 and b > 0:
  ans = 'Positive'
elif a <= 0 and b >= 0:
  ans = 'Zero'
elif a < 0 and  b < 0:
  if (b - a) % 2 == 0:
    ans = 'Negative'
  else:
    ans = 'Positive'
print(ans)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
string N;
int D;
lol dp[101][2][5];
lol rec(int k,bool fight,int one){
  if(k==N.size()){
    if(one==D) return 1;
    else return 0;
  }
  if(dp[k][fight][one]!=-1) return dp[k][fight][one];
  if(one>D) return 0;
  int lim;
  if(fight) lim=N[k]-'0';
  else lim=9;//int lim=(fight ? N[k]-'0' : 9);
  lol ret=0;
  for(int d=0;d<=lim;d++){
    if(d==0) ret+=rec(k+1,(fight && (d==lim)),one);
    else ret+=rec(k+1,(fight && (d==lim)),one+1);
  }
  return dp[k][fight][one]=ret;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(dp,-1,sizeof(dp));
    cin >>N;
    cin >>D;
    cout <<rec(0,true,0)<<'\n';
    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


int vector_finder(vector<string> v, string s){
    auto itr = find(v.begin(), v.end(), s);
    size_t ind = distance(v.begin(), itr);
    if(ind != v.size()) return 1;
    else return 0;
}

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

    int k;
    string s;
    cin >> s >> k;

    int slen = s.length();
    vector<string> vs;
    rep(i, slen){
        int num = 1;
        for(int j=i; j<min(i+k, slen); j++){
            if(!vector_finder(vs, s.substr(i, num))){
                vs.push_back(s.substr(i, num));
            }
            num++;
        }
    }

    sort(vs.begin(), vs.end());

    cout << vs[k-1] << endl;

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int main()
{
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double ang=5.5*(h*60+m);
	if(ang<0.0)ang+=360.0;
	while(ang>=360.0)ang-=360.0;
	if(ang>180)ang=360-ang;
	ang=ang/180.0*pi;
	printf("%.18f",(double)sqrt((double)a*a+(double)b*b-2.0*a*b*cos(ang)));
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    int N;
    int A;
    cin >> N;
    cin >> A;
    N %= 500;
    if (N <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    A = read_ints()
    avg = sum(A)/N
    cost = lambda M: sum(abs(a-M)**2 for a in A)
    return min(cost(math.floor(avg)), cost(math.ceil(avg)))


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


Measured memory_bytes: 62376
#include<stdio.h>
#define MAX 100000

typedef struct node{
  int left;
  int right;
  int p;

}Node;

Node node[MAX];
int depth[MAX];

void  depthSearch(int a,int b){
  depth[a]=b;
  if(node[a].left!=-1)depthSearch(node[a].left,b+1);

  if(node[a].right!=-1)depthSearch(node[a].right,b);
}

int main(){
  int i,j;
  int n;
  int id;
  int k;
  int c;
  int l;

  int a;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    node[i].p=-1;
    node[i].right=-1;
    node[i].left=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);

    if(k!=0){
      for(j=0;j<k;j++){
	scanf("%d",&c);
	if(j==0)node[id].left=c;
	else {
	  node[l].right=c;
	}
	l=c;
	node[l].p=id;
      }
    }
  }

  for(i=0;i<n;i++){
    if(node[i].p==-1)depthSearch(i,0);    
  }



  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,node[i].p,depth[i]);

    if(node[i].p==-1){
      printf("root, ");
      printf("[");
    
      for(j=0,a=node[i].left; a!=-1 ;a=node[a].right,j++){
	if(j==0)printf("%d",a);
	else printf(", %d",a);
  }
      printf("]\n");
    }

    else if(node[i].left==-1){
      printf("leaf, ");
      printf("[]\n");
    }

    else {
      printf("internal node, ");
      printf("[");
      
      for(j=0,a=node[i].left; a!=-1 ;a=node[a].right,j++){
	if(j==0)printf("%d",a);
	else printf(", %d",a);
      }
      printf("]\n");

    }
      
  }
  return 0;
}



Measured memory_bytes: 3360
#include <iostream>
#include <climits>
#include <stdio.h>

void bubbleSort(int A[], int N)
{
  int swapCount = 0;
  for (int i = 0; i <= N - 1; i++)
  {
    for (int j = N - 1; j >= i + 1; j--)
    {
      if (A[j] < A[j - 1])
      {
        std::swap(A[j], A[j - 1]);
        swapCount++;
      }
    }
  }

  for (int k = 0; k < N; k++)
  {
    std::cout << A[k];
    if (k != N - 1)
    {
      std::cout << " ";
    }
  }
  std::cout << std::endl;
  std::cout << swapCount << std::endl;
}

int main(int argc, char *argv[])
{
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for (i = 0; i < N; i++)
    scanf("%d", &A[i]);

  bubbleSort(A, N);

  return 0;
}



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

int main(){
  int N;
  long long t=0;
  cin >> N;
  vector<pair<int,int>> vec(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    vec.at(i) = make_pair(b,a);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    t += vec.at(i).second;
    if(t>vec.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
  ll n,d;
  cin >> n >>d;

  vector<vector<ll>> x(n,vector<ll>(d));

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

  ll ans = 0;

  for (ll i = 0; i < n; i++)
  {
    for (ll j = i+1; j < n; j++)
    {
      ll dist = 0;
      for (ll g = 0; g < d; g++)
      {
        dist+= pow(x[i][g] - x[j][g],2);
      }
      if ((ll)sqrt(dist) * (ll)sqrt(dist) == dist ){
        ans++;
      }
    }

    
  }


  cout << ans;

}


Measured memory_bytes: 256
# 参考URL
# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]


N, M = map(int, input().split())
p = list(map(int, input().split()))

uf = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x-1, y-1)

ans = 0
for i in range(N):
    if i == p[i]-1 or uf.same(i, p[i]-1):
        ans+=1
        
print(ans)

Measured memory_bytes: 13812
#include<iostream>
#include<cstdio>
using namespace std;
int visit[101],d[101],f[101],t;
//   訪問状態     発見    完了
int n,M[101][101];
const int WHITE=0; //未訪問
const int GRAY=1;  //訪問はした
void dfs(int u){
  visit[u]=GRAY; //訪問はした
  d[u]=++t; //発見した時刻
  for(int v=0;v<n;v++){
    if(M[u][v]==0) continue; //辺がない
    if(visit[v]==WHITE) dfs(v);
  }
  f[u]=++t; //訪問完了時刻
}
int main(){
  int u,v,k;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    if(visit[i]==WHITE) //訪問していないか
      dfs(i); //iを始点に
  }
  for(int i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}



Measured memory_bytes: 3224
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef unsigned long long int ull;

const ull B1=1e8+7;
const ull B2=1e9+7;
const int MAX=1000;

char s[MAX][MAX];
char a[MAX][MAX];
int h,w,r,c;

vector<pair<int,int>> match2d()
{
	ull t1=1,t2=1;
	for(int i=0;i<c;i++)t1*=B1;
	for(int i=0;i<r;i++)t2*=B2;
	
	ull tmp[MAX][MAX]={};
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<c;j++)tmp[i][0]=tmp[i][0]*B1+s[i][j];
		for(int j=0;j+c<w;j++)tmp[i][j+1]=tmp[i][j]*B1+s[i][j+c]-s[i][j]*t1;
	}
	
	ull shash[MAX][MAX]={};
	
	for(int i=0;i+c<=w;i++)
	{
		ull e=0;
		for(int j=0;j<r;j++)e=e*B2+tmp[j][i];
		shash[0][i]=e;
		for(int j=0;j+r<h;j++)
		{
			e=e*B2+tmp[j+r][i]-tmp[j][i]*t2;
			shash[j+1][i]=e;
		}
	}
	
	ull ahash=0;
	ull tmpa[MAX]={};
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			tmpa[i]=tmpa[i]*B1+a[i][j];
		}
	}
	for(int i=0;i<r;i++)
	{
		ahash=ahash*B2+tmpa[i];
	}
	
	vector<pair<int,int>> ans;
	
	for(int i=0;i+r<=h;i++)
	{
		for(int j=0;j+c<=w;j++)
		{
			if(ahash==shash[i][j])ans.push_back(make_pair(i,j));
		}
	}
	
	return ans;
}

int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>s[i][j];
	cin>>r>>c;
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>a[i][j];
	
	vector<pair<int,int>> m=match2d();
	
	sort(m.begin(),m.end());
	
	for(int i=0;i<m.size();i++)
	{
		cout<<m[i].first<<" "<<m[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 24084
#include <cstdio>


typedef long long int ll;
int N;
int A[100];

int main(){

    scanf("%d",&N);
    for(int i=1;i<=N;i++) scanf("%d",A+i);
    A[N+1]=A[N];

    int r=2;
    ll money=1000;
    while(r<=N){
        if (A[r]>A[r-1])
            money=(money%A[r-1])+((ll)A[r])*(money/A[r-1]);
        r++;
    }

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

    return 0;
}

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

using namespace std;

#define ll long long
const int mod=1e9+7;
const int mxN=2e5;
ll mode(ll x){
	return ((x%mod+mod)%mod);
}
ll add(ll a,ll b){
	return mode(mode(a)+mode(b));
}
ll mul(ll a,ll b){
	return mode(mode(a)*mode(b));
}

int main(){
//#ifndef ONLINE_JUGDE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
	vector<ll> a(n);
    for(int i=0;i<n;i++)
    	cin>>a[i];
    ll ans=0;
    vector<ll> sum(n+1);
    for(int i=n-1;i>=0;i--){
    	sum[i]=sum[i+1]+a[i];
	}
    for(int i=0;i<n;i++){
    	ans=add(ans,mul(a[i],sum[i+1]));
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 6344
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	long long a,b,x;
	cin >> a >> b >> x;
	
	if(a==0 && b==0){
		cout << "1" << endl;
		return 0;
	}
	
	long long range_min=a/x;
	
	long long range_mx=b/x;
	
	long long ans=range_mx-range_min;
	if(a%x==0)ans++;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<int(1e9 + 7)>;
  long long n, a, b;
  cin >> n >> a >> b;
  Mint A = 1, B = 1;
  for (int i = 0; i < a; i++) {
    A *= n - i;
    A /= i + 1;
  }
  for (int i = 0; i < b; i++) {
    B *= n - i;
    B /= i + 1;
  }
  cout << Mint(2).pow(n) - 1 - A - B << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	double a,l,x;
	while(cin >> a >> l >> x){
		double s=0;
		s += a*sqrt(l*l-a*a/4)/2;
		double L = (x+l) / 2.0;
		s +=  l * sqrt( L*L -l*l/4);
		printf("%.10lf\n",s);
	}
}

Measured memory_bytes: 1236
import java.io.*;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
           
                int[] a = new int[5];
                int r = -1;
                for (int j  = 0; j < 5; j++){
                    a[j] = in.nextInt();
                    if (a[j] == 0){
                        r = j + 1;
                    }
                }
                out.println(r);

        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 32980
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
const int LMAX=2010;
int dp[LMAX+1][LMAX+1],from[LMAX+1][LMAX+1];
string LCS(string &a,string &b){
	int m=a.size(),n=b.size();
	rep(i,m+1)dp[i][0]=0,from[i][0]=-1;
	rep(i,n+1)dp[0][i]=0,from[0][i]=-1;
	rep(i,m)rep(j,n){
		if(a[i]==b[j]){
			dp[i+1][j+1]=dp[i][j]+1;
			from[i+1][j+1]=2;
		}else{
			if(dp[i][j+1]<dp[i+1][j]){
				dp[i+1][j+1]=dp[i+1][j];
				from[i+1][j+1]=1;
			}else{
				dp[i+1][j+1]=dp[i][j+1];
				from[i+1][j+1]=0;
			}
		}
	}
	int idx=dp[m][n];
	string out(idx,'!');
	for(int i=m,j=n;~from[i][j];){
		switch(from[i][j]){
			case 0:i--;break;
			case 1:j--;break;
			case 2:i--;j--;idx--;out[idx]=a[i];break;
		}
	}
	return out;
}
int main(){
	string s;
	while(cin>>s){
		string t=s;
		reverse(all(t));
		cout<<LCS(s,t)<<endl;
	}
}

Measured memory_bytes: 32716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

template<class T>
struct segment_tree {
    using F = function<T(T,T)>;
    int n;
    vector<T> data;
    F f;
    T init_v;

    segment_tree(int n_, T init_v, F f) : f(f), init_v(init_v) {
        n = 1;
        while (n < n_) n *= 2;
        data.assign(2*n-1,init_v);
    }

    //kをaに変更
    void update(int k, T a) {
        k += n-1;
        data[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = f(data[k*2+1],data[k*2+2]);
        }
    }

    //[a,b)のquery,kは節点番号
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return data[k];
        else {
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T operator[](int a) {return data[a+n-1];}
};

int main() {
    int n, k; cin >> n >> k;
    vint p(n);
    rep(i,n) cin >> p[i];
    auto f_min = [](int a, int b) {
        if (a < b) return a;
        else return b;
    };
    auto f_max = [](int a, int b) {
        if (a < b) return b;
        else return a;
    };
    segment_tree<int> sg_min(n,inf,f_min);
    segment_tree<int> sg_max(n,-1,f_max);
    rep(i,n) {
        sg_min.update(i,p[i]);
        sg_max.update(i,p[i]);
    }
    vector<pair<bool,bool>> data;
    for (int i = 0; i <= n-k; i++) {
        pair<bool,bool> tmp = make_pair(false,false);
        if (sg_min.query(i,i+k) == p[i]) tmp.first = true;
        if (sg_max.query(i,i+k) == p[i+k-1]) tmp.second = true;
        data.push_back(tmp);
    }
    vint wrong_place = {-1};
    rep(i,n-1) {
        if (p[i] > p[i+1]) wrong_place.push_back(i);
    }
    wrong_place.push_back(n-1);
    int ans = 0;
    bool no_change = false;
    for (int i = 0; i <= n-k; i++) {
        int l = *lower_bound(all(wrong_place),i) - i + 1;
        if (l >= k) {no_change = true; continue;}
        if (i-1 >= 0 && data[i-1].first && data[i].second) continue;
        ans++;
    }
    if (no_change) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 9184
s = input()
q_num = int(input())
head = []
tail = []
flip = 0
for i in range(q_num):
    q = tuple(input().split())
    if q[0] == '1':
        flip ^= 1
    else:
        f = int(q[1]) - 1
        c = q[2]
        if f ^ flip == 0:
            head.append(c)
        else:
            tail.append(c)
if flip:
    head, tail = tail, head
    s = s[::-1]
head = ''.join(head)
tail = ''.join(tail)
print(head[::-1] + s + tail)

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


Measured memory_bytes: 3084
#include<stdio.h>

typedef struct house
{
  int f[3][10];
}house;
int main()
{
  int n;
  house a[4];
  int n1, n2, n3, n4;

  for(int i = 0; i<4; i++)
    {
      for(int j = 0; j<3; j++)
	{
	  for(int k = 0; k < 10; k++)
	    {
	      a[i].f[j][k] = 0;
	    }
	}
    }
  scanf("%d", &n);
  for(int i = 0; i<n; i++)
    {
      scanf("%d %d %d %d", &n1, &n2, &n3, &n4);
      a[n1-1].f[n2-1][n3-1] += n4;
    }
  for(int i = 0; i<4; i++)
    {
      for(int j = 0; j<3; j++)
	{
	  for(int k = 0; k<10; k++)
	    {
	      printf(" %d", a[i].f[j][k]);
	    }
	  printf("\n");
	}
      if(i <3)
	{
	  printf("####################\n");
	}
    }
}



Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

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


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  ll a, b, c, d, ans = -1000000000000000000;
  cin >> a >> b >> c >> d;
  ans = max(ans, a * c);
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
}

Measured memory_bytes: 3632
def palindrome_philia():
    # 入力
    S = input()
    # 処理
    # 文字列が奇数
    if len(S) % 2 == 1:
        comp_str_count = int((len(S) + 1) / 2 - 1)
    # 文字列が偶数
    elif len(S) % 2 == 0:
        comp_str_count = int((len(S) + 1) / 2)
    # 集計処理
    hag_count = 0
    for i in range(comp_str_count):
        if S[i] == S[-i-1]:
            pass
        else:
            hag_count += 1
        i += 1
    return hag_count

result = palindrome_philia()
print(result)

Measured memory_bytes: 8968
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n + 1);
	rep(i, n) cin >> a[i];
	b[0] = 0;
	REP(i, 1, n + 1) {
		b[i] = b[i - 1] + a[i - 1];
	}
	map<ll, ll> mp;
	ll ans = 0;
	rep(i, n + 1) {
		ans += mp[b[i]];
		mp[b[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int height[10];
	int tmp;
	int i=0,j=0;

	for (;i<10;i++)
		cin>>height[i];
	for (i=0;i<100;i++)
		for(j=1;j<10;j++)
			if (height[j-1]<height[j]) {
				tmp = height[j-1];
				height[j-1] = height[j];
				height[j] = tmp;
			}

	for (i=0;i<3;i++)
		cout<<height[i]<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    cin >> n;
    set<int> v;
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        v.insert(k);
    }
    cout << v.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[111111],e[11],d[11];
int n,pos;
int main()
{
	e[0]='e';e[1]='r';e[2]='a';e[3]='s';e[4]='e';
	d[0]='d';d[1]='r';d[2]='e';d[3]='a';d[4]='m';
	scanf("%s",s);
	n=strlen(s);
	pos=0;
	while(pos<n)
	{
		if (s[pos]=='e')
		{
			for (int i=0;i<5;i++)
			{
				if (s[pos+i]!=e[i])
				{
					cout<<"NO"<<endl;
					return 0;
				}
			}
			pos+=5;
			if (s[pos]=='r') pos++;
		}
		else if (s[pos]=='d')
		{
			for (int i=0;i<5;i++)
			{
				if (s[pos+i]!=d[i])
				{
					cout<<"NO"<<endl;
					return 0;
				}
			}
			pos+=5;
			if (s[pos]=='e')
			{
				if (s[pos+1]!='r')
				{
					cout<<"NO"<<endl;
					return 0;
				}
				if (s[pos+2]!='a') pos+=2;
			}
		}
		else 
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()

using namespace std;

//long a, b, c, d, i, j, k, n;


int main(){
//////////////////////////////////////////////////////

    int x;
    cin >> x;

    if ( x == 3 || x == 5 || x == 7 )
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    // cout << "n:" << n << endl;

    // vector<long> input(n);
    // for (int i = 0 ; i < n ; i ++ )
    // {
    //     cin >> input[i];
        // cout << "input[" << i << "]=" << input[i] << endl;
    // }

    // sort(input.begin() , input.end());

    // uint64_t max = numeric_limits<uint64_t>::max();



    // long sum = 0;
    // for ( int i = 0 ; i < n ; i ++ )
    // {
    //     sum += i;
    // }






    // cout <<      << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple

int main(){
  int n; cin >> n;string s1,s2; cin >> s1 >> s2;
  ll ans = 3;
  int state = 0; // 1: |x  2: -x
  for(int i = 0; i < n; i++){
    if(i == n-1){
      ans *= (state == 0?1:(state == 1?2:1));
      ans %= DIV;
    }else if(s1[i] == s1[i+1]){
      ans *= (state == 0?2:(state == 1?2:3));
      ans %= DIV;
      i++; state = 2;
    }else{
      ans *= (state == 0?1:(state == 1?2:1));
      ans %= DIV;
      state = 1;
    }
  }
  cout << ans%DIV << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,ans=1;
  cin>>n;
  ll f[n+1]={};

  for(int i=2;i<=n;i++){
    ll x=i;
    for(int j=2;;j++){
      while(x%j==0){
        f[j]++;
        x/=j;
      }
      if(x==1) break;
    }
  }
  for(int i=2;i<=n;i++){
    ans=(ans*(f[i]+1))%MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  bool ok[30]={};
  int x;
  for(int i=0;i<28;i++) {
    cin >> x; x--;
    ok[x] = 1;
  }
  int res[2], n=0;
  for(int i=0;i<30;i++) if(!ok[i]) res[n]=i+1, n++;
  sort(res, res+2);
  for(int i=0;i<2;i++) cout<<res[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 1160
//In the name of God
#include<bits/stdc++.h>
using namespace std;
int main()
{long long int a,b,c,d;
 cin>>a>>b>>c>>d;
 for(;;)
 {c=c-b;
  if(c<=0)
  {cout<<"Yes";
   return 0;}
  a=a-d;
  if(a<=0)
  {cout<<"No";
   return 0;}
 }
}

Measured memory_bytes: 3632