akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
}


Measured memory_bytes: 20948
#include <iostream>
#include <ios>
#include <algorithm>
using namespace std;
int n, A[20] = {};

bool check(int i, int v){
	if (i == n)					return false;
	if (v == A[i])				return true;
	if (v < A[i])				return false;
	if (check(i + 1, v))		return true;
	if (check(i + 1, v - A[i]))	return true;
	return false;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, i, k;
	cin >> n;
	for (i = 0; i < n; ++i)
		cin >> A[i];
	sort(A, A + n);
	cin >> m;
	for (i = 0; i < m; ++i){
		cin >> k;
		cout << (check(0, k) ? "yes\n" : "no\n");
	}

	return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
int main(void){
  int A,B,C;
  1<=A<=9;
  1<=B<=9;
  1<=C<=9;
  scanf("%d %d %d",&A,&B,&C);
  if(A==B&&A!=C){printf("Yes\n");
  } else if(A==C&&A!=B){printf("Yes\n");
  } else if(B==C&&A!=B){printf("Yes\n");
  } else{printf("No\n");}
}


Measured memory_bytes: 2036
import sys

input = sys.stdin.readline


def solve(S):
    for i, s in enumerate(S):
        if i % 2 == 1 and s == 'R':
            return 'No'
        if i % 2 == 0 and s == 'L':
            return 'No'
    return 'Yes'


if __name__ == '__main__':
    S = input()

    answer = solve(S.strip())
    print(answer)


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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n+1);
  vector<long long> b(n);
  for(int i = 0; i < n+1; i++) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  long long over = 0;
  long long ans = 0;
  for(int i = 0; i < n; ++i){
    long long k = a[i] - b[i] - over;
    if(k > 0){
      ans += b[i] + over;
      over = 0;
    }
    else{
      ans += a[i];
      over = min(b[i], -k);
    }
  }
  
  ans += min(a[n], over);
  
  cout << ans << endl;
}

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

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

vector<int> E[200005];
int k;
int in[200005], out[200005];
void dfs(int u, int p=-1) {
    in[u] = k++;
    for (int v: E[u]) {
        if (v == p) continue;
        dfs(v, u);
    }
    out[u] = k;
}

ll f(int a) {
    return ll(a)*(a+1)/2;
}

vector<int> V[200005];

int main() {
    int n;
    cin >> n;
    vector<int> C(n);
    rep(i, n) {
        int c;
        cin >> c;
        --c;
        C[i] = c;
    }
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    dfs(0);
    rep(i, n) {
        V[C[i]].push_back(i);
    }

    BIT<int> bi_tree(n);
    rep(i, n) bi_tree.add(i, 1);
    rep(i, n) {
        ll ans = f(n);
        sort(V[i].begin(), V[i].end(), [&](int a, int b) {
            return in[a] > in[b];
        });
        vector<P> history;
        for (int v: V[i]) {
            int s = 1;
            for (int u: E[v]) {
                if (in[v] >= in[u]) continue;
                int tmp = bi_tree.sum(in[u], out[u]);
                s += tmp;
                ans -= f(tmp);
            }
            bi_tree.add(in[v], -s);
            history.emplace_back(in[v], s);
        }
        int tmp = bi_tree.sum(0, n);
        ans -= f(tmp);
        cout << ans << endl;
        for (P p: history) {
            bi_tree.add(p.first, p.second);
        }
    }
    return 0;
}

Measured memory_bytes: 35292
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize, m: usize,
        ab: [(usize1, usize1); m],
    }

    let mut v = vec![vec![]; n];
    for (f, t) in ab {
        v[f].push(t);
        v[t].push(f);
    }

    let mut queue = std::collections::VecDeque::new();
    let mut from = vec![None; n];
    from[0] = Some(0);
    queue.push_back(0);
    while !queue.is_empty() {
        let cur = queue.pop_front().unwrap();
        for &next in &v[cur] {
            if next == cur {
                continue;
            }
            if from[next].is_some() {
                continue;
            }
            from[next] = Some(cur);
            queue.push_back(next);
        }
    }
    println!("Yes");
    for i in 1..n {
        println!("{}", from[i].unwrap() + 1);
    }
}


Measured memory_bytes: 13856
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector<int> Vec;
 
int N, maxi;
vector<string> v;
Vec num,l;
set<Vec> st;
 
int solve(int k, int idx, int sum, int S, int p){
    if(k == maxi){
        if(p != 0 || st.count(num)) return 0;
        st.insert(num);
        return 1;
    }
    int res = 0;
    if(idx == N-1){
        int val = (int)(v[idx][k]-'A');
        int ns = (sum + p) % 10;
        int np = (sum + p) / 10;
        if(num[val] != -1){
            if(l[idx] > 0 && k == l[idx] && num[val] == 0){
                return 0;
            }
            if(ns == num[val]){
                res = solve(k+1, 0, 0, S, np);
            }
        }else{
            for(int i = 0 ; i < 10 ; i++){
                if(S >> i & 1) continue;
                num[val] = i;
                if(ns == i && !(l[idx] > 0 && k == l[idx] && i == 0)){
                    res += solve(k+1, 0, 0, S|(1<<i), np);
                }
                num[val] = -1;
            }
        }
    }else{
        if(v[idx][k] == '*'){
            res = solve(k, idx+1, sum, S, p);
        }else{
            int val = (int)(v[idx][k]-'A');
            if(num[val] != -1){
                if(l[idx] > 0 && k == l[idx] && num[val] == 0){
                    return 0;
                }
                res += solve(k, idx+1, sum+num[val], S, p);
            }else{
                for(int i = 0 ; i < 10 ; i++){
                    if(S >> i & 1) continue;
                    num[val] = i;
                    if(!(l[idx] > 0 && k == l[idx] && i == 0)){
                        res += solve(k, idx+1, sum+i, S|(1<<i), p);
                    }
                    num[val] = -1;
                }
            }
        }
    }
    return res;
}
 
int main(){
    while(cin >> N, N){
        v.resize(N); l.resize(N);
        maxi = 0;
        Vec len(N);
        for(int i = 0 ; i < N ; i++){
            cin >> v[i];
            l[i] = len[i] = v[i].size();
            l[i]--;
            maxi = max(maxi, len[i]);
            reverse(v[i].begin(),v[i].end());
        }
        if(len[N-1] < maxi){
            cout << 0 << endl;
            continue;
        }
        for(int i = 0 ; i < N ; i++){
            while(len[i] != maxi){
                v[i] += '*';
                len[i]++;
            }
        }
        num.resize(26, -1); st.clear();
        cout << solve(0, 0, 0, 0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 10080
from sys import stdin
import math
K = int(stdin.readline().rstrip())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            tmp = math.gcd(i,j)
            ans += math.gcd(tmp,k)
print(ans)

Measured memory_bytes: 67808
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int a, b;
	cin >> a >> b;
	if(a + b == 15) cout << "+" << endl;
	else if(a * b == 15) cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,m = map(int,input().split())
# 列ベクトルとかの受け取り
lists = [list(map(int,input().split())) for _ in range(m)]

maxL = 1
minR = n
for i in range(m):
    maxL = max(maxL,lists[i][0])
    minR = min(minR,lists[i][1])

ans = minR - maxL +1
if ans <= 0:
    ans = 0

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 27332
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;
      
      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
i64 n,x,t;
cin>>n>>x>>t;
cout<<((n+x-1)/x*t);

  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


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


int N;
vector<int> A;

bool check(vector<int>& a){
  for(int i=0;i<N;i++)
    if(a[i]!=i) return false;
  return true;
}
int ind(vector<int>&a, int x){
  for(int i=0;i<N;i++)
    if( a[i] == x ) return i;
}
void view(vector<int>& a){
  for(int i=0;i<N;i++) cout << a[i] << " ";
  cout << endl;
}

typedef pair<vector<int>,int> P;

void solve(map<vector<int>,int>& M,vector<int>& A){
  M.clear();
  queue<P> q;
  q.push( P(A, 0) );
  M[A] = 0;
  while( !q.empty() ){
    P p = q.front(); q.pop();
    if( p.second == 4 ) return;
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        vector<int> a=p.first;
        reverse( a.begin()+i, a.begin()+j+1 );
        if( M.count( a ) == 0 ){
          M[a] = p.second+1;
          q.push( P(a,p.second+1) );
        }
      }
    }
  }
}

int main(){
  while(cin >> N){
    A.resize(N);
    for(int i=0;i<N;i++) {
      cin >>A[i]; A[i]--;
    }
    map<vector<int>,int> M1,M2;
    solve(M1,A);
    sort( A.begin(), A.end() );
    solve(M2,A);
    int res = 9;
    for( auto it = M1.begin(); it != M1.end();it++ )
      if( M2.count( it->first ) != 0 )
        res = min( res, it->second + M2[it->first] );
    cout << res << endl;
  }
}

Measured memory_bytes: 85192
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC171E
int main(void) {
  int n, k, i, cou=0, tmp=0;
  scanf("%d", &n);
  long long a[n];
  for(i=0; i < n; i++){
    scanf(" %lld" , &a[i]);
    tmp=tmp^a[i];
  }
  for(i=0; i < n; i++){
    printf("%lld\n", tmp^a[i]);
  }

}

Measured memory_bytes: 4040
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define REP(i,m,n) for(int i = (int)(m) ;i < (int)(n) ;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int n, cnt;


int main(){
	cin >> n;
	for (int i = 1; i <= n; i = i + 2){
		int c = 0;
		REP(j, 1, i + 1){
			if (i % j == 0){
				c++;
			}
		}
		if (c == 8) cnt++;


	}
	
	cout << cnt << endl;







	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
const ll M = 1e9+7;
const int MN = 200100;
class U {
	private:
		int n,nc;
		vi p,rk,sz;
	public:
		int num() {return nc;}
		U(int v) {
			nc = n = v;
			rk.assign(n,0);
			sz.assign(n,1);
			for(int i=0;i<n;i++) {p.push_back(i);}
		}
		int find(int a) {
			if(a == p[a]) return a;
			return p[a] = find(p[a]);
		}
		bool same(int a, int b) {return find(a) == find(b);}
		int size(int a) {return sz[find(a)];}
		bool un(int a, int b) {
			int x = find(a),y = find(b);
			if(x == y) return false;
			nc--;
			if(rk[x] > rk[y]) {
				p[y] = x;
				sz[x] += sz[y];
				return true;}
			if(rk[x] == rk[y]) rk[y]++;
			p[x] = y;
			sz[y] += sz[x];
			return true;
		}
};
inline ll mul(ll a, ll b) {return (a*b)%M;}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {ac = mul(ac,b);}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
inline ll inv(ll v) {return bp(v,M-2);}
vpl wo[MN];
vpl w;
vl col;
vl fr;
int main() {
	ll n,x,y;
	cin >> n >> x >> y;
	for(int i=0;i<n;i++) {
		ll c,k;
		cin >> c >> k;
		c--;
		wo[c].push_back({k,i});
		w.push_back({k,i});
		col.push_back(c);
	}
	sort(w.begin(),w.end());
	int mb = 1;
	while(mb < n && col[w[0].second] == col[w[mb].second]) {mb++;}
	ll pu[2] = {w[0].second,-1};
	ll we[2] = {w[0].first, M};
	if(mb < n) {pu[1] = w[mb].second;we[1] = w[mb].first;}
	for(int i=0;i<n;i++) {
		sort(wo[i].begin(),wo[i].end());
	}
	U bs(n);
	for(int i=0;i<n;i++) {
		for(int j=0;j<wo[i].size();j++) {
			if(wo[i][j].first+wo[i][0].first <= x) {
				bs.un(wo[i][j].second,wo[i][0].second);
			}
		}
	}
	for(int idx=0;idx<2;idx++) {
		ll me = pu[idx];
		if(me < 0) {continue;}
		ll mw = we[idx];
		for(int i=0;i<n;i++) {
			if(w[i].first+mw <= y) {
				if(col[w[i].second] != col[me]) {
					bs.un(w[i].second, me);
				}
			}
		}
	}
	ll rv[2];
	for(int idx=0;idx<2;idx++) {
		ll mu = pu[idx];
		if(mu < 0) {continue;}
		ll tot = 0;
		fr.assign(n,0);
		for(int i=0;i<n;i++) {
			if(bs.same(i,mu)) {
				fr[col[i]]++;
				tot++;
			}
		}
		ll ra = 1,rb = 1;
		for(int i=2;i<=tot;i++) {
			ra = mul(ra,i);
		}
		for(int i=0;i<n;i++) {
			for(int j=2;j<=fr[i];j++) {
				rb = mul(rb,j);
			}
		}
		rv[idx] = mul(ra,inv(rb));
	}
	ll res;
  //e
	if(pu[1] >= 0 && !bs.same(pu[0],pu[1])) {
		res = mul(rv[0],rv[1]);
	} else {
		res = rv[0];
	}
	cout << res << '\n';
}


Measured memory_bytes: 23524
#include <iostream>

using namespace std;
typedef long long LL;

int main(){
	int N;
	cin >> N;
	int count = 0;
	for (int i = 0; i < N; i++) {
	  int i1, i2;
	  cin >> i1;
	  cin >> i2;
	  if(i1==i2){
		count++;
	  }else{
		count = 0;
	  }
	  if(count==3){
		cout << "Yes";

		return 0;
	  }
	}

	cout << "No";

	return 0;
}

Measured memory_bytes: 3580
#include "stdio.h"

int main()
{

  int i,j,a,b;



while (1)
{


  scanf("%d %d\n",&a,&b);
  if (a==0) {
    break;
  }

  for (j = 0; j < a; j++)
  {

    for (i = 0; i < b; i++)
    {

      if ((i+j)%2==0)
     {
       printf("#");
      }
      
      else
      {
        printf(".");
      }
      



    }
    printf("\n");

  }
  printf("\n" );

}









  return 0;
}



Measured memory_bytes: 2048
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[10];
int t[1<<4];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	long long ret=0;
	std::sort(b,b+a);
	ret+=b[a-1];
	t[1]=b[a-1];
	if(a==5&&b[4]==2){
		printf("4\n");return 0;
	}
	if(a>1){
		ret+=b[a-2]-1;
		t[2]=b[a-2]-1;
		t[1]--;
		t[3]++;
		if(a>2){
			ret+=b[a-3]-2;
			t[4]=b[a-3]-2;
			t[1]--;
			t[2]--;
			t[5]++;
			t[6]++;
			if(a>3){
				if(b[a-3]>2){
					ret+=max(0,b[a-4]-3);
					t[8]=max(0,b[a-4]-3);
					t[1]--;
					t[2]--;
					t[9]++;
					t[10]++;
					if(b[a-4]>=3){
						t[4]--;
						t[12]++;
					}
					
				}else if(b[a-2]>2){
					ret+=b[a-4]-2;
					t[1]--;
					t[2]--;
					t[9]++;
					t[10]++;
					t[8]=b[a-4]-2;
				}else if(b[a-1]>2){
					ret+=b[a-4]-2;
					t[1]--;
					t[6]--;
					t[9]++;
					t[14]++;
					t[8]=b[a-4]-2;//return 1;
				}else{
					ret+=b[a-4]-1;
					t[3]--;
					t[11]++;
				}
				if(a>4){
					int val=0;
					for(int i=0;i<(1<<16);i++){
						bool ok=true;
						for(int j=0;j<16;j++)if((i&(1<<j))&&!t[j])ok=false;
						int tmp=__builtin_popcount(i);
						
						for(int j=0;j<4;j++){
							int at=0;
							for(int k=0;k<16;k++)if((k&(1<<j))&&(i&(1<<k)))at++;
							if(at>1)ok=false;
							//tmp+=at;
						}
						if(!ok)continue;
						val=max(val,tmp);
					}
					ret+=max(0,b[a-5]-val);
				}
			}
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 1044
{
  const run = (input: string) => {
    const [a, b, c] = input.trim().split(" ").map(v => parseInt(v))

    const sum = b + c
    let a2 = a
    for (let i = 0; i <= sum; i++) {
      if (a2 % b === c) {
        return 'YES'
      } else {
        a2 += a
      }
    }

    return 'NO'
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

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


Measured memory_bytes: 29628
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
using namespace std;

int GetMinimum(int A, int B, int C, int X, int Y){
    int maxnab = max(2*X, 2*Y);
    int minsum = INT_MAX;
    for(int nab=0; nab<=maxnab; nab+=2){
        int na = X - nab/2;
        int nb = Y - nab/2;
        if (na<0) na=0;
        if (nb<0) nb=0;
        int sum = A * na + B * nb + C * nab;
        if(sum < minsum) minsum = sum;
    }
    return minsum;
}

int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    auto n = GetMinimum(A,B,C,X,Y);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    ll D;
    cin >> N >> D;
    int ans = 0;
    rep(i,N){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y <= D*D) ans++;
    }
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
string repeat(string s, int n) 
{ 
    // Copying given string to temparory string. 
    string s1 = s; 
  
    for (int i=1; i<n;i++) 
        s += s1; // Concatinating strings 
  
    return s; 
} 

int main() {
    int a,b;
    cin >> a >> b;
    string as = repeat(to_string(a),b);
    string bs = repeat(to_string(b),a);
    if(as > bs){cout << bs;}
    else{cout << as;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<int,int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    string s;
    cin>>s;
    int z=s.length();
    if(s[z-1]=='1' || s[z-1]=='0' || s[z-1]=='6' || s[z-1]=='8'){
        cout<<"pon";
    }
    else if(s[z-1]=='3'){
        cout<<"bon";
    }
    else{
        cout<<"hon";
    }
}

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

using namespace std;
int main(){
  int N;
  cin >> N;
  vector<double> v(N);
  for(int  i = 0; i < N; i++) cin >> v[i];
  sort(v.begin(),v.end());
 double ans = 0;
  for(int i = 0; i < N - 1; i++){
   
    v[i + 1] = (v[i] + v[i + 1]) / 2.0;
  }

  cout << v[N - 1];
 return 0;
}

Measured memory_bytes: 256
def submit():
    s = str(input())
    k = int(input())

    for i, c in enumerate(s, start=1):
        if c != "1":
            if i > k:
                break
            else:
                print(c)
                return

    # 全て1 or kまで1 
    print("1")
            

if __name__ == "__main__":
    submit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  ll n, m;
  cin >> n >> m;
  ll a, b;
  vector<pair<ll,ll>> shop;

  for(int i=0; i<n; ++i){
    cin >> a >> b;
    shop.push_back({a, b});
  }

  sort(shop.begin(), shop.end());

  ll sum = 0;
  for(auto& i: shop){
    sum += i.first * min(m, i.second);
    m -= min(m, i.second);
  }
  cout << sum << endl;
}

Measured memory_bytes: 5352
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif


int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0){
        n/=k;
        cnt++;

    }
    cout<<cnt;

 
 
 
    
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
       public static void main(String[] args) {
    	  Scanner input=new Scanner( System.in);
    	  long n=input.nextLong();
    	  long a=input.nextLong();
		  long b=input.nextLong();
    	  for(int i=1;i<n;i++) {
    		 // System.out.println("s:"+a+"   "+b);
    		  long a1=input.nextLong();
    		  long b1=input.nextLong();
    		  if(a1>=a&&b1>=b) 
    			  {
    			  a=a1;
        		  b=b1;
    			  continue;
    			  }
    		  long d1=a/a1;
    		  if(a%a1!=0) d1++;
    		  
    		  long d2=b/b1;
    		  if(b%b1!=0) d2++;
    	//System.out.println("ss:"+d1+"   "+d2);
    		  long d=Math.max(d1, d2);
    		 
    		  a=d*a1;
    		  b=d*b1;
    		 
    	  }
    	  System.out.println(a+b);
          
	}
}


Measured memory_bytes: 26580
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        String s=sc.next();
  		String[] a=s.split("");
  		int ans=0;
  		int c=0;
  
		while(c<a.length){
        	if(a[c].equals("h")){
            	c=c+2;
            }else{
            	ans++;
              	c=c+2;
            }
          
        }
  		c=1;
  
  		while(c<a.length){
        	if(a[c].equals("i")){
            	c=c+2;
            }else{
            	ans++;
              	c=c+2;
            }
          
        }
  	if(a.length%2==1){
    	ans++;
    }
    
    
 	if(ans==0){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;


int main(){
	ll n,m;
	cin>>n>>m;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum%(4*m)!=0) cnt=(sum/(4*m))+1;
	else cnt=sum/(4*m);
	for(ll i=0; i<n; i++){
		if(a[i]>=cnt){
			mx++;
		}
	}
	if(mx>=m) cout<<"Yes";
	else cout<<"No";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,A;
    cin >> N >> A;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<vector<ll> > dp(51,vector<ll> (2501));
    rep(i,51){
        rep(j,51){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    rep(i,N){
        for (ll j = 49; j >= 0; j--){
            for (ll k = 2450; k >= 0; k--){
                dp[j + 1][k + vec[i]] += dp[j][k];
            }
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= 50; i++){
        ans += dp[i][i * A];
    }
    cout << ans << endl;
}


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

int main(){
ll test,i,j,count,flag=0,n,o1=0,o2=0,b1,x,y,m,l,z,max1,x1,y1,x2,y2,z1,k,sum,f,r,ans1,min1;
cin>>n;
x1=y1=0;
for(i=1;i<=n;i++){
	cin>>x;
	if(x%2 && i%2){
		x1++;
	
	}
}
cout<<x1<<"\n";
return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[100010];
  rep(i,n) cin >> a[i];
  int tmp = a[0];
  int cnt = 1;
  bool b = false;
  if (a[0] == 2) cout << 1 << endl;
  else {
    rep(i,1e5 + 10) {
      if (a[tmp - 1] == 2) {
        cout << cnt + 1 << endl;
        b = true;
        break;
      }
      else {
        cnt++;
        tmp = a[tmp - 1];
      }
    }
    if (b == false) cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b;
	cin >> a >> b;
	if(a == b) cout << "Draw" << endl;
	else if(a == 1 || (b != 1 && a > b)) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define OUTPUT(a,b,s) cout << s << '\n'
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b)
        OUTPUT(a,b,"a < b");
    else if (a > b)
        OUTPUT(a,b,"a > b");
    else
        OUTPUT(a,b,"a == b");
}

Measured memory_bytes: 1124
N = int(input())
C = [0]*N
S = [0]*N
F = [0]*N

for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N-1):            #各駅について時間計算
    cnt = C[i]+S[i]
    for j in range(i+1, N-1):     #次の電車について計算
        if(S[j] <= cnt):
            if(cnt % F[j] == 0):
                cnt += C[j]
            else:
                cnt += C[j] + (F[j] - cnt%F[j])
        else:
            cnt = S[j]+C[j]
    print(cnt)
print(0)

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

int main() {
    int num;
    int n;
    std::vector<int> vec{};
    std::cin >> num;
    for(auto i=0; i<num; i++) {
        std::cin >> n;
        vec.push_back(n);
    }
    std::reverse(vec.begin(), vec.end());
    for(auto i=0; i<vec.size(); i++) {
        std::cout << vec[i] << ((i<(vec.size()-1)) ? " " : "");
    }
    std::cout << std::endl;
}



Measured memory_bytes: 3160
A, B = map(int, input().split())
max_N = max(A, B)
min_N = min(A, B)
if (max_N % 2 == 0 and min_N % 2 == 0) or (max_N % 2 == 1 and min_N % 2 == 1):
    print(max_N - ((max_N - min_N) // 2))
else:
    print("IMPOSSIBLE")

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B;
    string s;
    cin>>A>>B>>s;
    int a = 0, b = 0;
    bool ans = true;
    REP(i,s.size()) {
        if (i == A) {
            if (s[i] != '-') ans = false;
        }
        else {
            if (!isdigit(s[i])) ans = false;
        }
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,k; cin >> n >> k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n-k){
        if(a[i]<a[i+k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 4780
import java.util.Scanner

object Main {
  def calc(x: Int): Int = if (x == 1) (1) else (calc(x / 2) * 2)

  def solve(sc: => Scanner): Unit = {
    println(Array.fill[Int](3)(sc.nextInt).sum)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

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

long long int mod = 1000000007;

long long int f[1010100];
void init() {
  f[0] = 1;
  for(int i = 1; i < 1010100; i++) f[i] = (f[i - 1] * i) % mod;
}

long long int inv(long long int x) {
  long long int res = 1;
  long long int k = mod - 2;
  long long int y = x;
  while (k) {
    if (k & 1) res = (res * y) % mod;
    y = (y * y) % mod;
    k /= 2;
  }
  return res;
}

long long int C(int n, int k) {
  long long int a = f[n]; // = n!
  long long int b = f[n-k]; // = (n-k)!
  long long int c = f[k]; // = k!

  long long int bc = (b * c) % mod;

  return (a * inv(bc)) % mod;
}

void Main() {
  init();
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    if (n - k + 1 < i + 1 || k - 1 < i) cout << 0 << endl;
    else cout << (C(n - k + 1, i + 1) * C(k - 1, i)) % mod << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main(){

  int n,k,x,y,a;
  cin>>n>>k>>x>>y;
  a=0;
    if(n<=k){
      a=x*n;
    }else{
      a=x*k+y*(n-k);
	}
  cout<<a<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}


signed main()
{
    showoff;
    int n,ans = 0;
    cin >> n;
    vector<int>v(n+5);
    FOR(i,1,n+1){
        cin >> v[i];
    }
    FOR(i,1,n+1){
        FOR(j,i+1,n+1)ans += v[i]*v[j];
    }
    cout << ans;
    return 0;

}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ....s

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
using namespace std;
map<pii,int> m;
ll x[55],y[55];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n,u,v;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >>  x[i] >> y[i];
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ll tx = x[i] - x[j];
            ll ty = y[i] - y[j];
            if(tx < 0){
                tx = -tx;
                ty = -ty;
            }
            if(tx == 0 && ty<0){
                ty = -ty;
            }
            m[{tx,ty}]++;
        }

    }
    for(auto itr:m){
        ans = max(ans,itr.second);
    }
    m.clear();
    cout << n - ans;
    return 0;
}
;


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

class Main{
    public static void main(String[] args){
	BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	try{
	    while(true){
		int flag=0, max=0, maxsofar=0, n = Integer.valueOf(sc.readLine());
		if(n==0)
		    break;
		int[] x = new int[n];
		for(int i=0; i<n; i++){
		    x[i] = Integer.valueOf(sc.readLine());
		    if(x[i]>=0)
			flag=1;
		}
		if(flag==0){
		    Arrays.sort(x);
		    System.out.println(x[x.length-1]);
		}
		else{
		    for(int i=0; i<n; i++){
			maxsofar = Math.max(maxsofar+x[i], 0);
			max = Math.max(max, maxsofar);
		    }
		    System.out.println(max);
		}
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 10000
using System;

namespace AOJ.ALDS
{
    public class StableSort
    {
        private struct Card
        {
            public string Suit { get; set; }
            public int Number { get; set; }
        }

        private static void BubbleSort(Card[] array, int N)
        {
            for (int i = 0; i < N; i++)
            {
                bool end = true;
                for (int j = N - 1; j > i; j--)
                {
                    if (array[j].Number < array[j - 1].Number)
                    {
                        var tmp = array[j];
                        array[j] = array[j - 1];
                        array[j - 1] = tmp;
                        end = false;
                    }
                }
                if (end) { break; }
            }
        }

        private static void SelectionSort(Card[] array, int N)
        {
            for (int i = 0; i < N; i++)
            {
                int min_j = i;
                for (int j = i; j < N; j++)
                {
                    if (array[j].Number < array[min_j].Number) { min_j = j; }
                }

                if (i != min_j)
                {
                    var tmp = array[i];
                    array[i] = array[min_j];
                    array[min_j] = tmp;
                }
            }
        }

        public static void Main()
        {
            int counter = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Trim().Split(' ');
            var bubble = new Card[counter];
            var select = new Card[counter];
            for (int i = 0; i < counter; i++)
            {
                bubble[i].Suit = input[i].Substring(0, 1);
                bubble[i].Number = int.Parse(input[i].Substring(1, 1));
                select[i] = bubble[i];
            }

            BubbleSort(bubble, counter);
            SelectionSort(select, counter);

            bool is_stable = true;
            for (int i = 0; i < counter; i++)
            {
                if (bubble[i].Suit != select[i].Suit || bubble[i].Number != select[i].Number)
                {
                    is_stable = false;
                    break;
                }
            }

            string out_bubble = "";
            foreach (var c in bubble) { out_bubble += c.Suit + c.Number + " "; }
            out_bubble = out_bubble.Trim();

            string out_sel = "";
            foreach (var c in select) { out_sel += c.Suit + c.Number + " "; }
            out_sel = out_sel.Trim();

            Console.WriteLine(out_bubble);
            Console.WriteLine("Stable");
            Console.WriteLine(out_sel);
            Console.WriteLine(is_stable ? "Stable" : "Not stable");
        }
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int p=n%1000;
	p=1000-p;
	p%=1000;
	cout<<p<<endl;
	return 0;
}



Measured memory_bytes: 3688
#include<iostream>

using namespace std;

int main(){
  string S;

  cin >> S;

  int a[26];
  
  for(int i = 0 ; i < S.size() ; i++ )
    a[i] = 0;

  for(int i = 0 ; i < S.size() ; i++ ){
    a[int(S[i]) - 'a' ]++;
  }
    
  for(int i  = 0 ; i < S.size() ; i++){
    if(a[i] > 1 ){
      cout << "no" << endl;
      return 0;
    }
  }
  
  cout << "yes" << endl;

  return 0;
}

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    const int INF = 1e9;
    int n;
    cin>>n;
    int h[n];
    for (int i=0;i<n;++i) cin>>h[i];

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int num, stack[10], p = 0;

  while (scanf("%d", &num) != EOF) {
    if (num == 0) {
      printf("%d\n", stack[--p]);
    } else {
      stack[p++] = num;
    }
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 600
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    string s = input<string>();

    vector<vector<int>> next(26, vector<int>(SZ(s) + 1, SZ(s)));
    for (int let = 0; let != 26; ++let)
        for (int pos = SZ(s) - 1; pos >= 0; --pos)
            next[let][pos] = (s[pos] == 'a' + let ? pos : next[let][pos + 1]);

    vector<int> f(SZ(s) + 1, 0);
    for (int i = SZ(s) - 1; i >= 0; --i) {
        int go = -1;
        for (int j = 0; j != 26; ++j)
            go = max(go, next[j][i]);

        if (go < SZ(s))
            f[i] = 1 + f[go + 1];
    }
    
    int ans_l = f[0] + 1;
    cerr << ans_l << "\n";
    string ans = "";
    int cur_pos = 0;
    for (int i = 0; i != ans_l; ++i) {
        int let;
        for (let = 0; let != 26; ++let)
            if (next[let][cur_pos] == SZ(s) or f[next[let][cur_pos] + 1] < ans_l - i - 1) {
                ans.push_back('a' + let);
                cur_pos = min(SZ(s), next[let][cur_pos] + 1);
                break;
            }

        assert(let != 26);
    }

    cout << ans << "\n";
    
    return 0;
}


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

const int LIMIT = 55555;
int primes[5637], n;
bool isPrime[LIMIT+1];

int main() {
    for (int i = 0; i <= LIMIT; i++) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i <= sqrt(LIMIT); i++) {
        for (int j = i + i; j <= LIMIT; j += i) {
            isPrime[j] = false;
        }
    }
    int idx = 0, ans;
    for (int i = 0; i <= LIMIT; i++) {
        if(isPrime[i] && i % 10 == 1) {
            primes[idx] = i;
            idx++;
        }
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << primes[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256