akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    string s; cin >> s;
    int n = s.size();

    s.erase(s.size()-1,1);

    for(int i = 1; s.size() > 1; i++){
        string tf = s.substr(0,s.size()/2);
        string tb = s.substr(s.size()/2,s.size()/2);
        //reverse(tb.begin(), tb.end());
        //cout << tf << " " << tb << endl;
        if(tf == tb && s.size() % 2 == 0){
            put(s.size());
            return 0;
        }
        s.erase(s.size()-1,1);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
    int x, y;
    while (cin >> x >> y, x || y)
    {
        cout << min(x, y) << ' ' << max(x, y) << endl;
    }
}



Measured memory_bytes: 2996
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

a,b,c,d = map(int,stdin.readline().rstrip().split())

if d > a+b:
    print(a-(d-a-b))
elif d < a:
    print(d)
else:
    print(a)

Measured memory_bytes: 9168
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=i+1
a=sorted(a)
def f(x):
    ans=0
    for i in range(n):
        ans+=abs(x-a[i])
    return ans

if n%2==0:
    m=n//2
else:
    m=(n+1)//2

print(f(a[m-1]))





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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll w, h;
    cin>>w>>h;
    vpii p(w + h);
    rep(i, w) {
        cin >> p[i].first;
    }
    rep(i, h){
        cin>>p[i + w].first;
        p[i + w].second = 1;
    }
    
    sort(all(p));

    ll ans = 0;
    h++; w++;
    rep(i, p.size()) {
        if (p[i].second == 1) {
            ans += w * p[i].first;
            h--;
        } else {
            ans += h * p[i].first;
            w--;
        }
    }

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


Measured memory_bytes: 1792
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
main = do
    [a,b]::[Int] <- map read . words <$> getLine
    putStrLn $ case a `compare` b of
                   GT -> "a > b"
                   EQ -> "a == b"
                   LT -> "a < b"

Measured memory_bytes: 3640
#include <stdio.h>


 int main(){int n,m,a[100][100],b[100],c[100],S=0,countA,countB;
 	scanf("%d %d",&n,&m);
 	for(countA=1;countA<=n;countA++){
 	   for(countB=1;countB<=m;countB++){
 	   scanf("%d",&a[countA-1][countB-1]);
 	   };};
 	   
 	   for(countA=1;countA<=m;countA++){
 	   scanf("%d",&b[countA-1]);
 	   };
 	   
 	   for(countA=1;countA<=n;countA++){
 	   for(countB=1;countB<=m;countB++){
 	   S=S+a[countA-1][countB-1]*b[countB-1];
 	   };c[countA-1]=S;
 	   S=0;
 	   };
 	   
 	   for(countA=1;countA<=n;countA++){
 	   printf("%d\n",c[countA-1]);
 	   };
 return 0;}
 


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

int main() {
    long long N;
    cin >> N;
    vector <long long> A(N+1);
    vector <long long> B(N);
    for (long long i=0; i<=N; i++) cin >> A.at(i);
    long long ans=0;
    for (long long i=0; i<N; i++) {
        long long B;
        cin >> B;
        ans += min(B, A.at(i));
        B = max((long long)0, B-A.at(i));
        if (B>0) {
            ans += min(B, A.at(i+1));
            A.at(i+1)=max((long long)0, A.at(i+1)-B);
        }
    }
    cout << ans;
}

Measured memory_bytes: 4700
#include <bits/stdc++.h>
#define lli long long int

using namespace std;
vector<pair<int,int > >adj[100010];
bool visit[100010];
int  dis[100010];
bool dfs(int v)
{
    visit[v]=1;
    bool ret=1;
    for(int i=0;i<adj[v].size();i++)
    {
        int u=adj[v][i].first;
        if(!visit[u])
        {
            dis[u]=dis[v]+adj[v][i].second;
            ret&=dfs(u);
            if(!ret)
                return 0;
        }
        else
            if(dis[u]!=dis[v]+adj[v][i].second)
            return 0;
    }
    return ret;
}

int main()
{

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        adj[a].push_back({b,c});
        adj[b].push_back({a,-c});
    }
 for(int i=1;i<=n;i++)
 {
     if(!visit[i])
     {
         if(!dfs(i))
         {
             cout <<"No";
             return 0;
         }
     }
 }
 cout <<"Yes";


}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q.r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

struct Cube
{
    ll f[6];
    //0 top
    //1 front
    //2 right
    //3 left
    //4 back
    //5 bottom
};

//実行部
void Main()
{
    Cube saikoro;
    rep(i, 6)
    cin >> saikoro.f[i];
    ll n;
    cin >> n;
    for(ll i = 0;i < n;i++)
    {
        ll a, b;
        cin >> a >> b;
        if(a == b) break;
        else if(saikoro.f[1] == a&&saikoro.f[5] == b || saikoro.f[5] == a&&saikoro.f[4] == b || saikoro.f[4] == a&&saikoro.f[0] == b || saikoro.f[0] == a&&saikoro.f[1] == b) fin(saikoro.f[2])
        else if(saikoro.f[1] == b&&saikoro.f[5] == a || saikoro.f[5] == b&&saikoro.f[4] == a || saikoro.f[4] == b&&saikoro.f[0] == a || saikoro.f[0] == b&&saikoro.f[1] == a) fin(saikoro.f[3])

        else if(saikoro.f[2] == a&&saikoro.f[0] == b || saikoro.f[0] == a&&saikoro.f[3] == b || saikoro.f[3] == a&&saikoro.f[5] == b || saikoro.f[5] == a&&saikoro.f[2] == b) fin(saikoro.f[1])
        else if(saikoro.f[2] == b&&saikoro.f[0] == a || saikoro.f[0] == b&&saikoro.f[3] == a || saikoro.f[3] == b&&saikoro.f[5] == a || saikoro.f[5] == b&&saikoro.f[2] == a) fin(saikoro.f[4])

        else if(saikoro.f[3] == a&&saikoro.f[1] == b || saikoro.f[1] == a&&saikoro.f[2] == b || saikoro.f[2] == a&&saikoro.f[4] == b || saikoro.f[4] == a&&saikoro.f[3] == b) fin(saikoro.f[0])
        else if(saikoro.f[3] == b&&saikoro.f[1] == a || saikoro.f[1] == b&&saikoro.f[2] == a || saikoro.f[2] == b&&saikoro.f[4] == a || saikoro.f[4] == b&&saikoro.f[3] == a) fin(saikoro.f[5])
    }
    return;
}

//前処理
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20); //高精度少数表示
    Main();
    return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>


using namespace std;

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

    int len1 = s1.length() + 1;
    int len2 = s2.length() + 1;

    vector< vector<int> > mat;
    mat.resize(len1);
    for (int i = 0; i < len1; ++i)
    {
        mat[i].resize(len2);
    }

    for (int i = 0; i < len1; ++i)
    {
        mat[i][0] = i;
    }
    for (int j = 0; j < len2; ++j)
    {
        mat[0][j] = j;
    }

    for (int i = 1; i < len1; ++i)
    {
        for (int j = 1; j < len2; ++j)
        {
            mat[i][j] = min(mat[i-1][j], mat[i][j-1]);
            if (s1[i-1] == s2[j-1])
            {
                mat[i][j] = min(mat[i-1][j-1], ++mat[i][j]);
            }
            else
            {
                mat[i][j] = min(mat[i-1][j-1], mat[i][j]);
                ++mat[i][j];
            }
        }
    }
/* for debugging
    for (int i = 0; i < len1; ++i)
    {
        for (int j = 0; j < len2; ++j)
        {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
*/

    cout << mat.back().back() << endl;

}

Measured memory_bytes: 4964
#include<iostream>
using namespace std;
int main()
{
	int n,x,maxi=-5,cnt=0;
	cin>>n;
	cin>>x;
	maxi=x;cnt++;
	for(int i=1;i<n;i++)
	{
		cin>>x;
		if(x>=maxi)
		cnt++;
		if(x>maxi)
		maxi=x;
		
	}
	cout<<cnt;
	
	
	
	
	
	
	
	return 0;
}

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

for i in range(len(s)):
    if k==0:break

    num=ord(s[i])
    ch_num=123-num
    if i==len(s)-1:
        s[i]=chr(97+(num+k-97)%26) #if num+k>122 else chr(num+k)
        #print(97+(num+k-97)%26)
        k=0
        break
    elif s[i]=='a':continue
    elif ch_num<=k:
        s[i]='a'
        k-=ch_num
print(''.join(s))

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            if(i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    vector<ll> a(3);
    ll d, n;
    cin >> a[0] >> a[1] >> a[2] >> d >> n;
    a[0] *= 4;
    a[1] *= 2;
    sort(a.begin(), a.end());
    ll ans = 0;
    if (a[0] * 2 <= d)
    {
        ans = a[0] * n;
    }
    else
    {
        ans = d * (n / 2) + a[0] * (n % 2);
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    set <int> box;
    int u;
    while(n--) {
        cin >> u;
        if(box.count(u)) {
            cout << "NO";
            return 0;
        }
        box.insert(u);
    }
    
    cout << "YES";
    
    return 0;
}

Measured memory_bytes: 9600
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B = rl()

from fractions import gcd
from functools import reduce

def get_gcd(A):
    return reduce(gcd, A)

def get_lcm(A):
	def lcm_base(a, b):
		return a*b//gcd(a,b)
	return reduce(lcm_base, A, 1)

print(get_lcm([A, B]))


Measured memory_bytes: 63980
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
tmp_old = A[0] - 1
for i in range(N):
    ans += B[A[i] - 1]
    tmp = A[i] - 1
    if tmp == tmp_old + 1:
        ans += C[tmp_old]
    tmp_old = tmp
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#define int long long
#define WHITE 0
#define GRAY 1
#define BLACK 2
typedef long long ll;
using namespace std;

int N, k, d[100];
vector<int> E[100];

void bfs(int s){
    queue<int> Q;
    d[s] = 0;
    Q.push(s);
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int i=0;i<E[u].size();i++){
            if(d[E[u][i]] == -1){
                d[E[u][i]] = d[u]+1;
                Q.push(E[u][i]);
            }
        }
    }
}

signed main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> k >> k;
        for(int j=0;j<k;j++) {
            int node;
            cin >> node;
            node--;
            E[i].push_back(node);
        }
    }
    for(int i=0;i<N;i++) d[i] = -1;
    bfs(0);
    for(int i=0;i<N;i++) cout << i+1 << " " << d[i] << endl;
    return 0;
}



Measured memory_bytes: 3172
def LI():return list(map(int,input().split()))
from collections import Counter, deque, defaultdict
from heapq import heappop, heappush
import numpy as np
import math
# p=math.pi


s=list(input())
t=list(input())
cnt=0
for i,j in zip(s,t):
    if i!=j:
        cnt+=1
print(cnt)

Measured memory_bytes: 29952
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    vector <int> A;
    while (n>0) {A.push_back((n%26+25)%26);n=(n-1)/26;}
    int m=A.size();
    for (int i=m-1;i>=0;i--) {
		char x=A[i]+'a';
		cout<<x;
		}
		cout<<endl;
    return 0;
}


Measured memory_bytes: 3648
//
// Copyright 2018 Authors All Rights Reserved.
//
// FileName: C.cc
// Author: Beiyu Li <sysulby@gmail.com>
// Date: 2018-08-25
//
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)

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

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

const int maxn = 100000 + 5;

int n, k;
int a[maxn];

int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &k);
  rep(i,n) scanf("%d", &a[i]);
  a[n] = inf;
  int ret = inf;
  int o = lower_bound(a, a + n, 0) - a;
  rep(i,n) {
    if (a[i] < 0) {
      int c = o - i + (a[o] == 0);
      if (c >= k) ret = min(ret, -a[i]);
      else if (i + k <= n) ret = min(ret, -a[i] + a[i+k-1] - a[i]);
    } else {
      int c = i - o + 1;
      if (c >= k) ret = min(ret, a[i]);
      else if (i >= k - 1) ret = min(ret, a[i] + a[i] - a[i-k+1]);
    }
  }
  printf("%d\n", ret);

  return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int N, M;
    cin >> N >> M;

    cout << (N==M ? "Yes" : "No") << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n, a, b; cin >> n >> a >> b;
    if((b-a)%2 == 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

x = ni()
can = False
for i in range(1, x + 1):
    if 0 <= x - 100*i <= 5*i:
        can = True
        break
    if x - 100*i < 0:
        break
print('1' if can else '0')

Measured memory_bytes: 3064
import sys

queue = []

header = sys.stdin.readline()
(n, q) = header.strip().split()
q = int(q)

for line in sys.stdin.readlines():
  (name, time) = line.strip().split()
  queue.append((name, int(time)))

total_time = 0
while len(queue) > 0:
  (name, time) = queue.pop(0)
  time -= q
  if time > 0:
    total_time += q
    queue.append((name, time))
  else:
    total_time += time + q
    print "%s %s" % (name, total_time)

Measured memory_bytes: 15312
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int X; cin >> X;
    for (Int a = -200; a <= 200; a++) {
        for (Int b = -200; b <= 200; b++) {
            if (a*a*a*a*a - b*b*b*b*b == X) {
                cout << a << ' ' << b << '\n';
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3652
N,x = map(int, input().split())
alist = list(map(int,input().split()))
ans = 0

if alist[0] > x:
    ans += (alist[0] - x)
    alist[0] -= (alist[0] - x)

for al in range(1,N):
    if (alist[al-1]+alist[al]) > x:
        ans += (alist[al-1]+alist[al]) - x
        alist[al] -= (alist[al-1]+alist[al]) - x

print(ans)

Measured memory_bytes: 14252
#include<stdio.h>
int main(void){int a,b,c,d,p
;scanf("%d%d%d%d%d",&a,&b,&c
,&d,&p);a*=p;if(p>c)b+=d*(p-
c);if(a>b)a=b;printf("%d\n",
a);return 0;}

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

int main() {
    int N, M, D;
    cin >> N >> M >> D;

    double ans = 1.0 * (N - D) / N / N * (M - 1);
    if (D != 0) {
        ans *= 2;
    }
    cout << setprecision(10) << ans << endl;
}


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

using namespace std;
using ll =long long;
#define rep(i,n) ;for( int i =0; i < n ; i ++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
int main(){
  ll n,k;
  cin>>n>>k;
  ll keta =1;
  while(n>=k){
    n = n/k;
    keta +=1;
  }
  cout<<keta<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<queue>
#include<ctime>
#include<vector>
using namespace std;
inline int rd(){
  register char ch=getchar();
  register bool flag=false;
  register int res=0;
  while(ch<'0'||ch>'9'){flag=(ch=='-');ch=getchar();}
  while(ch>='0'&&ch<='9'){
    res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
  if(flag)res=-res;
  return res;
}
#define INF 10000000000000000LL
#define N 300010
#define int long long
int n,m,ans=0;
int a[N];
int f[N],g[N];//getmaxa,getminb
int D;
bool cmp(const int &x,const int &y){
  return D?(x<y):(x>y);
}
/*struct treap{
  int key[N];
  int val[N];
  int sum[N],sz[N],ls[N],rs[N];
  #define fi first
  #define se second
  #define mp make_pair
  inline void upd(int x){
    sum[x]=sum[ls[x]]+sum[rs[x]]+val[x];
    sz[x]=sz[ls[x]]+sz[rs[x]]+1;
  }
  inline int merge(int u,int v){
    if(!u||!v)return u|v;
    if(key[u]>key[v]){rs[u]=merge(rs[u],v),upd(u);return u;}
    else {ls[v]=merge(u,ls[v]);upd(v);return v;}
  }
  inline int getlf(int u,int k){
    int res=0; 
   while(u)
     if(val[u]<=k)res+=sz[ls[u]]+1,u=rs[u];
     else u=ls[u];
   return res;
  }
  inline int getrf(int u,int k){
    int res=0;
    while(u)
      if(val[u]>=k)res+=sz[rs[u]]+1,u=ls[u];
      else u=rs[u];
    return res;
  }
  inline int getval(int u,int k){
    int res=0;
    while(u)
      if(k<=sz[ls[u]])u=ls[u];
      else k-=sz[rs[u]],res+=sum[ls[u]]+a[u];
    return res;  
 }
  inline pair<int,int>split(int u,int k){
    if(!k)return mp(0,u);
    if(k>=sz[u])return mp(u,0);
    pair<int,int>A;
    if(k<=sz[ls[u]]){
      A=split(ls[u],k);ls[u]=A.se;A.se=u;upd(u);return A;
    }
    else {
      A=split(rs[u],k-sz[ls[u]]-1);
      rs[u]=A.fi;A.fi=u;upd(u);return A;
    }
  }
  inline void insert(int v){
  
  }
  }T;*/
priority_queue<int>Q;
int sum;
void work(){
  n=rd();//m=rd();
  int i,j;
  for(i=1;i<=n+n+n;i++)
    a[i]=rd();//直接用堆就可以了
  for(i=1;i<=n;i++)
    Q.push(-a[i]),sum+=a[i];
  f[n]=sum;
  for(;i<=n+n;i++){
    Q.push(-a[i]);sum+=Q.top();Q.pop();sum+=a[i];
    f[i]=sum; 
  }while(!Q.empty())Q.pop();
  sum=0;
   for(i=n+n+n;i>n+n;i--)
    Q.push(a[i]),sum+=a[i];
   g[n+n+1]=sum;
   for(;i>n;i--){
     Q.push(a[i]);sum-=Q.top();Q.pop();sum+=a[i];
     g[i]=sum;
  }
   sum=-INF;
   for(i=n;i<=n+n;i++){
     sum=max(sum,f[i]-g[i+1]);}
   printf("%lld\n",sum);
}
#undef int
int main(){
  work();
  return 0;
}


Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n,k;
    cin>>n>>k;
    const ll mod=1e9+7;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll sum1=0,sum2=0;
    for(int i=0; i<n-1; ++i){
        for(int j=i+1; j<n; ++j){
            if(a[i]>a[j])sum1++;
        }
    }
    ll ans=sum1*k;
    ans%=mod;
    rep(i,n){
        rep(j,n){
            if(a[i]>a[j])sum2++;
        }
    }
    ans+=sum2*((k*(k-1)/2)%mod);
    ans%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
n = int(input())

for i in range(1, n+1):
    if i % 3 == 0:
        print(" " + str(i), end="")
    else:
        x = i
        while(x):
            if x % 10 == 3:
                print(" " + str(i), end="")
                break
            x //= 10

print()


Measured memory_bytes: 5868
def main():
    S = input()
    T = input()
    from collections import defaultdict
    dic1 = defaultdict(set)
    dic2 = defaultdict(set)
    for s, t in zip(S, T):
        dic1[s].add(t)
        dic2[t].add(s)
        if len(dic1[s]) > 1 or len(dic2[t]) > 1:
            return print("No")
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 41968
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int number[] = new int[n];
        for(int i = 0; i < n; i++){
        	number[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < n; i++){
        	while(number[i] % 2 == 0){
            	number[i] = number[i] / 2;
                count ++;
            }
        }
        System.out.println(count);
     }
}

Measured memory_bytes: 48740
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 100010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

//const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll n;cin>>n;
  vl a(n+1);
  rep(i,n+1)cin>>a[i];
  COMinit();
  map<ll,ll>M;
  ll key=-1;
  rep(i,n+1){
    M[a[i]]++;
  }
  for(auto p:M){
    if(p.second==2)key=p.first;
  }
  ll id1=-1,id2=-1;
  rep(i,n+1){
    if(a[i]==key&&id1==-1){
      id1=i;
    }
    else if(a[i]==key){
      id2=i;
    }
  }
  ll point=id1-0+n-id2;
  for(ll i=1;i<=n+1;i++){
    if(point+1<i){
      cout<<COM(n+1,i)<<endl;
    }
    else {
      ll ans=COM(n+1,i);
      ll d=COM(point,i-1);
      ans=ans+MOD-d;
      ans%=MOD;
      cout<<ans<<endl;
    }
  }
}



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

using namespace std;

int main(void)
{
	int n,m; cin>>n>>m;
	string a[n],b[m];
	for(int i = 0; i < n; i++) cin>>a[i];
	for(int i = 0; i < m; i++) cin>>b[i];
	/*
	char a[n][n],b[m][m];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin>>a[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			cin>>b[i][j];
		}
	}
	*/
	for(int i = 0; i <= n-m; i++){
		for(int j = 0; j <= n-m; j++){
			int ac_num = 0;
			for(int h = 0; h < m; h++){
				for(int w = 0; w < m; w++){
					if(a[i+h][j+w] == b[h][w]){
						//cout<<"i = "<<i<<", j = "<<j<<", h = "<<h<<", w = "<<w<<endl;
						//cout<<"a[i+h][j+w] = "<<a[i+h][j+w]<<", b[h][w] = "<<b[h][w]<<endl;
						ac_num++;
					}
				}
			}
			if(ac_num == m*m){
				cout<<"Yes"<<endl;
				//cout<<"i = "<<i<<", j = "<<j<<endl;
				//cout<<"a[i] = "<<a[i]<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, k, tmp;
	int i;
	int count1 = 0;
	int count2 = 0;
	
	scanf("%d", &n);
	tmp = n % 10;
	n = n / 10;
	for(i=1;i<3;i++){
		k = n % 10;
		n = n / 10;
		if(k == tmp){
			tmp = k;
			count1 += 1;
		}else{
			tmp = k;
			count2 += 1;
			count1 = 0;
			if(i > 1){
				printf("No\n");
				return 0;
			}
		}
	}
	if(k == n){
		count1 += 1;
	}else{
		count2 += 1;
	}
	if(count1 >= 2){
		printf("Yes\n");
	}
	if(count2 >= 2){
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 4100001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    com_init();
    int n, k; cin >> n >> k;
    if (n <= k - 1) {
        cout << com_mod(2 * n - 1, n) << "\n";
    } else {
        int ans = 0;
        rep (i, k + 1) {
            ans = mod(ans + mul_mod(com_mod(n, i), com_mod(n - 1, i)));
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 96384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int a,n;
	string b[105];
    cin>>a>>n;
    for(int s=0;s<a;s++)
        cin>>b[s];
    sort(b,b+a);
    for(int s=0;s<a;s++)
    cout<<b[s];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 4/13/2019, 9:01:56 PM
# Powered by Visual Studio Code
#

n = gets.to_i
h = gets.chomp.split(" ").map{|i| i.to_i}
ans = 0
for i in 0...n
  if i == 0
    ans += 1
  else
    ok = true
    for j in 0...i
      if h[j] > h[i]
        ok = false
        break
      end
    end
    if ok
      ans += 1
    end
  end
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int dx = x2-x1;
    int dy = y2-y1;
    
    int x3 = x2-dy;
    int y3 = y2+dx;
    
    int x4 = x1-dy;
    int y4 = y1+dx;
    
    cout << x3 << " "<< y3 << " " << x4 << " " << y4 << endl;
    
    
}



Measured memory_bytes: 256
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())

A = list(map(int, input().split()))

A.sort(reverse=True)
S = sum(A)
if S <= A[M - 1] * 4 * M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 6348
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	V<ll> a,b;
	int N,K;
	cin>>N>>K;
	rep(i,N){
		ll x;
		cin>>x;
		if(x>=0) b.pb(x);
		else a.pb(-x);
	}
	sort(all(a));
	sort(all(b));
	ll ans = 1e18;
	rep(A,K+1){
		int B = K-A;
		if(A>a.size() || B>b.size()) continue;
		ll x = A==0 ? 0 : a[A-1];
		ll y = B==0 ? 0 : b[B-1];
		if(x>y) swap(x,y);
		chmin(ans,x+x+y);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define modulo 998244353



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n;
    cin>>m>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=inf;
    ll ma=-inf;
    for(ll i=0;i<n;i++)
    {
        ll p=a[(i-1+n)%n];
        ll ne=a[(i+1)%n];
        ll d1=ne-a[i];
        ll d2=a[i]-p;
        if(d1<0)
        {
            d1+=m;
            d1%=m;
        }
        if(d2<0)
        {
            d2+=m;
            d2%=m;
        }
        ma=max(ma,max(d1,d2));
    }
    cout<<m-ma<<nl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) (int)(x).size()
using namespace std;

#define N 100007

int x, y, z, n;

int A[N];
int B[N];
int C[N];

ll res = -INF, diff, sum;

multiset<int> S;

ll sumA[N];
ll sumB[N];

VI v;

bool comp(int a, int b)
{
	return A[a]-B[a]>A[b]-B[b];
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> x >> y >> z;

	n = x+y+z;

	for(int i = 1; i <= n; ++i)
	{
		cin >> A[i] >> B[i] >> C[i];
		diff += C[i];
		A[i] -= C[i];
		B[i] -= C[i];
		C[i] -= C[i];
		v.pb(i);
	}

	sort(ALL(v), comp);

	for(int i = 0; i < n; ++i)
	{
		S.insert(A[v[i]]);
		sum += A[v[i]];

		if(S.size()>x)
		{
			sum -= *S.begin();
			S.erase(S.begin());
		}

		sumA[i] += sum;
	}

	S.clear();
	sum = 0;

	for(int i = n-1; i >= 0; --i)
	{
		S.insert(B[v[i]]);
		sum += B[v[i]];

		if(S.size()>y)
		{
			sum -= *S.begin();
			S.erase(S.begin());
		}

		sumB[i] = sum;
	}

	for(int i = x-1; i+y < n; ++i)
	{
		res = max(res, sumA[i]+sumB[i+1]);
	}

	cout << res+diff;
}


Measured memory_bytes: 7800
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int cnt[2][105];

int main() {
	double a;
	cin >> a;
	double l = a / 3;
	double ans = l * l * l;
	printf("%f", ans);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a,x,b) (a<=x && x<=b)
#define WS std::cout<<" ";
#define NL std::cout<<"\n"
#define OUT(dist) std::cout<<(dist);
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;



int main(){
    INIT;
    int N, D;
    cin >> N >> D;
    int ans = 0;
    for(int i = 0; i < N; i+=(2*D+1)) {
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int N, K[100], P[100];

  cin >> N;

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

  for(int i = 0; i < N; i++)
  {
    if(K[i] % P[i] != 0)
    {
      cout << K[i] % P[i] << endl;
    }
    else
    {
      cout << P[i] << endl;
    }
  }

  return 0;
}

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

int main() {
	int num1, num2;
	int vol, around;
	cin >> num1 >> num2;

	vol = num1 * num2;
	around = num1 * 2 + num2 * 2;

	cout << vol << " " << around << endl;
	return 0;
}

Measured memory_bytes: 1164
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N, X, Y;
	cin >> N >> X >> Y;
	--X, --Y;

	vector<ll> res(N);
	ll val;
	for (ll j = 0; j < N; ++j) {
		for (ll i = 0; i < j; ++i) {
			if (i <= X) {
				if (j <= X) {
					val = j - i;
				}
				else if (j <= Y) {
					val = min({ j - i, X - i + 1 + Y - j});
				}
				else {
					val = X - i + 1 + j - Y;
				}
				++res[val];
			}
			else if (i <= Y) {
				if (j <= Y) {
					val = min({ j - i, i - X + 1 + Y - j });
				}
				else {
					val = min({ j - i, i - X + 1 + j - Y });
				}
				++res[val];
			}
			else {
				val = j - i;
				++res[val];
			}
		}
	}
		
	for (ll i = 1; i < N; ++i) {
		cout << res[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll div = 10LL;
  while(N / div > 0){
    ll num = N/div;
    ans += num;
    div *= 5LL;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7

def calc(n,r):
    x = 1
    y = 1
    for i in range(r):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())
res = pow(2, n, mod) - 1
 
for i in [a, b]:
    res -= calc(n, i)
print(res % mod)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n)for(int i=1;i<=n;i++)

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> table;
    rep(i,9)
    {
        rep(j,9)
        {
            table.push_back(i*j);
        }
    }
    sort(table.begin(),table.end());
    if(binary_search(table.begin(),table.end(),n))cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

    #define debug(args...)(Debugger()) , args

    class Debugger{
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << std::endl;}

        private:
        
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)
#endif

const int N = 3003;

int dp[N][N][4];
int a[N][N];
int r, c, k;

int valid(int x, int y){
	if(x >= r or y >= c or x < 0 or y < 0){
		return 0;
	}
	return 1;
}

int fun(int row, int col, int pick){

	if(row == r-1 and col == c-1){
		if(pick != 3){
			return a[row][col];
		}else{
			return 0;
		}
	}

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

	if(pick == 3){	
		if(valid(row, col+1))
			dp[row][col][pick] = fun(row, col+1, pick);
		if(valid(row+1, col))
			dp[row][col][pick] = max(dp[row][col][pick], fun(row + 1, col, 0));
	}else{
		if(valid(row, col+1))
			dp[row][col][pick] = max(fun(row, col+1, pick+1) + a[row][col], fun(row, col+1, pick));
		if(valid(row+1, col))
			dp[row][col][pick] = max(dp[row][col][pick], fun(row + 1, col, 0) + a[row][col]);
	}

	return dp[row][col][pick];
}

void solve(){

	cin >> r >> c >> k;

	MEM(a, 0);
	MEM(dp, -1);

	for(int i = 0; i < k; ++i){
		int rr, cc, vv;
		cin >> rr >> cc >> vv;
		rr--;
		cc--;

		a[rr][cc] = vv;
	}

	cout << fun(0, 0, 0) << "\n";

}


int32_t main(){

	boost;
	
	int T;
	
	// cin >> T;
	T = 1;
	
	while(T--){
		solve();
	}
}



Measured memory_bytes: 356280
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double> > pq;
	for (int i = 0; i < n; i++) {
		double tmp;
		cin >> tmp;
		pq.push(tmp);
	}
	while (pq.size() > 1) {
		double x = pq.top();
		pq.pop();
		double y = pq.top();
		pq.pop();
		pq.push((x + y) / 2);
	}
	cout << pq.top() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=924844033;

ll n;

int main()
{
	ios::sync_with_stdio(0);
    str s,t;
    cin >> n >> s >> t;
    For(i,0,n)
    {
        ll j;
        for (j=i;j<n;j++)
            if (s[j]!=t[j-i]) break;
        if (j==n)
            RET(i+n);
    }
    RET(2*n);
}    

Measured memory_bytes: 256
A,B,K = map(int,input().split(" "))
C=K-A
if C >= 0:
    E = 0
elif C < 0:
    E = C * -1  
else:
    E = C
if E > 0:
    F = B
else:
    D=B-C
    if D >= 0:
        F = D
    else:
        F = 0

print('{} {}'.format(E , F))

Measured memory_bytes: 3064
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    int N, X;
    cin >> N >> X;
    vector<int> A;
    A.resize(N);

    int64 result = 0;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        result += (A[i] > X ? A[i] - X : 0);
        A[i] = min(A[i], X);
    }

    for (int i = 1; i < N; i++) {
        int S = A[i-1] + A[i];
        if (S > X) {
            result += S - X;
            A[i] -= (S - X);
        }
    }

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/agc029/tasks/agc029_a

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    long ans = 0;

    // Wを左端に寄せ、Bは空洞扱いにする。
    int leftW = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'W') {
            ans += (i - leftW);
            leftW++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720