akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#include "bits/stdc++.h"
#endif
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> Auniq = A;
    sort(all(Auniq));
    Auniq.erase(unique(all(Auniq)), Auniq.end());

    bool ans = true;

    if (Auniq.size() > 3) {
        ans = false;
    }
    else if (Auniq.size() == 1 ) {
        if (A[0] != 0) ans = false;
    }
    else {
        if (N % 3 != 0) {
            ans = false;
        }

        vector<int> B(Auniq.size());
        rep(i, N) {
            rep(j, Auniq.size()) {
                if (A[i] == Auniq[j]) {
                    B[j]++;
                }
            }
        }

        if (Auniq.size() == 3) {
            if (B[0] != B[1] || B[0] != B[2]) ans = false;

            rep(b, 31) {
                int b0 = 0, b1 = 0;
                rep(j, 3) {
                    if (Auniq[j] >> b & 1) b1++;
                    else b0++;
                }

                if ((b0 == 1 && b1 == 2) || b0 == 3);
                else {
                    ans = false;
                }
            }
        }
        else if (Auniq.size() == 2) {
            if (B[0] * 2 != B[1] || Auniq[0] != 0) {
                ans = false;
            }
        }
    }

    write(ans ? "Yes" : "No");
}

Measured memory_bytes: 1024
def min(a, b)
  a < b ? a : b
end

n = gets.chomp.split("").map(&:to_i).reverse
n << 0
n_size = n.size

dp = Array.new(n_size+1){Array.new(2, 0)}
dp[0][1] = 1
n_size.times do |i|
  num = n[i]
  dp[i+1][0] = min(num + dp[i][0], num + 1 + dp[i][1])
  dp[i+1][1] = min(10 - num + dp[i][0], 10 - (num + 1) + dp[i][1])
end
p dp.last[0]

Measured memory_bytes: 101388
#include<cctype>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

const int maxn=3000010;
int n,m,k,tot,st[maxn],pos;
int sa,sb,sc,sd,p[maxn<<1];
struct node
{
	int val,op;
}a[maxn],b[maxn],c[maxn],d[maxn];

bool cmp1(const node &x,const node &y)
{
	return x.val<y.val;
}

bool cmp2(const node &x,const node &y)
{
	return x.val>y.val;
}

int read()
{
	int x=0,f=1;
	char c=getchar();
	while (!isdigit(c))
		f=c=='-'?-1:1,c=getchar();
	while (isdigit(c))
		x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}

bool judge(int x,int y)
{
	return x==0||x==n||y==0||y==m;
}

void doit(int x,int y,int op)
{
	if (y==m)
		a[++sa]=(node){x,op};
	else
	if (x==n)
		b[++sb]=(node){y,op};
	else
	if (y==0)
		c[++sc]=(node){x,op};
	else
	if (x==0)
		d[++sd]=(node){y,op};
}

int main()
{
	int i,j,x,y,u,v;
	n=read();
	m=read();
	k=read();
	for (i=1;i<=k;i++)
	{
		x=read();
		y=read();
		u=read();
		v=read();
		if (judge(x,y)&&judge(u,v))
		{
			doit(x,y,i);
			doit(u,v,i);
		}
	}
	sort(a+1,a+sa+1,cmp1);
	sort(b+1,b+sb+1,cmp2);
	sort(c+1,c+sc+1,cmp2);
	sort(d+1,d+sd+1,cmp1);
	for (i=1;i<=sa;i++)
		p[++tot]=a[i].op;
	for (i=1;i<=sb;i++)
		p[++tot]=b[i].op;
	for (i=1;i<=sc;i++)
		p[++tot]=c[i].op;
	for (i=1;i<=sd;i++)
		p[++tot]=d[i].op;
	for (i=1;i<=tot;i++)
	{
		if (pos>=1&&st[pos]==p[i])
			pos--;
		else
			st[++pos]=p[i];
	}
	puts(pos==0?"YES":"NO");
	return 0;
}

Measured memory_bytes: 15232
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
#include <queue>
#include <utility>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int factor[] = {25, 10, 5, 1};

    int i = 0, sum = 0;
    while (i < 4)
    {
        sum += n / factor[i];
        n = n % factor[i];
        i++;
    }

    cout << sum << endl;
}


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

int main()
{
	string s1,s2;
	cin >> s1 >> s2;
	int m= s1.length(),n= s2.length();
	vector<vector<int> > dp(m+1, vector<int>(n+1,0));
	// vector<vector<string> > s(m+1, vector<string>(n+1));

	for(int i=1; i<=m; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(s1[i-1]== s2[j-1])
			{
				dp[i][j] = dp[i-1][j-1]+1;
				// s[i][j] = s[i-1][j-1] + s1[i-1];
			}
			else
			{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
				// if(dp[i-1][j]> dp[i][j-1])
				// {
				// 	dp[i][j] = dp[i-1][j];
				// 	s[i][j] = s[i-1][j];
				// }
				// else
				// {
				// 	dp[i][j] = dp[i][j-1];
				// 	s[i][j] = s[i][j-1];
				// }
			}

		}
	}
	string str;
	int i=m,j=n;
	while(i>0 && j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			str = s1[i-1] +str;
			i--;
			j--;
		}
		else if(dp[i-1][j] ==dp[i][j])
			i--;
		else
			j--;
	}
	// for(int i=1;i<=m;i++)
	// {
	// 	for(int j=1;j<=n;j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// for(int i=1;i<=m;i++)
	// {
	// 	for(int j=1;j<=n;j++)
	// 	{
	// 		cout << s[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << dp[m][n] << endl;
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

int n, m;
int cnt[26];
char a[102][102];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			cnt[a[i][j] - 'a']++;
		}
	}
	if (n % 2 == 0 && m % 2 == 0) {
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 4 != 0) {
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	} else if (n % 2 == 1 && m % 2 == 1) {
		bool ok = 0;
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 == 1) {
				cnt[i]--;
				ok = 1;
				break;
			}
		}
		if (!ok) {
			puts("No");
			return 0;
		}
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 == 1) {
				puts("No");
				return 0;
			}
		}
		int need = n / 2 + m / 2;
		for (int i = 0; need && i < 26; i++) {
			if (cnt[i] % 4 == 2) {
				cnt[i] -= 2;
				need--;
			}
		}
		if (need % 2 == 1) {
			puts("No");
			return 0;
		}
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 4 != 0) {
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	} else {
		if (n % 2 == 0) {
			swap(n, m);
		}
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 == 1) {
				puts("No");
				return 0;
			}
		}
		int need = m;
		for (int i = 0; need && i < 26; i++) {
			if (cnt[i] % 4 == 2) {
				cnt[i] -= 2;
				need -= 2;
			}
		}
		if (need % 4 != 0) {
			puts("No");
			return 0;
		}
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 4 != 0) {
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  cout << n * (n - 1) / 2 << '\n';
}


Measured memory_bytes: 3556
n=int(input())
nana=[7,5,3]
def check(x):
    s=str(x)
    d=1 if all(s.count(str(nana[i]))>=1 for i in range(3) ) else 0
    return d

def dfs(x):
    res=0
    if x>n:
        return 0
    if check(x):
        res+=1
    for i in range(3):
        res+=dfs(10*x+nana[i])
    return res
 
print(dfs(0))

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

int main() {
  int A, B, a, b, c, d, e, s;
  cin >> A >> B;
  s = 0;
  
  for (int i = A; i <= B; i++) {
    a = i % 10;
    b = ((i - a) / 10) % 10;
    c = (((i - a) / 10 - b) / 10) % 10;
    d = ((((i - a) / 10 - b) / 10 - c) / 10) % 10;
    e = (((((i - a) / 10 - b) / 10 - c) / 10 - d) / 10) % 10;
    
    if (a == e && b == d) {
      s++;
    }
    
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<int> A, B, C;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  B.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  C.resize(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i];
  }

  int ans = 0;
  int pos = -10;
  for (int i = 0; i < N; i++) {
    int p = A[i];
    ans += B[p];
    if (pos + 1 == p) {
      ans += C[pos];
    }
    pos = p;
  }

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e6+10;
int S[N],mp[3],buc[3];
int n;
void change(int a,int b) {
	swap(mp[a],mp[b]);
	for(int i=1;i<=n;++i) {
		if(S[i]==a) S[i]=b;
		else if(S[i]==b) S[i]=a;
	}
}
int L[N],R[N];
void del(int x) {
	buc[S[x]]--;
	R[L[x]]=R[x];
	L[R[x]]=L[x];
}
#include <assert.h>

void sol() {
	buc[0]=buc[1]=buc[2]=0;
	for(int i=R[0];i<=n;i=R[i]) buc[S[i]]++;
//	for(int i=R[0];i<=n;i=R[i]) printf("%d ",S[i]); puts("");
	
	
//	for(int i=R[0];i<=n;i=R[i]) printf("%d ",S[i]); puts("");
	{
		int t=buc[2]-buc[0];
		for(int i=R[0];R[i]<=n&&t;i=R[i])
			if(S[i]!=0&&S[R[i]]!=0&&S[L[i]]!=S[R[R[i]]])
				del(R[i]),del(i),t--;
	}
	{
		buc[0]=buc[1]=buc[2]=0;
		for(int i=R[0];i<=n;i=R[i]) buc[S[i]]++;
		assert(buc[1]==buc[2]);
	}
	for(int i=R[0];i<=n;i=R[i]) putchar('A'+mp[S[i]]);
}
int main() {
	mp[1]=1,mp[2]=2;
	
	{
		static char str[N];
		scanf("%s",str+1);
		int m=strlen(str+1);
		for(int i=1;i<=m;++i)
			if(i==1||str[i]!=str[i-1]) S[++n]=str[i]-'A';
	}
	
	S[0]=-1,S[n+1]=-2;
	for(int i=1;i<=n;++i) L[i]=i-1,R[i]=i+1; R[0]=1,L[n+1]=n;
	
	buc[0]=buc[1]=buc[2]=0;
	for(int i=1;i<=n;++i)
		buc[S[i]]++;
	{
		int ch=0;
		if(buc[1]<=min(buc[2],buc[0])) ch=1;
		if(buc[2]<=min(buc[1],buc[0])) ch=2;
		if(ch) change(0,ch),swap(buc[0],buc[ch]);
	}
	
	if(buc[1]<buc[2]) change(1,2),swap(buc[1],buc[2]);
	
//	if(S[R[0]]==1&&buc[1]>buc[2]) del(R[0]);
//	if(S[L[n+1]]==1&&buc[1]>buc[2]) del(L[n+1]);
	
//	for(int i=R[0];i<=n;i=R[i]) printf("%d ",S[i]); puts("");
	{
		int t=buc[1]-buc[2];
		for(int i=R[0];i<=n&&t;i=R[i])
			if(S[i]==1&&S[L[i]]!=S[R[i]]) del(i),t--;

		for(int i=R[0];i<=n&&t;i=R[i]) 
			if(S[i]==1&&S[L[i]]==0&&S[R[i]]==0) del(R[i]),del(i),t--;

	}
	
	sol();
	
	return 0;
	
	buc[0]=buc[1]=buc[2]=0;
	
//	cout<<mp[0]<<' '<<mp[1]<<' '<<mp[2]<<endl;
	
//	for(int i=R[0];i<=n;i=R[i]) printf("%d ",S[i]); puts("");
	
	int b[2]={0,0},c[2]={0,0};
	for(int i=0;i<n;) {
		int j=R[i]; while(j<=n&&S[j]!=0) j=R[j];
		
		buc[1]=buc[2]=0;
		for(int k=R[i];k<j;k=R[k]) buc[S[k]]++;
		
		i=j;
		
		if(!buc[1]&&!buc[2]) continue;
		if(!buc[1]) c[0]++;
		if(!buc[2]) b[0]++;
		
		if(buc[1]) b[1]++;
		if(buc[2]) c[1]++;
	}
//	cout<<b[0]<<' '<<b[1]<<' '<<c[0]<<' '<<c[1]<<endl;

//	for(int i=R[0];i<=n;i=R[i]) printf("%d ",S[i]); puts("");
	if(b[0]<=c[1]) { sol(); return 0; }
	{
		int t=b[0]-c[1];
		
		for(int i=R[0];i<=n&&t;i=R[i])
			if(S[i]==1&&S[L[i]]==0&&S[R[i]]==0)
				del(R[i]),del(i),t--;
	}
	
	sol();
	return 0;
}

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

int N;
int C[555], S[555], F[555];

int main() {
   cin >> N;
   for (int i = 0; i < N-1; i++) {
      cin >> C[i] >> S[i] >> F[i];
   }

   for (int i = 0; i < N; i++) {
      int t = 0;
      for (int j = i; j < N-1; j++) {
         if (j == i) t += S[j];
         // kをループで求める
         int k = 0;
         for ( ; ; k++) {
            if ((S[j] + F[j]*k) >= t) break;
         }
         t = S[j] + F[j]*k + C[j];
      }
      cout << t << endl;
   }

   return 0;
}


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

K, S = MAP()

ans = 0

for i in range(K+1):
    x = i
    for j in range(K+1):
        y = j
        z = S - (x + y)
        if 0 <= z <= K:
            ans += 1
print(ans)


Measured memory_bytes: 5384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<vector>
using namespace std;
int main(void){
	int a[11];
	int c;
	int x;
	int s=0;
	int n;
	int k;
	scanf("%d %d", &n,&k);
	for (int i = 0; i < 11; i++){
		a[i] = 0;
		for (int j = 2; j < 7; j++){
			x = 7 * i + j;
				if (x * 9 % 11 == k)a[i]++;
		}
	}
		x = (n-2) / 11;
		c = (n-2) % 11;
	for (int i = 0; i < 11; i++){
		if (i == 0){
			s=s+(a[i] * x);
		}
		else{
			if (i <= c){
				s = s + (a[i] * (x + 1));
			}
			else{
				s = s + (a[i] * x);
			}
		}
	}
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define MAX_N 100000
int a[MAX_N+1];
int main(){
    int N;
    cin >> N;
    REP1(i,N) cin >> a[i];
    int ans=0;
    REP1(i,N){
        if(a[a[i]] == i) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}


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

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int res = 0;
    for (int i = 0; i <= N / R; i++) {
        for (int j = 0; j <= N / G; j++) {
            int rest = N - i * R - j * G;
            if (rest >= 0 && rest % B == 0) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
 
    public static void main(String[] args) throws IOException{
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        String str =br.readLine();
        String[] stra = str.split(" ");
         
        double a = Double.parseDouble(stra[0]);
        double p = 3.1415926535897932384626433 ;
        System.out.printf("%.8f %.8f",a*a*p,2*p*a);
    }
 
}

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

int main() {
	int N;
	std::cin >> N;
	std::vector<int> d = std::vector<int>(N);
	for (int i = 0; i < N; i++) { std::cin >> d[i]; }
	std::sort(d.begin(), d.end());
	std::cout << d[N / 2] - d[N / 2 - 1] << '\n';

	return 0;
}

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

int main()
{
        string N; cin >> N;
        cout << "ABC";
        int len = N.length();
        if (len == 2) cout << "00" << N << endl;
        else if (len == 1) cout << "0" << N << endl;
        else cout << N << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// junbi
		Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.nextLine());
        int b = Integer.parseInt(sc.nextLine());
        int h = Integer.parseInt(sc.nextLine());

    	System.out.println(String.valueOf((a+b)*h/2));
	}
}


Measured memory_bytes: 21712
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}
int main(){
  int i,j,k,n,ans=0;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      for(k=1;k<=n;k++){
        int a=gcd(i,j);
        ans+=gcd(a,k);
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

b = list(map(int, input().split()))

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

out = 0

for i in range(len(a)):
    x = 0
    for j in range(m):
        x += a[i][j] * b[j]
    if x + c > 0:
        out += 1

print(out)

Measured memory_bytes: 3064
function f()
A=Array{Tuple{Int,Int}}(0)
lines=readlines()
N=parse(Int,shift!(lines))
for i=1:N
	a,b=map(x->parse(Int,x),split(shift!(lines)))
	push!(A,(b,a))
end
now=0
for (a,b)=sort(A)
	now+=b
	if now>a
		println("No")
		exit()
	end
end
println("Yes")
end
f()


Measured memory_bytes: 170296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	

	ll N,K;
	ll mod_number = 1000000000+7;
	
	cin>>N>>K;

	array<ll,200002> dp;
	dp[N+1] = 1;
	for(ll i = N; K <= i; i--){
		
		ll max_num = ((N + (N + 1 - i)) * i) / 2;
		ll min_num = ( ( (N - (N+1 - i)) + 0) * i) / 2;
		dp[i] = (dp[i+1] + max_num - min_num + 1) % mod_number;
		//cout<<"dp"<<i<<" : "<<dp[i]<<endl;
	}


	cout<<dp[K]<<endl;
	return 0;
}
//組み合わせ N_C_K
//普通なら
//ただし、和が他の物と一致することもある
//一致したものはもう一度計算せずなのでdp
//
//dp[K] = dp[K-1] * K
//
//dp[N+1] = 1
//dp[N] = N_C_(N-1) + dp[N+1]
//dp[N-1] = N_C_(N-2) + dp[N] + dp[N+1]
//}


Measured memory_bytes: 5116
#include<stdio.h>
int main(){
    int H,W,a,b;
    while(1){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0)break;
        for(a = 0;a < H;a++){
            for(b = 0;b < W;b++){
                printf("#");
            }
        printf("\n");
        }
    printf("\n");
    }



    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cmath>
  
using namespace std;
  
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        double x[4],y[4];
        for(int j=0;j<4;j++)
            cin>>x[j]>>y[j];
        if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2]))<1e-10)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
      
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>

using namespace std;

const int MAX_N=36;

struct Card{
    char type;
    int value;
};

void bubbleSort(Card *,int);
void selectionSort(Card *,int);

int main(){
    Card bubbleC[MAX_N],selectionC[MAX_N];
    int n;
    cin>>n;
    int i;
    for (i=0;i<n;i++){
        char temp[3];
        cin>>temp;
        bubbleC[i].type=temp[0];
        bubbleC[i].value=(int)(temp[1]-'0');
        selectionC[i].type=temp[0];
        selectionC[i].value=(int)(temp[1]-'0');
    }
    //BubbleSort
    bubbleSort(bubbleC,n);
    //SelectionSort
    selectionSort(selectionC,n);
    for (i=0;i<n;i++){
        cout<<bubbleC[i].type<<bubbleC[i].value;
        if (i!=n-1){
            cout<<" ";
        }
    }
    cout<<endl;
    cout<<"Stable"<<endl;
    for (i=0;i<n;i++){
        cout<<selectionC[i].type<<selectionC[i].value;
        if (i!=n-1){
            cout<<" ";
        }
    }
    cout<<endl;
    for (i=0;i<n;i++){
        if (bubbleC[i].type!=selectionC[i].type || bubbleC[i].value!=selectionC[i].value)
            break;
    }
    if (i<n){
        cout<<"Not stable"<<endl;
    }
    else
        cout<<"Stable"<<endl;
    return 0;
}

void bubbleSort(Card *c,int n){
    for (int i=0;i<n;i++){
        for (int j=n-1;j>=i+1;j--){
            if (c[j].value<c[j-1].value){
                Card temp(c[j]);
                c[j]=c[j-1];
                c[j-1]=temp;
            }
        }
    }
}

void selectionSort(Card *c,int n){
    for (int i=0;i<n;i++){
        int mini=i;
        for (int j=i;j<n;j++){
            if (c[j].value<c[mini].value){
                mini=j;
            }
        }
        Card temp(c[mini]);
        c[mini]=c[i];
        c[i]=temp;
    }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#include <cmath>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	long double a,b,x;
	cin>>a>>b>>x;
	if(x*2>=a*a*b){
		long double ta=a*a*b-x;
		//cout <<ta<<endl;
		ta/=(a*a*a/2);
		//cout <<ta<<endl;
		printf("%.9Lf",atan(ta)*180.0/M_PI);
		return 0;
	}
	else{
		long double ta=x;
		ta/=(a*b*b/2);
		printf("%.9Lf",90.0-atan(ta)*180.0/M_PI);
	}
	// your code goes here
	return 0;
}

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

int main(void) {
    vector<int> vec;
    while (true) {
        int x, y;
        string op;
        cin >> x >> op >> y;
        if (op == "+") {
            vec.push_back(x + y);
        }
        else if (op == "-") {
            vec.push_back(x - y);
        }
        else if (op == "*") {
            vec.push_back(x*y);
        }
        else if (op == "/") {
            vec.push_back(x/y);
        }
        else if (op == "?") {
            break;
        }
    }
    for (int i = 0; i < vec.size(); i++) {
        cout << vec.at(i) << endl;
    }
}


Measured memory_bytes: 3224
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<ArrayList<Integer>> graph = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<n;i++) {
			graph.add(new ArrayList<Integer>());
		}

		for (int i=0;i<m;i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		int[] colors = new int[n];

		if(dfs(graph,0,colors,1)) {
			long count = 0;
			for (int i=0;i<n;i++) {
				if(colors[i] == 1) {
					count++;
				}
			}

			System.out.println(count*(n-count)-m);
		} else {
			System.out.println((long)n*(n-1)/2-m);
		}
	}


	static boolean dfs(List<ArrayList<Integer>> graph, int node, int[] colors, int color) {
		if (color * colors[node] < 0) {
			return false;

		} else if (colors[node] == 0) {
			colors[node]=color;
			boolean tmp = true;
			for (Integer i : graph.get(node)) {
				tmp &= (dfs(graph, i, colors, -color));
			}
			return tmp;

		} else {
			return true;
		}
	}

}


Measured memory_bytes: 108508
#include <bits/stdc++.h>
using namespace std;
int main(void){
    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"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    
    sort(L.begin(), L.end());
    int sum = 0;
    for (int i = 0; i < N - 1; i++) {
        sum += L[i];
    }
    if (sum > L[N - 1]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

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

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  int wa = 0; rep(i,N) wa += A[i];
  bitset<(1<<22)> sum; sum.set(0);
  rep(i,N) sum |= sum<<A[i];
  int result = (wa+1)/2; while(!sum[result]) result++;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
unsigned long long lcm (unsigned long long a, unsigned long long b){
	unsigned long long a1 = a;
	unsigned long long b1 = b;
	if(a < b){
		unsigned long long tmp = a;
		a = b;
		b = tmp;
	}
	unsigned long long r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
	return (b1 / b) * a1;
}
int main () {
	int N;
	cin >> N;
	unsigned long long currentLCM;
	cin >> currentLCM;
	for (int i = 1; i < N; ++i)
	{
		unsigned long long tmp;
		cin >> tmp;
		currentLCM = lcm(currentLCM,tmp);
	}
	cout << currentLCM << endl;

}

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

int main() {
  long long N,A,B;
  cin>>N>>A>>B;
  long long ans=0;
  if(A+B==0){
    cout<<0;
    return 0;
  }
  ans+=(N/(A+B))*A;
  if(N%(A+B)<A) ans+=N%(A+B);
  else ans+=A;
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<cstdlib>
#include<deque>
#include<queue>
#include<bitset>
#include<functional>
#include<utility>
#include<list>
#include<iomanip>
#include<ctime>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int INF=1e9+1;
bool like[10];
int main()
{
	int n,k;
	cin>>k>>n;
	memset(like,1,sizeof(like));
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		like[x]=0;
	}
	for(int i=k;;i++)
	{
		int x=i;
		bool ok=1;
		while(x>0)
		{
			int a=x%10;
			if(!like[a]) ok=0;
			x/=10;
		}
		if(ok)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


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

struct Node {
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

Node *find(Node *u,int k) {
  while (u!=NIL and k!=u->key) {
    if (k<u->key) {
      u=u->left;
    }
    else {
      u=u->right;
    }
  }
  return u;
}
void insert(int k) {
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x!=NIL) {
    y=x;
    if (z->key<x->key) {
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent=y;
  if (y==NIL) {
    root=z;
  }
  else {
    if (z->key<y->key) {
      y->left=z;
    }
    else {
      y->right=z;
    }
  }
}
void inorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  inorder(u->left);
  cout<<" "<<u->key<<flush;
  inorder(u->right);
}
void preorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  cout<<" "<<u->key<<flush;
  preorder(u->left);
  preorder(u->right);
}
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    string com;
    cin>>com;
    if (com=="insert") {
      int x;
      cin>>x;
      insert(x);
    }
    else if (com=="print") {
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    } else {
      int x;
      cin>>x;
      Node *t=find(root,x);
      if (t!=NIL) {
        cout<<"yes"<<endl;
      }
      else {
        cout<<"no"<<endl;
      }
    }
  }
  return 0;
}


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

int main() {
	
  	vector<char> vec(6);
  
  	for(int i = 0; i < 6; i++){
  	cin >> vec.at(i);
    }
  
  	bool can = true;
  	for(int i = 0; i < 3;i++) {
    	if(vec.at(i) != vec.at(5 - i)) {
        	can = false;
        }
    }
  
  	if(can) {
    	cout << "YES" << endl;
    }else {
    	cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from collections import deque

def main():
    N, M, Q = map(int, readline().rstrip().split())
    P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
    ans = 0
    l = [[i] for i in range(1, M+1)]
    que = deque(l)
    for i in range(N):
        for _ in range(len(que)):
            ll = que.popleft()
            for j in range(ll[-1], M+1):
                que.append(ll + [j])
    
    for pair in que:
        score = 0
        for a, b, c, d in P:
            if pair[b-1] - pair[a-1] == c:
                score += d
        ans = max(ans, score)
    
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;
using ld = long double;
using ll = long long;

int main() {
    cout.precision(20);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        v[x]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << v[i] << '\n';
    }
}

Measured memory_bytes: 4048
n = int(input())
shop = [] # 10
profit = [] # 11
for i in range(n):
    shop.append(list(map(int,input().split())))
for i in range(n):
    profit.append(list(map(int,input().split())))
cond = [bin(i)[2:].zfill(10) for i in range(1,2**10)]
ans = -int(1e15)
for i in range(len(cond)):
    pro_cnt = 0
    tar = cond[i]
    for j in range(n):
        tar_shop = shop[j]
        cnt = 0
        for k in range(10):
            if int(tar[k]) & tar_shop[k] == 1:
                cnt += 1
        pro_cnt += profit[j][cnt]
    ans = max(ans, pro_cnt)
print(ans)









Measured memory_bytes: 41580
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[2000];
int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    REP(i,N){
        ll a;
        cin >> a;
        if(i == 0)
            A[i] = a;
        else
            A[i] = a + A[i-1];
    }

    vector<ll> sum;
    for(int i = -1; i < N; i++){
        for(int k = i+1; k < N; k++){
            if(i == -1)
                sum.push_back(A[k]);
            else
                sum.push_back(A[k] - A[i]);
        }
    }
    //cout << sum.size() << endl;

    //sort(sum.begin(), sum.end(), greater<ll>());

    //for(int i = 0; i < sum.size(); i++){
    //    printf("%d : %lld\n", i, sum[i]);
    //}

    bool find = false;
    //ll ans = (1LL << 40) - 1;
    ll ans = 0;
    vector<ll> tmp[100];
    for(int i = 63; i >= 0; i--){
        int num = 0;
        for(int s = 0; s < sum.size(); s++){
            ll x = sum[s];
            //printf("%lld ", x);
            if(((x >> i) & 1) == 0) continue;
            else{
                tmp[i].push_back(x);
                num++;
            }
        }
        //printf("\n");
        if(num >= K){
            sum = tmp[i];
            ans += (1LL << i);
        }

    }

    //if(find)
    //    cout << ans << endl;
    //else
    //    cout << 0 << endl;
        cout << ans << endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

ll a[100010];


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

	ll ans = 1LL << 60;

	rep(j,2){
		ll cur = 0LL , sum = 0LL;
		rep(i,n){
			sum += a[i];
			const int sign = (i + j) % 2;

			if(sign){
				if(sum >= 0){
					cur += sum + 1;
					sum = -1LL;
				}
			}else{
				if(sum <= 0){
					cur += 1 - sum;
					sum = 1LL;
				}
			}

		}
		chmin(ans,cur);
	}

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

Measured memory_bytes: 1024
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($N,$A,$B) = explode(" ",trim(fgets(STDIN)));
//$a[] = array_map('intval',explode(" ",trim(fgets(STDIN))));

$p = intdiv($N , ($A+$B));
$amari = $N % ($A+$B);

$sumb = $p*$A;
$sumb += min($A,$amari);

printf("%d\n",$sumb);


Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N,sum,mi,ma,a;
	while(cin>>N){
		if(N==0) break;
		sum=0;
		ma=0;
		mi=1001;
		for(int i=0;i<N;i++){
			cin>>a;
			mi=min(mi,a);
			ma=max(ma,a);
			sum=sum+a;
		}
		cout<<(sum-mi-ma)/(N-2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

//Dropping Ink
public class Main{

	public static int[][] map;
	public static boolean[][] used;
	public static int[][] move = {{0,1},{1,0},{-1,0},{0,-1}};
	public static int[][] move2 = {{1,1},{1,-1},{-1,1},{-1,-1}};
	public static int dx;
	public static int dy;
	public static int d;
	
	public static void f(int x, int y, int z){
		if(!(0<=x&&x<10&&0<=y&&y<10))return;
		if(Math.abs(dx-x)+Math.abs(dy-y)>z)return;
		if(used[x][y])return;
		map[x][y]++;
		used[x][y] = true;
		for(int k=0;k<4;k++){
			f(x+move[k][0], y+move[k][1], z);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		map = new int[10][10];
		while(sc.hasNext()){
			String[] s = sc.next().split(",");
			dx = Integer.parseInt(s[0]);
			dy = Integer.parseInt(s[1]);
			d = Integer.parseInt(s[2]);
			used = new boolean[10][10];
			f(dx, dy, (d==3?2:1));
			if(d==2){
				for(int k=0;k<4;k++){
					int x = dx+move2[k][0];
					int y = dy+move2[k][1];
					if(0<=x&&x<10&&0<=y&&y<10)map[x][y]++;
				}
			}
		}
		int c = 0;
		int max = 0;
		for(int x=0;x<10;x++){
			for(int y=0;y<10;y++){
				c+=map[x][y]==0?1:0;
				max = Math.max(max, map[x][y]);
			}
		}
		System.out.println(c);
		System.out.println(max);
	}
}

Measured memory_bytes: 11000
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
ll dd[mm];
map<string,ll>name; 
int main()
{
	ll n,k,i,j,m,t,a,b,c;
	cin>>a>>b;
	k=-1;
	for(i=0;i<=100000;i++)
	{
		if(floor(i*0.08)==a&&floor(i*0.1)==b)
		{
		k=i;break;}
		
	}
	cout<<k<<endl;
	
	
    
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] mtx = new int[N][N];

    for (int i = 0; i < N; i++) {
      String s = sc.next();
      for (int k = 0; k < s.length(); k++) {
        mtx[i][k] = Integer.parseInt(s.charAt(k)+"");
      }
    }

    int ans = -1;
    for (int i = 0; i < N; i++) {
      List<List<Integer>> vList= bfs(mtx,i);
      if(vList!=null){
        ans = Math.max(ans,vList.size());
      }
    }
    System.out.println(ans);
  }
static
  private List<List<Integer>> bfs(int[][] mtx, int i){

    int N = mtx.length;
    List<List<Integer>> list = new ArrayList<>(1000);
    boolean[] visited = new boolean[N];
    Queue<int[]> q = new LinkedList<>();
    int[] node= {i,0};
  visited[i] = true;
    q.offer(node);

    while(!q.isEmpty()){
      int[] nextNode = q.remove();

      int next= nextNode[0];
      int step = nextNode[1]; // Vi

      if(list.size()==step){
        list.add(step,new ArrayList<>());
      }
      list.get(step).add(next);

      for (int j = 0; j < N ; j++) {
        int adj = mtx[next][j];
        if(adj ==1 && !visited[j]){
          int[] adjNode= {j,step+1};
          visited[j] = true;
          q.offer(adjNode);
        }
      }
    }

    //Verify the self connected in Vi
    for (int j = 0; j < list.size(); j++) {//each V
      List<Integer> l = list.get(j);
      for (int k = 0; k < l.size() ; k++) {
        for (int m = k+1; m < l.size() ; m++) {
          if(mtx[l.get(k)][l.get(m)] == 1){
            return null;
          }
        }
      }
    }
    return list;
  }


}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<vector<bool> > cards(4,vector<bool>(13,false));
    string mark = "SHCD";
    int innum;
    char inmrk;
    for (int i = 0; i < n; i++)
    {
        cin >> inmrk >> innum;
        for(int j = 0 ; j < 4 ; j++)
            if(inmrk == mark[j])
                cards[j][innum - 1] = true;
    }

    for(int j = 0 ; j < 4 ; j++)
        for(int i = 0 ; i < 13 ; i++)
            if(cards[j][i] == false)
                cout << mark[j] << " " << (i + 1) << endl;
    
  
    return 0;
}


Measured memory_bytes: 3176
import sys

ERROR_INPUT = 'input is invalid'
OPECODE = ['+', '-', '*']
STACK = []


def main():
    inp = get_input()
    print(calc_stack(li=inp))


def calc_stack(li):
    if li[0] in OPECODE:
        ans = calc(left=STACK[-2], right=STACK[-1], ope=li[0])

        del li[0]
        if not li:
            return ans

        STACK.pop()
        STACK.pop()
        STACK.append(ans)

        return calc_stack(li=li)

    else:
        STACK.append(int(li[0]))
        del li[0]
        return calc_stack(li=li)


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp


main()

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

int main() {
	std::string S;
	std::cin >> S;

	int w;
	std::cin >> w;

	std::string result = "";

	for(int i = 0; i < S.size(); i += w) {
		result += S.at(i);
	}
	
	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var as []int

func main() {
	N := ReadInt()
	as = ReadInts(N)
	for i := 0; i <= N; i++ {
		for j := 0; j <= N; j++ {
			memo[0][i][j] = Undef
			memo[1][i][j] = Undef
		}
	}
	fmt.Println(solve(0, 0, N))
}

const Undef = math.MinInt32

var memo [2][3001][3001]int

func solve(turn, i, j int) int {
	if i == j {
		return 0
	}
	if memo[turn][i][j] != Undef {
		return memo[turn][i][j]
	}
	if turn == 0 {
		memo[turn][i][j] = Max(
			as[i]+solve(1^turn, i+1, j),
			as[j-1]+solve(1^turn, i, j-1),
		)
	} else {
		memo[turn][i][j] = Min(
			-as[i]+solve(1^turn, i+1, j),
			-as[j-1]+solve(1^turn, i, j-1),
		)
	}
	return memo[turn][i][j]
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 143424
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,a,b=mii()

if n==2 and a==1 and b==2:
    print(0)
    exit()


def p_f(a,n,p):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res
def nCk(n, k, mod=10 ** 9 + 7):
    if n < k:
        return 0
    k = min(k, n - k)
    numer = 1
    for x in range(n - k + 1, n + 1):
        numer = (numer * x) % mod
    denom = 1
    for x in range(1, k + 1):
        denom = (denom * x) % mod
    return numer * pow(denom, mod - 2, mod) % mod
 

ans=(p_f(2,n,mod) -1)%mod -nCk(n,a,mod)%mod - nCk(n,b,mod)%mod
print(ans%mod) 

Measured memory_bytes: 63852
n,k,q = map(int,input().split())
a_dict = {}
for i in range(n):
    a_dict[i+1] = 0
for _ in range(q):
    a = int(input())
    a_dict[a] += 1
ls = sorted(a_dict.items(), key=lambda x: x[0])
for item in ls:
    if item[1] > q - k:
        print('Yes')
    else:
        print('No')

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

const ll mod = 1000000007;

ll powmod(ll n, ll k, ll m) {
  if (k == 0) return 1;
  ll t = powmod(n, k / 2, m);
  t = (t * t) % m;
  if (k % 2 == 1)
    t = (t * n) % m;
  return t;
}

int main() {
  int n;
  cin >> n;
  int zero = 0;
  map<pair<ll, ll>, pair<int, int>> vct;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      zero++;
      continue;
    }
    ll g = gcd(a, b);
    a /= g, b /= g;
    if (a == 0 || b == 0) a = abs(a), b = abs(b);
    if (b < 0) a = -a, b = -b;
    if (a <= 0) {
      ll tmp = -a;
      a = b, b = tmp;
      vct[make_pair(a, b)].second++;
    } else
      vct[make_pair(a, b)].first++;
  }
  ll prod = 1;
  for (auto it : vct) {
    ll sum = powmod(2, it.second.first, mod) + powmod(2, it.second.second, mod) - 1;
    sum %= mod;
    prod = (prod * sum) % mod;
  }
  prod += zero - 1;
  if (prod < 0) prod += mod;
  cout << prod << endl;
  return 0;
}


Measured memory_bytes: 16076
// Contest: AtCoder Beginner Contest 173 (https://atcoder.jp/contests/abc173)
// Problem: B: Judge Status Summary (https://atcoder.jp/contests/abc173/tasks/abc173_b)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    map<string, int> m;
    int n; cin >> n;
    rep(i, n) {
        string s; cin >> s;
        m[s]++;
    }

    using namespace std::string_literals;
    for (auto s : {"AC"s, "WA"s, "TLE"s, "RE"s})
        cout << s << " x " << m[s] << '\n';

    return 0;
}


Measured memory_bytes: 3632