akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;
const int MAX_V = 110;
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n; cin >> n;
	map<int, int>mp;
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		for (auto p : prime_factor(i)) {
			while (p.second--) {
				mp[p.first]++;
			}
		}
	}
	for (int i = 1; i <= 1010; i++) {
		ans *= (mp[i] + 1); ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>

using namespace std;
int main()
{
    int x;
    cin >> x;
    for (int i = 9; i > 1; i--)
    {
        if (x >= 200 * i)
        {
            cout << 10 - i << endl;
            break;
        }
    }

    return 0;
}

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

int main() {
    int n, m;
    while (cin >> n >> m, n | m) {
        map<int, int> mp;
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            mp[a] = max(mp[a], b);
        }
        int sum = 0;
        for (auto e : mp) sum += e.second;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<=0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
if memo!=[]:
    pie=(sum-memo[-1])
else:
    pie=(sum-tasteab[0])
print(pie)

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a.at(i);
    }

    queue<int> block;
    rep(i, n)
    {
        block.push(a.at(i));
    }
    int number = 1;
    int times = 0;
    rep(i, n)
    {
        if (block.front() == number)
        {
            number++;
            block.pop();
        }
        else
        {
            times++;
            block.pop();
        }
    }
    if (number == 1)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << times << endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;

int n,d1[100005],d2[100005],F,S;
vector <int> v[100005];
bool b[100005];

inline void dfs1(int x,int p,int dist)
{
	d1[x]=dist;
	for (int i=0;i<v[x].size();i++)
	{
		int tx=v[x][i];
		if (tx==p) continue;
		if (tx==n)
		{
			d1[tx]=dist+1;
			continue;
		}
		dfs1(tx,x,dist+1);
	}
}

inline void dfs2(int x,int p,int dist)
{
	d2[x]=dist;
	for (int i=0;i<v[x].size();i++)
	{
		int tx=v[x][i];
		if (tx==p) continue;
		if (tx==1)
		{
			d2[tx]=dist+1;
			continue;
		}
		dfs2(tx,x,dist+1);
	}
}

inline int dfs(int x,int p,int dist)
{

	if (dist==0) return x;	b[x]=true;
	for (int i=0;i<v[x].size();i++)
	{
		int tx=v[x][i];
		if (tx==p || d1[tx]==-1 || d2[tx]==-1 || (d1[tx]+d2[tx]!=d1[n])) continue;
		return dfs(tx,x,dist-1);
	}
}

inline int Count(int x,int p)
{
	int res=1;
	for (int i=0;i<v[x].size();i++)
	{
		int tx=v[x][i];
		if (tx==p || b[tx]) continue;
		res+=Count(tx,x);
	}
	return res;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].PB(y);
		v[y].PB(x);
	}
	memset(d1,-1,sizeof(d1));
	memset(d2,-1,sizeof(d2));
	dfs1(1,-1,0);
	dfs2(n,-1,0);
//	for (int i=1;i<=n;i++) cout<<d2[i]<<" ";
	int node=dfs(1,-1,d1[n]/2+1);
//	if (d1[n]%2)
	S=Count(node,-1);
	F=n-S;
	if (F>S) puts("Fennec"); else puts("Snuke");
	return 0;
}

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

//学生の座標とチェックポイントの座標のマンハッタン距離を返す関数
int dst(int a, int b, int c, int d){
  int x, y;
  if (a>c) x = a-c;
  else x = c-a;
  if (b>d) y = b-d;
  else y = d-b;
  return x+y;
}

int main() {
  int n, m; cin >>n >>m;
  vector<int> a(n), b(n), c(m), d(m);
  for (int i=0; i<n; i++) cin >>a.at(i) >>b.at(i);
  for (int i=0; i<m; i++) cin >>c.at(i) >>d.at(i);
  
  for (int i=0; i<n; i++){
    int dstmin = 999999999;
    int chkmin;
    for (int j=0; j<m; j++){
      int distance = dst(a.at(i),b.at(i),c.at(j),d.at(j));
      if (distance < dstmin){
        dstmin = distance;
        chkmin = j+1;
      }
    }
    cout <<chkmin <<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int A[1005],B[1005];
int C[1005][13];
set<int> U;
int dp[1005][4097];

signed main(){
	cin>>N>>M;
	REP(i,M){
		cin>>A[i]>>B[i];
		REP(j,B[i]){
			cin>>C[i][j];
			U.insert(C[i][j]);
		}
	}
	if(U.size()!=N){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,1005)REP(j,4097){
		dp[i][j]=INF;
	}
	REP(i,4097){
		dp[0][0]=0;
	}
	int b=0;
	REP(i,B[0]){
		b|=(1<<(C[0][i]-1));
	}
	dp[0][b]=A[0];
	for(int i=1;i<M;i++){
		b=0;
		REP(j,B[i]){
			b|=(1<<(C[i][j]-1));
		}
		DEB(b)END
		for(int j=0;j<=4096;j++){
			if(dp[i-1][j]!=INF){
				dp[i][j]=min(dp[i][j],dp[i-1][j]);
				dp[i][j|b]=min(dp[i-1][j]+A[i],dp[i][j|b]);
				if(j|b==15){
					DEB(dp[i-1][13])DEB(dp[i][15])DEB((13|14))END
				}
			}
		}
		DEB(dp[i-1][13])DEB(dp[i][15])DEB((13|14))END
	}
	b=0;
	REP(i,N){
		b|=(1<<i);
	}
	cout<<dp[M-1][b]<<endl;
	return 0;
}


Measured memory_bytes: 32512
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll a[n+1];
	for(ll i=1; i<=n; i++){
		cin >> a[i];
		a[i]-=i;
	}
	sort(a+1, a+n+1);
	ll x=a[(n+1)/2], min=0;
	for(ll i=1; i<=n; i++){
		min+=abs(x-a[i]);
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll a, b; cin >> a >> b;
  if (a * b <= 0) cout << "Zero\n";
  else if (b < 0 && (b-a+1)%2) cout << "Negative\n";
  else cout << "Positive\n";
  return 0;
}


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


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

 int64_t M;

 for(int64_t i=1;i<=N;i++){
   M=N/i;
   if(i>M){
     cout << (i-1)*(i-1) << endl;
     break;
   }
   else if(i==M){
     cout << i*i << endl;
     break;
   }

 }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
using namespace std;
int main()
{
    int n;
    cin>>n;
    rep(k,n)
    {
        string s1,s2,temp;
        cin>>s1; cin>>s2;
        if(s1.size()<s2.size()){temp=s1;s1=s2;s2=temp;}
        int d = s1.size()-s2.size();
        rep(i,d){ s2 = "0" + s2;}
        //cout << s1<<"\n"<<s2<<endl;
        int ku=0;
        for(int i=s1.size()-1;i>-1;i--)
        {
            int next =0;
            if( (int)(s2[i]-'0'+s1[i]-'0')+ku >= 10){next = 1;}
            s1[i] =(( (int)(s2[i]-'0'+s1[i]-'0' ) +ku) % 10 + '0');
            ku = next;
            //cout << s1[i];
        }
        if(ku+s1.size()>80){cout <<"overflow"<<endl;continue;}
        if(ku)cout<<1;
        cout << s1<<endl;

    }
    return 0;
}

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

ll F[300010], I[300010];
ll A_AB[300010], B_AB[300010];

ll modpow(ll a, ll b) {
	ll ans = 1;
	while(b){
		if (b & 1) {
			ans = a * ans % MOD;
		}
		a = a * a % MOD;
		b /= 2;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	return F[n] * I[r] % MOD * I[n - r] % MOD;
}

int main() {
	F[0] = I[0] = 1;
	for (ll i = 1;i < 300010;i++) {
		F[i] = F[i - 1] * i % MOD;
		I[i] = modpow(F[i], MOD - 2);
	}
	ll N, A, B, C;
	cin >> N >> A >> B >> C;
	A_AB[0] = B_AB[0] = 1;
	ll IAB = modpow(A + B, MOD - 2);
	for (int i = 1;i <= N;i++) {
		A_AB[i] = A_AB[i - 1] * A % MOD * IAB % MOD;
		B_AB[i] = B_AB[i - 1] * B % MOD * IAB % MOD;
	}
	ll ans = 0, cnta = 0, cntb = 0;
	ll ep = 100 * modpow(100 - C, MOD - 2) % MOD;
	for (ll i = 0;i < N;i++) {
		cnta = ep * (N + i) % MOD
			* A_AB[N] % MOD
			* B_AB[i] % MOD
			* nCr(N + i - 1, i) % MOD;
		cntb = ep * (N + i) % MOD
			* B_AB[N] % MOD 
			* A_AB[i] % MOD
			* nCr(N + i - 1, i) % MOD;
		ans += cnta + cntb;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9860
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S,T;
    cin >> S >> T;
    bool rg=true;
    if(S.size()+1!=T.size())rg = false;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i]!=T[i]){
            rg = false;
            break;
        }
    }
    if(rg)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3652
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
const int mod = 1000000007;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
using namespace std;
ll gcd(ll x, ll y) {
	if (max(x, y) % min(x, y) == 0)return min(x, y);
	else return gcd(max(x, y) % min(x, y), min(x, y));
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
int get(int n) {
	string s;
	cout << n << endl<<flush;
	cin >> s;
	if (s == "Vacant")exit(0);
	else if (s == "Male")return 0;
	else return 1;
}
int main() {
	ll n; cin >> n;	
	ll l = 0, r = n - 1, m, v[100000] = {};
	v[0]=get(0);
	v[n - 1] = get(n - 1);
	while (1) {
		if(r-l<2){
			v[l]=get(l);
			v[r]=get(r);
		}
		m = (l + r) / 2;
		v[m] = get(m);
		if (v[m] == v[0]) {
			if (m % 2 == 0)l = m;
			else r = m;
		}
		if (v[m] == v[n - 1]) {
			if (m % 2 == 0)r = m;
			else l = m;
		}
	}
	return 0;
}


Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;  
int n,m,p[20],v[20];
string s[20];
bool chk()
{
	memset(v,0,sizeof(v));
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(v[i]||v[j]||i==j)continue;
			int f=1;
			for(int k=0;k<n;k++)if(s[p[k]][i]!=s[k][j])
			{
				f=0;
				break;
			}
			if(f)v[i]=v[j]=1;
		}
	}
	int cc=0,t=0;
	for(int i=0;i<m;i++)if(!v[i])cc++,t=i;
	if(!cc)return true;
	if(cc>=2||m&1==0)return false;
	for(int i=0;i<n;i++)if(s[p[i]][t]!=s[i][t])return false;
	return true;
}
void dfs(int x,int v)
{
	if(x==(n+1)/2)
	{
		if(chk()){puts("YES");exit(0);}
		return;
	}
	for(int i=x;i<n;i++)
	{
		for(int j=i+1;j<n;j++)if(p[i]==-1&&p[j]==-1)
		{
			p[i]=j;p[j]=i;
			dfs(x+1,v);
			p[i]=-1;p[j]=-1;;
		}
		if(v&&p[i]==-1)
		{
			p[i]=i;
			dfs(x+1,false);
			p[i]=-1;
		}
	}
}
int main()  
{  
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){cin>>s[i];p[i]=-1;}  
    dfs(0,n&1);
	printf("NO\n");
    return 0;
}

Measured memory_bytes: 384
import itertools

n=int(input())

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

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

lis=[]
for i in list(itertools.product([0,1],repeat=10))[1:]:
    lisi=0
    for j in range(n):
        sj=0
        for k in range(10):
            sj+=i[k]*f[j][k]
        lisi+=p[j][sj]
    lis.append(lisi)

print(max(lis))

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

int main(void){
  int A, B ,C, X;
  cin >> A >> B >> C >> X;
  
  int count = 0; //record the answer
  
  for (int a = 0; a <= A; a++){
    for (int b = 0; b <= B; b++){
      for (int c = 0; c <= C; c++) {
        int total = 500 * a + 100 * b + 50 * c;
        if (total == X) {
          count++;   
        }
      }  
    }    
  }
  
  cout << count << endl;
  
}

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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;   //人数
            int s;//必要な枚数
            int i;
            //人数を入力
            n = int.Parse(Console.ReadLine());
            //必要な枚数を求める
            //（合計を求めるメルアルゴリズム）
            s = 0;    //合計を0に初期化
             for (i=1; i<=n;  i++)　//i→0の繰り返し
            {
                s = s + i;　// sを1増やす
            }

             //出力
            Console.WriteLine(s);
        }
    }
}


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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }



int main() {
    int n;
    cin >> n;
    auto v = make_v(n, n, 0);
    auto dp = make_v(n, n, 0);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < n; ++j) {
            v[i][j] = s[j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(i == 0 || j == 0){
                int issym = 1;
                for (int k = 0; k < n; ++k) {
                    for (int l = k; l < n; ++l) {
                        if(v[(k+i)%n][(l+j)%n] != v[(l+i)%n][(k+j)%n]){
                            issym = 0;
                            k = l = n;
                        }
                    }
                }
                dp[i][j] = issym;
            }else {
                dp[i][j] = dp[i-1][j-1];
            }
            ans += dp[i][j];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
n = input()

if int(n[-1]) == 2 or int(n[-1]) == 4 or int(n[-1]) == 5 or int(n[-1]) == 7 or int(n[-1]) == 9:
    print('hon')
elif int(n[-1]) == 0 or int(n[-1]) == 1 or int(n[-1]) == 6 or int(n[-1]) == 8:
    print('pon')
else:
    print('bon')

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

int main()
{
	int n;
	cin >> n;
	vector<int> X(n);
	for (int i = 0; i < n; i++)  cin >> X[i];

	int ans = int(1e9);
	for (int i = 0; i <= 100; i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			sum += (X[j] - i) * (X[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

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

using namespace std;

#define B       (cout << "Sehen Sie mich!" << endl)
#define VB(val) (cout << val << endl)

inline int ctoi(const char c){
        if('0' <= c && c <= '9') return (c -'0');
        return -1;
}

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

        for (int i = 0; i <= 1; i++) {
                for (int j = 0; j <=1; j++) {
                        for (int k = 0; k <= 1; k++) {
                                int res = 0;
                                char cstr[4] = {n[0], n[1], n[2], n[3]};
                                char ops[3];
                                string ret = "";
                                if (i == 0) {
                                        res = ctoi(cstr[0]) + ctoi(cstr[1]);
                                        ops[0] = '+';
                                } else {
                                        res = ctoi(cstr[0]) - ctoi(cstr[1]);
                                        ops[0] = '-';
                                }
                                if (j == 0) {
                                        res += ctoi(cstr[2]);
                                        ops[1] = '+';
                                } else {
                                        res -= ctoi(cstr[2]);
                                        ops[1] = '-';
                                }
                                if (k == 0) {
                                        res += ctoi(cstr[3]);
                                        ops[2] = '+';
                                } else {
                                        res -= ctoi(cstr[3]);
                                        ops[2] = '-';
                                }
                                if (res == 7) {
                                        //ret += cstr[0] + ops[0] + cstr[1]
                                        //      + ops[1] + cstr[2] + ops[2] + cstr[3] + "=7";
                                        ret += {cstr[0], ops[0], cstr[1], ops[1],
                                                         cstr[2], ops[2], cstr[3]};
                                        ret += "=7";
                                        VB(ret);
                                        return 0;
                                }
                        }
                }
        }
}

Measured memory_bytes: 256
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}


int main(){
  int a,b;
  cin >> a >> b;
  if (13 <= a)cout << b << endl;
  else if (6 <= a && a <= 12)cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
def kaibun(a):
    l = len(a)
    aa = a.copy()
    aa.reverse()
    D = True
    for i in range(l//2):
        if a[i] != aa[i]:
            D = False
            break
    return D



S = list(input())

ans = "No"

if (kaibun(S)) & (kaibun(S[:len(S)//2])) & (kaibun(S[(len(S) + 1)//2:])):
    ans = "Yes"

print(ans)



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

int main() {
  int n, k = 0;
  cin >> n;
  vector<int> a(n - 1), b(n - 1), c(n - 1, -1);
  vector<vector<pair<int, int>>> r(n, vector<pair<int, int>>());
  for(int i = 0; i < n - 1; i++) {
    cin >> a.at(i) >> b.at(i);
    r.at(--a.at(i)).push_back({--b.at(i), i});
    r.at(b.at(i)).push_back({a.at(i), i});
  }
  for(int i = 0; i < n; i++)
    k = max(k, (int)r.at(i).size());
  queue<pair<int, int>> que;
  pair<int, int> p;
  for(int i = 0; i < r.at(0).size(); i++) {
    que.push(r.at(0).at(i));
    c.at(r.at(0).at(i).second) = i;
  }
  while(que.size()) {
    p = que.front();
    que.pop();
    int col = 0;
    for(int i = 0; i < r.at(p.first).size(); i++) {
      if(r.at(p.first).at(i).second == p.second)
        continue;
      if(c.at(p.second) == col)
        col++;
      que.push(r.at(p.first).at(i));
      c.at(r.at(p.first).at(i).second) = col;
      col++;
    }
  }
  cout << k << endl;
  for(int i = 0; i < n - 1; i++)
    cout << c.at(i) + 1 << endl;
}

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    ll s = 0;
    rep(i, n){
        cin >> a[i];
        s += a[i];
    }

    ll MIN = 2002002002002002002;
    ll s_=0;
    rep(i, n){
        s_ += a[i];
        if(i<n-1){
            MIN = min(MIN, abs(s_-(s-s_)));
        }
    }
    cout << MIN << endl;
    // printf("%d\n", N);
    return 0;
}

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

int main(){
  vector<int> box(3);
  vector<int> swap(3);
  for(int i=0;i<3;i++){
    cin >> box[i];
  }
  swap[0]=box[2];
  swap[1]=box[0];
  swap[2]=box[1];
  
  cout << swap[0] << " " << swap[1] << " " << swap[2] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
#define println std::cout << std::endl;
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n, m;
	std::cin >> n >> m;
	std::vector<std::vector<int>> q(n);
	for (int i = 0, x, y; i < m; ++i) {
		std::cin >> x >> y;
		--x; --y;
		q[x].emplace_back(y);
		q[y].emplace_back(x);
	}
	std::vector<bool> vis(n);
	std::function<void(int)> dfs = [&](int u) -> void {
		vis[u] = 1;
		for (auto x : q[u]) if (!vis[x]) {
			dfs(x);
		}
	};
	int r = -1;
	for (int i = 0; i < n; ++i) if (!vis[i]) {
		dfs(i);
		++r;
	}
	print(r);
	return 0;
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    ll w, h, n; cin >> w >> h >> n;
    ll bt=0, top=h, left=0, right=w;
    REP(i, n){
        ll x, y, a;   cin >> x >> y >> a;
        
        if(a==1)    left = max(x, left);
        else if(a==3) bt = max(y, bt);
        else if(a==2) right=min(x, right);
        else top = min(y, top);
    }
    ll res = max(0LL, top-bt)*max(0LL, right-left);
    cout << res << endl;
    
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
int main(){

    ll N;
    cin >> N;

    //map<ll, ll> mp; 
    vector<ll > K(200019, 0);
    vector<ll > C(200019, 0);
    vector<ll > C_1(200019, 0);

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
        K[t]++;
    }

    ll sum = 0;
    for(ll i = 1; i <= N; i++){
        C[i] = K[i] * (K[i]-1) / 2;
        C_1[i] = (K[i]-1) * (K[i]-2) / 2;
        sum += C[i];
    }    

    for(ll i = 0; i < vec.size(); i++){
        //cout << ";" << vec[i-1] << endl;
        cout << sum - C[vec[i]] + C_1[vec[i]] << endl;;
    }    
    //set<ll > 
    
}

Measured memory_bytes: 8944
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12);
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED
    string s;
    cin >> s;
    int c=0;
    if(s[0]=='A')
    {
        if('Z'-s[1]>=0)
        {
            //cout << "a";
            goto end;
        }
        for(int i=2;i<s.size()-1;++i)
        {
            if(s[i]=='C')
            {
                ++c;
                continue;
            }
            if('Z'-s[i]>=0)
            {
                //cout << "b";
                goto end;
            }
        }
        if('Z'-s[s.size()-1]>=0)
        {
            //cout << "c";
            goto end;
        }
    }
    if(c==1)
    {
        cout << "AC" << endl;
        return 0;
    }
    end:
    cout << "WA" << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 100;

int N;
pair<int, int> red[MAX];
pair<int, int> blue[MAX];
vector<int> G[MAX * 2];
int m[MAX * 2];
bool used[MAX * 2];

bool match(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		if (m[G[v][i]] == -1 || (!used[m[G[v][i]]] && match(m[G[v][i]]))) {
			m[v] = G[v][i];
			m[G[v][i]] = v;
			return true;
		}
	}
	return false;
}

int main() {
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> red[i].first >> red[i].second;
	}
	for (int i = 0; i < N; i++) {
		cin >> blue[i].first >> blue[i].second;
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
				G[i].push_back(j + N);
				G[j + N].push_back(i);
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < MAX * 2; i++)m[i] = -1;

	for (int i = 0; i < N * 2; i++) {
		for (int j = 0; j < MAX * 2; j++)used[j] = false;
		if (m[i] == -1 && match(i))ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;


int main() {
ll x;
  in(x);
 ll ans=0;
  ll wa =100;
while(x>wa){
  wa *= 1.01;
  //out(wa);
 ans++; 
}
  out(ans);
}


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

char day[][4] = {
                 "thu",
                 "fri",
                 "sat",
                 "sun",
                 "mon",
                 "tue",
                 "wed"
};

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

    cout << day[x % 7] << endl;

    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<double> x(n), y(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i];
    }

    std::vector<int> route(n);
    for (int i = 0; i < n; i++) {
        route[i] = i;
    }

    double sum = 0;
    int count = 0;
    do {
        for (int i = 1; i < n; i++) {
            int p = route[i - 1], q = route[i];
            sum += std::sqrt(
                (x[p] - x[q]) * (x[p] - x[q])
                + (y[p] - y[q]) * (y[p] - y[q])
            );
        }
        count++;
    } while (std::next_permutation(route.begin(), route.end()));

    std::cout << std::fixed << std::setprecision(8) << sum / count << std::endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
result=[]
for i in range(n-k):
    if a[i]<a[i+k]:
        result.append('Yes')
    else:
        result.append('No')
for j in range(n-k):
    print(result[j])

Measured memory_bytes: 31612
#include <iostream>

int main(int argc, char const *argv[]) {
    using namespace std;
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int n;
    int a[100], b[100];
    cin >> n;
    rep(i, n - 1) cin >> b[i];

    rep(i, n) a[i] = INF;
    rep(i, n-1) {
        a[i + 1] = b[i];
        if (b[i] < a[i]) a[i] = b[i];
    }
    ll ans = 0;
    rep(i, n) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int X;
	cin >> X;
	vector<int> pow_number;
	pow_number.push_back(1);
	for (int i = 2; i <= sqrt(X); i++) {
		int tmp = i, p = 1;
		while (tmp <= X) {
			tmp *= i;
			p++;
		}
		pow_number.push_back(pow(i, p - 1));
	}

	int max_num = 0;
	for (int i = 0; i < (int)pow_number.size(); i++) {
		if (max_num < pow_number.at(i)) {
			max_num = pow_number.at(i);
		}
	}

	cout << max_num << endl;
}

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

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    int ans = n%10;
    if(ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9)
    cout << "hon";
    else if( ans == 0 || ans == 1 || ans == 6 || ans == 8)
    cout << "pon";
    else
    cout << "bon";
}









Measured memory_bytes: 3668
import javax.swing.text.TabableView;
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    static int minCost=Integer.MAX_VALUE;
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        InputReader in=new InputReader(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int x=in.nextInt();
        int cost[]=new int[n];
        int [][]val=new int[n][m];
        for(int i=0;i<n;i++){
            cost[i]=in.nextInt();
            for(int j=0;j<m;j++)
                val[i][j]=in.nextInt();
        }
        boolean []visit=new boolean[n];
        solve(0,visit,cost,val,x);
        if(minCost==Integer.MAX_VALUE)
            out.println(-1);
        else out.println(minCost);
        out.flush();
    }
    public static void solve(int n,boolean []visit,int cost[],int val[][],int x){
        if(n==visit.length){
            int totalval[]=new int[val[0].length];
            int spend=0;
            for(int i=0;i<n;i++){
                if(visit[i]){
                    spend+=cost[i];
                    for(int j=0;j<val[0].length;j++)
                        totalval[j]+=val[i][j];
                }
            }
            for(int i=0;i<val[0].length;i++)
                if(totalval[i]<x)
                    return;
            minCost=Math.min(spend,minCost);
            return;
        }
        solve(n+1,visit,cost,val,x);
        visit[n]=true;
        solve(n+1,visit,cost,val,x);
        visit[n]=false;
    }
    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            tokenizer = null;
        }
        public String next() throws IOException{
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
}

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

using namespace std;

class Dijkstra {
  using QItem = pair<int, int>;

 public:
  vector<int> minDistance(vector<array<int, 3>> edges, int n, int src) {
    vector<int> costs(n, -1);
    costs[src] = 0;

    // 各ノードの隣接ノードとその距離を初期化
    vector<map<int, int>> distances(n);
    for (auto &edge : edges) {
      int n1 = edge[0], n2 = edge[1], d = edge[2];
      distances[n1][n2] = d;
      distances[n2][n1] = d;
    }

    vector<bool> used(n, false);
    priority_queue<QItem, vector<QItem>, greater<QItem>> q;
    q.push({0, src});

    while (!q.empty()) {
      // 未確定で，コストの一番低いノードを選択する
      auto [min_cost, min_idx] = q.top();
      q.pop();

      // 選択したノードは確定とする
      used[min_idx] = true;

      // 選択したノードの隣接ノードについて，そのコストを再計算する
      auto dist = distances[min_idx];
      for (auto p : dist) {
        int new_cost = min_cost + p.second;
        if (costs[p.first] < 0 || costs[p.first] > new_cost) {
          costs[p.first] = new_cost;
          q.push({new_cost, p.first});
        }
      }
    }

    return costs;
  }
};

int main(int argc, const char *argv[]) {
  int n, m, r;
  cin >> n >> m >> r;

  vector<int> vr(r);
  for (int i = 0; i < r; ++i) {
    cin >> vr[i];
    vr[i]--;
  }

  vector<array<int, 3>> edges(m);
  for (auto &e : edges) {
    cin >> e[0] >> e[1] >> e[2];
    e[0]--;
    e[1]--;
  }

  vector<vector<int>> costs(r);

  // costs[i][j]: vr[i]からjまで移動するときのコスト
  Dijkstra dijkstra;
  for (int i = 0; i < vr.size(); ++i) {
    costs[i] = dijkstra.minDistance(edges, n, vr[i]);
  }

  // 順番を全探索
  vector<int> order(r);
  iota(order.begin(), order.end(), 0);

  int ans = -1;
  do {
    int cost_sum = 0;
    for (int i = 0; i < order.size() - 1; ++i) {
      cost_sum += costs[order[i]][vr[order[i + 1]]];
    }

    if (ans < 0 || cost_sum < ans) {
      ans = cost_sum;
    }
  } while (next_permutation(order.begin(), order.end()));

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 5748
import java.util.*;

class Main{
  public static double E(int s){
    double t=(double)(s);
    return (t+1)/2;
  }
  
  public static double sum(double[] s,int idxs,int idxe,int M){
    double ans=0.0;
    for(int i=idxs;i<idxe;i++){
      ans+=s[i];
    }
    return ans;
  }
  
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int K=sc.nextInt();
    double[] p=new double[N];
    
    for(int i=0;i<N;i++){
      p[i]=E(sc.nextInt());
    }
    
    double Answer=0.0;
    double summary=0.0;
    for(int i=0;i<K;i++){
      summary+=p[i];
    }
    Answer=summary;
    for(int i=0;i<N-K;i++){
      summary+=(p[K+i]-p[i]);
      if(summary>Answer) Answer=summary;
    }
    
    System.out.print(Answer);
  }
}


Measured memory_bytes: 82024
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int m=getInt(),f=getInt(),b=getInt();

		int v=Math.max(0,b-m);
		
		System.out.println(f<v?"NA":v);
	}
}

Measured memory_bytes: 26240
/* AOJ-ALDS1_1_D Maximum Profit */

#include <iostream>
#include <limits.h>

using namespace std;

const int N = 2e5;
int a[N];

int main()
{
    int n;

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

    int maxval = INT_MIN;
    int minval = a[0];
    for(int i=1; i<n; i++) {
        maxval = max(maxval, a[i] - minval);
        minval = min(minval, a[i]);
    }

    cout << maxval << endl;

    return 0;
}




Measured memory_bytes: 3884
#include <stdio.h>
int disabled_route[16][16];

int main(void){
	int dataset;
	scanf("%d", &dataset);

	while(dataset--){
		int gx, gy, matatabi;
		int x1, y1, x2, y2;
		int foo;
		for(x1=0;x1<16;x1++)
		for(y1=0;y1<16;y1++)
		disabled_route[x1][y1] = 0;

		scanf("%d", &gx);
		scanf("%d", &gy);
		scanf("%d", &matatabi);

		while(matatabi--){
			scanf("%d", &x1);
			scanf("%d", &y1);
			scanf("%d", &x2);
			scanf("%d", &y2);
			if(x1 > x2) {
				foo = x1;
				x1 = x2;
				x2 = foo;
			}else if(y1 >y2) {
				foo = y1;
				y1 = y2;
				y2 = foo;
			}
			disabled_route[x2][y2] += ( x1==x2 ? 1 : 2 );
		}

		if(foo = count(gx, gy)) printf("%d\n", foo);
		else printf("Miserable Hokusai!\n");
	}

	return 0;
}

int count(x, y){
	if(x==0 && y==0) return 1;
	switch(disabled_route[x][y]){
	  case 3:
		return 0;
	  case 2:
		return y ? count(x, y-1) : 0;
	  case 1:
		return x ? count(x-1, y) : 0;
	  case 0:
		return (y ? count(x, y-1) : 0) + (x ? count(x-1, y) : 0);
	}
}

/* note
1	vertical
2	horizontal
*/

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

int main() 
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll A,B;cin>>A>>B;
	if(A%2==0)
	{
		if((B-A+1) % 4 == 0)cout<<0;
		else if((B-A+1) % 4 == 1)cout<<B;
		else if((B-A+1) % 2 == 0)cout<<1;
		else cout<<(B ^ 1);
	}
	else
	{
		if((B-A) % 4 == 0)cout<<A;
		else if((B-A) % 4 == 1)cout<<(A ^ B);
		else if((B-A) % 2 == 0)cout<<(A ^ 1);
		else cout<<(A ^ (B ^ 1));
	}
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

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

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int a,b,c; cin >> a >> b >> c;
  
  if(a == b and b == c and a % 2 == 0){
    cout << -1 << endl;
    return 0;
  }

  int ans = 0;
  while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0){
    int x = (b + c) / 2, y = (c + a) / 2, z = (a + b) / 2;
    a = x; b = y; c = z;
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
	double a,b;

	while (cin >> a >> b) {
		if (a < 35.5 && b < 71.0 ) {
			cout << "AAA" << endl;
		} else if (a < 37.5 && b < 77.0) {
			cout << "AA" << endl;
		} else if (a < 40.0 && b < 83.0) {
			cout << "A" << endl;
		} else if (a < 43.0 && b < 89.0) {
			cout << "B" << endl;
		} else if (a < 50.0 && b < 105.0) {
			cout << "C" << endl;
		} else if (a < 55.0 && b < 116.0) {
			cout << "D" << endl;
		} else if (a < 70.0 && b < 148.0) {
			cout << "E" << endl;
		} else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

vector<int> g[N], ans;
bool bio[N];
int parent[N];

void dfs(int u) {
  bio[u] = true;
  for (int v: g[u]) {
    if (bio[v]) continue;
    dfs(v);
  }
  ans.push_back(u);
}

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int u, v, i = 0; i < n-1+m; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) {
    if (bio[i]) continue;
    dfs(i);
  }
  for (int u: ans)
    for (int v: g[u])
      if (!parent[v])
	parent[v] = u;
  for (int i = 1; i <= n; ++i) printf("%d\n", parent[i]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 13020
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was.get(k,0)
print(str(ac)+" "+str(wa))

Measured memory_bytes: 55896
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,dist[305][305]={},ans,a,b,c,q,l,now,tank[305][305]={},s,t;
  cin >> n >> m >> l;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i!=j) {
        dist[i][j]=INF;
        tank[i][j]=INF;
      }
    }
  }
  for(int i=0; i<m; i++) {
    cin >> a >> b >> c;
    a--,b--;
    dist[a][b]=dist[b][a]=c;
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<n; k++) {
        if(i!=j&&i!=k&&j!=k) {
          dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
        }
      }
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i!=j&&dist[i][j]<=l) {
        tank[i][j]=1;
      }
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<n; k++) {
        if(i!=j&&i!=k&&j!=k) {
          tank[j][k]=min(tank[j][k],tank[j][i]+tank[i][k]);
        }
      }
    }
  }
  cin >> q;
  while(q--) {
    cin >> s >> t;
    s--,t--;
    cout << (tank[s][t]==INF?-1:tank[s][t]-1) << endl;
  }
}

Measured memory_bytes: 2048