akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<vector<int>> refer(N+1,vector<int>(N+1,-1));
  for(int i=1; i<=N; i++){
    cin >> A.at(i);
    for(int j=0; j<A.at(i); j++){
      int x,y;
      cin >> x >> y;
      refer.at(i).at(x) = y;
    }
  }

  int answer = 0;
  for(int bit = 0; bit < (1<<N); bit++){
    vector<int> S(N+1,0);
    int count = 0;
    for(int i=0; i<N; i++){
      if(bit & (1<<i)){
        S.at(i+1) = 1;
        count++;
      }
    }
    
    bool flag = true;
    for(int i=1; i<=N; i++){
      for(int j=1; j<=N; j++){
        if(refer.at(i).at(j) != -1){
          if(S.at(i) == 1 && refer.at(i).at(j) != S.at(j)){
            flag = false;
          }
        }
      }
    }
    if(answer < count && flag){
      answer = count;
    }
  }
  
  cout << answer << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a, b;
    cin >> a >> b;
    int lena = a.length(), lenb = b.length();
    if (lena < lenb) {
        cout << "LESS" << endl;
        return 0;
    } else if (lena > lenb) {
        cout << "GREATER" << endl;
        return 0;
    } else {
        for (int i = 0; i < lena; i++) {
            if (a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            } if (a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())

# cum_sum[L][R]
cum_sum = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L, R = map(int, input().split())
    cum_sum[L][R] += 1

for l in range(1, N+1):
    for r in range(1, N+1):
        cum_sum[l][r] += cum_sum[l][r-1] + cum_sum[l-1][r] - cum_sum[l-1][r-1]

for _ in range(Q):
    p, q = map(int, input().split())
    print(cum_sum[q][q]-cum_sum[q][p-1]-cum_sum[p-1][q]+cum_sum[p-1][p-1])


Measured memory_bytes: 13416
n,*a=`dd`.split.map &:to_i;f=0;puts %w(Second First)[loop{b=a.map{|e|e&1^1};s=b.reduce :+;(s==n-1&&(0...n).find{|i|b[i]==0&&a[i]>1&&a[i]-=1})||(break f^=s&1);g=a.reduce :gcd;a=a.map{|e|e/g};f^=1}]

Measured memory_bytes: 31972
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

int main(void)
{
  ll N, K;
  cin >> N >> K;
  ll i;
  ll array[100001] = {};
  for (i = 0; i < N; i++)
  {
    ll a, b;
    cin >> a >> b;
    array[a] += b;
  }
  for (i = 0; i < 100001; i++)
  {
    K -= array[i];
    if (K <= 0)
    {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> namber(n);
  for (int i = 0;i<n;i++) cin >> namber.at(i);
  sort(namber.begin(), namber.end(),greater<int>());
  int a_sum = 0;
  int b_sum = 0;
  for (int i = 0;i < n;i++){
    if (i%2 == 0) a_sum += namber.at(i);
    if (i%2 == 1) b_sum += namber.at(i);
  }
  cout << a_sum - b_sum << endl;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, d = list(map(int, input().rstrip('\n').split()))
    if abs(c- a) <= d:
        print("Yes")
    elif abs(a - b) <= d and abs(b - c) <= d:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38496
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    string s,t;
    cin>>s>>t;
    int flag=1;
    forn(i,s.size()) flag&=(s[i]==t[i]);
    if(flag) cout<<"Yes"<<ln;
    else cout<<"No"<<ln;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll n;
    cin >> n;
    vector <ll> v;
    for (int i=0;i<n;i++){
        ll p;
        cin >> p;
        v.push_back(p);
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    for (int i=0;i<v.size()-1;i++){
        sum += v[i];
    }
    if(sum > v[v.size()-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long long int a,b,n,i,max=0,c,d;
  double fb,fi,fa;
  scanf("%lld%lld%lld",&a,&b,&n);
  /*for(i=0;i<=n;i++){
    fb=(double)b;
    fa=(double)a;
    fi=(double)i;
    c=(long long int)(fa*fi/fb);
    d=i/b;
    if(max<c-a*d){
      max=c-a*d;
    }
  }*/
  i=b-1;
  if(i>n){
    i=n;
  }
  fb=(double)b;
  fa=(double)a;
  fi=(double)i;
  c=(long long int)(fa*fi/fb);
  d=i/b;
  if(max<c-a*d){
    max=c-a*d;
  }
  printf("%lld\n",max);
  return 0;
}


Measured memory_bytes: 1712
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    using namespace std;
    
    int func(int n){
        int out =(n%2==0) ? (n/2) : (3*n + 1);
        return out;
    }

    int main() {
        int n;double t,a; cin >> n>> t>> a;
        double min = 999999;
        int ind = -1;
        for(int i =0; i < n;i++){
            double h; cin >> h;
            double dif =  fabs(a - (t - h*0.006));
            //cout << dif<< endl;
            if (min > dif){
                min = dif;
                ind = i+1; 
            }
        }
        cout << ind << endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;

bool check(vector<ll> &c, ll X){
    bool ans = true;
    for(int i=1; i<c.size(); i++){
        if(c[i] < X) ans = false;
    }
    return ans;
}



int main(){
    ll N, M, X;
    cin >> N >> M >> X;
    vector<vector<ll>> S(N, vector<ll>(M+1));
    for(int i=0; i<N; i++){
        for(int l=0; l<M+1; l++){
            cin >> S[i][l];
            }
        }
//    for(int i=0; i<N; i++){
//        for(int l=0; l<M+1; l++){
//            cout << S[i][l];
//            }
//        cout << endl;
//        }
    int C_count = 100000*12+1;
    bool flag = true;
    for(ll bit=0; bit < (1<<N); bit++){
        vector<ll> count(M+1);
        for(int i=0; i<N; i++){
            if(bit & (1<<i)){
                for(int l=0; l<M+1; l++){
                    count[l] += S[i][l];
                }
                if(check(count, X) && C_count > count[0]){
                    C_count = count[0];
                    flag = false;
                }

            }
        }
//        for(int i=0; i<B.size(); i++){
//            cout << B[i];
//            }
//        cout << endl;
    }
    if(flag) C_count=-1;
    cout << C_count;

}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

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

    vector<ll> a(n);
    ll sum =0;
    for(auto &x:a){
        cin >> x;
        sum += x;
    }

    ll summod=0;
    for(int i=0;i<n;i++){
        sum-=a[i];
        summod+=a[i]*(sum%MOD);
        summod%=MOD;
    }

    cout << summod << endl;

    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c; cin>>a>>b>>c;
    int ans=(c+max(a,b)-1)/max(a,b);
    cout<<ans<<endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

struct NODE{
  ll b,l,u;
  ll score;
};

ll n,x;
ll aoki;
bool isOK(ll mid, vector<NODE> &v){
  if(mid == 0) return false;
  ll full = mid/x;
  ll amari = mid % x;
  if(full == n) return true;
  // calc c_sum
  VLL c_sum(n,0);
  rep(i,n){
    if(i == 0) c_sum[i] = v[i].score;
    else c_sum[i] += v[i].score + c_sum[i-1];
  }

  //あまりの場所を1箇所決める{
  rep(i,n){
    ll total = -aoki;
    if(full <= i){
      //満点を取るやつ
      if(full > 0) total += c_sum[full-1];
      //あまりを取るやつ
      total += v[i].b * v[i].l;
      if(v[i].b < amari){
        total += v[i].u * (amari - v[i].b);
      }else{
        total += v[i].l * (amari - v[i].b);
      }
    }else{
      //満点を取るやつ
      if(full > 0){
        total += c_sum[full];
        total -= v[i].score;
      }
      total += v[i].b * v[i].l;
      if(v[i].b < amari){
        total += v[i].u * (amari - v[i].b);
      }else{
        total += v[i].l * (amari - v[i].b);
      }
    }
    if(total >= 0) return true;
  }
  return false;
}

bool cmp(NODE a, NODE b){
  return a.score < b.score;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> x;
  vector<NODE> v(n);

  rep(i,n){
    cin >> v[i].b >> v[i].l >> v[i].u;
    v[i].score = v[i].l * v[i].b + v[i].u * (x - v[i].b);
    aoki += v[i].b * v[i].l;
  }
  if(aoki == 0){
    cout << 0 << endl;
    return 0;
  }
  sort(all(v),cmp);
  reverse(all(v));

  ll ok = x*n;
  ll ng = -1;
  while(ok - ng > 1){
    ll mid = (ok + ng)/2;
    if(isOK(mid,v)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  return 0;
}


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

using namespace std;

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

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

    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= (sum + 4 * m - 1) / (4 * m)) {
            cnt++;
        }
    }

    cout << (cnt >= m ? "Yes" : "No") << endl;
}


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

#define CH(n,A,B) (A<=n&&n<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long LLINF = 1e15;

using namespace std;

int n,m,c,s,g;
int x,y,dist,comp,p[25],q[25][55],r[25][55];
int d[35][1005][1005], f[1005][1005];

int main() {
  while(1){
    cin>>n>>m>>c>>s>>g;
    if(n==0&&m==0&&c==0&&s==0&&g==0) break;
    s--; g--;
    REP(k,0,c)REP(i,0,n)REP(j,0,n){
      if(i==j) d[k][i][j] = 0;
      else d[k][i][j] = INF;
    }
    REP(i,0,m){
      cin>>x>>y>>dist>>comp;
      x--; y--; comp--;
      d[comp][x][y] = min(dist, d[comp][x][y]);
      d[comp][y][x] = min(dist, d[comp][y][x]);  //???????????????
    }

    REP(i,0,c) cin>>p[i];
    REP(i,0,c){
      q[i][0] = 0;
      REP(j,1,p[i]){
        cin>>q[i][j];
      }
      q[i][p[i]] = INF;
      REP(j,0,p[i]){
        cin>>r[i][j];
      }
    }

    //?????????????????????????????????????§??????????????????¢???
    REP(company,0,c){
      REP(k,0,n)REP(i,0,n)REP(j,0,n) {
        d[company][i][j] = min(d[company][i][j], d[company][i][k]+d[company][k][j]);
      }
    }

    REP(i,0,n)REP(j,0,n){
      if(i==j) f[i][j] = 0;
      else f[i][j] = INF;
    }
    REP(company,0,c){
      //?????????????????????????????¨????????´???????????????????§?????????????????????????
      REP(from,0,n)REP(to,0,n){
        if(d[company][from][to] == INF) continue; //??°???????????????????¨?????????????
        int fare = 0;
        REP(i,0,p[company]){
          if(q[company][i] > d[company][from][to]) break;
          fare += r[company][i] * min(d[company][from][to]-q[company][i],q[company][i+1]-q[company][i]);
        }
        f[from][to] = min(f[from][to], fare);
      }
    }

    REP(k,0,n){
      REP(i,0,n){
        REP(j,0,n){
          f[i][j] = min(f[i][j], f[i][k]+f[k][j]);
        }
      }
    }
    if(f[s][g] == INF) cout<<-1<<endl;
    else cout<<f[s][g]<<endl;
  }

  return 0;
}

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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = 1 ^ 2 ^ 3 ^ a ^ b;
    cout << ans << endl;
    return 0;
}


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

namespace AOJ2
{
    class Program
    {
        static char[] delimeterChar = { ' ', ',', '.' };

        static void Main(string[] args)
        {
            List<string> resultList = new List<string>();

            string input = Console.ReadLine();

            string[] inputArray = input.Split(delimeterChar,StringSplitOptions.RemoveEmptyEntries);

            foreach (string s in inputArray)
            {
                if (s.Length >= 3 && s.Length <= 6)
                {
                    resultList.Add(s);
                }
            }

            for (int i = 0; i < resultList.Count; i++)
            {
                if (i != resultList.Count - 1)
                {
                    Console.Write("{0} ", resultList[i]);
                }
                else
                {
                    Console.WriteLine(resultList[i]);
                }
            }

            Console.ReadKey();
        }


    }
}

Measured memory_bytes: 5448
#include<bits/stdc++.h>
using namespace std;
int par[100001],ran[100001];
int club[100001];
int main(void){
	int n,m,q;
	int i,j;
	int x,y,z;
	int flg,place;
	cin>>n>>m>>q;
	for(i=1;i<=n;i++){
		par[i]=i;
		ran[i]=0;
		club[i]=0;
	}
	flg=0;
	place=0;
	for(i=0;i<q;i++){
		cin>>z>>x>>y;
		if(flg==0){
			if(z==1){
				while(x!=par[x])	x=par[x];
				while(y!=par[y])	y=par[y];
				// printf("club[x]=%d club[y]=%d\n",club[x],club[y]);
				if(x!=y){
					if(!(club[x]==club[y]||club[x]==0&&club[y]!=0||club[x]!=0&&club[y]==0)){
						flg=1;
						place=i+1;
					}
					else{
						if(ran[x]<ran[y]){
							par[x]=y;
							if(club[x]!=0)	club[y]=club[x];
						}
						else if(ran[x]>ran[y]){
							par[y]=x;
							if(club[y]!=0)	club[x]=club[y];
						}
						else{
							par[y]=x;
							ran[x]++;
							if(club[y]!=0)	club[x]=club[y];
						}
					}
					
				}
			}
			else{
				while(x!=par[x])	x=par[x];
				if(club[x]==0)		club[x]=y;
				else{
					if(club[x]!=y){
						flg=1;
						place=i+1;
					}
					
				}
			}
			// for(j=1;j<=m;j++){
				// printf("j=%d club[j]=%d\n",j,club[j]);
			// }
		}
	}
	cout<<place<<endl;
	return 0;
}


Measured memory_bytes: 4276
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))

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

int cnt(int x) {
	int res = 0;
	while(x % 2 == 0) {
		res++;
		x /= 2;
	}
	return res;
}

int main() {
	int n, a;
	int min = 99999999;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (min > cnt(a))min = cnt(a);
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    
   ll n; cin >> n;
 vector<ll> v(n);
 rep(i, n) {
 cin >> v[i];
 }
 
 vector<ll> c(n);
 rep(i, n) {
 cin >> c[i];
 }
 vector<ll> k(n);
 rep(i, n) { if(v[i]>=c[i]) {k[i] = v[i] - c[i] ;} ;
  if (v[i] < c[i]) {k[i] = 0 ;} ;}
 ll sum = 0;
 rep(i, n) {
 sum += k[i];
 }
 cout << sum << endl;
 }
   



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int nax = 1e5 + 7;
int n, ns, ny;
vector<int>adj[nax];
vector<int>dis1(nax);
vector<int>dis2(nax);
void dfs(int node, int par, int d, vector<int>&a) {
	a[node] = d;
	for (auto k : adj[node]) {
		if (k == par)continue;
		dfs(k, node, d + 1, a);
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> ns >> ny;
	--ns, --ny;
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		--v, --u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs(ns, -1, 0, dis1);
	dfs(ny, -1, 0, dis2);
	vector<int>leaf;
	for (int i = 0; i < n; i++) {
		if (adj[i].size() == 1) {
			leaf.pb(i);
		}
	}
	int ans = 0;
	for (auto k : leaf) {
		if (dis1[k] < dis2[k]) {
			ans = max(ans, dis2[k] - 1);
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 14752
#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

int n,t;
char ch[10000010];

int main()
{
	scanf("%s%d",ch,&n);
	t=strlen(ch);
	
	for(int i=0;i<t;i+=n)
		printf("%c",ch[i]);
	

	return 0;
}

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int a, b; cin >> a >> b;
  	cout << (b + a - 3) / (a - 1) << endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long

ll mod=998244353;
ll fac[300010];

ll poww( ll x, ll y )
{
    if(y==0) return 1LL;
    ll a = poww( x,y/2 )%mod;
    ll res=a*a;
    res%=mod;
    if( y%2==1 ) res*=x;
    return res%mod;
}

ll inv( ll x )
{
    return poww( x,mod-2 );
}

ll binom( ll n, ll k )
{
    if(k>n) return 0;
    ll br = fac[n];
    ll naz = fac[k]*fac[n-k];
    naz%=mod;
    naz = inv( naz );
    ll ans = (br*naz)%mod;
    return ans;
}

int main()
{
        ios_base::sync_with_stdio(false);
            cin.tie(NULL);

            ll n,a,b,k;
            cin>>n>>a>>b>>k;

            fac[0]=1LL;
            for(ll i=1;i<=n;i++) fac[i]=(fac[i-1]*i)%mod;

            ll res=0;
            for(ll i=0;i<=n;i++){
                ll bb = k - a*i;
                if(bb<0) continue;
                if( bb%b == 0 ){
                    bb/=b;
                    res+=binom( n,i )*binom( n,bb );
                    res%=mod;
                }
            }

            cout<<res<<endl;

            return 0;
}































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

typedef long long ll;

ll n;

ll solve(ll x, ll y, ll z){
    return ((x*x+y*y+z*z)+(x*y+y*z+z*x));
}

int main(){

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

    cin >> n;
    ll arr[n+1];
    for(ll i=0; i<=n; i++) arr[i]=0;

    ll x;

    for(ll i=1; i<=130; i++){
        bool done=true;
        for(ll j=1; j<=130; j++){
            bool flag=true;
            for(ll k=1; k<=130; k++){
                x = solve(i,j,k);
                if(x<=n){
                    arr[x]++;
                    flag=false;
                    done=false;
                }
                if(x>n) break;
            }
            if(flag) break;
        }
        if(done) break;
    }
    for(int i=1; i<=n; i++) cout<<arr[i]<<'\n';

    return 0;
}


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

using namespace std;

char field[1001][1001];
char chs[3]={'J','O','I'};
int cnts[3][1001][1001];

int main(){

    int h,w;
    cin>>h>>w;
    int K;
    cin>>K;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>field[i][j];
    for(int i=0;i<3;i++){
        for(int j=0;j<h;j++){
            for(int k=0;k<w;k++){
                cnts[i][j+1][k+1]=cnts[i][j][k+1]+cnts[i][j+1][k]-cnts[i][j][k];
                if(field[j][k]==chs[i])cnts[i][j+1][k+1]++;
            }
        }
    }
    for(int i=0;i<K;i++){
        int miny,minx,maxy,maxx;
        cin>>miny>>minx>>maxy>>maxx;
        for(int j=0;j<3;j++){
            int res=cnts[j][maxy][maxx]-cnts[j][maxy][minx-1]-cnts[j][miny-1][maxx]+cnts[j][miny-1][minx-1];
            cout<<res;
            if(j==2)cout<<endl;
            else cout<<" ";
        }
    }

    return 0;
}

Measured memory_bytes: 0
n, p = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
def nCk(n, k)
  r, j = 1, 1
  return 0 if k > n || k < 0
  k = n - k if n - k < k
  while j <= k
    r *= n
    n -= 1
    r /= j
    j += 1
  end
  r
end
even = 0
odds = 0
n.times do |i|
  even += 1 if a[i] % 2 == 0
  odds += 1 if a[i] % 2 == 1
end
ans = 0
0.upto(even) do |i|
  ans += nCk(even, i)
end
cnt = 0
0.upto(odds) do |i|
  next if i % 2 == 1 - p
  cnt += nCk(odds, i)
end
ans *= cnt
puts ans

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

using ll = long long;

// 辺の情報
struct edge {
   ll to, cost;
};

const ll INF = 1e18;
ll N, M; // Nはノードの個数、Mは辺の個数
ll dist[1010]; // 最短距離
vector<edge> Graph[2010]; // グラフ

// ベルマンフォード法
void bellmanFord() {
   for (int i = 0; i < N; i++) {
      if (dist[i] == -INF) continue;
      for (edge e : Graph[i]) {
         dist[e.to] = max(dist[e.to], dist[i] + e.cost);
      }
   }
}

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      // a~bまでの距離で、コストはc
      Graph[a].push_back(edge{b, c});
   }

   // 最短距離を-INFで初期化
   for (int i = 0; i < N; i++) {
      dist[i] = -INF;
   }

   // 始点は0で初期化
   dist[0] = 0;
   // N回ベルマンフォード法を使う
   for (int k = 0; k < N; k++) {
      bellmanFord();
   }
   ll ans1 = dist[N-1];

   // N回ベルマンフォード法を使う
   for (int k = 0; k < N; k++) {
      bellmanFord();
   }
   ll ans2 = dist[N-1];

   // 2つの答えが違えば負の閉路が存在するため"inf"となる
   if (ans1 != ans2) {
      puts("inf");
   } else {
      cout << ans1 << endl;
   }

   return 0;
}

Measured memory_bytes: 384
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, M = getNM()
lista = []
for i in range(M):
    s, c = getNM()
    lista.append([s, c])
ans = -1
sta = 0
if N > 1:
    sta = 10 ** (N - 1)
for i in range(sta, 10 ** N):
    flag = True
    for jud in lista:
        if str(i)[jud[0] - 1] != str(jud[1]):
            flag = False
            break
    if flag:
        ans = i
        break
print(ans)

Measured memory_bytes: 38256
using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        string[] s = p.ReadInput(true);
        var array = new int[s.Length];
        array = p.ConvertIntArray(s);
        var a = array[0];
        var b = array[1];
        var K = (a + b )/ 2;

        if(Math.Abs(a - K) == Math.Abs(b-K))
        {
            Console.WriteLine(K);
        }
        else
        {
            Console.WriteLine("IMPOSSIBLE");
        }
    }

    public string ReadInput()
    { 
        return Console.ReadLine();
    }

    public string[] ReadInput(bool b)
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    { 
        var convertedArray = new int[x.Length];
        for(var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

double outer(double xa, double ya, double xb, double yb){
    return (xa * yb - xb * ya);
}

int main(void)
{
    double x[3], y[3], xp, yp, op1, op2, op3;
    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &xp, &yp) != EOF){
        op1 = outer(x[1]-x[0], y[1]-y[0], xp-x[0], yp-y[0]);
        op2 = outer(x[2]-x[1], y[2]-y[1], xp-x[1], yp-y[1]);
        op3 = outer(x[0]-x[2], y[0]-y[2], xp-x[2], yp-y[2]);
        if ( ( (op1>0.0)&&(op2>0.0)&&(op3>0.0) )|| ( (op1<0.0)&&(op2<0.0)&&(op3<0.0) ) ) {
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return (0);

}


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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    vector last(C, vector<unsigned long>{0});
    vector<unsigned long> ans(D);

    for(unsigned long i{0}; i < D; ++i){
        unsigned long mx{0}, mxi{0};
        for(unsigned long j{0}; j < C; ++j){
            unsigned long tmp{v[i][j] + c[j] * (i + 1 - last[j].back())};
            if(tmp > mx){
                mx = tmp;
                mxi = j;
            }
        }
        ans[i] = mxi;
        last[mxi].push_back(i + 1);
    }
    for(auto&& i : last)i.push_back(D + 1);

    mt19937_64 mt{random_device{}()};
    uniform_int_distribution<unsigned long> uid(1, D);

    auto start = chrono::system_clock::now();

    for(unsigned long iter{0}; iter < 100000; ++iter){
        unsigned long d{uid(mt)};
        auto f = ans[d - 1];
        unsigned long tmp{c[f] * (*upper_bound(begin(last[f]), end(last[f]), d) - d) * (d - *prev(lower_bound(begin(last[f]), end(last[f]), d))) + v[d - 1][f]};
        unsigned long mx{tmp}, mxi{0};
        for(unsigned long i{0}; i < C; ++i){
            unsigned long temp{c[i] * (*upper_bound(begin(last[i]), end(last[i]), d) - d) * (d - *prev(lower_bound(begin(last[i]), end(last[i]), d))) + v[d - 1][i]};
            if(temp > mx){
                mx = temp;
                mxi = i;
            }
        }
        if(mx > tmp){
            last[f].erase(lower_bound(begin(last[f]), end(last[f]), d));
            last[mxi].insert(upper_bound(begin(last[mxi]), end(last[mxi]), d), d);
            ans[d - 1] = mxi;
        }
        if(!(iter & 65535))if(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() > 1600)break;
    }

    for(const auto& i : ans)cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 3740
N=int(input())
A=list(map(int,input().split()))
def count(x):
    c=0
    while c>=0:
        if x%2==0:
            x=x//2
            c+=1
        else:
            break
    return c
l=[0]*N
for i in range(N):
    l[i]+=count(A[i])
print(min(l))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int l = s.size();
    if (s[l-1] == s[0])
    {
        if (l % 2 == 0)
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;
    }
    else
    {
        if (l % 2 == 0)
            cout<<"Second"<<endl;
        else
            cout<<"First"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  int tim = n / 500;
  n %= 500;
  n -= n % 5;
  n += tim * 1000;
  cout << n;

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 256
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
n,m,r=map(int,input().split())
*R,=map(int,input().split())
table=[[0]*n for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    table[a-1][b-1]=c
    table[b-1][a-1]=c
d=floyd_warshall(csgraph=table, directed=False, return_predecessors=False)
cost=[sum(d[i[j]-1][i[j+1]-1]for j in range(r-1))for i in permutations(R)]
print(int(min(cost)))

Measured memory_bytes: 20372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    string s=a+b;
    stringstream ss(s);
    ll n=0;
    ss>>n;
    ll l=0,r=1e9;
    while(l<r){
        ll m=(l+r)/2;
        if(m*m==n)return 0*puts("Yes");
        if(m*m>n)r=m;
        else l=m+1;
    }
    puts("No");
}


Measured memory_bytes: 3660
#include <stdio.h>

int main(void)
{
    int i;
    int num, num1, num2;
    int digits;
    
    while (scanf("%d%d", &num1, &num2) != EOF){
        num = num1 + num2;
        digits = 0;
        while (num != 0){
            num /= 10;
            digits++;
        }
        printf("%d\n", digits);
    }
    
    return (0);
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int q = fs.nextInt();
        final List<int[]> queries = new ArrayList<>();
        for (int i = 0; i < q; i++) {
            queries.add(new int[] { fs.nextInt(), fs.nextInt() });
        }
        queries.sort(Comparator.comparingInt(a -> a[1]));
        int res = 0;
        int prevRemove = -1;
        for (int[] qq : queries) {
            if (prevRemove == -1 || prevRemove <= qq[0]) {
                res++;
                prevRemove = qq[1];
            }
        }
        System.out.println(res);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 59012
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  if(a == 5 && b == 5 && c == 7){
    printf("YES");
  }
  else if(a == 5 && c == 5 && b == 7){
    printf("YES");
  }
  else if(b == 5 && c == 5 && a == 7){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
def f(s, k):
    
    k = int(k)
    
    cnt = 0
    ss = s
    for i in range(len(ss)):
        if i == 0:
            continue

        if ss[i-1] == ss[i]:
            ss = ss[:i] + '\\' + ss[i+1:]
            cnt += 1
        
    cnt = cnt * k
    
    if s.count(s[0]) == len(s):
        if len(s) % 2 == 1:
            cnt = cnt + (k//2)
    else:    
        cntchk1 = 0
        cntchk2 = 0
        if s[0] == s[len(s)-1]:
            for i in range(len(s)):
                if s[len(s)-1] == s[len(s)-1 - i]:
                    cntchk1 += 1
#                 else:
#                     break
                if i < len(s)-1 and s[0] == s[i+1]:
                    cntchk2 += 1
                    
            if cntchk1 % 2 == 0 and cntchk1 % 2 == 0:
                cnt = cnt + (k -1)
                
    return str(cnt)

## Submit
print(f(input(),input()))

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;

  if(n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;

  return 0;
}


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

#define ll  long long
#define pb push_back
#define mp make_pair
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
int h[100001];
int dp[100001];

int go(int n){
    if(n==0) return 0;
    else if(n==1)return 0;
    else if(n==2) return abs(h[2]-h[1]);
    else {
        if(dp[n]!=-1){
            return dp[n];
        }else{
            dp[n]=min(go(n-1)+abs(h[n-1]-h[n]),go(n-2)+abs(h[n-2]-h[n]));
            return dp[n];
        }  

    }  
}


int main() {
    
    int t, n, m;
    cin>>n;
    memset(h,-1,sizeof(h));
    memset(dp,-1,sizeof(dp));

    Fo(i,n){
        cin>>h[i];
    }
    dp[1]=0;
    cout<<go(n)<<endl;
    return 0;
}




Measured memory_bytes: 2560
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let a_b_k = stdin.lock().lines().next().unwrap().unwrap();
    let mut a_b_k = a_b_k.split_whitespace();
    let a = a_b_k.next().unwrap().parse::<u64>().unwrap();
    let b = a_b_k.next().unwrap().parse::<u64>().unwrap();
    let k = a_b_k.next().unwrap().parse::<u64>().unwrap();

    if a >= k {
        println!("{} {}", a - k, b);
    } else if a + b >= k {
        println!("0 {}", a + b - k);
    } else {
        println!("0 0");
    }
}


Measured memory_bytes: 4352
k = [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
]
K = int(input())
print(k[K-1])


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

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

  int m, d;
  cin >> m >> d;

  int ans = 0;
  for (int i = 22; i <= d; ++i) {
    int d1 = i % 10;
    int d2 = i / 10;

    if (d1 < 2 || d2 < 2) continue;
    if (d1 * d2 <= m) ++ans;
  }

  cout << ans << endl;

  return (0);
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, 101) rep(j, 101) rep(k, 101) {
    int x = i + 1;
    int y = j + 1;
    int z = k + 1;
    mp[x * x + y * y + z * z + x * y + y * z + z * x]++;
  }
  rep(i, n) {
    cout << mp[i + 1] << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5480
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = int(input())
    ans = [0]*10**4
    for x in range(1,10**2+1):
        for y in range(1,10**2+1):
            for z in range(1,10**2+1):
                tmp = (x+y+z)**2-x*y-y*z-z*x
                if tmp <= 10**4:
                    ans[tmp-1] += 1
    for i in range(N):
        print(ans[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 9620
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1];
	if((A * B) % 2 == 0) writeln("No");
	else writeln("Yes");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
for i in range(m):
  inp=list(map(lambda x:int(x)-1,input().split()))
  s.append(inp[1:])
p=list(map(int,input().split()))
c=0
for i in range(2**n):
  st=[]
  for j in range(m):
    t=0
    for k in s[j]:
      if i&(2**k):
        t^=1
    st.append(t)
  if p==st:
    c+=1
print(c)

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	float m;
	cin >> n;
	m = n;
	if(n % 2) cout << round(m / 2) / m;
	else cout << (m / 2) / m;

	return 0;
}



Measured memory_bytes: 512
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let mut counts = std::collections::HashMap::new();
    for i in 0..4 {
        *counts.entry(s[i]).or_insert(0) += 1;
    }

    if counts.len() == 2 && counts.iter().all(|e| *e.1 == 2) {
        return "Yes".to_string();
    }

    return "No".to_string();
}


Measured memory_bytes: 2160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;

namespace AtCoder_Core
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            string result = string.Empty;
            if (S.Length <= K)
            {
                Console.WriteLine(S);
            }
            else
            {
                Console.WriteLine(S.Substring(0, K) + "...");
            }

        }
    }

}

Measured memory_bytes: 27380
raw_input()
xs = [int(x) for x in raw_input().split()]
a = xs.pop()
dp = [0] * 21
dp[xs[0]] = 1

for x in xs[1:]:
    ndp = [0] * 21
    for n, c in enumerate(dp):
        for nn in [n+x, n-x]:
            if 0 <= nn < 21:
                ndp[nn] += c
    dp = ndp

print dp[a]

Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

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

int N, K;

int Sum[200010];
map<int, int> counter;

int f(int a)
{
	a += K * (int)1e9;
	return a % K;
}

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}

	rep(i, N+1) {
		if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
		ans += counter[f(Sum[i] - i)];
		counter[f(Sum[i] - i)]++;
	}

	cout << ans << endl;
}


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

int main(){
  
  int x,y,z;
  cin >> x >> y >> z;

  if( x == y && !(x == z) ) {
    
    cout << "Yes" << endl;
    
  }
     
  else if( y == z && !(x == z) ){
    
    cout << "Yes" << endl;
    
  }
     
   else if( x == z && !(x == y) ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No"<< endl;
    
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==b&&b!=c)||(b==c&&a!=b)||(c==a&&b!=c)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
from itertools import combinations
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
dp = [-10**18 for i in range(1<<n)]
for i in range(n):
  dp[2**i] = 0
def judge(S):
  if dp[S] != -10**18:
    return dp[S]
  T = S
  retls = [0]
  sls = []
  ret0 = 0
  for i in range(n):
    if 1<<i & S:
      sls.append(i)
  for i,j in combinations(sls,2):
    ret0 += a[i][j]
  retls.append(ret0)
  while T>0:
    T = (T-1)&S
    if T == 0:
      break
    retls.append(judge(T)+judge(S^T))
  dp[S] = max(retls)
  return max(retls)
print(judge(2**n-1))

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

using namespace std;

typedef long long LL;

int main(){
    LL x;double y;
    cin>>x>>y;

    y*=100;

    LL z=y;

    for(int i=-1;i<=1;++i){
        if(fabs((z+i)-y)<fabs(z-y)){
            z+=i;
        }
    }


    cout<<x*z/100;
    return 0;
}



Measured memory_bytes: 3712