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

const int64_t M = 1e9 + 7;

int64_t modpow(int64_t a, int64_t n)
{
    int64_t res = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            res = res * a % M;
        }
        a = a * a % M;
        n >>= 1;
    }
    return res;
}

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

    vector<int64_t> cnt(k + 1, 0);
    int64_t res = 0;
    for (int i = k; i > 0; i--)
    {
        int x = k / i;
        cnt.at(i) = modpow(x, n);
        for (int j = i + i; j <= k; j += i)
        {
            cnt.at(i) = (cnt.at(i) + M - cnt.at(j)) % M;
        }
        res = (res + (cnt.at(i) * i) % M) % M;
    }
    cout << res << endl;
}

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

#define MX 200050
int a[MX], b[MX];
int c[MX], d[MX];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", a + i);
	for(int i = 0; i < n; i++) scanf("%d", b + i);
	int res = 0;
	for(int i = 0; i < 29; i++) {
		for(int j = 0; j < n; j++) c[j] = a[j] & ((1 << (i + 1)) - 1);
		for(int j = 0; j < n; j++) d[j] = b[j] & ((1 << (i + 1)) - 1);
		sort(d, d + n);
		int j, tot = 0;
		for(int j = 0; j < n; j++) {
			tot += lower_bound(d, d + n, (2 << i) - c[j]) - lower_bound(d, d + n, (1 << i) - c[j]);
			tot += lower_bound(d, d + n, (4 << i) - c[j]) - lower_bound(d, d + n, (3 << i) - c[j]);
			tot &= 1;
		}
		if(tot & 1) res ^= 1 << i;
	}
	printf("%d\n", res);
	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    vector<int> dist(N+1, -1);
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    bool goal = false;
    
    while(!que.empty() && !goal){
        int a = que.front();
        que.pop();
        if(a == N){
            goal = true;
            break;
        }

        for(int i = 9; a + i <= N;i*=9){
            if(dist[a+i] != -1) continue;
            dist[a+i] = dist[a]+1;
            que.push(a+i);
        }

        for(int i = 6; a + i <= N;i*=6){
            if(dist[a+i] != -1) continue;
            dist[a+i] = dist[a]+1;
            que.push(a+i);
        }

        if(a+1 <= N && dist[a+1] == -1){
            dist[a+1] = dist[a]+1;
            que.push(a+1);
        }

    }
    cout << dist[N] << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for (int i = (m) ; i < (n) ; i++)
#define per(i,n,m) for (int i = (n-1) ; i >= (m) ; i--)
#define all(x)     (x).begin(), (x).end()
#define sz(x)      ((int) (x).size())
ll gcd(ll x,ll y){
    if(y==0)return x;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}
int main(void){
    int N,error=0;
    long long int sum=1;
    long double count=pow(10,18);
    cin>>N;
    vector<long long int> data(N);
    rep(i,0,N){
        cin>>data.at(i);
        if(data.at(i)==0)sum=0;
    }
    if(sum!=0){
        rep(i,0,N){
            count/=data.at(i);
            if(count<1.0){
                error++;
                break;
            }
            sum*=data.at(i);
        }
    }
    if(error!=0)cout<<-1<<endl;
    else cout<<sum<<endl;
}

Measured memory_bytes: 4036
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;


public class Main {



    public static void main(String args[])  {

        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        double ans = a * 1.0 / b;
        System.out.println(ans);

    }

}


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

using namespace std;

const int N = 1e5 + 10;

char s[N];

int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1), a, b, c, d;
  a = b = c = d = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'N') a = 1;
    if (s[i] == 'S') b = 1;
    if (s[i] == 'W') c = 1;
    if (s[i] == 'E') d = 1;
  }
  if ((a ^ b) || (c ^ d)) {
    puts("No");
  } else {
    puts("Yes");
  }
  return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const LL MOD = 1e9 + 7;
const int N = 1e6;

LL fct[N + 5], inv[N + 5];

LL fast(LL A,LL B) {
	LL res = 1;
	while(B) {
		if(B & 1) res = res * A % MOD;
		B /= 2;
		A = A * A % MOD;
	}
	return res;
}

void pre() {
	fct[0] = 1;
	for(int i = 1;i <= N;i++) fct[i] = fct[i-1] * i % MOD;
	inv[N] = fast(fct[N], MOD - 2);
	for(int i = N - 1;i >= 0;i--) inv[i] = inv[i + 1] * (i + 1) % MOD;
}

LL combin(int n,int r) {
	if(n < r) return 0;
	return fct[n] * inv[r] % MOD * inv[n - r] % MOD;
}

void hora(int tc) {
	int n,m,k;
	cin>>n>>m>>k;
	int space = m + k;
	LL tot = 0;
	LL totals = 1;
	for(int w = 0;w <= m + k;w++) {
		if(w > m) totals -= combin(w - 1, m);
		if(w > k) totals -= combin(w - 1, k);
		totals %= MOD, totals += MOD, totals %= MOD;
		tot += combin(n - 1 + w, n - 1) * totals % MOD * fast(3, m + k - w) % MOD;
		totals = totals * 2 % MOD;
		tot %= MOD;
	}
	cout<<tot<<endl;
}

int main(){
	pre();
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

vector<pair<ll, ll>> v;
int main(){
	int n; scanf("%d", &n);
	REP(i, n){
		ll a, b; scanf("%lld%lld", &a, &b);
		v.EB(b, a);
	}
	sort(v.begin(), v.end());
	ll t = 0;
	bool ok = true;
	REP(i, n){
		t += v[i].second;
		if(t > v[i].first) ok = false;
	}
	if(ok) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 6384
from math import floor, sqrt
Q = int(input())
A = []

for i in range(Q):
  A.append(list(map(int,input().split())))

for i in range(Q):
  P,Q = min(A[i][0], A[i][1]), max(A[i][0], A[i][1])
  if P == Q or P == Q-1:
    print(2*(P - 1))
  else:
    C = floor(sqrt(P*Q))
    if C == sqrt(P*Q):
      C -= 1

    if C*(C+1) >= P*Q:
      print(2*C - 2)
    else:
      print(2*C - 1)

Measured memory_bytes: 3064
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m;
ll K,a[100111],b[100111],nb[100111];
int t[100111],p[70][100111];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]),b[i]=a[i]-a[i-1],t[i]=i;
	getii(m,K);
	for(int i=1;i<=m;i++)
	{
		int x;
		geti(x);
		swap(t[x],t[x+1]);
	}
	for(int i=1;i<=n;i++)p[0][t[i]]=i;
//	for(int i=1;i<=n;i++)cerr<<t[i]<<" ";cerr<<endl;
//	for(int i=1;i<=n;i++)cerr<<b[i]<<" ";cerr<<endl;
	for(int i=1;i<63;i++)for(int j=1;j<=n;j++)p[i][j]=p[i-1][p[i-1][j]];
	for(int i=62;i>=0;i--)
	{
		if((K>>i)&1)
		{
			for(int j=1;j<=n;j++)nb[p[i][j]]=b[j];
			swap(nb,b);
		}
	}
	for(int i=1;i<=n;i++)a[i]=a[i-1]+b[i],putsi(a[i]);
	return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  const int INF = 1 << 20;
  int N, A, B;
  cin >> N >> A >> B;
  vi a(N), b(N), c(N);
  rep(i, N) cin >> a[i] >> b[i] >> c[i];

  vector<vector<vi>> dp(50, vector<vi>(500, vi(500, INF)));
  rep(i, 50) rep(j, 500) rep(k, 500) {
    dp[i][j][k] = INF;
  }

  dp[0][0][0] = 0;
  rep(i, N) {
    for (int j = 0; j+a[i] < 500; j++) {
      for (int k = 0; k+b[i] < 500; k++) {
        cmin(dp[i+1][j][k], dp[i][j][k]);
        if (dp[i][j][k] != INF)
          cmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
      }
    }
  }

  int ans = INF;
  for (int i = 1; A*i < 500 && B*i < 500; i++) {
    cmin(ans, dp[N][A*i][B*i]);
  }
  cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	string S; cin>>S;

	int maxi = 0;
	rp(s,1,N){
		set<char> c1;
		rp(i,0,s){
			c1.insert(S[i]);
		}
		set<char> c2;
		rp(i,s,N){
			c2.insert(S[i]);
		}
		int count = 0;
		for(auto a:c1){
			if(c2.count(a))count++;
		}
		maxi = max(maxi, count);

	}

	ote(maxi);
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }


  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
     if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  bool operator == (Mint &a) const {
    return x==a.x;
  }

  bool operator != (Mint &a) const {
    return x!=a.x;
  }
};

int A[1004][1004];
int ID[1004][1004];
std::vector<int > to[1004*1004];
int memo[1004*1004];
bool doing[1004*1004];

int dfs(int v){
  if (memo[v]!=-1) {
    return memo[v];
  }
  if (doing[v]) return -1;
  doing[v]=true;
  int child_max=0;
  for (int child : to[v]){
    //printf("%d is child of %d\n",v,child);
    int v = dfs(child);
    if (v==-1) return -1;
    child_max = std::max(child_max, v);
  }
  memo[v]=child_max+1;
  doing[v]=false;
  return memo[v];
}

int main(){
  int N;
  scanf("%d", &N);
  int V=0;
  for (int i=0; i<1004; i++){
    for (int j=i+1; j<1004; j++){
      ID[i][j]=V;
      V++;
    }
  }
  for (int i=0; i<1004*1004; i++){
    memo[i]=-1;
    doing[i]=false;
  }
  
  for (int i=0; i<N; i++){
    for (int j=0; j<N-1; j++){
      scanf("%d", &A[i][j]);
      A[i][j]--;
      int min = std::min(i, A[i][j]);
      int max = std::max(i, A[i][j]);
      int id = ID[min][max];
      //printf("i=%d j=%d, id=%d\n", i, j, id);
      A[i][j]=id;
    };
    for (int j=0; j<N-2; j++){
      to[A[i][j+1]].push_back(A[i][j]);
    }
  }
  int max = 0;
  for (int i=0; i<V; i++){
    int v = dfs(i);
    //if (i<5) printf("dfs(%d)=%d\n", i, v);
    if (v==-1){
      printf("-1\n");
      return 0;
    }
    max = std::max(max, v);
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 55260
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s;
    cin >> s;
    int r = 700;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'o'){
            r += 100;
        }
    }
    cout << r;
    
    cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        int N = ReadInt();
        int[] h = ReadInts();
        int cnt = 0;
        for (int i = 100; i > 0; i--)
        {
            for(int k = 0;k<N;k++)
            {
                if(h[k]==i)
                {
                    cnt++;
                    h[k]--;
                    k++;
                    while(k < N && h[k] == i)
                    {
                        h[k]--;
                        k++;
                    }
                }
            }
        }
        return cnt.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

struct Price {
    int x, y;
    Price(int x = 0, int y = 0) : x(x), y(y) {}
};

bool operator< (Price a, Price b) {
    return a.x < b.x;
}
int n, m;
Price a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) cin >> a[i].x >> a[i].y;
    sort(a+1, a+n+1);
    ll res = 0;
    FOR(i,1,n) {
        int g = min(m, a[i].y);
        m -= g;
        res += (ll) g * a[i].x;
        if (m == 0) break;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1024
n,k=gets.chomp.split(" ").map { |e| e.to_i }
x=gets.chomp.split(" ").map { |e| e.to_i   }


def abs(n)

  if n>=0
    return n
  else
    return -n
  end

end


min = 10**13


for i in 0..(n-k)
   cons1 = abs(x[i]) + abs(x[i+k-1] - x[i])
   cons2 = abs(x[i+k-1]) + abs(x[i+k-1] - x[i])

  const = cons1 > cons2 ? cons2 : cons1

  min = min > const ? const : min

end

puts min

Measured memory_bytes: 9484
# -*- coding: utf-8 -*-
import sys
import math


#n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
a = hoge[0]
b = hoge[1]

if(a-b)%2!=0:
	print("IMPOSSIBLE")
else:
	print((a+b)//2)



Measured memory_bytes: 2940
N,K = map(int,input().split())
if N*(N-1)//2-(N-1) - K < 0:
    print(-1)
    exit()
M = N-1 + N*(N-1)//2-(N-1) - K
print(M)
for i in range(2,N+1):
    print(1,i)


r = N*(N-1)//2-(N-1) - K
for i in range(2,N+1):
    for j in range(i+1,N+1):
        if r == 0:
            exit()
        if r > 0:
            print(i,j)
            r -= 1

Measured memory_bytes: 42736
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;


const int maxn = 1e6+5;
ll q[maxn], p[maxn], r[maxn], s[maxn];
int main()
{
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    for(int i = 1; i <= a; i++) cin >> p[i];
    for(int i = 1; i <= b; i++) cin >> q[i];
    for(int i = 1; i <= c; i++) cin >> r[i];
    sort(p+1, p+a+1, greater<ll>());
    sort(q+1, q+b+1, greater<ll>());
    sort(r+1, r+c+1, greater<ll>());
    ll ans = 0;
    int flag = 1;
    for(int i = 1; i <= x; i++) ans += p[i], s[flag++] = p[i];
    for(int i = 1; i <= y; i++) ans += q[i], s[flag++] = q[i];
    sort(s+1, s+flag);
    int w = 1;
    for(int i = 1; i <= c; i++) {
        if(r[i] > s[w]) {
            ans += r[i] - s[w++];
        }
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11904
#include<iostream>
#include<cstdio>
#define M 2010
using namespace std;
int n,num,L,R,ans,tot,k;
int head[M],U[M],V[M];
struct edge{int next,to;}e[M<<1];
void add(int from,int to) {
	e[++num]=(edge){head[from],to};
	head[from]=num;
}
void dfs(int x,int fa,int dep) {
	if(dep>k/2) tot++;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa) dfs(e[i].to,x,dep+1);
}
int main() {
	scanf("%d%d",&n,&k);ans=n;
	for(int i=1;i<n;i++) {
		scanf("%d%d",&U[i],&V[i]);
		add(U[i],V[i]);add(V[i],U[i]);
	}
	if(k&1) {
		for(int i=1;i<n;i++) {
			tot=0;
			dfs(U[i],V[i],0);
			dfs(V[i],U[i],0);
			ans=min(ans,tot);
		}
	}
	else {
		for(int i=1;i<=n;i++)
			tot=0,dfs(i,0,0),ans=min(ans,tot);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "Yes";
            if (iA % 2 == 0 || iB % 2 == 0) { sOut = "No"; }
            
            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_6_B_Partition
{

    class Program
    {
        const int MAX = 500000;
        static int[] A = new int[MAX];

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(input[i]);
            }
            Partition(n, n - 1);
        }

        static void Partition(int n, int r)
        {
            int changeIndexLast = 0;
            var lowerRNum = 0;
            bool UpperRNum = false;
            for (int i = 0; i < n - 1; i++)
            {
                if (!UpperRNum)
                {
                    if(A[i] > A[r])
                    {
                        UpperRNum = true ;
                        changeIndexLast = lowerRNum;
                    }
                    
                    if (A[i] <= A[r])
                    {
                        lowerRNum++;
                        continue;
                    }
                }
                if (A[i] <= A[r])
                {
                    lowerRNum++;
                    if (i >= 1)
                    {
                        int d = A[changeIndexLast];
                        A[changeIndexLast] = A[i];
                        A[i] = d;
                        changeIndexLast++;
                    }
                }
            }

            int c = A[lowerRNum];
            A[lowerRNum] = A[r];
            A[r] = c;

            Print(lowerRNum, n);
        }

        static void Print(int lowerRNum, int n)
        {
            for (int i = 0; ; i++)
            {
                if (i == n - 1)
                {
                    Console.Write(A[i] + "\r\n");
                    break;
                }
                if (i == lowerRNum)
                {
                    Console.Write("[{0}] ", A[i]);
                    continue;
                }
                Console.Write(A[i] + " ");
            }
        }
    }
}



Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll a, b;
    cin >> a >> b;
    ll mn = min(a, b/2);
    b -= mn*2;
    ll ans = mn + b/4;
    cout << ans << endl;
}


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

void solve(std::string s) {
  string res = "";
  for (auto ch : s) {
    if (ch == '0' or ch == '1') {
	res += ch;
    } else {
      if (res.size()) {
	  res.pop_back();
      }
    }
  }
  cout << res << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}


Measured memory_bytes: 256
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
int x = 0, y = 0, z = 0,n = 0;
asas;
cncn;
//BEGIN OF CODE.
int main(void){
	int n, k;
	string s;
	cin >> n >> k >> s;
	rep(i, n) {
		if (i != k-1)cout << s[i];
		else {
			cout << char(s[i] + 32);
		}
	}
	cout << rt;
	please AC;
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    char c;
    cin>>c;
    
    int ans = int(c);
    //cout<<ans<<endl;
    
    char c1 = char(ans+1);
    cout<<c1<<endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int b, f, r, v;
	int n, i, j, k;/*整数の宣言*/
	int count[4][3][10] = { 0 };/*配列の宣言と初期化*/

	scanf("%d", &n);/*情報の数を入力*/

	for (i = 0; i < n; i++)/*n回繰り返す*/
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);/*b,f,r,vの入力*/
		count[b - 1][f - 1][r - 1] += v;/*配列に代入*/
	}

	for (i = 0; i < 4; i++)/*4回繰り返す*/
	{
		for (j = 0; j < 3; j++)/*3回繰り返す*/
		{
			for (k = 0; k < 10; k++)/*10回繰り返す*/
			{
				printf(" %d", count[i][j][k]);/*入居者数の出力*/
			}
			printf("\n");/*改行*/
		}

		if (i == 0 || i == 1 || i == 2)/*iが3でないとき*/
		{
			printf("####################\n");/*#の入力と改行*/
		}
	}

	return 0;
}


Measured memory_bytes: 2128
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;

vector<ll> divisor(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret), greater<ll>());
  return (ret);
}


int main(){ 
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll> yaku = divisor(n);
  ll k = yaku.size();
  if(k%2!=0){
    ans += 2*(yaku[k/2]-1);
  }
  else{
    ans += yaku[(k-1)/2]-1+yaku[(k-1)/2+1]-1;
  }
  cout << ans << endl;

  return 0;

}


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

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

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

  if (a == b) cout << c << '\n';
  else if (b == c) cout << a << '\n';
  else cout << b << '\n';

  return (0);
}


Measured memory_bytes: 3608
import numpy as np
N,M = map(int,input().split())
L = np.array([list(map(int,input().split())) for _ in range(N)])
l = [[1,1,1],[1,1,-1],[1,-1,1],[-1,1,1],[1,-1,-1],[-1,-1,1],[-1,1,-1],[-1,-1,-1]]
ans = 0
for i in range(8):
    su = L[:,0]*l[i][0]+L[:,1]*l[i][1]+L[:,2]*l[i][2]
    s = np.sort(su)[::-1]
    ans = max(ans,sum(s[:M]))
print(ans)

Measured memory_bytes: 22044
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, ql, qr, len, tim, a[MAXN], b[MAXN], cir[MAXN], q[MAXN], d[MAXN], par[MAXN], vis[MAXN];
vector <int> adj[MAXN];
bool c[MAXN];

inline void Dfs(int x)
{
	for (auto y : adj[x])
		if (!c[y])
			Dfs(y);
	tim ++;
	for (auto y : adj[x])
		if (!c[y])
			vis[a[y]] = tim;
	while (vis[a[x]] == tim)
		a[x] ++;
	b[x] = a[x];
}

inline void Dfs(int x, int ban)
{
	for (auto y : adj[x])
		if (c[y] && (y ^ ban))
			Dfs(y, ban);
	tim ++;
	for (auto y : adj[x])
		vis[b[y]] = tim;
	while (vis[b[x]] == tim)
		b[x] ++;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		par[i] = Read(), adj[par[i]].pb(i), d[par[i]] ++;
	for (int i = 1; i <= n; i ++)
		if (!d[i])
			q[++ qr] = i;
	while (ql ^ qr)
	{
		int x = q[++ ql];
		if (!-- d[par[x]])
			q[++ qr] = par[x];
	}
	for (int i = 1; i <= n; i ++)
		if (d[i])
			for (int x = i; d[x]; x = par[x])
				d[x] = 0, c[cir[len ++] = x] = 1;
	for (int i = 0; i < len; i ++)
		Dfs(cir[i]);
	Dfs(cir[len - 1], cir[0]);
	tim ++;
	for (auto y : adj[cir[0]])
		vis[b[y]] = tim;
	for (int i = 0; ; i ++)
		if (vis[i] ^ tim)
		{
			if (b[cir[0]] == i)
				return puts("POSSIBLE"), 0;
			break;
		}
	mcpy(b, a);
	tim ++;
	for (auto y : adj[cir[0]])
		if (!c[y])
			vis[b[y]] = tim;
	for (int i = 0, f = 0; ; i ++)
		if (vis[i] ^ tim)
			if (!f)
				f = 1;
			else
			{
				b[cir[0]] = i;
				break;
			}
	Dfs(cir[len - 1], cir[0]);
	tim ++;
	for (auto y : adj[cir[0]])
		vis[b[y]] = tim;
	for (int i = 0; ; i ++)
		if (vis[i] ^ tim)
		{
			if (b[cir[0]] == i)
				return puts("POSSIBLE"), 0;
			return puts("IMPOSSIBLE"), 0;
		}
}


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

int main(void){
	int x,n;
	scanf("%d%d",&x,&n);
	if(n==0){
		printf("%d",x);
		return 0;
	}
	int p[n];
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	int seek = 0;
	for(int l=0;l<=51;l++){
			for(int i=0;i<n;i++){
				if(x-l == p[i]){
					seek++;
				}
			}
			if(seek==0){
				printf("%d",x-l);
				return 0;
			}
			seek = 0;
			for(int i=0;i<n;i++){
				if(x+l == p[i]){
					seek++;
				}
			}
			if(seek==0){
				printf("%d",x+l);
				return 0;
			}
			seek=0;
		}
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

    cin >> n;
	vi a(n),b(n);
	ans = 1;
	REP(i,n){
    	cin >> a[i] >> b[i];
    	//ans*=k-m+1;
    }
	sort(ALL(a));sort(ALL(b));
	ll cent = ((n-1)/2+n/2)/2;
	ans = b[cent] - a[cent];
	if(n%2==0){
    	ans+=b[cent+1] - a[cent+1];
    }
	/*REP(i,n){
    	dbg(ab[i].first);
    	dbg(ab[i].second);
    	dbglf;
    }*/
    cout << ans+1 << endl;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define fo(i, a, b) 	for (int i=a; i<(b); i++)
#define forev(i, b, a) 	for (int i = (b)-1; i >= a; i--)
typedef unsigned long long int	lli;
typedef long double		ld;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define enl	"\n"
#define fast	ios_base::sync_with_stdio(0); cin.tie(0);
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

void printString(uint64_t n)
{
	char* str = new char[200]; uint64_t i = 0;
	while (n > 0) {
		uint64_t rem = n % 26;
		if (rem == 0) {
			str[i++] = 'z';
			n = (n / 26) - 1;
		}
		else {
			str[i++] = (rem - 1) + 'a';
			n = n / 26;
		}
	}
	str[i] = '\0';
	reverse(str, str + strlen(str));

	cout << str << endl;
}



int main() {
	fast;
	// int t; cin >> t; while (t--)
	uint64_t n; cin >> n;
	printString(n);

	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
   int N, M;
   long long int money = 0;

   cin >> N >> M;

   long long int *A = new long long int[N]; //値段
   long long int *B = new long long int[N]; //取扱数

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

   size_t *index = new size_t[N];
   iota(index, index+N, 0);

   stable_sort(index, index+N, [&A](size_t i1, size_t i2){
      return A[i1] < A[i2];
   });

   int want = M;

   for(int i=0;i<N;i++){
      int d = index[i];
      if(want > B[d]){
         money += A[d] * B[d];
         want -= B[d];
      }else if(want <= B[d]){
         money += A[d] * want;
         break;
      }
   }

   cout << money << endl;

   return 0;
}


Measured memory_bytes: 2944
local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local function solve(x)
  local c = 0
  for i = 1, n do
    c = c + mma(0, mce(t[i] / x) - 1)
  end
  return c <= k
end
local min, max = 0, 1000000000
while 1 < max - min do
  local mid = mfl((min + max) / 2)
  if solve(mid) then
    max = mid
  else
    min = mid
  end
end
print(max)


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
int N;
main(){for(cin>>n>>k,N=n;--n;*Z-=T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=0);n<N;a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       //*Z-=*O=W(*O=0);
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38008
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int a5 = a % 10;
    int a3 = a / 100;
    int a4 = a / 10  % 10;
    int a2 = a /1000 % 10;
    int a1 = a / 10000;
    int b5 = b % 10;
    int b3 = b / 100;
    int b4 = b / 10 % 10;
    int b2 = b /1000 % 10;
    int b1 = b / 10000;

    int ans = b3 - a3 - 1;
    if(a2 < a4)
    {
        
    }
    else if(a2 == a4)
    {
        if(a1 < a5)
        {
           
        }
        else
        {
            ans++;
        }
    }
    else ans++;
    if(b2 > b4)
    {
        
    }
    else if(b2 == b4)
    {
        if(b1 > b5)
        {
            
        }
        else
        {
            ans++;
        }
    }
    else ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
	int n, m;
	cin >>n >>m;
	cout <<2 * m - n <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a[3][10]={0},b[3][10]={0},c[3][10]={0},d[3][10]={0};
	int i,k,num,tou,f,r,v;
	
	scanf("%d",&num);
	for(i=0;i<num;i++){
		scanf("%d %d %d %d",&tou,&f,&r,&v);
		switch(tou){
				case 1:a[f-1][r-1]+=v;
				break;
				
				case 2:b[f-1][r-1]+=v;
				break;
				
				case 3:c[f-1][r-1]+=v;
				break;
				
				case 4:d[f-1][r-1]+=v;
				break;
		}	
	}
	for(i=0;i<3;i++){
		for(k=0;k<10;k++){
			printf(" %d",a[i][k]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(i=0;i<3;i++){
		for(k=0;k<10;k++){
			printf(" %d",b[i][k]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(i=0;i<3;i++){
		for(k=0;k<10;k++){
			printf(" %d",c[i][k]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(i=0;i<3;i++){
		for(k=0;k<10;k++){
			printf(" %d",d[i][k]);
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m;
    cin>>n>>m;
    int a=0;
    rep(i,m){
        int b;
        cin>>b;
        a+=b;
    }
    if(n>=a) cout<<n-a<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3624
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
#define int long long
signed main() {
    int n,k;cin >> n >> k;
    int p = 1;
    int j;
    bool ok = false;
    rep(i, 30) {
        p*=k;
        if(p>n){
            j=i;
            break;
        }
        if(p==n) {
            ok = true;
            j=i;
            break;
        }
    }
    if(ok) cout << j+2 << endl;
    else cout << j+1 << endl;
    return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


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

  vi d(3);
  rep(i, 3) cin >> d[i];

  int x = *max_element(all(d));

  int goal = x + x + x;
  int sum = accumulate(all(d),0);

  if ((goal - sum) % 2) goal = (x+1) * 3;
  cout << (goal - sum) / 2 << endl;
}


Measured memory_bytes: 3616
fn main() {
    let mut line: String = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let digits = line.trim().chars().collect::<Vec<_>>();

    println!("{}", calc(&digits, 0));
}

fn calc(digits: &[char], parent_value: u64) -> u64 {
    if digits.len() == 0 {
        parent_value
    } else {
        (1..digits.len()+1)
            .map(|i| calc(&digits[i..], to_num(&digits[0..i]) + parent_value))
            .sum()
    }
}

fn to_num(d :&[char]) -> u64 {
    d.iter().rev().enumerate().fold(0, |acc, (i, n)| {
        acc + n.to_digit(10).unwrap() as u64 * 10u64.pow(i as u32)
    })
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int x = 0;
	int y = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'a'&&x < A + B){x++; cout << "Yes" << endl;}
		else if (S[i] == 'b'&&x < A + B && y < B){x++; y++; cout << "Yes" << endl;}
		else cout << "No" << endl;
	}
}



Measured memory_bytes: 896
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

N = int(input())
S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

num_E = [0] * N
num_W = [0] * N
max_num = 0
leader_index = 0
for i, c in enumerate(S):
    if c == "W":
        num_W[i] = num_W[i - 1] + 1
        num_E[i] = num_E[i - 1]
    else:
        num_W[i] = num_W[i - 1]
        num_E[i] = num_E[i - 1] + 1
    tmp = num_E[i] - num_W[i]
    if max_num < tmp:
        leader_index = i
        max_num = tmp

print(S[:leader_index].count("W") + S[leader_index + 1:].count("E"))

Measured memory_bytes: 23784