akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector> 
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int b[maxn];//b[0]代表-1的个数 
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<maxn;i++) a[i]=0;
	b[0]=0;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x>=1){
			a[x-1]++;
			a[x]++;
			a[x+1]++;
			ans=max(ans,max(a[x-1],max(a[x],a[x+1])));
		}else{
			b[0]++;
			a[x]++;
			a[x+1]++;
			ans=max(ans,max(b[0],max(a[x],a[x+1])));
		} 
	} 
	printf("%d\n",ans);
	return 0;
}

/*
B
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i+=2){
		printf("%c",s[i]);
	} printf("\n");
	return 0;
}
*/

/*
A
int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	if(t>=n) printf("0\n");
	else printf("%d\n",n-t);
	return 0;
} 
*/


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 998244353;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		long n=sc.nextLong();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long ans=n/(a+b)*a;
		long k=n%(a+b);
		ans+=Math.min(k, a);
		out.print(ans);
		out.flush();
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;
string k;
int d;
const ll mod = 1e9 + 7;
ll dp[10005][2][105];
int main() {
  cin >> k >> d;

  dp[0][1][0] = 1;
  int n = k.size();

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 2; j++) {
      int x =  j ? (k[i] - '0') : 9;
      for(int m = 0; m <= x; m++) {
	for(int l = 0; l < d; l++) {
	  (dp[i+1][(j && (m == x))][((l + m) % d)] += dp[i][j][l]) %= mod;
	}
      }
    }
  }
  /* for(int i = 0; i <= n; i++) {
    for(int j = 0; j < 2; j++) {
      for(int m = 0; m < d; m++) {
	cout <<"dp["<<i<<"]["<<j<<"]["<<m<<"] = "<< dp[i][j][m] << endl;
      }
    }
    }*/
  

  cout << (dp[n][0][0] + dp[n][1][0] + mod- 1) % mod;
}

  


Measured memory_bytes: 16768
"use strict";

const func = (input) => {
    const a = input.split('\n');
    const [N, K] = a[0].split(" ").map(e => parseInt(e));
    let array = a[1].split(" ").map(e => parseInt(e));

    array.sort(function (x, y) {
        return x - y;
    });

    let ans = 0;
    for (let i = 0; i < K; i++) {
        ans += array[i];
    }
    console.log(ans);
}

func(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    for(auto c : s) cout << 'x';
    cout << endl;
}

Measured memory_bytes: 256
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes";
	else cout << "No";
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

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

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N;
	cin >> N;
	vector<string> ss(N);
	REP(i, N)cin >> ss[i];

	int cnt = 0;
	int a = 0, b = 0, ba = 0;
	for (auto s : ss) {
		REP(i, (int)s.size() - 1) {
			if (s[i] == 'A'&&s[i + 1] == 'B')cnt++;
		}
		if (s.back() == 'A' && s.front() == 'B') {
			ba++;
			continue;
		}
		if (s.front() == 'B')b++;
		if (s.back() == 'A')a++;
	}

	if (ba > 0) {
		cnt += ba - 1;
		if (a > 0) {
			a--;
			cnt++;
		}
		if (b > 0) {
			b--;
			cnt++;
		}
	}
	cnt += min(a, b);
	cout << cnt << endl;

	return 0;
}


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


int s,n,ok,i;
int len[N];
int main(){
    scanf("%d",&s);
    len[0]=s;
    i=1;
    while(ok==0){
        if(s%2==0){
            s=s/2;
        }else{
            s=s*3+1;
        }
        len[i]=s;
        for(int j=0;j<i;j++){
            if(len[j]==s)ok=1;
        }
        i++;
    }
    printf("%d",i);
}

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

int main() {
    int A[3][3];
    int N;
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> A[i][j]; 
        }
    }
    cin >> N;
    int b[N];
    for(int i = 0; i < N; i++) {
        cin >> b[i];
    }
    int ans[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            ans[i][j] = 0; 
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(b[i] == A[j][k]) {
                    ans[j][k] = 1;
                }
            }
        }
    }
    int count = 0;
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
             if(ans[i][j] == 1) {
                 count++;
             }
             if(count == 3) {
                 cout << "Yes" << endl;
                 return 0;
             }
        }
        count = 0;
    }
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
             if(ans[j][i] == 1) {
                 count++;
             }
             if(count == 3) {
                 cout << "Yes" << endl;
                 return 0;
             }
        }
        count = 0;
    }
    for(int i = 0; i < 3; i++) {
        if(ans[i][i] != 1) {
            break;
        } 
        if(i == 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for(int i = 0; i < 3; i++) {
        if(ans[i][2-i] != 1) {
            break;
        } 
        if(i == 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int x;
  cin >> x;
  if (x == 1)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n,k,q;
    cin >>n >> k >> q;
    vector<int> vec(n);
    for(int i=0;i<q;i++){
        int x;
        cin >> x;
        x--;
        vec[x]++;
    }
    for(int i=0;i<n;i++){
        if(k-(q-vec[i])>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
const double PI = acos(-1);
void no(){
  cout << "No" << endl;
  exit(0);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(sz(s)%2) no();
  FOR(i, 0, sz(s)){
    if(i%2==0 && s[i]!='h' || i%2 && s[i]!='i') no();
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3636
while True:
    m, t, f = map( int, raw_input().split())
    if m == -1 and t == -1 and f == -1:
        break
    if m == -1 or t == -1:
        r = "F"
    elif (m + t) >= 80:
        r = "A"
    elif (m + t) >= 65:
        r = "B"
    elif (m + t) >= 50:
        r = "C"
    elif (m + t) >= 30:
        if f >= 50:
            r = "C"
        else:
            r = "D"
    else:
        r = "F"

    print r

Measured memory_bytes: 4224
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)
#define VEC2(type,name,w,h) vector<vector<type>>name(h,vector<type>(w))

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    int n,m,k;
    cin>>n>>m;
    vector<int> l(m,0);
    rep(i,n){
        cin>>k;
        rep(j,k){
            int a;
            cin>>a;
            l[a-1]++;
        }
    }
    int ans=0;
    rep(i,m){
        if(l[i]==n){
            ++ans;
        }
    }
    cout<<ans;
}
/*
*/

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

lli bitCount(lli num){
    lli rtn = 0;
    while(num>0){
        rtn += (num%2);
        num /= 2;
    }

    return rtn;
}

map<lli,lli> bitC;
vector<pair<lli,lli>> G[60];
lli iii;

void dfs(lli from,lli now,lli nowBit,lli target){
    LOG4(from,now,nowBit,target);
    if(now == target){
        bitC[iii] = nowBit;
        return;
    }

    for(auto e:G[now]){
        if(e.first == from)continue;
        dfs(now,e.first,nowBit|(1LL<<e.second),target);
    }
}

lli ppow(lli num,lli cnt){
    if(cnt<0)return 0;

    lli rtn = 1;
    while(cnt--){
        rtn*=num;
    }
    return rtn;
}

void func(long long N, std::vector<long long> a, std::vector<long long> b, long long M, std::vector<long long> u, std::vector<long long> v){


    REP(i,0,N-1){
        G[a[i]].push_back({b[i],(lli)i});
        G[b[i]].push_back({a[i],(lli)i});
    }

    for(iii = 0 ; iii < M ;iii++){
        dfs(-1,u[iii],0,v[iii]);
    }

    lli ans = 0;
    REP(i,0,(1LL<<(M))){
        lli bCnt = bitCount(i);

        lli bit = 0;
        REP(j,0,M){
            if(!(i&(1LL<<j)))continue;
            bit |= bitC[j];
        }
        lli invalidBit = bitCount(bit);

        LOG(invalidBit);
        lli num = ppow(2,N-1-invalidBit);

        LOG3(ans,i,num);
        if(bCnt%2==0)ans += num;
        else ans -= num;
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        a[i]--,b[i]--;
    }
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
        u[i]--,v[i]--;
    }
    func(N, std::move(a), std::move(b), M, std::move(u), std::move(v));
    return 0;
}


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

int main(){
  char b;
  cin >> b;
  if(b=='A')  
    cout << "T";
  if(b=='T')
    cout << "A";
  if(b=='C')
    cout << "G";
  if(b=='G')
    cout << "C";
}

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

using namespace std;
int dp[15][1130];
bool isPrime[1130];
vector<int> prime;

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 1130; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < 1130; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	dp[0][0] = 1;
	for(int i = 0; i < prime.size(); ++i)
	{
		for(int j = 14; j > 0; --j)
		{
			for(int k = prime[i]; k <=1120; ++k)
			{
				dp[j][k] += dp[j - 1][k - prime[i]];
			}
		}
	}
	int n, k;
	while(cin >> n >> k, n || k)
	{
		cout << dp[k][n] << endl;
	}
}

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

Measured memory_bytes: 1280
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=dp[i-w]+v
            if tmp>dp[i]:
                dp[i]=tmp
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)


Measured memory_bytes: 14408
#include<iostream>
#include<iomanip>

int main()
{
	int n;
	while( std::cin >> n )
		std::cout << "3C" << std::setw( 2 ) << std::setfill( '0' ) << ( n % 39 ? n % 39 : 39 ) << std::endl;

	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < M; i++) cin >> c[i] >> d[i];

    for(int i = 0; i < N; i++){
        int dist = inf, index = -1;
        for(int j = 0; j < M; j++){
            if(dist > abs(a[i] - c[j]) + abs(b[i] - d[j])){
                dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                index = j + 1;
            }
        }
        cout << index << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
  Contest 105
  B - Cakes and Donuts
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    std::string r = "No";
    int cakes = 0;
    while (1) {
        const int cakes_cost = cakes * 4;
        const int donuts_cost = n - (cakes_cost);
        if (donuts_cost < 0)
            break;
        if (donuts_cost % 7 == 0) {
            r = "Yes";
            break;
        }
        ++cakes;
    }
    std::cout << r << std::endl;

    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i=0; i<N; i++){
        cin >> h.at(i);
    }
    bool flag = false;
    int ans = 0;
    bool end;
    while(true){
        flag = false;
        end = true;
        for(int i=0; i<N; i++){
            if(h.at(i)!=0){
                flag = true;
                end = false;
                h.at(i) -= 1;
            }
            else if(flag){
                break;
            }
        }
        if(end){
            break;
        }
        ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

ll count_one(ll n) {
	ll count = 0;
	while(n > 0) {
		if ((n & 1) == 1) count++;
		n = n / 2;
	}
	return count;
}

ll solve(ll n) {
	ll d = count_one(n);

	if (d == 0) return 0;

	if (n % d == 0) {
		return 1;
	}
	n = n % d;

	return solve(n) + 1;


}


int main() {
	int n;
	cin >> n;
	string xs;
	cin >> xs;

	ll p_cnt = 0;
	for (char x : xs) {
		if (x == '1') p_cnt ++;
	}
		
	vector<ll> a_p(n + 1, 0);
	vector<ll> a_m(n + 1, 0);
	
	ll cnt_plus = p_cnt + 1;
	ll cnt_minus = p_cnt - 1;



	ll cur = 1;
	ll plus_ans = 0;
	for (int i = 0; i < n; i++) {
		if (cnt_plus == 0) {
			break;
		}
		ll pos = n - i - 1;
		a_p[pos] = cur; 
		if (xs[pos] == '1') {
			plus_ans += cur;
			plus_ans %= cnt_plus;

		}
		cur = cur * 2;
		cur %= cnt_plus;
	}

	cur = 1;
	ll minus_ans = 0;
	for (int i = 0; i < n; i++) {
		if (cnt_minus == 0) {
			break;
		}
		int pos = n - i - 1;
		a_m[pos] = cur; 
		if (xs[pos] == '1') {
			minus_ans += cur;
			minus_ans %= cnt_minus;

		}
		cur = cur * 2;
		cur %= cnt_minus;
	}

	//cout << "middle:" << endl;



	rep(i, n) {
		ll cur_n = 0;
		//cout << "i:" << i  << endl;
		//cout << " xs[i]:" << xs[i] << endl;

		if (xs[i] == '1') {
			//cout << "minus_ans:" << minus_ans << endl;
			ll ans = minus_ans - a_m[i] ;
			
			//cout << "cnt_minus:" << cnt_minus << endl;

			if (cnt_minus > 0) {
				//cout << "a:" <<  endl;
				cur_n = (ans + cnt_minus) % cnt_minus;
			} else {
				cout << "0" <<  endl;
				continue;
			}
			
		} else {
			//cout << "plus_ans:" << plus_ans << endl;

			ll ans = plus_ans + a_p[i] ;
			cur_n = (ans + cnt_plus) % cnt_plus;
		} 
		//cout << "cur_n:" << cur_n << endl;

		if (cur_n == 0) {
			cout << 1 << endl;
		} else {
			cout << solve(cur_n) + 1 << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 6160
#include<bits/stdc++.h>
#define int long long
using namespace std;
 

int pp[100005];
const int mod=1e9+7;
int mm[3];

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    pp[0]=1;
    for(int i=1;i<=100000;i++)
        pp[i]=pp[i-1]*3%mod;
    string a;
    cin>>a;
    int x=0,y=0,z=0;
    int tot=0;
    int n=a.length();
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='A')
            mm[0]++;
        else if(a[i]=='B')
            mm[1]++;
        else if(a[i]=='C')
            mm[2]++;
        else
            tot++;
    }

    for(int i=0;i<n;i++)
    {
        if(a[i]=='A')
            x++;
        else if(a[i]=='C')
            y++;
        else if(a[i]=='?')
        {
            int tt1=(x*pp[z])%mod;
            if(z)
                tt1+=pp[z-1]*(z);
            tt1%=mod;
            int tt2=((mm[2]-y)*pp[tot-z-1])%mod;
            if(tot-z-2>=0)
                tt2+=pp[tot-z-2]*(tot-z-1)%mod;
            tt2%=mod;
            ans+=(tt1*tt2)%mod;
            ans%=mod;
            z++;
        }
        else
        {
            int tt1=(x*pp[z])%mod;
            if(z)
                tt1+=pp[z-1]*(z);
            tt1%=mod;
            int tt2=((mm[2]-y)*pp[tot-z])%mod;
            if(tot-z)
                tt2+=pp[tot-z-1]*(tot-z)%mod;
            tt2%=mod;
            ans+=(tt1*tt2)%mod;
            ans%=mod;
        }
    }
    
    cout<<ans;
}

Measured memory_bytes: 4552
#include<bits/stdc++.h>
using namespace std;
string LCS_Length(string X, string Y)
{
	int n = X.size();
	int m = Y.size();
	vector<vector<pair<int, char>>>dp(n + 1, vector<pair<int, char>>(m + 1));
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			if (i == 0 || j == 0)
			{
				dp[i][j] = {0, 'i'};
			}
		}
	}
	//d=diagonal , l=left , u=up
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (X[i - 1] == Y[j - 1])
			{
				dp[i][j].first = dp[i - 1][j - 1].first + 1;
				dp[i][j].second = 'd';
			}
			else
			{
				int op1 = dp[i - 1][j].first;
				int op2 = dp[i][j - 1].first;
				if (op1 > op2)
				{
					dp[i][j].first = op1;
					dp[i][j].second = 'u';
				}
				else
				{
					dp[i][j].first = op2;
					dp[i][j].second = 'l';
				}
			}
		}
	}
	// for (int i = 0; i <= n; i++)
	// {
	// 	for (int j = 0; j <= m; j++)
	// 	{
	// 		cout << dp[i][j].first << "," << dp[i][j].second << "   ";
	// 	}
	// 	cout << endl;
	// }
	string ans = "";
	int i = n, j = m;
	while (i > 0 and j > 0)
	{
		if (dp[i][j].second == 'd')
		{
			ans = X[i - 1] + ans;
			i--;
			j--;
		}
		else if (dp[i][j].second == 'l')
		{
			j--;
		}
		else if (dp[i][j].second == 'u')
		{
			i--;
		}
	}
	return ans;

}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string X, Y;
	cin >> X >> Y;
	cout << LCS_Length(X, Y) << endl;
	return 0;
}


Measured memory_bytes: 74112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    int a;
    vector<int> A(N, 0);
    for (int i = 0; i < N-1; i++) {
        cin >> a;
        a--;
        A[a]++;
    }
    for (int i = 0; i < N; i++) {
        printf("%d\n", A[i]);
    }
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
inline int read()
{
  int p=0; int f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}

struct node{int x,y,next;}edge[N]; int len,first[N];
void ins(int x,int y)
{
  len++; edge[len].x=x; edge[len].y=y; edge[len].next=first[x]; first[x]=len;
  len++; edge[len].x=y; edge[len].y=x; edge[len].next=first[y]; first[y]=len;
}

int n,cnta[N],cntb[N]; int ans[N];

int s[N],top; bool vis[N];

void dfs(int x)
{
  while(1)
  {
    int k = first[x]; if(k==-1) break; first[x] = edge[k].next;
    int y = edge[k].y;
    if(!vis[k>>1])
    {
      vis[k>>1] = 1;
      dfs(y); s[++top] = k;
    }
  }
}

int main()
{

  len=1; memset(first,-1,sizeof(first)); n=read();
  for(int i=1;i<=n;i++){int x=read(); if(x==-1) x=0,ins(x,i); else{ins(x,i); cnta[x]++;}}
  for(int i=1;i<=n;i++){int x=read(); if(x==-1) x=0,ins(x,i+n); else{ins(x+n,i+n); cntb[x]++;}}
  for(int i=1;i<=n;i++)
  {
    ans[i] = -1; if((cnta[i]&1) != (cntb[i]&1)){printf("IMPOSSIBLE\n"); return 0;}
    if((cnta[i]&1) == 1 && (cntb[i]&1) == 1) ans[i] = 0;
    else ins(i,i+n);
  }

  printf("POSSIBLE\n");
  top=0; dfs(1);

  for(int i=top;i>=1;i--)
  {
    int k = s[i];
    if(edge[k].x >= 1 && edge[k].x <= n && edge[k].y <=2*n && edge[k].y >= n+1) ans[edge[k].x] = 1;
  }

  for(int i=1;i<=n;i++) printf("%d%c",ans[i]," \n"[i==n]);

  return 0;
}

Measured memory_bytes: 31744
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int N, K;
int A[505], pl[505], mi[505];

//int dp[2][1000010];
bool solve(int x) {
	vector<P>v;
	REP(i, N) {
		int a = A[i]%x;
		int b = (x - a);
		v.push_back({ a,b });
	}
	VSORT(v);
	vector<int>cum1(N + 1), cum2(N + 1);
	cum1[0] = 0, cum2[0] = 0;
	REP(i, N) {
		cum1[i + 1] = cum1[i] + v[i].first;
		cum2[i + 1] = cum2[i] + v[i].second;
	}
	REP(i, N+1) {
		if (cum1[i] > K)return false;
		int a = cum1[i];
		int b = cum2[N] - cum2[i];
		if ((a%x == b % x) && max(a, b) <= K)return true;
	}
	return false;
}

bool muri[1000010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	int sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	int ans = 1;
	for (int x = 1; x*x <= sum; x++) {
		if (sum%x == 0) {
			if (solve(x))ans = max(ans,x);
			if (solve(sum / x))ans = max(ans, sum / x);
		}
	}
	print(ans);
}



Measured memory_bytes: 256
from sys import stdin

def main():
    N = int(input())
    B = list(map(int, input().split()))

    maxb = max(B)
    ans = [maxb] * N
    for i, b in enumerate(B):
        ans[i] = min(ans[i], b)
        ans[i+1] = min(ans[i+1], b)
    print(sum(ans))

input = lambda: stdin.readline()[:-1]
main()


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

int main()
{
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> divs(10000010);

  for (int i = 1; i <= n; i++){
    for (int j = i; j <= n; j+=i)
    {
      divs[j]++;
    }
  }

  long long ans = 0;
  for (long long i = 1; i <= n; i++)
  {
    ans += i*divs[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 81324
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int dp[110000];
Int n, h[110000];

int main(){
    cin >> n;
    for(int i = 0;i < n;i++)cin >> h[i];

    dp[0] = 0;
    for(int i = 1;i < n;i++){
        if(i == 1){
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        }
        else{
            dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                        dp[i-2] + abs(h[i] - h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

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

int main(void){
  int n,ans;
  
  cin >> n;
  ans=0;
  for (int i=1; i<=n; i++){
    int t=10,dig=1;
    while (t<=i){
      t*=10; dig++;
    }
    if (dig%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    int n; cin >> n;
    int arr[n];
    forn(i,0,n)cin >> arr[i];

    // int l , r , d;
    // cin >> l >> r >> d;

    // int ans = 0;

    // forn(i,l,r+1){
    //     if(i % d == 0)ans++;
    // }


    // cout << ans << "\n";

    int ans = 0;

    forn(i,0,n){
        if(i%2 == 0 && arr[i] % 2 == 1){
            ans++;

        }
    }
    

    
    cout << ans << "\n";
        


}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

    while(t--){
        solve();
    }




    return 0;
}
      
       


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int n;
void dfs(string s,char mx){
    if(s.size()==n){
        cout << s << endl;
        return;
    }
    for (char c='a';c<=mx+1;c++){
        string t=s;
        t+=c;
        dfs(t,max(c,mx));
    }
}

int main(){
    cin >> n;
    dfs("",'a'-1);
    return 0;
}

Measured memory_bytes: 1536
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(r.readLine());
		for(int i = 0; i < n; i++) {
			String s = r.readLine();
			int a = s.indexOf(" ");
			int z = s.lastIndexOf(" ");
			int[] arr = new int[3];
			arr[0] = Integer.valueOf(s.substring(0, a));
			arr[1] = Integer.valueOf(s.substring(a+1, z));
			arr[2] = Integer.valueOf(s.substring(z+1));
			Arrays.sort(arr);
			if((arr[2] * arr[2]) == arr[0] * arr[0] + arr[1] * arr[1]) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 9916
#include <bits/stdc++.h>
using namespace std;
int main() {
// m Restaurant
int N,x=0,z=0;
cin>>N;
if(1<=N&&N<=100){
x=N*800;
z=N/15;
x-=(z*200);
}
    printf("%d",x);
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter

N = int(input().strip())
a_list = list(map(int, input().rstrip().split()))
#-----

cnt_dic = Counter(a_list)

cnt=0
for i,value in cnt_dic.items():
    if i == value:
        continue
    elif i > value:
        cnt += value
    elif i < value:
        cnt += (value - i)

print(cnt)


Measured memory_bytes: 18668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K, S;
    cin >> N >> K >> S;
    vl A(N, 0);
    rep(i, K) A[i] = S;
    if (S != 1e9)
        repe(i, K, N) A[i] = 1e9;
    else
        repe(i, K, N) A[i] = 1;

    rep(i, N) cout << A[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int result = 2018;
        loop: for (long i = l; i < r; i++) {
            for (long j = i + 1; j <= r; j++) {
                result = Math.min(result, (int)((i * j) % 2019));
                if ((i * j) % 2019 == 0) {
                    break loop;
                }
            }
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22100
A,B,C=map(int,input().split())
K=int(input())
D=[]
for i in range(K):
    for j in range(K-i):
        if A*(2**i)<B*(2**j) and B*(2**j)<C*(2**(K-i-j)):
            D.append('Yes')
        else:
            D.append('No')
if ('Yes' in D)==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll q;
  cin >> q;
  while(q--) {
    ll a,b;
    cin >> a >> b;
    if(a>b) {
      ll tmp=a;
      a=b;
      b=tmp;
    }
    ll c=sqrtl(a*b-1);
    ll ans=2*c;
    if(a<=c) ans--;
    if(c*(c+1)>=a*b) ans--;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;
typedef pair<ll, ll> LP;
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1);
}
 
int main()
{
  int h,w,k;
  char a[200][200];
  k=0;
  cin >> h >> w;
  rep(i,h){
    rep(j,w){cin >> a[i][j];
            }
  }
  rep(i,h){
    rep(j,w){if(a[i][j]=='#'){a[i][w]='#';
                              a[h][j]='#';
                             }
            }
  }
  rep(i,h){
    rep(j,w){if(a[i][w]=='#'&&a[h][j]=='#'){if(k==0)printf("\n");
                                            printf("%c",a[i][j]);
                                            k=5;
                                           }
            }k=0;
  }
}

Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll digit[N], n;

ll DIG(ll x){
	ll sum = 0;
	while (x){
		sum += x % 10;
		x /= 10;
	}
	return sum;
}

int main(){
	IOS;
	cin >> n;
	ll ans = INF;
	for (int i = 1; i < N; i++){
		digit[i] = DIG(i);
	}
	for (int i = 1; i < n; i++){
		ans = min(ans, digit[i] + digit[n - i]);
	}
	cout << ans;
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 1792
#include <iostream>


using namespace std;
#define BLACKJACK (21)

int main()
{
    int A1 = 0, A2 = 0, A3 = 0;
    int sum = 0;
    cin >> A1 >> A2 >> A3;

    sum = A1 + A2 + A3;
   // cout << sum << A1 << A2 << A3 << endl;

    if (sum > BLACKJACK) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }

        


   // cout << "A1 , A2"<< endl; 

 //   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	map<string, int>m;
	rep(i, N) {
		string S;
		cin >> S;
		m[S]++;
	}
	int mx = -INF;
	for (auto i : m) {
		mx = max(mx, i.second);
	}
	vector<string>ans;
	for (auto i : m) {
		if (i.second == mx)ans.push_back(i.first);
	}
	sort(ans.begin(), ans.end());
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 27420
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    D, X = map(int, input().split())
    A = []
    for _ in range(N):
        A.append(int(input()))

    ans = 0
    for i in range(N):
        a = A[i]
        for j in range(1000):
            if j * a + 1 <= D:
                ans += 1
    print(ans + X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N,R;
    cin >> N >>R;
    if(N < 10){
        cout << R + (10 - N) * 100 << endl;
    }else{
        cout << R << endl;
    }

}


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

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

	for(int i=X-K+1; i <= X+K-1; ++i){
		if(i != X+K-1){
			cout << i << " ";
		}
		else{
			cout << i << endl;
		}
	}
}


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

flag = False
for i in range(N+1):
	for j in range(N+1-i):
		k = (Y - (10000*i+5000*j))//1000
		if(i + j + k == N):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#define maxn 1024
using namespace std;
int main ()
{
	bool flag,ok;
	flag=ok=false;
	char ch[maxn];
	cin>>ch;
	for (int i=0;i<strlen(ch);i++)
		if (ch[i]=='C')flag=true;
		else if (ch[i]=='F'&&flag){ok=true;break;}
	if (ok)cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    for(int i = 0; i < 19; i++){
        char c;
        scanf("%c", &c);
        if(c == ','){
            printf(" ");
        }else{
            printf("%c", c);
        }
    }
    printf("\n");
    return 0;
}

        


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> k(m);
    int s[11][11];
    vector<int> p(m);
    //入力
    for (int i=0;i<m;i++){
        cin >> k.at(i);
        // cout << k.at(i)<< " " << endl;
        for (int j=0;j<k.at(i);j++){
            int tmp;
            cin >> tmp ;
            tmp--;
            s[i][j] =tmp;
            // cout << s[i][j] << " " << endl;
        }
    }    
    for (int i=0;i<m;i++){
        cin >> p.at(i);
        // cout << p.at(i) << endl;
    }
    int ans_cnt=0;
    //スイッチの状態を全列挙
    for (int bit=0;bit<(1<<n);bit++){
        int cnt=0;
        vector<bool> sw(n);
        //スイッチの状態(onかoffか)
        for (int i=0;i<n;++i){
            if(bit & (1<<i)){
                sw.at(i) = true;
                // cout << i << endl;
            }
        }
        //電球jについて
        for (int j=0;j<m;j++){
            int s_cnt=0;
            //電球とつながってるスイッチを確認
            for(int l=0;l<k.at(j);l++){
                if(sw[s[j][l]]) s_cnt++;
                // cout << s_cnt << endl;
            }
            if((s_cnt % 2) == p.at(j)) {
                cnt++;
                continue;
            }
            else break;
            
        }
        if(cnt ==m )
            ans_cnt++;
    }
    cout << ans_cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ab = sc.nextInt() + sc.nextInt();
    int cd = sc.nextInt() + sc.nextInt();
    sc.close();

    if (ab == cd) {
      System.out.println("Balanced");
    } else if (ab > cd) {
      System.out.println("Left");
    } else {
      System.out.println("Right");
    }

  }
}

Measured memory_bytes: 21588
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static int N;
    static string S;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        S = cin.next();
    }
    static void solve()
    {
        input();
        int[] countW = new int[N];
        int[] countE = new int[N];
        if (S[0] == 'E')
            countE[0] = 1;
        else
            countW[0] = 1;
        for(int i = 1; i < N; i++)
        {
            countE[i] = countE[i - 1];
            countW[i] = countW[i - 1];
            if (S[i] == 'E')
                countE[i]++;
            else
                countW[i]++;
        }
        int ans = countE[N - 1] - countE[0];
        for(int i = 1; i < N; i++)
        {
            int value = countW[i - 1] + countE[N - 1] - countE[i];
            if(value < ans)
                ans = value;
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 14432