akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;

int d[400][400] = {};
int _d[11][11] = {};
int dp[1 << 11][11] = {};
int n;

int rec(int s, int v) {
    if(dp[s][v] >= 0) {
        return dp[s][v];
    }

    if(s == (1<<n) - 1 && v== 0) {
        return dp[s][v];
    }

    int res = 500000;
    for(int u = 0; u < n; u++) {
        if(!(s >> u & 1)) {
            res = min(res, rec(s | 1<<u, u) + _d[v][u]);
        }
    }
    return dp[s][v] = res;
}

int main() {
    while(true) {
        string c[20];
        int w,h;
        cin >> w >> h;
        if(w == 0 && h == 0) {
            break;
        }
        for(int i = 0; i < h; i++) {
            cin >> c[i];
        }

        int size = w*h;

        for(int i = 0; i < size; i++) {
            for(int j = 0; j < size; j++) {
                int ix = i%w, iy = i/w, jx = j%w, jy = j/w;
                if(i == j) d[i][j] = 0;
                else if(abs(ix - jx) +abs(iy - jy) == 1 && c[iy][ix] != 'x' && c[jy][jx] != 'x') d[i][j] = 1; 
                else d[i][j] = 50000; 
            }
        }
        for(int k = 0; k < size; k++) {
            for(int i = 0; i < size; i++) {
                for(int j = 0; j < size; j++) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }

        vector<int> v;
        int rob;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(c[i][j] == 'o') rob = j + (i*w);
                if(c[i][j] == '*') v.push_back(j + (i*w));
            }
        }

        bool unreached = false;

        for(int i = 0; i < v.size(); i++) {
            if(d[rob][v[i]] >= 50000) {
                cout << -1 << endl;
                unreached = true;
                break;
            }
            _d[0][i+1] = d[rob][v[i]];
            for(int j = 0; j < v.size(); j++) {
                _d[i+1][j+1] = d[v[i]][v[j]];
            }
        }
        if(unreached) {
            continue;
        }

        n = v.size() + 1;
        for(int i = 0; i <(1 << n); i++) {
            for(int j = 0; j < n; j++) {
                dp[i][j] = -1;
            }
        }

        cout << rec(0,0)+1 << endl;


    }

}


Measured memory_bytes: 3788
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

int main()
{
	ll n;
	cin >> n;
	ll sum = 0;
	while(n)
	{
		if(n%10 == 2)
			sum++;
		n /= 10;
	
	}
	cout << sum <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int solve(int x, int y, int z){
  vector<int> v(x);
  rep(i,x) cin>>v[i];
  vector<int> e(y+1,0), a(y+1);
  rep(i,z){
    int p,q,r;
    cin>>p>>q>>r;
    e[p] = q;
    a[p] = r;
  }

  vector<vector<double>> dp(y+1, vector<double>(5005, 0));
  dp[0][0] = 1;
  rep(i,y) rep(j,5005) if(dp[i][j]>0){
    rep(k,x){
      int ni = min(i+v[k],y);
      int nj = j;
      if(e[ni]==1) ni=min(ni+a[ni],y);
      else if(e[ni]==2) nj += a[ni];
      else if(e[ni]==3) nj = max(nj-a[ni], 0);
      dp[ni][nj] += dp[i][j]/x;
    }
  }

  double ret = 0;
  rep(i,5005) ret += dp[y][i]*i;
  return (int)ret;
}

int main(){
  int x,y,z;
  while(cin>>x>>y>>z, x|y|z){
    cout << solve(x,y,z) << endl;
  }

  return 0;
}

Measured memory_bytes: 4924
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

// pow
//int power(int a, int b){
	//int result = 1;
	//while(b>0){
		//if(b%2) result *= a;
		//a*=a;
		//b/=2;
	//}
	//return result;
//}

// rotate vector
//rotate(a.begin(),a.begin()+offset,a.end());

// next permutation - returns true if next permutation is lexigraphically greater else false
//while(next_permutation(all(s))) ans.insert(s);

// bitset way to simulate all subsets
// assume we have int a[n];
//for(int i = 0; i < 1<<n; ++i){
		 //bit set way to simulate every possible set
		//forn(j,0,n) if(i>>j&1) then a[j] is in cur set

// iota		
// int p[8];
// iota(p,p+8,0) --> {0,1,2,3,4,5,6,7}

// * note lowerbound is the same as upperbound but inclusive
// lower_bound finds value >= to given value
// to find a lowerbound/upper bound in unsorted list use set<pair<int,int>> 
// where the second element is the index
//auto itr = s.lower_bound({-t,0});
//if(itr == s.end()) cout << "-1\n";

// values in set are stored in increased order by default

// fast subarray sum using map
//void solve(){
	//int n,x; cin >> n >> x;
	//ll s = 0;
	//map<ll,int> mp;
	//++mp[0];
	//ll ans = 0;
	//forn(i,0,n){
		//int v; cin >> v;
		//s+=v;
		//ans+=mp[s-x];
		//++mp[s];
	//}
	//cout << ans;
//}

// 0-1 knapsack
//void solve(){
	 //x is maximum capacity, n is number of items
	//int n, x;
	//cin >> n >> x;
	//vector<int> weight(n), value(n);
	//forn(i,0,n) cin >> weight[i];
	//forn(i,0,n) cin >> value[i];
	//vector<vector<int>> dp(n+1,vector<int>(x+1,0));
	//forn(i,1,n+1){
		//forn(j,0,x+1){
			//dp[i][j] = dp[i-1][j];
			//int space = j-weight[i-1];
			//if(space >= 0) dp[i][j] = max(dp[i][j], dp[i-1][space]+value[i-1]);
		//}
	//}
	//cout << dp[n][x] << endl;
//}
 
 

 

void solve(){
	int a; cin >> a;
	cout << a + a*a + a*a*a;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main ()
{
    int n;
    int sum = 0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int m;
    cin>>m;
    for(int i=0;i<m;++i)
    {
        int p , x;
        cin>>p>>x;
        int sum2 = sum;
        sum2-=a[p - 1];
        sum2+=x;
        cout<<sum2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int t1,t2,a1,a2,b1,b2;
bool a,b;
signed main(){
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(t1*a1+t2*a2==t1*b1+t2*b2){
		puts("infinity");
		return 0;
	}
	a=(a1<b1);
	b=(t1*a1+t2*a2<t1*b1+t2*b2);
	if(a==b){
		puts("0");
		return 0;
	}
	int x=(t1*a1+t2*a2)-(t1*b1+t2*b2);
	int y=t1*(b1-a1);
	x=abs(x),y=abs(y);
	cout<<(y/x)*2+(y%x!=0)<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int n;
    cin >> n;
    int p[n];
    REP(i, n) cin >> p[i];

    int c = 0;
    REP(i, n - 2) {
        if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ||
            (p[i] > p[i + 1] && p[i + 1] > p[i + 2]))
            c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int n, m;
int main(){
	char s[100010];
	int i, j, k;
	cin >> n;
	cin >> s;
	for(i = 0; i < strlen(s); ++i){
		int x = s[i] + n;
		if(x > 'Z')x -= 26;
		s[i] = x;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	if (n <= 111) cout << "111" << endl;
	else if (n <= 222) cout << "222" << endl;
	else if (n <= 333) cout << "333" << endl;
	else if (n <= 444) cout << "444" << endl;
	else if (n <= 555) cout << "555" << endl;
	else if (n <= 666) cout << "666" << endl;
	else if (n <= 777) cout << "777" << endl;
	else if (n <= 888) cout << "888" << endl;
	else if (n <= 999) cout << "999" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X, K, D;
  cin >> X >> K >> D;

  int cnt = abs(X)/D;

  int ans;
  if(!(K <= cnt)){
    if(X < 0){
      ans = X+cnt*D;
    }else{
      ans = X-cnt*D;
    }
    K -= cnt;
    K %= 2;
    if(K){
      ans = min(abs(ans+D), abs(ans-D));
    }
  }else{
    if(X < 0){
      ans = X+K*D;
    }else{
      ans = X-K*D;
    }
  }

  cout << abs(ans) << "\n";

  return 0;
}


Measured memory_bytes: 3700
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,m,q,A[maxn],B[maxn],C[maxn],f[maxn],cnt,x[maxn],c2;

inline int F(int x)
{
	if(f[x]==x) return x;
	return f[x]=F(f[x]);
}

inline void mer(int x,int y)
{
	int fx=F(x),fy=F(y);
	if(fx!=fy) f[fx]=fy;
}

int main()
{
	n=read(); m=read(); q=read(); rep(i,1,n) f[i]=i;
	rep(i,1,q)
	{
		A[i]=read()+1; B[i]=read()+1; C[i]=read();
		if(C[i]==0) mer(A[i],B[i]);
	}
	rep(i,1,n) if(f[i]==i) cnt++;
	rep(i,1,q)
	{
		if(C[i]==1)
		{
			int u=F(A[i]),v=F(B[i]);
			if(u==v) return puts("No"),0;
			else
			{
				if(!x[u]) x[u]=1,c2++;
				if(!x[v]) x[v]=1,c2++;
			}
		}
	}
	ll nw=n-cnt;
	if(cnt==1)
	{
		if(m==n-1) puts("Yes");
		else puts("No");
	}
	else if(cnt==2)
	{
		if(c2||m!=n-1) puts("No");
		else puts("Yes");
	}
	else
	{
		ll l=n,r=nw+((cnt-1)*cnt)/2; if(!c2) l--;
		if(m>=l&&m<=r) puts("Yes"); else puts("No");
	}
	return 0;
}

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

using namespace std;

int A,B,a=1,b=1;
char grid[100][100];
//vector<vector<char>>grid(100,vector<char>(100));
bool flag=0;

int main(){
	for(int i=0;i<50;i++){
		for(int j=0;j<100;j++){
			grid[i][j]='.';
		}
	}

	for(int i=50;i<100;i++){
		for(int j=0;j<100;j++){
			grid[i][j]='#';
		}
	}

	cin>>A>>B;
	if(B!=1){
	for(int i=0;i<49;i=i+2){
		for(int j=0;j<100;j=j+2){
			
			grid[i][j]='#';
			b++;
			if(b==B)break;
		}
		if(b==B)break;
	}
	}

	if(A!=1){
	for(int i=51;i<100;i=i+2){
		for(int j=0;j<100;j=j+2){
			
			grid[i][j]='.';
			a++;
			if(a==A)break;
		}
		if(a==A)break;
	}
	}

	cout<<100<<" "<<100<<endl;

	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			cout<<grid[i][j];
		}
		cout<<'\n';
	}

	return 0;
	



}

Measured memory_bytes: 256
from queue import Queue

N = int(input())
g = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

q = Queue()
count = [0, 0]
used = [False] * N

q.put((0, 0))
count[0] += 1
used[0] = True

q.put((N - 1, 1))
count[1] += 1
used[N - 1] = True

while not q.empty():
    u, color = q.get()
    for v in g[u]:
        if not used[v]:
            q.put((v, color))
            count[color] += 1
            used[v] = True

print("Fennec" if count[0] > count[1] else "Snuke")

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

#define int long long int
#define mp make_pair
#define mod 1000000007
using namespace std;

string s;
int d , n;
vector <int> v(10002);
int dp[10002][102][2];

int fun(int pos , int rem , int limit)
{
    if(pos == n){
        return (rem == 0);
    }
    int &ans = dp[pos][rem][limit];
    if(ans != -1){
        return ans;
    }
    ans = 0 ;
    if(limit){
        for (int i = 0; i <= v[pos]; ++i) {
            if(i == v[pos]){
                ans += fun(pos+1,(rem+i)%d,1);
            }
            else{
                ans += fun(pos+1,(rem+i)%d,0);
            }
        }
    }
    else{
        for (int i = 0; i <= 9; ++i) {
            ans += fun(pos+1,(rem+i)%d,0);
        }
    }
    ans %= mod;
    return ans;
}

int32_t main() {
    string s;
    cin >> s;
    scanf("%lld", &d);
    n = s.length();
    for (int i = 0; i < n; ++i) {
        v[i] = s[i] - '0';
    }
    for (int i = 0; i < 10002; ++i) {
        for (int j = 0; j < 102; ++j) {
            for (int k = 0; k < 2; ++k) {
                dp[i][j][k] = -1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= v[0]; ++i) {
        if(i == v[0]){
            ans += fun(1,i%d,1);
        }
        else{
            ans += fun(1,i%d,0);
        }
    }
    ans = (ans-1+mod)%mod;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 17024
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<string> s(n);
    vector<int> p(n), id(n);
    
    fori(n) {
        cin>>s[i]>>p[i];
        id[i]=i;
    }

    sort(id.begin(), id.end(), [&](int i1, int i2) {
        if(s[i1]!=s[i2])
            return s[i1]<s[i2];
        return p[i2]<p[i1];
    });

    fori(n)
        cout<<id[i]+1<<endl;
    

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 200005
#define int long long int
int dsu[MAX];
int ranks[MAX];
void create(int n)
{
    for(int i = 0 ;i  <= n ; i++)
    {
        dsu[i] = i;
        ranks[i] = 0;
    }
}
int find_set(int v)
{
    if(v == dsu[v])
        return v;
    return dsu[v] = find_set(dsu[v]);
}
void merge(int a, int b)
{
    a = find_set(a);
    b = find_set(b);
    if(a == b)
        return;
    if (ranks[a] < ranks[b])
        swap(a, b);
    dsu[b] = a;
    if (ranks[a] == ranks[b])
        ranks[a]++;
}
void solve()
{
    int n,m;
    cin >> n >> m;
    create(n);
    for(int i = 0 ; i < m ; i++)
    {
        int x,y;
        cin >> x>>y;
        merge(x,y);
    }
    int ans = 0;
    map<int,int> mp;
    for(int i = 1 ; i <= n ; i++)
    {
        mp[find_set(i)]++;
            
    }
    for(auto it: mp)
        ans = max(ans,it.S);
    cout << ans;
    
    return;
}

int32_t main()
{
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    
    return 0;
}
/*
 AtCoder after Google Online Challenge Fail:(
 */


Measured memory_bytes: 19068
N = int(input())
ans = 0

if N % 2 == 1:
    print(0)
else:
    num_10 = N // 10
    ans += num_10
    N = N//10
    while (N >= 1):

        num_5 = N // 5
        ans += num_5
        N = N // 5

    print(ans)


Measured memory_bytes: 2940
N = int(input())
a = list(map(int, input().split()))

dic = {}
for n in a:
  if n in dic:
    dic[n] += 1
  else:
    dic[n] = 1
    
dic = dic.items()
ans = 0
for number in dic:
  if number[0] <= number[1]:
    ans += number[1] - number[0]
  else:
    ans += number[1]
    
print(ans)

Measured memory_bytes: 18168
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    bool ans = false;
    for (int i = 1; i <= b; i++) {
        if (i*a % b == c) ans = true;
    } 

    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

sum = 0

for i in range(N):
    sum_t = 0
    j = i + 1
    n = j
    while n != 0:
        sum_t += n % 10
        n //= 10
    if sum_t >= A and sum_t <= B:
        sum += j

print(sum)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long int ans = 0;
    long int N, a,b,c,d,f;
	cin >> N >> a >> b >> c >> d >> f;
    long int K = min({ a,b,c,d,f});
	long long int m = (N-1)/K;
	ans = m + 5;
	
	cout << ans;
}

Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=3e3+10;
	//------------------FIXED------------------
	
	void main()
	{
		ll I=qread(),O=qread(),T=qread(),J=qread(),L=qread();
		write((I/2)*2+O+(J/2)*2+(L/2)*2+(I&1 and J&1 and L&1)*3+(I%2==0 and I>0 and J&1 and L&1)+(I&1 and J%2==0 and J>0 and L&1)+(I&1 and J&1 and L%2==0 and L>0));
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//线性预处理模意义
	mine::main();
	if(DD) cerr<<"\n---------------------Zory---------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

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

typedef long long ll;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];
int siz[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
        siz[i] = 1;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int s = siz[x] + siz[y];
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    siz[find(x)] = s;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int size(int x) {
    return siz[find(x)];
}

int main() {
    int N, M, x, y, ans = 0;
    cin >> N >> M;
    vector<int> p(N);
    rep(i, N) {
        cin >> p[i];
        p[i]--;
    }
    init(N);
    rep(i, M) {
        cin >> x >> y;
        unite(x - 1, y - 1);
    }
    rep(i, N) {
        if (same(i, p[i])) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<string.h>
 
int main(void){
 
    int i,j;
    int q;
    int x, y;
 
    char str[1000];
    char str2[10];
    char w[1000];
    char r;
 
    scanf("%s", str);
    scanf("%d", &q);
 
    /* ?????????strstr?????????????????????0????????????¨?????? */
    for(i=0; i<q; i++){
        scanf("%s", str2);
 
        if(strcmp(str2, "replace")==0){
            scanf("%d %d %s", &x, &y, w);
                for(j=x; j<=y; j++){
                str[j]=w[j-x];
            }                               /* strstr???a???????????????b???????????????§????????? */
        }
 
    else if(strcmp(str2, "reverse")==0){
        scanf("%d %d",&x, &y);
            while(x<y){
                r=str[x];
                str[x]=str[y];
                str[y]=r;
                x++;
                y--;
            }                               /* strstr???a???????????????b???????????????§???????????? */
        }
 
    else if(strcmp(str2, "print")==0){
        scanf("%d %d",&x,&y);
            for(j=x; j<=y; j++){
                printf("%c", str[j]);
            }                               /* strstr???a???????????????b???????????????§???p????????? */
            printf("\n");
        }
    }
 
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = 100005;
vector<int> dp[N];
int dpp[N][3];

int main()
{
       int n,m;
       cin>>n>>m;
       fri(i,0,m){
              int x,y;
              cin>>x>>y;
              --x;--y;
              dp[x].pb(y);
              //dp[y].pb(x);
       }
       int s,t;
       cin>>s>>t;
       --s;--t;
       memset(dpp,-1,sizeof dpp);
       queue<pair<pair<int,int>,int>> q;
       dpp[s][0] = 0;
       q.push({{s,0},0});
       while(!q.empty())
       {
              int curr = q.front().fr.fr;
              int j = q.front().fr.sc;
              int dis = q.front().sc;
              q.pop();
              for(int k : dp[curr]){
                            if(dpp[k][(j+1)%3] == -1){
                                   q.push({{k,(j+1)%3},dis+1});
                                   dpp[k][(j+1)%3] = dis+1;
                            }
              }
       }
       if(dpp[t][0] == -1){
              cout<<-1<<endl;
       }
       else{
              cout<<dpp[t][0]/3<<endl;
       }
}


Measured memory_bytes: 6912
#include <stdio.h>

#define A 1000

int main()
{
  int array[A];
  int i;
  int num;//打ち込む個数
  int v;
  int j;
  int k;

  scanf("%d",&num);

  for(i = 0; i<num ;i++)
    {
      scanf("%d",&array[i]);
    }
 
  for(k=0 ; k < num ; k++)
    {
      printf("%d",array[k]);
      if(k<num-1)printf(" ");
    }
  printf("\n");

  for(i = 1 ; i <= num-1 ; i++)//ソート
    {
      v = array[i];
      j = i - 1;

      
      while(j >= 0 && array[j] > v)
	{
	  array[j+1] = array[j];
	  j--;
	}
      array[j+1] = v;

      for(k=0 ; k < num ; k++)
	{
	  printf("%d",array[k]);
	  if(k<num-1)printf(" ");
	}
      if(i<=num-1)printf("\n");
    }
  return 0;
}

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

#define ll long long

int main(void){

    int w,h,n;
    cin>>w>>h>>n;

    int ew=w,eh=h,sw=0,sh=0;
    for(int i=0;i<n;i++){
        int x,y,a;
        cin>>x>>y>>a;
        switch(a){
            case 1:
            if(x>sw)sw=x;
            break;
            case 2:
            if(x<ew)ew=x;
            break;
            case 3:
            if(y>sh)sh=y;
            break;
            case 4:
            if(y<eh)eh=y;
            break;
        }
    }
    cout<<max((ew-sw),0)*max((eh-sh),0)<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] inputStr = sc.next().split("");
        int result = 0;
        if("1".equals(inputStr[0])){
            result++;
        }
        if("1".equals(inputStr[1])){
            result++;
        }
        if("1".equals(inputStr[2])){
            result++;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
const int K = 100010;
int dp[K];
int a[110];
int n, k;
int mini;
bool get(int x) {
    if(dp[x] != -1) return dp[x];
    else if(x < mini) {
        dp[x] = 0;
        return false;
    } else {
        for(int i = n-1; i >= 0; i --) {
            int curr = a[i];
            if(x >= curr && !get(x - curr) ) {
                dp[x] = 1;
                return true;
            }
        }
        dp[x] = 0;
        return false;
    }
}

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof dp);
    sort(a, a+n);
    mini = a[0];
    if(get(k)) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n,w,i,j;
    cin>>n>>w;
    ll weight[101];
    ll val[101];
    ll arr[n+1][w+1];
    memset(arr,0,sizeof(arr));
    for(i=1;i<=n;i++)
    cin>>weight[i]>>val[i];
    for(i=0;i<=n;i++)
    for(j=0;j<=w;j++)
    {
        if(i==0 || j==0)
        arr[i][j] = 0;
        
        else if(weight[i]<=j)
        arr[i][j] = max(val[i]+arr[i-1][j-weight[i]],arr[i-1][j]);
        
        else
        arr[i][j] = arr[i-1][j];
    }
    
    cout<<arr[n][w]<<endl;
}


Measured memory_bytes: 79104
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <string>  	
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define bublic public
#define kektor vector
#define pii pair<int, int>
#define pp pair
#define all(x) x.begin(), x.end()
#define rand() (rand() << 15)
    
using namespace std;
    
typedef long long ll;

     
int RandInt(int min, int max) {
    if (max < min) swap(min, max);
    random_device rd;                                                                                                                                                                        
    mt19937 mt(rd());
    uniform_int_distribution<int> dist(min, max);
    return dist(mt);
}
                                                                      
const int maxn = 3e5, mod = 1e9 + 7, inf = 1e18;

void solve() {
	int a, b, c; cin >> a >> b >> c; 
	int el = max(a, max(b, c)); 
	int ans = inf; 
	for (int i = el; i <= 1e4; ++i) {
		int a1 = i - a, b1 = i - b, c1 = i - c; 
		int cur = 0;
		if ((a1 % 2 + b1 % 2 + c1 % 2) % 2 == 0) {
			cur += a1 / 2;
			cur += b1 / 2;
			cur += c1 / 2;
			a1 %= 2, b1 %= 2, c1 %= 2;
			cur += (a1 + b1 + c1) / 2;
			ans = min(ans, cur);
			if (ans == 1) {
				cout << i; 
				return; 
			} 
		} 
	}
	cout << ans; 
}                               
    
signed main() {
	srand(time(0)); 
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef offline_judge 
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    #endif   
    solve();
    return 0;                                        
}    

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

int main(){
char a,b;
  cin>>a>>b;
  
  if(a=='H' && b=='H'){cout<<'H'<<endl;}
if(a=='D' && b=='H'){cout<<'D'<<endl;}
  if(a=='H' && b=='D'){cout<<'D'<<endl;}
  if(a=='D' && b=='D'){cout<<'H'<<endl;}
}

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

int main(){
    float r;
    cin >> r;
    cout << 2*3.14*r << "\n";
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std; 
int N,ptr=0,res;
int A[100000]; 
int main (){
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i]; 
  sort(A,A+N);
  while(ptr<N){
    int cc=A[ptr],f=0;
    while(ptr<N&&A[ptr]==cc) f++,ptr++;
    res+=f%2;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, i;
  cin >> N >> i;
  cout << N + 1 - i << "\n";
  // print();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll>> dp(n+1, vector<ll>(3, -LINF));
  dp[0][1] = 0;
  dp[1][1] = 0;
  dp[1][2] = a[0];
  for (int i = 2; i <= n; i++) {
    ll mn = i/2-1, mx = (i+1)/2;
    for (ll num = mn; num <= mx; num++) {
      int j = num-mn;
      if (num-((i-1)/2-1) >= 0 && num-((i-1)/2-1) <= 2)
        chmax(dp[i][j], dp[i-1][num-((i-1)/2-1)]);
      if (num-1-((i-2)/2-1) >= 0 && num-1-((i-2)/2-1) <= 2)
        chmax(dp[i][j], dp[i-2][num-1-((i-2)/2-1)]+a[i-1]);
    }
  }
  cout << dp[n][1] << endl;
  return 0;
}

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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

const ll MAXN = 1000001;
bool P[MAXN];
bool S[MAXN];

template<typename T> T gcdraw(T a, T b) { return a ? gcdraw(b%a, a) : b; }
template<typename T> T gcd(T a, T b)
{
    const auto aa = abs(a), bb = abs(b);
    return aa > bb ? gcdraw(aa, bb) : gcdraw(bb, aa);
}

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

    vector<ll> A(N);
    rep (i, N) { cin >> A[i]; }

    vector<ll> PS = { 1, 2 };
    for (ll i=3;i*i<=MAXN;i+=2) if (!P[i])
    {
        for (ll j=2*i;j*j<=MAXN;j+=i) { P[j] = true; }
        PS.emplace_back(i);
    }

    const auto isPairwise = [&]()
    {
        for (ll i=0;i<N;++i)
        {
            for (const auto& p: PS)
            {
                if (A[i] < p * p) { break; }
                if (A[i] % p) { continue; }

                const auto x = p;
                const auto y = A[i] / p;

                if (x != 1 && S[x]) { return false; }
                if (y != 1 && S[y]) { return false; }

                S[x] = true;
                S[y] = true;
            }
        }

        return true;
    };

    if (isPairwise())
    {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    ll setwise = A[0];
    for (ll i=1;i<N;++i) { setwise = gcd(setwise, A[i]); }

    if (setwise == 1)
    {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N+1),C(N+1);
  for(int &i:A)
    cin>>i;
  B[0]=0;
  C[N]=0;
  int j=0;
  for(int i=0;i<N;i++){
    j=__gcd(j,A[i]);
    B[i+1]=j;
  }
  j=0;
  for(int i=N-1;i>=0;i--){
    j=__gcd(j,A[i]);
    C[i]=j;
  }
  j=0;
  for(int i=0;i<N;i++)
    j=max(j,__gcd(B[i],C[i+1]));
  cout<<j<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
v2 d;
v2 dd;
ld ans;


int main(){
  cin >> n;
  d = v2(n,vl(2));
  for(ll i = 0;i < n;i++) cin >> d[i][0] >> d[i][1];
  sort(d.begin(),d.end(),[](vl a,vl b){
    return atan2(a[0],a[1]) < atan2(b[0],b[1]);
  });
  dd = v2(2*n,vl(2));
  for(ll i = 0;i < 2*n;i++){
    dd[i] = d[i%n];
  }
  for(ll i = 0;i < 2*n;i++){
    for(ll j = i+1,l = 0;j <= 2*n && l < n;j++,l++){
      ll x = 0;
      ll y = 0;
      for(ll k = i;k < j;k++){
        x += dd[k][0];
        y += dd[k][1];


      }
      ld dx = (ld)x;
      ld dy = (ld)y;
      ans = max(ans,sqrt(dx*dx+dy*dy));
    }
  }
  cout << setprecision(17);
  cout << ans << endl;

}


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

using namespace std;

int main(void){
	int A, B;
	int ans;
	cin >> A >> B;
	ans = A+B;
	if(ans>=10){
		cout << "error" << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a,b;
    do{
        scanf("%d %d",&a,&b);
        if (a == 0 && b == 0){
            break;
        }
        else if (a>b){
            printf("%d %d\n",b,a);
        }
        else{
            printf("%d %d\n",a,b);
        }
    }while (1);
    return 0;
}



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

int main()
{
	auto div_num = [](int x) {
		int r = 0;
		for (int i = 1; i <= x; i++)
		{
			if (x % i == 0)
			{
				r++;
			}
		}
		return r;
	};
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2)
	{
		if (div_num(i) == 8)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var a = ReadArrayInt();
            var plus = 0L;
            var val = 0L;
            for (int i = 0; i < n; i++)
            {
                val += a[i];
                if (i % 2 == 0)
                {
                    if (val <= 0)
                    {
                        plus += Math.Abs(val) + 1;
                        val = 1;
                    }
                }
                else
                {
                    if (val >= 0)
                    {
                        plus += Math.Abs(val) + 1;
                        val = -1;
                    }
                }
            }
            var minus = 0L;
            val = 0;
            for (int i = 0; i < n; i++)
            {
                val += a[i];
                if (i % 2 != 0)
                {
                    if (val <= 0)
                    {
                        minus += Math.Abs(val) + 1;
                        val = 1;
                    }
                }
                else
                {
                    if (val >= 0)
                    {
                        minus += Math.Abs(val) + 1;
                        val = -1;
                    }
                }
            }

            Console.WriteLine(plus < minus ? plus : minus);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main()
{
    int n, i;
    double sum = 0.0;
    int a[100];
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      sum += (double)1/a[i];
    }
    cout << 1/sum << endl;
}

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int N = 1e5 + 5;

char s[N];

signed main(){
	scanf("%s", s+1);	
    int n = strlen(s+1);
    for(int i=1; i<n; i++)
        if(s[i] != s[n-i]){
            cout << -1;
            return 0;
        }
    
    if(s[1] == '0' || s[n-1] == '0' || s[n] == '1'){
        cout << -1;
        return 0;
    }
    
    int pre = 1;
    for(int i=2; i<=n/2; i++){
        if(s[i] == '0') continue;
		
        for(int j=pre; j<i; j++)
            printf("%d %d\n", i, j);
        pre = i;
    }
	
    for(int i=pre; i<n; i++)
        printf("%d %d\n", n, i);
        
    return 0;
}

Measured memory_bytes: 3908
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, S: str):
    if N%2 == 0:
        if S[:N//2] == S[N//2:]:
            print(YES)
            exit()
        
    print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


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

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int b[n];
  for(int i=0;i<n;i++){
    b[i]=0;
  }
  for(int i=0;i<n;i++){
    b[a[i]-1]++;
  }
  sort(b,b+n);
  int ans=0;
  for(int i=0;i<n-k;i++){
    ans+=b[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
// ORZ YJZ
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n;
vector<int> g[100005];
vector<int> path;
int dis[100005], par[100005];
int dfs(int x, int p, int d) {
	int cnt=1;
	dis[x]=d;par[x]=p;
	rep(i,0,(int)g[x].size()-1) {
		int y=g[x][i];
		if (y!=p&&~y) cnt+=dfs(y,x,d+1);
	}
	return cnt;
}
void get_path(int x, int y) {
	dfs(x,-1,0);
	path.clear();
	path.pb(y);
	while (y!=x) {
		y=par[y];
		path.pb(y);
	}
	reverse(path.begin(),path.end());
}
void destroy_connect(int x, int y) {
	rep(i,0,(int)g[x].size()-1) if (g[x][i]==y) g[x][i]=-1;
	rep(i,0,(int)g[y].size()-1) if (g[y][i]==x) g[y][i]=-1;
}
int main() {
	n=readint();
	rep(i,1,n-1) {
		int x=readint(),y=readint();
		g[x].pb(y);g[y].pb(x);
	}
	get_path(1,n);
//	rep(i,0,(int)path.size()-1) cerr<<path[i]<<(i+1==(int)path.size()?'\n':' ');
	int m=(int)path.size()-2;
//	Fe:0~|_m/2_|  Sn:|_m/2_|+1~m-1
	int x=(m+1)>>1;
	destroy_connect(path[x],path[x+1]);
	int y=dfs(n,-1,0);
//	cerr<<y<<" "<<n-y<<endl;
	if (y<n-y) {
		printstr("Fennec");
	} else {
		printstr("Snuke");
	}
	return 0;
}


Measured memory_bytes: 14972
#include <stdio.h>
int main(void)
{
    int n, a[51];
    int sum = 0, i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);

    for (i = 0; i < n; ++i)
    {
        for (j = i + 1; j < n; ++j)
        {
            sum += a[i] * a[j];
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
m = gets.chomp.to_i

puts array[m-1]

Measured memory_bytes: 1788