akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int KMPSearch(string& S,string& Q){
	vector<int> T(Q.size());
	T[0]=-1;
	if(T.size()>1) T[1]=0;
	for(int i=2,j=0,ei=Q.size();i<ei;){
		if(Q[i-1]==Q[j]){
			T[i] = ++j;
			i++;
		}
		else if(j>0){
			j = T[j];
		}
		else{
			T[i++] = 0;
		}
	}
	for(int m=0,i=0,es=S.size(),eq=Q.size();m+i<es;){
		if(Q[i]==S[m+i]){
			//if(i==e) return m;
			if(i+1==eq){
				out(m);
				m = m+i-T[i];
				if(i>0) i = T[i];
			}
			else i++;
		}
		else{
			m = m+i-T[i];
			if(i>0) i = T[i];
		}
	}
	return S.size();
}

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

	string S=in<string>(),T=in<string>();
	KMPSearch(S,T);

	return 0;
}



Measured memory_bytes: 4492
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=1e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

int n;
int a[maxn],o[maxn],e[maxn];
set<int>odd,even;

PII best[2][2];
int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	for(int i=0;i<n;i+=2) e[a[i]]++;
	for(int i=1;i<n;i+=2) o[a[i]]++; 
	
	
	for(int i=0;i<maxn;i++){
		if(mp(e[i],i)>best[0][0])
		best[0][1]=best[0][0],best[0][0]=mp(e[i],i);
		else if(mp(e[i],i)>best[0][1])
		best[0][1]=mp(e[i],i);
	}
	for(int i=0;i<maxn;i++){
		if(mp(o[i],i)>best[1][0])
		best[1][1]=best[1][0],best[1][0]=mp(o[i],i);
		else if(mp(o[i],i)>best[1][1])
		best[1][1]=mp(o[i],i);
	}  //找前两个数的比较方法 
	int res = 0;
    if (best[0][0].second == best[1][0].second)
        res = max(best[0][0].first + best[1][1].first,
                  best[0][1].first + best[1][0].first);
    else res = best[0][0].first + best[1][0].first;
    printf("%d\n", n - res);
	
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
#define ll long long 
using namespace std;

bool issqaure(int n){
    int s = sqrt(n);
    return ((s * s) == n);
}
int main(){
   int n,d;
   cin >> n >> d;
   int a[n][d];
   for(int i = 0; i < n; i++){
       for(int j = 0; j < d; j++){
           cin >> a[i][j];
       }
   }
   int ans = 0;
   
   for(int i = 0; i < n - 1; i++){
       for(int j = i + 1; j < n; j++){
           int a1 = 0;
           for(int k = 0; k < d; k++){
               a1+= (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
           }
           if(issqaure(a1)) ans++;
       }
   }
   
   cout << ans << endl;
}

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

using namespace std;

int main(){
    int N;
    int a, b;
    cin >> N;
    vector<pair<int, int>> ABs(N);
    for(int i = 0; i < N; ++i){
        cin >> a >> b;
        ABs[i] = make_pair(b, a);
    }

    sort(ABs.begin(), ABs.end());
    long long nowTime = 0;
    for(auto i: ABs){
        if(nowTime+i.second <= i.first){
            nowTime += i.second;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  vector<vector<int>> g(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      g[i][j] = s[j] - '0';
    }
  }
  int ans = -1;
  for (int st = 0; st < n; st++) {
    vector<int> level(n);
    level[st] = 1;
    queue<int> que;
    que.push(st);
    while (que.size()) {
      int cur = que.front();
      que.pop();
      for (int i = 0; i < n; i++) {
        if (!g[cur][i]) continue;
        if (!level[i]) {
          level[i] = level[cur] + 1;
          que.push(i);
        }
      }
    }
    bool no = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (g[i][j]) {
          if (abs(level[i] - level[j]) != 1) {
            no = true;
          }
        }
      }
    }
    if (!no) ans = max(ans, *max_element(level.begin(), level.end()));
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 384
n = int( input() )
v = list( map( int, input().split() ) )
c = list( map( int, input().split() ) )

max_eff = 0
for i in range(2**n):
    val_sum = 0
    cos_sum = 0
    for j in range(n):
        if ( i >> j ) & 1:
            val_sum += v[j]
            cos_sum += c[j]
    if max_eff < val_sum - cos_sum:
        max_eff = val_sum - cos_sum

print(max_eff)

Measured memory_bytes: 42092
#include<stdio.h>
int main(){
	char str[101],str1[101];
	int i,n;
	scanf("%d %s %s",&n,&str,&str1);
	for(i=0;i<2*n;i++){
		if(i%2==0){
			printf("%c",str[i/2]);
		}else printf("%c",str1[(i-1)/2]);
	}
} 

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int lnum = 753, ans = 0;
  string str;
  vector<int> split_val;

  cin >> str;
  for (int i = 0; i < str.size() - 2; ++i) {
    string tmp;
    for (int j = 0; j < 3; ++j)
      tmp += str[i + j];
    split_val.push_back(atoi(tmp.c_str()));
  }
  for (auto val : split_val) {
    if (abs(val - lnum) < ans | ans == 0)
      ans = abs(val - lnum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from functools import reduce
n = int(input())

ans = 0
def dfs(numl):
    global ans
    if 3 in numl and 5 in numl and 7 in numl and n >= reduce( lambda a,b:10*a+b, numl):
        ans += 1
    if len(str(n)) > len(numl):
        for i in [3,5,7]:
            dfs(numl+[i])

dfs([])
print(ans)

Measured memory_bytes: 52444
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=30;
int n,id,t[30];
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)t[s[i]-'a']++;
	if(n<26)
	{
		for(int i=1;i<=n;i++)putchar(s[i]);
		for(int i=0;i<26;i++)
			if(!t[i]){putchar(i+'a');break;}
		return 0;
	}
	t[s[n]-'a']--;
	for(int i=n-1;i>=1;i--)
		if(s[i]<s[i+1]){id=i;break;}
		else t[s[i]-'a']--;
	if(!id){printf("-1");return 0;}
	for(int i=1;i<id;i++)putchar(s[i]);
	for(int i=s[id]-'a'+1;i<26;i++)
		if(!t[i]){putchar(i+'a');break;}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll power(ll a,ll b){
  ll res=1;
  while(b>0){
    if(b&1) res=res*a;
    a=a*a;
    b>>=1;
  }
  return res;
}

int main(){
  ll N,P,ans=0;
  cin>>N>>P;
  ll A[N],S=0,T=0;
  REP(i,N){
    cin>>A[i];
    A[i]%=2;
    if(A[i]==0) S++;
    else T++;
  }
  
  ans=power(2,T-1);
  if(T==0 && P==1) ans=0;
  ans*=power(2,S);
  
  co(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, r, g, b, n, ans = 0;
  scanf("%lld%lld%lld%lld", &r, &g, &b, &n);
  for(i = 0; i * r <= n; ++i) for(j = 0; i * r + j * g<= n; ++j) if(!((n - i * r - j * g) % b)) ++ans;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
typedef long long ll;
const ll INF = 99999999;
using namespace std;

int main(void) {

    int n; cin >> n;
    ll t_min = INF;
    ll t_max = -INF;
    ll t_sum = 0;
    for (int i = 0; i < n; i++) {
        ll tmp; cin >> tmp;
        t_min = min(t_min, tmp);
        t_max = max(t_max, tmp);
        t_sum += tmp;
    }

    cout << t_min << " " << t_max << " " << t_sum << endl;

    return 0;
}

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


#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 10000007
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 
#define mod  1000000007



int main()
{
	FAST;
	int n;
	cin >> n;
	n --;
	n = abs(n);
	cout << n;
	
	return 0;
}

Measured memory_bytes: 3648
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/abc095/tasks/arc096_a

def solve():
    A, B, C, X, Y = list(map(int, input().split()))

    ans = 0
    # 用意するピザの少ない方をまず買う
    if A+B <= C*2:
        # 1枚ずつ買ったほうが安い場合
        if X <= Y:
            ans += A*X + B*X
        else:
            ans += A*Y + B*Y
    else:
        # Cを2枚買った方が安い場合
        ans += min(X, Y)*C*2

    # 残りのピザを買う
    if X >= Y:
        if A <= C*2:
            ans += (X-Y)*A
        else:
            ans += (X-Y)*C*2
    else:
        if B <= C*2:
            ans += (Y-X)*B
        else:
            ans += (Y-X)*C*2

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n;
  cin >> n;
  while(n-- > 0){
    int X,Y,H,W;
    cin >> X >> Y >> W >> H;
    int m;
    cin >> m;
    int cnt = 0;
    rep(i,m){
      int x,y;
      cin >> x >> y;
      if(X <= x && x <= X+W && Y <= y && y <= Y+H){
	cnt++;
      }
    }
    cout << cnt << endl;
  }
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> l(n);
  for(ll i = 0; i < n; i++) cin >> l[i];
  sort(all(l));
  ll sum = 0;
  for(ll i = 0; i < n-1; i++){
    sum += l[i];
  }
  if(l[n-1] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,m;
  cin >> n >> m;
  rep(i,m){
      ll a;
      cin >> a;
      n-=a;
  
  }
  if(n<0)cout << -1 << endl;
  else cout << n << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(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(){
    string s; cin>>s;
    string def[3] = {"Sunny", "Cloudy" , "Rainy"};
    int ans = 0;
    rep(i, 3) {
        if(def[i] == s){
            ans = (i+1) %3;
        }
    }
    cout << def[ans] << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,m;cin>>n>>m;
  vl k(m);
  vvl s(m,vl(0));
  rep(i,m){
    cin>>k[i];
    rep(j,k[i]){
      ll t;cin>>t;
      t--;
      s[i].push_back(t);
    }
  }
  vl p(m);
  rep(i,m)cin>>p[i];
  ll count=0;
  rep(bit,1<<n){
    ll part=0;
    rep(i,m){
      ll sum=0;
      rep(j,k[i]){
        if(1<<s[i][j]&bit)sum+=1;
      }
      if(sum%2==p[i])part++;
    }
    if(part==m)count++;
  }
  cout<<count<<endl;
}
      
  
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<int64> A(X), B(Y), C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    sort(all(A));
    sort(all(B));
    sort(all(C));

    vector<int64> v;
    rep(i, X) rep(j, Y) v.push_back(A[i] + B[j]);
    sort(all(v));
    reverse(all(v));

    vector<int64> v2(min((int)v.size(), 3000));
    copy(v.begin(), v.begin()+v2.size(), v2.begin());
    
    vector<int64> ans;
    rep(i, v2.size()) rep(j, Z) {
        ans.push_back(v2[i] + C[j]);
    }

    sort(all(ans));
    reverse(all(ans));
    rep(i, K) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 43368
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let p = read_vec::<f64>();

    let exp = p.into_iter().map(|x| (1.0 + x) / 2.0).collect::<Vec<_>>();
    let mut seq_exp = vec![0.0; n];
    for i in 0..k {
        seq_exp[0] += exp[i];
    }
    let mut ans = seq_exp[0];
    for i in 1..n - k + 1 {
        seq_exp[i] = seq_exp[i - 1] - exp[i - 1] + exp[i + k - 1];
        if ans < seq_exp[i] {
            ans = seq_exp[i];
        }
    }
    // debug!(exp);
    // debug!(seq_exp);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 10996
#include <bits/stdc++.h>
#include<iostream>
typedef long long ll;
using namespace std;
int main(){
    ll x,a,b,c,d,e;

    cin>>x;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    cin>>e;
    vector<ll>v{a,b,c,d,e};
    ll min = *min_element(v.begin(),v.end());

    ll ans = 5 + ceil(double(x-min)/double(min));

    cout <<ans;



}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int k,a,b;
  cin >> k >> a >> b;
  if (k == 1) {
  	cout << "OK" << "\n";
    return 0;
  }
  for (int i = a; i <= b; ++i) {
    if(i%k == 0) {
      cout << "OK" << "\n";
      return 0;
    }
  }
  cout << "NG" << "\n";
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <vector>
#include <cassert>
#include <algorithm>

using i32 = int;
using i64 = long long;
constexpr i32 maxn = 100000;

inline i32 in() {
	i32 n;
	scanf("%d", &n);
	return n;
}

std::vector<i32> to[maxn + 1];

inline void lnk(const i32 &u, const i32 &v) {
	to[u].emplace_back(v);
	to[v].emplace_back(u);
}

i32 val[maxn + 1];
bool col[maxn + 1];

bool color(const i32 &u, const i32 &p, const bool &c) {
	if (val[u] != -1 and c != col[u])
		return false;
	for (const i32 &v: to[u])
		if (v != p and color(v, u, not c) == false)
				return false;
	return true;
}

i32 l[maxn + 1],
	r[maxn + 1];

void contract(const i32 &u, const i32 &p) {
	if (val[u] == -1)
		l[u] = -1e9, r[u] = 1e9;
	else l[u] = r[u] = val[u];
	for (const i32 &v: to[u])
		if (v != p)
			contract(v, u),
			l[u] = std::max(l[u], l[v] - 1),
			r[u] = std::min(r[u], r[v] + 1);
}

inline bool vaild(const i32 &u, const i32 &v) {
	return l[u] <= v and v <= r[u];
}

void calc(const i32 &u, const i32 &p) {
	for (const i32 &v: to[u])
		if (v != p) {
			if (vaild(v, val[u] - 1)) 
				val[v] = val[u] - 1;
			else if (vaild(v, val[u] + 1))
				val[v] = val[u] + 1;
			calc(v, u);
		}
}

i32 main() {
	const i32 n = in();
	for (i32 i = 1; i < n; ++i)
		lnk(in(), in());
	std::fill(val + 1, val + n + 1, -1);

	const i32 k = in(); i32 root = 0;
	for (i32 i = 1; i <= k; ++i)	
		root = in(), val[root] = in(), col[root] = (val[root] & 1);

	if (color(root, 0, col[root]) == false)
		return puts("No"), 0;
	contract(root, 0);

	for (i32 u = 1; u <= n; ++u)
		if (l[u] > r[u])
			return puts("No"), 0;
	calc(root, 0);

	puts("Yes");
	for (i32 i = 1; i <= n; ++i)
		printf("%d\n", val[i]);

	return 0;
}

Measured memory_bytes: 16216
//	Ctrl + k → Ctrl + d: コード整形(ファイル全体)
//	Ctrl + k → Ctrl + f: コード整形(選択範囲)
//
//*/
//
////#include <bits/stdc++.h> // Atcoder公式はこう書くが、ローカルでは不効
#include "bits/stdc++.h" // 提出時こちらで問題なし
//#include <iostream>
//#include <string>
//#include <typeinfo>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REP2(i, s, n) for (int i=(int)(s); i<(int)(n); i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
#define SORT(c) sort((c).begin(),(c).end())
#define R_SORT(c) sort((c).begin(),(c).end(),greater<>())
using G = vector<vector<int>>;
using M = map<int, int>;
using P = pair<int, int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
using V = vector<int>;
using ll = long long;
using ull = unsigned long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int gcd(int a, int b) {
	int r;
	r = a % b;
	if (r == 0) return b;
	else return gcd(b, r);
}

int main()
{
	int x; cin >> x;
	double ans = 360 / x; // 回転しなければならない最低回数。

	cout << 360 / gcd(x, 360) << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
EDGE=[tuple(map(int,input().split())) for i in range(M)]

E=[[] for i in range(N+1)]
J=[0]*(N+1)

for x,y in EDGE:
    J[x]+=1
    J[y]+=1

    E[x].append(y)
    E[y].append(x)

from collections import deque
Q=deque()
Q.append(1)

USE=[0]*(N+1)

while Q:
    x=Q.pop()

    for to in E[x]:
        if USE[to]==0:
            Q.append(to)
            USE[to]=1

if min(USE[1:])==0:
    print("No")
    sys.exit()

for i in range(N+1):
    if J[i]%2==1:
        print("No")
        sys.exit()

if max(J)>=6:
    print("Yes")
    sys.exit()

if sum(J)<=2*N+2:
    print("No")
    sys.exit()

if sum(J)>=2*N+6:
    print("Yes")
    sys.exit()

FOUR=[]
for i in range(N+1):
    if J[i]==4:
        FOUR.append(i)

Q=deque()
Q.append(FOUR[0])
USE=[0]*(N+1)

count=0

while Q:
    x=Q.pop()

    for to in E[x]:
        if to==FOUR[1]:
            count+=1
            continue
            
        if USE[to]==0:
            Q.append(to)
            USE[to]=1

if count==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 30916
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" : "<<x<<'\n';
#define int long long
#define PI 3.141592653589793238
#define INF 1000000000

int n,m;

vector<int> parent;
vector<bool> visited;
vector<int> Distance;
vector<vector<int>> adj;

void dijkstra(int root){
	Distance[root]=0;
	priority_queue<pair<int,int>> pq;
	pq.push({0,root});
	while(!pq.empty()){
		int u = pq.top().second;
		pq.pop();
		if(visited[u]) continue;
		visited[u]=true;
		for(int v : adj[u]){
			if(Distance[u]+1 < Distance[v]){
				Distance[v] = Distance[u]+1;
				pq.push({-Distance[v],v});
				parent[v]=u;
			}
		}
	}
}


void solve()
{
	cin>>n>>m;
	adj.resize(n+1); Distance.resize(n+1,INF);
	visited.resize(n+1,false); parent.resize(n+1,-1);
	for(int i=0;i<m;i++){
		int u,v; cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dijkstra(1);

	bool conn = true;
	for(int i=2;i<=n;i++){
		if(parent[i]==-1) conn=false;
	}
	if(conn){
		cout<<"Yes\n";
		for(int i=2;i<=n;i++)
			cout<<parent[i]<<'\n';
	}
	else{
		cout<<"No\n";
	}
}

int32_t main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}

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

#define nl "\n"
#define db(a) cout << (#a) << " = " << (a) << endl
#define ll long long
#define MOD 1000000007

int mod(int a, int b) {return a >= 0 ? a % b : (b + a % b) % b;}
int dceil(int a, int b) {return (a + b - 1) / b;}
/***********************************/

#define N -1

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

Measured memory_bytes: 720
# coding: utf-8
# Here your code !

def main(N,k):
    p = 0
    p2 = 0
    memo = 0
    for i in range(N-1):
        p, p2 = p2, k*(p2+1)//(k-1) - 2
        while p2-1-p2//k != p:
            p2+=1
    return p2

if __name__ == '__main__':
    N,k=input().split()
    print(main(int(N),int(k)))

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

int main()
{
  int num[3];scanf("%d %d %d",&num[0],&num[1],&num[2]);
  sort(num,num+3);
  int ans=num[2]-num[1];
  num[0]=num[0]+num[2]-num[1];
  num[1]=num[2];
  if((num[2]-num[0])%2==0)ans+=((num[2]-num[0])/2);
  else ans+=((num[2]-num[0]+1)/2+1);
  printf("%d",ans);
}

Measured memory_bytes: 3812
#include <stdio.h>

int main (void)
{
    int N;
    long long A[200000];
    int i;
    long long ans = 0;
    

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

    for(i=0;i<N-1;i++){
        if(A[i]>A[i+1]){
            ans = ans + A[i] - A[i+1];
            A[i+1] = A[i];
            //printf("%lld %d \n", A[i],ans);
        }
    }
 
    printf("%lld",ans);
    return 0;
    
}

Measured memory_bytes: 3256
#include<iostream>
using namespace std;
int main(){
    int n,m;
    int A[100][100],B[100],C[100];
    cin >>n >>m;
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>B[i];
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            C[i]+=A[i][j]*B[j];
        }
    }
    for(int i=0;i<n;i++){
        cout<<C[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]]++;
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += b[i] * (b[i] - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        cout << ans - (b[a[i]] - 1) * b[a[i]] / 2 + (b[a[i]] - 2) *(b[a[i]] - 1) / 2 << endl;
    }

}


Measured memory_bytes: 5760
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    n=int(input())
    s=list(map(str,input()))
    a=[]
    for i in range(1000):
        if i<10:
            a.append("00"+str(i))
        elif i>=10 and i<100:
            a.append("0"+str(i))
        else:
            a.append(str(i))
#    print(s)
#    print(a)
    count=0
    for i in range(1000):
        keta1=a[i][0]
        keta2=a[i][1]
        keta3=a[i][2]
   #     print(keta1,keta2,keta3)
        x=my_index(s,keta1,n+1)
        if x>=n-1:
            continue

        y = my_index(s[x+1:], keta2,n+1)
        if y>=len(s[x+1:])-1:
            continue
        z = my_index(s[x+y+2:], keta3,n+1)
        if z>len(s[x+y+2:]):
            continue
        if x!=n+1 and y!=n+1 and z!=n+1:
        #    print(s[x],s[y],s[z],i)
            count+=1
    print(count)

#  print(c)




            #    print(n,kingaku(a,b,x))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3820
using System;
public class A{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int ans = 0;
        bool flag = false;
        string[] s = new string[n];
        int[] t = new int[n];
        for (int i=0;i<n;i++){
            string[] sti = Console.ReadLine().Split(' ');
            s[i]=sti[0];t[i]=int.Parse(sti[1]);
        }
        string x = Console.ReadLine();
        for (int i=0;i<n;i++){
            if (flag){
                ans += t[i];
            }
            if (s[i]==x){
                flag = true;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std; 
int main(){
int n;
cin>>n;
int *a=new int[n];
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);int sum=0,sum2=0;
for(int i=n-1;i>=0;i--){
    if(i%2==0)sum+=a[i];
    else sum2+=a[i];
}
cout<<max(sum2,sum)-min(sum2,sum);

}


Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,heapq
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    q,w,qq,ww = 0,0,0,0
    for i in range(n):
        s = insr()
        if s == "AC":
            q = q + 1
        elif s == "WA":
            w = w + 1
        elif s == "TLE":
            qq = qq + 1
        else:
            ww = ww + 1
    print("AC x",q)
    print("WA x",w)
    print("TLE x",qq)
    print("RE x",ww)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    b = [[0] * len(a) for i in range(len(a))]
    for i in range(len(a)): 
        for j in range(len(a)): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
main()

Measured memory_bytes: 68564
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n, q;
    cin>>n>>q;
    lli i, h[n+1], v[n+1], height = n, width = n, ans = (n - 2) * (n - 2);
    
    for(i=0;i<=n;i++) h[i] = v[i] = n;
    
    while(q--)
    {
        lli type, x;
        cin>>type>>x;
        
        if(type == 1)
        {
            if(x < width)
            {
                for(i=x;i<width;i++) h[i] = height;
                width = x;
            }
            ans -= h[x] - 2;
        }
        else
        {
            if(x < height)
            {
                for(i=x;i<height;i++) v[i] = width;
                height = x;
            }
            ans -= v[x] - 2;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
#define F(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define D(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define LL long long
LL rd() {
	LL f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	LL x = 0; for (; isdigit(c); c = getchar()) x = x*10+c-'0'; return x*f;
}

const int N = 100005;

int n, m;
LL a[N], t[N], b[N];

void p(LL l, LL cnt) {
	if (l <= a[1]) return b[l] += cnt, void();
	int y = lower_bound(a+1, a+m+1, l)-a;
	t[y-1] += cnt * (l / a[y-1]);
	p(l % a[y-1], cnt);
}

int main() {
	a[++m] = n = rd();
	F(i, 1, rd()) {
		LL x = rd();
		while (m > 0 && x <= a[m])
			a[m--] = 0;
		a[++m] = x;
	}
	
	t[m] = 1;
	D(i, m, 1)
		p(a[i], t[i]);
	D(i, n, 1) b[i] += b[i+1];
	F(i, 1, n) printf("%lld\n", b[i]);
	
	return 0;
}

Measured memory_bytes: 4096
function gcd(u, v)
  while v ~= 0 do
    u, v = v, u%v
  end
  return u
end

N, X = io.read("*n", "*n")
io.read()

x = {}

for v in string.gmatch(io.read(), "(%d+)") do
  table.insert(x, tonumber(v))
end

d = math.abs(X - x[1])

for v = 2, N do
  d = gcd(d, math.abs(X - x[v]))
end

print(d)


Measured memory_bytes: 7600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int n, a[100010], b[100010], ans;
map<int, int> mp;
int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++ ) scanf("%d", a+i), b[i] = a[i], mp[a[i]] = i;
    sort(b, b+n);
    for(int i = 0 ; i < n ; i++ ) if( i%2 != mp[b[i]]%2 ) ans++;
    printf("%d", ans/2);
    return 0;
}


Measured memory_bytes: 5760
N=int(input())

for n in range(N):
    gx,gy=map(int,input().split())
    T=[[0 for i in range(gy+1)]for j in range(gx+1)]
    left=[[0 for i in range(gy+1)]for j in range(gx+1)]
    upper=[[0 for i in range(gy+1)]for j in range(gx+1)]
    p=int(input())

    for i in range(p):
        x1,y1,x2,y2=map(int,input().split())
        if x1==x2:
            upper[x1][max(y1,y2)]=1
        if y1==y2:
            left[max(x1,x2)][y1]=1
    
    for i in range(gx+1):
        for j in range(gy+1):
            if i==0 and j==0:
                T[0][0]=1
                continue
            if i==0 and j>=1 and upper[i][j]==0 and left[i][j]==0:
                T[i][j]=T[i][j-1]
                continue
            if i>=1 and j==0 and upper[i][j]==0 and left[i][j]==0:
                T[i][j]=T[i-1][j]
                continue
            if left[i][j]==1 and upper[i][j]==1:
                T[i][j]=0
            elif left[i][j]==0 and upper[i][j]==1:
                T[i][j]=T[i-1][j]
            elif left[i][j]==1 and upper[i][j]==0:
                T[i][j]=T[i][j-1]
            else:
                T[i][j]=T[i-1][j]+T[i][j-1]
    if T[gx][gy]==0:
        print("Miserable Hokusai!")
    else:
        print(T[gx][gy])    


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q;cin >> n >> q;
  string s;cin >> s;
  vector<char> d(q),t(q);
  for(int i=0;i<q;i++){
    cin >> d[i] >> t[i];
  }
  int ll=-1,lr=n;
  while(lr-ll>1){
    int mid=(ll+lr)/2;
    char now=s[mid];
    int num=mid;
    bool f=true;
    for(int i=0;i<q;i++){
      if(d[i]==now){
        if(t[i]=='L'){
          num--;
          if(num==-1){
            f=false;
            break;
          }
          now=s[num];
        }
        else{
          num++;
          if(num==n){
            break;
          }
          now=s[num];
        }
      }
    }
    if(!f){
      ll=mid;
    }
    else{
      lr=mid;
    }
  }
  int rl=-1,rr=n;
  while(rr-rl>1){
    int mid=(rl+rr)/2;
    char now=s[mid];
    int num=mid;
    bool f=true;
    for(int i=0;i<q;i++){
      if(d[i]==now){
        if(t[i]=='L'){
          num--;
          if(num==-1){
            break;
          }
          now=s[num];
        }
        else{
          num++;
          if(num==n){
            f=false;
            break;
          }
          now=s[num];
        }
      }
    }
    if(!f){
      rr=mid;
    }
    else{
      rl=mid;
    }
  }
  cout << max(0,rr-ll-1) << endl;
}

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

int a[500][500];
int v[1000];
int main() {
	int n, k; scanf("%d%d", &n, &k);
	rep(i, k)rep(j, n / 2)scanf("%d", &a[i][j]), a[i][j]--;
	random_device rnd; mt19937 mt(rnd());
	while (1) {
		rep(i, n)v[i] = mt() % 2;
		rep(i, k) {
			int sum = 0;
			rep(j, n / 2) {
				sum += v[a[i][j]];
				if (sum > 3 * n / 8)goto g;
				if (sum + n / 2 - j - 1 < n / 8)goto g;
			}
		}
		rep(i, n)printf("%d", v[i]); puts("");
		return 0;
	g:;
	}
}

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

int count2(long a){
  int count = 0;
  while(a%2==0){
    count++;
    a = a /2;
  }
  return count;
}

int main(){
  int N;
  cin >> N;
  int count = 0;
  for(int i = 0; i< N; i++){
    long tmp;
    cin >> tmp;
    count += count2(tmp);
  }
  
  cout << count << endl;
  
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n));
  LL total=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) cin >> a[i][j];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      total+=a[i][j];
    }
  }
  vector<vector<bool>> ok(n,vector<bool>(n,true));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(a[j][k]>a[j][i]+a[i][k]){
          cout << -1 << endl;
          return 0;
        }else if(ok[j][k]&&i!=j&&i!=k&&a[j][k]==a[j][i]+a[i][k]){
          total-=a[j][k];
          ok[j][k]=false;
        }
      }
    }
  }
  cout << total << endl;
  return 0;
}


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

#define MAXN 200010

string s;
int n;

int main(){
	cin >> s;
	n = sz(s);
	

	int res = 0;
	vi PD(2019, 0);

	for(int i = n-1; i >= 0; i--){
		vi PDnovo(2019);
		for(int r = 0; r < 2019; r++){
			int ans = 0;
			int dig = s[i] - '0';
			int oldr = r;
			int nr = r;
			nr*=10;
			nr%=2019;
			nr+=dig;
			nr%=2019;
			if(nr == 0){
				ans++;
			}
			ans += PD[nr];
			PDnovo[oldr] = ans;
		}
		res += PDnovo[0];
		PD = PDnovo;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1<<20, mod = 1e9 + 7;
string s;
int n, ans = 1<<30;
int p[maxn], sm[maxn], tt[maxn];
void solvep(string s) {//stuff with +
	p[0] = 0;
	int gm = 0;
	//cout << s << '\n';
	for(int i = 1; i <= n; i++) {
		p[i] = p[i-1] + (s[i] == '1' ? -1 : 1);
		gm = min(gm, p[i]);
	//	cout << p[i] << " ";
	}
//	cout << '\n';
	sm[n] = p[n];
	for(int i = n-1; i >= 0;i--) sm[i] = min(p[i], sm[i+1]);
	//for(int i = 0; i <= n; i++) cout << sm[i] << " ";
	
	//for(int i = 0; i <= n; i++) cout << p[i] << ' '; cout << '\n';
	int r = 0;
	for(int i = 0; i <= n; i++) {
		sm[i] += r;
		p[i] += r;
		//cout << i << " " << sm[i] << " " << sm[i]-2 << " " << gm << '\n';
		if(s[i] == '?' && sm[i] - 2 >= gm) {
			r-=2;
			//cout <<"at " << i << '\n';
			sm[i] -= 2;
			p[i] -= 2;
			s[i] = '1';
		}
		tt[i] = r;
		if(s[i] == '?') s[i] = '0';
		//cout << p[i] << "\n";
	}
	//for(int i = 0; i <= n; i++) cout << p[i] << ' '; cout << '\n';
	//cout << s << '\n';
	int x = 0, y = 0; r = 0;
	for(auto i : s) {
		if(i == '1') r--;
		else if(i != '.') r++;
		x = min(x, r);
		y = max(y, r);
	}
	ans = min(ans, y-x);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> s;
	n = s.size();
	s = "." + s;
	for(int i = 0; i < 2; i++) {
	memset(p, 0, sizeof p);
	memset(sm, 0, sizeof sm);
	solvep(s);
	memset(p, 0, sizeof p);
	memset(sm, 0, sizeof sm);
	for(auto &i : s) if(i != '?' && i != '.') i ^='0'^'1';
	solvep(s);
	reverse(s.begin(), s.end());
	s.pop_back();
	s = "." + s;
	}
	cout << ans;
}


Measured memory_bytes: 17408
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
}

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

int main() {
   long long l,r;
   cin >> l >> r ;
   long long d;
   d= r-l;
   long long  m= 5000000;
   long long  a=0;
   
   if(d <2019) {
       for(long long  i=l;i<r;i++){
	       for(long long  j=i+1 ; j< r+1 ;j++){
		        m=min (m, ((i% 2019)*(j%2019))%2019);
		   }
	   }
	   a=m;
   }
   cout << a << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N) { cin >> A[i]; }
    rep(i, M) { cin >> B[i]; }
    vector<ll> Asum(N + 1), Bsum(M + 1);
    rep(i, N) Asum[i + 1] = Asum[i] + A[i];
    rep(i, M) Bsum[i + 1] = Bsum[i] + B[i];

    int bcnt = 0;
    int res = 0;
    for(int i = N; i >= 0; i--) {
        ll s = Asum[i];
        int cnt = i;
        while(bcnt < M && s + Bsum[bcnt + 1] <= K)
            bcnt++;
        if(s + Bsum[bcnt] <= K)
            res = max(bcnt + cnt, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9532
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n;
	int a[111];
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	ll ans=1000000007;
	for(int i=0;i<=100;i++)
	{
		ll res=0;
		for(int j=1;j<=n;j++)
			res+=(a[j]-i)*(a[j]-i);
		//cout<<res<<endl;
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    string a, b;
    cin >> a >> b;
    int sum = stoi(a + b);
    bool ans = false;
    if (fmod(sqrt(sum), 1) == 0)ans = true;
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        String ans = "AGC";
        if(R<1200) ans = "ABC";
        if(1200<=R&&R<2800) ans = "ARC";
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<queue>
#include<stack> 
#include<stdlib.h> 
#include<time.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const double eps=10-8;
const double inf=0x3f3f3f3f;
const ll mod=1000000007; 
const int maxn=1000+15;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
char ch[maxn];
int clo[maxn][maxn];
int pan[maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll a,b,c,i,j,p;
	ll n;
	cin>>n;
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(i%2&&a%2) ans++;
	}
    cout<<ans<<endl;
	 return 0;
}


Measured memory_bytes: 3644