akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


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




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool check(const vector<int>& v, const vector<int>& w){
  rep(i,v.size()){
    if(v[i] != w[i]) return false;
  }
  return true;
}


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

  vector<int> p, q;
  rep(i,N){
    int a;
    cin >> a;
    p.push_back(a);
  }
  rep(i,N){
    int a;
    cin >> a;
    q.push_back(a);
  }
  
  vector<int> v;
  rep(i,N){
    v.push_back(i+1);
  }

  int retP = -1, retQ = -1;
  int cnt = 1;
  do {
    if(check(v,p)) retP = cnt;
    if(check(v,q)) retQ = cnt;
    cnt++;
  }while(next_permutation(ALLOF(v)));

  cout << abs(retP - retQ) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0)
#define fori(x,a,b) for (int x=a;x<=b;++x)
#define ford(x,a,b) for (int x=a;x>=b;x--)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define mp make_pair
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define getbit(x,i) ((x>>(i-1))&1)
#define batbit(x,i) (x|(1ll<<(i-1)))
#define tatbit(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
const int maxn = 2e5 + 10;
int x[maxn];
int n;
map<ii,int> cnt;
main()
{
    cin>>n;
    double c;
    fori(i,1,n)
    {
        cin>>c;
        x[i] = round(1ll*c*1e9);
    }
    int dem1 = 0,dem2 = 0;
    fori(i,1,n)
    {
        int z = x[i];
        dem1 = 0,dem2 = 0;
        while(z%2==0) dem1++,z/=2;
        while(z%5==0) dem2++,z/=5;
        cnt[{dem1,dem2}]++;
    }


    int kq = 0;
    forv(u,cnt)
    {
        forv(v,cnt)
        {
           if (u.fi.fi + v.fi.fi >=18 && u.fi.se + v.fi.se >=18)
           {
               if (u < v) kq+=1ll*u.se*v.se;
               else if (u==v) kq+=1ll*u.se*(v.se-1)/2;
           }
        }
    }
    cout<<kq;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;

#define all(x) (x).begin(), (x).end()
#define size(x) (ll)x.size()
#define x first
#define y second
#define chkmax(x, y) x = max(x, y)
#define chkmin(x, y) x = min(x, y)
#define pb emplace_back
mt19937_64 gen;

vector<ll> fact(ll x) {
	vector<ll> res;
	for(ll i = 2; i * i <= x; i++) {
		while (x % i == 0) {
			res.push_back(i);
			x /= i;
		}
	}
	if (x > 1) res.push_back(x);
	sort(all(res));
	res.resize(unique(all(res)) - res.begin());
	return res;
}

void run() {
	ll r1, r2;
	cin >> r1 >> r2;
	vector<ll> a = fact(r1);
	vector<ll> b = fact(r2);
	vector<ll> c;
	int res = 1;
	for(ll x : a) {
		for(ll y : b) {
			if (x == y) {
				res++;
			}
		}
	}
	cout << res;

} 
 
signed main() {
#ifdef kek
  gen(12 * 21);
#else
  gen.seed(time(0));
#endif // kek
  ios::sync_with_stdio(0);
  cin.tie(0);
  run();
}

Measured memory_bytes: 256
from collections import deque

H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))


def cut(bit):

    """
    横の切れ目の場所をビットで管理する。
    "00...0" <= bit <= "11...1"(H - 1桁)の時に、縦に入れる切れ目の最小回数を返す。
    """

    end = [] # 板チョコを横区切りにした結果、上から何段目で各板チョコのピースが終わるか
    for i in range(H - 1):
        if bit[i] == '1':
            end.append(i)
    end.append(H - 1)
    chocolates = [0] * (len(end))
    #print("end={}".format(end))

    """
    ここまでで板チョコを横に切ったわけだが、こうして分割した横長の部分板チョコを
    上からsection = 0, 1, 2,..., len(end)-1と呼び分けることにする。
    """

    cut = 0
    whites_sum = [0] * len(end) # w列目までの白チョコの累積数をsectionごとに管理。cutが入れば初期化。
    for w in range(W):
        whites = [0] * len(end) # whites[section] = (w列目にある白チョコをsectionごとに保存)
        section = 0 # 現在のsection
        coarse = False # 横切りが荒過ぎて１列に白チョコがK個より多く並んだ場合に探索を打ち切るフラグ

        for h in range(H + 1):
            # sectionを跨いだ場合の処理
            if h > end[section]:
                if whites[section] > K:
                    coarse = True
                    break
                elif whites_sum[section] + whites[section] > K:
                    cut += 1
                    whites_sum = whites
                    whites = [0] * len(end)
                    section += 1
                else:
                    whites_sum[section] += whites[section]
                    section += 1

            # 白チョコカウント
            if h < H and S[h][w] == '1':
                whites[section] += 1

        # coarseフラグが立っていたら-1を返す。
        if coarse:
            return -1
    return cut


ans = 10 ** 10
for h in range(2 ** (H - 1)):
    bit = bin(h)[2:] # "0b..."を除くため
    l = len(bit)
    bit = '0' * (H - 1 - l) + bit # bitの桁数をH - 1にする。
    #print("bit={}".format(bit))

    vertical_cuts = cut(bit)
    if vertical_cuts != -1:
        preans = vertical_cuts + bit.count('1')
        ans = min(ans, preans)
        #print("vertical_cut={}, cut={} -> ans={}".format(vertical_cuts, preans, ans))


print(ans)


Measured memory_bytes: 48476
S=input()

emp=1
A=0
AB=0
ABC=0

big = 10**9+7



for a in S:
    if a == 'A':
        (emp,A,AB,ABC)=(emp,emp+A,AB,ABC)
    if a == 'B':
        (emp,A,AB,ABC)=(emp,A,A+AB,ABC)
    if a == 'C':
        (emp,A,AB,ABC)=(emp,A,AB,AB + ABC)
    if a == '?':
        (emp,A,AB,ABC)=(3*emp%big, (emp+ 3*A) %big, (A+ 3*AB)%big,(AB + 3*ABC)%big)

print(ABC%big)


Measured memory_bytes: 3188
//
// Educational DP B.Frog2
//  implementation-1: 配るDP
//
//

#include <iostream>
using namespace std;

const long long INF = 1LL << 60;
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; }


int main() {
	int N,K;
	cin >> N >> K;
	
	long long h[100010];			// 階段の高さ
	long long dp[100100];  		// コスト
	for(int i=0; i<N; i++) cin >> h[i];
	for(int i=0; i<100100; i++) dp[i] = INF;
	dp[0] = 0;
	
	// Dymanic Programming
	for(int i=0; i<N; i++) {
		for(int j=1; j<=K; j++) {
			chmin(dp[i+j], dp[i] + abs(h[i+j]-h[i]) );
		}	
	}
	
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    ll x, y;
    cin >> x >> y;
    ll cnt = 0;
    while(y >= x){
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
from math import factorial as fac
x,y=map(int,input().split())
a=2*y-x
b=2*x-y
mod=10**9+7
if a>=0 and b>=0 and a%3==0 and b%3==0:
  a=a//3
  b=b//3
  a1=1
  a2=1  
  n3=10**9+7
  for i in range(a):
    a1*=a+b-i
    a2*=i+1
    a1%=n3
    a2%=n3
  a2=pow(a2,n3-2,n3)
  print((a1*a2)%n3)
else:
  print(0)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vi v;
    v.pb(-1);
    int mi=1000001,ma=-1000001;
    int mat,mit;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        v.pb(k);
        if(k<mi){
            mi=k;
            mit=i;
        }
        if(k>ma){
            ma=k;
            mat=i;
        }
    }
    cout<<2*n-1<<endl;
    if(abs(ma)>=abs(mi)){
        for(int i=1;i<=n;i++){
            v[i]+=ma;
            cout<<mat<<' '<<i<<endl;
        }
        for(int i=1;i<=n-1;i++){
            cout<<i<<' '<<i+1<<endl;
        }
    }
    else{
        for(int i=1;i<=n;i++){
            v[i]+=mi;
            cout<<mit<<' '<<i<<endl;
        }
        for(int i=n-1;i>=1;i--){
            cout<<i+1<<' '<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
char s[10000],t[10000];
int main(){
	while(true){
		int n;
		cin >> n;
		if(!n) break;
		rep(i,n) cin >> s[i] >> t[i];
		int m;
		cin >> m;
		rep(i,m){
			char c,ans;
			cin >> c;
			ans=c;
			rep(i,n) if(c==s[i]) ans=t[i];
			cout << ans;
		}
		cout << endl;
	}
	return 0;
}

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

typedef long long int ll;

int main () {
    int n, x, y; cin >> n >> x >> y;
    vector< vector<int> > g(n, vector<int>(n, 10000000));
    for (int i = 0; i < n - 1; i++) {
        g[i][i+1] = 1;
        g[i+1][i] = 1;
    }
    x--; y--;
    g[x][y] = 1;
    g[y][x] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            g[i][j] = min(g[i][j], j - i);
            g[j][i] = min(g[j][i], j - i);

        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            g[i][j] = min(g[i][j], (abs(i - x) + abs(j - y) + 1));
            g[j][i] = min(g[i][j], (abs(i - x) + abs(j - y) + 1));
        }
    }
    vector<int> ans(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (g[i][j] >= 10000000) {
                continue;
            }
            ans[g[i][j]]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<algorithm>
using namespace std;
int ta[1100][2100];//時間iのときのPCjの中に利用者を入れる
int info[1100][4];
int main(){
	int n,m,r,q;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)break;
	cin>>r;
	for(int i=0;i<2100;i++)for(int j=0;j<1100;j++)ta[j][i]=0;
	for(int i=0;i<1100;i++)for(int j=0;j<4;j++)info[i][j]=0;
	for(int i=0;i<r;i++){
	for(int j=0;j<4;j++)cin>>info[i][j];
	}
	for(int i=0;i<r;i++){
	int time=info[i][0],pc=info[i][1],p=info[i][2],f=info[i][3];
	if(f!=0){
		ta[pc][time]=p;
	}
	else ta[pc][time]=-p;
	}
	for(int i=0;i<1000;i++){
		for(int j=0;j<1999;j++){
		ta[i][j+1]+=ta[i][j];
		}
	}
	cin>>q;
for(int countfor=0;countfor<q;countfor++){
int ts,te,m,ans=0;
bool f=0;
cin>>ts>>te>>m;
for(int i=ts;i<te;i++){
	f=0;
	for(int j=0;j<=n;j++){
	if(ta[j][i]==m)f=1;
	}
	if(f){ans++;}
}
cout<<ans<<endl;
}
}
	return 0;
}

Measured memory_bytes: 10200
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// vector print(debug or stdout)
template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    ll  N, K;
    cin >> N >> K;
    vector<ll> A(N+1);
    FOR(i,1,N+1) cin >> A[i];

    vector<ll> visit(N+1);
    ll town = 1;
    ll tele = 1;
    while(true) {
        if (visit[A[town]] != 0) break;
        visit[A[town]] = tele;
        town = A[town];
        tele++;
    }
    //vout(ALL(visit),cerr);

    ll ans = 0;
    ll loop = A[town];
    //cerr << loop << endl;
    if (K < tele) {
        auto it = find(ALL(visit),K);
        ans = distance(visit.begin(),it);
    }
    else {
        ll looplen = tele - visit[loop];
        ll k2 = K - visit[loop];
        //cerr << k2 << " " << looplen << endl;
        ll m = k2 % looplen;
        auto it = find(ALL(visit),visit[loop]+m);
        ans = distance(visit.begin(),it);
        //cerr << visit[loop]+m << endl;
    }

    cout << ans << '\n';

    return 0;
}

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

int N,M;
vector<vector<int>> p;

void dfs(vector<int> v) {
	if(v.size() == N)
		p.push_back(v);
	else
		for(int i=v.at(v.size()-1); i<=M; ++i) {
			vector<int> t = v;
			t.push_back(i);
			dfs(t);
		}
}

int main() {
	int Q,r=0;
	cin >> N >> M >> Q;
	vector<int> a(Q),b(Q),c(Q),d(Q);

	rep(i,Q)
		cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
	
	rep(i,10) {
		vector<int> x;
		x.push_back(i+1);
		dfs(x);
	}

	rep(i,p.size()) {
		int t=0;
		rep(j,Q)
			if(p.at(i).at(b.at(j)-1)-p.at(i).at(a.at(j)-1) == c.at(j))
				t += d.at(j);
		r = max(r, t);
	}

	cout << r << endl;
}

Measured memory_bytes: 9864
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

A.sort(key=lambda x: x[1])
# print(A)

time = 0
for a in A:
	work, limit = a
	time += work
	if time > limit:
		print('No')
		sys.exit()
print('Yes')

Measured memory_bytes: 84572
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()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let (a,b,c) = (v[0],v[1],v[2]);
    println!("{}",
        if a < b && b < c {
            "Yes"
        } else {
            "No"
        });
}


Measured memory_bytes: 5028
l = int(input())
s = input().split()
#print(s)
ans = []

k =  l * 2
i = 0
while(i < l):
    #print(s[0][i])
    ans.append(s[0][i])
    ans.append(s[1][i])
    i += 1

ans2 = ''.join(ans) 
print(ans2)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)



// // aのp乗を求める関数
// ll modpow(ll a, int p)  {
//   if (p == 0) return 1;
//   if (p%2 == 0) {
//     int halfP = p / 2;
//     ll half = modpow(a, halfP);
//     return half * half % MOD;
//   }
//   else  {
//     return a * modpow(a, p-1) % MOD;
//   }
// }
//
//
// /// aCbを求める関数
// ll mod_combination(int a, int b)  {
//   if (b > a-b)  return mod_combination(a, a-b);
//   ll ansMul = 1;
//   ll ansDiv = 1;
//   rep(i, b) {
//     ansMul *= (a - i);
//     ansDiv *= (i + 1);
//     ansMul %= MOD;
//     ansDiv %= MOD;
//   }
//   ll ans = ansMul * modpow(ansDiv, MOD-2) % MOD;
//   return ans;
// }

// /// 最大公約数を求める関数
// ll gcd(ll m, ll n) {
//   // int x = max(m, n);
//   // int y = min(m, n);
//   if (y == 0) return x;
//   return gcd(y, x%y);
// }


int main(void){
	int a[5], k;
	cin >> a[0];
	cin >> a[1];
	cin >> a[2];
	cin >> a[3];
	cin >> a[4];
	cin >> k;
	int ans = 0;
  rep(i, 5)	{
		for (int j=i+1; j<5; j++)	{
			if (abs(a[i]-a[j]) > k)	{
				ans++;
			}
		}
	}

	if (ans == 0)	{
		cout << "Yay!" << endl;
	}	else	{
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long n=sc.nextLong();
long s=0;
long q=n/500;
s=q*1000;
long z=n%500;
long f=(z/5);
s=s+(f*5);
System.out.println(s);
}

}

Measured memory_bytes: 21332
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(int64_t i=2; i<=n; ++i) {
            if(f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for(int64_t j = i*i; j <= n; j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }
    //素数判定
    bool isPrime(int x) {return f[x] == x;}
    //素数判定(1つ用)(宣言はsqrt(x)のサイズで)
    bool isPrime1(int64_t x) {
        bool m = true;
        for(int z:primes) {
            if(!(x%z)) {
                m = false;
                break;
            }
        }
        return m;
    }
    //素数列挙
    vector<int > factorList(int x) {
        assert(x <= n);
        vector<int> res;
        while(x != 1) {
            res.emplace_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    //素因数分解　pair(素数, 素因数の数)
    vector<pair<int, int> > factor(int x) {
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<pair<int, int> > res(1, pair<int, int>(fl[0], 0));
        for(int p : fl) {
            if(res.back().first == p) {
                ++res.back().second;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)
    vector<int64_t> factorList1(int64_t x) {
        vector<int64_t> vec;
        for(int z:primes) {
            while(!(x%z)) {
                vec.emplace_back(z);
                x /= z;
            }
        }
        if(x != 1) vec.emplace_back(x);
        return vec;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)　pair(素数, 素因数の数)
    vector<pair<int64_t, int> > factor1(int64_t x) {
        vector<int64_t> vec = factorList1(x);
        vector<pair<int64_t, int> > vecc;
        for(vector<int64_t>::iterator itr = vec.begin(); itr != vec.end(); ++itr) {
            if(itr != vec.begin() && *itr == *(itr-1)) {
                (vecc.end()-1)->second++;
            } else {
                vecc.emplace_back(pair<int64_t, int>(*itr, 1));
            }
        }
        return vecc;
    }
}pp(1300);

int main() {
    int n;
    cin >> n;
    vi ff;
    vi ans;
    int kk = 0;
    rep(i, n) {
        while(pp.primes[kk]%5 != 2) {
            kk++;
        }
        ans.push_back(pp.primes[kk]);
        kk++;
    }

    rep(i, n) {
        cout << ans[i] << (i== n-1 ? '\n':' ');
    }
}

Measured memory_bytes: 256
/* Simple Calculator */
#include <stdio.h>

int main()
{
    int a, b;
    char op;

    while(1){
        scanf("%d %c %d", &a, &op, &b);
     if(op == '?'){ break; }
     if(op == '+'){ printf("%d\n", a+b); }
     if(op == '-'){ printf("%d\n", a-b); }
     if(op == '*'){ printf("%d\n", a*b); }
     if(op == '/'){ printf("%d\n", a/b); }
    }
}


Measured memory_bytes: 2076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_4_B_BinarySearch
{
    class Program
    {
        static int[] S = new int[100100];
        static int n;
        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            S = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var q = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var C = 0;


            for (int i = 0; i < q; i++)
            {
                C += BinarySearch(T[i]);
            }
            Console.WriteLine(C);
        }
        
        static int BinarySearch(int key)
        {
            int left = 0;
            int right = n;
            int mid;
            while (left < right)
            {
                mid = (left + right) / 2;
                if (key == S[mid])
                {
                    return 1;
                }
                else if (key > S[mid])
                {
                    left = mid + 1;
                }
                else
                {
                    right = mid;
                }
            }
            return 0;
        }
    }
}


Measured memory_bytes: 29672
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
#include <cstdint>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
#define mod 1000000007
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


ll comb(int n, int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int compare_char(const void* left, const void* right) {
	char *left_char = (char *)left;
	char *right_char = (char *)right;

	return strcmp(left_char, right_char);
}

int main(){


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

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	ll i, j, k, l, m, n, len, a, b, c;
	ll A, B, C, D, N, M, K, num_R, num_G, num_B, ans;
	ll sum = 0, sum_B = 0, sum_C = 0, max, min, count = 0, W;
	ll **dp;
	char S[200000];



	cin >> K >> A >> B;

	i = 0;
	while (sum<=B){
		sum = i*K;
		if (sum >= A && sum <= B){

			cout << "OK" << endl;
			return 0;
		}
		i++;
	}

		cout << "NG" << endl;


	return 0;

}
    

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	string bf, in;
	cin >> n;
	set<string> st;
	rep(i, n){
		cin >> in;
		if(i != 0){
			if(bf.back() != in[0]){
				cout << "No" << endl;
				return 0;
			}
		}
		if(st.count(in) == 1){
			cout << "No" << endl;
			return 0;
		}
		st.insert(in);
		bf = in;
	}
	cout << "Yes" << endl;
	return 0;
}

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

int N, A[100], Count = 0;

void SelectionSort(int A[], int N) {
	for (int i = 0; i < N; i++) {
		int min_j = i;
		for (int j = i + 1; j < N; j++) {
			if (A[j] < A[min_j]) {
				min_j = j;
			}
		}
		if (i != min_j) {
			swap(A[i], A[min_j]);
			Count++;
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	SelectionSort(A, N);
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << Count << endl;
}


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

int GCD(int X,int Y){
    if(Y>X){
        int Z=X;
        X=Y;
        Y=Z;
    }
    int Z;
    while(Y>0){
        Z=X%Y;
        X=Y;
        Y=Z;
    }
    return X;
}
int main(){
    int x,y;
    cin>>x>>y;
    cout<<GCD(x,y)<<endl;
    return 0;
}



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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  rep(i,110){
   c-=b;
   if(c<=0){
   cout<<"Yes"<<endl;
   break;
   }
    a-=d;
   if(a<=0){
   cout<<"No"<<endl;
   break;
   }
   
  }
  
  
}


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

int main() {
  
  int N, A, B, answer;
  cin >> N >> A >> B;
  
  N = N * A;
  B = B;
  
  if ( N < B ) {
    answer = N;
  }
  
  if ( N > B ) {
    answer = B;
  }
  
  if ( N == B ) {
    answer = N;
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 256
#![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 n = read::<usize>();
    let mut a = read_vec::<usize>();
    a.sort();
    a.reverse();
    let mut ans = 0;
    for i in 0..2 * n {
        if i % 2 == 1 {
            ans += a[i];
        }
    }
    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: 13560
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	
	if (n % 10 == 3) printf("bon\n");
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) printf("pon\n");
	else printf("hon\n");
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<ll> v,w;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n;
    p=(n+1)/2;
    ld aa;
    aa=((ld)p)/n;
    cout<<sp(10)<<aa;
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

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

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, C; cin >> N >> C;
  int inf = (100000)*2 + 1;
  vector<vector<int>> jikokuhyo(C, vector<int>(inf));
  for (int i = 0; i < N; ++i) {
    int s, t, c; cin >> s >> t >> c;
    --c;
    jikokuhyo[c][s*2-1] += 1;
    jikokuhyo[c][t*2] -= 1;
  }

  for (int time = 1; time < inf; ++time) {
    for (int index = 0; index < C; ++index) {
      jikokuhyo[index][time] += jikokuhyo[index][time-1];
    }
  }
  vector<int> result(inf, 0);
  for (int t = 0; t < inf; ++t) {
    int res{};
    for (int i = 0; i < C; ++i) {
      if (jikokuhyo[i][t] > 0) {
        ++res;
      }
    }
    result[t] = res;
  }
  auto ans = boost::max_element(result);
  cout << *ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 24576
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n % 3 == 0) {
        map<ll, int> mp;
        for (int i = 0; i < n; i++) {
            mp[a[i]]++;
        }
        if (mp.size() > 3) {
            cout << "No" << endl;
        } else {
            ll x = 0;
            for (auto it = mp.begin(); it != mp.end(); it++) {
                if (it->second % (n / 3) > 0) {
                    cout << "No" << endl;
                    return 0;
                }
                if (it->second / (n / 3) == 1 || it->second / (n / 3) == 3) {
                    x ^= it->first;
                }
            }
            if (x == 0) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    } else {
        bool f = true;
        for (int i = 0; i < n; i++) {
            if (a[i] > 0) {
                f = false;
                break;
            }
        }
        if (f) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 5760
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
 
 
 
int main()
{
 
    queue < pair<int, int> > q;
    pair<int, int> p;
 
 
 
    char **m;
    char c[10] = { "123456789" };
    int **f;
	bool flg = false;
    int n, k, i, i1, c1, i2, sum = 0;
    cin >> n;
    cin >> k;
    cin >> c1;
 
    m = new char *[n + 2];
    f = new int *[n + 2];
 
    for (i = 0; i < n + 2; i++){
        m[i] = new char[k + 2];
        f[i] = new int[k + 2];
    }
 
    for (i = 1; i <= n; i++){
        for (i1 = 1; i1 <= k; i1++){
            cin >> m[i][i1];
        }
    }
 
    for (i = 0; i < n + 2; i++){
        for (i1 = 0; i1 < k + 2; i1++){
            if (i == 0 || i == n + 1){
                m[i][i1] = 'X';
            }
            else if (i1 == 0 || i1 == k + 1){
                m[i][i1] = 'X';
            }
        }
    }
 
    for (i = 1; i <= n; i++){
        for (i1 = 1; m[i][i1] != '\0'; i1++){
            if (m[i][i1] == 'S'){
                q.push(make_pair(i, i1));
            }
        }
    }
 
 
 
    pair<int, int> temp;
 
    temp = q.front();
 
    for (i = 0; i < c1; i++){

		for (i1 = 0; i1 < n + 2; i1++){
				for (i2 = 0; i2 < k + 2; i2++){
					if ((i1 == 0 || i1 == n + 1) && !flg){
						f[i1][i2] = 1;
					}
					else if ((i2 == 0 || i2 == k + 1) && !flg){
						f[i1][i2] = 1;
					}
					else
						f[i1][i2] = -1;
				}
		}

		flg = true;

        f[temp.first][temp.second] = 0;
 
		while (!q.empty()){
            p = q.front();
            q.pop();
 
            int x[4] = { -1, 1, 0, 0 }, y[4] = { 0, 0, -1, 1 };
 
            for (int j = 0; j < 4; j++){
 
                //???????????´??????????´¢
                if (m[p.first + x[j]][p.second + y[j]] != 'X' && f[p.first + x[j]][p.second + y[j]] < 0){
                    q.push(make_pair(p.first + x[j], p.second + y[j]));
                    f[p.first + x[j]][p.second + y[j]] = f[p.first][p.second] + 1;
                }
            }
            //??´?????????????????????
            if (m[p.first][p.second] == c[i]){
                sum += f[p.first][p.second];
                temp = p;
                while (!q.empty()){
                    q.pop();
                }
                q.push(p);
                break;
			}
		}
	}
 
    cout << sum << endl;
 
    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll r;
  cin >> r;
  printf("%.7f\n", r*2*3.1415926);
  
}


Measured memory_bytes: 3752
#include <stdio.h>
#define N 1000000
int left_key(int);
int right_key(int);
void BuildMaxHeap();
void maxHeapify(int);

int n,A[N+1];
int main()
{
  int i;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
    }
  
  BuildMaxHeap();
  
  for(i=1;i<=n;i++)
    {
      printf(" %d",A[i]);
    }
  
  printf("\n");
  return 0;
}
void maxHeapify(int x)
{
  int l=0,r=0,largest=0;
  int es_largest=0; //??\???????????????????????¨???
  l=left_key(x);
  r=right_key(x);
  
  if(l<=n&&A[l]>A[x]) largest=l;
  else largest=x;
  
  if(r<=n&&A[r]>A[largest]) largest=r;
  
  if(largest!=x)
    {
      es_largest=A[largest];
      A[largest]=A[x];
      A[x]=es_largest;
      maxHeapify(largest);
    }
}

void BuildMaxHeap()
{
  int i;
   for(i=n/2;i>=1;i--) //???????????°?????????????????§???n/2
    {
      maxHeapify(i);
    }
}

int left_key(int x)
{
  return 2*x;
}
int right_key(int x)
{
  return 2*x+1;
}

Measured memory_bytes: 4556
N = int(input())
a = list(map(int, input().split()))
boxes = [0]*N
for i in reversed(range(N)):
    x = N //(i + 1)
    boxes[i] = (a[i] + sum([boxes[j*(i + 1) - 1] for j in range(2, x+1)]))%2
print(sum(boxes))
ans = []
for i in range(N):
    if boxes[i] == 1:
        ans.append(i + 1)
print(*ans)

Measured memory_bytes: 14140
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    for(int i=0;i<s.size();i++){
        int ans = 0;
        if(int(s[i])+n > int('Z')){
            ans = int('A') + int(s[i])+ n -int('Z')-1;
        }
        else{
            ans = int(s[i]) + n;
        }
        cout << char(ans);
    }
    cout << endl;
    return 0;

}

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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// #define int long long
// --------------------------------------------------------------------------------

const int mod = 9;

void test_case(int tc)
{
	string s;cin>>s;
	int sum = 0;
	for(auto x:s)sum = (sum+x-'0')%mod;
	cout<<((sum==0)?"Yes":"No");
}

int32_t main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int tc=1;
    //cin>>tc;
    for(int i=1;i<=tc;++i)test_case(tc);
}

Measured memory_bytes: 3708
# E - Coprime
from math import gcd

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
MAX = 10**6
L = [0]*(MAX+1)

def prime(x):
    global L
    p = 2
    while x>1:
        if L[x]==1:
            return False
        if x%p==0:
            while x%p==0:
                x //= p
            tmp = p
            while tmp<=MAX:
                L[tmp] = 1
                tmp += p
        p = p+1 if p*p<x else x   
    return True
        
G = A[0]
pairwise = True
_ = prime(A[0])

for i in range(1,N):
    a = A[i]
    if pairwise:
        pairwise = prime(a)
    G = gcd(G,a)

if pairwise:
    print('pairwise coprime')
elif G==1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 213052
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
    int n; cin >> n;
    vector<vector<int>> F(n, vector<int>(10)), P(n, vector<int>(11));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> P[i][j];
        }
    }
    int ans = -INF;
    for(int i = 1; i < (1<<10); i++){
        vector<int> num(n);
        int tmp = 0;
        for(int j = 0; j < 10; j++){
            if(i & (1 << j)){
                for(int k = 0; k < n; k++){
                    if(F[k][j]) num[k]++;
                }
            }
        }
        for(int j = 0; j < n; j++){
            tmp += P[j][num[j]];
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
#define sag (sol|1)
//#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
#define N (int)(1e5+10)
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



int n, C;
int value[100005], weight[100005];
vpi vec(100005,{MAXN,MAXN});
int dp[100005];
signed main() {

    int a,b;
    cin >>a>>b;
    vi vec(b);
    int sum = 0;
    for (int i = 0; i <b ; ++i) {
        cin>>vec[i];
        sum+=vec[i];
    }
    if(sum >=a)cout<<"Yes";
    else cout << "No";
    return 0;

}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
const int N = 1e5 + 9;
 
set<int>r[N], b[N];
using pii = pair<int, int>;
queue<pii>Q;
int n, f[N];
int find (int x) { while (x != f[x]) x = f[x] = f[f[x]]; return x; }
 
int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) f[i] = i;
	for (int i = 1, u, v; i < n; ++i) scanf("%d%d", &u, &v), b[u].insert(v), b[v].insert(u);
	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d%d", &u, &v), r[u].insert(v), r[v].insert(u);
		if (b[u].count(v)) Q.push(pii(u, v)); 
	} 
	for (int i = 1, x, y; i < n; ++i) {
		if (Q.empty()) return puts("NO"), 0;
		x = find(Q.front().first); y = find(Q.front().second); Q.pop();
		if (x == y) { --i; continue ; }
		r[x].erase(y); r[y].erase(x); b[x].erase(y); b[y].erase(x);
		if (r[x].size() > r[y].size()) x ^= y ^= x ^= y;
		f[x] = y;
		for (auto v : r[x]) if (b[y].count(v)) Q.push(pii(v, y));
		for (auto v : b[x]) if (r[y].count(v)) Q.push(pii(v, y));
		for (auto v : r[x]) {
			r[y].insert(v), r[v].erase(x), r[v].insert(y);
		}
		for (auto v : b[x]) {
			b[y].insert(v), b[v].erase(x), b[v].insert(y);
		}
	}
	return puts("YES"), 0;
}

Measured memory_bytes: 29056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#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 ALL(n) begin(n), end(n)
#define IN(a, x, b) (a <= x && x < b)
#define INIT                        \
  std::ios::sync_with_stdio(false); \
  std::cin.tie(0);
template <class T>
inline T CHMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  INIT;
  int n, q;
  cin >> n;
  vector<int> m(100005, 0);
  ll total = 0;
  REP(i, n) {
    int a;
    cin >> a;
    m[a] += 1;
    total += a;
  }
  cin >> q;
  int b;
  int c;
  REP(i, q) {
    cin >> b >> c;
    int s = c - b;
    total = total + (m[b] * s);
    cout << total << "\n";
    m[c] += m[b];
    m[b] = 0;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
int main(){
    int i, r, x, tmp, n, p, c, z, data[51];
    for(; scanf("%d%d", &n, &r);){
       if( n == 0 && r == 0 ){
           break;
       }
        for( i = n, x = 0; i > 0; i--, x++ ){
            data[x] = i;
        }
        for( i = 0; i < r; i++ ){
            scanf("%d%d", &p, &c);
            for( x = 0; x < p - 1; x++ ){
                for( z = 0; z < p + c-1; z++ ){
                     if( z == 0 ){
                         tmp = data[z];
                     }else if( z == p + c - 2 ){
                        data[z - 1] = data[z];
                        data[z] = tmp;
                     }else{
                        data[z - 1] = data[z];
                     }
                }
            }
        }
        printf("%d\n", data[0]);
    }
    return 0;
}

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

signed main(void)
{
	int a, b;
	int diff;
	cin >> a >> b;

	diff = (a + b) / 2;
	if (abs(a - diff) != abs (b - diff))
		cout << "IMPOSSIBLE" << endl;
	else
		cout << diff << endl;
	return 0;
}


Measured memory_bytes: 256