akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,cnt[50],x; 
int main()
{
	cin>>n>>m;
	for (i=1;i<=m*2;i++)
	{
		cin>>x;
		cnt[x]++;
	}
	for (i=1;i<=n;i++) cout<<cnt[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; 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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N, Q;
  cin >> N >> Q;
  vector<P> A(N-1);
  vector<vector<int>> C(N,vector<int>());
  REP(i,N-1){
    cin >> A[i].first >> A[i].second;
    A[i].first--;
    A[i].second--;
    C.at(A[i].first).push_back(A[i].second);
    C.at(A[i].second).push_back(A[i].first);
  }
  vector<P> B(Q);
  REP(i,Q){
    cin >> B[i].first >> B[i].second;
    B[i].first--;
  }
  vector<int> cnt(N,0);
  REP(i,Q){
    cnt[B[i].first]+=B[i].second;
  }

  queue<int> que;
  vector<int> dist(N,-1);
  dist[0]=0;
  que.push(0);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto nv:C[v]){
      if(dist[nv]!=-1) continue;
      dist[nv]=dist[v]+1;
      cnt[nv]+=cnt[v];
      que.push(nv);
    }
  }
  

  REP(i,N){
    if(i!=N-1){
      cout << cnt[i] << " ";
    }else{
      cout << cnt[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 19444
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (auto& x : p) cin >> x;
  for (auto& x : q) cin >> x;
  int a, b;
  vector<int> perm(n);
  iota(perm.begin(), perm.end(), 1LL);
  int i = 0;
  do {
    if (perm == p) a = i;
    if (perm == q) b = i;
    i++;
  } while (next_permutation(perm.begin(), perm.end()));
  cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = 0;
    for (int i=1; i<=n; i++){
      sum+=i;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21712
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
static const int N = 1000;
 
int max(int s,int t){
if (s>=t) return s;
return t;
}
 
int lcs(char X[], char Y[], int m ,int n) {
  int c[N + 1][N +1];
  int maxl = 0,i,j;
 
  strcmp(&X[0], " ");
  strcmp(&Y[0], " ");
  //X[0] = ' ';
  //Y[0] = ' ';
  for(i=0;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;
 
  for(i = 1;i <=m; i++) {
    for(j = 1;j <=n; j++) {
    if(X[i] == Y[j]) {
      c[i][j] = c[i-1][j-1] + 1;
    } else {
      c[i][j] = max(c[i-1][j] , c[i][j-1]);
    }
    maxl = max(maxl,c[i][j]);
  }
}
 
return maxl;
}
 
 
int main() {
  char s1[1001],s2[1001];
  int i,n;
 
  scanf("%d\n", &n);
  for (i=0;i<n;i++) {
    scanf("%s", &s1[1]);
    scanf("%s", &s2[1]);
    printf("%d\n", lcs(s1,s2,(int)strlen(&s1[1]),(int)strlen(&s2[1])));
  }
  return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
            bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        assert(i>0);
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

void solve(long long N, std::vector<string> A){
    unordered_map<int, vector<int>> twoFive;
    rep(i,0,N) {
        ll numerator, denominator = 1;
        auto pos = A[i].find('.');
        if (pos == string::npos) {
            numerator = stoll(A[i]);
        } else {
            rep(j,0,A[i].size()-pos-1) denominator *= 10;
            string s = A[i].substr(0, pos) + A[i].substr(pos+1, A[i].size()-pos);
            numerator = stoll(s);
        }
        int two = 0, five = 0;
        while (numerator % 2 == 0) {
            numerator /= 2;
            two++;
        }
        while (numerator % 5 == 0) {
            numerator /= 5;
            five++;
        }
        while (denominator % 2 == 0) {
            denominator /= 2;
            two--;
        }
        while (denominator % 5 == 0) {
            denominator /= 5;
            five--;
        }
        twoFive[two].push_back(five);
    }
    BIT bit(100);
    int base = 50;
    ll answer = 0;
    rep(i,0,50) {
        if (i != 0) {
            for (int five : twoFive[-i]) {
                bit.add(base - five, 1);
            }
        }
        for (int five : twoFive[i]) {
            answer += bit.sum(base + five);
            bit.add(base - five, 1);
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<string> A(N);
    for(int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    solve(N, std::move(A));
    return 0;
}


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

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

  int ans = 0;
  for (int i = 1; i <= N; i++) {

    int k = 0, cp = i;

    while (cp >= 10) {
      cp /= 10;
      k++;
    }

    if (k % 2 == 0) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    long long n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    rep(i, n) sort(s[i].begin(), s[i].end());
    sort(s.begin(), s.end());

    long long ans = 0, cnt = 0;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            cnt++;
            ans += cnt;
        }else
            cnt = 0;
    }
    cout << ans << endl;

}

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

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

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

using namespace std;

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

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

int main(void)
{
    const int N_MAX = 500;
    const int C_MAX = 30;
    int N, C;
    int D[N_MAX][N_MAX];
    int c[N_MAX][N_MAX];
    cin >> N >> C;
    REP(i, C) REP(j, C) cin >> D[i][j];
    REP(i, N) REP(j, N) {
        cin >> c[i][j];
        c[i][j]--;
    }

    int p[3][C_MAX]; // p[r][C] = # { grid (i, j) | (i + j) % 3 = r and c[i][j] = C }
    REP(i, 3) REP(j, C_MAX) p[i][j] = 0;
    REP(i, N) REP(j, N) {
        p[(i + j) % 3][c[i][j]]++;
    }

    int result = INT_MAX;
    int c_after[3];
    for (c_after[0] = 0; c_after[0] < C; c_after[0]++) {
        for (c_after[1] = 0; c_after[1] < C; c_after[1]++) {
            if (c_after[0] == c_after[1]) continue;
            for (c_after[2] = 0; c_after[2] < C; c_after[2]++) {
                if (c_after[0] == c_after[2] || c_after[1] == c_after[2]) continue;
                int x = 0;
                REP(r, 3) REP(c_before, C) {
                    x += D[c_before][c_after[r]] * p[r][c_before];
                }
                amin(result, x);
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	ll ans = 0;
	ll aans = 0;
	ll rans = 0;
	ll aback = 0;
	ll rback = 0;
	ll sum = 0;
	ll rsum = 0;
	vll aa, ra, ab, rb;
	makei(N);
	makel(C);
	vll x(N), v(N);
	rep(N)cin >> x[i] >> v[i];
	rep(N) {
		sum += v[i];
		rsum += v[N - 1 - i];
		aa.push_back(aans = max(aans, sum - x[i]));
		ra.push_back(rans = max(rans, rsum - C + x[N - 1 - i]));
		ab.push_back(aback = max(aback, sum - 2 * x[i]));
		rb.push_back(rback = max(rback, rsum - 2 * (C - x[N - 1 - i])));
	}
	ans = max(aans, (ll)0);
	ans = max(ans, rans);
	rep(N - 1) {
		ans = max(ans, aa[i] + rb[N - 2 - i]);
		ans = max(ans, ra[N - 2 - i] + ab[i]);
	}
	say(ans);
}

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

int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int> (d));
    rep(i, n)rep(j, d){
        cin >> x[i][j];
    } 
    double dist = 0;
    int cnt = 0; 
    rep(i, n){        
        for(int j = i + 1; j < n; j++){
            dist = 0;
            rep(k, d){
                dist += pow(x[i][k] - x[j][k], 2.0);
            }
            double ans = sqrt(dist);
            if(ceil(ans) != floor(ans)){
                continue;
            }else{
                cnt++;
            }
        }    
        
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999

    /*Solve*/
int main(){
    ll n;
    vector<ll> a,b,c;   //c[i]:=a[i]にあと何回足せばb[i]の倍数となるか
    cin >> n;
    ll x,y;
    rep(i,n){
        cin >> x >> y;
        a.push_back(x);
        b.push_back(y);
        if(x>y){
            c.push_back(y-abs(x-y)%y);
        }else c.push_back(abs(x-y)%y);
        if(y==1 || x==0)c[i]=0;
    }
    long long sum=0;
    for(ll i=n-1;i>=0;i--){
        sum+=c[i];
        if(i==0)break;
        if(b[i-1]==1 || sum==0){
            c[i-1]=0;
            break;
        }
        if(c[i-1]>=sum){
            c[i-1]=abs(c[i-1]-sum)%b[i-1];
        }else if((c[i-1]-sum)%b[i-1]==0){
            c[i-1]=0;
        }else c[i-1]=b[i-1]-abs(c[i-1]-sum)%b[i-1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2912
#include "iostream"
#include "vector"
#include "string"
#include <iomanip>

//const double PI = 3.14159265358979323846;

using namespace std;

int main() {
	int x1,x2,x3,x4,x5;

	cin >> x1 >> x2 >> x3 >> x4 >> x5;

	if (x1 == 0) {
		cout << '1' << endl;
	}
	if (x2 == 0) {
		cout << '2' << endl;
	}	
	if (x3 == 0) {
		cout << '3' << endl;
	}	
	if (x4 == 0) {
		cout << '4' << endl;
	}	
	if (x5 == 0) {
		cout << '5' << endl;
	}

	return 0;

}

Measured memory_bytes: 3040
grid = []
for row in range(3):
    row = list(map(int, input().split()))
    grid.append(row)
# print(grid)
n = int(input())

for _ in range(n):
    num = int(input())
    for row in range(3):
        for col in range(3):
            if grid[row][col] == num:
                grid[row][col] = '*'
# print(grid)

# row
is_ok = False
for row in range(3):
    if grid[row][0] == grid[row][1] == grid[row][2] == '*':
        is_ok = True
        break

# col    
for col in range(3):
    if grid[0][col] == grid[1][col] == grid[2][col] == '*':
        is_ok = True
        break


# ななめ
if grid[0][0] == grid[1][1] == grid[2][2] == '*' or grid[0][2] == grid[1][1] == grid[2][0] == '*':    
    is_ok = True

if is_ok:
    print('Yes')
else:
    print('No')    

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

using namespace std;
using ll = long long;

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

  string s;
  cin >> s;
  for (auto c : s) {
    if (c == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3608
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n,m,c[10]={0,2,5,5,4,5,6,3,7,6};
	cin>>n>>m;
	vi a(m);
	rep(i,m)cin>>a[i];
	sort(all(a));
	vvi dp(m+1,vi(n+1));
	dp[0][0]=1;
	rep(i,m)rep(j,n+1)if(dp[i][j])rep(k,10010){
		if(j+k*c[a[i]]>n)break;
		cmax(dp[i+1][j+k*c[a[i]]],dp[i][j]+k);
	}
	string s="";
	int t=n;
	for(int i=m-1;i>=0;i--){
		rep(j,n+1)if(t-j==(dp[i+1][t]-dp[i][j])*c[a[i]]){
			s+=string(dp[i+1][t]-dp[i][j],'0'+a[i]);
			t=j;
			break;
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int ctoi(char c){
	return c - 'a';
}

int main(){
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<set<int> > st(26);
	for (int i = 0; i < s.length(); i++){
		st[ctoi(s[i])].insert(i);
	}
	for (int i = 0; i < q; i++){
		int x;
		cin >> x;
		if (x == 1){
			int a;
			char c;
			cin >> a >> c;
			st[ctoi(s[a-1])].erase(a-1);
			st[ctoi(c)].insert(a-1);
			s[a-1] = c;
		}else{
			int a, b;
			cin >> a >> b;
			int coun = 0;
			for (int j = 0; j < 26; j++){
				auto iter1 = st[j].lower_bound(a-1);
				auto iter2 = st[j].lower_bound(b);
				if (iter1 != iter2) coun++;
			}
			cout << coun << endl;
		}
	}
	return 0;
}


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

using namespace std;

#define forn(i0, n0) for (int i0 = 0; i0 < n0; i0++)
#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvl (v) for (ll x : v) cout << x << ' '; cout << '\n'
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define Sort(a) sort(all(a))
#define Reverse reverse (all(a))

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    vector <ll> a(n, 0);
    double avg = 0;
    forn(i, n) {
        cin >> a[i];
        avg += a[i];
    }
    avg /= (4 * m);
    Sort(a);
    if (a[n - m] >= avg) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 1000
#define MAX_H 10000

signed main(){
    int h,n;
    cin >> h >> n;
    int a[n],b[n];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    ll ans = LINF;
    vector<vector<ll>> dp(n + 1, vector<ll>(h + 1, LINF));
    rep(i,n){
        dp[i][0] = 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= h; j++){
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);    
            if(j + a[i] <= h) dp[i + 1][j + a[i]] = min(dp[i][j + a[i]], dp[i + 1][j] + b[i]);
            else ans = min(ans, dp[i + 1][j] + b[i]);
        }
    }
    cout << min(dp[n][h], ans) << endl;
    return 0;
}

Measured memory_bytes: 78592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int n,a,b;

int main()
{
    cin >> n>> a>>b;
    cout<<min(n*a,b)<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll N;
    cin >> N;

    for(ll i=1; i<=N; i++) {
        double t=i;
        t/=100;
        t*=108;
        //cout << t << nl;
        if((int)t == N) {
            cout << i << nl;
            return 0;
        }
    }
    cout << ":(" << nl;
}

Measured memory_bytes: 256
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

if __name__ == '__main__':
    n, p = (int(x) for x in input().split())
    
    list = prime_factors(p)
    count = 0
    beforeValue = -1
    
    ans = 1
    if (n == 1):
        ans = p
    else :
        for i in range(0, len(list)):
            if (beforeValue == list[i]):
                count += 1
                if (count % n == 0):
                    ans *= list[i]
            else:
                count = 1
                beforeValue = list[i]
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll N, M;
  cin >> N >> M;
  priority_queue<Pll, vector<Pll>, greater<Pll>> que;
  for(int i = 0; i < N; i++){
    ll A, B;
    cin >> A >> B;
    que.push(Pll(A, B));
  }

  ll ans = 0;
  ll counter = 0;
  while(true){
    ll A = que.top().first;
    ll B = que.top().second;
    que.pop();
    if(counter + B < M){
      ans += A*B;
      counter += B;
    }
    else{
      ans += A*(M - counter);
      counter += M-counter;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2420
N,M,Query = map(int,input().split())
from itertools import combinations_with_replacement
P = tuple(combinations_with_replacement(range(1,M+1),N))
Q = []
for _ in range(Query):
    a,b,c,d = map(int,input().split())
    Q.append((a,b,c,d))
    answer = 0
for p in P:
    ans = 0
    for a,b,c,d in Q:
        if p[b-1]-p[a-1]==c:
            ans += d
    answer = max(ans,answer)
print(answer)

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

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  for (int i = n - 1; i > 0; --i) {
    cout << arr[i] << " ";
  }
  cout << arr[0] << endl;
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 2e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=2e5+5;
//#define local
#ifdef local
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif
void solve()
{
    int n , m  , i ,j;
    cin >> n;
    int a[n];
    map< int , int > mp;
    for(i=1 ; i<n ;i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    for(i=1 ; i<=n ; i++){
        cout << mp[i] << endl;
    }
}

signed main()
{
    int tc=1 , i ,j;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}


Measured memory_bytes: 17692
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,blb = 0;
    cin>>n;
    while(n!=0)
    {
        if(n%10==7)
            blb = 1;
        n /= 10;
    }
    if(blb==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3624
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	int H, W, K;
	cin >> H >> W >> K;
	vector <vector<int>> CELLS(6, vector<int>(6));
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			char x;
			cin >> x;
			if (x == '.') CELLS.at(h).at(w) = 0;
			if (x == '#') CELLS.at(h).at(w) = 1;
		}
	}

	int ans = 0;

	vector <vector<int>> CELLS_Copy(6, vector<int>(6));

	for (int i = 0; i < (1 << H); i++) {
		bitset<6> A(i);

		for (int j = 0; j < (1 << W); j++) {

			for (int a = 0; a < 6; a++) {
				for (int b = 0; b < 6; b++) {
					CELLS_Copy.at(a).at(b) = CELLS.at(a).at(b);
				}
			}

			bitset<6> B(j);
			for (int k = 0; k < W; k++) {
				if (B.test(k)) {
					for (int x = 0; x < 6; x++) {
						CELLS_Copy.at(x).at(k) = 0;
					}
				}
			}
			for (int l = 0; l < H; l++) {
				if (A.test(l)) {
					for (int y = 0; y < 6; y++) {
						CELLS_Copy.at(l).at(y) = 0;
					}
				}
			}
			int cnt = 0;
			for (int p = 0; p < 6; p++) {
				for (int q = 0; q < 6; q++) {
					if (CELLS_Copy.at(p).at(q) == 1) cnt++;
				}
			}
			if (cnt == K) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
template<typename T> istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec)	is >> x;
	return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
	os << "[";
	rep(i, vec.size())	os << (i ? ", " : "") << vec[i];
	os << "]";
	return os;
}
template<typename T> istream& operator >> (istream& is, pair<T, T>& p) {
	is >> p.first >> p.second;
	return is;
}
template<typename T> ostream& operator << (ostream& os, pair<T, T>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e9;
const ld infl = 1e100;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	string s;	cin >> s;
	// .....####
	int bkCnt = 0;
	int whCnt = 0;
	rep(i, n) {
		if (s[i] == '.')	whCnt++;
		else	bkCnt++;
	}
	int ret = n;
	rrep(i, n) {
		ret = min(ret, bkCnt);
		if (s[i] == '.')	bkCnt++;
		else	bkCnt--;
	}
	cout << min(ret, bkCnt) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }

vector<bool> check(1000001, false);
/*  PrimeFact
    init(N): 初期化。O(N log log N)
    get(n): クエリ。素因数分解を求める。O(log n)
 */
template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    bool ch(T n) {
        while(n != 1) {
            if(check.at(n) == false) check.at(n) = true;
            else return true;
            n /= spf[n];
        }
        return false;
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
    // nの約数の個数を求める
    T get_num(T n) {
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        T res = 1;
        for(auto k : m){
            res *= (k.second + 1);
        }
        return res;
    }
};


int main(){
    PrimeFact<int> p(1000001);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a.at(i);
    }
    map<int, int> g = p.get(a[0]);
    
    for(auto i: g){
        bool ok = true;
        rep(j, n) {
            if(a.at(j) % i.first != 0) {
                ok = false;
                break;
            }
        }
        if(ok) {
            cout << "not coprime" << endl;
            return 0;
        }
    }

    rep(i, n) {
        if(p.ch(a.at(i))) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 11184
#include <iostream>
#include <algorithm>
#define RF return false
#define RT return true

using namespace std;

int a[21], num, m, q;

bool dfs (int n, int sum)
{
    bool ret;
    if (n==num && sum!=m) RF;
    if (sum==m) RT;
    if (sum>m) RF;
    if (sum<m)
    {
        for (int i=n+1; i<=num; i++)
        {
            ret=dfs(i,sum+a[i]);
            if (ret) RT;
        }
        RF;
    }
}

int main()
{
    cin>>num;
    for (int i=1; i<=num; i++) cin>>a[i];
    sort(a,a+num);
    cin>>q;
    bool ret[q];
    for (int i=0; i<q; i++)
    {
        cin>>m;
        ret[i]=dfs(0,0);
    }
    for (int i=0; i<q; i++) cout<<(ret[i] ? "yes\n" : "no\n");
    return 0;
}



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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int tmp = i;
		int cnt = 0;
		while(tmp != 0){
			cnt ++;
			tmp /= 10;
		}
		if(cnt % 2) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
def gcd(a, b):
    if a < b:
        temp = a
        a = b
        b = temp

    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return b


A, B, C, D = map(int, input().split())

c_st = (A-1) // C
c_end = B // C
c_num = c_end - c_st

d_st = (A-1) // D
d_end = B // D
d_num = d_end - d_st

E = (C * D) // gcd(C, D)
e_st = (A-1) // E
e_end = B // E
e_num = e_end - e_st

ans = B - A - c_num - d_num + e_num + 1

print(ans)


Measured memory_bytes: 3064
import sys

# Set max recursion limit
sys.setrecursionlimit(1000000)


def li_input():
    return [int(_) for _ in input().split()]


def is_boardable(W, P, K):
    T = [0] * K

    wi = 0
    ti = 0
    while wi < len(W):
        if T[ti] + W[wi] <= P:
            T[ti] += W[wi]
            wi += 1
        else:
            ti += 1

            if ti == K:
                return False
    
    return True


def main():
    N, K = li_input()
    W = [int(input()) for _ in range(N)]

    l = 0
    r = 100000 * 10000

    while l + 1 < r:
        m = (l + r) // 2

        if is_boardable(W, m, K):
            P = m
            r = m
        else:
            l = m

    print(P)
    

main()



Measured memory_bytes: 9572
# include <iostream>
# include <cstdio>
# include <cmath>

using namespace std;
unsigned long long f[2][109]= {0};
int main() {

//	freopen("knight.in","r",stdin);
//	freopen("knight.out","w",stdout);

	int n,i,j,a;
	cin >> n;

	for(i=1; i<=2; i++) {
		for(j=1; j<=n; j++) {
			cin >> a;
			f[i][j]=max(f[i-1][j]+a,f[i][j-1]+a);
//			cout << f[i][j] << " ";
		}
//		cout << endl;
	}

	cout<<f[2][n]<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
#define ld long double

vector<int>topo;
const int N=1e5+10;
bool visited[N];
void dfs(int s,vector<int>adj[])
{
    visited[s]=true;
    for(auto node:adj[s])
    {
        if(!visited[node])dfs(node,adj);
    }
    topo.pb(s);
}
int main()
{
   int n,m;
   cin>>n>>m;
   vector<int>adj[n+1];
   vector<int>adj2[n+1];
   forl(i,0,m)
   {
       int a,b;
       cin>>a>>b;
       adj[a].pb(b);
       adj2[b].pb(a);
   }
   forl(i,1,n+1) 
   {
       if(!visited[i]) dfs(i,adj);
   }
   reverse(topo.beg,topo.en);
   int dp[n];
   forl(i,0,n) dp[topo[i]]=0;
   int maxi=0;
   forl(i,1,n)
   {
       for(auto node:adj2[topo[i]])
       {
           dp[topo[i]]=max(dp[topo[i]],1+dp[node]);
       }
       maxi=max(maxi,dp[topo[i]]);
   }
   cout<<maxi<<endl;
   

}

Measured memory_bytes: 13952
h,w = map(int,input().split())

sll = []
for _ in range(h):
    sl = list(input())
    sll.append(sl)

yoko = [[] for i in range(h)]
for idx, sl in enumerate(sll):
    point = 0
    for s in sl:
        if s == "#":
            if point > 0:
                for _ in range(point):
                    yoko[idx].append(point)
            yoko[idx].append(0)
            point = 0
        else:
            point += 1
    if point > 0:
        for _ in range(point):
            yoko[idx].append(point)


tate = [[0 for i in range(w)] for i in range(h)]
for i in range(w):
    point = 0
    for idx,sl in enumerate(sll):
        if sl[i] == "#":
            if point > 0:
                for j in range(1, point+1):
                    tate[idx-j][i] = point
            tate[idx][i] = 0
            point = 0
        else:
            point += 1
    if point > 0:
        for j in range(1, point+1):
            tate[idx-j+1][i] = point


ans = 0
for yokol, tatel in zip(yoko,tate):
    for y, t in zip(yokol, tatel):
        if y+t > ans:
            ans = y+t

print(ans-1)

Measured memory_bytes: 250760
#include <bits/stdc++.h>
#define For(i,l,r) for (register int i=l; i<=r; i++)
using namespace std;
typedef unsigned long long LL;
typedef signed long long ll;
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
char a[10], b[10];
int ans = 0;
int main() {
	scanf("%s", a+1);
	scanf("%s", b+1);
	For(i,1,3)
		if (a[i] == b[i]) ans++;
	cout << ans;
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n, d, x;
	cin >> n >> d >> x;

	int ans = n + x;
	while (n--) {
		int a;
		cin >> a;
		int i = 1;
		while (i * a + 1 <= d) {
			ans++;
			i++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int N=200005;
int n,a[N],b[N],x[N],y[N];
void Sort(int a[],int d){
	int xx=0,yy=0;
	for (int i=1;i<=n;i++)
		if ((a[i]>>d)&1)
			y[++yy]=a[i];
		else
			x[++xx]=a[i];
	for (int i=1;i<=xx;i++)
		a[i]=x[i];
	for (int i=1;i<=yy;i++)
		a[i+xx]=y[i];
}
int count(int a[],int d,int v){
	int ans=0;
	for (int i=1;i<=n;i++)
		if (((a[i]>>d)&1)==v)
			ans++;
	return ans;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	int ans=0;
	for (int i=0;i<29;i++){
		int a0=count(a,i,0);
		int a1=count(a,i,1);
		int b0=count(b,i,0);
		int b1=count(b,i,1);
		int d=(a0*b1+a1*b0)&1;
		int p=n,base=(1<<i)-1;
		for (int j=1;j<=n;j++){
			while (p>0&&(a[j]&base)+(b[p]&base)>base)
				p--;
			d=(d+n-p)&1;
		}
		Sort(a,i);
		Sort(b,i);
		ans|=d<<i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		while (true) {
			ans_t = null;
			int n = sc.nextInt();
			if (n == 0)
				break;
			double[][] v = new double[n][2];
			for (int i = 0; i < n; ++i) {
				v[i][0] = sc.nextDouble();
				v[i][1] = sc.nextDouble();
			}
			double X = sc.nextDouble();
			double Y = sc.nextDouble();
			Arrays.sort(v, new Comparator<double[]>() {
				@Override
				public int compare(double[] o1, double[] o2) {
					return -Double.compare(o1[1] / o1[0], o2[1] / o2[0]);
				}
			});
			// v???vy/vx???????????????????????????
			double g = 9.8;
			int left = 0;// [0...left...]??????ti>0??§?????§???
			int right = n; // [0....r](r<right)??????ti>0??§?????§???
			// vx>0??????px=???vix*ti????????????{t}????????¨???????????¨???????¨????????????????
			do {
				int middle = (right + left) / 2;
				if (check(X, Y, g, v, middle)) {
					left = middle;
				} else {
					right = middle;
				}
			} while (right - left > 1);
			check(X, Y, g, v, left);
			double max = 0;
			for (int i = 0; i < ans_t.length; ++i) {
				max += (v[i][1] * ans_t[i] - 0.5 * g * ans_t[i] * ans_t[i]);
			}

			double min = max;
			for (int i = 0; i < n; ++i) {
				double t = X / v[i][0];
				min = Math.min(min, v[i][1] * t - 0.5 * g * t * t);
			}
			if (min <= Y && Y <= max) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

	double[] ans_t;

	boolean check(double X, double Y, double g, double[][] v, int middle) {
		int n = middle + 1;
		double px = X;
		double coe = v[0][0];
		double[] t = new double[n];
		for (int i = 1; i < n; ++i) {
			// i???i
			// j???0
			double a = 1 / g * (v[i][1] / v[i][0] - v[0][1] / v[0][0]);
			a *= v[i][0] * v[i][0];
			px -= a;
			a = v[i][0] * v[i][0] / v[0][0];
			coe += a;
		}
		if (px / coe < 0)
			return false;
		t[0] = px / coe;
		for (int i = 1; i < n; ++i) {
			t[i] = v[i][0] * (1 / g * (v[i][1] / v[i][0] - v[0][1] / v[0][0]) + t[0] / v[0][0]);
			if (t[i] < 0)
				return false;
		}
		ans_t = Arrays.copyOf(t, t.length);
		return true;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 94796
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0

for i in 0..a do
  for j in 0..b do
    for k in 0..c do
      if 500 * i + 100 * j + 50 * k == x then
        count += 1
      end
    end
  end
end

puts count

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

int main(){
    int N;
    int x[100001];
    int y[100001];
    int t[100001];
    bool flag = 0;

    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> t[i] >> x[i] >> y[i];
        // cin >> x[i];
        // cin >> y[i];
    }

    for (int i = 0; i < N; i++){
        if (i != 0){
            t[i] = t[i] - t[i-1];
            x[i] = x[i] - x[i-1];
            y[i] = y[i] - y[i-1];
        }
        if(x[i] < 0) x[i] = -1 * x[i];
        if(y[i] < 0) y[i] = -1 * y[i];
        if(t[i] % 2 == 0){
            // t = even
            // if ((x[i] + y[i]) % 2 == 0 && x[i] + y[i] <= t[i]) ;
            // else flag = 1;
            if ((x[i] + y[i]) % 2 != 0 || x[i] + y[i] > t[i]) flag = 1;
        }else
        {
            // t = odd
            // if ((x[i] + y[i]) % 2 == 1 && x[i] + y[i] <= t[i]) ;
            // else flag = 1;
            if ((x[i] + y[i]) % 2 != 1 || x[i] + y[i] > t[i]) flag = 1;
        }
    }
    if (flag == 0) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner a =  new Scanner(System.in);
        int h = a.nextInt();
        int ans = 0;
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= h; j++){
                for(int k = 1; k <= h; k++){
                    int temp = gcd(i,j);
                    ans+=gcd(temp,k);
                }
            }
        }
        
        System.out.println(ans);
    }
    
    static int gcd(int x, int y){
        if(y == 0)return x;
        else{
            return gcd(y, x%y);
        }
    }
}

Measured memory_bytes: 35856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  vector<tuple<double,ll,double>> vec;
  vec.push_back(make_tuple(4*q,4*q,1));
  vec.push_back(make_tuple(2*h,2*h,1));
  vec.push_back(make_tuple(s,s,1));
  vec.push_back(make_tuple(d/2,d,2));
  sort(vec.begin(),vec.end());
  ll f=get<1>(vec[0]);
  double c=get<2>(vec[0]);
  if(c!=2.0){
    cout<<n*f;
    return 0;
  }
  ll m=n%2;
  cout<<(n-m)/2*f+m*get<1>(vec[1]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long int lint;
typedef unsigned long long int ulint;


lint n,a;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++){
		a=s[i];
		a+=n;
		if(a>'Z') a-='Z'-'A'+1;
		s[i]=a;
	}

	cout<<s;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
g = A[0]
for a in A:
    g = gcd(g, a)
print(g)


Measured memory_bytes: 16324
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  ll X, Y;
  cin >> X >> Y;
  if (abs(X - Y) <= 1)
    cout << "Brown" << endl;
  else
    cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int a,b;
scanf("%5d",&a);
scanf("%5d",&b);
 if(a>b){
   printf("a > b\n",a,b);
 }
 if(a<b){
   printf("a < b\n",a,b);
 }
 if(a==b){
   printf("a == b\n",a,b);
 }
}


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

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n + 1);
    int longest = 0;
    rep(i, n) cin >> a[i];
    a[n] = k + a[0];
    rep(i, n) longest = max(longest, a[i + 1] - a[i]);
    cout << k - longest << endl;
}

Measured memory_bytes: 3948