akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
AC
"""
import sys
from sys import stdin
from itertools import chain
input = stdin.readline


def flatten(listOfLists):
    "Flatten one level of nesting"
    return chain.from_iterable(listOfLists)


cards = []
def main(args):
    global cards
    n = int(input())
    m = int(input())

    cards = [x for x in range(1, (2*n)+1)]
    for _ in range(m):
        op = int(input())
        if op == 0:
            # shuffle()
            temp = [[y, b] for y, b in zip(cards[:n], cards[n:])]
            cards = list(flatten(temp))
        else:
            # cut(k)
            cards = cards[op:] + cards[:op]

    print('\n'.join(map(str, cards)))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    cin >> n;

    vector<bool> ps(1e6+5, true);
    vector<int> cnt(1e6+5);

    int a[n];
    set<int> s;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        s.insert(a[i]);
    }
    for (int e: s) {
        if (ps[e]) {
            for (int i=2*e; i<1e6+5; i+=e)
                ps[i] = false;
        }
    }

    int ans = 0;
    for (int e : a) {
        if (ps[e] && cnt[e] < 2) ans++;
    }
    cout << ans << "\n";
}


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

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

    vector<long long> dp(n, 1e12);
    dp[0] = 0;

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

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4812
/*---------------------------------------------------------------------*/
/*                   -------------------------------------             */
/*                   -----------MEHEDI HASAN--------------             */
/*                   -----CSE,JAHANGIRNAGAR UNIVERSITY----             */
/*                   -------------------------------------             */
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
//#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
/*---------------------------------------------------------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define ccc(x)      cout<<#x<<"="<<"("<<x.ff<<" "<<x.ss<<") ";
#define CC(x)       cout<<"["<<#x<<"] = ";for(auto xx: x) cout<<xx<<" ";
#define CCC(x)      cout<<"["<<#x<<"] = ";for(auto xx: x) cout<<"("<<xx.ff<<" "<<xx.ss<<") ";
#define MARK(x)     cout<<x<<" ";
#define ee          cout<<"\n";
#define OK          cout<<"Ok till line "<<__LINE__<<"\n";
/*---------------------------------------------------------------------*/
#define ff          first
#define ss          second
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define ps          push
#define psb         push_back
#define psf         push_front
#define pp          pop
#define ppb         pop_back
#define ppf         pop_front
#define all(x)      x.begin(),x.end()
#define TESTS       int t;cin>>t;for(int tcase=1;tcase<=t;tcase++)
#define ordered_set tree< int, null_type, less_equal< int >, rb_tree_tag, tree_order_statistics_node_update>
/*---------------------------------------------------------------------*/
#define MAX (int) (5e5+88)

int main()
{
    FAST
    int n,m;cin>>n>>m;
    int s=0;
    while(m--)
    {
        int x;cin>>x;
        s+=x;
    }
    if(s>n) cout<<-1<<endl;
    else cout<<n-s<<endl;
    return 0;
}
/*--------------------------------------------------------------------*/
/*
>Check Corner Cases (n==1 or T==1)
>Overflow issues?
>LB / UB !!not found!! check?
*/
/*--------------------------------------------------------------------*/
/* ---INPUT---
--------(1)------
4
3
AAB
5
AABAA
1
B
4
BABA
-------(2)-------
5
5
AAAAA
6
BBAAAA
1
A
2
BA
10
AAAAAAAAAB


-------(3)-------


-------(4)-------



--------------
*/
/*--------------------------------------------------------------------*/


//https://codeforces.com/contest/466/problem/C try again


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,1,n+1){
        if((1<=i&&i<=9)||(100<=i&&i<=999)||(10000<=i&&i<=99999)) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    ll a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    int ans=0;
    for(int i=0; i<n; i++){
        if(x<a[i]){
            cout << ans << endl;
            return 0;
        }
        x-=a[i];
        ans++;
    }
    if(x>0) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	ll k;
	vector<P>p(n);
	cin >> k;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}

	sort(p.begin(), p.end());
	ll count = 0;
	for (int i = 0; i < n; i++) {
		count += p[i].second;
		if (count >= k) {
			cout << p[i].first << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 4768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        //N円の税抜き価格X円を知りたい！！
        //値段
        int n = sc.nextInt();
        
        //税抜き価格
        double x = 1.0;
        
        while(true){
            if((int)(x * 1.08) == n){
                System.out.println((int)x);
                break;
            }
            x++;
            
            if(x > n){
                System.out.println(":(");
                break;
            }
        }
    }
}


Measured memory_bytes: 35596
#include <stdio.h>
#include <algorithm>
using namespace std;

int table[1005][1005];
int weight[1000];
int value[1000];
int w;
int n;
int Case = 0;

int main()
{
	while(true)
	{
		Case++;
		
		scanf("%d", &w);
		if(w == 0) break;
		scanf("%d", &n);
		
		for(int i = 0; i < n; i++)
		{
			scanf("%d,%d", &value[i], &weight[i]);
		}
		
		for(int i = 0; i <= n; i++)
		{
			for(int j = 0; j <= w; j++)
			{
				table[i][j] = -1;
			}
		}
		
		table[0][0] = 0;
		
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j <= w; j++)
			{
				if(table[i][j] == -1) continue;
				table[i + 1][j] = max(table[i + 1][j], table[i][j]);
				if(j + weight[i] <= w)
				{
					table[i + 1][j + weight[i]] = max(table[i + 1][j + weight[i]], table[i][j] + value[i]);
				}
			}
		}
		
		int ansValue = 0;
		int ansWeight;
		for(int i = 0; i <= w; i++)
		{
			if(ansValue < table[n][i])
			{
				ansValue = table[n][i];
				ansWeight = i;
			}
		}
		
		printf("Case %d:\n", Case);
		printf("%d\n%d\n", ansValue, ansWeight);
	}
	
	return 0;
}

Measured memory_bytes: 4964
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main ()
{
    ll X,Y;cin>>X>>Y;
    ll cnt = 0;
    ll A = X;
    while(A<=Y){
        cnt++;
        A = 2 * A;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

num_r = s.count('R')
num_g = s.count('G')
num_b = s.count('B')

ans = num_r*num_g*num_b

for i in range(n):
    for j in range(i, n):
        k = j+(j-i)
        if (k < n) and (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            ans -= 1
print(ans)

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
#define LL long long 
LL mulmod(LL a,LL b, LL m){LL q=(LL)(((long double)a*(long double)b)/(long double)m);LL r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}/* for TOO LARGE mod of the order 10^18 etc */
 
template<typename T>T mod(T a,T b){while(a < 0)a+=b ;return a%b ;}
template <typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mod(x*p, m);p=mod(p*p, m);n>>=1;}return x;}
template <typename T>T power(T e,T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template <typename T> T InverseEuler(T a, T m){return (a==1? 1 : power(a, m-2, m));}/*use IFF m is a prime number */
template<typename T>inline T gcd(T a, T b){T c;while (b){ c = b;b = a % b;a = c;}return a;}
template <typename T> T lcm(T a, T b){return (a*(b/gcd(a,b)));}


const long long MOD = 1e9 + 7 ;
const int MAXN = 1e5 + 10 ;
long long fact[MAXN] ;
long long ifact[MAXN] ;
int A[MAXN] ;
int mark[MAXN] ;
int main(int argc,char* argv[]) { 
    io() ;
    fact[0] = 1 ;
    for(int i = 1; i < MAXN; i++){
        fact[i] = fact[i-1]*1ll*i ;
        fact[i] %= MOD ;
    }
    ifact[MAXN - 1] = InverseEuler(fact[MAXN - 1], MOD) ;
    for(int i = MAXN - 2; i >= 0; i--){
        ifact[i] = 1ll*(i + 1)*ifact[i+1] ;
        ifact[i] %= MOD ;
    }
    int n ;
    cin >> n ;
    int num = -1 ;
    for(int i = 1; i <= (n + 1); i++){
        cin >> A[i] ;
        if(mark[A[i]]){
            num = A[i] ;
        }
        mark[A[i]] = 1 ;
    }
    int cnt = 0 ;
    int st = 0 ;
    int en = 0 ;
    for(int i = 1; i <= (n+1); i++){
        if(A[i] == num){
            if(!st){
                st = 1 ;
            }
            else if(!en){
                en = 1 ;
            }
        }
        else{
            if(!st || (st && en)){
                cnt++ ;
            }
        }
    }
    cout << n << endl ;
    for(int k = 2; k <= n; k++){
        long long ans = (((fact[n+1]*ifact[k])%MOD)*ifact[n + 1 - k])%MOD ;
        if(cnt >= (k-1)){
            ans = ans + MOD - (((fact[cnt]*ifact[k - 1])%MOD)*ifact[cnt - k + 1])%MOD ;
            ans %= MOD ;
        }
        cout << ans << endl ;
    }
    cout << 1 << endl ;
    return 0 ; 
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

using Int = long long;

const int MAX_N = 100000;
const int mod = 1000000007;

int N;
Int dp[MAX_N][2];
vector<int> G[MAX_N];

// col=0 -> black, col=1 -> white
Int DP(int cur, int col, int par = -1)
{
	if (G[cur].size() == 1 and par == G[cur][0]) return 1;

	if (dp[cur][col] != -1) return dp[cur][col];

	Int ret = 1;

	for (int &nxt : G[cur]) {
		if (nxt == par) continue;

		if (col == 0) { // black
			ret *= DP(nxt, 1, cur);
		} else {
			ret *= DP(nxt, 0, cur) + DP(nxt, 1, cur);
		}

		ret %= mod;
	}

	return dp[cur][col] = ret;
}

int main()
{
	cin >> N;

	for (int i = 0; i < N - 1; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	Int ans = 0;
	memset(dp, -1, sizeof dp);

	for (int i = 0; i < 2; ++i) {
		ans += DP(0, i);
		ans %= mod;
	}

	cout << ans << endl;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

long long int gcd(long long int a, long long int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

int main() {
	long long int n, k;
	cin >> n >> k;
	vector<long long int> a(n);
	long long int MAX = 0;
	bool h = false;
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
		MAX = max(MAX, a[i]);
		if (a[i] == k) {
			h = true;
		}
	}
	if (h) {
		cout << "POSSIBLE" << endl;
	} else if (MAX < k) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		sort(a.begin(), a.end());
		long long int aa = a[0];
		for (long long int i = 1; i < n; i++) {
			aa = gcd(aa, a[i]);
		}
		if (aa == 1) {
			cout << "POSSIBLE" << endl;
		}
		else {
			if (k % aa == 0) {
				cout << "POSSIBLE" << endl;
			}
			else {
				cout << "IMPOSSIBLE" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M, A[100000];
    cin >> N >> M;
    REP(i, N) cin >> A[i];
    sort(A, A + N);

    int B, C;
    pii CB[100000];
    REP(i, M) {
        cin >> B >> C;
        CB[i] = {C, B};
    }
    sort(CB, CB + M, greater<pii>());

    int i = 0;
    for (auto cb : CB) {
        bool conti = true;
        REP(j, cb.second) {
            if (i < N && cb.first > A[i]) A[i++] = cb.first;
            else {
                conti = false;
                break;
            }
        }
        if (!conti) break;
    }

    ll sum = 0;
    REP(i, N) sum += A[i];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1408
n=int(input())
al=[chr(ord('a') + i) for i in range(26)]
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
print(num2alpha(n).lower())

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int q;
	ll num[100001];
	for(int i=0;i<=100000;i++) num[i] = 0;
	for (int i = 0; i < n; i++){
		num[a[i]]++;
	}
	cin >> q;
	ll sum = 0;
	for(int i=0;i<=100000;i++){
		sum += i*num[i];
	}
	for(int i=0;i<q;i++){
		int b,c;
		cin >> b >> c;
		if(num[b]>0){
			num[c] += num[b];
			sum += num[b] * (c-b);
			num[b] = 0;
		}
		cout << sum << endl;
	}
		
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N == 25) return cout << "Christmas" << "\n", 0;
  if (N == 24) return cout << "Christmas Eve" << "\n", 0;
  if (N == 23) return cout << "Christmas Eve Eve" << "\n", 0;
  if (N == 22) return cout << "Christmas Eve Eve Eve" << "\n", 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];

    pair<int, int> b[n];

    for (int i=0; i<n; i++) {
        cin >> a[i];
        b[i].first = i;
        b[i].second = a[i];
    }


    sort(b, b+n, [](pair<int, int> x, pair<int, int> y) {
        return x.second > y.second;
    });

    int maxIdx=b[0].first;
    int max=b[0].second;

    for (int i=0; i<n; i++) {
        if (i == maxIdx) {
            cout << b[1].second << endl;
        } else {
            cout << max << endl;
        }
    }
}

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

int main()
{
	int a, b;
	while (cin >> a >> b, !(a == 0 && b == 0)) {
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if ((i + j) % 2 == 0) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 3076
a,b,c=map(int,input().split())
if a>b:
    a,b=b,a
else:
    a,b=a,b
if b>c:
    b,c=c,b
else:
    b,c=b,c
if a>b:
    a,b=b,a
else:
    a,b=a,b
print(f'{a} {b} {c}')


Measured memory_bytes: 5612
n = int(input())
xy_ls = [0]*n

for i in range(n):
    a = int(input())
    ls = [list(map(int, input().split())) for _ in range(a)]
    xy_ls[i] = ls 

ok_ls = []
for i in range(2**n):
    ok = 1
    people = [0]*n
    for j in range(n):
        if i >> j & 1:
            people[j] = 1
    for j in range(n):
        if people[j] == 1:
            for xy in xy_ls[j]:
                if xy[1] != people[xy[0]-1]:
                    ok = 0
    if ok:
        ok_ls.append(len([i for i in people if i == 1]))

print(max(ok_ls))

Measured memory_bytes: 75192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){
    int x; cin >> x;
    auto v = prime_table(1000000);
    FOR(i,x,1000000){
        if(v[i]) {
            cout << i << endl;
            return 0;
        }    
    }
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c;
  cin >> a >> b >> c;
  if (a * b * c % 2 == 0) {
    cout << 0 << '\n';
  } else {
    cout << min({a * b, b * c, c * a}) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = list(map(str, input().split()))
num = [0 for _ in range(10)]

for v in d:
    num[int(v)] = 1

for j in range(10 * n):
    v = n + j
    v_l = list(str(v))
    flag = True
    for i in v_l:
        if num[int(i)] == 1:
            flag = False
            break
    if flag:
        print(v)
        exit()


Measured memory_bytes: 3060
S = input()
N = len(S)
for i in range(int((N-1)/2)):
  if S[i] != S[-(i+1)]:
    print("No")
    exit()
half = S[0:int((N-1)/2)]
for i in range(int((N-1)/4)):
  if half[i] != half[-(i+1)]:
    print("No")
    exit()
print("Yes")

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    int res = 0;
    for (int i = 0; i < N;) {
        int j = i;
        while (j < N && S[j] == S[i]) ++j;
        ++res;
        i = j;
    }
    cout << res << endl;
}


Measured memory_bytes: 512
o=input()
e=input()
if len(o)!=len(e):
  for i in range(len(o)-1):
    print(o[i],end="")
    print(e[i],end="")
  print(o[-1])  
else:
  for i in range(len(o)):
    print(o[i],end="")
    print(e[i],end="")

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

int	main()
{
	int	a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b > c + d)
		cout << "Left" << endl;
	else if (a + b < c + d)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;
}


Measured memory_bytes: 256
from collections import deque
k=int(input())
d=deque(range(1,10))

for i in range(k):
    x=d.popleft()
    if x % 10 != 0:
        d.append(10*x + x%10 -1)
    d.append(10*x + x%10)
    if x%10 != 9:
        d.append(10*x + x%10 +1)

print(x)

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, X; scanf("%d %d", &N, &X);
  vector<int> M(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &M[i]);
    X -= M[i];
  }
  sort(M.begin(), M.end());
  int ans = N;
  while (X - M[0] >= 0) {
    ++ans;
    X -= M[0];
  }
  printf("%d\n", ans);
  return 0;
}


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

int a, b, c;

int main()
{
	cin >> a >> b >> c;
	if (a == b)
		cout << c << '\n';
	else if (a == c)
		cout << b << '\n';
	else 
		cout << a << '\n';
	return 0;
}

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

 
int main() {
   int n,x;
   cin>>n>>x;
   vector<int> D(n+2);
   D[1]=0;
   for(int i=1;i<=n;i++){
       int l;
       cin>>l;
       D[i+1]=D[i]+l;
   }
   int count=0;
   for(int i=1;i<=n+1;i++){
       if(D[i]>x)break;
       count++;
   }

   cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<vector<int>> d(10, vector<int>(10, 1000000));

void warshall_floyd(int n) {
    rep(k,n) rep(i,n) {
        rep(j,n) {
            d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }
}
int main()
{
    ll a, b, x; cin >> a >> b >> x;
    if (a % x == 0)
        cout << b/x - a/x + 1 << endl;
    else
        cout << b/x - a/x  << endl;

    return 0;
}


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

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

  if (n == 1) {
    cout << k << endl;
    return 0;
  } else {
    cout << k * (int)pow(k - 1, n - 1) << endl;
  }
}


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

int main(void){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    
    vector<int> v(n,0);
    for(int i = 1;i < n;i++){
        if(s.substr(i-1,2) == "AC")v[i]++;
        v[i] += v[i-1];
    }
    
    for(int i = 0;i < q;i++){
        int l,r;
        cin >> l >> r;
        r--;l--;
        cout << v[r]-v[l] << endl;
    }
}

Measured memory_bytes: 3804
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 

 
int main()
{
	int N,i;
	cin >> N;
	set<string>s1;
	string s;
	for(i = 0; i < N; i++)
	{
		cin >> s;
		s1.insert(s);
	}

	cout << s1.size() << endl;

    
    biday;
}
 
//...............BYE BYE................

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


set<string> s[7][7];

void calc(string str,int j,int y)
{
	s[j][y].insert(str);
	if((j<=3&&y==5)||(j==5&&y<=3)||(j==5&&y==5)||(j==6&&y==4)||(j==4&&y==6))
	{
		return;
	}
	else
	{
		calc(str+"A",j+1,y);
		calc(str+"B",j,y+1);
	}
}

int main()
{
	calc("",0,0);
	int j,y;
	cin>>j>>y;
	set<string>::iterator it = s[j][y].begin(),en=s[j][y].end();
	for(;it!=en;it++)
	{
		cout<<*it<<endl;
	}
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;


int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	ll h;
	cin>>h;
	ll pow2=1;
	while(pow2*2<=h) pow2*=2;
	cout<<pow2*2-1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;
int lx, ly;
int d[210][210][6], w[210][210];

bool isin(int x, int y){
    return x >= -lx && y >= -ly && x <= lx && y <= ly;
}

int main() {
    int sx, sy, gx, gy, n;
    cin >> sx >> sy >> gx >> gy >> n;
    VI x(n), y(n);
    REP(i,n) cin >> x[i] >> y[i];
    cin >> lx >> ly;
    REP(i,n) w[lx+x[i]][ly+y[i]] = 1;
    REP(i,2*lx+2) REP(j,2*ly+2) REP(t,6) d[i][j][t] = INF;
    d[sx+lx][sy+ly][0] = 0;
    priority_queue<pair<P,P>, vector<pair<P,P> >, greater<pair<P,P> > > q;
    q.push(make_pair(P(0, 0), P(sx, sy)));
    int dx1[] = {0,1,1,0,-1,-1,0}, dy1[] = {1,0,-1,-1,-1,0,0};
    int dx2[] = {0,1,1,0,-1,-1,0}, dy2[] = {1,1,0,-1,0,1,0};
    while (!q.empty()){
        pair<P,P> a = q.top();
        q.pop();
        int x = a.second.first, y = a.second.second;
        int tm = a.first.second, dist = a.first.first;
        if(d[lx+x][ly+y][tm] < dist) continue;
        REP(k,7){
            int cost = 1;
            if (abs(x*y*tm) % 6 == k) cost = 0;
            int xx = x, yy = y;
            if (x % 2 == 0){
                xx += dx1[k];
                yy += dy1[k];
            }else{
                xx += dx2[k];
                yy += dy2[k];
            }
            if (!isin(xx,yy) || w[xx+lx][yy+ly]) continue;
            int tm_next = (tm + 1) % 6;
            if (d[xx+lx][yy+ly][tm_next] > d[x+lx][y+ly][tm] + cost){
                d[xx+lx][yy+ly][tm_next] = d[x+lx][y+ly][tm] + cost;
                q.push(make_pair(P(d[xx+lx][yy+ly][tm_next], tm_next), P(xx,yy)));
            }
        }
    }
    int ans = INF;
    REP(t,6) ans = min(ans, d[gx+lx][gy+ly][t]);
    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}

Measured memory_bytes: 4216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    int n;
    LL ma = 0;
    cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ma += a[i] - 1;
    }




    /*for (int i = 0; i < 1000000; i++) {
        LL sum = 0;
        for (int j = 0; j < n; j++) {
            sum += i % a[j];
        }
        ma = max(ma, sum);
    }*/

    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; 
    cin >> n >> k;
    int tmp =1;
    for(int i = 0; i < n; ++i){
        tmp = min(tmp+k,2*tmp);
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
  int alice[101] = {0};
  int bob[101] = {0};

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  for (int i = A; i <= B; ++i) {
    alice[i] = 1;
  }
  for (int i = C; i <= D; ++i) {
    bob[i] = 1;
  }
  int n = 0;
  for (int i = 0; i <= 100; ++i) {
    if (alice[i] == 1 && bob[i] == 1)
      ++n;
  }
  if (n == 0)
    cout << n << endl;
  else
    cout << n - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
import sys

n, *aaa = map(int, sys.stdin.read().split())

aaa.sort(reverse=True)
aaa.append(-1)
i = 0
while aaa[i + 1] > i + 1:
    i += 1

j = i
while aaa[j] >= i + 1:
    j += 1

if (aaa[i] - i) % 2 == 0 or (j - i) % 2 == 0:
    ans = 0
else:
    ans = 1

print(['First', 'Second'][ans])


Measured memory_bytes: 19984
//Diverse Word

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s;cin>>s;
    map<char,int>m{};
    rep(i,0,s.size())m[s[i]]++;
    if(s.size()<26){
        char t;
        for(char i='a';i<='z';i++){
            if(m[i]==0){
                s.pb(i);
                break;
            }
        }
        cout<<s<<nnn;
    }else{
        string t = s;
        if(!next_permutation(range(s))){
            cout<<-1<<nnn;
            return 0;
        }
        bool flag = true;
        for(int i=0;flag;i++){
            cout<<s[i];
            if(s[i]!=t[i])flag = false;
        }
        cout<<nnn;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll a; cin >> a;
	string s; cin >> s;
	ll b = 100*(s[0]-'0') + 10*(s[2]-'0') + (s[3]-'0');
	cout << a*b/100 << endl;
}

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

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i==0 && (n/i)<=9)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    int n; cin>>n;
    int num=(n+110)/111;
    cout << num*111 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	string S, T;
	cin >> S >> T;
	N = S.size();
	M = T.size();
	int INF = (int)1 << 50;
	vector<vector<int> > dp(N + 1, vector<int>(M + 1, -INF));
	vector<vector<pair<int, int> > > from(N + 1, vector<pair<int, int> >(M + 1));
	dp[0][0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (i + 1 <= N && j + 1 <= M) {
				if (S[i] == T[j]) {
					if (dp[i + 1][j + 1] < dp[i][j] + 1) {
						dp[i + 1][j + 1] = dp[i][j] + 1;
						from[i + 1][j + 1] = make_pair(i, j);
					}
				}
				else {
					if (dp[i + 1][j + 1] < dp[i][j]) {
						dp[i + 1][j + 1] = dp[i][j];
						from[i + 1][j + 1] = make_pair(i, j);
					}

				}
			}
			if (i + 1 <= N) {
				if (dp[i + 1][j] < dp[i][j]) {
					dp[i + 1][j] = dp[i][j];
					from[i + 1][j] = make_pair(i, j);
				}
			}
			if (j + 1 <= M) {
				if (dp[i][j + 1] < dp[i][j]) {
					dp[i][j + 1] = dp[i][j];
					from[i][j + 1] = make_pair(i, j);
				}
			}
		}
	}
	int X = N;
	int Y = M;
	int cur = dp[N][M];
	//cerr << cur << endl;
	string res;
	while (true) {
		tie(X, Y) = from[X][Y];
		if (cur != dp[X][Y]) {
			res.push_back(S[X]);
		}
		cur = dp[X][Y];
		if (X == 0 && Y == 0)break;
	}
	reverse(res.begin(), res.end());
	cout << res << endl;
}

Measured memory_bytes: 211584
n = int(input())
list_num = list(map(int, input().split()))
flg = False
for i in range(n):
  if list_num[i] % 2 == 1 or (list_num[i] % 2 == 0 and (list_num[i] % 3 == 0 or list_num[i] % 5 == 0)):
    flg = True
  else:
    flg = False
    break

if flg:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include <iostream>
#include <queue>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;

struct Point{
	int x,y;
	Point(){}
	Point(int x,int y):x(x),y(y){}
	bool operator==(const Point& p)const{return x==p.x && y==p.y;}
};

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		Point tak,kaz;
		cin>>tak.x>>tak.y>>kaz.x>>kaz.y;
		tak.x--; tak.y--;
		kaz.x--; kaz.y--;
		
		vvi grid(h,vi(w));
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin>>grid[i][j];
		
		vvvvi vis(h,vvvi(w,vvi(h,vi(w,-1))));
		queue<pair<Point,Point>> q;
		vis[tak.y][tak.x][kaz.y][kaz.x]=0;
		q.emplace(tak,kaz);
		int res=-1;
		while(q.size()){
			tak=q.front().first;
			kaz=q.front().second;
			q.pop();
			
			if(vis[tak.y][tak.x][kaz.y][kaz.x]>=100)
				break;
			if(tak==kaz){
				res=vis[tak.y][tak.x][kaz.y][kaz.x];
				break;
			}
			
			int dx[]={-1,1,0,0},dy[]={0,0,-1,1};
			for(int k=0;k<4;k++){
				int tx=tak.x+dx[k],ty=tak.y+dy[k];
				int kx=kaz.x-dx[k],ky=kaz.y-dy[k];
				if(tx<0 || w<=tx || ty<0 || h<=ty || grid[ty][tx])
					tx=tak.x,ty=tak.y;
				if(kx<0 || w<=kx || ky<0 || h<=ky || grid[ky][kx])
					kx=kaz.x,ky=kaz.y;
				if(vis[ty][tx][ky][kx]!=-1)
					continue;
				vis[ty][tx][ky][kx]=vis[tak.y][tak.x][kaz.y][kaz.x]+1;
				q.emplace(Point(tx,ty),Point(kx,ky));
			}
		}
		
		if(res==-1)
			puts("NA");
		else
			printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 30104
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);
    
    ll n;
    cin>>n;
    unordered_map <string, ll> mp;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<mp.size()<<endl;

}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.14159265;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    double R; cin >> R;
    cout << fixed << setprecision(10) <<  2*PI*R << endl;
    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
int sum=0,n,x;
bitset<5000000>s; 
int main(){
	scanf("%d",&n),s[0]=1;
	for(int i=1;i<=n;++i)scanf("%d",&x),s|=s<<x,sum+=x;
	for(int i=(sum+1)/2;;++i)if(s[i]){cout<<i;return 0;}
	return 0;
}

Measured memory_bytes: 2048
//package Atcoder;

import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int health1=fs.nextInt();
		int strength1=fs.nextInt();
		int health2=fs.nextInt();
		int strength2=fs.nextInt();
		int ans1=0,ans2=0;
		ans1=health2%strength1==0 ? health2/strength1:health2/strength1+1;
		ans2=health1%strength2==0 ? health1/strength2:health1/strength2+1;
		if(ans1<=ans2)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

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

int main()
{
	int x, y, tmp;
	cin >> x >> y;
	if (x < y)
	{
		tmp = x;
		x = y;
		y = tmp;
	}
	while (y)
	{
		tmp = x;
		x = y;
		y = tmp;

		y -= y / x * x;
	}
	cout << x << endl;

	return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;

  cout << a*b / __gcd(a, b) << endl;  
  
  return 0;
}


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

int main()
{
    
    vector<char> S(10);

    for (int i = 0; i < 10; i++)
    {
        cin >> S.at(i);
    }
    S.at(3) = '8';

    for (int i = 0; i < 10 ; i++)
    {
        cout << S.at(i) ;
    }

    cout << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = 0;
    for i in 1..(n + 1) {
        if i % 2 == 0 {
            continue;
        };

        let mut count = 0;
        for j in 1..(i + 1) {
            if i % j == 0 {
                count += 1;
            }
        }
        if count == 8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
# https://atcoder.jp/contests/dp/tasks/dp_b

def main():
    N, K = map(int, input().split())
    h = [int(x) for x in input().split()]

    dp = [0] * (N)
    dp[0] = 0

    # 参考：https://atcoder.jp/contests/dp/submissions/10181844
    for i in range(1, N):
        tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
        dp[i] = min(tmp)
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13980
#include <stdio.h>

int dec[20000];

int main(){
	int a,b,n;
	int dummy;
	int sum;
	while(scanf("%d %d %d", &a, &b, &n) != EOF){
		dec[0] = a / b;
		dummy = a % b;

		for(int i = 1; i <= n; i++){
			a = dummy * 10;
			dec[i] = a / b;
			dummy = a % b;
		}
		sum = 0;
		for(int i = 1; i <= n; i++){
			sum += dec[i];
		}
		printf("%d\n",sum);

	}
	return 0;
}

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

int main(){
        int n;cin>>n;
        ll a[n],dp[n];memset(dp,0,sizeof(dp));
        for(int i=0;i<n;i++)cin>>a[i];
        dp[1]=abs(a[0]-a[1]);
        for(int i=2;i<n;i++)
            dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
        cout<<dp[n-1];
	return 0;
}




Measured memory_bytes: 1792
import statistics
n = int(input())
a = list(map(int, input().split()))
summ = 0
for i in range(n):
    a[i] = a[i] - (i + 1)
b = statistics.median_low(a)
ans = 0
for i in range(n):
    ans += abs(a[i] - b)
print(ans)

Measured memory_bytes: 27244
import java.util.Scanner;

public class Main {

	
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		// n k
		long n = sc.nextLong();
		long k = sc.nextLong();
		
		
		long nDivK = n % k;
		long divK = k - nDivK;
		
		long min;
		
		if (nDivK < divK)
			min = nDivK;
		else
			min = divK;
		
		log( min );
		sc.close();
		
	}
	
	
	// test 3 C
//	public static void main(String[] args) {
//		// TODO Auto-generated method stub
//		Scanner sc = new Scanner(System.in);
//		
//		int k = sc.nextInt();
//		int n = sc.nextInt();
//		
//		int ary[] = new int[n];
//
//		for(int i =0; i<n; i++) {
//			ary[i] = sc.nextInt();
//		}
//
//		// 隣同士の距離を調査しつつ、最大の距離を求める。
//		// 最大 > (K/2) の場合、それは K-最大 に adjust する
//		int maxLen = 0;
//		for(int i=0; i< (n-1); i++) {
//			int j = i+1;
//			int dist1;
//			dist1 = ary[j]-ary[i];
//
////			if ( dist1 > (k/2) ) {
////				dist1 = k - dist1;
////			}
//			if(maxLen<dist1)
//				maxLen = dist1;
//		}
//		
//		// end を調査
//		int lastDist = k + ary[0] - ary[n-1];
//		if (maxLen < lastDist)
//			maxLen = lastDist;
//		
//		int tripLen = k - maxLen;
//		
//		log( tripLen );
//		sc.close();
//		
//	}
	
//	static int updateArray( int k,int n, int[] ary) {
//		int max = ary[0];
//		int min = ary[0];
//		for (int i = 0; i < ary.length; i++) {
//		    int v = ary[i];
//		    if (v > max) {
//		        max = v;
//		    }
//		    if (v < min) {
//		        min = v;
//		    }
//		}
//
//		
//		int new_dif;
//		if ((max-min) > (k/2)){
//			new_dif = (max-min) - (k-(max-min));
//		}
//		else {
//			new_dif = (max-min);
//		}
//
//		return new_dif;
		
//		if ((max-min) > (k/2)){
//			int newary[] = new int[ary.length];
//			// max を min (-) に変更
//			for(int j=0;j<ary.length; j++) {
//				if (ary[j] == max) {
//					newary[j] = (max-k);
//				}
//				else {
//					newary[j]=ary[j];
//				}
//			}
//			return updateArray(k,n,newary);
//		}
		
//		return ary;
//	}
	
	
}


Measured memory_bytes: 21844
#include<iostream>

#include<string>
#include <algorithm> 
using namespace std;

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    if(
       s1.substr(s1.length()-1,1)==s2.substr(0,1)
    && s2.substr(s2.length()-1,1)==s3.substr(0,1)
    ) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 1;

int N;
map<int, int> mp;

int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for (auto it : mp) {
    if (it.second & 1) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let s1 = str2vec(&input_line_str());
    let s2 = str2vec(&input_line_str());
    let s3 = str2vec(&input_line_str());
    println!("{}{}{}", s1[0], s2[1], s3[2]);
}

Measured memory_bytes: 4352