akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll n,k ;
	cin >> n >> k ;
	if(n==1){
		cout << 1 << endl ;
		return 0 ;
	}
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	for(int i=0;i<k;i++){
		ll sum = 0 ;
		for(int i=0;i<n;i++) sum += a.at(i) ;
		if(sum==n*n) break ;
		vll sub(n+1,0) ;
		for(int i=0;i<n;i++){
			sub.at(max(0ll,i-a.at(i)))++ ;
			sub.at(min(n,i+a.at(i)+1))-- ;
		}
		a.at(0) = sub.at(0) ;
		for(int i=1;i<n;i++) a.at(i) = a.at(i-1)+sub.at(i) ;
	}
	for(int i=0;i<n;i++) cout << a.at(i) << (i==n-1?'\n':' ') ;
}

Measured memory_bytes: 6428
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    string S;
    cin >> S;
    ll K;
    cin >> K;
    for(ll i = 0; i < S.size(); i++) {
        ll need = (26 - (S[i] - 'a')) % 26;
        if(need <= K) {
            S[i] = 'a';
            K -= need;
        }
    }
    K %= 26;
    while(K--) {
        S.back()++;
        if(S.back() == 'z' + 1) S.back() = 'a';
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 592
import java.util.Scanner;

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

		//A
		/*
		int a = sc.nextInt();//前回の記録
		int b = sc.nextInt();//目標
		System.out.println(2*b-a);*/

		//B
		int N = sc.nextInt();//回数
		int K = sc.nextInt();//操作Bで足す値K
		int ans = 1;
		for(int i = 0; i < N ; i++){
			if(ans<K)
				ans = ans*2;	//操作A
			else
				ans += K;		//操作B
		}
		System.out.println(ans);

	}
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n,q; cin>>n>>q;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = -1;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  //cout<<<<endl;
  ll d;
  vector<pair<ll,pair<ll,ll>>> st(n);
  ll sum = 0;
  for(i=0;i<n;i++){
    cin>>st[i].second.first>>st[i].second.second>>st[i].first;
  }
  sort(ALL(st));
  map<ll,pair<ll,ll>> dd;
  for(i=0;i<q;i++){
    cin>>d;
    dd.insert({d,{-1,d}});
  }
  dd.insert({INF,{INF,INF}});
  ll a, b, c;
  for(i=0;i<n;i++){
    a=st[i].first;
    b=st[i].second.first;
    c=st[i].second.second;
    auto itr = dd.lower_bound(b-a);
    auto itr2 = dd.upper_bound(c-a-1);
    for(;itr!=itr2&&itr!=dd.end()&&itr->first!=INF;){
      if(itr->second.first==-1){
      itr->second.first=a;
      itr->second.second=itr2->first;
      itr++;
      }
      else if(itr->second.second < itr2->first){
        itr=dd.lower_bound(itr->second.second);
      }
      else{
        itr=dd.end();
      }

    }

  }
  for(auto itr=dd.begin();itr->first!=INF;itr++){
    cout<<itr->second.first<<endl;
  }

  return 0;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	map<char,int>m;
	char c;
	for(int i = 0 ; i < 4 ; i ++){
		cin >> c;
		m[c]++;
	}
	if(m[c] == 2 && m.size() == 2) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N;
  cin >> N;
  if (N % 2 == 0)
    cout << N/2 << endl;
  else 
    cout << N/2 + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

candidates = []
candidates.append(a * x + b * y)
candidates.append(c * max(x, y) * 2)
candidates.append(c * min(x, y) * 2 + (a if x > y else b) * abs(x - y))

print(min(candidates))

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){

int S=0;
int a=0,b=0,c=0,e=0,f=0;

cin >> S;

a=S/3600; //hour
b=S/60; //min
e=b%60;
c=S%60; //sec


cout << a << ":" << e << ":" << c << endl;

return 0;

}

Measured memory_bytes: 1164
#include <stdio.h>

#define MAX 5000

int main(void) {
	int n;
	
	while( scanf("%d", &n) != EOF ){
		if(n==0) break;
	
		long nums[MAX];
		int i, j;
		long sum, m;
		
		for(i=0; i<n; i++){
			scanf("%ld", &nums[i]);
		}
		long max=nums[0];
		
		for(i=0; i<n;i++) {
			sum=0;
			for(j=i; j<n; j++) {
				sum+=nums[j];
				if(sum > max) max = sum;
			}
		}	
			
		printf("%ld\n", max);

	}

	return 0;
}

Measured memory_bytes: 628
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

struct edge {
	ll to;
	ll cost;
};

void toposo_(vector<vector<edge>>& g, vector<int>& used, vector<int>& l, int pos) {
	if (!used[pos]) {
		used[pos] = 1;
		for (int i = 0; i < g[pos].size(); i++) {
			toposo_(g, used, l, g[pos][i].to);
		}
		l.push_back(pos);
	}
}
vector<int> toposo(vector<vector<edge>>& g) {
	vector<int> u(g.size(),0), ret;
	for (int i = 0; i < g.size(); i++)toposo_(g, u, ret, i);
	reverse(ret.begin(), ret.end());
	return ret;
}
int main() {
	int V, E;
	cin >> V >> E;
	vector<vector<edge>> g(V);
	for (int i = 0; i < E; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back({ b,1 });
	}
	auto c = toposo(g);

	for (int i = 0; i < c.size(); i++)cout << c[i] << endl;
}


Measured memory_bytes: 4456
N = int(input())
a = [input() for i in range(N)]
listA = []
for i in range(N):
    ai,bi = map(int, a[i].split())
    listA.append([ai,bi])
listA.sort(key = lambda x:x[1])

time = 0
able = True

for i in range(N):
    time += listA[i][0]
    if time > listA[i][1]:
        able = False
        break
if able == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 52360
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int[] a = r.ii();
        println(Math.max(Math.max(a[0]+a[1], a[0]-a[1]),a[0]*a[1])); 
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

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

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

    int a[n-1];
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1])
            a[i] = 1;
        else
            a[i] = 0;
    }

    int ans = 0;
    int count = 0;
    for(int i=0;i<n-1;i++){
        if(a[i]==1){
            count += 1;
            if(ans<count){
                ans = count;
            }
        }else{
            count = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    String[] S=scan.nextLine().split("");
    String[] T=scan.nextLine().split("");
    int count=0;
    for(int i=0;i<3;i++){
      if(S[i].equals(T[i])){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21712
def divisors(num):
    array = []
    limit = int(num ** 0.5) + 1
    for i in range(1, limit):
        if num % i == 0:
            div1 = i
            div2 = num//i
            array.append(div1)
            if div1 != div2:
                array.append(div2)
    return array


n = int(input())
ans = set(divisors(n-1))

candidates = divisors(n)
candidates.remove(1)
for k in candidates:
    num = n // k
    while num % k == 0:
        num //= k
    residue = num % k
    if residue == 1:
        ans.add(k)

ans.discard(1)
print(len(ans))



Measured memory_bytes: 3188
# AOJ 0080 Third Root
# Python3 2018.6.15 bal4u

while True:
	q = int(input())
	if q < 1: break
	
	x = q / 2
	err = 0.00001*q
	while True:
		x2 = x * x
		t = x2 * x - q
		if -err < t < err: break
		x = x - t / (3 * x2)
	print(x)



Measured memory_bytes: 5608
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
int a[2200];
ll x;
int mn[2200][2200];

int main() {
	cin >> n;
	cin >> x;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i) {
		mn[i][0] = a[i];
		for (int j = 1; j < n; ++j)
			mn[i][j] = min(mn[i][j - 1], a[(i - j + n) % n]);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		ans += a[i];
	for (int i = 0; i < n; ++i) {
		ll now = x * i;
		for (int j = 0; j < n; ++j)
			now += mn[j][i];
		ans = min(ans, now);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 17408
//
//  main.c
//  A
//
//  Created by s1262004 on 2019/07/19.
//  Copyright © 2019 s1262004. All rights reserved.
//

#include <stdio.h>
int n;
int A[100][100] = {0};

int main(int argc, const char * argv[]) {
    int i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        int key, num;
        scanf("%d %d", &key, &num);
        for (j = 0; j < num; j++) {
            int temp;
            scanf("%d", &temp);
            A[key-1][temp-1] = 1;
        }
    }
    
    for (i = 0; i < n; i++){
        printf("%d", A[i][0]);
        for (j = 1; j < n - 1; j++){
            printf(" %d", A[i][j]);
        }
        printf(" %d\n", A[i][j]);
    }
    return 0;
}



Measured memory_bytes: 2112
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=1e9+7;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
void fun(int pos){

}
void solve(){
    ll n; cin>>n;
    ll a=1,b=1,c=1;
    for(int i=0;i<n;i++){
        a*=10;
        if(a>mod) a%=mod;
    }
    for(int i=0;i<n;i++){
        b*=9;
        if(b>mod) b%=mod;
    }
    
    for(int i=0;i<n;i++){
        c*=8;
        if(c>mod) c%=mod;
    }
    ll z=2*b;
    if(z>mod) z%=mod;
    if((a-(z-c))<0){
        ll ans=(a-(z-c));
        while(ans<0){
            ans+=mod;
        }
        cout<<ans<<endl;
    }else{
        ll ans=(a-(z-c));
        if(ans>mod){
            cout<<ans%mod<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
}
int main(){
    fastio();
    //write code
    int t; t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CFennecVsMonster solver = new CFennecVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class CFennecVsMonster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            if (n <= k) {
                out.println(0);
            } else {
                ArrayList<Integer> h = new ArrayList<>();
                long sum = 0;
                for (int i = 0; i < n; i++) {
                    h.add(in.nextInt());
                }
                Collections.sort(h);
                for (int i = 0; i < n - k; i++) sum += h.get(i);
                out.println(sum);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

void solve_abc109_c() {
	ll N, X;
	ll ans = 0;

	cin >> N >> X;


	vector<ll> x(N);
	ll tmp;
	rep(i, N) {
		cin >> tmp;
		x[i] = tmp - X;
	}

	ans = abs(x[0]);
	rep(i, N) {
		ans = abs(gcd(ans, x[i]));
	}

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


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

	solve_abc109_c();

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
vector<lli> divisor(lli N){
  vector<lli>res;
  for(lli i=1;i*i<=N;i++){
    if(N%i==0){
      res.push_back(i);
      if(i!=N/i)res.push_back(N/i);
    }
  }
  Sort(res);
  return res;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  sum=INF;
  auto P=divisor(N);
  K=P.size();
  if(K%2==1)Out(P[K/2]*2-2);
  else Out(P[K/2]+P[K/2-1]-2);
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = a+b;
  if(ans > 23) ans -= 24;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
j = int(input())
i = list(map(int, input().split()))
l=0
for k in range(j):
    if i[k]%2==0:
        if i[k]%3!=0 and i[k]%5!=0:
            print('DENIED')
            l=1
            break
if l == 0:
    print('APPROVED')

Measured memory_bytes: 3060
use proconio::{fastout, input};
use std::collections::VecDeque;

#[derive(Debug, Clone, Default)]
struct Cell {
    wait: usize,
    cost: usize,
    neighbors: Vec<usize>,
}

#[fastout]
fn main() {
    input! {in_n: usize, in_ps: [usize; in_n * in_n]};

    let width = in_n + 2;
    let height = in_n + 2;
    let mut cells = Vec::new();

    for i in 0..(width * height) {
        let x = i % width;
        let y = i / width;
        let mut cell = Cell::default();

        if 0 < x && x < width - 1 && 0 < y && y < height - 1 {
            cell.wait = 1;
            cell.cost = *[x, width - x - 1, y, height - y - 1].iter().min().unwrap();
            cell.neighbors.push(i + 1);
            cell.neighbors.push(i - 1);
            cell.neighbors.push(i + width);
            cell.neighbors.push(i - width);
        }

        cells.push(cell);
    }

    let mut cost = 0;

    for in_p in in_ps {
        let x = (in_p - 1) % in_n + 1;
        let y = (in_p - 1) / in_n + 1;
        let i = x + y * width;

        cells[i].cost -= 1;
        cells[i].wait = 0;
        cost += cells[i].cost;

        let mut queue = VecDeque::new();

        queue.push_front(i);

        while !queue.is_empty() {
            let i = queue.pop_back().unwrap();

            for n in cells[i].neighbors.clone().iter() {
                let c = cells[i].cost + cells[*n].wait;

                if cells[*n].cost > c {
                    cells[*n].cost = c;
                    queue.push_front(*n);
                }
            }
        }
    }

    println!("{}", cost);
}


Measured memory_bytes: 27152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

ll n, a, b, c, d;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> c >> d >> n;
	ll c2 = min(d, min(2*c, min(4*b, 8*a)));
	ll c1 = min(c, min(2*b, 4*a));
	cout << (n/2)*c2 + (n%2)*c1 << endl;
	return 0;
}

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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

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

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

string s, add[2];
bool rev;

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

    cin >> s;
    int q;
    cin >> q;

    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            rev ^= 1;
            swap(add[0], add[1]);
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) add[0].pb(c);
            else add[1].pb(c);
        }
    }

    for (auto it = add[0].rbegin(); it != add[0].rend(); ++it) cout << *it;
    if (rev) reverse(all(s));
    cout << s;
    cout << add[1];
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e18
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b)  for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
const ll N=100;
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
       ll n;cin>>n;
       map<string,ll>mm;
       string s;
       for(ll i=0;i<n;i++){
          cin>>s;
          mm[s]++;
       }
       cout<<"AC x "<<mm["AC"]<<"\n";
       cout<<"WA x "<<mm["WA"]<<"\n";
       cout<<"TLE x "<<mm["TLE"]<<"\n";
       cout<<"RE x "<<mm["RE"]<<"\n";
    }
}


Measured memory_bytes: 3664
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = ins()
cnt = 1
out = 0
for i in range(2*n):
    if s[i]=='B' and out%2==0 or s[i]=='W' and out%2==1:
        out += 1
    else:
        if out==0:
            print(0)
            exit()
        cnt = (cnt*out)%R
        out -= 1
    #ddprint(f"{i=} {cnt=} {out=}")
if out!=0:
    print(0)
    exit()
for i in range(2,n+1):
    cnt = (cnt*i)%R
print(cnt)


Measured memory_bytes: 67756
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int c = 0;
	int d = 0;

	for (int i = 0; i < n; i++) {
		if (i == 0) {
			c += a.at(0);
		}
		else if (i % 2 == 1) {
			d += a.at(i);
		}
		else {
			c += a.at(i);
		}
	}

	cout << c - d << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int N;
    scanf("%d",&N);
    char siri[N][12];
    rep(i,N){
        scanf("%s",siri[i]);
    }
    rep(i,N-1){
        if(siri[i][strlen(siri[i])-1]!=siri[i+1][0]){
            printf("No");
            return 0;
        }else{
            for(int j=0;j<i;j++){
                if(strcmp(siri[i],siri[j])==0){
                    printf("No");
                    return 0;
                }else{
                    ;
                }
            }
        }
    }
    for(int i=0;i<N-1;i++){
        if(strcmp(siri[N-1],siri[i])==0){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}


Measured memory_bytes: 1736
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B = map(int, readline().split())
    if A%2 and B%2:
        print('Odd')
    else:
        print('Even')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9068
n, k = map(int, input().split())
h = []
for i in range(n):
  h_ = int(input())
  h.append(h_)
h.sort()
#print(h)
ans = float('inf')
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

Measured memory_bytes: 13392
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll G = 0;
	ll X = 0;
	//double a[100000] = {};
	//double b[100000] = {};
	//ll v[100] = {};
	ll *p, *c, *d;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;

	
	//char p;
	cin >>N;
	//cin >> D >> G;
	//vector<pair<float, float>> is(D);
	//sort(is.begin(), is.end());
	//p = (ll *)malloc(D * sizeof(ll));
	//c = (ll *)malloc(D * sizeof(ll));
	//d = (ll *)malloc(D * sizeof(ll));

	//rep(i, 0, D) {
	//	cin >> is[i].first >> is[i].second;
	//	//cin >> p[i] >>c[i];

	//	//d[i] = (p[i] + 1) * 100;
	//}
	
	if (N < 105)
		cout << 0 << endl;
	else if(N < 135)
		cout << 1 << endl;
	else if (N < 165)
		cout << 2 << endl;
	else if (N < 189)
		cout << 3 << endl;
	else if (N < 195)
		cout << 4 << endl;
	else
		cout << 5 << endl;

	
	//sort(l,l+N);


	return 0;

}



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

unsigned long long *a, n;


int main(){
    int i;
    scanf("%llu",&n);
    a = (unsigned long long *)malloc((n+1)*sizeof(unsigned long long));
    for(i=0;i<n;i++){
        scanf("%llu", a+i);
    }
    a[n]=0;//N+1日目は0円としておく
    unsigned long long money=1000,kabu=0;
    for(i=0;i<n;i++){
        if(a[i]<a[i+1]){
            kabu += money/a[i];
            money %= a[i];
        }else if(a[i]>a[i+1]){
            money += kabu*a[i];
            kabu = 0;
        }
    }
    printf("%llu\n",money);
    return 0;
}


Measured memory_bytes: 1632
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = [0] ~ readln.split.to!(int[]);
    int r;
    foreach (i; 1..N+1) {
        if (as[as[i]] == i) ++r;
    }
    writeln(r/2);
}

Measured memory_bytes: 4284
# coding: utf-8
# Your code here!

s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
c = int(s[2])
k = int(s[3])
total = 0

    
    
if a > 0 and k > 0 :
    
    if k > a :
        total = a
    elif k < a :
        total = k
    elif k == a :
        total = a
    k = k - a
        
# print(a)
        
if b > 0 and k > 0 :
    k = k - b

# print(k)
if c > 0  and k > 0 :
    # print(k)
    if k > c :
        total = total - c
    elif k < c :
        total = total - k
    elif k == c :
        total = total - c


print(total)

Measured memory_bytes: 61884
/* ALDS1_9_C: Priority Queue */

#include <iostream>
#include <string>

const int MAX_N_NODES = 2000000;

class PriorityQueue {
    int size;
    int *heap;
    void max_heapify(int heap[], int i);
    int parent(int i);
    int left(int i);
    int right(int i);
    public:
        PriorityQueue();
        ~PriorityQueue();
        void insert(int key);
        int extract_max();
};

PriorityQueue::PriorityQueue() {
    size = 0;
    heap = new int[ MAX_N_NODES + 1 ];
}

PriorityQueue::~PriorityQueue() {
    delete [] heap;
}

int PriorityQueue::parent(int i) {
    return i / 2;
}

int PriorityQueue::left(int i) {
    return i * 2;
}

int PriorityQueue::right(int i) {
    return i * 2 + 1;
}

void PriorityQueue::insert(int key) {
    size++;
    heap[size] = key;

    int i = size;
    while (1 < i && heap[parent(i)] < heap[i]) {
        std::swap(heap[parent(i)], heap[i]);
        i = parent(i);
    }
}

int PriorityQueue::extract_max() {
    int max = heap[1];
    heap[1] = heap[size];
    size--;
    max_heapify(heap, 1);

    return max;
}

void PriorityQueue::max_heapify(int heap[], int i) {
    int il = left(i);
    int ir = right(i);

    int max_i = i;
    if (il <= size && heap[i] < heap[il])
        max_i = il;
    if (ir <= size && heap[max_i] < heap[ir])
        max_i = ir;

    if (max_i != i) {
        std::swap(heap[i], heap[max_i]);
        max_heapify(heap, max_i);
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    PriorityQueue pq;
    int key;
    std::string command;

    while(true) {
        std::cin >> command;
        if (command == "insert") {
            std::cin >> key;
            pq.insert(key);
        }
        else if (command == "extract") {
            std::cout << pq.extract_max() << "\n";
        }
        else if (command == "end") {
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int result;

		switch (n) {
		case 0:
		case 2:
			result = 1;
			break;
		case 1:
			result = 2;
			break;
		default:
			result = 0;
			break;
		}
		
		System.out.println(result);
	}

}



Measured memory_bytes: 26416
using System;

class program
{
    public static int Main()
    {
        var count = 0;
        while (true)
        {
            count++;
            var i = int.Parse(Console.ReadLine());
            if (i == 0) break;
            Console.WriteLine("Case {0}: {1}", count, i);
        }

        return 0;
    }
}

Measured memory_bytes: 5772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int t=0;
  for (int i = 0; i < 3; i++) {
    if(S.at(i)==T.at(i)){
      t ++;
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

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

Measured memory_bytes: 3648
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            StringBuilder S = new StringBuilder(sc.next());
            int N = sc.nextInt();
            for (int i = 0; i < N; i++) {
                String operator = sc.next();
                int a = sc.nextInt(), b = sc.nextInt() + 1;
                if (operator.equals("print")) {
                    System.out.println(S.substring(a, b));
                } else if (operator.equals("reverse")) {
                    S.replace(a, b, (new StringBuilder(S.substring(a, b))).reverse().toString());
                } else {
                    String x = sc.next();
                    S.replace(a, b, x);
                }
            }
        }
    }

}



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

int main() {
  ll n; cin>> n;
  vector<ll> v(n);
  rep(i,n){cin>>v[i];}
  vector<ll> dp(n);
  dp[0]=0;
  rep(i,n-1){
    if(i==0){dp[i+1]=dp[i]+abs(v[1]-v[0]);}
    else{
      dp[i+1]= min(dp[i]+abs(v[i+1]-v[i]), dp[i-1]+abs(v[i+1]-v[i-1]) );
    }
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 4792
#include <stdio.h>
int main(){
  int i,j,N,k,p;
  int v[1000];
  scanf("%d",&N);
  for(i=0; i < N;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i< N;i++){
    k=v[i];
    j=i-1;
    while(j>= 0 && v[j] > k){
      v[j+1]=v[j];
      j--;
      v[j+1]=k;
    }
    for(p=0;p < N ;p++){
        if (p<N-1) {
      printf("%d ",v[p]);
        } else {
            printf("%d",v[p]);
        }
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2072
function Main(input){
	var xs = input.trim().split('\n');
    //console.log(xs[1][2]);
    if(xs[0][0]==xs[1][2] && xs[1][0]==xs[0][2] && xs[0][1]==xs[1][1]){
    console.log('YES');
    }else{
    console.log('NO');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

ll mod_pow(int x, int n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * (ll)x % MOD;
  return res;
}

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

  string N;
  int K;
  cin >> N >> K;
  int t = N.size();
  ll dp0[101][4];
  ll dp1[101][4];
  rep(i, t) {
    dp0[i][0] = 1;
    dp1[i][0] = 0;
  }
  dp0[0][1] = N[0]-'1';
  dp1[0][1] = 1;
  dp0[0][2] = 0;
  dp1[0][2] = 0;
  dp0[0][3] = 0;
  dp1[0][3] = 0;
  // cout << dp0[0][1] <<  ' ' << dp1[0][1] << endl;
  for (int i = 1; i < t; i++) {
    for (int j = 1; j <= 3; j++) {
      if (N[i] == '0') {
        dp0[i][j] = 9*dp0[i-1][j-1]+dp0[i-1][j];
        dp1[i][j] = dp1[i-1][j];
      }
      else {
        dp0[i][j] = 9*dp0[i-1][j-1]+dp0[i-1][j]+(N[i]-'1')*dp1[i-1][j-1]+dp1[i-1][j];
        dp1[i][j] = dp1[i-1][j-1];
      }
    }
  }
  // rep(i, t) {
  //   repto(j, 3) {
  //     cout << dp0[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  // rep(i, t) {
  //   repto(j, 3) {
  //     cout << dp1[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  cout << dp0[t-1][K]+dp1[t-1][K] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound

using namespace std;

int main(){
    int N;
    int s[101];
    while(1){
        cin >> N;
        if(N==0){
            break;
        }
        for(int i=0;i<N;i++){
            cin >> s[i];
        }
        int ans=0;
        int MAX=s[0],min=s[0];
        for(int i=0;i<N;i++){
            if(MAX<s[i]){
                MAX=s[i];
            }
            if(min>s[i]){
                min=s[i];
            }
        }
        for(int i=0;i<N;i++){
            ans+=s[i];
        }
        ans-=MAX;
        ans-=min;
        cout << ans/(N-2) << endl;
    }
    return 0;
}



Measured memory_bytes: 3000
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCoder
{
	public class Program
	{
		public static void Main()
		{
			System.IO.StreamWriter sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			new Program().Solve(new ConsoleInput(Console.In, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin)
		{
			int s = cin.ReadInt;
			int w = cin.ReadInt;
			WriteLine(s <= w ? "unsafe" : "safe");
		}
		public class ConsoleInput
		{
			private readonly System.IO.TextReader _stream;
			private readonly char _separator = ' ';
			private readonly Queue<string> inputStream;
			public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
			{
				_separator = separator;
				_stream = stream;
				inputStream = new Queue<string>();
			}
			public string Read
			{
				get
				{
					if (inputStream.Count != 0)
					{
						return inputStream.Dequeue();
					}
					string[] tmp = _stream.ReadLine().Split(_separator);
					for (int i = 0; i < tmp.Length; ++i)
					{
						inputStream.Enqueue(tmp[i]);
					}
					return inputStream.Dequeue();
				}
			}
			public string ReadLine => _stream.ReadLine();
			public int ReadInt => int.Parse(Read);
			public long ReadLong => long.Parse(Read);
			public double ReadDouble => double.Parse(Read);
			public string[] ReadStrArray(long N) { string[] ret = new string[N]; for (long i = 0; i < N; ++i) { ret[i] = Read; } return ret; }
			public int[] ReadIntArray(long N) { int[] ret = new int[N]; for (long i = 0; i < N; ++i) { ret[i] = ReadInt; } return ret; }
			public long[] ReadLongArray(long N) { long[] ret = new long[N]; for (long i = 0; i < N; ++i) { ret[i] = ReadLong; } return ret; }
		}
	}
}

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

int k[3];
signed main(){
	string a;cin>>a;
	for(char i:a){
		k[i-'a']++;
		}
	sort(k,k+3);
	if(k[2]-k[0]<=1)puts("YES");
	else puts("NO");	
	}


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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  int64_t O, P;
  O = N / (A + B);
  P = N % (A + B);

  if(P <= A){
      cout << (O * A + P) << endl;
  }else{
      cout << (O * A + A) << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int A[3][3];
	int N;
	int b[10];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}

	bool is_selected[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			is_selected[i][j] = false;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A[j][k] == b[i]) {
					is_selected[j][k] = true;
				}
			}
		}
	}

	if (is_selected[0][0] && is_selected[0][1] && is_selected[0][2]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[1][0] && is_selected[1][1] && is_selected[1][2]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[2][0] && is_selected[2][1] && is_selected[2][2]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[0][0] && is_selected[1][0] && is_selected[2][0]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[0][1] && is_selected[1][1] && is_selected[2][1]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[0][2] && is_selected[1][2] && is_selected[2][2]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[0][0] && is_selected[1][1] && is_selected[2][2]) {
		cout << "Yes\n";
		return 0;
	}
	if (is_selected[0][2] && is_selected[1][1] && is_selected[2][0]) {
		cout << "Yes\n";
		return 0;
	}

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

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m,l;
int d[305][305];
vector <pair<int,int>> v[305];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> l;
    int x,y,z;
    for(int i = 1;i <= m;i++) {
        cin >> x >> y >> z;
        v[x].push_back({y,z});
        v[y].push_back({x,z});
    }
    priority_queue <pair<pair<int,int>,int>> q;
    int c[305];
    for(int i = 1;i <= n;i++) {
        q.push({{0,0},i});
        memset(c,0,sizeof(c));
        while(!q.empty()) {
            x = -q.top().first.first;
            y = -q.top().first.second;
            z = q.top().second;
            q.pop();
            if(c[z]) continue;
            c[z] = 1;
            d[i][z] = x;
            for(auto k : v[z]) {
                if(c[k.first]) continue;
                if(k.second > l) continue;
                if(y + k.second > l) {
                    q.push({{-x-1,-k.second},k.first});
                }
                else q.push({{-x,-y-k.second},k.first});
            }
        }
        for(int j = 1;j <= n;j++) {
            if(c[j] == 0) d[i][j] = -1;
        }
    }
    int qq;
    cin >> qq;
    while(qq--) {
        cin >> x >> y;
        cout << d[x][y] << '\n';
    }
}

#endif


Measured memory_bytes: 2684
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b >> c;


    if( (b*10+c)%4  ) cout << "NO"; 
    else cout << "YES";
    return 0;
}

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

int main()
{
    int c1, c5, c10, c50, c100, c500;

    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

    if ( c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 >= 1000 ) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return ( 0 );
}



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

int main() {
    int x, y;
    cin >> x >> y;

    rep(i,100) {
        rep(j,100) {
            if ((2*i + 4 *j == y) && i + j == x) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;

}

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

long double n;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (ll i = 1; i <= 3500; i++) {
        for (ll j = 1; j <= 3500; j++) {
            ll t = n * i * j;
            ll b = 4*i*j - n*j - n*i;
            if (b > 0 && !(t % b)) {
                cout << i << ' ' <<  j << ' ' << t / b;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 256
/*
A3001.c
*/

#include <stdio.h>
#include <stdlib.h>
int n;
struct jk_st
{
  double gpa;
  int point;
  int order;
} data[100000];
  
int compA( const void * a , const void * b ) {

  if( ((struct jk_st * )a)->gpa > ((struct jk_st * )b)->gpa)
    return -1;

  else
    if( ((struct jk_st * )a)->gpa == ((struct jk_st * )b)->gpa)
    return 0;
  
  return 1;
}
int compB( const void * a , const void * b ) {

  if( ((struct jk_st * )a)->order < ((struct jk_st * )b)->order)
    return -1;

  else
    if( ((struct jk_st * )a)->order == ((struct jk_st * )b)->order)
    return 0;
  
  return 1;
}


void solve()
{
  int i,j,acc,same,pt;
  double prev;
  prev=data[0].gpa;same=1;
  acc=1;
  for(i=1,acc=0;i<=n;i++)
    {
      if(i==n || data[i].gpa!=prev)
      {
	acc += same;
	pt =(n-acc)*3+(same-1);

	for(j=1;j<=same;j++)
	  data[i-j].point=pt;
	same=1;
      }
      else
      	same++;
      

      prev=data[i].gpa;
      //printf("i=%d same=%d\n",i,same);
    }
}

void dump()
{ int i;
  for(i=n-1;i>=n-30;i--)
    printf("%d:%lf[%d][%d]\n",i,data[i].gpa,data[i].point,data[i].order);
}
void output()
{ int i;
  for(i=0;i<n;i++)
    printf("%d\n",data[i].point);
}

int main()
{
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%lf",&(data[i].gpa));
      data[i].order=i;
    }
  qsort(data,n,sizeof(struct jk_st),compA);
  
  solve();
  //dump();  
  qsort(data,n,sizeof(struct jk_st),compB);

  output();
  return(0);
}



Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, T;
  cin >>N >>T;
  vector<int> Z(N, 0);
  for(int i=0; i<N; i++){
    int a;
    cin>>a;
    Z[i]=a;
  }
  long long ans=0;
  for(int i=N-1; i>0; i--){
    ans+=min(Z[i]-Z[i-1], T);
  }
  ans+=T;
  cout << ans << endl;
}

Measured memory_bytes: 1024
from collections import deque
sa=deque(input())
sb=deque(input())
sc=deque(input())
player=[(sa, "A"),
        (sb, "B"),
        (sc, "C")]
card={"a":0,
      "b":1,
      "c":2}
next_p=0

while True:
    p=player[next_p]
    s=p[0]
    if len(s)<=0:
        win=p[1]
        break

    next_p=card[s.popleft()]

print(win)

Measured memory_bytes: 3316