akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Including Policy Based DS
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI (2.0*acos(0.0))

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

//typedef tree<
//int,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)

// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=1000000007LL;
LL modMul(LL a, LL b){

    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
	if(b%2==1)x = (x%mod*a%mod)%mod;
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 100095;
//-------------------------------------------------------------------------------

LL dp[mx];
LL h[mx];

int main(){
//  READ;
//  WRITE;
//	BOOST;

    LL t,l,x,k,n,m;

    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>h[i];

	clr(dp,INF);
    dp[1]=0;

    for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
            if(i-j>0){
                dp[i] = min( dp[i-j]+abs(h[i]-h[i-j]),dp[i] );
            }
		}
    }

	cout<<dp[n]<<endl;




    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

const int N=1005,P=1e9+7;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

struct Matrix {
	int a[2][2]; 	
	Matrix(){ mem(a,0); } 
	Matrix operator*(const Matrix &r){
		Matrix c; 
		lop(i,0,2)lop(j,0,2)lop(k,0,2)c.a[i][j]=add(c.a[i][j],mul(a[i][k],r.a[k][j]));
		return c;
	}
} ; 



int power(int a,long long k){
	int res=1;
	for(;k;k>>=1,a=mul(a,a))if(k&1)res=mul(res,a);
	return res;
}

Matrix power(Matrix a,long long k){
	Matrix res;
	res.a[0][0]=res.a[1][1]=1;	
	for(;k;k>>=1,a=a*a)if(k&1)res=res*a;
	return res;
}

int n,m,a,b,c,rb,rc,cb,cc;
long long k;
char g[N][N]; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
//	freopen("dat.in","r",stdin);
//	freopen("my.out","w",stdout);
#endif

	scanf("%d%d%lld",&n,&m,&k); 
	rep(i,1,n)scanf("%s",g[i]+1);
	rep(i,1,n)rep(j,1,m)a+=g[i][j]=='#';
	rep(i,1,n)rep(j,1,m-1)rb+=g[i][j]==g[i][j+1]&&g[i][j]=='#';
	rep(i,1,n-1)rep(j,1,m)cb+=g[i][j]==g[i+1][j]&&g[i][j]=='#'; 
	rep(i,1,n)rc+=g[i][1]==g[i][m]&&g[i][1]=='#';
	rep(j,1,m)cc+=g[1][j]==g[n][j]&&g[1][j]=='#';
	//Pr("%d,%d,%d,%d,%d\n",a,rb,cb,rc,cc); 
	if(!rc&&!cc){
		printf("%d\n",power(a,k-1));
		return 0; 
	}
	if(rc&&cc){
		printf("%d\n",1);
		return 0; 
	}
	Matrix tr; 

	int b,c;
	if(rc)b=rb,c=rc;else b=cb,c=cc;

	tr.a[0][0]=a,tr.a[0][1]=P-b,tr.a[1][0]=0,tr.a[1][1]=c;
	//lop(i,0,2)lop(j,0,2)printf("%d%c",tr.a[i][j]," \n"[j+1==2]); 
	tr=power(tr,k-1);
	printf("%d\n",add(tr.a[0][0],tr.a[0][1]));

	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <cctype>

using namespace std;

int main()
{
        char str[201];

        fgets(str, 200, stdin);
        int len = strlen(str);
        str[len - 1] = '\0';
        for (int i = 0; i < len; i++) {
                str[i] = toupper(str[i]);
        }
        printf("%s\n", str);

        return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3620
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),k=in(),c=in();
    string s;cin>>s;
    vector<ll>v1(n,-1),v2(n,-1);

    ll next_ok=0,cnt=0;
    for(ll i=0;i<n;++i){
        if(s[i]=='o'&&i>=next_ok){
            v1[i]=++cnt;
            next_ok=i+c+1;
            if(cnt==k)break;
        }
    }

    next_ok=n-1;cnt=0;
    for(ll i=n-1;i>=0;--i){
        if(s[i]=='o'&&i<=next_ok){
            v2[i]=++cnt;
            next_ok=i-c-1;
            if(cnt==k)break;
        }
    }

    for(ll i=0;i<n;++i)if(v1[i]!=-1&&v2[i]!=-1&&v1[i]+v2[i]==k+1)cout<<i+1<<endl;
}


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

using namespace std;

int main() {
    long n;
    cin >> n;
    vector<long> a(n);
    for (long i = 0; i < n; ++i) {
        cin >> a[i];
    }
    long a2 = 0;
    for (long i = 0; i < n; ++i) {
        a2 += pow(-1, i) * a[i];
    }
    vector<long> b(n);
    b[0] = a2/2;
    for (long i = 1; i < n; ++i) {
        b[i] = a[i-1] - b[i-1];
    }
    for (long i = 0; i < n-1; ++i) {
        cout << b[i] * 2 << ' ';
    }
    cout << b[n-1] * 2 << endl;
	return 0;
}

Measured memory_bytes: 2944
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    print(X + Y // 2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int M = 10000, INF = 0x3f3f3f3f;

int dp[M + 1];

int main() {
	int m, n; cin >> m >> n;
	fill(dp, dp + m + 1, INF);
	dp[0] = 0;
	while (n--) {
		int a, b; cin >> a >> b;
		for (int x = 0; x < m; x++) {
			int y = min(x + a, m);
			dp[y] = min(dp[y], dp[x] + b);
		}
	}
	cout << dp[m] << '\n';
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int& x : p)
    	cin >> x;
  sort(p.begin(), p.end());
  long long sum = 0;
  for(int i = 0; i < k; i++)
    	sum += p[i];
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3628
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def bfs(N):
    q = deque(["7", "5", "3"])
    res = []

    while q:
        s = q.popleft()

        for c in ["7", "5", "3"]:
            new = s + c

            if int(new) > N:
                continue

            if "7" in new and "5" in new and "3" in new:
                res.append(new)

            q.append(new)

    return len(res)


def main():
    N = int(input())

    ans = bfs(N)
    print(ans)


if __name__ == "__main__":
    main()


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll ans = 0;
    ll A[N]; rep(i, N) cin >> A[i];
    sort(A, A+N); reverse(A, A+N);
    map<ll, int> avail;
    rep(i, N){
        if(avail.count(A[i])) avail[A[i]]++;
        else avail[A[i]] = 1;
    }
    rep(i, N){
        if(avail[A[i]] == 0) continue;
        else{
            ll msb = (1ll << 31);
            while((msb & A[i]) != msb) msb >>= 1;
            ll key = (msb << 1) - A[i];
            if(key == A[i]){
                if(avail[key] >= 2){
                    avail[key] -= 2;
                    ans++;
                }
            }
            else{
                if(avail[key] > 0){
                    avail[A[i]]--;
                    avail[key]--;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N=0;
  cin >> N;
  string color="";
  
  for(int i=0; i<N; i++){
    cin >> color;
    if(color == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  }  
  cout << "Three" << endl;
  return 0;
}
  


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#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)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

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

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b; cin >> a >> b;
  
  if (a + b >= 10) cout << "error\n";
  else cout << a + b << endl;
  
  return (0);
}

Measured memory_bytes: 3636
N,M=map(int,input().split())
l=sorted([list(map(int,input().split())) for i in range(N)])
ans=0
for i in l:
  if M-i[1]>0:
    M-=i[1]
    ans+=i[0]*i[1]
  else:
    ans+=i[0]*M
    break
print(ans)

Measured memory_bytes: 28652
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

lli d;
lli c[26];
lli s[370][26];
lli t[370];
lli lastDay[26];
std::chrono::system_clock::time_point start;

lli score(){

	lli ans = 0;
	REP(i,0,26)lastDay[i]=0;

	REP(i,1,d+1){
		ans += s[i-1][t[i-1]];

		lastDay[t[i-1]] = i;
		REP(j,0,26){
			ans -= c[j]*(i-lastDay[j]);
		}
		//cout<<ans<<endl;
	}
	return ans;
}

void dummyDayInput(){

	REP(i,0,d){
		cin>>t[i];
		//t[i]=1;
		t[i]--;
	}

}

void input(){
	cin>>d;
	REP(i,0,26)cin>>c[i];
	REP(i,0,d){
		REP(j,0,26){
			cin>>s[i][j];
		}
	}
}

void dummyDayChangeInput(){
	lli m;
	cin>>m;

	REP(i,0,m){
		lli d,q;
		cin>>d>>q;
		d--,q--;
		t[d] = q;
		cout<<score()<<endl;
	}
}

void init(){
	REP(i,0,365){
		lli maxD = -1;
		lli maxScore = 0;
		REP(j,0,26){
			if(maxScore<s[i][j]){
				maxScore = s[i][j];
				maxD = j;
			}
		}
		t[i] = maxD;
	}
}

void outputT(){
	REP(i,0,d){
		cout<<t[i]+1<<endl;
	}
}

int main(){

	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	start = std::chrono::system_clock::now();
	mt19937 mt{std::random_device{}()};

	const lli T = 1950*1000;

	input();
	init();

	uniform_int_distribution<int> contestDist(0,25);
	uniform_int_distribution<int> dayDist(0,d-1);

	lli prevScore=score();

	lli cnt = 0;
	
	while(1){
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        double elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now-start).count();
        if(elapsed > T)break;

        lli contestD = contestDist(mt);
        lli dayD     = dayDist(mt);

        LOG2(contestD,dayD);

        lli prevContest = t[dayD];
        t[dayD] = contestD;

        lli nowScore = score();
        if(cnt%1000==0)LOG3(cnt,nowScore,prevScore);
        if(prevScore>nowScore){
        	t[dayD] = prevContest;
        }
        else{
        	prevScore = nowScore;
        }
	}
	

	outputT();
	//dummyDayInput();
	//score();
	//dummyDayChangeInput();
 
	return 0;
}

Measured memory_bytes: 3724
program atcoder322_1
  read(5,*)N,M
  if(N<=1) then
     K=0
  else
     K=N*(N-1)/2
  end if
  if(M<=1) then
     K=K+0
  else
     K=K+M*(M-1)/2
  end if
  write(6,*)K
end program atcoder322_1

Measured memory_bytes: 768
package main

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	s := make([]int64, n+1)
	w := make([]int64, n+1)
	for i := 0; i < n; i++ {
		s[i+1] = s[i] + int64(a[i])
		w[i+1] = w[i] + int64(max(a[i], 0))
	}
	ans := int64(math.MinInt64)
	for i := 0; i <= n-k; i++ {
		x := w[n] - (w[i+k] - w[i])
		x += max64(s[i+k]-s[i], 0)
		ans = max64(ans, x)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    map<string, ll> mp1;
    forr(i, n)
    {
        string str;
        cin>>str;
        mp1[str]++;
    }
    cout<<mp1.size();
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 19256
#include <algorithm>
#include <iostream>
#include <vector>

#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define outl(d)         std::cout<<(d)<<"\n"
#define int             long long

using namespace std;
using ll = long long;

ll n, k;

ll solve2(vector<ll> x) {
  if (n == 1) return 0;

  vector<ll> y(n-1);
  for (int i = 1; i < n; i++)
    y[i-1] = x[i] - x[i-1];
  sort(y);

  ll ans = x[n-1] - x[0];
  for (int i = 0; i < k-1; i++) {
    ans -= y[n-2-i];
    if (ans < 0) return 0;
  }
  return ans;
}

void solve() {
  ll t; cin >> t;
  rep(i, t) {
    cin >> n >> k;
    vector<ll> x(n); rep(j, n) cin >> x[j];
    outl(solve2(x));
  }
}

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

  solve();
}



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

long long k, a, b;

int main(){
  cin >> k >> a >> b;
  if(a >= b - 2 || a > k){
    cout << k + 1 << endl;
  }else{
    long long rest = k - a + 1;
    cout << a + ((rest / 2) * (b - a))  + rest % 2<< endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    int n; cin >> n;
    bool flag = false;
    int count = 0;
    rep(i, n)
    {
        int d1, d2;
        cin >> d1 >> d2;
        if( d1 == d2 )
        {
            count++;
            if( count >= 3 ) flag = true;
        }
        else
        {
            count = 0;
        }
    }
    if( flag )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(void){

    string S;  cin >> S;
    bool flag = true;
    for(int i = 0 ; i < 3 ; i++)
        if(S[i] == S[i + 1])   flag = false;
    
    if(flag)  cout << "Good" << endl;
    else cout << "Bad" << endl;
    
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]+a[j]>a[k])
				{
					ans++;
				}
				else
				{
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int ans = 0;
	ans += x / 500 * 1000;
	x %= 500;
	ans += x / 5 * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn=2e5+1;
typedef pair<int,int> pii;

int n,a[maxn],res;
vector<pii>ans;

void solve1(int l,int r){
	while(a[r-1]>0){
		ans.pb(mp(a[l],a[r]));
		a[l]=a[l]-a[r];
		r--;
	}
	int pos=r;r--;
	while(r>=l){
		ans.pb(mp(a[pos],a[r]));
		a[pos]=a[pos]-a[r];
		r--;
	}
	res=a[pos];
}

void NET(){
	res=a[2]-a[1];
	ans.pb(mp(a[2],a[1]));
}

void solve3(){
	ans.pb(mp(a[1],a[2]));
	a[2]=a[1]-a[2];
	solve1(2,n);
}

void solve2(){
	ans.pb(mp(a[n],a[n-1]));
	a[n-1]=a[n]-a[n-1];
	solve1(1,n-1);
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	scanf("%d",a+i);
	sort(a+1,a+1+n);
	if (n==2) NET();
	else if (a[1]<0&&a[n]>0) solve1(1,n);
	else if (a[n]<=0) solve2();
	else if (a[1]>=0) solve3();
	printf("%d\n",res);
	for (int i=0;i<ans.size();++i){
		pii v=ans[i];
		printf("%d %d\n",v.fr,v.sc);
	}
}

Measured memory_bytes: 3188
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for _ in range(n):
    a=list(map(int,input().split()))
    calc=c
    for j in range(m):
        calc+=a[j]*b[j]
    if calc>0:
        ans+=1
print(ans)


Measured memory_bytes: 9084
#include<stdio.h>
int main()
{
    int a,b,x,y,i,j;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    if(a<x&&b<y)
    {
        for(i=0;i<y-b;i++)
            printf("U");
        for(i=0;i<x-a;i++)
          printf("R");
          for(i=0;i<y-b;i++)
            printf("D");
        for(i=0;i<x-a;i++)
          printf("L");
          printf("L");
          for(i=0;i<=y-b;i++)
            printf("U");
        for(i=0;i<=x-a;i++)
          printf("R");
        printf("D");
        printf("R");
        for(i=0;i<=y-b;i++)
            printf("D");
            for(i=0;i<=x-a;i++)
          printf("L");
          printf("U");

    }
    else if(a<x&&b>y)
    {
        for(i=0;i<b-y;i++)
            printf("D");
        for(i=0;i<x-a;i++)
          printf("R");
          for(i=0;i<b-y;i++)
            printf("U");
        for(i=0;i<x-a;i++)
          printf("L");
          printf("L");
          for(i=0;i<=b-y;i++)
            printf("D");
        for(i=0;i<=x-a;i++)
          printf("R");
        printf("U");
        printf("R");
        for(i=0;i<=b-y;i++)
            printf("U");
            for(i=0;i<=x-a;i++)
          printf("L");
          printf("D");

    }
    else if(a>x&&b<y)
    {
        for(i=0;i<y-b;i++)
            printf("U");
        for(i=0;i<a-x;i++)
          printf("L");
          for(i=0;i<y-b;i++)
            printf("D");
        for(i=0;i<a-x;i++)
          printf("R");
          printf("R");
          for(i=0;i<=y-b;i++)
            printf("U");
        for(i=0;i<=a-x;i++)
          printf("L");
        printf("D");
        printf("L");
        for(i=0;i<=y-b;i++)
            printf("D");
            for(i=0;i<=a-x;i++)
          printf("R");
          printf("U");

    }
    else if(a<x&&b<y)
    {
        for(i=0;i<y-b;i++)
            printf("U");
        for(i=0;i<x-a;i++)
          printf("R");
          for(i=0;i<y-b;i++)
            printf("D");
        for(i=0;i<x-a;i++)
          printf("L");
          printf("L");
          for(i=0;i<=y-b;i++)
            printf("U");
        for(i=0;i<=x-a;i++)
          printf("R");
        printf("D");
        printf("R");
        for(i=0;i<=y-b;i++)
            printf("D");
            for(i=0;i<=x-a;i++)
          printf("L");
          printf("U");

    }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ff first
#define ss second
#define ii pair<int,int>
#define lp(x,y) for(ll i=x;i<y;i++)
#define pb push_back
const int N = 200 * 1000 + 11;
 
 
int main() 
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x,d,count=0;
    cin>>x>>d;
    ll l=d*d;
  
    lp(0,x)
    {
        ll a,b;
        cin>>a>>b;
        ll y = abs(a*a) + abs(b*b) ;
        if(l>=y)count++; 
        
    }
    cout<<count;
}

Measured memory_bytes: 3644
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1200031;

int d,n;

int f(int x){
	if (x%100)
		return 0;
	return f(x/100)+1;
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>d>>n;
	for (int i=1;;i++){
		if (f(i)==d)
		{
			--n;
			if (n==0){
				cout<<i<<endl;
				return 0;
			}
		}
	}

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

unordered_map <string, int> Hash;

int coins;

main()
{
	IOS
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		
		Hash[s]++;
	}
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		
		Hash[s]--;
	}
	
	for(auto i : Hash)
		amax(coins, i.S);
	
	cout << coins;
}

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

int main() {
	int k;
	char str[101];
	scanf("%d %s", &k, str);
	int len = strlen(str);
	if (len <= k) {
		printf("%s\n", str);
	}
	else {
		for (int i = 0; i < k; i++) {
			printf("%c", str[i]);
		}
		puts("...");
	}
	return 0;
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power,long long mod)
{
    LL ret=0;

    if(power==0) return 1LL%mod;
    if(power==1) return number%mod;
    if(power%2==0)
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod)%mod;
        return ret%mod;
    }
    else
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod*number%mod)%mod;
        return ret%mod;
    }
}

int main()
{

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

    map<int,int> mp;

    mp[a]++;
    mp[b]++;
    mp[c]++;

    if(mp.size()==2)
        cout<<"Yes";
    else
        cout<<"No";


    return 0;
}

/*

*/


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  int n = in();

  rep(i, n){
    int m = in();
    int a[m];
    rep(j, m) a[j] = in();
    int up = 0, down = 0;
    reps(j, 1, m){
      if (a[j - 1] < a[j]) up = max(a[j] - a[j - 1], up);
      else down = max(a[j - 1] - a[j], down);
    }
    cout << up << " " << down << "\n";
  }

  return (0);
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, x;
  cin >> N >> x;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i < N - 1; ++i) {
    if (A.at(i) + A.at(i + 1) > x) {
      ll temp = A.at(i) + A.at(i + 1) - x;
      if (temp > A.at(i + 1)) {
        A.at(i) -= temp - A.at(i + 1);
        A.at(i + 1) = 0;
      }
      else {
        A.at(i + 1) -= temp;
      }
      ans += temp;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		char[] t = sc.nextLine().toCharArray();
		int   sl = s.length;
		int   tl = t.length;

		int max  = 0;

		for(int i = 0; i < sl - tl + 1; i ++) {

			int cnt = 0;

			for(int j = 0; j < tl; j++) {

				if(s[i + j] == t[j])cnt++;
			}

			max = Math.max(max, cnt);
		}


		System.out.println(tl - max);
	}
}


Measured memory_bytes: 35704
#include <stdio.h>

int main(void) {
  int a, b, flag = 0;
  char s[11];
  scanf("%d %d %s", &a, &b, s);

  for (int i = 0; i < a; i++) {
    if (s[i] < '0' || '9' < s[i]) flag = 1;
  }
  if (s[a] != '-') flag = 1;
  for (int i = a+1; i < a+1+b; i++) {
    if (s[i] < '0' || '9' < s[i]) flag = 1;
  }

  if (flag) puts("No");
  else puts("Yes");

  return 0;
}


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

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;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

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


    ll ans = -1001001001;

    if(a < 0 && b < 0) {
        if(c < 0 && d < 0) {
            ans = ll(a) * c;
        }
        else if(c < 0 && d >= 0) {
            ans = ll(a) * c;
        }
        else if(c >= 0 && d >= 0) {
            ans = ll(c) * b;
        }
    }

    else if(a < 0 && b >= 0) {
        if(c < 0 && d < 0) {
            ans = ll(a) * c;
        }
        else if(c < 0 && d >= 0) {
            ll ans1 = ll(a)*c;
            ll ans2 = ll(b)*d;
            ans = max(ans1, ans2); 
        }
        else if(c >= 0 && d >= 0) {
            ans = ll(b)*d;
        }
    }
    else if(a >= 0 && b >= 0) {
        if(c < 0 && d < 0) {
            ans = ll(a) * d;
        }
        else if(c < 0 && d >= 0) {
            ans = ll(b) * d;
        }
        else if(c >= 0 && d >= 0) {
            ans = ll(b) * d;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
n, k = list(map(int, input().split()))
ls = [list(map(int, input().split())) for _ in range(n - 1)]
qs = [list(map(int, input().split())) for _ in range(k)]

ws = [0 for _ in range(n)]
for q in qs:
	ws[q[0] - 1] += q[1]

ds = [[] for _ in range(n)]
for l in ls:
	ds[l[0] - 1].append(l[1] - 1)

for i in range(0, n):
	for x in ds[i]:
		ws[x] += ws[i]

for i in range(n):
	print(ws[i])


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

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

    static class ADoubleHelix {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            String answer = null;
            if (s.equals("A")) {
                answer = "T";
            } else if (s.equals("T")) {
                answer = "A";
            } else if (s.equals("C")) {
                answer = "G";
            } else if (s.equals("G")) {
                answer = "C";
            }

            out.println(answer);
        }

    }

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

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

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

    }
}



Measured memory_bytes: 20820
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int n;
ll ans = 0;

void dfs(ll cur, int mask){
	if(cur > n) return;
	if(mask == 7) ans++;
	dfs(cur * 10 + 5, mask | 1);
	dfs(cur * 10 + 3, mask | 2);
	dfs(cur * 10 + 7, mask | 4);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n;
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main() {
	int a,b;
	cin>>a>>b;
	if(a==b) cout<<"Draw"<<endl;
	else if(a>b){
		if(b==1)cout<<"Bob"<<endl;
		else cout<<"Alice"<<endl;
	}
	else if(a<b){
			if(a==1)cout<<"Alice"<<endl;
		else cout<<"Bob"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	//入力する文字列
	string input_s;
	//出力する文字列
	string output_s;

	//入力
	cin >> input_s;

	for (int i = 0; i < input_s.length(); i++) {
		//cout << input_s[i] << endl;
		if (input_s[i]=='0') {
			//入力が0の時
			output_s += "0";
		}
		else if (input_s[i] == '1') {
			//入力が1の時
			output_s += "1";
		}
		else if (input_s[i] == 'B') {
			//入力がBの時
			if (output_s.empty() != 1) {
				//出力文字列が空でない
				output_s = output_s.erase(output_s.length()-1);
			}
		}
	}

	//出力
	cout << output_s << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A_dict = {}
for i in range(N):
    A_dict[i+1] = A[i]

sorted_dict = sorted(A_dict.items(), key=lambda x: x[1])

ans = []
for t in sorted_dict:
    ans.append(t[0])
print(' '.join(map(str, ans)))

Measured memory_bytes: 31088
N=int(input())
A=list(map(int,input().split()))#食べた順番
B=list(map(int,input().split()))#得点
C=list(map(int,input().split()))#ボーナスポイント
P=0
k=0
for i in range(0,N):
    P=P+B[i]
for j in range(0,N-1):    
    if A[j]+1==A[j+1]:
        k=A[j]-1
        P=P+C[k]
print(P)

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

#define N 200009

using namespace std;

map<int,int> m1[N];

int main(){
	int i,j,t1,t2,t3,t4,n,m;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&t1,&t2);
		m1[t1][t2]++;
		m1[t2][t1]++;
	}
	for(i=2;i<=n-1;i++){
		if(m1[i].find(1)!=m1[i].end() && m1[i].find(n)!=m1[i].end()){
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 28416
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int dataset = scanner.nextInt();
			if(dataset == 0){
				break;
			}
			int[] input = new int[dataset];
			for(int i=0; i<dataset; i++){
				input[i] = scanner.nextInt();
			}
			int[] ans = new int[dataset];
			for(int i=0; i<dataset; i++){
				int[] tmpi = new int[dataset-i];
				for(int j=0; j<dataset-i; j++){
					int tmp_sum = 0;
					for(int k=0; k<=j; k++){
						tmp_sum += input[i+k];
					}
					tmpi[j] = tmp_sum;
//					System.out.println("tmpi[" + j + "]" + tmpi[j]);
				}
				Arrays.sort(tmpi);
				ans[i] = tmpi[tmpi.length-1];
//				System.out.println(i + "の最大値" + tmpi[tmpi.length-1]);
			}
			Arrays.sort(ans);
			System.out.println(ans[ans.length-1]);
		}
	}
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; ++i)
#define IFOR(i,s,e) for (int i=s; i<e; --i)
#define ITER(v) v.begin(), v.end()

constexpr int MAX_N = 200'000;
constexpr int64_t MAX_VAL = 1e9+1;

int64_t merge(int64_t* A, const int& left, const int& mid, const int& right) {
    const int n1 = mid - left;
    const int n2 = right - mid;

    auto L = new int64_t[n1+1];
    auto R = new int64_t[n2+1];
    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }

    L[n1] = MAX_VAL;
    R[n2] = MAX_VAL;

    int64_t count = 0;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            count += n1 - i;
        }
    }
    delete[] L;
    delete[] R;
    return count;
}

int64_t mergeSort(int64_t* A, const int& left, const int& right) {
    int64_t count = 0;
    if (left + 1 < right) {
        const int mid = (left + right) / 2;
        count += mergeSort(A, left, mid);
        count += mergeSort(A, mid, right);
        count += merge(A, left, mid, right);
        return count;
    }
    return 0;
}


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

    int n;
    cin >> n;

    int64_t* A = new int64_t[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int64_t count = mergeSort(A, 0, n);
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 5992
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

bool isRepdigit(int num) {
	int a = num / 100;
	int b = (num - 100 * a) / 10;
	int c = num - 100 * a - 10 * b;
	if (a == b && b == c) return true;
	else return false;
}

int main()
{
	int n;
	cin >> n;
	while (n <= 999) {
		if (isRepdigit(n)) {
			cout << n << endl;
			return 0;
		}
		n++;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
#define RANGE(c) c.begin(), c.end()
using namespace std;

int k, a, b;

int main(void){
    cin >> k >> a >> b;
    
    int kleft = k;
    long long mmax = 1;
    // はじめは 1. を a-1 回行って a 枚にすることしかできない
    if(kleft < a-1){
        mmax += kleft;
        kleft = 0;
    }
    else{
        mmax += a-1;
        kleft -= a-1;
    
        // b-a <= 2 なら kleft 回 1. で増やすのが得
        if(b-a <= 2){
            mmax += kleft;
            kleft = 0;
        }
        else{
            // 2.3. を繰り返し、1回余ったら 1. するのが最適
            if(kleft % 2 == 1){
                mmax ++;
                kleft --;
            }
            mmax += (long long)(b-a)*(kleft/2);
            kleft = 0;
        }
    }
    cout << mmax << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define mrep(p,mp) for(auto p : mp)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
int n,l;
cin >> n >> l;
vector<string> s(n);
rep(i,n) cin >> s[i];
string sum;
sort(s.begin(),s.end());
rep(i,n)
    sum += s[i];
cout << sum << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,l,s;
    char str[100000];
    scanf("%s",str);
    l = strlen(str);
    if(str[l-1] == 's'){
        str[l] = 'e';
        str[l + 1] = 's';
    }
    else{
        str[l] = 's';
    }
    printf("%s\n",str);
    return 0;
}


Measured memory_bytes: 3768
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  ll N, K, Q;
  
  cin >> N >> K >> Q;
  
  vector<ll> P(N,0);
  vector<int> A(Q);
  
  REP(i,Q){
    cin >> A[i];
    P[A[i]-1]++;
  }
  
  REP(i,N){
    if(P[i]>Q-K){
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
    
  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}




Measured memory_bytes: 1792
import Data.List
k i=(drop(i-1)).(take(i+2))
t s i j h=(if j<1 then [] else[k i (s!!(j-1))])++[k i(s!!j)]++(if (j+1)>=h then [] else [k i(s!!(j+1))])
u s =(sum.map (length.elemIndices '#'))s
f s j h w= if j>=h then[]else[g s 0 j h w]++f s (j+1) h w
g s i j h w=if i>=w then[]else (if (s!!j)!!i =='#'then"#"else(show(u(t s i j h))))++g s (i+1) j h w
main=do
 [h,w]<-map read.words<$>getLine
 s<-lines<$>getContents
 putStr$unlines$f s 0 h w

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];

int main() {
    int n,sum = 0,ans = 1<<30;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    for (int i= 1; i <= 100; ++i) {
        sum = 0;
        for (int j = 0; j < n; ++j) {
            sum += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using llu = long long unsigned;
using ld = long double;

const int inf = 0x3c3c3c3c;
const ll infl = 0x3c3c3c3c3c3c3c3c;

int main(){
	cin.tie(NULL);
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if(N == 1 && M == 1) return !printf("1");
    if(N == 1) return !printf("%lld", M - 2);
    if(M == 1) return !printf("%lld", N - 2);
    printf("%lld", (N - 2) * (M - 2));
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

int toMinute(int h, int m){
	return h * 60 + m;
}

int roundUp(int i){
	if(i % 50){
		return i - (i % 50) + 50;
	}
	return i;
}

//17*60+30 = 1050
//19*60+30 = 1170

int main(){
	int MAX_N = 7;
	int d[MAX_N+1][MAX_N+1], p[MAX_N+1][MAX_N+1];
	d[1][2] = 6;
	d[1][3] = 13;
	d[1][4] = 18;
	d[1][5] = 23;
	d[1][6] = 43;
	d[1][7] = 58;
	d[2][3] = 7;
	d[2][4] = 12;
	d[2][5] = 17;
	d[2][6] = 37;
	d[2][7] = 52;
	d[3][4] = 5;
	d[3][5] = 10;
	d[3][6] = 30;
	d[3][7] = 45;
	d[4][5] = 5;
	d[4][6] = 25;
	d[4][7] = 40;
	d[5][6] = 20;
	d[5][7] = 35;
	d[6][7] = 15;

	p[1][2] = 300;
	p[1][3] = 500;
	p[1][4] = 600;
	p[1][5] = 700;
	p[1][6] = 1350;
	p[1][7] = 1650;
	p[2][3] = 350;
	p[2][4] = 450;
	p[2][5] = 600;
	p[2][6] = 1150;
	p[2][7] = 1500;
	p[3][4] = 250;
	p[3][5] = 400;
	p[3][6] = 1000;
	p[3][7] = 1350;
	p[4][5] = 250;
	p[4][6] = 850;
	p[4][7] = 1300;
	p[5][6] = 600;
	p[5][7] = 1150;
	p[6][7] = 500;

	int a, na, ma;
	while(std::cin >> a >> na >> ma, !std::cin.eof()){
		int b, nb, mb;
		std::cin >> b >> nb >> mb;

		int min_a = toMinute(na, ma),
			min_b = toMinute(nb, mb);

		int big = (a>b)?a:b,
			small = (a<b)?a:b;

		if((1050 <= min_a && min_a <= 1170 ||
				1050 <= min_b && min_b <= 1170) &&
			 d[small][big] <= 40){
			std::cout << roundUp(p[small][big] / 2) << std::endl;
		}else{
			std::cout << p[small][big] << std::endl;
		}
	}
}

Measured memory_bytes: 1160
import re
def main():
    X=int(input()) 
    while True:
        if is_prime(X):
            print(X)
            return
        X += 1


def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;cin>>n;
    vector<ll> a(3*n);
    rep(i,3*n){
        cin>>a[i];
    }
    sort(ALL(a));
    ll ans=0;
    deque<ll> dq;
    rep(i,3*n){
        dq.push_back(a[i]);
    }
    while(!dq.empty()){
        ll a,b,c;
        a=dq.back();
        dq.pop_back();
        b=dq.back();
        dq.pop_back();
        c=dq.front();
        dq.pop_front();
        ans+=b;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
n, m = map(int, input().split())
a = [True] * (n + 1)
for _ in range(m):
    a[int(input())] = False
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    if a[i + 1]:
        dp[i + 1] += dp[i]
    if i + 2 < n + 1:
        if a[i + 2]:
            dp[i + 2] += dp[i]
print(dp[n] % 1000000007)

Measured memory_bytes: 503280