akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

vector<vector<pair<int, int>>> path;
vector<vector<pair<int, int>>> sub;

struct N {
  int now, cost;
};

bool operator<(const N &lhs, const N &rhs) { return lhs.cost < rhs.cost; }

int main() {
  while (true) {
    int n;
    int sum = 0;
    cin >> n;
    path.clear();
    sub.clear();
    if (n == 0)
      break;
    path.resize(n);
    sub.resize(n);
    vector<int> P(n - 1);
    vector<int> D(n - 1);
    for (int i = 1; i < n; i++) {
      cin >> P[i - 1];
      P[i - 1]--;
    }
    for (int i = 1; i < n; i++) {
      cin >> D[i - 1];
      sum += D[i - 1];
    }
    for (int i = 0; i < n - 1; i++) {
      path[P[i]].push_back(make_pair(i + 1, D[i]));
      path[i + 1].push_back(make_pair(P[i], D[i]));
    }
    vector<bool> c(n);
    int rest = 0;
    for (int i = 0; i < n; i++) {
      if (path[i].size() == 1) {
        rest += path[i][0].second;
        c[i] = true;
      }
    }
    int subsum = sum - rest;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < path[i].size(); j++)
        if (!c[path[i][j].first] && !c[i]) {
          sub[i].push_back(path[i][j]);
        }
    }
    vector<bool> used(n);
    int id = -1;
    for (int i = 0; i < n; i++) {
      if (c[i] || used[i])
        continue;
      multiset<N> q;
      q.insert(N{i, 0});
      while (q.size() > 0) {
        N now = *q.begin();
        q.erase(q.begin());
        if (used[now.now])
          continue;
        used[now.now] = true;
        id = now.now;
        for (int j = 0; j < sub[now.now].size(); j++) {
          q.insert(N{sub[now.now][j].first, now.cost + sub[now.now][j].second});
        }
      }
      break;
    }
    int dist = 0;
    used.clear();
    used.resize(n);
    multiset<N> q;
    q.insert(N{id, 0});
    while (q.size() > 0) {
      N now = *q.begin();
      q.erase(q.begin());
      if (used[now.now])
        continue;
      used[now.now] = true;
      dist = now.cost;
      for (int j = 0; j < sub[now.now].size(); j++) {
        q.insert(N{sub[now.now][j].first, now.cost + sub[now.now][j].second});
      }
    }
    cout << dist * 2 + (subsum - dist) * 3 + rest << endl;
  }
  return 0;
}



Measured memory_bytes: 3224
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll coin;
	cin>>coin;
	
	ll a = coin/500;
	ll b = coin%500;
	cout << a*1000 + b/5*5 <<endl;
}

Measured memory_bytes: 256
def do():
    n = int(input())
    for b in range(1,3501):
        for c in range(1,3501):
            if (4*b*c - n*b - n*c) == 0:
                continue
            a = (n*b*c) / (4*b*c - n*b - n*c)
            if a < 1:
                continue
                

            if a.is_integer():
                print(int(a),b,c)
                return 0
    return 0
do()

Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int cnt=0;
    string w,t;
    cin>>w;
    for(int i=0;i<w.size();++i){
        if('A'<=w[i]&&w[i]<'Z'){
            w[i]+='a'-'A';
        }
    }
    while(cin>>t){
        if(t=="END_OF_TEXT"){
            break;
        }
        for(int i=0;i<t.size();++i){
            if('A'<=t[i]&&t[i]<='Z'){
                t[i]+='a'-'A';
            }
        }
        if(w==t){
            ++cnt;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n;
	cin >> n;
	string s;
	map <string, int> mp;
	for(int i = 0; i < n; i++) {
		cin >> s;
		mp[s]++;
	}
	cout << (int)mp.size();
}


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

int main() {
    int N;
    cin>>N;
    double p[N];
    for(int i=0;i<N;++i){
        cin>>p[i];
    }
    double DP[N][N+1];
    DP[0][0] = 1-p[0];
    DP[0][1] = p[0];
    for(int i=1;i<N;++i){
        DP[i][0] = DP[i-1][0] * (1-p[i]);
    }
    for(int i=1;i<N;++i){
        DP[i][i+1] = DP[i-1][i]*p[i];
    }
    for(int i=1;i<N;++i){
        for(int j=1;j<=i;++j){
            DP[i][j] = DP[i-1][j-1]*p[i] + DP[i-1][j] * (1-p[i]);
        }
    }
    double ans = 0;
    for(int i=N/2+1;i<=N;++i){
        ans += DP[N-1][i];
    }
    /**
    for(int i=0;i<N;++i){
        for(int j=0;j<=N;++j){
            cout<<DP[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    **/
    cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 70272
n = int(input())
S = []
H = []
C = []
D = []
for i in range(n):
    a, b = input().split()
    b = int(b)
    if a == 'S':
        S.append(b)
    elif a == 'H':
        H.append(b)
    elif a == 'C':
        C.append(b)
    elif a == 'D':
        D.append(b)
        
for i in range(1, 14):
    if not i in S:
        print('S',i)
for i in range(1,14):
    if not i in H:
        print('H',i)  
for i in range(1,14):
    if not i in C:
        print('C',i)
for i in range(1, 14):
    if not i in D:
        print('D',i)


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

void call(int n) {
    int i = 0;
    while (++i <= n) {
        int x = i;
        
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        
        while (x) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}


int main(void) {
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[210011];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[2];

P u[1];
queue<int> q;
//stack<int> s;
set<int> s;
map<int,int> p;

vector<int> v[1];


bool as(P a,P b)
{
  return a.x<b.x;
}

int f(long long x)
{
  d++;
  printf("? %lld\n",x);
  fflush(stdout);
  char r[3];
  scanf("%s",r);
  if(r[0]=='Y') return 1;
  return 0;
}

int main()
{
  for(int t=1,i=1;t<=1000000000;i++,t*=10)
  if(f(t)==0)
  {
    a=i-1;
    goto qwe;
  }
  for(int t=1;;t*=10)
  {
    if(f(t+1)==1)
    {
      printf("! %d\n",t);
      fflush(stdout);
      return 0;
    }
  }
  qwe:;
  for(int t=1;t<a;t++)
  {
    n=0,m=9;
    if(t==1) n=1;
    for(;n<m;)
    {
      int h=(n+m)/2+1;
      if(f(x*10+h)==1) n=h;
      else m=h-1;
    }
    x=x*10+n;
  }
  n=0,m=9;
  if(a==1) n=1;
  for(;n<m;)
  {
    int h=(n+m)/2;
    if(f(x*100+h*10+1)==1) m=h;
    else n=h+1;
  }
  printf("! %lld\n",x*10+n);
  fflush(stdout);
}






Measured memory_bytes: 684
#include <iostream>
#include <memory.h>
#include <algorithm>
#include <cstdio>
#define FOR(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define FORD(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
typedef long long ll;
struct dta{
    ll v1,v2;
};
using namespace std;

ll a,b,minval,maxval,res;

dta catdoc(ll h,ll w){
    dta kq;
    kq.v1=(w/2)*h;
    kq.v2=(w-(w/2))*h;
    return kq;
}
dta catngang(ll w,ll h){
    dta kq;
    kq.v1=(w/2)*h;
    kq.v2=(w-(w/2))*h;
    return kq;
}
int main(){
    cin>>a>>b;
    res=1e18;
    FOR(i,1,a){ // cat doc
        dta tmp=catdoc(a-i,b);
        minval=min(i*b,min(tmp.v1,tmp.v2));
        maxval=max(i*b,max(tmp.v1,tmp.v2));
        res=min(res,maxval-minval);
        tmp=catngang(a-i,b);
        minval=min(i*b,min(tmp.v1,tmp.v2));
        maxval=max(i*b,max(tmp.v1,tmp.v2));
        res=min(res,maxval-minval);
    }
    FOR(i,1,b){
        dta tmp=catdoc(a,b-i);
        minval=min(i*a,min(tmp.v1,tmp.v2));
        maxval=max(i*a,max(tmp.v1,tmp.v2));
        res=min(res,maxval-minval);
        tmp=catngang(a,b-i);
        minval=min(i*a,min(tmp.v1,tmp.v2));
        maxval=max(i*a,max(tmp.v1,tmp.v2));
        res=min(res,maxval-minval);
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main (void) {
	long int sum = 0;
	int  n, i;
	
	scanf("%d", &n);
	
	for (i = 0; i <= n; i++) {
		//printf("%d   %d\n", i%3, i%5);
		if(i%3 == 0 || i%5 == 0) {
			
		}
		else {
			sum += i;
		}
	}
	printf("%ld\n", sum);
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int a;
	cin>> a;

	cout<< a+a*a+a*a*a << endl;
 
	return 0;
}

Measured memory_bytes: 3636
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[200010];
ll dist[200010] = {};
ll ans[200010] = {};
ll N;
ll cur_ans = 1;

struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};
Combination cb(200010);


void dfs(ll cur, ll par){
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur);
        dist[cur] += dist[e];
    }
    dist[cur]++;
}


void dfs2(ll cur, ll par){
    ll sum = 0;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        sum += dist[e];
    }

    for(auto &e: tree[cur]){
        if(e == par) continue;
        (cur_ans *= cb.nck(sum, dist[e])) %= MOD;
        sum -= dist[e];
        dfs2(e, cur);
    }

}


void dfs3(ll cur, ll par){
    ans[cur] = cur_ans;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        ll v1 = cb.nck(N-1, N - dist[e]);
        (cur_ans *= v1) %= MOD;
        ll v2 = cb.nck(N-1, dist[e]);
        (cur_ans *= cb.power(v2, MOD-2)) %= MOD;
        ll tmp = dist[e];
        dist[e] = N;
        dist[cur] = N - tmp;
        dfs3(e, cur);
        dist[e] = tmp;
        dist[cur] = N;
        (cur_ans *= v2) %= MOD;
        (cur_ans *= cb.power(v1, MOD-2)) %= MOD;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll a[200010], b[200010];
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
    }
    dfs(0, -1);
    dfs2(0, -1);
    dfs3(0, -1);
    rep(i,0,N) print(ans[i]);
}


Measured memory_bytes: 24304
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int>
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int N = 400000 + 5;
const int M = 1e9 + 7;
int A[N];
int pA[N];
int B[N];
int pB[N];
int n , m , k;

bool check(int mid)
{
 int sum = 0;
 int mn = INF;
 loop(i, 0, mid + 1)
 {
  if ( i > n ) break;
  int t = INF;
  if ( mid - i <= m ) t = pA[i] + pB[mid - i];
  mn = min(mn, t);
 }

 return mn <= k;
}

void solve()
{
 cin >> n >> m >> k;
 int sum = 0;
 loop(i, 0, n)cin >> A[i];
 loop(i, 1, n + 1) sum += A[i - 1] , pA[i] = sum;
 sum = 0;
 loop(i, 0, m)cin >> B[i];
 loop(i, 1, m + 1)sum += B[i - 1] , pB[i] = sum;

 // loop(i,1,n+1)cout << pA[i] << " ";cout << endl;

 int ans = 0;

 int st = 0 , en = n + m;

 while (st <= en)
 {
  int mid = (st + en) / 2;
  if (check(mid))
  {
   ans = mid;
   st = mid + 1;
  }
  else en = mid - 1;
 }

 cout << ans;

}

int32_t main()
{

 cout << fixed << setprecision(16);

 ios_base:: sync_with_stdio(false);
 cin.tie(NULL); cout.tie(NULL);


 int t = 1;
 // cin >> t;
 while (t--)solve();

}

Measured memory_bytes: 9916
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    vvi cs(3, vi(3));
    cin>>cs;
    bool ans = true;
    rep(i, 2) {
        if (cs[i][1] - cs[i][0] != cs[i + 1][1] - cs[i + 1][0]) ans = false;
        if (cs[i][2] - cs[i][0] != cs[i + 1][2] - cs[i + 1][0]) ans = false;
        if (cs[i][2] - cs[i][1] != cs[i + 1][2] - cs[i + 1][1]) ans = false;
    }
    rep(i, 2) {
        if (cs[1][i] - cs[0][i] != cs[1][i + 1] - cs[0][i + 1]) ans = false;
        if (cs[2][i] - cs[0][i] != cs[2][i + 1] - cs[0][i + 1]) ans = false;
        if (cs[2][i] - cs[1][i] != cs[2][i + 1] - cs[1][i + 1]) ans = false;
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A.at(i);
    }
    ll sum = 0;
    ll tmp = 0;
    for(ll i=0;i<N;i++){
        tmp = max(A.at(i),tmp);
        if(tmp>A.at(i)){
            sum += tmp-A.at(i);
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    int res=0;
    for(int i=1;i<=n;i++){
        if(i%2==0)continue;
        int tmp=0;
        for(int j=1;j<=i;j++) if(i%j==0)tmp++;
        if(tmp==8)res++;
    }
    cout<<res<<endl;
}

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

int main(){
	int n , m;
	int t[50001]={0};
	for(int i=1;i<50001;++i){
		t[i]=1e+9;
	}
	cin >> n >> m;
	int* c = new int [m];
	for(int i=0;i<m;++i){
		cin >> c[i];
	}
	for(int i=0 ; i<m;++i){
		for(int j=c[i]; j<n+1 ;++j){
			t[j]=min(t[j] , t[j-c[i]]+1);
		}
	}
	cout << t[n] << endl;
	delete [] c;
	return 0;
}

Measured memory_bytes: 1396
function exawizards2019_A()

    # STEP.01
    # read out the given integers
    A, B, C = Base.parse.(Base.split(Base.readline(Base.STDIN)))

    # STEP.02
    # determine if there exists an equilateral triangle whose sides have lengths A, B and C.
    if Base.isequal(A, B) && Base.isequal(B, C)
        Base.println(Base.STDOUT, "Yes")
    else
        Base.println(Base.STDOUT, "No")
    end

    # STEP.TRUE_END
    return Base.nothing

end

Main.exawizards2019_A()

Measured memory_bytes: 175592
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

map<ll,ll> mp;

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

  ll n,m,sum=0;
  cin >> n >> m;

  mp[0]++;
  REP(i,n){
    ll a;
    cin >> a;
    sum += a;
    mp[sum%m]++;
  }
  ll ans = 0LL;
  for(auto &e: mp){
    ans += e.second*(e.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
// No.202525032120
#include <bits/stdc++.h>
#define N 1001000
using namespace std;

int n, a[N];

int main() {
#ifdef isLOCAL
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%1d", a + i);

    for (int i = 1; i < n; ++i)
        a[i] = abs(a[i] - a[i + 1]);
    a[n] = 0;

    bool flag = 1;
    for (int i = 1; i < n; ++i)
        if (a[i] == 1) flag = 0;

    for (int i = 1; i < n; ++i)
        if (a[i] == 2) a[i] = flag;

    int ans = 0;
    for (int i = 0; i < n - 1; ++i)
        if (a[i + 1] == 1) ans ^= (((n - 2) & i) == i);

    if (ans) puts(flag ? "2" : "1");
    else puts("0");

    return 0;
}


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

const int N = 52;
const int mid = N*N/2;

int dp[N][N*N];

signed main() {
  int n, A;
  cin >> n >> A;

  vector<int> x(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    x[i] -= A;
  }

  memset(dp, 0, sizeof(dp));
  dp[0][mid] = 1;

  for (int i = 1; i <= n; i++) {
    for (int s = 0; s + x[i] < N * N; s++) {
      dp[i][s] += dp[i - 1][s];
      if(s + x[i] >= 0)
        dp[i][s + x[i]] += dp[i - 1][s];
    }
  }

  cout << dp[n][mid] - 1 << endl;
  return 0;
}

Measured memory_bytes: 4708
using System;
using System.Linq;

namespace ABC109C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long[] longs = ConsoleInput.LongArray();
            long N = longs[0];
            long X = longs[1];
            long[] Xi = ConsoleInput.LongArray();
            
            long[] Defs = new long[N + 1];
            for (int i = 0; i < N; i++)
            {
                Defs[i] = Xi[i] - X;
            }

            Defs[N] = 0;
            
            Array.Sort(Defs);
            long gcd = 0;
            for (int i = 0; i < N; i++)
            {
                long diff = Defs[i + 1] - Defs[i];
                if (gcd == 0)
                {
                    gcd = diff;
                    continue;
                }
                gcd = Gcd(gcd, diff) ;
                if (gcd == 1)
                {
                    break;
                }
            }
            Console.WriteLine(gcd);
        }

        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }
    }
    
    
    
    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
    
}

Measured memory_bytes: 21856
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,d=0,e=0;
	cin>>x>>y;
	int c[y+1];
	for(int i=1;i<=y;i++)
	cin>>c[i];
	for(int i=0;i<=y;i++)
	{
		d=0;
		e=0;
		for(int k=1;k<=y;k++)
		{
			if(x+i==c[k])
			{
				d++;
 			}
			if(x-i==c[k])
			{
				e++;
			}
		}
		if(e==0)
		{ 
			cout<<x-i<<endl;
			return 0; 
		} 
		if(d==0)
		{
			cout<<x+i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 k; cin>>k;
    vector<ll> a(k);
    rep(i,k) cin>>a[i];
    vector<ll> ans={2,2};
    rep(i,k){
        if(ans[1]<a[k-1-i]){ans={-1,-1}; break;}
        if(ans[0]%a[k-1-i]!=0) ans[0]=(1+ans[0]/a[k-i-1])*a[k-i-1];
        ans[1]=(1+ans[1]/a[k-i-1])*a[k-i-1]-1;
    }
    if(ans[0]==-1 || ans[0]>ans[1]) cout<<-1<<endl;
    else cout<<ans[0]<<' '<<ans[1]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 998244353LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	if(n % 2 == 0) {
		set<pll> ans;
		FOR(i, 1, n + 1) {
			FOR(j, 1, n + 1) {
				if(i == j) continue;
				if(i + j != n + 1) {
					ll a = i, b = j;
					if(a > b) swap(a, b);
					ans.insert({a, b});
				}
			}
		}
		cout << (ll)ans.size() << endl;
		for(auto p: ans) {
			cout << p.first << " " << p.second << endl;
		}
	} else {
		set<pll> ans;
		FOR(i, 1, n + 1) {
			if(i == n) continue;
			FOR(j, 1, n + 1) {
				if(i == j) continue;
				if(j == n) continue;
				if(i + j != n) {
					ll a = i, b = j;
					if(a > b) swap(a, b);
					ans.insert({a, b});
				}
			}
		}
		FOR(i, 1, n + 1) {
			if(i == n) continue;
			ll a = n, b = i;
			if(a > b) swap(a, b);
			ans.insert({a, b});
		}
		cout << (ll)ans.size() << endl;
		for(auto p: ans) {
			cout << p.first << " " << p.second << endl;
		}
	}
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,m;
	cin >> n >>m;
	
	ll ans = (n-m)*100ll + m*1900ll;
	
	ans *= pow(2,m);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a,b,x;
long long s;
int bits(int num) {
	int cnt = 0;
	while(num != 0)
		cnt++,num/=10;
	return cnt;
}
int main()
{
	scanf("%d%d",&a,&b);
	s = a*pow(10,bits(b));
	s += b,x = sqrt(s);
	if(x*x!=s) printf("No");
	else printf("Yes");
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,ans=0;
ll a[1000];
vector<ll> choice;
const ll MOD = 1000000007;
ll com(vector<ll> num){
    ll x=0;
    for(auto i:num){
        ll t=1;
        For(j,0,i-1){
            t*=2;
        }
        x+=t;
    }
    return x;
}
void Main(){    
    cin>>n>>m;
    vector<bool> flags(n,false);
    vector<vector<ll>> c(m);
    For(i,0,m){
        cin>>a[i];
        ll b;cin>>b;
        For(j,0,b){
            ll C;cin>>C;
            c.at(i).push_back(C);
            flags.at(C-1)=true;
        }
    }
    bool flag=true;
    For(i,0,n){
        flag=(flags.at(i)&&flag);
    }
    For(i,0,n){
        flags.at(i)=false;
    }
    ll t=1;
    For(i,0,n) t*=2;
    vector<vector<ll>> cost(m,vector<ll>(t,MOD));
    if(flag){
        ll num0=com(c.at(0));
        For(j,0,num0+1){
            cost.at(0).at((j & num0))=a[0];
        }
        For(i,1,m){
            ll num=com(c.at(i));
            For(j,0,t){
                cost.at(i).at(j)=cost.at(i-1).at(j);
            } 
            For(j,0,num+1){
                cost.at(i).at((j & num))=min(cost.at(i).at((j & num)),a[i]);
            }       
            For(j,0,t){
                cost.at(i).at((j|num))=min(cost.at(i).at((j|num)),min(cost.at(i-1).at((j|num)),cost.at(i-1).at(j)+a[i]));
            }
        }
        /*For(i,0,m){
            For(j,0,t){
                cout<<cost.at(i).at(j)<<" ";
            }
            cout<<endl;
        }*/
        cout<<cost.at(m-1).at(t-1)<<endl;
    }
    else{
        cout<<-1<<endl;
    }

}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 32512
#include <iostream> // cout, endl, cin
#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 <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i=0; i<26; i++) cin >> c[i];
    vector<vector<int>> G(d,vector<int> (26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> G[i][j];
        }
    }
    vector<int> t(d);
    int sum = -inf;
    for(int i=0; i<d; i++){
        t[i] = rand()%26;
    }
    for(int k=0; k<10000; k++){
        vector<P> pre(100);
        for(int i=0; i<100; i++){
            int a = rand() % d;
            int b = rand() % 26;
            pre[i].first = a;
            pre[i].second = t[a];
            t[a] = b;
        }
        vector<int> now(26,0);
        vector<int> last(26,0);
        for(int i=0; i<d; i++){
            last[t[i]] = i+1;
            now[t[i]] += G[i][t[i]];
            for(int j=0; j<26; j++){
                now[t[i]] -= c[j] * (i+1 - last[j]);
            }
        }
        int s = 0;
        for(int j=0; j<26; j++){
            s += now[j];
        }
        if(s > sum){
            sum = s;
        }else{
            for(int i=0; i<100; i++){
                t[pre[i].first] = pre[i].second;
            }
        }
    }
    for(int i=0; i<d; i++){
        cout << t[i]+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define MAX 500005
#define MAX_BIT 50
#define PRECISION 0.00000000001
#define INF 2000000000
pair<pair<int,int>,int> arr[MAX];
int BLOCK_SIZE;
int cnt[MAX];
vector<pair<pair<int,int>,pair<int,int> > > Queries;
bool sortByIndex(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b)
{
    return a.first.second<b.first.second;
}
bool sortByMO(pair<pair<int,int>,pair<int,int> > a,pair<pair<int,int>,pair<int,int> > b)
{
    return (a.second.first/BLOCK_SIZE<b.second.first/BLOCK_SIZE)||((a.second.first/BLOCK_SIZE==b.second.first/BLOCK_SIZE)&&a.second.second<b.second.second);
}
int addElement(int index)
{
    int ans=(cnt[arr[index].second]==0);
    cnt[arr[index].second]++;
    //printf("Adding %d->%d\n",index,ans);
    return ans;
}
int removeElement(int index)
{
    cnt[arr[index].second]--;
    int ans=(cnt[arr[index].second]==0);
    //printf("Removing %d->%d\n",index,ans);
    return ans;
}
void process(int n)
{
    BLOCK_SIZE=sqrt(n);
    if(n%BLOCK_SIZE) BLOCK_SIZE++;
    int q=Queries.size();
    sort(Queries.begin(),Queries.end(),sortByMO);
    sort(arr,arr+n);
    int i=0;
    arr[i].second=0;
    for(i=1;i<n;i++)
    {
        arr[i].second=arr[i-1].second+(arr[i].first.first!=arr[i-1].first.first);
    }
    sort(arr,arr+n,sortByIndex);
    int l=1,r=0;
    int ans=0;
    for(i=0; i<q; i++)
    {
        //printf("Query %d: %d - %d\n",i+1,Queries[i].second.first+1,Queries[i].second.second+1);
        while(r<Queries[i].second.second)
        {
            ans=ans+addElement(++r);
        }
        while(r>Queries[i].second.second)
        {
            ans=ans-removeElement(r--);
        }
        while(l>Queries[i].second.first)
        {
            ans=ans+addElement(--l);
        }
        while(l<Queries[i].second.first)
        {
            ans=ans-removeElement(l++);
        }
        Queries[i].first.second=ans;
    }
    sort(Queries.begin(),Queries.end());
}
int main()
{
    int n,i,j,q;
    pair<pair<int,int>,pair<int,int> > query;
    scanf("%d",&n);
    scanf("%d",&q);
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i].first.first);
        arr[i].first.second=i;
    }
    for(i=0;i<q;i++)
    {
        scanf("%d %d",&query.second.first,&query.second.second);
        query.second.first--;
        query.second.second--;
        query.first.first=i;
        Queries.push_back(query);
    }
    process(n);
    for(i=0;i<q;i++)
    {
        printf("%d\n",Queries[i].first.second);
    }
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int d;

int main(void) {
    // Here your code !
    scanf("%d", &d);

    if (d == 25) {
      printf("Christmas\n");
    } else if (d == 24) {
      printf("Christmas Eve\n");
    } else if (d == 23) {
      printf("Christmas Eve Eve\n");
    } else {
      printf("Christmas Eve Eve Eve\n");
    }

    return 0;
}


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

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

  vector<int> h(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> h.at(i);
  }

  vector<long long int> min_cost(N + 1);
  for (int i = 0; i < N + 1; i++)
  {
    min_cost.at(i) = 1e+12;
  }
  min_cost.at(1) = 0;

  for (int i = 1; i <= N - 1; i++)
  {
    for (int j = 1; j <= min(K, N - i); j++)
    {
      min_cost.at(i + j) =
          min(min_cost.at(i + j),
              min_cost.at(i) + abs(h.at(i + j) - h.at(i)));
    }
  }
  cout << min_cost.at(N) << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    
    char data[h+2][w+2];
    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            data[i][j] = '#';
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> data[i+1][j+1];
        }
    }
    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            cout << data[i][j];
        }
        cout << endl;
    }
    return 0;

}

Measured memory_bytes: 3644
n = 0
until gets.to_i == 0
	n += 1
	maxweight = $_.to_i
	
	a = []
	possible = Array.new(maxweight+1,nil)
	possible[0] = 0
	
	gets.to_i.times{|i|
		temp = Array.new(maxweight+1,nil)
		price,weight = gets.split(',').map &:to_i
		(maxweight+1).times{|j|
			if possible[j]
				temp[j+weight] = possible[j] + price
				possible[j] = [possible[j],temp[j].to_i].max
			else
			    possible[j] = temp[j]
			end
		}
	}
	puts "Case #{n}:"
	puts a = possible[0..maxweight].map(&:to_i).max
	puts possible.index(a)
end

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

long long mod = 998244353;
long long fact[1 << 20];
long long factinv[1 << 20];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2LL == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i <= 1000000; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= 1000000; i++) factinv[i] = Div(1, fact[i], mod);
}

long long ncr(int n, int r) {
	if (r < 0 || n < r) return 0;
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}

long long katalan(int a, int b) {
	long long r1 = (a - b + 1);
	long long r2 = fact[a + b];
	long long r3 = factinv[b];
	long long r4 = factinv[a + 1];
	return (r1 * r2 % mod) * (r3 * r4 % mod) % mod;
}

long long N, M;

int main() {
	// 入力
	init();
	cin >> N >> M;
	if (N < M) { swap(N, M); }

	// 場合分け
	if (N == M) {
		long long r1 = ncr(2 * N, N);
		long long r2 = modpow(2, 2 * N - 1, mod);
		cout << (N - Div(1, 2, mod) + Div(r2, r1, mod) + mod) % mod << endl;
		return 0;
	}

	// 計算
	long long Answer1 = 0;
	long long Answer2 = ncr(N + M, N);
	for (int i = 0; i <= M; i++) {
		long long v1 = Div(modpow(2, 2 * i, mod), 2, mod) + (N * ncr(2 * i, i) % mod);
		long long v2 = katalan(N - i - 1, M - i);
		Answer1 += (v1 * v2 % mod);
		Answer1 %= mod;
	}

	// 出力
	long long FinalAns = Div(Answer1, Answer2, mod);
	FinalAns = (FinalAns - Div(1, 2, mod) + mod) % mod;
	cout << FinalAns << endl;
	return 0;
}

Measured memory_bytes: 19268
def main():
    max_num = 10**6
    N = int(input())
    A = list(map(int, input().split()))
    M = {}
    for a in A:
        if a not in M:
            M[a] = 0
        M[a] += 1
    B = sorted(set(A))
    S = [0]*(max_num + 1)
    ans = 0

    for b in B:
        if S[b] != 0:
            continue
        if M[b] == 1:
            ans += 1
        v = b
        while v <= max_num:
            S[v] = 1
            v += b
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44312
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b, c, d = Input()

    if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
        print("Yes")
    else:
        print("No")


main()

Measured memory_bytes: 9128
#include <stdio.h>

int selectionSort(int A[], int N)
{
    int i, j, t, sw = 0, minj;
    for (i = 0; i < N - 1; i++)
    {
        minj = i;
        for (j = i; j < N; j++)
        {
            if (A[j] < A[minj])
            {
                minj = j;
            }
        }
        t = A[i];
        A[i] = A[minj];
        A[minj] = t;
        if (i != minj)
            sw++;
    }
    return sw;
}

int main()
{
    int A[100], N, i, sw;

    scanf("%d", &N);
    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    sw = selectionSort(A, N);

    for (i = 0; i < N; i++)
    {
        if (i > 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);

    return 0;
}


Measured memory_bytes: 2764
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
MIN,MAX = min(aa),max(aa)
SUM = sum(aa)
S = N*(N+1)//2

def main():
	if SUM%S != 0:
		return 'NO'
	else:
		k = SUM // S
		if MIN < k or k*N < MAX:
			return 'NO'
		tmp = 0
		for i in range(N):
			d = aa[i-1] - aa[i]
			d += k
			if d % N == 0:
				tmp += d//N
			else:
				return 'NO'
		if tmp == k:
			return 'YES'
		else:
			return 'NO'

print(main())


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

int main(){
    int a, i = 0;
    cin >> a;

    while (a != 4 && a != 2 && a != 1){
        if (a % 2 == 0)
            a = a / 2;
        else
            a = a * 3 + 1;
        i++;
        // cout << a << endl;
    }
    cout << i + 4 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int N;
ll K;
vector<ll> A;

struct cum_sum_lm {
	vector<ll> sum;
	int N;
	cum_sum_lm() = default;
	cum_sum_lm(int _N) {
		N = _N;
		sum.resize(N + 1);
	}

	void setup(vector<ll>& _ar) {
		sum.resize(_ar.size() + 1);
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + _ar[i];
			sum[i + 1] %= K;
		}
	}
	ll getval(int l, int r) {
		//[l, r)
		ll ret = (sum[r] - sum[l] + K) % K;
		return ret;
	}
};

map<ll, int> cnt;

int main() {
	cin >> N >> K;
	A.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
		A[i] %= K;
	}

	cum_sum_lm cs(N);
	cs.setup(A);

	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		if (i >= K) {
			cnt[cs.getval(0, i - K)]--;
		}
		ans += cnt[cs.getval(0, i)];
		cnt[cs.getval(0, i)]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int b[1000001];
int main(){
	int i,n,s=0;
	cin>>n;
	int a[n+1];
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++){
		for(int j=a[i];j<=a[n];j+=a[i]){
			b[j]++;
		}
	}
	for(i=1;i<=n;i++)
		if(b[a[i]]==1) s++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define H_MAX 50
#define W_MAX 50

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int H,W;

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int main() {
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	if(e-a >  k) {
		cout << ":(" << endl;
	}
	else
		cout << "Yay!" << endl;
	

  return 0;
}
 


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

int main(){
    int m,f,r;
    char grade;
    while(true){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1) break;
        if(f==-1||m==-1){
            grade = 'F';
        }else if(80<=m+f){
            grade = 'A';
        }else if(65<=m+f&&m+f<80){
            grade = 'B';
        }else if(50<=m+f&&m+f<65){
            grade = 'C';
        }else if(30<=m+f&&m+f<50){
            if(r>=50) grade = 'C';
            else grade = 'D';
        }else if(m+f<30){
            grade = 'F';
        }
        cout<<grade<<'\n';
    }
}


Measured memory_bytes: 3068
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

ll A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint(), K = getint();

	rep1(i, N) {
		A[i] = A[i - 1] + getint();
	}

	int p = N;
	while (p >= 1 && A[p] > K) p--;
	ll kotae = p;
	ll B = 0;
	rep1(i, M) {
		B += getint();
		if (B > K) break;
		while (p >= 1 && A[p] + B > K) p--;
		if (kotae < i + p) kotae = i + p;
	}

	printf("%d\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3292
package main

import(
    "fmt"
)



func main() {
    var a,b,c string
    fmt.Scan(&a,&b,&c)
    fmt.Printf("%c%c%c",a[0],b[1],c[2])
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
n=int(input())
a=[[int(i) for i in input().split()]for i in range(n)]

time=0
sum_xy=0
for t,x,y in a:
    if t-time<abs(sum_xy-(x+y)) or (t-time)%2!=(sum_xy-(x+y))%2:
        print('No')
        exit()
    time=t
    sum_xy=x+y
print('Yes')

Measured memory_bytes: 21156
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;
#define ll long long
 
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){x=x*10+c-48;c=getchar();}
	return x*f;
}
 
inline ll llread()
{
	ll x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){x=x*10+c-48;c=getchar();}
	return x*f;
}

ll l;
ll a[200005];
int n;
ll sum[200005],pre[200005];
ll ans=0;

int main()
{	
	int i; 
	l=llread(); n=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	for(i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(i=n;i>=1;i--)
		pre[i]=pre[i+1]+l-a[i];
	int step=0,x;
	ll cou=0;
	for(i=1;i<=n;i++)
	{
		step=n-i;
		x=i+(step/2);
		if(step&1)
			cou=(pre[x+2]+sum[x]-sum[i-1])*2+l-a[x+1];
		else
			cou=(pre[x+1]+sum[x-1]-sum[i-1])*2+a[x];
		ans=max(ans,cou);
	}
	for(i=1;i<=n;i++)
		a[i]=l-a[i];
	ll t; 
	for(i=1;i<=n-i+1;i++)
	{ 
		t=a[i];
		a[i]=a[n-i+1];
		a[n-i+1]=t;
	}
	sum[0]=0;
	for(i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	pre[n+1]=0; 
	for(i=n;i>=1;i--)
		pre[i]=pre[i+1]+l-a[i];
	for(i=1;i<=n;i++)
	{
		step=n-i;
		x=i+(step/2);
		if(step&1)
			cou=(pre[x+2]+sum[x]-sum[i-1])*2+l-a[x+1];
		else
			cou=(pre[x+1]+sum[x-1]-sum[i-1])*2+a[x];
		ans=max(ans,cou);
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 8392