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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout << d << endl;
#define coutd(d) cout << std::setprecision(10) << d << endl;
#define cinline(n) getline(cin, n);
#define replace_all(s, b, a) replace(s.begin(), s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

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

inline bool inside(int y, int x, int H, int W)
{
  return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[101][200005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,w; cin>>n>>w;
  vector<ll> W(n), V(n);
  rep(i,n) cin>>W[i]>>V[i];
  
  rep(i,n){
    for(int j=0; j<=w; j++){
      dp[i+1][j+W[i]]=max(dp[i][j+W[i]], dp[i][j]+V[i]);
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 156416
def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,k=getints()

x = n // k

if k % 2 == 1:
    print(x**3)
else:
    y = (n + k - k // 2) // k
    res = x**3 + y**3
    print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(3e5) +5;

int dp[1001][10001]={0};


int main()
{
    idfc;
    int h,n;
    cin>>h>>n;
    int i;int j;
    int a,b;
    for(i=1;i<=h;i++)dp[0][i]=modo;
    int t;
    //for(i=1;i<=n;i++)cout<<dp[i][0]<<endl;
    for(i=1;i<=n;i++)
    {
        cin>>a>>b;
        for(j=1;j<=h;j++)
        {
            t=max(0,j-a);
            dp[i][j]=min(dp[i-1][j],dp[i][t]+b);
            //cout<<dp[i][j]<<" ";
        }
        //if(i==1)cout<<dp[i][540]<<endl;
        //cout<<dp[i][h]<<endl;
    }
    cout<<dp[n][h];
    
    
    
    return 0;
}

Measured memory_bytes: 39424
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
//typedef pair<ll, ll> P;
const ll INF=1LL<<60;

int main(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll kotae1=a[n-1];
  ll sa=0;
  int sa_i=0;
  rep(i,n-1){
    if(sa < min( abs(a[i]-kotae1),a[i])){
        sa=min( abs(a[i]-kotae1),a[i]);
        sa_i=i;
    }
    if(abs(a[i]-kotae1)< abs(a[i+1]-kotae1))break;
  }
  cout<<kotae1<<" "<<a[sa_i]<<endl;
  return 0;
}

Measured memory_bytes: 4048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
    int n;
    cin >> n;
    vector<int> rate(n),color = {0,0,0,0,0,0,0,0};
    rep(i,n) cin >> rate[i];
    sort(all(rate));
    int count = 0,free = 0;
    rep(i,n){
        if(rate[i] < 400) color[0]++;
        else if(rate[i] < 800) color[1]++;
        else if(rate[i] < 1200) color[2]++;
        else if(rate[i] < 1600) color[3]++;
        else if(rate[i] < 2000) color[4]++;
        else if(rate[i] < 2400) color[5]++;
        else if(rate[i] < 2800) color[6]++;
        else if(rate[i] < 3200) color[7]++;
        else free++;
    }
    rep(i,8){
        if(color[i] != 0) count++;
    }
    if(count != 0) cout << count << " " << count+free << endl;
    else cout << 1 << " " << min(8,free) << endl;
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int sum, max = 0;
	sum += A;
	if (max < A) max = A;
	sum += B;
	if (max < B) max = B;
	sum += C;
	if (max < C) max = C;
	// ここまででsumはA+B+C
	// maxはAからCのうち最大値
	
	// 操作によって常にsumが2増える
	// また、最低でも全数値をmaxへ
	// なら全てをmaxにできるか考える
	if ((3 * max - sum) % 2 == 0)
		cout << (3 * max - sum) / 2;
	else cout << (3 * max + 3 - sum) / 2;
	return 0;
}

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

pub 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")
}

use std::cmp::min;

fn main() {
    let n = read::<usize>();    
    let m = read::<usize>();    

    let mut key = vec![(0, 0); m];
    for i in 0..m {
        let a = read::<usize>();
        let b = read::<usize>();

        let mut s = 0;
        for j in 0..b {
            let c = read::<usize>() - 1;
            s |= 1<<c;
        }
        key[i] = (s, a);
    }

    let mut dp = vec![100_000_000_000; 1<<n];
    dp[0] = 0;
    for i in 0..1<<n {
        for j in 0..m {
            let t = i | key[j].0;
            let cost = dp[i] + key[j].1;
            dp[t] = min(dp[t], cost);
        }
    }
    let ans = dp[(1<<n) - 1];
    if ans == 100_000_000_000 {
        println!("-1")
    } else {
        println!("{}", dp[(1<<n) - 1]);
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
vector<vector<int>> v(9,vector<int>(9,-1));//-1は辺がない
int n;
queue<P> que;
int ans = 0;
void search(){
	while(que.size()!= 0){
		ll x = que.front().fs;
		ll used = que.front().sc;
		que.pop();
		used |= (1 << (x -1));
		for(int i = 1; i <= n; i++) {
			if (v[x][i] == 1 && !(1 & used >> (i- 1))){
				que.push(mp(i,used));
			}
		}
		if (used == (1<< n) - 1){
			ans += 1;
		}
	}
}
int main(){
	int m,a,b;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a][b] = 1;
		v[b][a] = 1;
	}
	que.push(mp(1,0));
	search();
	cout << ans <<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef pair<ll , ll> Pair ;
const int N = 2e5 + 10 ;
Pair a[N] ;
#define f first
#define s second
ll c[N] , dp[44] ;
bool cmp(Pair a , Pair b)
{
  return a.f * (b.s + 1) >  b.f * (a.s + 1) ;
}
int main()
{
  ll n , t ;
  scanf("%lld%lld" , &n , &t) ;
  int cnt1 = 0 , cnt2 = 0 ;
  for(int i =1 ; i <= n ;i ++)
   {
     ll x , y ;
     scanf("%lld%lld" , &x , &y) ;
     if(x == 0) c[++ cnt1] = y + 1 ;
     else a[++ cnt2] = {x , y} ;
   }
   sort(a + 1 , a + cnt2 + 1 , cmp) ;
   sort(c + 1 , c + cnt1 + 1) ;
   for(int i = 0 ;i <= 30 ;i ++) dp[i] = t + 1 ;
   dp[0] = 0 ;
   for(int i = 1; i <= cnt2 ;i ++)
    for(int j = 30 ;j > 0 ;j --)
     dp[j] = min(dp[j] , (dp[j - 1] + 1) * (a[i].f + 1) + a[i].s) ;
  int ans = 0;
  for(int i = 1; i <= cnt1 ; i ++) c[i] += c[i - 1] ;
  for(int i = 0 ;i <= 30 ;i ++)
   {
     if(dp[i] > t) continue ;
     int j = 0 ;
     if(cnt1)
      j = upper_bound(c + 1 , c + cnt1 + 1 , t - dp[i]) - c - 1 ;
    ans= max(ans , j + i) ;

   }
   cout << ans << endl ;
  return 0 ;
}


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

using namespace std;

int main(){
    bool a=0,b=0,c=0;
    string s;
    cin>>s;
    for( int i=0;i<=2;i++){
        if(s[i]=='a')a=1;
        if(s[i]=='b')b=1;
        if(s[i]=='c')c=1;

    }
    if(a&&b&&c){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}


Measured memory_bytes: 3628
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = input()
m = len(n)
K = I()

dp1 = [[0]*4 for _ in range(m+1)] #等しい
dp2 = [[0]*4 for _ in range(m+1)] #未満
dp1[0][0] = 1
for i in range(m):
    x = int(n[i])
    for j in range(10):
        if j == x:
            if j == 0:
                for k in range(4):
                    dp1[i+1][k] += dp1[i][k]
                    dp2[i+1][k] += dp2[i][k]
            else:
                for k in range(3):
                    dp1[i+1][k+1] += dp1[i][k]
                    dp2[i+1][k+1] += dp2[i][k]
        elif j < x:
            if j == 0:
                for k in range(4):
                    dp2[i+1][k] += dp1[i][k]
                    dp2[i+1][k] += dp2[i][k]
            else:
                for k in range(3):
                    dp2[i+1][k+1] += dp1[i][k]
                    dp2[i+1][k+1] += dp2[i][k]
        else:
            for k in range(3):
                dp2[i+1][k+1] += dp2[i][k]
ans = dp1[m][K] + dp2[m][K]
print(ans)

Measured memory_bytes: 39152
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		StringBuilder[] S = new StringBuilder[H];
		sc.nextLine();

		for(int i=0;i<H;i++) {
			S[i] = new StringBuilder(sc.nextLine());
		}

		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(S[i].charAt(j) == '.') {
					int mine = CalcMine(S,i,j);
					S[i].setCharAt(j, (char)(mine + 48));
				}
			}
		}

		for(int i=0;i<H;i++) {
			System.out.println(S[i].toString());
		}


	}

	public static int CalcMine(StringBuilder[] s,int h,int w) {

		int mine = 0;
		int H = s.length;
		int W = s[0].length();
		if(w > 0 			&& s[h].charAt(w-1) == '#') mine++;		//左
		if(w > 0 && h > 0 	&& s[h-1].charAt(w-1) == '#') mine++;	//左上
		if(h > 0 			&& s[h-1].charAt(w) == '#') mine++;		//上
		if(h > 0 && w < W-1	&& s[h-1].charAt(w+1) == '#') mine++;	//右上
		if(w < W-1 			&& s[h].charAt(w+1) == '#') mine++;		//右
		if(h < H-1 && w < W-1 && s[h+1].charAt(w+1) == '#') mine++;	//右下
		if(h < H-1 			&& s[h+1].charAt(w) == '#') mine++;		//下
		if(h < H-1 && w > 0 	&& s[h+1].charAt(w-1) == '#') mine++;	//左下

		return mine;
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <fstream>
#define F freopen("in.txt","r",stdin);
using namespace std;

int main()
{
	//F

	string ss;
	cin>>ss;

	  int i=0;
	  int ans=0;
	  while(i<ss.size())
	  {

	  	int cnt=0;
	  	  while(ss[i]=='R')
	  	  {
	  	  	i++;
	  	  	cnt++;
	  	  }

	  	 ans=max(ans,cnt);
	  	  i++;

	  }
	  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int num[3];
int table[100005][2];
char buf[4];


int main(){

	scanf("%d %d %d %d",&N,&num[0],&num[1],&num[2]);

	for(int i = 0; i < N; i++){

		scanf("%s",buf);
		table[i][0] = buf[0]-'A';
		table[i][1] = buf[1]-'A';

		if(table[i][0] > table[i][1]){

			swap(table[i][0],table[i][1]);
		}
	}

	vector<char> ANS;

	for(int i = 0; i < N; i++){

		int L = table[i][0],R = table[i][1];
		if(num[L] == 0 && num[R] == 0){

			printf("No\n");
			return 0;

		}else if(num[L] == 0){

			num[L]++;
			num[R]--;

			ANS.push_back('A'+L);

		}else if(num[R] == 0){

			num[R]++;
			num[L]--;

			ANS.push_back('A'+R);

		}else{

			if(i < N-1 && (table[i][0] != table[i+1][0]||table[i][1] != table[i+1][1])){

				if(table[i][0] == table[i+1][0] || table[i][0] == table[i+1][1]){

					num[L]++;
					num[R]--;
					ANS.push_back('A'+L);
				}else{

					num[R]++;
					num[L]--;

					ANS.push_back('A'+R);
				}

			}else{

				num[L]++;
				num[R]--;
				ANS.push_back('A'+L);
			}
		}
	}

	printf("Yes\n");

	for(int i = 0; i < ANS.size(); i++){

		printf("%c\n",ANS[i]);
	}

	return 0;
}


Measured memory_bytes: 4700
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

array<array<int64_t, 3001>, 3001> dp;

int main()
{
    string s, t;
    cin >> s >> t;

    for (auto& v : dp)
    {
        fill(v.begin(), v.end(), 0);
    }

    for (uint64_t i = 1; i <= s.size(); i++)
    {
        for (uint64_t j = 1; j <= t.size(); j++)
        {
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    vector<int> indices;
    int i = s.size();
    int j = t.size();
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            indices.push_back(i - 1);
            i--;
            j--;
        }
        else if (dp[i - 1][j] < dp[i][j - 1])
        {
            j--;
        }
        else
        {
            i--;
        }
    }
    reverse(indices.begin(), indices.end());
    for (auto& idx : indices)
    {
        std::cout << s[idx];
    }
    std::cout << endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define INF 0x3f3f3f
#define PI 3.1415926535897932384626433832795
#define MODX 1000000007
#define PB push_back
#define F first
#define S second
#define FOR(i,k) for(int i=0; i<k; i++)
#define RFOR(i,k) for(int i=k; i>=0; i--)
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define MOD(x, m) ((((x) % (m)) + (m)) % (m))
#define SZ(x) ((int)x.size())
#define FIND(x,y) x.find(y)!=x.end()
#define D(x) cout<<#x<<": "<<(x)<<endl
#define DV(x) cout<<#x<<": "; for(auto &d:x) cout<<d<<" "; cout<<endl
#define DM(x) for(auto &p:x) cout<<p.F<<":"<<p.S<<" "; cout<<endl
#define OUT(x) cout<<(x)<<endl

using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<char,int> MC;
typedef map<int,int> MI;
typedef map<string,int> MS;

template<typename T, typename U> void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if(x < y) x = y; }
VPII nb = {{0,1}, {1,0}, {0,-1}, {-1,0}};
PII operator+(PII &l, PII &r) { return {l.F+r.F, l.S+r.S}; }
bool IsValid(PII p, int Y, int X) { return p.F >=0 && p.F < Y && p.S >=0 && p.S 
< X; }
bool IsPrime(int n) { if (n <= 1)  return false; if (n <= 3)  return true; if (n
%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || 
n%(i+2) == 0) return false; return true; }

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  OUT(min(a,b) + min(c,d));
}


Measured memory_bytes: 256
//
//  main.cpp
//  
//
//  Created by yataka on 2018/10/11.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string S, T;
    cin >> S >> T;
    long long  A = S.size(), B = T.size();
    if( A > B){
        cout << "GREATER" << endl;
    }
    if (A == B ){
        for ( long long  i = 0; i < A; i++){
            if(S[i] < T[i]){
                cout << "LESS" << endl;
                return 0;
            }
            if(S[i] > T[i]){
                cout << "GREATER" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    if(A < B){
        cout << "LESS" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, r, g, b;
	scanf("%d%d%d%d", &r, &g, &b, &n);
	long long ans = 0;
	for (int i = 0; i <= n/r; i++) {
		for (int j = 0; j <= n/g; j++) {
			if (i * r + j * g <= n && (n - i * r - j * g) % b == 0)ans++;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
template<class T> il T Max(T a,T b){return a>b?a:b;}
template<class T> il T Min(T a,T b){return a<b?a:b;}
int a,b;
int main(){
	a=rd(),b=rd(),rt(Max(a+b,Max(a-b,a*b)));
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2304
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for a in range(0, 1000):
    for b in range(0, 1000):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()
        elif pow(-1*a, 5)-pow(b, 5) == x:
            print(-1*a, end=" ")
            print(b*-1)
            exit()
        elif pow(-1*a, 5)-pow(b*-1, 5) == x:
            print(-1*a, end=" ")
            print(b*-1)
            exit()


Measured memory_bytes: 9228
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll dp[1010][3];
const int MAX_DIGIT = 100;
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vector<string> s(n);
    map<string, ll> num;
    rep(i,n) {
      cin >> s[i];
      num[s[i]]++;
    }
    ll count = 0;
    for (auto it = num.begin(); it != num.end(); ++it) {
      chmax(count, it->second);
    }
    sort(all(s));
    ll count2 = 1;
    //rep(i,n) print(s[i]);
    rep(i, n){
      if(i == n - 1) {
        if(count == count2){
          print(s[i]);
        }
        break;
      }
      if(s[i] != s[i + 1]){
        if(count == count2){
          print(s[i]);
        }  
        count2 = 0;
      }
      count2++;
    }
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        cin >> y[i];
    }
    for(int i=0;i<n-1;i++){
        cin >> z[i];
    }
    for(int i=0;i<n;i++){
        ans += y[x[i] - 1];
    }
    for(int i=0;i<n;i++){
        if(x[i] == x[i+1] - 1){
            ans += z[x[i] - 1];
        }
    }
    p(ans);
    return 0;
}






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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007


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

   int N,W;
   cin>>N>>W;
   vector<int>w(N),v(N);
   for(int i=0;i<N;i++)cin>>w[i]>>v[i];

   vector<vector<ll>>dp(N+1,vector<ll>(W+1,0));
   for(int i=1;i<=N;i++){
      for(int j=0;j<=W;j++){
         if(j-w[i-1]>=0)dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
         else dp[i][j] = dp[i-1][j];
      }
   }

   //for(auto it:dp[N])cout<<it<<endl;
   cout<<*max_element(dp[N].begin(),dp[N].end())<<endl;
   return 0;
}


Measured memory_bytes: 80256
N = int(input())
A = {}
for _ in range(N):
    a = int(input())
    if a not in A:
        A[a] = 1
    else:
        A[a] += 1
count = 0
for val in A.values():
    if val % 2 == 0:
        continue
    else:
        count+= 1
print(count)

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

int main(){
  vector<int> t(5); cin>>t[0]>>t[1]>>t[2]>>t[3]>>t[4];
  int min_time=1000;
  sort(t.begin(),t.end());
  do {
    int time;
    time=((t[0]+9)/10+(t[1]+9)/10+(t[2]+9)/10+(t[3]+9)/10)*10+t[4];
 	min_time = min(min_time, time); 
  } while (next_permutation(t.begin(),t.end()));
  cout << min_time << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = ":(";
        int i = 100;
        while(i<n*100+100){
            if(i*1.08>=n*100&&i*1.08<=n*100+99){
                ans = String.valueOf(i/100);
                break;
            }
            i += 100;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
using System;
class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int count = 0;
    for (int i = 1; i <= N; i++)
    {
      int digits = (int)(Math.Log10(i)) + 1;
      if (digits % 2 == 1)
        count++;
    }
    Console.WriteLine(count);
  }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


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

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


    return 0;
}


Measured memory_bytes: 3616
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors
  
n = int(input())
ans = 0
for i in range(1, n + 1):
  if i % 2 == 1 and len(make_divisors(i)) == 8:
    ans += 1
print(ans)

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

using namespace std;

int in(){ int a; cin >> a; return a; }
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  int a;
  cin >> a;
  cout << a + a * a + a*a*a << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

int main(){
  string s;
  cin >> s;
  cin.ignore();

  for (int i = 0; i < s.length(); i+=2){
    if(!((s[i] == 'R') || (s[i] == 'U') || (s[i] == 'D'))){
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 1; i < s.length(); i+=2){
    if(!((s[i] == 'L') || (s[i] == 'U') || (s[i] == 'D'))){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    double v;
    while(cin >> v){
        // v = 9.8t
        double t = v / 9.8;
        double y = 4.9*t*t;
        int n = (int)(ceil(y)+4)/5+1; 
        cout << n << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        boolean[] one = new boolean[s.length()];
        int num = 0;
        for (int i = 0; i < s.length(); i++) {
            if (i == 0) {
                if (s.charAt(i) == '1')
                    one[i] = true;
            } else {
                one[i] = s.charAt(i) == '1' && one[i - 1];
            }

            if (num == 0 && s.charAt(i) != '1')
                num = s.charAt(i) - '0';
        }
        if (k > one.length) {
            System.out.println(num);
        } else {
            if (one[(int) (k - 1)])
                System.out.println(1);
            else
                System.out.println(num);
        }
    }

}


Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
    ans+=a[0]-x
    a[0]=x
for i in range(1,n):
    if a[i]+a[i-1]>x:
        ans+=a[i]-(x-a[i-1])
        a[i]=x-a[i-1]
#print(a)
print(ans)


Measured memory_bytes: 59632
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
template<class Container, class InputIt>
Container countTable(InputIt first, InputIt last)
{
    Container cnt;
    for (; first != last; ++first) { ++cnt[*first]; }
    return cnt;
}
// }}}


signed main()
{
    int N, K;
    int a[200010];

    cin >> N >> K;
    rep(i, 0, N) cin >> a[i];

    auto cnt = countTable<map<int,int>>(a, a+N);

    int p = max(0, (int)cnt.size() - K);
    vector<int> buf;
    for (auto e : cnt) {
        buf.push_back(e.second);
    }

    sort(ALL(buf));
    int ans = 0;
    rep(i, 0, p) {
        ans += buf[i];
    }

    cout << (ans) << endl;
    return 0;
}


Measured memory_bytes: 11516
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream& operator<<(ostream& out, vector<T> &v){
  for (int i = 0; i < (int)v.size(); i++) {
    out<<v[i]<<' ';
  }
  return out;
}

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a >= 0 || c >= 0){
    c -= b;
    if(c <= 0){
      cout << "Yes";
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No";
      return 0;
    }
  }





  return 0;
}


Measured memory_bytes: 3616
// AOJ ALDS1_15_D Huffman Coding
// 2019.3.9 bal4u

#include <stdio.h>
#include <stdlib.h>

// 優先度付きキュー
#define MAX 60    // 2*26
typedef struct { int id, f; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].f < que[i].f) min = l; else min = i;
	if (r < qsize && que[r].f < que[min].f) min = r;
	if (min != i) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int id, int f)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].id = id, que[i].f = f;
	while (i > 0 && que[min = PARENT(i)].f > que[i].f) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}

typedef struct { int f; int left, right; } T;
T tbl[MAX]; int sz;
char buf[100003];

int count(int id, int level)
{
	if (id < 26) return tbl[id].f*level;
	return count(tbl[id].left, level + 1) + count(tbl[id].right, level + 1);
}

int main()
{
	int i, l_id, l_f, r_id, r_f;
	char *p;

	fgets(p=buf, 100003, stdin);
	while (*p >= 'a') tbl[*p-'a'].f++, p++;   // 文字ごとの出現頻度
	for (i = 0; i < 26; i++) if (tbl[i].f) enq(i, tbl[i].f);  // Qに入れる
	if (qsize == 1) { printf("%d\n", que[0].f); return 0; }
	sz = 26;
	while (1) {
		l_id = que[0].id, l_f = que[0].f, deq();
		if (!qsize) break;
		r_id = que[0].id, r_f = que[0].f, deq();
		tbl[sz].f = l_f + r_f, tbl[sz].left = l_id, tbl[sz].right = r_id;
		enq(sz, tbl[sz].f);
		sz++;
	}
	printf("%d\n", count(l_id, 0));
	return 0;
}


Measured memory_bytes: 2092
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int A, B; cin >> A >> B;
	cout << max(2 * A - 1, max(A + B, 2 * B - 1)) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int h,w;cin>>h>>w;

	string s[h];
	for(int i=0;i<h;i++)cin>>s[i];

	vector<int> row(h,false),col(w,false);

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				row[i]=true;
				col[j]=true;
			}
		}
	}

	for(int i=0;i<h;i++)
		if(row[i]){
			for(int j=0;j<w;j++)
				if(col[j]) cout<<s[i][j];
			cout<<endl;
		}
	return 0;

}

Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, m) = input!(u32, u32);

    if n >= 10 || m >= 10 {
        println!("-1");
    } else {
        println!("{}", n * m);
    }
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int a;
  int counter=0;
  cin >> a;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin >> vec.at(i);
  }
  for(int i=0;i<a;i++){
    if(vec.at(i)%2==0){
      if(vec.at(i)%3==0||vec.at(i)%5==0){
        counter++;
      }
      else{
        counter-=101;
      }
    }
  }
  if(counter>=0){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())
  
n=i()
a=intl()
a.sort()
alice=0
bob=0
for i in range(-1,-n-1,-1):
	if i%2==1:
		alice+=a[i]
	else:
		bob+=a[i]
print(alice-bob)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define ll long long
#define ld long double
#define MAX (int)(pow(10,5)+10)
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,9);
ll INF = inf;
ll modulo = pow(10,9)+7;
double eps = 1e-10;
ifstream in;
ofstream out;
 
 
 
void deal(){
	ll n ,x;
	cin>>n>>x;
	vector<ll> arr(n);
	fori(n)
		cin>>arr[i];
	sort(arr.rbegin(), arr.rend());
	vector<ll> dp(MAX, 0);
	dp[x] = 1;
	fori(n){
		vector<ll> dpn(MAX,0);
		forj(MAX){
			dpn[j%arr[i]]+=dp[j];
			dpn[j] 		 +=(dp[j]*(n-i-1));
			dpn[j%arr[i]]%=modulo;
			dpn[j]		 %=modulo;
		}
		dp = dpn;
	}
	ll sum = 0;
	fori(MAX){
		sum+=dp[i]*i;
		sum%=modulo;
	}
	cout<<sum;
}
 
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
/*
	
*/

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void){
  bool isPrime[1000001];

  for(int i = 0 ; i <= 1000000 ; i++){
    isPrime[i] = true;
  }

  isPrime[0] = false;
  isPrime[1] = false;
  for(int n = 2 ; n <= 1000000 ; n++){
    if(isPrime[n]){
      for(int m = n ; m <= 1000000 ; m += n){
        isPrime[m] = false;
      }
      isPrime[n] = true;
    }
  }

  while(1){
    int a , b;
    cin >> a;
    cin >> b;

    if(a == 0 && b == 0){
      return 0;
    }

    int akey = 0;
    int afactmax;
    for(int i = 2 ; i <= a ; i++){
      if(isPrime[i] && a % i == 0){
        akey += i;
        afactmax = i;
      }
    }
    akey = 2 * afactmax - akey;

    int bkey = 0;
    int bfactmax;
    for(int i = 2 ; i <= b ; i++){
      if(isPrime[i] && b % i == 0){
        bkey += i;
        bfactmax = i;
      }
    }
    bkey = 2 * bfactmax - bkey;

    if(akey > bkey){
      cout << "a" << endl;
    }else{
      cout << "b" << endl;
    }



  }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = n%k;
    ans = min(ans, k-ans);
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s=input()
ans=[]
for i in range(len(s)):
    if s[i]=='0':
        ans.append('0')
    if s[i]=='1':
        ans.append('1')
    if s[i]=='B' and len(ans)>0:
        ans.pop(len(ans)-1)
print(''.join(ans))


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

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = k - 1; i > 0; --i) {
        cout << x - i << " ";
    }
    for (int i = 0; i < k; ++i) {
        if (i == k - 1) {
            cout << x + i << endl;
            return 0;
        }
        cout << x + i << " ";
    }
    return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ.Volume0
{
    class Program0025
    {
        static void Main(string[] args)
        {
            string line;
            var inputs = new Queue<string[]>();

            while ((line = Console.ReadLine()) != null)
            {
                inputs.Enqueue(new[] { line, Console.ReadLine() });
            }

            foreach (var input in inputs)
            {
                int hit, blow;            

                string[] a = input[0].Split(' ').ToArray();
                string[] b = input[1].Split(' ').ToArray();

                hit = Enumerable.Range(0, 4).Count(i => a[i] == b[i]);
                blow = a.Intersect(b).Count() - hit;

                Console.WriteLine("{0} {1}", hit, blow);
            }
        }
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 900200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
ll res = -1e18;
ll suff[N];
ll pref[N];
ll a[N];
ll b[N];
ll n, sum;


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

	cin >> n;
	int all = n + n + n;
	fo(i, all)
		cin >> a[i];
	fo(i, all)
		b[i] = a[i];
	sort(b + 1, b + all + 1);
	multiset<ll> q;
	pref[0] = -1e18;
	fo(i, all)
	{
		q.insert(a[i]);
		sum += a[i];
		if(q.size() > n)
		{
		    sum -= *q.begin();
			q.erase(q.begin());
		}
		pref[i] = sum;
		if(i > n)
			pref[i] = max(pref[i], pref[i - 1]);
	}
	q.clear();
	sum = 0;
	suff[all + 1] = 1e18;
	for(int i = all; i >= 1; --i)
	{
		q.insert(a[i]);
		sum += a[i];
		if(q.size() > n)
		{
			sum -= *(--q.end());
			q.erase(--q.end());
		}
		suff[i] = sum;
		if(i <= n + n)
			suff[i] = min(suff[i], suff[i + 1]);
	}
	for(int i = n; i <= n + n; ++i)
	{
		res = max(res, pref[i] - suff[i + 1]);
	}
	cout << res;
	return 0;	
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

double x, t;

int main(){
  cout << setprecision(17);
  cin >> t >> x;
  cout << t/x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <time.h>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";

///summary : とりあえず貪欲法
int vmax(std::vector<int> v)
{
	int ans = 0;
	int maxVal = INT_MIN;       // 整数最小値
	for (int i = 0; i < (int)v.size(); i++) {
		if (v[i] > maxVal) {
			maxVal = v[i];
			ans = i;
		}
	}
	return ans;
}

int checker(const vector<int>& t, const int D, const vector<int>& c, const vector<vector<int>> s) {
	vector<int> last(26, -1);
	int satisfy = 0;
	rep(date, D) {
		last[t[date]] = date;
		satisfy += s[date][t[date]];
		rep(i, 26) satisfy -= c[i] * (date - last[i]);
	}
	return satisfy;
}

vector<int> SetAns() {
	/// normal_input
	int D;
	cin >> D;

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	rep(i, 26) cin >> c[i];
	rep(i, D) rep(j, 26) cin >> s[i][j];;
	
	/// main_process
	vector<int> t(D);
	rep(i, D) t[i] = vmax(s[i]);

	//候補の最適化
	int val = -1;
	vector<int> rN(2);
	int maxVal = checker(t, D, c, s);

	rep(_i, 1000) {
		vector<int> tmpAns = t;
		rep(_j, _i % 10) {
			rN[0] = rand() % D;
			rN[1] = rand() % 26;

			//change
			tmpAns[rN[0]] = (tmpAns[rN[0]] + rN[1]) % 26;
		}
		int tmpVal = checker(tmpAns, D, c, s);

		if (tmpVal > maxVal) {
			t = tmpAns;
			maxVal = tmpVal;
		}
	}

	return t;
}

int main() {
	srand((unsigned)time(NULL));
	vector<int> ans = SetAns();
	for (const auto& i : ans) {
		cout << i + 1 << endl;
	}
	//cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3296
function Main(input) {
  input = input.split("\n");
  var x = parseInt(input[0].split(" ")[0]);
  var y = parseInt(input[0].split(" ")[1]);
  var ans = -1;
  if(x%y!=0){
    ans=x;
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int val[3];
	cin>>val[0]>>val[1]>>val[2];
	
	sort(val,val+3);
	int dif=(val[2]-val[0])+(val[2]-val[1]);
	cout<<(dif%2==0 ? dif/2 : dif/2+2)<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

class Node {
public:
    int location;
    int p, l, r;

    Node() {}
};

class Point {
public:
    int id, x, y;

    Point() {}
    Point(int id, int x, int y) : id(id), x(x), y(y) {}

    bool operator < (const Point &p) const {
        return id < p.id;
    }

    void print() {
        printf("%d\n", id);
    }
};


const int MAX_N = 500000;
const int NIL = -1;

int n;
Point P[MAX_N];
Node T[MAX_N];
int np;

bool lessX(const Point &p1, const Point &p2) {
    return p1.x < p2.x;
}
bool lessY(const Point &p1, const Point &p2) {
    return p1.y < p2.y;
}

int makeKDTree(int l, int r, int d) {
    if (!(l < r)) return NIL;

    int mid = (l+r)/2;
    int t = np++;
    if (d % 2 == 0) {
        sort(P+l, P+r, lessX);
    } else {
        sort(P+l, P+r, lessY);
    }

    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, d+1);
    T[t].r = makeKDTree(mid+1, r, d+1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int d, vector<Point> &ans) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if (sx <= x && x <= tx && sy <= y && y <= ty) {
        ans.push_back(P[T[v].location]);
    }

    if (d % 2 == 0) {
        if (T[v].l != NIL) {
            if (sx <= x) find(T[v].l, sx, tx, sy, ty, d+1, ans);
        }
        if (T[v].r != NIL) {
            if (x <= tx) find(T[v].r, sx, tx, sy, ty, d+1, ans);
        }
    } else {
        if (T[v].l != NIL) {
            if (sy <= y) find(T[v].l, sx, tx, sy, ty, d+1, ans);
        }
        if (T[v].r != NIL) {
            if (y <= ty) find(T[v].r, sx, tx, sy, ty, d+1, ans);
        }
    }
}

int main(void) {
    int x, y;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;
    int root = makeKDTree(0, n, 0);

    int q; scanf("%d", &q);
    int sx, tx, sy, ty;
    for (int i = 0; i < q; i++) {
        vector<Point> ans;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for (auto j = 0; j < ans.size(); j++) ans[j].print();
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 14524