akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 101010;
int n, m;
int x[N];
int main(){
	scanf("%d%d", &n, &m);
	rep(i, 0, n) scanf("%d", x + i);
	int ans = 1e9;
	for(int l = 0, r = m - 1; r < n; r++, l++) {
		int t = 0;
		if(x[r] <= 0)
			t = abs(x[l]);
		else if(x[l] >= 0)
			t = x[r];
		else {
			t = max(x[r], abs(x[l])) + 2 * min(x[r], abs(x[l]));
		}
		ans = min(ans, t);
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n],b[n], c[n-1];
  for (int i=0; i<n; i++) {
    cin>>a[i];
    --a[i];
  }
  for (int i=0; i<n; i++) cin>>b[i];
  for (int i=0; i<n-1; i++) cin>>c[i];

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

template<typename T>
struct Sum_2D{
  vector<vector<T>>cul;
  bool flag;
  Sum_2D(int h,int w):cul(h+1,vector<T>(w+1)){
    flag=false;
  }

  void add(int x,int y,T val){//0インデックス
    ++x;++y;
    if(x>=cul.size()||y>=cul[0].size())return;
    cul[x][y]+=val;
  }

  void build(){
    flag=true;
    for(int i=1;i<cul.size();++i){
      for(int j=1;j<cul[i].size();++j){
        cul[i][j]+=cul[i][j-1]+cul[i-1][j]-cul[i-1][j-1];
      }
    }
  }

  T query(int lb_x,int lb_y,int ub_x,int ub_y){
    //lb_x,lb_y:左下(含む),ub_x,ub_y:右上(含まない)
    //0インデックスに直す
    assert(flag==true);
    return cul[ub_x][ub_y]-cul[ub_x][lb_y]-cul[lb_x][ub_y]+cul[lb_x][lb_y];
  }
};


void solve(){
  int n,m,q;
  cin>>n>>m>>q;
  vector<int>l(m),r(m);
  rep(i,m)cin>>l[i]>>r[i],l[i]--,r[i]--;
  Sum_2D<int>sum(n+1,n+1);
  rep(i,m){
    sum.add(l[i],r[i],1);
  }
  sum.build();
  while(q--){
    int a,b;//今回はbも含む
    cin>>a>>b;
    a--;
    cout<<sum.query(a,a,b,b)<<"\n";
  }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3584
s=input()
n=len(s)
if n<26:
    check=[False]*26
    for i in range(26):
        if chr(97+i) in s: check[i]=True
    print(s+chr(97+check.index(False)))
if n==26:
    if s[::-1]=='abcdefghijklmnopqrstuvwxyz':
        print(-1)
    else:
        for i in range(n)[::-1]:
            f=False
            l=[]
            for j in range(i,n):
                if s[i]<s[j]:
                    l.append(s[j])
            if l==[]:
                continue
            else:
                l.sort()
                print(s[:i]+l[0])
                f=True
            if f:break
        

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

using namespace std;

int main()
{
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	cout << (a[2] - a[1]) + (a[1] - a[0]) <<endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M, X = map(int, input().split())
C = np.array([[int(i) for i in input().split()] for j in range(N)])

memo = np.array([0 for i in range(M)])

def check(memo):
    for i in memo:
        if i < X:
            return False
    return True

def rec(i, cost, memo):
    if i == N:
        if check(memo):
            return cost
        return float("inf")
    
    # i番目を選ばない    
    # i番目を選ぶ
    return min(rec(i+1, cost, memo), rec(i+1, cost+C[i, 0], memo+C[i, 1:]))

ans = rec(0, 0, memo)
if ans != float("inf"):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        string[] inputs = Console.ReadLine().Split();
        int A = int.Parse(inputs[0]);
        int B = int.Parse(inputs[1]);
        int[] hist = Console.ReadLine().Split()
            .Select(int.Parse)
            .GroupBy(x =>
            {
                if(x <= A)
                    return 0;
                if(x > B)
                    return 2;
                else
                    return 1;
            })
            .Aggregate(new int[3], (ret, item) => {ret[item.Key] = item.Count(); return ret;});
        //Console.WriteLine(string.Join(",",hist));
        Console.WriteLine(hist.Min());
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string S;
	cin >> S;
	int count = 0;
	int ans = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'A')
			count++;
		else if (S[i] == 'T')
			count++;
		else if (S[i] == 'G')
			count++;
		else if (S[i] == 'C')
			count++;
		else
			count = 0;
		ans = max(ans, count);
	}

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    int d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n", d, r, f);
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

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

int main(){
	ll x;
	cin >> x;
	string ans = (x  >= 1200)? "ARC": "ABC";
	cout << ans << endl;

}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#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>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
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;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		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 p[60];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		p[i]--;
	}
	for(int i=0;i<a;i++)for(int j=i;j<a;j++){
		swap(p[i],p[j]);
		bool ok=true;
		for(int k=0;k<a;k++){
			if(p[k]!=k)ok=false;
		}
		if(ok){
			printf("YES\n");return 0;
		}
		swap(p[i],p[j]);
	}
	printf("NO\n");

}

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

int main() {
  int A,B,tmp,tmp2,ans=0;
  cin >> A >> B;
  vector <int>x(5);
  vector <int>y(5);
  for (int i=A;i<=B;i++){
    int j=0;
    tmp=i;
    while(tmp){
      x.at(j)=tmp%10;
      tmp/=10;
      j++;
    }
    y=x;
    reverse(x.begin(),x.end());
    if(x==y)
      ans++;
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 256
MOD=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x_sum=sum((2*i-n+1)*x[i]for i in range(n))
y_sum=sum((2*i-m+1)*y[i]for i in range(m))
print(x_sum*y_sum%MOD)

Measured memory_bytes: 18556
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX 100000

int partition(int *A, int p, int r)
{
    int x = A[r];
    int i, j;
    int tmp;

    i = p - 1;
    for (j= p; j < r; j++)
    {
        if (A[j] <= x)
        {
            i += 1;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;

    return i + 1;
}


int main(void)
{
    int n;
    int A[MAX];
    int q;

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

    q = partition(A, 0, n - 1);

    // if (q == 0)
    // {
    //     printf("[%d]", A[0]);
    // }
    // else
    // {
    //     printf("%d", A[0]);
    // }
    printf("%d", A[0]);
    for (int i = 1; i < n; i++)
    {
        if (i == q)
        {
            printf(" [%d]", A[i]);
        }
        else
        {
            printf("% d", A[i]);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2244
def solve():
    n = int(input())
    a = tuple(int(x) for x in input().split())

    memo = tuple([None] * n for _ in range(n))
    for i in range(n):
        memo[i][i] = a[i]

    for l in range(n - 2, -1, -1):
        for r in range(l + 1, n):
            memo[l][r] = max(a[r] - memo[l][r - 1], a[l] - memo[l + 1][r])

    print(memo[0][n - 1])


if __name__ == '__main__':
    solve()

# [l,r]を
# l:=配列aの右端から左にシフト
# r:=lと一致する位置からn-1まで右にシフト
# と考えると、l==rは既にメモ化済みなので、l=n-2以前、r=l+1以降を調べればよい
# 漸化式で使う値は、
# lがより右にいるときの計算結果（前のループで計算済み）と
# rがより左にいるときの計算結果（一番左でもl==rなので計算済み）
# なので、参照する値がNoneになることはなく、Noneのチェックは不要になる

# enumerateを辞めた


Measured memory_bytes: 179804
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, X = mapint()
burger = [1]*50
pa = [1]*50
for i in range(1, 50):
    burger[i] = burger[i-1]*2+3
    pa[i] = pa[i-1]*2+1

to_eat = X
layer = N
ans = 0
while 1:
    if layer==0:
        ans += to_eat
        break
    if to_eat<=1:
        break
    elif to_eat==burger[layer-1]+2:
        ans += pa[layer-1]+1
        break
    elif to_eat==burger[layer-1]+1:
        ans += pa[layer-1]
        break
    elif to_eat==burger[layer-1]*2+3:
        ans += pa[layer-1]*2+1
        break
    elif to_eat<=burger[layer-1]:
        layer -= 1
        to_eat -= 1
        continue
    else:
        ans += pa[layer-1]+1
        to_eat -= burger[layer-1]+2
        layer -= 1

print(ans)

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

int main() {
  char a[10], b[10];
  cin >> a >> b;
  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 500000 + 233;
const int maxA = (1 << 20) + 233;
const LL P = 1000000007;
int n, a[maxN];
LL f[maxA], g[maxA];

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	a[0] = 0;
	for(int i = 1; i <= n; ++i) cin >> a[i], a[i] ^= a[i - 1];
	// odd length
	memset(f, 0, sizeof(f)); memset(g, 0, sizeof(g));
	f[0] = 1;
	for(int i = 1; i < n; ++i) {
		LL x = f[a[i] ^ a[n]], y = g[a[i] ^ a[n]];
		(f[a[i]] += y) %= P;
		(g[a[i]] += x) %= P;
//		printf("%d: g[%d] += %lld\n", i, a[i], x);
	}
	LL ans = f[0];
//	display(a[n]); display(ans);
	// even length
	if(a[n] == 0) {
		memset(f, 0, sizeof(f)); // sum
		memset(g, 0, sizeof(g)); // sum * cnt
		LL cnt = 0;
		for(int i = 1; i < n; ++i) {
			LL fun = f[a[i]] * cnt - g[a[i]] + 1;
//			printf("fun %d = %lld\n", i, fun);
			fun = (fun % P + P) % P;
			cnt += (a[i] == 0);
			(f[a[i]] += fun) %= P;
			(g[a[i]] += fun * cnt) %= P;
			(ans += fun) %= P;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<ll> A;
vector<int> Binal;

bool chb(int m){
  int x=0;
  for(int i=0;i<N;i++){
    x += max(0,Binal[i]-m);
  }
  return (x <= M);
}

int main()
{
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif

  cin >> N >> M;
  A = fetch_vec<ll>(N);
  Binal.assign(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<=32;j++)
      if(A[i] & (1LL<<j)) Binal[i] = j+1;
  }

  int l=0,r=31;
  while(l<r){
    int m = (l+r)/2;
    if(chb(m))
      r = m;
    else 
      l = m+1;
  }

  REP(i,N) Binal[i] = max(0,Binal[i]-l);
  REP(i,N) A[i] = (A[i] >> Binal[i]);
  int res = M-accumulate(ALL(Binal),0);

  VRSORT(A);
  for(int i=0;i<min(res,N);i++){
    A[i] = A[i]>>1LL;
  }

  cout << accumulate(ALL(A),0LL) << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323
int i,j,k;
int power(int x,int y){
    if(y==0)return 1;
    if(y==1)return x;
    if(y&1)return (((power(x,y/2)*power(x,y/2))%PRIME)*x)%PRIME;
    else return (power(x,y/2)*power(x,y/2))%PRIME;
}
void Anon_mouS(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N);
    vector<int> B(M);
    for(i=0;i<N;i++) cin >> A[i];
    for(i=0;i<M;i++) cin >> B[i];
 
    int tot = 0;
    for(i=0;i<M;i++) tot += B[i];
 
    int j = M;
    int ans = 0;
    for(i=0;i<=N;i++) {
        while (j > 0 && tot > K) {
            j -= 1;
            tot -= B[j];
        }
        if (tot > K) break;
        ans = max(ans, i+j);
        if (i == N) break;
        tot += A[i];
    }
    cout << ans << endl;
}
 
int32_t main(){
    fastio;
    int q=1;
    // cin>>q;
    // SieveOfEratosthenes();
    while(q--){
        Anon_mouS();
    }
    return 0;   
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
int K, X, Y; 
vector<pair<int, int>> ans; 
bool ok(int x1, int y1, int x2, int y2){
	return abs(x1 - x2) + abs(y1 - y2) == K; 
}
void last(int x, int y){
	int xx[8] = {(x+y)/2, (x+y)/2 - K, (x+y)/2 + K, (x+y)/2, (x-y)/2 + K, (x-y)/2, (x-y)/2, (x-y)/2 - K}; 
	int yy[8] = {(x+y)/2 + K, (x+y)/2, (x+y)/2, (x+y)/2 - K, -(x-y)/2, -(x-y)/2 + K, -(x-y)/2 - K, -(x-y)/2}; 
	for(int i = 0; i < 8; i++){
		if(ok(0, 0, xx[i], yy[i]) && ok(xx[i], yy[i], x, y)){
			ans.emplace_back(xx[i], yy[i]); 
			ans.emplace_back(x - xx[i], y - yy[i]); 
			return; 
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	cin >> K >> X >> Y; 
	if(!(K & 1) && (abs(X+Y) & 1)){
		cout << -1 << "\n"; return 0; 
	}
	if(abs(X) + abs(Y) == K){
		cout << 1 << "\n" << X << " " << Y << "\n"; return 0; 
	}
	int sX = 1, sY = 1; 
	if(X < 0){
		sX = -1; X *= -1; 
	}
	if(Y < 0){
		sY = -1; Y *= -1; 
	}
	if((X + Y) % K == 0){
		while(X >= K){
			ans.emplace_back(K, 0); X -= K; 
		}
		while(Y >= K){
			ans.emplace_back(0, K); Y -= K; 
		}
		if(X) ans.emplace_back(X, Y); 
	}else if(!(K & 1)){
		while(X + Y > K * 2){
			if(X >= K){
				ans.emplace_back(K, 0); X -= K; 
			}else if(Y >= K){
				ans.emplace_back(0, K); Y -= K; 
			}
		}
		last(X, Y);  
	}else if(!((X + Y) & 1)){
		while(X + Y > K * 2){
			if(X >= K * 2){
				ans.emplace_back(K, 0); X -= K; 
				ans.emplace_back(K, 0); X -= K; 
			}else if(Y >= K * 2){
				ans.emplace_back(0, K); Y -= K; 
				ans.emplace_back(0, K); Y -= K;
			}else{
				ans.emplace_back(K, 0); X -= K; 
				ans.emplace_back(0, K); Y -= K;
			}
		}
		last(X, Y); 	
	}else if(X + Y < K){
		ans.emplace_back(-K, 0); X += K; 
		last(X, Y); 
	}else{
		while(X + Y > K * 3){
			if(X >= K * 2){
				ans.emplace_back(K, 0); X -= K; 
				ans.emplace_back(K, 0); X -= K; 
			}else if(Y >= K * 2){
				ans.emplace_back(0, K); Y -= K; 
				ans.emplace_back(0, K); Y -= K;
			}else if(X >= K && Y >= K){
				ans.emplace_back(K, 0); X -= K; 
				ans.emplace_back(0, K); Y -= K;
			}
		}
		if(X >= K){
			ans.emplace_back(K, 0); X -= K; 
			last(X, Y); 
		}else{
			ans.emplace_back(0, K); Y -= K; 
			last(X, Y); 
		}
	}
	int nx = 0, ny = 0; 
	cout << ans.size() << "\n"; 
	for(auto p : ans){
		nx += p.first; ny += p.second; 
		cout << sX * nx << " " << sY * ny << "\n"; 
	}
}

Measured memory_bytes: 3952
let a, b, c = Scanf.scanf " %s %s %s" @@ fun a b c -> a, b, c
let is = Array.make 3 0
let g s i x = if is.(i) >= String.length s then (Printf.printf "%c\n" x; exit 0) else (is.(i) <- is.(i) + 1; is.(i) - 1)
let rec f x = match x with 'a' -> f a.[g a 0 'A'] | 'b' -> f b.[g b 1 'B'] | _ -> f c.[g c 2 'C']
let _ = f 'a'

Measured memory_bytes: 2432
def myord(c):
	asc = ord(c)
	if asc <= 90:
		return asc
	else :
		return asc - 6
def mychr(asc):
	if asc <= 90:
		return chr(asc)
	else :
		return chr(asc + 6)
import sys
while 1:
	n = int(raw_input())
	if n == 0:
		break
	k = map(int,raw_input().split())
	length = len(k)
	inc = 0
	station = []
	s = raw_input()
	for ls in s:
		key = k[inc]
		asc = myord(ls) - k[inc]
		station.append(mychr(asc) if asc >= 65 else mychr(116 - (65 - asc) + 1))
		inc = inc + 1 if inc + 1 < length else 0
	for si in station:
		sys.stdout.write(si)
	print ""

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int h[n];for(int i=0;i<n;i++)cin>>h[i];
  int dp[n];
  fill(dp,dp+n,2000000000);
  dp[0]=0;
  for(int i=0;i<n-2;i++){
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
  }
  dp[n-1]=min(dp[n-1],dp[n-2]+abs(h[n-1]-h[n-2]));
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b,c;cin>>n>>a>>b>>c;
    //0が1個以下ならいける
    //0が2個あってしかももう1個も1だと厳しい
    //0が2個でももう1個が2以上なら0,0を最初に狙われなければいける
    //なるべく0を作らないように
    vector<string> s(n);rep(i,n)cin>>s[i];
    vector<string> ans;
    bool pos = true;
    rep(i,n){
        string str = s[i];
        if(str=="AB"){
            if(a>b){a--;b++;ans.push_back("B");}
            else if(a<b){a++;b--;ans.push_back("A");}
            else{
                if(a==0){pos=false;break;}
                if(i<n-1){
                    if(s[i+1]=="AB"||s[i+1]=="BC"){a--;b++;ans.push_back("B");}
                    else{a++;b--;ans.push_back("A");}
                }else{
                    a--;b++;ans.push_back("B");
                }
            }
        }else if(str=="BC"){
            if(c>b){c--;b++;ans.push_back("B");}
            else if(c<b){c++;b--;ans.push_back("C");}
            else{
                if(c==0){pos=false;break;}
                if(i<n-1){
                    if(s[i+1]=="BC"||s[i+1]=="AB"){c--;b++;ans.push_back("B");}
                    else{c++;b--;ans.push_back("C");}
                }else{
                    c--;b++;ans.push_back("B");
                }
            }
        }else{//str=="AC"
            if(c>a){c--;a++;ans.push_back("A");}
            else if(c<a){c++;a--;ans.push_back("C");}
            else{
                if(c==0){pos=false;break;}
                if(i<n-1){
                    if(s[i+1]=="AC"||s[i+1]=="AB"){c--;a++;ans.push_back("A");}
                    else{c++;a--;ans.push_back("C");}
                }else{
                    c--;a++;ans.push_back("A");
                }
            }
        }
    }
    if(pos){
        cout<<"Yes"<<endl;
        for(string str:ans)cout<<str<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 10568
//abc139_e.cpp
//Mon Oct 28 21:37:05 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	queue<int> a[n];
	for (int i=0;i<n;i++){
		for (int j=0;j<n-1;j++){
			int temp;
			cin >> temp;
			temp--;
			a[i].push(temp);
		}
	}

	int count = 0;
	int ans = 0;
	queue<int> x;
	while (count < n*(n-1)/2){
		int update = 1;
		int used[n];
		fill(used,used+n,0);
		if (ans == 0){
			for (int i=0;i<n-1;i++){
				if (a[i].size()==0 || used[i]){
					continue;
				}
				int first = a[i].front();
				if (i == a[first].front() &&
					used[first] == 0){
					a[i].pop();
					a[first].pop();
					used[i]=1;
					used[first]=1;
					update = 0;
					count++;
					x.push(i);
					x.push(first);
				}
			}
		}else {
			int size = x.size();
			for (int i=0;i<size;i++){
				int testman = x.front();x.pop();
				if (a[testman].size()==0 || used[testman]){
					continue;
				}
				int first = a[testman].front();
				if (testman == a[first].front() &&
					used[first]==0){
					a[testman].pop();
					a[first].pop();
					used[testman] = 1;
					used[first] = 1;
					update = 0;
					count++;
					x.push(testman);
					x.push(first);
				}
			}
		}
		ans++;
		if (update){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define M 1000000007
typedef long long int ll;
#define INF 1000000000000000
int main()
{
   ll h,w;
   cin>>h>>w;
   ll dp[h+1][w+1];
   ll i,j;
   char a[h][w];
   for(i=0;i<h;i++)
   {
       for(j=0;j<w;j++)
       {
           cin>>a[i][j];
       }
   }
   memset(dp,0,sizeof(dp));
   dp[1][1]=1;
   for(i=2;i<=w;i++)
   {
       if(a[0][i-1]=='.')
       {
           if(dp[1][i-1]!=0)
            dp[1][i]=1;
           else
            dp[1][i]=0;
       }
       else
       {
           dp[1][i]=0;
       }
   }
   for(i=2;i<=h;i++)
   {
       if(a[i-1][0]=='.')
       {
           if(dp[i-1][1]!=0)
            dp[i][1]=1;
           else
            dp[i][1]=0;
       }
       else
       {
           dp[i][1]=0;
       }
   }
   for(i=2;i<=h;i++)
   {
       for(j=2;j<=w;j++)
       {
           if(a[i-1][j-1]=='.')
           {
               if(a[i-2][j-1]=='.')
                dp[i][j]+=dp[i-1][j];
               if(a[i-1][j-2]=='.')
                dp[i][j]+=dp[i][j-1];

               dp[i][j]%=M;
           }
       }
   }
   cout<<dp[h][w];

}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]" << endl; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dump(...) dump_func(__VA_ARGS__)
#define dump2(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dump(...)
#define dump2(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    ll D, T, S;
    cin >> D >> T >> S;
    rep(i,D)dump(D);
    cout << ((D + S - 1) / S <= T ? "Yes" :"No") << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    while(1)
    {
        int nb_equipes;
        cin>>nb_equipes;
        if(nb_equipes==0) break;
        map<string,vector<string> > m;
        string first = "";
        for(int c=0;c<nb_equipes;c++)
        {
            string s;
            cin>>s;
            string id = s.substr(0,s.find(':'));
            if(c==0) first = id;
            string reste = s.substr(s.find(':')+1);
            reste = reste.substr(0,reste.size()-1);
            stringstream ss(reste);
            string element;
            while(getline(ss,element,','))
            {
                m[id].push_back(element);
            }
        }
        vector<string> parcours;
        parcours.push_back(first);
        int res = 0;
        map<string,bool> visites;
        visites[first]=true;
        while(!parcours.empty())
        {
            string act = parcours.back();
            parcours.pop_back();
            if(m.find(act)==m.end())
            {
                res++;
            }
            for(int c=0;c<m[act].size();c++)
            {
                if(!visites[m[act][c]])
                {
                    visites[m[act][c]]=true;
                    parcours.push_back(m[act][c]);
                }
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 1452
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	ll a, b, k;
	cin >> a >> b >> k;

	if (a > k) {
		a = a - k;
		cout << a << ' ' << b << endl;
	}
	else {
		k = k - a;
		a = 0;
		if (b > k) {
			b = b - k;
			cout << a << ' ' << b << endl;
		}
		else {
			b = 0;
			cout << a << ' ' << b << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main () {
  int n;
  cin >> n;
  vector<int> a(n), b;
  for(int i = 0; i < n; i++) cin >> a[i];
  b = a;
  sort(b.begin(), b.end());
  int m1 = b[n / 2 - 1], m2 = b[n / 2];
  for(int i = 0; i < n; i++) if (a[i] <= m1) cout << m2 << endl;
  else cout << m1 << endl;
  return 0;
}

Measured memory_bytes: 3712
n, m = map(int, input().split())
lmax = 0
rmin = n
for _ in range(m):
    l, r = map(int, input().split())
    lmax = max(lmax, l)
    rmin = min(rmin, r)

if lmax > rmin:
    print(0)
else:
    print(rmin - lmax + 1)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int n,a,b,i;

  while(scanf("%d",&n),n){
    int Pa=0,Pb=0;
    for(i=0;i<n;i++){
      scanf("%d %d",&a,&b);
      if(a>b)Pa+=a+b;
      else if(a<b)Pb+=a+b;
      else {Pa+=a; Pb+=b;}
    }
    printf("%d %d\n",Pa,Pb);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int interval = 1; interval < n; interval++) {
        int ans_tmp = 0;
        for (int left = 0; left + interval < n; left++) {
            int right = left + interval;
            if (s[left] == s[right]) ans_tmp++;
            else ans_tmp = 0;
            ans = max(ans, min(ans_tmp, interval));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
s = input()
if s[len(s) - 1] == '0' or s[len(s) - 1] == '1' or s[len(s) - 1] == '6' or s[len(s) - 1] == '8':
    print("pon")
elif s[len(s) - 1] == '3':
    print("bon")
else:
    print("hon")


Measured memory_bytes: 61940
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const a = input[1].split(" ").map((x: string): number => +x);
a.unshift(0);
a.push(0);

const dist = (a: number, b: number) => {
	return Math.abs(a - b);
};

let sum = 0;
for (let i = 0; i < a.length - 1; i++) {
	sum += dist(a[i], a[i + 1]);
}

for (let i = 1; i <= n; i++) {
	const prev = a[i - 1];
	const mid = a[i];
	const next = a[i + 1];
	const original_cost = dist(next, mid) + dist(mid, prev);
	const new_cost = dist(next, prev);
	console.log(sum - (original_cost - new_cost));
}


Measured memory_bytes: 33324
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int N;
  cin >> N;
  vector<int> nums(N);

  for (int &x : nums)
    cin >> x;

  multiset<int> remaining;
  for (int x : nums)
    remaining.insert(x);

  int ans = 0;
  while (!remaining.empty()) {
    auto iter = prev(remaining.end());
    const int num = *iter;
    remaining.erase(iter);

    int b = 1;
    while (b <= num) { b *= 2; }

    auto fiter = remaining.find(b - num);
    if (fiter == remaining.end()) { continue; }

    debug(num, b - num);
    remaining.erase(fiter);
    ++ans;
  }

  cout << ans << "\n";

}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    REP(i, N) { cin >> a[i]; }
    int ma = *max_element(a.begin(), a.end());
    int pm = a[0];
    int mindex = max_element(a.begin(), a.end()) - a.begin();
    int mi = *min_element(a.begin(), a.end());
    int miindex = min_element(a.begin(), a.end()) - a.begin();
    int cnt = 0;
    std::stringstream buffer;
    if(mi >= 0) {
        for(int i = 1; i < N; i++) {
            cnt++;
            buffer << i << " " << i + 1 << endl;
        }
    } else if(ma <= 0) {
        for(int i = N - 1; i >= 1; i--) {
            cnt++;
            buffer << i + 1 << " " << i << endl;
        }
    } else if(abs(mi) > abs(ma)) {
        //すべて負にする
        // cout << "a" << endl;
        for(int i = 0; i < N; i++) {
            cnt++;
            buffer << miindex + 1 << " " << i + 1 << endl;
        }
        for(int i = N - 1; i >= 1; i--) {
            cnt++;
            buffer << i + 1 << " " << i << endl;
        }
    } else {
        for(int i = 0; i < N; i++) {
            cnt++;
            buffer << mindex + 1 << " " << i + 1 << endl;
        }
        for(int i = 1; i < N; i++) {
            cnt++;
            buffer << i << " " << i + 1 << endl;
        }
    }

    cout << cnt << endl;
    cout << buffer.str() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long

using namespace std;

LL n,a[3005],dp[3005][3005];
LL solve(int front,int back) {
    if (front>back) return 0;
    if (dp[front][back]!=-1) return dp[front][back];
    if ((n-back+front-1)%2==0) return dp[front][back]=max(solve(front+1,back)+a[front],solve(front,back-1)+a[back]);
    else return dp[front][back]=min(solve(front+1,back)-a[front],solve(front,back-1)-a[back]); 
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for (int i=1;i<=n;i++) cin >> a[i];
    memset (dp,-1,sizeof(dp));
    cout << solve(1,n) << endl;
    return 0;
}


Measured memory_bytes: 70912
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
L = [0] * (87)
L[0] = 2
L[1] = 1
for i in range(2,87):
    L[i] = L[i-1] + L[i-2]
print(L[I()])


Measured memory_bytes: 10388
import collections

n=int(input())
s=[]
set={}
for i in range(n):
    s.append(input())
for i in range(n):
    temp=list(s[i])
    temp.sort()
    s[i]=''.join(temp)
count=0
ans=collections.Counter(s)
countlist=ans.most_common()
for i in range(len(countlist)):
    if countlist[i][1]<=1:
        break
    else:
        temp=countlist[i][1]-1
        count+=(temp+1)*temp//2

print(count)

Measured memory_bytes: 82776
fn main() {
    // input
    let input = read_vec::<i32>();

    // A
    let a:i32 = input[0];
    // B
    let b:i32 = input[1];
    // C
    let c:i32 = input[2];

    let mut ans = b + c - a;
    if ans < 0 {
         ans = 0;
    };

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

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <stdio.h>

#define N 1000001

void make_prime_flag_table(int n,int a[N]){
  int i,j;
  a[0]=a[1]=0;
  a[2]=1;
  for( i=3;i<=n;i++)
    a[i] = i&1;
  i=3;
  while( i*i<=n ){
    for( j=i<<1;j<=n;j+=i)
      a[j] = 0;
    do{ i+=2;}while(!a[i]);
  }
}


int main(void){
  int a,n,d;
  int p[N];  // prime number table 
  int i,j;

  make_prime_flag_table( N-1,p );

  while( 1 ){
    scanf("%d %d %d ",&a,&d,&n );
    if( !a && !n && !d )
      break;

    i=0;j=0;
    while( 1  ){
      if( p[a]==1 )
	j++;
      if( j==n )
	break;
      a+=d;
    }
    printf("%d\n",a );
  }
  return 0;
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	r := nextInt()
	fmt.Printf("%.20f\n", 2.0 * float64(r) * math.Pi)
}


Measured memory_bytes: 1760
#include<bits/stdc++.h>
using namespace std;
int main (){
    int h,n;cin>>h>>n;
    vector<int> V(n);
    for(int i=0;i<n;i++){
            cin>>V[i];
    }
    if(accumulate(V.begin(),V.end(),0)>=h)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  int N = 0,M = 0,X = 0,ans1 = 0,ans2 = 0;
  cin >> N >> M >> X;
  vector<int>A(M);
  rep(i,M){
    cin >> A[i];
    if(A[i] > X){
      ans1++;
    }
    else{
      ans2++;
    }
  }
  cout << min(ans1,ans2);
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll x,y,a,b,c; cin >> x >> y >> a >> b >> c;
        vector<pair<ll,ll>> v;
        ll mohit;
        rep(i,a) cin >> mohit, v.pb({mohit,1LL});
        rep(i,b) cin >> mohit, v.pb({mohit,2LL});
        rep(i,c) cin >> mohit, v.pb({mohit,3LL});
        sort(v.rbegin(),v.rend());

        ll replace =0,sum =0;
        rep(i,a+b+c){
            if(x+y+replace<=0) break;
            if(v[i].ss==1 and x>0) sum += v[i].ff , x--;
            else if(v[i].ss==2 and y>0) sum +=v[i].ff , y--;
            else if(v[i].ss==3) sum+= v[i].ff , replace--;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,x,n;
    cin>>n>>k;
    set<int>s1;
    for(int i=1;i<=k;i++){
        cin>>x;
        s1.insert(x);
    }
    int s[10],r=0;
    while(n!=0){
        int t=n%10;
        s[r++]=t;
        n=n/10;
    }
    reverse(s,s+r);
    int y=0,i;
    //r=s.size();
    for(i=0;i<r;i++){
        //d=s[i]-'0';
        if(!s1.count(s[i]))
            y++;
        else
            break;
    }
    int h=s[0];
    while(1){
        if(!s1.count(h)){
            break;
        }
        else
            h++;
    }
    if(y==r){
        for(int i=0;i<r;i++)
            cout<<s[i];
    }
    else if(h>9){
        for(int i=1;i<10;i++){
            if(!s1.count(i)){
                cout<<i;
                break;
            }
        }
        for(int i=1;i<=r;i++){
            for(int j=0;j<10;j++){
                if(!s1.count(j)){
                    cout<<j;
                    break;
                }
            }
        }
    }
    else{
        //cout<<i;
        for(int j=i;j>=0;j--){
            //d=s[j]-'0';
            //cout<<d<<endl;
            for(int l=s[j]+1;l<10;l++){
                if(!s1.count(l)){
                    for(int i=0;i<j;i++)
                        cout<<s[i];

                    cout<<l;
                    for(int i=j+1;i<r;i++){
                        //int d=s[i]-'0';
                        for(int p=0;p<10;p++){
                            if(!s1.count(p)){
                                cout<<p;
                                break;
                            }
                        }
                    }
                    return 0;
                }
            }
        }
        for(int i=1;i<10;i++){
            if(!s1.count(i)){
                cout<<i;
                break;
            }
        }
        for(int i=1;i<=r;i++){
            for(int j=0;j<10;j++){
                if(!s1.count(j)){
                    cout<<j;
                    break;
                }
            }
        }
    }

}

Measured memory_bytes: 3608