akhauriyash/Code-Regression huggingface dataset:
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
//}}}


int solve(){
  int n,W;cin>>n>>W;

  int w[n], v[n];
  int cnt[4]={};
  vvi x(4);
  rep(i, n){
    cin>>w[i]>>v[i];
    cnt[w[i]-w[0]]++;
    x[w[i]-w[0]].pb(v[i]);
  }
  rep(i, 4){ sort(all(x[i]), greater<int>()); }
  rep(i, 4){
    rep(j, 1, sz(x[i])){
      x[i][j] += x[i][j-1];
    }
  }
  dump(x);
  dump_1d(w, n);

  int ans=0;
  rep(i, cnt[0]+1){
    rep(j, cnt[1]+1){
      rep(k, cnt[2]+1){
        rep(l, cnt[3]+1){
          dump(i,j,k,l);
          int res = 0;
          if (i*(w[0]) + j*(w[0]+1) + k*(w[0]+2) + l*(w[0]+3)<=W){
            if (i>0) res += x[0][i-1];
            if (j>0) res += x[1][j-1];
            if (k>0) res += x[2][k-1];
            if (l>0) res += x[3][l-1];
            chmax(ans,res);
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

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

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,k;
    cin>>n>>k;
    int x=n/k;
    n-=x*k;
    int a1=abs(n);
    int a2=abs(n-k);
    int a3=abs(n+k);
    cout<<min(a1,min(a2,a3));








	
return 0;
}


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

lint n, x;

lint burger_size(lint m) {
    return (1LL << (m + 2)) - 3;
}

lint all_paty(lint m) {
    return (1LL << (m + 1)) - 1;
}

// レベルmバーガーの下からy枚に何枚パティがあるか
lint dfs(lint m, lint y) {
    if (y == 0) {
        return 0;
    }
    if (y == burger_size(m)) {
        return all_paty(m);
    }
    lint res = 0;
    y--;
    res += dfs(m - 1, min(burger_size(m - 1), y));
    y -= min(burger_size(m - 1), y);
    if (y == 0) {
        return res;
    }
    y--, res++;
    res += dfs(m - 1, min(burger_size(m - 1), y));
    return res;
}

int main() {
    cin >> n >> x;
    cout << dfs(n, x) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
bool check(string s)
{
	//cout<<s<<endl;
	int sz=s.size();
	for(int i=0;i<=sz/2;i++)
		if(s[i]!=s[sz-i-1]) return 0;
	return 1;
}
int main()
{
	string s;
	cin>>s;
	bool flag=0;
	if(s.size()&1)
	{
		if(check(s)&&check(s.substr(0,(s.size()-1)/2))&&check(s.substr((s.size()+3)/2-1)))
			flag=1;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
struct coin1 {
	int a, b, c;
};
bool cmp1(const coin1 &x, const coin1 &y) {
	if (x.b-x.a !=y.b- y.a)return x.b-x.a < y.b-y.a;
	if (x.a != y.a)return x.a < y.a;
	if (x.b != y.b)return x.b < y.b;
	return x.c <= y.c;
}

int a[100006], b[100006], c[100006];
int sa[100006], sb[100006],sca[100006];
signed main() {
	int x, y, z; cin >> x >> y >> z;
	int n = x + y + z;
	vector<coin1>V;
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
		V.push_back({a[i],b[i],c[i]});
	}
	sort(V.begin(), V.end(),cmp1);
	rep(i, n) {
		sa[i] = V[i].a;
		sb[i] = V[i].b;
	}
	rep(i, n-1)sa[i + 1] += sa[i];

	for (int i = n - 1; i > 0; i--)sb[i - 1] += sb[i];
	priority_queue<int>Q1, Q2;
	int sum = 0;
	rep(i, x)Q1.push(V[i].c - V[i].a);
	for (int i = x; i < x + z; i++) {
		int now = V[i].c - V[i].a;
		if (Q1.top() < now) {
			Q2.push(now);
			sum += now;
		}
		else {
			Q1.push(now);
			sum += Q1.top();
			Q2.push(Q1.top());
			Q1.pop();
		}
		sa[i] += sum;
	}
	while (Q1.size())Q1.pop();
	while (Q2.size())Q2.pop();

	sum = 0;
	for (int i = n - 1; i >= x+z; i--)Q1.push(V[i].c - V[i].b);
	for (int i = x + z - 1; i >= x; i--) {
		int now = V[i].c - V[i].b;
		if (Q1.top() < now) {
			Q2.push(now);
			sum += now;
		}
		else {
			Q1.push(now);
			sum += Q1.top();
			Q2.push(Q1.top());
			Q1.pop();
		}
		sb[i] += sum;
	}

	int ans = 0;
	for (int i = x-1; i < x + z; i++) {
		ans = max(ans, sa[i] + sb[i + 1]);
	}
	cout << ans << endl;
}


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

class Main {

	void solve() {
		
		int n = inint(), m = inint();
		Answer[] answers = new Answer[m];
		for (int i=0; i<m; i++) {
			answers[i] = new Answer(inint(), instr());
		}
		
		boolean[] isAC = new boolean[n];
		int[] WAnum = new int[n];
		int ACcount = 0;
		int WAcount = 0;
		
		for (int i=m-1; i>=0; i--) {
			
			if (isAC[answers[i].number - 1] == false) {
				if (answers[i].result.equals("AC")) {
					isAC[answers[i].number - 1] = true;
					ACcount++;
					
					
				}
			}
			else {
				if (answers[i].result.equals("WA")) {
					WAnum[answers[i].number - 1]++;
				}
				else {
					WAnum[answers[i].number - 1] = 0;
				}
			}
			
		}
		
		for (int i=0; i<n; i++) {
			WAcount += WAnum[i];
		}
		
		
		out.println(ACcount + " " + WAcount);
		
	}
	
	public double calc(int[] a, int b) {
		double d = 0;
		for (int i=0; i<a.length; i++) d += a[i];
		d += b;
		return d / (double)(a.length + 1);
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

class Answer {
	public Answer(int number, String result) {
		this.number = number;
		this.result = result;
	}
	int number;
	String result;
}

Measured memory_bytes: 72056
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int total = 0;
    for (int i = 0; i < N; i++) {
        int day = 1;
        int cnt = 0;
        while (day <= D) {
            day += A[i];
            cnt += 1;
        }
        total += cnt;
    }
    cout << total + X << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int st = 60 * h1 + m1;
	int ed = 60 * h2 + m2;
	cout << (ed - st - k) << endl;
	return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int check_k(string &s1, string &s2, int i, int j) {
    if (i == 0 && j == 0) return 3;
    if (i == 0) {
        if (s1[0] == s2[0]) return 1;
        else return 2;
    }
    if (j == 0) {
        if (s1[i] == s1[i - 1]) return 1;
        else if (s1[i - 1] == s2[i - 1]) return 2;
        else {
            if (s1[i] == s2[i]) return 1;
            else return 3;
        }
    }
    return 1;
}

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

    string s1, s2;
    cin >> s1 >> s2;


    mint ans = 1;
    rep(i, n) {
        rep(j, 2) {
            int k = check_k(s1, s2, i, j);
            ans *= k;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
unittest
{
	assert( [ "1 2", "10 10", "12 4" ].parse.expand.solve == "1" );
	assert( [ "100 1", "101 101", "102 1" ].parse.expand.solve == "infinity" );
	assert( [ "12000 15700", "3390000000 3810000000", "5550000000 2130000000" ].parse.expand.solve == "113" );
	
	assert( [ "100000 100000", "5000000000 5000000000", "6000000000 3999999999" ].parse.expand.solve == "2000000000" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ts = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( ts, as, bs );
}

auto solve( long[] ts, long[] as, long[] bs )
{
	// 初速が早いほうをAにする
	if( as[ 0 ] < bs[ 0 ] )
	{
		auto cs = as;
		as = bs;
		bs = cs;
	}
	
	// 1セットの走行距離を計算
	auto xs = zip( ts, as ).map!( ( z ) => z[ 0 ] * z[ 1 ] ).array;
	auto ys = zip( ts, bs ).map!( ( z ) => z[ 0 ] * z[ 1 ] ).array;
	auto xt = xs.sum;
	auto yt = ys.sum;
	
	// 1セットの走行距離が同じなら、離す→追いつかれる→離す、をずっと繰り返す
	if( xt == yt ) return "infinity";
	
	// Aが1セットの走行距離も長いなら、ずっと前を走る
	if( yt <  xt ) return "0";
	
	// Aが1セットの走行距離が短いなら、離す→追い抜かれる→追い抜く、を繰り返して最後は追い抜かれたままになる
	auto ds = zip( xs, ys ).map!( ( z ) => z[ 0 ] - z[ 1 ] ).array;
	auto dt = ds.sum;
	auto ans = 2 * ( ds[ 0 ] / -dt ) + ( ds[ 0 ] % -dt != 0 );
	return ans.to!( string );
}


Measured memory_bytes: 256
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf
}

fn gcd(a: usize, b: usize) -> usize {
    let mut m = a;
    let mut n = b;
    while m != 0 {
        if n > m {
            std::mem::swap(&mut n, &mut m);
        }
        m %= n;
    }
    n
}

fn main() {
    let _ = read();
    let a: Vec<usize> = read()
        .trim()
        .split(' ')
        .map(|x| x.parse().unwrap())
        .collect();

    let mut ans = a[0];
    for hp in a {
        ans = gcd(ans, hp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import Control.Applicative
import Control.Monad
import Data.IORef
import qualified Data.Vector as V
import System.IO

main :: IO ()
main = do
    n <- readLn
    table <- V.fromList <$> replicateM n (newIORef "Unknown")
    print 0
    hFlush stdout
    head <- getLine
    print (n-1)
    hFlush stdout
    end <- getLine
    writeIORef (table V.! 0) head
    writeIORef (table V.! (n-1)) end
    res <- loop table 0 (n - 1)
    return ()

loop :: V.Vector (IORef String) -> Int -> Int -> IO Int
loop table a b = do
    let mid = if even (a + b) then (a+b) `div` 2 else (a+b-1) `div` 2
    print mid
    hFlush stdout
    seat <- getLine
    writeIORef (table V.! mid) seat
    case seat of
        "Vacant" -> return mid
        _ -> do
            frontValid <- isValid table a mid
            rearValid <- isValid table mid b
            if not frontValid then
                loop table a mid
            else if not rearValid then
                loop table mid b
            else returnVacant table a b

returnVacant :: V.Vector (IORef String) -> Int -> Int -> IO Int
returnVacant table p q = do
    pContent <- readIORef (table V.! p)
    qContent <- readIORef (table V.! q)
    if pContent == "Vacant" then
        return p
    else if qContent == "Vacant" then
        return q
    else do
        print "ERROR"
        return 12345

-- Is range valid
isValid :: V.Vector (IORef String) -> Int -> Int -> IO Bool
isValid table p q = do
    pContent <- readIORef (table V.! p)
    qContent <- readIORef (table V.! q)
    let diff = q - p
    if pContent == "Vacant" || qContent == "Vacant" then
        return False
    else if even diff && pContent == qContent then
        return True
    else if odd diff && pContent /= qContent then
        return True
    else
        return False
    


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

int main(){
    int n;
    cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else if(n >= 1200 && n < 2800) cout << "ARC" << endl;
    else if(n >= 2800) cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());

		int[] players = new int[n];

		Arrays.fill(players, k);

		for (int i = 0; i < q; i++) {
			int ans = Integer.parseInt(sc.next());
			players[ans - 1] += 1;
		}

		for (int i = 0; i < n; i++) {
			if (players[i] <= q) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}

	}
}

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

using namespace std;

int main()
{
  	string s;
	cin >> s;
  	map<char, int> m;
  	for(int i = 0; i < 4; i++){
    	m[s[i]]++;
    }
  	bool check = true;
  	for(int i = 0; i < 4; i++){
    	if(m[s[i]] != 2) check = false;
    }
	if(check) cout << "Yes" << endl;
  	else cout << "No" << endl;




}

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

int main() {
  long long h;long long n;long long a; long long i; long long sum=0;
  cin>>h;
  cin>>n;
  for(i=0;i<n;i++)
  {
      cin>>a;
      sum=sum+a;
  }
  if(sum>=h)
  {
      cout<<"Yes"<<endl;
  }
  else
  {
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  string S;
  cin >> S;
  ll K;
  cin >> K;

  if (K == 1) {
    COUT(S[0]);
    return 0;
  }

  ll count = 0;
  rep(i, S.size()) {
    if (count == K) {
      COUT(1);
      return 0;
    }

    if (S[i] == '1') {
      count++;
      continue;
    }
    COUT(S[i]);
    return 0;
  }

  COUT(1);
  return 0;
}

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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans=0;
	string s;
	cin >>n;
	cout << n/3 <<"\n";
	return 0;
	
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;
    map<ll, ll> p;
    REP(i, n) {
        ll a, b;
        cin >> a >> b;
        p[b] = a;
    }

    auto itr = p.begin();
    ll ans = itr->first + itr->second;
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    vector<size_t> A;

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

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

    size_t total = 0;    
    if(N % 2 == 1)
    {
        for(int i = (N - 1)/2; i < N; ++i)
        {
            total += 2 * A[i];
        }
        total -= (A[N-1] + A[(N-1)/2]);
    }
    else
    {
        for(int i = N/2; i < N; ++i)
        {
            total += 2 * A[i];
        }
        total -= A[N-1];
    }


    cout << total << endl;

    return 0;    
}

Measured memory_bytes: 4820
n, m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().split(' ')
    a = int(a)
    b = int(b)
    M = 0
    for j in input().split(' '):
        M += 2**(int(j)-1)

    for j in range(2**n):
        # dp[j|M] = min(dp[j]+a, dp[j|M])
        dp[j|M] = dp[j] + a if dp[j] + a < dp[j|M] else dp[j|M]

    # for j in range(2**n):
    #     if dp[j|M] > dp[j] + a:
    #         dp[j|M] = dp[j] + a

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

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

typedef long long ll;

int n,k;
int w[1000000];

int main(){
   int a,b;
   cin >> a>>b;
   if(a<10&&b<10) cout << a*b <<endl;
   else cout << -1 << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
 
int main()
{
  int N;
  std::cin >> N;
  std::vector<long long> a(3 * N);
  for (int i = 0; i < 3 * N; i++)
    std::cin >> a[i];
  std::sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = N; i < 3 * N; i += 2)
    ans += a[i];
  std::cout << ans << std::endl;
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  string s(b, '0'+a);
  string t(a, '0'+b);
  if (a > b) cout << t << endl;
  else cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    if a==b {
	println!("Draw");
    }else if a == 1{
	println!("Alice");
    }else if a < b || b == 1{
	println!("Bob");
    }else {
	println!("Alice");
    }
}


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

const int MOD = 1e9+7;

int a[2010];

int main() {
	int n, k;
	long long ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (a[i] > a[j])
				ans = (ans+((i>j)?((k-1ll)*k/2):((k+1ll)*k/2)))%MOD;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#define chmax(x,y) x=max(x,y)

int a[3005][3005];
ll dp[3005][3005][4];
int main() {
	int R, C, n;
	cin >> R >> C >> n;
	rep(i, n) {
		int r, c, v;
		cin >> r >> c >> v;
		a[r - 1][c - 1] = v;
	}
	rep(i, R)rep(j, C) {
		for (int k = 2; k >= 0; --k) {
			chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
		}
		rep(k, 4) {
			chmax(dp[i + 1][j][0], dp[i][j][k]);
			chmax(dp[i][j + 1][k], dp[i][j][k]);
		}
	}
	ll ans = 0;
	rep(k, 4)chmax(ans, dp[R - 1][C - 1][k]);
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 320596
f=lambda:map(int,input().split())
def r(x):
  while p[x]>=0: x=p[x]
  return x
def u(x,y):
  x,y=r(x),r(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]; p[y]=x
n,m,k=f()
l,p=[0]*-~n,[-1]*-~n
for _ in range(m):
  a,b=f()
  u(a,b); l[a]-=1; l[b]-=1
for _ in range(k):
  c,d=f()
  if r(c)==r(d): l[c]-=1; l[d]-=1
for i in range(n+1): l[i]-=p[r(i)]+1
print(*l[1:])

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> jobs(m+1);
    int a, b;
    rep(i,n) {
        cin >> a >> b;
        if (a>m) continue;
        jobs[m-a].push_back(b);
    }
    ll ans = 0;
    priority_queue<int> q;
    for (int i=m-1;i>=0;i--) {
        for (auto &&job : jobs[i]) {
            q.push(job);
        }
        if (!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

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

int brute(string s) {
    while (s.size() > 1) {
        string t;
        for (int i=1; i<s.size(); i++)
            t += abs(s[i] - s[i-1]) + '0';
        s = t;
        cout<<s<<endl;
    }
    return s[0] - '0';
}

int solve(string s) {
    int n = s.size() - 1;
    bool anyone = false;
    bool ans1 = 0, ans2 = 0;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == '1')    anyone = true;
        if ( (n & i) != i)  continue;
        if (s[i] == '1')    ans1 ^= 1;
        if (s[i] == '2')    ans2^=1;
    }

    if (anyone) return ans1;
    else        return 2*ans2;
}

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    for (char &c: s)    c--;

//    int x = brute(s);
    cout<<solve(s)<<endl;
//    assert(solve(s) == x);
//    main();
}

/*
a       b       c       d
a+b     b+c     c+d
a+2b+c  b+2c+d
a+3b+3c+d
*/


Measured memory_bytes: 2332
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s: Vec<_> = s.trim().chars().collect();
	s.sort();
	if s[0] == s[1] && s[2] == s[3] && s[0] != s[2] {
		println!("Yes");
	} else {
		println!("No");
	}
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
  long a,b,tmp,gdc,lcm,alpha;
  long k,l;
  while(scanf("%ld %ld",&a,&b)!=EOF){
    if(a>b){ //?????¶??????a<=b?????¶????????????
      tmp=a;
      a=b;
      b=tmp;
    }
    for(k=1;k<=b;k++){
      if(b%k==0){
        l=b/k;
        if(a%l==0){
          gdc=l;
          break;
        }
      }
    }
    alpha = a/gdc;
    lcm = alpha * b;
    printf("%ld %ld\n",gdc,lcm);
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
int h[maxn],son[maxn];
int n,m,a,b,ans;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=m;i++)
	{
		cin>>a>>b;
		son[a]=max(son[a],h[b]);
		son[b]=max(h[a],son[b]);	
	}
	for(int i=1;i<=n;i++)
	{
		if(h[i]>son[i])
			ans++;
	}
	cout<<ans;
return 0;
}


Measured memory_bytes: 4376
#[allow(unused_imports)]
use std::io::{self, BufRead};
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(dead_code)]
fn readln_to_vec<T>(buf: &mut BufRead) -> Vec<T> 
where T: std::str::FromStr,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    let mut s = String::new();
    buf.read_line(&mut s).unwrap();
    s.split(" ")
        .map(|x| x.trim())
        .filter(|x| !x.is_empty())
        .filter_map(|x| x.parse().ok())
        .collect()
}

#[allow(dead_code)]
fn readln_to<T>(buf: &mut BufRead) -> T
where T: std::str::FromStr + std::clone::Clone,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    readln_to_vec::<T>(buf)[0].clone()
}

#[allow(unused_macros)]
macro_rules! readln_to_tuple {
    (
        $bufRead: expr, ( $( $t: ty ),* )
    ) => (
        {
            let buf: &mut BufRead = $bufRead;
            let ln = readln_to_vec::<String>(buf);
            let mut i = ln.into_iter();
            ( $( i.next().unwrap().parse::<$t>().unwrap() ),* )
        }
        )
}


fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    let stdin = &mut stdin;

    let (n, h) = readln_to_tuple!(stdin, (i64, i64));
    let mut a = Vec::new();
    let mut b = Vec::new();
    for _ in 0..n {
        let (ai, bi) = readln_to_tuple!(stdin, (i64, i64));
        a.push(ai);
        b.push(bi);
    }
    let a_max = a.into_iter().max().unwrap();
    b.sort();
    let mut ans: i64 = 0;
    let mut sum: i64 = 0;
    let mut iter = b.into_iter().rev().take_while(|&x| x > a_max);
    while sum < h {
        if let Some(bi) = iter.next() {
            sum += bi;
            ans += 1;
        } else {
            let a_count = (h - sum + a_max - 1) / a_max;
            ans += a_count;
            sum += a_max * a_count;
        }
    }
    println!("{}", ans);
}



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

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            for(int i = 0; i < s.Length; i++)
            {
                int tmp = s[i] + n;
                if (90 < tmp)
                {
                    tmp -= 26;
                }
                Console.Write((char)tmp);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13212
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int m,n;
struct Ask{
	int l,r;
}A[N];
int cmp(Ask x,Ask y){
	return x.r-x.l<y.r-y.l;
}
struct Tree{
	int l,r,num,flag;
}T[N*4];
void build(int x,int l,int r){
	T[x].l=l;T[x].r=r;
	if (l==r)return;
	int mid=(l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
}
void down(int x){
	T[x*2].num+=T[x].flag;
	T[x*2+1].num+=T[x].flag;
	T[x*2].flag+=T[x].flag;
	T[x*2+1].flag+=T[x].flag;
	T[x].flag=0;
}
void insert(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return;
	if (T[x].l>=l&&T[x].r<=r){
		T[x].num++;
		T[x].flag++;
		return;
	}
	down(x);
	insert(x*2,l,r);
	insert(x*2+1,l,r);
}
int find(int x,int y){
	if (T[x].l==T[x].r)return T[x].num;
	down(x);
	int mid=(T[x].l+T[x].r)/2;
	if (y<=mid)return find(x*2,y);
	else return find(x*2+1,y);
}
int main(){
	scanf("%d%d",&m,&n);
	for (int i=1;i<=m;i++)scanf("%d%d",&A[i].l,&A[i].r);
	sort(A+1,A+m+1,cmp);
	build(1,1,n);
	for (int i=1,j=1;i<=n;i++){
		while (j<=m&&A[j].r-A[j].l+1<i){
			insert(1,A[j].l,A[j].r);
			j++;
		}
		int ans=m-j+1;
		for (int k=i;k<=n;k+=i)ans+=find(1,k);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 9728
import java.util.*;
public class Main {

    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] p = new int[N];
        UnionFind tree = new UnionFind(N);
        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt()-1;
        }
        for (int i = 0; i < M; i++) {
            int x = scanner.nextInt()-1;
            int y = scanner.nextInt()-1;
            tree.union(x,y);
        }
        int count = 0;
        for (int i = 0; i < N; i++) {
            if(tree.find(i) == tree.find(p[i])){
                count ++;
            }
        }
        System.out.println(count);
    }

    public static class UnionFind{
        private int[] d;
        public UnionFind(int num){
            d = new int[num];
            for(int i=0; i<num; i++){
                d[i] = -1;
            }
        }
        public void union(int a, int b){
            a = find(a);
            b = find(b);
            if(a == b){
                return;
            }
            if(-d[a] < -d[b]){
                int tmp = a;
                a = b;
                b = tmp;
            }
            d[a] += d[b];
            d[b] = a;
        }
        public int find(int a){
            if(d[a] < 0){
                return a;
            }else{
                d[a] = find(d[a]);
                return d[a];
            }
        }
        public int size(int a){
            return -d[find(a)];
        }
    }

}

Measured memory_bytes: 89856
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;

const int N = 110000;

int n, m;
vector < int > g[N], gg[N];
int nn, mas[N];
int pas[N];

bool F[N];
int par[N];

void dfs (int k){
    F[k] = 1;
    for (int to : g[k])
        if (F[to] == 0)
            dfs (to);
    pas[k] = nn;
    mas[nn--] = k;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i < n + m; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb (v);
        gg[v].pb (u);
    }
    nn = n;
    for (int i = 1; i <= n; i++)
        if ((int)gg[i].size() == 0)
            dfs (i);
    for (int i = 2; i <= n; i++){
        int t = 1;
        for (int u : gg[mas[i]])
            t = max (t, pas[u]);
        par[mas[i]] = mas[t];
    }
    for (int i = 1; i <= n; i++)
        cout << par[i] << endl;
    return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll r,g,b,n;
  cin>>r>>g>>b>>n;
  vi a,p;
  rep(i,3001)rep(j,3001){
    a.eb(r*i+g*j);
  }
  rep(i,3001){
    p.eb(n-b*i);
  }
  sort(all(a));
  ll ans=0;
  rep(i,3001){
    ans+=ub(a,p[i])-lb(a,p[i]);
  }
  out(ans);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 133468
import math
def isPrime(a):
    mx = math.sqrt(a)
    tmp = 2
    while tmp <= mx:
        if a % tmp == 0:
            return False
        tmp += 1
    return True

x = int(input())
tmp = 0
while True:
    if isPrime(x + tmp):
        f = 1
        print(x+tmp)
        break
    tmp += 1


Measured memory_bytes: 62032
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 1;
const int inf = 1e9 + 7;
signed main () {
    double n;
    cin >> n;
    double ans = ceil(n / 2) / n;
    cout << ans << endl;        

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
using namespace std;
typedef long long ll;
ll const MAX = 1e6 + 5;
vll v(MAX);
vll pen(MAX);

ll const MOD = 998244353;
ll mod_p(ll x, ll y) {
       x %= MOD;
       y %= MOD;
       return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
       x %= MOD;
       y %= MOD;
       return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
       x %= MOD;
       if (t == 0) {
               return 1;
       }
       else {
               ll v = mod_pow(x, t / 2);
               if (t % 2 == 0) {
                       return v * v % MOD;
               }
               else {
                       return v * v%MOD * x %MOD;
               }
       }
}

ll mod_inv(ll x) {
       return mod_pow(x, MOD - 2);
}

int main(){
    ll n;
    cin >> n;
    REP(i,1,n){
        ll x;
        cin >> x;
        v[x]++;
    }
    ll ans = 0;
    REP(i,1,MAX){
        pen[i] = mod_inv(i);
    }
    REP(i,1,MAX){
        ll sum = 0;
        for(ll j = 2 * i;j <= MAX; j += i){
            pen[j] = mod_p(pen[j], -pen[i]);
        }
        for(ll j = i; j<= MAX; j+=i){
            REP(k,1,v[j]){ 
                ans = mod_p(ans, mod_m(mod_m(sum, j), pen[i]));
                sum = mod_p(sum, j);               
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 15872
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    vector<int> a;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    //sort(a.begin(), a.end());
    //reverse(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += a[i];
    }
    sort(a.begin(), a.end());
    if (sum % 10 != 0)
    {
        cout << sum << endl;
    }
    else
    {
        for (int i = 0; i < N; i++)
        {
            if ((sum - a[i]) % 10 != 0)
            {
                cout << sum - a[i] << endl;
                return 0;
            }
        }
    }
    if (sum % 10 == 0)
    {
        sum = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	ll sum = 0;
	ll a, b, c; cin >> a >> b >> c;
	ll k; cin >> k;
	if (k % 2 == 0) {
		cout << a - b << endl;
	}
	else {
		cout << b - a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int r;

int main(){
    cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,a[300000],b[300000];
ll sa[300000],sb[300000],temp[300000],temp2[300000],si[300000];

ll bit[300002],bit2[300002];

void add(ll *v,ll i,ll j){
	while(i<=N){
		v[i]+=j;
		i+=i&-i;
	}
}

ll sum(ll *v,ll i){
	ll res=0;
	while(i>0){
		res+=v[i];
		i-=i&-i;
	}
	return res;
}

ll l_b(ll s){
	ll lb=1,ub=N+2;
	while(lb+1<ub){
		ll mid=(lb+ub)/2;
		if(sum(bit,mid)>sum(bit2,mid)*s) ub=mid;
		else lb=mid;
	}
	return lb==1?0:sum(bit2,lb);
}

int main(){
	scanf("%lld",&N);
	for(ll i=0;i<N;i++) scanf("%lld%lld",&a[i],&b[i]);
	P x[300000];
	for(ll i=0;i<N;i++) x[i]=P(b[i],a[i]);
	sort(x,x+N,greater<P>());
	for(ll i=0;i<N;i++) temp[i]=sa[i]=x[i].second,sb[i]=x[i].first;
	sort(temp,temp+N);
	for(ll i=0;i<N;i++){
		ll w=lower_bound(temp,temp+N,sa[i])-temp;
		while(temp2[w]) w++;
		temp2[w]=1;
		si[i]=w+1;
	}
	ll k=0;
	for(ll i=0;i<N;i++){
		add(bit,si[i],sa[i]);
		add(bit2,si[i],1);
		k=max(k,l_b(sb[i]));
	}
	printf("%lld\n",k);
}

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

int main(int argc, char **argv)
{
	int MAX = 1000010;
	vector<ll> v(MAX);
	for (int i = 1; i < MAX; ++i)
	{
		if (i % 3 == 0 || i % 5 == 0)
			v[i] = 0;
		else
			v[i] = i;
	}
	for (int i = 2; i < MAX; ++i)
	{
		v[i+1] += v[i];
	}
	int n; cin >> n;
	if (n == 1)
	{
		std::cout << 1 << std::endl;
		return 0;
	}
	std::cout << v[n]+1 << std::endl;
}


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

int main()
{
  string a;
  cin >> a;
  for(int i = 0;i < 3;i++){
    if(a[i] == '1') a[i] = '9';
    else a[i] = '1';
  }
  for(int i = 0;i < 3;i++) cout << a[i];


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define lim 100005
#define INF 1e13
int main()
 {
  
  ll a,b;
  cin>>a>>b;
  a=a+b+1;
  cout<<a/2<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	double r;
	cin >> r;
	cout << 2.0 * r * 3.1415926535 << endl;

	return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
   cin>>a[i];
  }
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<k;i++)
  {
   ans+=a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>

int main() {
    while(true) {
        int m,f,r;
        std::cin >> m >> f >> r;
        if((m == -1) && (f == -1) && (r == -1)) break;
        int score = m + f;
        char result = ((m == -1) || (f == -1)) ? 'F' :
                      (score >= 80) ? 'A' :
                      (score >= 65) ? 'B' :
                      (score >= 50) ? 'C' :
                      (score >= 30) ? ((r >= 50) ? 'C' : 'D') : 'F';
        std::cout << result << std::endl;
    }
}



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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long a, b;
  cin >> n >> a >> b;
  if (n == 1) {
    if (a == b) {
      cout << 1 << '\n';
    } else {
      cout << 0 << '\n';
    }
  } else {
    long long MIN = a + b + a * (n - 2);
    long long MAX = a + b + b * (n - 2);
    if (MAX >= MIN) {
      cout << MAX - MIN + 1 << '\n';
    } else {
      cout << 0 << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3616
from operator import itemgetter
N, K = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(N)]
td.sort(key=itemgetter(1, 0), reverse=True)
t, d = zip(*td)

s = set()
q = []
tmp = 0
now = 0
for i in range(K):
    if t[i] not in s:
        s.add(t[i])
    else:
        q.append(d[i])

    tmp += d[i]
    now += 1
kind = len(s)
sums = [-100000000000]*(kind+1)
sums[kind] = tmp
for i in range(K, N):
    if not q:
        break
    if t[i] not in s:
        s.add(t[i])
        tmp = q.pop()
        kind += 1
        sums.append(sums[kind-1] + d[i] - tmp)
#while q:
#    kind += 1
#    tmp = q.pop()
#    for i in range(now, N):
#        now += 1
#        if t[i] not in s:
#            s.add(t[i])
#            sums.append(sums[kind-1] + d[i] - tmp)
#            break
for i in range(len(sums)):
    sums[i] += i**2
print(max(sums))



Measured memory_bytes: 81496
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;	cin>>n>>k;
	int a[k+1],i,j;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	int ans[k+1];
	ans[0]=0;
	for(i=1;i<=k;i++){
		ans[i]=0;
		for(j=0;j<n;j++){
			if(a[j]<=i && !ans[i-a[j]])	ans[i]=1;
		}
		// cout<<ans[i]<<endl;
	}
	if(ans[k])	cout<<"First";
	else	cout<<"Second";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 640
A = []
B = []
C = []
n, m, l = map(int, input().strip().split())
[A.append(list(map(int, input().strip().split()))) for x in range(n)]
[B.append(list(map(int, input().strip().split()))) for y in range(m)]
[C.append([0 for zz in range(l)]) for z in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]
        if j == l - 1:
            print(C[i][j])
        else:
            print(C[i][j],end=' ')

Measured memory_bytes: 9044