akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n,a, b;
	cin >>n>> a >> b;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x >= a&&x < b)continue;
		else ans++;
	}
	cout << ans<<endl;
	return 0;

}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while (b <= a && k > 0)
    {
        b *= 2;
        --k;
    }
    c <<= k;
    if (a < b && b < c)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<numeric>
#include<map>
#include<limits>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int mod = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> sum(s.size()+1, 0);
    for (int i = 1; i <= s.size(); i++)
    {
        if(s[i]=='C' && s[i-1]=='A'){
            sum[i+1] = sum[i] + 1;
        }else{
            sum[i+1] = sum[i];
        }
    }
    for (int i = 0; i < q; i++)
    {
        int l, r; cin >> l >> r;
        int ans = sum[r]-sum[l];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
# D - RGB Triplets
from collections import defaultdict


def main():
    _ = int(input())
    S = input().rstrip()
    indices, doubled_indices = defaultdict(list), defaultdict(set)
    for i, c in enumerate(S):
        indices[c].append(i)
        doubled_indices[c].add(2 * i)
    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for c1, c2, c3 in ["RGB", "GBR", "BRG"]:
        cnt -= sum(
            i + j in doubled_indices[c3] for i in indices[c1] for j in indices[c2]
        )
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10004
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    ll N;
    cin >> N;
    cout << 800*N-200*(N/15)<<endl;
    return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;

  if (a.size()>b.size()){
    cout << "GREATER" << endl;
  }
  else if (a.size()<b.size()){
    cout << "LESS" << endl;
  }
  else if (a>b){
    cout << "GREATER" << endl;
  }
  else if (b>a){
    cout << "LESS" << endl;
  }
  else {
    cout << "EQUAL" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

long long i,j,k,N,M,ans,K,Y;

vector<long long> A;

void dfs(long long X)
{
  long long x,s,t;
  
  if(X<=3234566667)
  {
  for(s=-1;s<=1;s++)
  {
    x=X%10;
    if(x+s==10) continue;
    else if(x+s==-1) continue;
    
    A.push_back(10*X+x+s);
    
    dfs(10*X+x+s);
  }
  }
  
}


int main()
{
  cin>>K;

  if(K<=9)
  {
    cout<<K;
    return 0;
  }
  
  for(i=1;i<=9;i++)
  {
    A.push_back(i);
    dfs(i);
  }
  
  sort(A.begin(),A.end());
  
  cout <<A[K-1];
  
  
  
  
  
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n; cin >> n;
    ll a = 0;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = i; j <= n; j += i)
        {
            a += j;
        }
    }
    cout << a;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
int p;
int power(int base, int e) {
    int res = 1;
    while (e > 0) {
        if (e % 2 == 1)
            res = 1LL * res * base % p;
        base = 1LL * base * base % p;
        e /= 2;
    }
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n >> p;
    std::vector<int> fac(3 * n + 1), invFac(3 * n + 1), p2(n + 1), p3(n + 1);
    fac[0] = 1;
    for (int i = 1; i <= 3 * n; ++i)
        fac[i] = 1ll * fac[i - 1] * i % p;
    for (int i = 0; i <= 3 * n; ++i)
        invFac[i] = power(fac[i], p - 2);
    p2[0] = 1;
    p2[1] = power(2, p - 2);
    for (int i = 2; i <= n; ++i)
        p2[i] = 1ll * p2[i - 1] * p2[1] % p;
    p3[0] = 1;
    p3[1] = power(3, p - 2);
    for (int i = 2; i <= n; ++i)
        p3[i] = 1ll * p3[i - 1] * p3[1] % p;
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; i + j <= n; ++j) {
            int k = 3 * n - 3 * i - 2 * j;
            ans = (ans + 1ll * p3[i] * invFac[i] % p * p2[j] % p * invFac[j] % p * invFac[k]) % p;
        }
    }
    ans = 1ll * fac[3 * n] * ans % p;
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	string S;	cin >> S;
	string a = "Good";
	for (int i = 0; i < 3; i++)
	{
		if(S.at(i) == S.at(i+1))
		{
			a = "Bad";
		}
	}
	cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		int t = 0;
		int d = i;
		while (d)
		{
			d /= 10;
			t++;
		}
		if (t%2 == 1)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from decimal import Decimal

n,k=map(int,input().split())

sum=0

for i in range(1,n+1):
    if i<k:
        cnt=0
        tempi=i
        while tempi<k:
            tempi*=2
            cnt+=1
        sum+=1/(n*(2**cnt))
    else:
        sum+=1/n

print(sum)

Measured memory_bytes: 22160
o=input()
e=input()
O=len(o)
E=len(e)
ans=''
if O==E:
  for i in range(O):
    ans+=o[i]+e[i]
if O+1==E:
  for i in range(O):
    ans+=o[i]+e[i]
  ans+=e[-1]
if O-1==E:
  for i in range(E):
    ans+=o[i]+e[i]
  ans+=o[-1]
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
const ll MOD = 1e9 + 7;

string S;
ll dp[100001][13];

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

  dp[0][0] = 1;
  for (int i = 0; i < S.size(); i++) {
    int c = 0;
    if (S[i] == '?') {
      c = -1;
    } else {
      c = S[i] - '0';
    }

    for (int j = 0; j < 10; j++) {
      if (c == -1 || c == j) {
        for (int k = 0; k < 13; k++) {
          dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
          dp[i + 1][(k * 10 + j) % 13] %= MOD;
        }
      }
    }
  }

  cout << dp[S.size()][5] << endl;
  return 0;
}

Measured memory_bytes: 10704
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)


//pairの例
int main(){
    int N;
    cin >> N;
    pair<pair<string,int>,int> s[110];

    //　点数を高い順でソートしたいのでに-1倍
    for(int i = 0;i < N;i++){
        string t;
        int j;
        cin >> t >> j;
        s[i] = make_pair(make_pair(t,-j),i+1);
    }

    sort(s,s+N);
    for(int i = 0;i < N;i++){
        printf("%d",s[i].second);
        cout << endl; 
    }

   

}

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

int f(int n) {
  int i = 0;
  while (n % 2 == 0) n /= 2, i++;
  return i;
}

int main() {
  ios::sync_with_stdio(false);
  long long N, M, L, A;
  cin >> N >> M >> L;

  int l = f(L);
  while (cin >> A) {
    if (f(A) != l) goto NG;
    L = L * A / __gcd(L, A);
    if (L / 2 > M) goto NG;
  }

  cout << (M - L / 2) / L + 1 << "\n";
  return 0;
  NG:
  cout << 0 << "\n";
}

Measured memory_bytes: 256
n = int(input())
li = []

for i in range(1,n+1):
    if (i%3 == 0) or (i%10 ==3) or(int(i/10)%10 ==3) or(int(i/100)%10 ==3)or(int(i/1000)%10 ==3):
        print(" "+str(i),end="")

print("")



Measured memory_bytes: 5872
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var minval = int.MaxValue;
        var count = 0;

        foreach(var x in ary) {
            if (x <= minval) count++;
            minval = Math.Min(x,minval);
        }

        return count;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 29404
n,x = map(int,input().split())
lm = list(map(int,input().split()))
ln = [0]
for a in range(len(lm)):
  ln.append(ln[a]+lm[a])
s = 0
for b in range(len(ln)):
  if ln[b] <= x:
    s += 1
print('{}'.format(s))


Measured memory_bytes: 3060
#include<stdio.h>


int main()
{
	long long int  a,c;
	char b;
	while(scanf("%lld %c %lld",&a,&b,&c) != EOF)
	{
		if(b == '+')
		{
			printf("%lld\n",a+c);
		}
		else if(b == '-')
		{
			printf("%lld\n",a-c);
		}
	}
	return 0;
} 

Measured memory_bytes: 128
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = [2, 4, 5, 7, 9]
    B = [0, 1, 6, 8]
    C = 3

    a = N % 10
    if a in A:
        print("hon")
    elif a in B:
        print("pon")
    else:
        print("bon")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
# coding: utf-8
# Your code here!
import math

while True:
    n,x = list(map(int,input().split()))
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    c += 1
    print(c)


Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string n;
    cin>>n;
    
    int s=0;
    for(int i=0;i<n.size();i++){
      if(n[i]=='7') s++;
    }
    
    if(s>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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() {
	string s,t;
	cin >> s >> t;
	rep(i, s.length()) {
		if(s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> A(n);
    vector<ll> B(n);

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

    sort(A.begin(), A.end());
    sort(B.rbegin(), B.rend());

    if(n % 2 == 0){
        ll a1 = A[n/2-1];
        ll a2 = A[n/2];
        ll b1 = B[n/2];
        ll b2 = B[n/2-1];
        cout << (-a2+b2-a1+b1+1) << endl;
    }
    else{
        ll a1 = A[(n+1)/2-1];
        ll b1 = B[(n+1)/2-1];
        cout << b1-a1+1 << endl;
    }
}

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

using namespace std;

typedef long long ll;

const int N=200010,Q=200010;
const long long inf=1ll<<61; 
int n,q,A,B,x[Q];
long long f[Q],T[2][N];
void ins(int t,int i,long long x){
    for(;i<=n;i+=i&-i)
        T[t][i]=min(T[t][i],x);
}
long long qry(int t,int i){
    long long s=inf;
    for(;i;i-=i&-i)
        s=min(s,T[t][i]);
    return s;
}
int main(){
	scanf("%d%d%d%d",&n,&q,&A,&B);
	long long sum=0,ans;
	for(int i=0;i<q;i++){
        scanf("%d",x+i);
        if(i)
            sum+=abs(x[i]-x[i-1]);
    } 
	ans=sum+min(abs(x[0]-A),abs(x[0]-B));
	for(int i=1;i<=n;i++)
        T[0][i]=T[1][i]=inf;
	for(int i=q;--i;){
		f[i]=-abs(x[i]-x[i-1])+min(min(qry(0,x[i-1])+x[i-1],qry(1,n+1-x[i-1])-x[i-1]),0ll);
		ins(0,x[i],f[i]-x[i]);
		ins(1,n-x[i]+1,f[i]+x[i]); 
		ans=min(ans,sum+f[i]+min(abs(x[0]-A)+abs(x[i]-B),abs(x[0]-B)+abs(x[i]-A)));
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return (2*i)+1; }

void maxHeapify(int i){
  int l, r, largest, tmp;
  l = left(i);
  r = right(i);
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  
  if( r <= H && A[r] > A[largest] ) largest = r;

  if( largest != i ){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int tmp;
  if( key < A[i] ) return;
  A[i] = key;
  while( i > 1 && A[i/2] < A[i] ){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i / 2;
  }
}

void insert(int key){
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char c[10];

  while( 1 ){
    scanf("%s",c);
    if( c[0] == 'e' && c[1] == 'n' ) break;
    if( c[0] == 'i' ){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }
  return 0;
}



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

long long n;
map<char, set<int>> mp;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    char x;
    int p;
    cin >> x >> p;
    mp[x].insert(p);
  }
  for(int i = 1; i <= 13; ++i)
    if(mp['S'].find(i) == mp['S'].end())
      cout << "S " << i << endl;
  for(int i = 1; i <= 13; ++i)
    if(mp['H'].find(i) == mp['H'].end())
      cout << "H " << i << endl;
  for(int i = 1; i <= 13; ++i)
    if(mp['C'].find(i) == mp['C'].end())
      cout << "C " << i << endl;
  for(int i = 1; i <= 13; ++i)
    if(mp['D'].find(i) == mp['D'].end())
      cout << "D " << i << endl;

  return 0;
}


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

int main()
{
	int n,a,b,cnt;
	while(~scanf("%d",&n)){
		cnt=0;
		for(a=0;a<=18;a++){
			for(b=0;b<=18;b++){
				if(a+b==n) cnt+= (10-(int)abs(a-9)) * (10-(int)abs(b-9));
			}
		}
		cout << cnt << endl;
	}
	return 0;	
}

Measured memory_bytes: 0
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]



N, x = map(int, input().split())
a = list(map(int, input().split()))


a.sort()

ans = 0
for i in range(N-1):
    e = a[i]
    if x >= e:
        ans += 1
        x -= e
if a[-1] == x:
    ans += 1

print(ans)


Measured memory_bytes: 3060
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
import std.container;
class t
{
    int parent, left, right;
    this()
    {
        parent = left = right = -1;
    }

    int depth;
    int height;
}
void dep(t[] tt, int i, int d = 0)
{
    if (i == -1)
    {
        return;
    }
    tt[i].depth = d;
    dep(tt, tt[i].left, d + 1);
    dep(tt, tt[i].right, d + 1);
}
int hei(t[] tt, int i)
{
    auto a1 = 0, a2 = 0;
    if (tt[i].left != -1)
        a1 = hei(tt, tt[i].left) + 1;
    if (tt[i].right != -1)
        a2 = hei(tt, tt[i].right) + 1;
    tt[i].height = max(a1, a2);
    return tt[i].height;
}
void pre(t[] tt, int i)
{
    if (i == -1)
    {
        return;
    }
    write(" ", i);
    pre(tt, tt[i].left);
    pre(tt, tt[i].right);
}
void in_(t[] tt, int i)
{
    if (i == -1)
    {
        return;
    }
    in_(tt, tt[i].left);
    write(" ", i);
    in_(tt, tt[i].right);
}
void post(t[] tt, int i)
{
    if (i == -1)
    {
        return;
    }
    post(tt, tt[i].left);
    post(tt, tt[i].right);
    write(" ", i);
}
void main()
{
    auto c = readln.strip.to!int;
    auto tt = new t[c];
    foreach (i; 0..c)
        tt[i] = new t();
    foreach (i; 0..c)
    {
        auto a = readln().strip.split(" ").map!(to!int).array;
        if (a[1] != -1)
        {
            tt[a[0]].left = a[1];
            tt[a[1]].parent = a[0];
        }
        if (a[2] != -1)
        {
            tt[a[0]].right = a[2];
            tt[a[2]].parent = a[0];
        }
    }
    foreach (i; 0..c)
    {
        if (tt[i].parent == -1)
        {
            writeln("Preorder");
            pre(tt, i);
            writeln();
            writeln("Inorder");
            in_(tt, i);
            writeln();
            writeln("Postorder");
            post(tt, i);
            writeln();
        }
    }
}



Measured memory_bytes: 2496
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int d,g;
    cin>>d>>g;
    g=g/100;
    int p[d+2],c[d+2];
    int id[d+2];
    ll ses=inf;
    f(i,1,d)
    {
        cin>>p[i]>>c[i];
        c[i]=c[i]/100;
        id[i]=i;
    }
    do
    {
        ll sum=g,cnt=0;
        for(int i=1;i<=d;i++)
        {
            int idx=id[i];
            int nd=sum/idx;
            if(sum%idx!=0)nd++;
            if(nd<=p[idx])
            {
                cnt+=nd;
                break;
            }
            else
            {
                cnt+=p[idx];
                sum-=(idx*p[idx]);
                sum-=c[idx];
                if(sum<=0)break;

            }

        }

        ses=min(ses,cnt);

    }while(next_permutation(id+1,id+d+1));
    cout<<ses<<endl;
    return 0;

}





































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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set Counter
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<int> v;
    ::std::unordered_map<T, int> Map;
    ::std::vector<::std::vector<int> > data;
    int kind;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_.size()){
        int sz = v_.size(); kind = 0;
        for(int i=0;i<sz;i++){
            T t = v_[i];
            if (Map.count(t)){
                data[Map[t]].push_back(i);
            }else{
                Map[t] = kind++;
                data.push_back(::std::vector<int>());
                data.back().push_back(i);
            }
            v[i] = Map[t];
        }
    }
    //query for all elements
    int query(T x){
        if (!Map.count(x)) return 0;
        return data[Map[x]].size();
    }
    //query for [a, b]
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!Map.count(x)) return 0;
        int xi = Map[x];
        auto right = ::std::upper_bound(data[xi].begin(),data[xi].end(),b);
        auto left  = ::std::lower_bound(data[xi].begin(),data[xi].end(),a);
        return right-left;
    }
    //search x for [k, tail]
    int find(int k, T x){
        if (!Map.count(x)) return -1;
        int xi = Map[x];
        auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
        if (itr!=data[xi].end()){
            return *itr;
        }else{
            return -1;
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    vector<char> v(n);
    rep(i,n) v[i]=s[i];
    RangeSet<char> rs(v);
    int ans=1e7;
    rep(i,n){
        int A = rs.query(0,i-1,'W');
        int B = rs.query(i+1,n-1,'E');
        chmin(ans,A+B);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4364
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in()-2*t.in();e<0&&(e=0),console.log(e)}}]);

Measured memory_bytes: 21192
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s;
  cin >> s;

  REP(i, s.size()-1){
    if(i+2 < s.size()) if(s[i] == s[i+1] || s[i+1] == s[i+2] || s[i+2] == s[i]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
    if(s[i] == s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }

  cout << "-1 -1" << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int a, b;
  cin >> a >> b;
  int k;
  cin >> k;
  if(abs(a-b) < k*2){
    REP2(i,a,b+1) cout << i << endl;
  }
  else{
    REP2(i,a, a+k) cout << i << endl;
    REP2(i,b-k+1, b+1) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    
    rep(i,n)  {
        cin >> vec[i];
    }
 vector<int> vec_sorted = vec;
    sort(vec_sorted.rbegin(), vec_sorted.rend());
  
    rep(i,n)  {
    int ans = vec_sorted[0];
    if (vec_sorted[0] == vec[i]) ans = vec_sorted[1];
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a.at(i));
	}

	int q;
	cin >> q;

	int cnt = 0;
	for (int i = 0; i < q; i++)
	{
		int x;
		scanf("%d", &x);
		if (*lower_bound(a.begin(), a.end(), x) == x)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3228
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

	u64 a;

public:
	constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
	constexpr u64 value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	modint &operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	modint &operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	modint &operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	modint &operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};

#include<algorithm>
#include<iostream>
#include<vector>

int main() {
	using mint = modint<1000000007>;

	int n, x;
	std::cin >> n >> x;
	std::vector<int> s(n);
	for (auto &e : s) {
		std::cin >> e;
	}
	std::sort(s.begin(), s.end());

	std::vector<std::vector<mint>> dp(n + 1, std::vector<mint>(x + 1));

	for (int i = 0;i <= x;++i) {
		dp[0][i] = i;
	}
	for (int i = 0;i < n;++i) {
		for (int j = 0;j <= x;++j) {
			dp[i + 1][j] = dp[i][j] * i + dp[i][j%s[i]];
		}
	}

	std::cout << dp[n][x].value() << std::endl;

	return 0;
}


Measured memory_bytes: 158592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll a[114514],b[114514],n,m;
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>a[i];
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  sort(a,a+m);
  for(int i=1;i<m;i++)b[i-1]=a[i]-a[i-1];
  sort(b,b+m-1);
  ll sum=0;
  for(int i=m-2;i>=m-n;i--)sum+=b[i];
  cout<<a[m-1]-a[0]-sum;
  return 0;
}

Measured memory_bytes: 1792
def gcd(x, y):
	m = x
	n = y
	while n != 0L:
		tmp = n
		n = m % n
		m = tmp
	return m

n = int(raw_input())
a = map(long, raw_input().split())
lcm = 1L
for i in range(0, n):
	lcm = lcm * a[i] / gcd(lcm, a[i])
sum = 0L
for i in range(0, n):
	sum = sum + (lcm-1L) % a[i]
print sum

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

namespace AOJ {
	class Program {
		static void Main(string[] args) {
			int N;
			do {
				N = Utils.GetInt();
				new Calc().Solve(N);
			} while (N!=0);

		}

		public class Calc {
			public struct team {
				public int I;
				public int A;
				public int P;
				public int U;
				public team(int i,int u,int a,int p) {
					I = i;A = a;P = p;U = u;
				}
			}
			public void Solve(int N) {
				var list = new List<team>();
				for (int i = 0; i < N; i++) {
					var line = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToList();
					list.Add(new team(line[0], line[1], line[2], line[3]));
				}
				list = list.OrderByDescending(_ => _.A).ThenBy(_ => _.P).ThenBy(_=>_.I).ToList();

				var already = new int[1001];

				int cnt = 0;
				var ans = new List<int>();
				foreach (var item in list) {
					if (cnt < 10) {
						if (already[item.U] < 3) {
							already[item.U]++;
							cnt++;
							ans.Add(item.I);
						}
					}else if (cnt < 20) {
						if (already[item.U] < 2) {
							already[item.U]++;
							cnt++;
							ans.Add(item.I);
						}
					}else if (cnt < 26) {
						if (already[item.U] == 0) {
							already[item.U]++;
							cnt++;
							ans.Add(item.I);
						}
					}
				}
				foreach (var item in ans) {
					Console.WriteLine(item);
				}
				return;
			}
		}
	}

	public static class Utils {
		public static int GetInt() {
			return int.Parse(Console.ReadLine());
		}
	}
}

Measured memory_bytes: 10152
#include<stdio.h>
 
int cal(int a);
 
int main(void)
{
  int a;
  int cal_out;
  scanf("%d",&a);
  cal_out = cal(a);
  printf("%d\n",cal_out);
  return 0;
}
 
int cal(int a)
{
  int res;
  res = a+a*a+a*a*a;
  return res;
}

Measured memory_bytes: 2096
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , k , a[ N ] , l[ N ] , r[ N ] , s[ N ];
void init(){
  n = getint();
  k = getint();
  for( int i = 1 ; i <= n ; i ++ ){
    a[ i ] = getint();
    s[ i ] = s[ i - 1 ] + a[ i ];
  }
  for( int i = 1 ; i <= n ; i ++ )
    l[ i ] = max( 0ll , a[ i ] ) + l[ i - 1 ];
  for( int i = n ; i >= 1 ; i -- )
    r[ i ] = max( 0ll , a[ i ] ) + r[ i + 1 ];
}
void solve(){
  LL ans = 0;
  for( int i = k ; i <= n ; i ++ ){
    LL tans = max( 0ll , s[ i ] - s[ i - k ] ) + l[ i - k ] + r[ i + 1 ];
    ans = max( ans , tans );
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	
	static Scanner scan;
	
	private static int[] array;
	private static int counter;
	
	private static void SelectionSort() {
		for(int i = 0; i < array.length - 1; i++) {
			int min = i;
			for(int j = i; j < array.length; j++) {
				if(array[j] < array[min]) min = j;
			}
			if(min != i) swap(i, min);
		}
	}
	
	private static void swap(int i, int j) {
		int tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;
		
		counter++;
	}
	
	public static void printArray() {
		for(int i = 0; i < array.length - 1; i++) {
			System.out.print(array[i] + " ");
		}
		System.out.println(array[array.length - 1]);
	}
	
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		
		// Get the value of input array's length
		final int length = scan.nextInt();
		
		// Get the input array
		array = new int[length];
		for(int i = 0; i < length; i++) {
			array[i] = scan.nextInt();
		}
		
		// Carry out the selection sort
		SelectionSort();
		printArray();
		System.out.println(counter);
	}

}



Measured memory_bytes: 26324
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ff first
#define ss second
 
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    setprecision(20);
    
    int n;
    cin>>n;
    
    int dig=0;
    int ans=1;
    int a[n];
    bool f=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            f=1;
        }
    }
    sort(a,a+n);
    int maxi=1e18;
    if(f)
    {
        cout<<0;
        return 0;
    }
    
    for(int i=0;i<n;i++)
    {
        if(ans>maxi/a[i])
        {
            cout<<-1;
            return 0;
        }
        ans=ans*a[i];
    }
    cout<<ans;
    
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>    //vectorを使う
#include <string>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) a.begin(),a.end()

int main(void){
    int n;
    vector<long int> v(n);
    vector<long int> c(n);

    cin >> n;
    FOR(i,0,n){
        cin >> v.at(i); 
    }
    FOR(i,0,n){
        cin >> c.at(i); 
    }

    vector<int> p(n);
    FOR(i,0,n){
        p.at(i)=v.at(i)-c.at(i); 
    }

    int mv=0;
    FOR(i,0,n){
        if(p.at(i)>0){
            mv=mv+p.at(i);
        }else{}
    }
    
    cout << mv << endl;
}

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

int main() {
  int D;
  cin >> D;
  switch (D){
  case 25:
    cout << "Christmas" << endl;
    break;
  case 24:
    cout << "Christmas Eve" << endl;
    break;
  case 23:
    cout << "Christmas Eve Eve" << endl;
    break;
  case 22:
    cout << "Christmas Eve Eve Eve" << endl;
    break;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
string S;
int main() {
	cin >> S;
	cout << S.substr(0, 5) << ' ' << S.substr(6, 7) << ' ' << S.substr(14, 5) << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;
int main(){
  int n;
  cin >> n;
  long long *r = (long long *)calloc(n, sizeof(long long));
  for(int i=0;i<n;i++){
    cin >> r[i];
  }

  long long dif = r[1] - r[0];
  long long dmin = r[0];
  for(int i=1;i<n;i++){
    dif = max(dif, r[i]-dmin);
    dmin = min(dmin, r[i]);
  }

  cout << dif << endl;

  return 0;
}



Measured memory_bytes: 4640
#include <iostream>
#include <vector>
#include <set>
using namespace std;

using int64 = long long;
using State = pair<int64, int>; // <cost, city>

void Dijkstra(int s, vector<int64>& to_city,
              const vector<vector<pair<int, int>>>& costs) {
  set<State> q;
  q.insert({0LL, s});
  to_city[s] = 0;
  while (!q.empty()) {
    auto front = q.begin();
    int64 cost = front->first;
    int city = front->second;
    q.erase(front);
    for (auto p : costs[city]) {
      int to = p.first;
      int64 sum = cost + p.second;
      if (to_city[to] >= 0 && to_city[to] < sum)
        continue;
      to_city[to] = sum;
      q.insert({sum, to});
    }
  }
}

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  --s;
  --t;
  // [JPY(0)/SNK(1)][from] = [(to,cost)]
  vector<vector<vector<pair<int, int>>>> costs(2, vector<vector<pair<int,int>>>(n));
  for (int i = 0; i < m; ++i) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    --u;
    --v;
    costs[0][u].push_back({v, a});
    costs[0][v].push_back({u, a});
    costs[1][u].push_back({v, b});
    costs[1][v].push_back({u, b});
  }

  vector<vector<int64>> to_city(2, vector<int64>(n, -1));
  Dijkstra(s, to_city[0], costs[0]);
  Dijkstra(t, to_city[1], costs[1]);

  // move to SNK
  vector<int64> ret(n);
  int64 c = 1e+15;
  for (int i = n - 1; i >= 0; --i) {
    c = min(c, to_city[0][i] + to_city[1][i]);
    ret[i] = static_cast<int64>(1e+15) - c;
  }
  for (int64 r : ret)
    cout << r << "\n";

  return 0;
}


Measured memory_bytes: 17536
sx, sy, tx, ty = map(int ,input().split())
rec = []
rec.append((tx - sx) * "R" + (ty - sy) * "U")
rec.append((tx - sx) * "L" + (ty - sy) * "D")
rec.append("D" + (tx - sx + 1) * "R" + (ty - sy + 1) * "U" + "L")
rec.append("U" + (tx - sx + 1) * "L" + (ty - sy + 1) * "D" + "R")

print("".join(map(str, rec)))


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] v=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(a[j-1]>a[j]){
					int box=v[j-1];
					v[j-1]=v[j];
					v[j]=box;
					box=a[j];
					a[j]=a[j-1];
					a[j-1]=box;
				}
			}
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(v[j-1]<v[j]){
					int box=v[j-1];
					v[j-1]=v[j];
					v[j]=box;
					box=a[j];
					a[j]=a[j-1];
					a[j-1]=box;
				}
			}
		}
		System.out.println(a[0]+" "+v[0]);
	}
}

Measured memory_bytes: 17336
p = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

a, b = map(map(str, p).index, raw_input().split())
if a > b:
    print "Alice"
elif a < b:
    print "Bob"
else:
    print "Draw"

Measured memory_bytes: 2568
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int count = 0;
    for (int i = (a > b ? b : a); i > 0; i--) {
        if (a % i == 0 && b % i == 0) count++;
        if (count == k) {
            printf("%d\n", i); break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
long int operation(int n,ll cnt,vector<ll>sum,vector<ll> a) {
	for (int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + a[i];
		if (sum[i - 1] > 0) {
			if (sum[i] >= 0) {
				cnt += sum[i] + 1;
				sum[i] = -1;
			}
		}
		else if (sum[i - 1] < 0) {
			if (sum[i] <= 0) {
				cnt += abs(sum[i]) + 1;
				sum[i] = 1;
			}
		}
	}
	return cnt;
}
int main() {
	int n;
	cin >> n;
	vector<ll>sum(n),a(n),sum2(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll count = 0;
	ll count2 = 0;
	sum[0] = a[0];
	if (sum[0]>0) {
		sum2[0] = -1;
		count2 += sum[0] + 1;
	}
	else if (sum[0] < 0) {
		sum2[0] = 1;
		count2 += abs(sum[0])+1;
	}
	else {
		sum[0] = 1;
		count++;
		sum2[0] = -1;
		count2++;
	}
	cout<<min(operation(n, count, sum, a) 
		,operation(n, count2, sum2, a))<< endl;
}

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

int main () {
  string S;
  cin >> S;
  int alphabet[26] = {0};

  for (int i=0;i<S.length();++i) {
    alphabet[S[i] - 'a'] = 1;
  }

  for (int i=0;i < 26;++i) {
    if (alphabet[i] == 0) {
      cout << (char)(i + 'a') << endl;;
      return 0;
    }
  }

  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1)
		cout << "No";
	else
	{
		bool ok = true;
		for (int i = 0; i < n / 2; i++)
			if (s[i] != s[i + n / 2])
				ok = false;
		if (ok)
			cout << "Yes";
		else
			cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
#include<map>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    while (cin >> n)
    {
        int* p = new int[n + 5];
        for (int i = 1; i <= n; i++)p[i] = 0;
        for (int i = 1; i < n; i++)
        {
            int x;
            cin >> x;
            p[x]++;
            //cout << x << " " << p[x] << '\n';
        }
        for (int i = 1; i <= n; i++)cout << p[i] << '\n';
    }
}



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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

int ceil_div(int a, int b) {
  return (a + b - 1) / b;
}

void MAIN() {
  int n, k;
  cin >> n >> k;
  int ans = ceil_div(n - 1, k - 1);
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  int L, R, d;
  cin >> L >> R >> d;

  int ans = 0;
  for (int x = L; x <= R; x++) {
    ans += (x % d ==0);
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3152