akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
	char n;
	char a[20];
	int k = 0;
	memset(a, 0, sizeof(a));
	while(scanf("%c", &n) != EOF)
	{
		if(n == '0')
		{
			a[k] = '0';
			k++;
			}
		if(n == '1')
		{
			a[k] = '1';
			k++;
			}
		if(n == 'B')
		{
			if(k != 0)
			k--;
			}
		}
	for(int i = 0; i < k; i++)
	{
		printf("%c", a[i]);
		}
	printf("\n");
	}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;


int main() {
    int n, x;
    cin >> n >> x;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);
    cout << (x - accumulate(vec.begin(), vec.end(), 0)) / *min_element(vec.begin(), vec.end()) + n << endl;
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    cout << ceil((double)(n-k)/(k-1))+1 << '\n';
}

Measured memory_bytes: 640
a,b,c,d=map(int, input().split())

if a==b:
    if c==d:
        print("yes")
    else:
        print("no")
elif a==c:
    if b==d:
        print("yes")
    else:
        print("no")
elif a==d:
    if b==c:
        print("yes")
    else:
        print("no")
else:
    print("no")


Measured memory_bytes: 5596
#include <stdio.h>

int main(void)
{
    int n, a[5000], i, j, k;
    long long int sum, max;
    
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        for (i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }
        sum = 0;
        for (i = 0; i < n; i++) {
            for (j = i; j < n; j++) {
                sum += a[j];
                if (i == 0 && j == 0) {
                 max = sum;
                } else {
                    if (max < sum)
                        max = sum;
                }
            }
            sum = 0;
        }
        printf("%lld\n", max);
    }
    return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n, t; cin >> n >> t;
	vector<int>A(n);
	for (int i = 0; i < n; i++)cin>>A[i];

	vector<int>x;
	int Max = 0;
	for (int i = n - 1; i >= 0; i--) {
		Max = max(Max, A[i]);
		x.push_back(Max - A[i]);
	}
	sort(x.begin(), x.end(), greater<int>());
	int X = x[0];
	int cnt = 1;
	for (int i = 1; i < n; i++) {
		if (x[i] == x[i - 1])cnt++;
		else break;
	}
	cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char s[N];
int main(){
	scanf("%s",s);
	int a=0,b=1e9,c=0,d=0,l=strlen(s),x;
	for(l--;~l;l--){
		x=s[l]-'0';
		c=min(a+x,b+x+1);
		d=min(a+10-x,b+10-x-1);
		a=c,b=d;
	}
	printf("%d",min(a,b+1));
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  rep (i, 0, n)
    cin >> p.at(i);
  
  int ans = 0;
  int min = 200001;
  
  rep (i, 0, n) {
    if (min > p.at(i)) {
      ans++;
      min = p.at(i);
    }
  }  

  cout << ans << endl;
  
}


Measured memory_bytes: 1024
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[10];
int main(){
	scanf("%s",in);
	if(in[2]==in[3]&&in[4]==in[5])printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N,x,ans;
	x = 0;
	ans = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I')x++;
		else if (S[i] == 'D')x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//Δ_B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 55;
int n,a[N],b[N];
map<pair<int,int>,int> M;
map<pair<int,int>,int>::iterator it;
int main()
{
	int i,j;
	cin>>n;
	for(i=1;i<=n;i=i+1)
		cin>>a[i]>>b[i];
	for(i=1;i<=n;i=i+1)
		for(j=1;j<=n;j=j+1)
			if(i!=j)
				M[make_pair(a[i]-a[j],b[i]-b[j])]++;
	i=0;
	for(it=M.begin();it!=M.end();it++)
		i=max(i,(*it).second);
	cout<<n-i;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dp[3001][3001];

int main() {
  string S,T; cin>>S>>T;
  int N = S.size(), M = T.size();

  rep(i,N) rep(j,M) {
    chmax(dp[i+1][j+1], dp[i+1][j]);
    chmax(dp[i+1][j+1], dp[i][j+1]);
    chmax(dp[i+1][j+1], dp[i][j]+(S[i]==T[j]));
  }
  string ans;
  while (N>0 && M>0) {
    if (dp[N][M] == dp[N-1][M]) N--;
    else if (dp[N][M] == dp[N][M-1]) M--;
    else {
      ans = S[N-1] + ans;
      N--;
      M--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35456
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

signed main()
{
  ios::sync_with_stdio(false);

  int m;
  while (cin >> m, m){
    int card[7], num[7];
    int dp[1001][8] = {1, 0};
    REP(i, m) cin >> card[i] >> num[i];

    REP(i, m){
      REP(j, 1001){
        REP(k, num[i] + 1){
          if (j + card[i] * k > 1000) continue;
          dp[j + card[i] * k][i + 1] += dp[j][i];
        }
      }
    }

    int g;
    cin >> g;
    REP(i, g){
      int n;
      cin >> n;
      print(dp[n][m]);
    }
  }

  return (0);
}

Measured memory_bytes: 1228
import sys
from io import StringIO
import unittest
import os
import itertools

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def triangle(a, b, c):
    # 三角形が存在するか確認
    if a + b > c and b + c > a and c + a > b:
        # 直角三角形
        if a ** 2 == b ** 2 + c ** 2:
            return 0
        # 鋭角三角形
        elif a ** 2 < b ** 2 + c ** 2:
            return 1
        # 鈍角三角形
        elif a ** 2 > b ** 2 + c ** 2:
            return 2
    else:
        # 三角形が存在しない
        return 3


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n = int(input())
    l_s = list(map(int, input().split()))
    l_s.sort()

    # l_s = list(set(l_s))
    # aaa = list(itertools.combinations(l_s, 3))

    cnt = 0
    aaa = list(range(n))

    for a in aaa:
        an = l_s[a]
        for b in aaa[a + 1:]:
            bn = l_s[b]
            if an == bn:
                continue
            for c in aaa[b + 1:]:
                cn = l_s[c]
                if bn == cn:
                    continue
                if triangle(an, bn, cn) < 3:
                    cnt += 1
    print(cnt)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5
4 4 9 7 5"""
        output = """5"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """6
4 5 4 3 3 5"""
        output = """8"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """10
9 4 6 1 9 6 10 6 6 8"""
        output = """39"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """2
1 1"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 72388
/*{{{*/
#include<bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPR(I, N) for (int I = (N)-1; I >= 0; --I)
#define REPPR(I, A, B) for (int I = (A); I >= (B); --I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL& x, LL v) {x = (x + v) % MOD; if (x < 0)x += MOD;}
/*}}}*/
void solve() {
	int n, k;
	R(n, k);
	int ans=0;
	while(n>0){
		n/=k;
		ans++;
	}
	W(ans);
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 int n;string s;
int a[999],b[999];
int ans=0;
void solve()
{
   int n;string s;cin>>n>>s;
   int t=0;
   rep(i,1,n)t+=(s[i]=='E');
   int ans=INF;
   REP(i,n)
   {
       ans=min(ans,t);
       t+=(s[i]=='W')-(s[i+1]=='E');
   }
   cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> a(n);
	if(s == 1e9){
		rep(i, 0, n){
			if(i < k) a[i] = s;
			else a[i] = 1;
		}
	}else{
		rep(i, 0, n){
			if(i < k) a[i] = s;
			else a[i] = 1e9;
		}
	}
	for(int ii = 0; ii < a.size(); ii++){
			if(ii) cout << ' ';
			cout << a[ii];
	}
	cout << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=2e5+9;
	int a[N],m,v,p,n,ans,sum[N];
	int main(){
		n=read<int>(),m=read<int>(),v=read<int>(),ans=p=read<int>();
		for(int i=1;i<=n;i++) a[i]=read<int>();
		sort(a+1,a+n+1);
		for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	//	for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
		for(int i=1;i<=n-p;i++){
			if(m+a[i]<a[n-p+1]) continue;
			else{
				int tmp=(p-1+i)*m+((n-p+1-i)*(a[i]+m)-(sum[n-p+1]-sum[i]));
			//	cout<<tmp<<endl;
				if(tmp>=m*v) ans++;
			}
		}
		printf("%lld\n",ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 1792
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let a=t.n(n)
  let ans=0
  for(let i=0;i<n;i++){
    ans+=1/a[i]
  }
  t.o(1/ans)
}
main()

Measured memory_bytes: 7500
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	L := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		L[i] = sc.NextInt()
		sum += L[i]
	}
	for i := 0; i < N; i++ {
		if sum-L[i] <= L[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int n;
    int a[200000];
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);

    int max=0;
    int maxi;
    for(int i=0;i<n;i++)
    {
        if(max<a[i]) {
            max=a[i];
            maxi=i;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(i==maxi)
        {
            int m=0;
            for(int j=0;j<n;j++)
            {
                if(m<a[j]&&j!=maxi)
                {
                    m=a[j];
                }
            }
            if(m==0) printf("%d\n",max);
            else printf("%d\n",m);
        }
        else{
            printf("%d\n",max);
        }
    }
}

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


int main() {
    string s;
    cin >> s;
    int a=0;
    int b=0;
    for(int i=0;i<3;i++){
        if('A'==s[i]){
            a++;
        }else if('B'==s[i]){
            b++;
        }
    }
    if(a==3||b==3){
        cout << "No" << endl;
        return 0;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto x = readln.chomp.split.to!(int[]);
  auto sum = long.max;
  foreach (i; 0..100) {
    long lsum;
    foreach (e; x) {
      lsum += (i - e) ^^ 2;
    }
    sum = min(sum, lsum);
  }
  sum.writeln;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    X = Scanner.int()
    X -= 400
    print(8 - X // 200)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10776
def simple_calculator():
	x, y = map(int, raw_input().split(" "))
	numofpushbuttonA = abs(abs(x)-abs(y))
	if abs(x)<abs(y):
		if x*y==0:
			if y>0:
				print numofpushbuttonA
			else:
				print numofpushbuttonA+1
		elif x*y>0:
			if x>0:
				print numofpushbuttonA
			else:
				print numofpushbuttonA+2
		else:
				print numofpushbuttonA+1
	else:
		if x*y==0:
			if x>0:
				print numofpushbuttonA+1
			else:
				print numofpushbuttonA
		elif x*y>0:
			if x<0:
				print numofpushbuttonA
			else:
				print numofpushbuttonA+2
		else:
			print numofpushbuttonA + 1


if __name__ == "__main__":
	simple_calculator()

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;

    deque<char> que;
    rep(i, s.length()) que.push_back(s[i]); 

    bool rev = false;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) rev = 1-rev;
        else {
            int f;
            char c;
            cin >> f >> c;
            --f;
            if (f^rev) que.push_back(c);
            else que.push_front(c);
        }
    }
    
    string ans = "";
    while (!que.empty()) {
        if (rev) {
            ans += que.back();
            que.pop_back();
        }
        else {
            ans += que.front();
            que.pop_front();
        }
    }

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

Measured memory_bytes: 1412
using System;
using System.Linq;

namespace id_0511cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var checkSubmitted = Enumerable.Repeat(false, 30).ToArray();
            foreach(var i in Enumerable.Range(0, 28))
            {
                checkSubmitted[int.Parse(Console.ReadLine()) - 1] = true;
            }
            var notSubmitted1 = checkSubmitted.ToList().FindIndex(x => x == false);
            var notSubmitted2 = checkSubmitted.ToList().FindLastIndex(x => x == false);
            Console.WriteLine(notSubmitted1 + 1);
            Console.WriteLine(notSubmitted2 + 1);
        }
    }
}



Measured memory_bytes: 9384
#include <stdio.h>

#define MAX_SIZE 100

int main(void)
{
    //宣言
    int arr[MAX_SIZE];      //数列の入力用
    int reverse[MAX_SIZE];  //数列の出力用
    int size;               //数列の長さ
    int i;                  //for文用 
    int arrIndex, revIndex; //数列の並べ替え用

    //数列の長さの決定
    scanf("%d", &size);

    //制約の範囲外ならエラーメッセージを出力
    if(size > MAX_SIZE)
    {
        printf("Invalid Input\n");
        return 0;
    }

    for(i=0; i<size; i++)
    {
        scanf("%d",&arr[i]);
    }

    revIndex = 0;
    arrIndex = size - 1;

    //数列を並べ替える
    while(arrIndex >= 0)
    {
        reverse[revIndex] = arr[arrIndex];

        revIndex++;
        arrIndex--;
    }

    //数列の出力
    for(i=0; i<size; i++)
    {
        if(i==size-1)
        {
            printf("%d",reverse[i]);
        }
        else
        {
            printf("%d ",reverse[i]);
        }
    }

    printf("\n");

    return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>

int main(void){
  long int n,a,b;
  scanf("%ld%ld%ld",&n,&a,&b);
  long int p;
  
  if(a==0&&b==0){
    printf("0");
    return 0;
  }
  
  if(n%(a+b)<a){
    p=n%(a+b);
  }else{
    p=a;
  }
  
  printf("%ld",(n/(a+b))*a+p);
  
  return 0;
}

Measured memory_bytes: 128
/*
 #pragma GCC target ("avx2")
 #pragma GCC optimize ("Ofast")
 #pragma GCC optimize ("unroll-loops")
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#define F first
#define S second
#define pb push_back
using namespace std;
const long long N = 2e5 + 10;
long long a[N],cnt[N];
int  main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    long long sum=0;
    for(long long i=1;i<=n;i++){
        sum+=(cnt[i]*(cnt[i]-1))/2;
    }
    for(long long i=1;i<=n;i++){
        long long k=(cnt[a[i]]*(cnt[a[i]]-1))/2;
        long long k2=((cnt[a[i]]-1)*(cnt[a[i]]-2))/2;
        cout<<sum-k+k2<<'\n';
    }
    return 0;
}


Measured memory_bytes: 4736
S =list(map(str, input()))
n=0

if len(S)%2 ==0:
	for i in range(int(len(S)/2)):
		if S[i]!=S[len(S)-1-i]:
			n +=1
	print(n)
else:
	for i in range(int((len(S)-1)/2)):
		if S[i]!=S[len(S)-1-i]:
			n +=1
	print(n)
	

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

using namespace std;

int n;
int a[2007], b[2007], p[2007], h[2007];
vector<int> ch[2007];

// 0 - white
// 1 - red
// 2 - blue
int type[2007];
int cntred = 0;
bool active[2007];

vector<int> res;

void rotate(int w) {
	res.push_back(w);
	memcpy(b, a, sizeof a);
	b[w] = a[0];
	while(w) {
		b[p[w]] = a[w];
		w = p[w];
	}
	memcpy(a, b, sizeof b);
}

void dfs(int w) {
	active[w] = 1;
	for(int u : ch[w])
		dfs(u);
	
	if(ch[w].size() == 0
		|| (ch[w].size() == 1 && type[ch[w][0]] == 1)) {
			type[w] = 1;
			cntred++;
		}
}

void dfs2(int w) {
	for(int u : ch[w]) {
		h[u] = h[w] + 1;
		dfs2(u);
	}
}

mt19937 rng(time(0));

int rand(int a, int b) {
	return uniform_int_distribution<int>(a, b)(rng);
}

int main() {
	scanf("%d", &n);
	//~ n = 2000;
	for(int i = 1 ; i < n ; i++) {
		scanf("%d", &p[i]);
		//~ p[i] = rand(0, i - 1);
		//~ cout << p[i] << " ";
		ch[p[i]].push_back(i);
	}
	dfs2(0);
	for(int i = 0 ; i < n ; i++)
		scanf("%d", &a[i]);
		//~ a[i] = i;
	//~ shuffle(a, a + n, rng);
				int cn = 0;
	while(ch[0].size()) {
		memset(type, 0, sizeof type);
		memset(active, 0, sizeof active);
		cntred = 0;
		dfs(0);
		if(type[0] == 1)
			cntred--;
		type[0] = 0;
		//~ cout << "dfs" << endl;
		//~ for(int i = 0 ; i < n ; i++)
			//~ cout << type[i] << " " ;
		//~ cout << endl;

		while(cntred) {
			cn++;	
			//~ cout << "it" << " " << cn << endl;
			
			//~ for(int i = 0 ; i < n ; i++)
				//~ cout << "in vertex " << i << " there is a ball color " << type[a[i]] << " number " << a[i] << endl;
			//~ cout << endl;

			
			if(type[a[0]] == 1) {
				int w = a[0];
				while(type[p[w]] == 1 || type[p[w]] == 2)
					w = p[w];
				while(!ch[w].empty() && (type[a[ch[w][0]]] != 2
					|| (type[a[ch[w][0]]] == 2 && h[a[ch[w][0]]] < h[a[0]])))
						w = ch[w][0];
						
				cntred--;
				type[a[0]] = 2;
				rotate(w);
			} else {
				int w = 0;
				for(int i = 1 ; i < n ; i++)
					if(type[a[i]] < 2 && h[i] > h[w] && active[i])
						w = i;
				type[a[0]] = 3;
				rotate(w);
			}
			
			//~ if(cn > 100)
				//~ exit(0);
		}
		
		for(int i = 0 ; i < n ; i++) {
			if(type[a[i]] == 2) {
				ch[p[i]].erase(find(ch[p[i]].begin(), ch[p[i]].end(), i));
			}
		}
	}
	
	printf("%d\n", res.size());
	for(int x : res)
		printf("%d\n", x);
	
	return 0;
}


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

#define endl '\n'

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

  string s;
  cin >> s;

  if(s=="ABC")
    cout<<"ARC";
  else
    cout<<"ABC";

  return 0;

}


Measured memory_bytes: 3616
from heapq import heappush, heappop
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    W, H, N = map(int, readline().split())
    if W == H == N == 0:
        return False
    MP = [[0]*W for i in range(H)]

    S = [(i-2, i-2) for i in range(3)]
    T = [(i-2, i-2) for i in range(3)]
    for i in range(H):
        s = readline().strip()
        for j, c in enumerate(s):
            if c == '#':
                MP[i][j] = 1
            elif c != ' ':
                idx = "abcABC".find(c)
                if idx < 3:
                    S[idx] = (j, i)
                else:
                    T[idx-3] = (j, i)

    dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
    que = deque([S[0] + (0,)])
    MM = {S[0]: 0, (-1, -1): -2, (0, 0): -1}
    sx, sy = S[0]
    U = [[0]*W for i in range(H)]
    U[sy][sx] = 1
    G = [[0]]
    cur = 1
    while que:
        x, y, v = que.popleft()
        for dx, dy in dd:
            nx = x + dx; ny = y + dy
            if MP[ny][nx] or U[ny][nx]:
                continue
            U[ny][nx] = 1
            MM[nx, ny] = cur
            que.append((nx, ny, cur))
            G.append([cur, v])
            G[v].append(cur)
            cur += 1
    MM[-1, -1] = len(G); G.append([len(G)])
    MM[0, 0] = len(G); G.append([len(G)])
    a0 = MM[S[0]]; b0 = MM[S[1]]; c0 = MM[S[2]]
    a1 = MM[T[0]]; b1 = MM[T[1]]; c1 = MM[T[2]]

    L = cur+2
    def check(s):
        que = deque([s])
        D = [-1]*L
        D[s] = 0
        while que:
            v = que.popleft()
            nd = D[v]+1
            for w in G[v]:
                if D[w] != -1:
                    continue
                D[w] = nd
                que.append(w)
        return D

    D1 = check(a1); D2 = check(b1); D3 = check(c1)
    INF = 10**18

    hcost = max(D1[a0], D2[b0], D3[c0])
    D = {(a0, b0, c0): 0}
    que = [(hcost, 0, a0, b0, c0)]
    g_key = (a1, b1, c1)
    push = heappush; pop = heappop
    while que:
        hcost, cost, a, b, c = pop(que)
        key = (a, b, c)
        if key == g_key:
            break
        if D[key] < cost:
            continue
        nd = cost+1
        for na in G[a]:
            d1 = D1[na]
            for nb in G[b]:
                if na == nb or (nb == a and na == b):
                    continue
                d2 = D2[nb]
                for nc in G[c]:
                    if na == nc or nb == nc or (nc == a and na == c) or (nc == b and nb == c):
                        continue
                    n_key = (na, nb, nc)
                    if nd < D.get(n_key, INF):
                        D[n_key] = nd
                        hcost = max(d1, d2, D3[nc]) + nd
                        push(que, (hcost, nd, na, nb, nc))
    write("%d\n" % D[g_key])
    return True
while solve():
    ...


Measured memory_bytes: 126620
use proconio::input;
use std::collections::{HashMap, VecDeque};
 
fn main() {
  input! {
    n: usize,
    k: usize,
    mut vals: [usize;n]
  }
  
  if n <= k {
    println!("1");
  } else {
    let mut val = (n - k) / (k - 1) + 1;
    if (n - k) % (k - 1) > 0 {
      val += 1;
    }
    println!("{}", val); 
  }
}

Measured memory_bytes: 3208
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  N = int(input())
  Pn = list(map(int, input().split()))
  Tn = list(map(int, input().split()))
  dp = [int(10001) for _ in range(N+1)]
  dp[0] = 0

  for i in range(1,N+1):
    for j in range(4):
      if Tn[j] > i:
        dp[i] = min(dp[i],Pn[j])
      else:
        dp[i] = min(dp[i],dp[i-Tn[j]]+Pn[j])
  print(dp[N])

if __name__ == "__main__":
  main()


Measured memory_bytes: 5612
N,M=map(int,input().split())
dw=dict()
da=dict()
for i in range(M):
    k,v=input().split()
    if k not in da.keys():
        if v=="WA":
            if k in dw.keys():
                dw[k]+=1
            else:
                dw[k]=1
        else:
            da[k]=1
for k in dw.keys():
    if k not in da.keys():
        dw[k]=0
print(sum(da.values()),sum(dw.values()))

Measured memory_bytes: 17116
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e6+5;
char a[N],b[N];int q[N],h,t,n,res;
int main(){
	scanf("%d%s%s",&n,a+1,b+1);
	if(!strcmp(a+1,b+1))return puts("0"),0;
	h=1,t=0;
	for(R int i=n,p=n;i;--i)if(b[i]!=b[i-1]){
		cmin(p,i);while(p&&a[p]!=b[i])--p;
		if(!p)return puts("-1"),0;
		while(h<=t&&q[h]-(t-h+1)>=i)++h;
		q[++t]=p;
		if(i!=p)cmax(res,t-h+1);
	}
	printf("%d\n",res+1);
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    ll p = N-1;
    for(int i=2; pow(i, 2)<=N; i++){
        if(N%i==0){
            if((N/i-1) + i -1 < p){p = (N/i-1) + i -1 ;}
            else{break;}
        }else{continue;}
    }
    cout << p;
}

Measured memory_bytes: 384
x, y=map(int, input().split())
if x==1:
  a=300000
elif x==2:
  a=200000
elif x==3:
  a=100000
else:
  a=0
  
if y==1:
  b=300000
elif y==2:
  b=200000
elif y==3:
  b=100000
else:
  b=0
  
if x==1 and y==1:
  c=400000
else:
  c=0
  
print(a+b+c)

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

typedef complex<double> P;
const double eps = 1e-10;
const double inf = 1e10;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

namespace std {
  bool operator < (const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

P project(P s1, P s2, P p) {
  P base = s2 - s1;
  double t = dot(p - s1, base)/norm(base);
  return s1 + base*t;
}

P reflect(P s1, P s2, P p) {
  return p + (project(s1, s2, p) - p)*2.0;
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 &&
           ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0 );
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 -a1)/cross(b, a);
}

int main() {
  int N;
  P s;
  vector<P> g;
  while(cin >> N && N) {
    g.resize(N);
    cin >> s.real() >> s.imag();
    for(int i = 0; i < N; ++i) {
      cin >> g[i].real() >> g[i].imag();
    }

    vector<pair<P,P> > seg;
    for(int i = 0; i < N; ++i) {
      seg.push_back(make_pair(g[i], g[(i+1)%N]));
    }
    sort(seg.begin(), seg.end());
    int res = 0;
    do {
      try {
        vector<pair<P,P> > t = seg;
        P A, B;
        for(int i = 0; i < N; ++i) {
          P a = t[i].first;
          P b = t[i].second;
          if(abs(ccw(s,a,b)) != 1) throw 0;
          if(ccw(s,a,b) == -1) swap(a, b);
          if(i == 0) {
            A = a;
            B = b;
          } else {
            if(ccw(s,A,a) ==  1) A = a;
            if(ccw(s,B,b) == -1) B = b;
            if(!(cross(A-s,B-s) > eps)) throw 0; // important
          }
          for(int j = i+1; j < N; ++j) {
            P p = reflect(a, b, t[j].first);
            P q = reflect(a, b, t[j].second);
            t[j] = make_pair(p, q);
          }
        }
        if(cross(A-s,B-s) > eps) ++res;
      } catch(...) {}
    } while(next_permutation(seg.begin(), seg.end()));
    cout << res << endl;
  }
  return 0;
}

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

int main() {
	vector<string> s(3);
	int offset = 'A'-'a';
	rep(i,3)cin>>s[i];
	rep(i,3){
		char a = s[i][0]+offset;
		cout<<a;
	}
	cout<<endl;
}

Measured memory_bytes: 256
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def partition(a, p, r):
    # xがピボット
    x = a[r][1]
    i = p - 1
    for j in range(p, r):
        if a[j][1] <= x:
            i = i + 1
            a[i], a[j] = a[j], a[i]
    a[i+1], a[r] = a[r], a[i+1]
    return i + 1


def quicksort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quicksort(a, p, q-1)
        quicksort(a, q+1, r)


def main():
    n = int(input())
    cards = []
    for i in range(n):
        c = input().split()
        cards.append((c[0], int(c[1])))

    stable_sorted_cards = sorted(cards, key=lambda x: x[1])
    quicksort(cards, 0, n-1)

    if cards != stable_sorted_cards:
        print('Not stable')
    else:
        print('Stable')

    for card in cards:
        print(card[0], card[1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 21416
A=int(input())
B=int(input())

if A==1 and B==2:
    print(3)
if A==2 and B==1:
    print(3)
if A==2 and B==3:
    print(1)
if A==3 and B==2:
    print(1)
if A==1 and B==3:
    print(2)
if A==3 and B==1:
    print(2)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

struct Edge {
  int src, dst;
  ll cost;
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef pair<int, pair<int, ll> > State;

const ll INF = 1LL<<40;

typedef vector<vector<ll> > mat;

void wf(mat &a) {
  const int N = a.size();
  REP(k,N) {
    REP(i,N) {
      REP(j,N) {
	chmin(a[i][j], a[i][k] + a[k][j]);
      }
    }
  }
}

int solve(const Graph &g, const int start, const int goal, const int L) {
  //  cout << "Go... " << start << " " << goal << " " << L << endl;
  const int N = g.size();
  vector<vector<ll> > closed(N, vector<ll>(N+1, 0));
  //  vector<vector<ll> > closed(N, vector<ll>(N+1, INF));
  priority_queue<State, vector<State>, greater<State> > q;
  closed[start][0] = L;
  q.push(make_pair(0, make_pair(start, L)));

  while(! q.empty()) {
    State s = q.top(); q.pop();
    int cnt = s.first;
    int cur = s.second.first;
    ll rem = s.second.second;
    //    cout << "CUR=" << cnt << "," << cur+1 << "," << rem << endl;
    if(cur == goal) {
      return cnt;
    }
    REP(i, g[cur].size()) {
      int nxt = g[cur][i].dst;
      ll cost = g[cur][i].cost;
      ll nrem = rem - cost;
      int ncnt = cnt;
      if(nrem < 0LL) {
	ncnt++;
	nrem = L - cost;
      }
      if(nrem < 0LL) continue;
      //      cout << "NXT=" << ncnt << "," << nxt+1 << "," << nrem << "," << closed[nxt][ncnt] << endl;
      if(closed[nxt][ncnt] > nrem) continue;
      closed[nxt][ncnt] = nrem;
      q.push(make_pair(ncnt, make_pair(nxt, nrem)));
    }
  }
  return -1;
}

int main() {
  int N, M; cin>>N>>M;
  ll L; cin>>L;
  mat cost(N, vector<ll>(N, INF));
  mat move(N, vector<ll>(N, INF));

  REP(i,M) {
    int a, b; ll c; cin>>a>>b>>c; a--; b--;
    if(c <= L) {
      cost[a][b] = cost[b][a] = c;
    }
  }
  wf(cost);
  Graph g = Graph(N);
  REP(a,N) {
    REP(b,N) {
      if(a == b) continue;
      if(cost[a][b] <= L) {
	move[a][b] = 1;
	//	cout << a+1 << "->" << b+1 << "===" << cost[a][b] << endl;
      }
    }
  }

  wf(move);

  int Q; cin>>Q;

  REP(q,Q) {
    int s, t; cin>>s>>t; s--; t--;
    ll ans = move[s][t];
    if(ans >= INF) ans = -1;
    else ans--;
    //cout << "Answer=" << s << " " << t << "=";
    cout << ans << endl;
  }
  return 0;
}


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

class Baggage{
    int* w;
    int  n;
    int top;
public:
    Baggage(int* w_in, int n_in){
        w = w_in;
        n = n_in;
        top = 0;
    }
    bool is_empty(){
        return top == n;
    }
    int front(){
        return w[top];
    }
    void pop(){
        top++;
    }
    void reset(){
        top = 0;
    }
};

class Truck{
    int initial_number;
    int remain_number;
    int p;
    int remain_p;
public:
    Truck(int number){
        initial_number = number;
        remain_number  = number - 1;
    }
    bool exist_next_truck(){
        return remain_number != 0;
    }
    void next_truck(){
        remain_p = p;
        remain_number--;
    }
    bool can_ride(int weight){
        if (remain_p >= weight) {
            return true;
        }
        return false;
    }
    void ride(int weight){
        remain_p -= weight;
    }
    void reset(){
        remain_p = p;
        remain_number = initial_number - 1;
    }

    bool can_ride_all(Baggage baggage, int p_in) {
        p = p_in;
        reset();
        while (!baggage.is_empty()) {
            if (can_ride(baggage.front())) {
                ride(baggage.front());
                baggage.pop();
                continue;
            }
            if (exist_next_truck()) {
                next_truck();
                continue;
            }
            return false;
        }
        return true;
    }

    int search_p(Baggage b, int min_p, int max_p) {
        int mid_p = (min_p + max_p) / 2;
        if (!can_ride_all(b, mid_p)) {
            return search_p(b, mid_p + 1, max_p);
        }
        if (can_ride_all(b, mid_p - 1)) {
            return search_p(b, min_p, mid_p - 1);
        }
        return mid_p;
    }
};


int main(){
    int n, k;
    cin >> n >> k;
    int w[n];
    int max_w = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        if (w[i] > max_w) max_w = w[i];
        sum += w[i];
    }
    Baggage baggage(w, n);
    Truck truck(k);
    cout << truck.search_p(baggage, max_w, sum) << endl;;

    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ll v[MAXN];



void solve(){
	int n;
	cin >> n;
	REP(i, 0, n){
		cin >> v[i];
	}
	ll ans = 0ll;
	while(1){
		int maxi = 0;
		REP(i, 0, n){
			if (v[i] > v[maxi]){
				maxi = i;
			}
		}
		if (v[maxi] < n){
			break;
		}
		ll d = v[maxi] / n;
		v[maxi] -= d * n;
		REP(i, 0, n){
			if (i != maxi){
				v[i] += d;
			}
		}
		ans += d;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
x = int(input())
import math

def primes(n):
    a = [True] * (n + 1)
    a[0] = False
    a[1] = False
    for i in range(2, int(math.sqrt(n))+1):
        for j in range(i * 2, n + 1, i):
            a[j] = False
    return [i for i in range(n + 1) if a[i]==True]

a = primes(x*5)

b = [a[i] for i in range(len(a)) if a[i]>=x]
print(min(b))

Measured memory_bytes: 8620