akhauriyash/Code-Regression huggingface dataset:
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
r=gi
puts Math::PI*2*r

Measured memory_bytes: 14300
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

#define D_N 0
#define D_E 1
#define D_S 2
#define D_W 3

using namespace std;

class Dice {
private:
  int side_values[6];

public:
  void set_values(vector<int> v) {
    for(int i=0; i<6; i++) {
      this->side_values[i] = v[i];
    }
  }

  void roll(int dir) {
    int side_temp[6];
    switch(dir) {
    case D_N:
      side_temp[0] = this->side_values[1];
      side_temp[1] = this->side_values[5];
      side_temp[2] = this->side_values[2];
      side_temp[3] = this->side_values[3];
      side_temp[4] = this->side_values[0];
      side_temp[5] = this->side_values[4];
      break;
    case D_E:
      side_temp[0] = this->side_values[3];
      side_temp[1] = this->side_values[1];
      side_temp[2] = this->side_values[0];
      side_temp[3] = this->side_values[5];
      side_temp[4] = this->side_values[4];
      side_temp[5] = this->side_values[2];
      break;
    case D_S:
      side_temp[0] = this->side_values[4];
      side_temp[1] = this->side_values[0];
      side_temp[2] = this->side_values[2];
      side_temp[3] = this->side_values[3];
      side_temp[4] = this->side_values[5];
      side_temp[5] = this->side_values[1];
      break;
    case D_W:
      side_temp[0] = this->side_values[2];
      side_temp[1] = this->side_values[1];
      side_temp[2] = this->side_values[5];
      side_temp[3] = this->side_values[0];
      side_temp[4] = this->side_values[4];
      side_temp[5] = this->side_values[3];
      break;
    default:
      break;
    }

    for(int i=0; i<6; i++) {
      this->side_values[i] = side_temp[i];
    }
  }

  int get_side_idx_of_value(int val) {
    for(int i=0; i<6; i++) {
      if(this->side_values[i] == val) {
        return i;
      }
    }

    return -1;
  }
  
  void roll_for_value(int val) {
    int side_idx = this->get_side_idx_of_value(val);
    switch(side_idx) {
    case 1:
      this->roll(D_N);
      break;
    case 2:
      this->roll(D_W);
      break;
    case 3:
      this->roll(D_E);
      break;
    case 4:
      this->roll(D_S);
      break;
    case 5:
      this->roll(D_N);
      this->roll(D_N);
      break;
    default:
      break;
    }
  }

  int get_value() {
    return this->side_values[0];
  }

  void get_standing_sides(int * sides) {
    sides[0] = this->side_values[1];
    sides[1] = this->side_values[2];
    sides[2] = this->side_values[4];
    sides[3] = this->side_values[3];
  }
};
      
int main() {
  // Put your favorite codes here
  vector<int> v;
  Dice d;
  int n;
  for(int i=0; i<6; i++) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  d.set_values(v);

  cin >> n;

  for(int i=0; i<n; i++) {
    int t, f;
    int sides[4];
    int res;
    cin >> t >> f;
    d.roll_for_value(t);
    d.get_standing_sides(sides);
    for(int j=0; j<4; j++) {
      if(sides[j] == f) {
        if(j == 3) {
          res = sides[0];
        } else {
          res = sides[j+1];
        }
        break;
      }
    }
    cout << res << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3144
import java.util.*;import java.io.*;import java.math.*;

public class Main
{
	static int first_dig(int n){
		while(n>9)
			n/=10;
		return n;
	}

    public static void process()throws IOException
    {
    	int n=ni(),mp[][]=new int[11][11];

    	long res=0l;

    	for(int i=1;i<=n;i++){
    		mp[first_dig(i)][i%10]++;
    	}

    	for(int i=1;i<=n;i++){
    		res+=mp[i%10][first_dig(i)];
    	}
    	pn(res);
    }


   	static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    	//oj = System.getProperty("ONLINE_JUDGE") != null;
    	if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
	
	
	

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={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; }

int main(){
    ll N,K,cnt=0;
    cin>>N>>K;
    for(ll i=K;i<=N+1;i++){
        cnt++;
        cnt+=(N-i+1)*i;
        cnt%=MOD;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
using vec_i=vector<int>;
const int INF = 1e9;
typedef tuple<int,string,int> t;

int main(){
  int N,b,c;cin>>N;
  string a;
  vector<t> p_l;
  REP(i,0,N){
    cin>>a>>b;
    p_l.emplace_back(i,a,b);

  }
  sort(p_l.begin(),p_l.end(),[](auto const& a,auto const& b){
    if(get<1>(a)!=get<1>(b)) return get<1>(a)<get<1>(b);
    else return get<2>(a)>=get<2>(b);
  });
  REP(i,0,N)print(get<0>(p_l[i])+1);
}


Measured memory_bytes: 256
N = int(input())
A = []
XY = [[] for _ in range(N)]
for i in range(N):
    A.append(int(input()))
    for j in range(A[i]):
        x, y = map(int, input().split())
        XY[i].append((x-1, y))

solution = 0
for i in range(1, 1<<N):
    honest = set()
    unhonest = set()
    ans = [0]*N
    cnt = 0
    while i > 0:
        if i % 2:
            honest.add(cnt)
            ans[cnt] = 1
        i //= 2
        cnt += 1

    unhonest = set(range(N)) - honest

    flag = False
    for p in range(N):
        if p in honest:
            for x, y in XY[p]:
                if y == 0:
                    if x in honest:
                        flag = True
                        break

                elif y == 1:
                    if x in unhonest:
                        flag = True
                        break
        if flag:
            break

    if flag:
        continue
    else:
        solution = max(solution, sum(ans))
    
print(solution)       

Measured memory_bytes: 48348
import java.util.*;
import java.io.*;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];

		int[] dp = new int[n];
		dp[0] = a[0] = Integer.parseInt(br.readLine());
		int length = 1;

		for (int i=1; i<n; i++) {
			a[i] = Integer.parseInt(br.readLine());
			if (dp[length-1] < a[i]) {
				dp[length++] = a[i];
			}else {
				int index = Arrays.binarySearch(dp,0,length,a[i]);
				if (index < 0)
					index = ~index;
				dp[index] = a[i];
			}
		}

		System.out.println(length);

		br.close();
	}
}

Measured memory_bytes: 31540
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = gcd(a,b);
		
		// 計算
		long result = 1;
		//System.out.println("n:" + n + "sqrt:" + sqrt(n));
		ArrayList<NumList> list = new ArrayList<NumList>();
		for(int m = 2; m <= sqrt(n); m++){
		    if(n == 1) break;
		    if(n%m == 0){
		        NumList numList = new NumList(m, 0);
		        while(n%m == 0){
		            n = n/m;
		            numList.num2++;
		        }
		        list.add(numList);
		    }
		}
		if(n != 1) list.add(new NumList(n, 1));
		result += list.size();
		// 出力
		System.out.println(result);
        
	}
	
	static long gcd(long x, long y){
	    if(x < y){
	        long temp = x;
	        x = y;
	        y = temp;
	    }
	    if(y == 0) return x;
	    if(x%y == 0) return y;
	    return gcd(y , x%y);
	}
}

class NumList {
    long num1;
    long num2;
    
    NumList(long num1, long num2){
        this.num1 = num1;
        this.num2 = num2;
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(998244353)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

//i個見て, 和がjの個数
ll dp[3001][3001] = {};

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n,s;cin>>n>>s;
  vector<int> A(n);
  rep(i,n){
    cin>>A[i];
  }

  dp[0][0] = 1;

  rep(i,n){
    rep(j,s+1){
      dp[i+1][j] += dp[i][j] * 2;
      dp[i+1][j] %= MOD;
      if(j + A[i] <= s){
        dp[i+1][j+A[i]] += dp[i][j];
        dp[i+1][j+A[i]] %= MOD;
      }
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}

Measured memory_bytes: 74012
#include<iostream>
using namespace std;
int main(){
    int n,t,a,b,min=1000,o=0;
    cin>>n>>t;
    for (int i=1; i<=n; i++) {
        cin>>a>>b;
        if (t>=b) {
            o+=1;
            if (min>a) {
                min=a;
            }
        }
    }
    if (o==0) {
        cout<<"TLE"<<endl;
    }
    else cout<<min<<endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int L[MAXN];
int R[MAXN];
char S[MAXN];

stack<int> st;

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

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

    st.push(0);

    for(int i=1;i<=n;i++){
        while(!st.empty()){
            cur = st.top();
            if(A[cur]<A[i])break;
            st.pop();
        }
        L[i] = i-st.top();
        st.push(i);
    }

    while(!st.empty())st.pop();

    st.push(n+1);

    for(int i=n;i>=1;i--){
        while(!st.empty()){
            cur = st.top();
            if(A[cur]<A[i])break;
            st.pop();
        }
        R[i] = (st.top())-i;
        st.push(i);
    }

    ll res = 0;

    for(int i=1;i<=n;i++)
        res+=1LL*A[i]*L[i]*R[i];

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 3456
import itertools, math

n = int(input())
x = []
y = []
for _ in range(n):
    xy = input().split()
    x.append(int(xy[0]))
    y.append(int(xy[1]))

j = list(range(n))
total = 0
c = 0
for v in itertools.permutations(j, n):
    for k in range(n - 1):
        a, b = v[k], v[k + 1]
        total += math.sqrt(((x[b] - x[a]) ** 2) + ((y[b] - y[a]) ** 2))
    c += 1

ave = total / c
print(ave)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n, m, v, p;
int a[114514];
signed main() {
	cin >> n >> m >> v >> p;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	p = n - p;
	for (int i = p; i < n; i++) {
		if (a[i] == a[p])p = i;
	}
	int ng = -1, ok = p, mid;
	while (ok - ng > 1) {
		mid = (ng + ok) / 2;
		int memo = 0;
		for (int i = mid + 1; i <= p; i++) {
			memo += m - (a[i] - a[mid]);
		}
		int me = p - mid;
		me = n - me;
		if (memo + me * m >= m * v && a[p] - a[mid] <= m)ok = mid;
		else ng = mid;
	}
	cout << n - ok << endl;
	ggr
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<numeric>
using namespace std;

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

    if(S == "RRR"){
        cout << 3 << endl;
    }
    else if(S=="SRR" || S=="RRS"){
        cout << 2 << endl;
    }
    else if (S=="SSR" || S=="SRS" || S=="RSS" || S=="RSR"){
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define MAXN	25
#define MAXS	1048576
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
bool limited[MAXN][MAXN], type[MAXN][MAXN];
int ans[2][MAXN][MAXS];
void update(int &x, int y) {
	x = (x + y) % P;
}
int func(int s, int tmp) {
	int t = (tmp - 1) & s;
	s &= ~(tmp - 1);
	s ^= s & -s;
	s ^= tmp;
	return s | t;
}
int main() {
	int n, m, k;
	read(n), read(m), read(k);
	for (int i = 1; i <= k; i++) {
		int x, y, z;
		read(x), read(y), read(z);
		limited[x - 1][y - 1] = true;
		type[x - 1][y - 1] = z;
	}
	ans[0][0][0] = 1;
	int goal = (1 << n - 1) - 1;
	for (int i = 0, now = 0, dest = 1; i < m; i++, now ^= 1, dest ^= 1) {
		memset(ans[dest], 0, sizeof(ans[dest]));
		for (int j = 0; j < n - 1; j++) {
			int tmp = 1 << j;
			for (int s = 0; s <= goal; s++) {
				if ((!limited[i][j] || !type[i][j]) && ((tmp & s) == 0))
					update(ans[now][j + 1][s], ans[now][j][s]);
				if (!limited[i][j] || type[i][j]) {
					if (tmp & s) update(ans[now][j + 1][s], ans[now][j][s]);
					else update(ans[now][j + 1][func(s, tmp)], ans[now][j][s]);
				}
			}
		}
		for (int s = 0; s <= goal; s++)
			update(ans[dest][0][s], ans[now][n - 1][s]);
	}
	int finalans = 0;
	for (int i = 0; i <= goal; i++)
		update(finalans, ans[m & 1][0][i]);
	cout << finalans << endl;
	return 0;
}

Measured memory_bytes: 205184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  priority_queue<ll> que;
  map<ll, int> mp;
  for(int i=0; i<N; i++){
    ll tmp;
    cin >> tmp;
    if(mp[tmp] == 1) {
      que.push(tmp);
      mp[tmp] = 0;
    }else{
      mp[tmp]++;
    }
  }
  ll ans;
  if(que.size() >= 2) {
    auto e1 = que.top(); que.pop();
    auto e2 = que.top(); que.pop();
    ans = e1*e2;
  }else ans = 0;
  

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


Measured memory_bytes: 6528
n=int(input())
a=list(map(int,input().split()))

t=sum(a)
m=10**9
flag=0
for i in range(len(a)-1):
  t-=2*a[i]
  if i==0:
    m=abs(t)
  else:
    m=min(abs(t),m)
print(m)

Measured memory_bytes: 30744
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int d,n;
  cin>>d>>n;
  if(d==0){if(n<100){cout<<n<<endl;}
           else cout<<101<<endl;}
  if(d==1){if(n<100){cout<<n*100<<endl;}
           else cout<<10100<<endl;}
  if(d==2){if(n<100){cout<<n*10000<<endl;}
           else cout<<1010000<<endl;}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<map>
#include<set> 
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<math.h>
using namespace std;
const int maxn = 1e6 + 5;
typedef unsigned long long ull;
int main()
{
	int K,X;
	cin>>K>>X;
	int sum=K*500;
	if(sum>=X)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
 } 



Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  string s;
  cin >> s;
  cout << s;
  cout << (s.back() == 's' ? "es" : "s") << endl;
  return 0;
}

Measured memory_bytes: 3632
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h1=0,m1=0,h2=0,m2=0,k=0;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<((h2-h1)*60+m2-m1-k)<<endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if (n % 2 == 0) {
            System.out.println(n);
            return;
        }
        System.out.println(2 * n);
    }

}


Measured memory_bytes: 21844
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
    int n,x,ans=0;
    cin>>n>>x;
    int a[n];
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        int d=max(0ll,a[i]+a[i+1]-x);
        a[i+1]-=d;
        chmax(a[i+1],0ll);
        ans+=d;
    }
    dans;
}


Measured memory_bytes: 1024
from sys import stdin
import numpy as np
N,M=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
data=sorted(data)
ans=0
cnt=0
for j in data:
    cnt+=j[1]
    ans+=j[0]*j[1]
    if cnt >= M:
        ans=ans-(cnt-M)*j[0]
        break
print(ans)

Measured memory_bytes: 31424
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 150005;
const ll inf = 2e18;
int main () 
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    bool no=0;
    int n;
    cin>>n;
    map<string,int> mp;
    string txt;
    int maxx=0;
    forr(i,0,n)
    {
        cin>>txt;
        mp[txt]++;
        maxx=max(maxx,mp[txt]);
    }
    vector<string> ans;
    for (auto it=mp.begin();it!=mp.end();it++)
    {
        if (it->se==maxx)
            ans.pb(it->fi);
    }
    sort(ans.begin(),ans.end());
    forr(i,0,ans.size())
    cout<<ans[i]<<endl;
}


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

int main(){
    int N;
    cin>>N;
    string W[N+1];
    for(int i=0;i<N;i++){
        cin>>W[i];
    }
    W[N]=W[N-1].at(W[N-1].size()-1);
    int d=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            if(W[i]==W[j]){
                d=0;
                break;
            }
        }
        if(d==0) break;
        if(d==1){
            if(W[i].at(W[i].size()-1)!=W[i+1].at(0)){
                            d=0;
                            break;
                }
            }
    }
    if(d==0) cout<<"No"<<endl;
    if(d==1) cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
from itertools import combinations

s = input()
K = int(input())

cand = set()
for c in s:
    cand.add(c)
for l, r in combinations(range(len(s)), 2):
    if r - l + 1 > K:
        continue
    cand.add(s[l:r + 1])

cand = list(cand)
cand.sort()

print(cand[K - 1])

Measured memory_bytes: 4776
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 3116
 *  2020/5/4
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        int[] a = new int[N];
        for(int n = 0; n < N; n++) {
            a[n] = sc.nextInt() * 2;
        }
        Arrays.sort(a);

        for(int i = 0; i < Q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();

            int lidx = Arrays.binarySearch(a, l * 2 - 1);
            if (lidx < 0) {
                lidx = -lidx - 1;
            }
            int ridx = Arrays.binarySearch(a, r * 2 + 1);
            if (ridx < 0) {
                ridx = -ridx - 1;
            }
            result.printf("%d\n", ridx - lidx);
        }

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 153232
#include<bits/stdc++.h>
using namespace std;
#define N 400 + 5
#define K 5
#define base 1000
#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, ans, C[N][K];
unordered_map <int, int> M;
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Hash(int a, int b, int c, int d){
    int ans = 0;
    ans = ans * base + a, ans = ans * base + b, ans = ans * base + c, ans = ans * base + d;
    return ans;
}
void update(int val, int x){
    int a, b, c, d;
    d = val % base, val /= base;
    c = val % base, val /= base;
    b = val % base, val /= base;
    a = val % base, val /= base;
    M[Hash(a, b, c, d)] += x;
    M[Hash(b, c, d, a)] += x;
    M[Hash(c, d, a, b)] += x;
    M[Hash(d, a, b, c)] += x;
}
signed main(){
    n = read();
    rep(i, 1, n){
        C[i][0] = read(), C[i][1] = read(), C[i][2] = read(), C[i][3] = read();
        update(Hash(C[i][0], C[i][1], C[i][2], C[i][3]), 1);
    }
    rep(i, 1, n){
        update(Hash(C[i][0], C[i][1], C[i][2], C[i][3]), -1);
        rep(j, i + 1, n){
            update(Hash(C[j][0], C[j][1], C[j][2], C[j][3]), -1);
            rep(k, 0, 3){
                int AA = Hash(C[i][0], C[i][3], C[j][k], C[j][(3 + k) % 4]);
                int BB = Hash(C[i][3], C[i][2], C[j][(1 + k) % 4], C[j][k]);
                int CC = Hash(C[i][2], C[i][1], C[j][(2 + k) % 4], C[j][(1 + k) % 4]);
                int DD = Hash(C[i][1], C[i][0], C[j][(3 + k) % 4], C[j][(2 + k) % 4]);
                int a, b, c, d;
                a = M[AA], update(AA, -1);
                b = M[BB], update(BB, -1);
                c = M[CC], update(CC, -1);
                d = M[DD], update(DD, -1);
                if(a > 0 && b > 0 && c > 0 && d > 0) ans += a * b * c * d;
                update(AA, 1), update(BB, 1), update(CC, 1), update(DD, 1);
            }
            update(Hash(C[j][0], C[j][1], C[j][2], C[j][3]), 1);
        }
        update(Hash(C[i][0], C[i][1], C[i][2], C[i][3]), 1);
    }
    printf("%lld", ans / 3);
    return 0;
}

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


int main(){
    long long L,R;
    cin>>L>>R;    
    if(R-L>=2018){
        cout<<0;
        return 0;
    }
    long long ans=2019;
    for(long long i=L;i<R;i++){
        for(long long j=L+1;j<=R;j++){
            if((i*j)%2019<ans){
                ans=(i*j)%2019;
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val ans = Iterator.continually(io.StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .map(in => {
      val Array(t, x, y) = in
      if ((x + y > t) || ((t-x-y) & 1) == 1) false else true
    })
    .takeWhile(_ == true)
    .size

  println(if (ans == n) "Yes" else "No")
}

Measured memory_bytes: 60748
#include<bits/stdc++.h>
using namespace std;
#define RI register int
char S[1005];int len,n,s,e,w;
int main()
{
	scanf("%s",S+1);
	len=strlen(S+1);
	for(RI i=1;i<=len;++i)
		if(S[i]=='S') s=1;
		else if(S[i]=='E') e=1;
		else if(S[i]=='W') w=1;
		else n=1;
	if((s^n)||(e^w)) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

void main() {
    auto S = readln.split.to!(int[]);
    auto sx = S[0], sy = S[1], tx = S[2], ty = S[3];
    void po(string c, int x) {
        foreach (i; 0..x) {
            write(c);
        }
    }
    po("R", tx-sx);
    po("U", ty-sy);

    po("L", tx-sx);
    po("D", ty-sy);

    po("L", 1);
    po("U", ty-sy+1);
    po("R", tx-sx+1);
    po("D", 1);

    po("R", 1);
    po("D", ty-sy+1);
    po("L", tx-sx+1);
    po("U", 1);
    writeln;
}

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


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N), D(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> F[i];
    sort(A.rbegin(), A.rend());
    sort(F.begin(), F.end());
    for(int i = 0; i < N; i++) D[i] = A[i]*F[i];
    ll Min = 0;
    ll Max = 0;
    for(int i = 0; i < N; i++) Max = max(Max, D[i]);
    Max++;
    ll cache;
    //cout  << " " << Min << " " << Max << endl;
    while(1){
        ll tag = (Min + Max)/2;
        //cout << tag << " " << Min << " " << Max << endl;
        if(tag == cache){
            cout << tag << endl;
            return 0;
        }
        ll k = K;
        bool flag = false;
        for(int i = 0; i < N; i++){
            ll c;
            if(D[i] <= tag) continue;
            if((D[i]-tag)%F[i] == 0) c = 0;
            else c = 1;
            ll num = (D[i] - tag)/F[i]+c;
            //cout << i << " " <<num << " " << tag << endl;
            k -= num;
            if(k < 0) {
                flag = true;
                break;
            }
        }
        if(flag) Min = tag+1;
        else Max = tag;
        cache = tag;
    }

}

Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>


#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void B_task();

int main()
{
	B_task();
	
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N, D;
	get2int(N, D);

	printf("%d\n", N / (2 * D + 1) + (N % (2*D+1) ? 1 : 0));
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cctype>
#include<cstring>
#include<string>
#include<iomanip>

using namespace std;

int main(){
	int n,taros=0,hanakos=0;
	string taro,hanako;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>taro>>hanako;
		if(taro>hanako)taros+=3;
		else if(taro==hanako){taros++;hanakos++;}
		else hanakos+=3;
		/*
		taro.erase();
		hanako.erase();
		*/
	}
	cout<<taros<<" "<<hanakos<<endl;
	return 0;

}

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

ll dp[105][2][4];

int main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	int l = s.size();
	
	//dp初期条件
	dp[0][1][0] = 1;
	dp[0][1][1] = (s[0] - '0') - 1;
	dp[0][0][1] = 1;
	
	REP(i,l-1){
		int d = s[i] - '0';
		rep(smaller, 2){
			rep(j, k+1){
				for (int x = 0; x <= 9 ; ++x) {
					int nsmaller = smaller;
					int nj = j;
					if(smaller == 0){
						if(x > d) continue;
						if(x != 0) nj++;
						if(x < d) nsmaller = 1;
					}else{
						if(x != 0) nj++;
					}
					if(nj > k) continue;
					dp[i][nsmaller][nj] += dp[i-1][smaller][j];
				}
			}
		}
	}
	
	ll ans = dp[l-1][0][k] + dp[l-1][1][k];
	cout << ans << endl;
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 string s;
 cin >> s;
 if(s[0]=='7' || s[1]=='7' || s[2]=='7')
 cout << "Yes";
 else
 cout << "No";
 return 0;
}

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

int main()
{

	int N, j = 1, k = 0;
	cin >> N;
	int a[N], b[N];
	for (int i = 1; i < N + 1; i++)
	{
		cin >> a[i];
		b[i] = 1;
	}

	while (b[j])
	{
		b[j]--;
		j = a[j];
		k++;
		if (j == 2)
		{
			cout << k << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


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

int main() {
  int n,q;
  cin >>n>>q;
  vector<int> a(n-1),b(n-1);
  vector<int>t[n],c(n);

  rep(i,n-1) {
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
    t[b.at(i)].push_back(a.at(i));
    t[a.at(i)].push_back(b.at(i));
  }
  vector<int>p(q),x(q);
  rep(i,q){
    cin>>p.at(i)>>x.at(i);
    p.at(i)--;
    c[p.at(i)]+=x.at(i);
  }
  vector<int>ans(n);
  queue<int>que;
  que.push(0);
  ans.at(0)=c.at(0);
  vector<bool>v(n,false);
  v.at(0)=true;
  while(!que.empty()){
    int p=que.front();que.pop();
    rep(j,t[p].size()){
      if(!v.at(t[p].at(j))){
        que.push(t[p].at(j));
        ans.at(t[p].at(j))=ans.at(p)+c.at(t[p].at(j));
        v.at(t[p].at(j))=true;
      }
    }
  }
  
  rep(i,n){
    cout<<ans.at(i)<<" ";
  }
}

Measured memory_bytes: 19444
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N;

//オリジナル変数


//サブ関数
//入力
void input() {
	cin >> N;
}

//計算
void calc() {
	
}

//出力
void output() {
	int upper = 0;
	while (upper*(upper+1)*0.5 < N) upper++;
	
	while (N > 0) {
		if (upper <= N) {
			cout << upper << endl;
			N -= upper;
		}
		upper--;
	}
}

//デバッグ
void debug() {
	cin >> N;
}

//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] h; readA(n, h);

  auto dp = new int[](n);
  dp[0] = 0; dp[1] = (h[1]-h[0]).abs;
  foreach (i; 2..n)
    dp[i] = min(dp[i-1] + (h[i]-h[i-1]).abs, dp[i-2] + (h[i]-h[i-2]).abs);

  writeln(dp[$-1]);
}


Measured memory_bytes: 3580
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (b-a == c-b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
w = input()
d = dict()
flag = 0
for i in w:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1
for k,v in d.items():
    if v%2==0:
        flag=1
    else:
        flag=0
        break
if flag==1:
    print("Yes")
else:
    print("No")


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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
using namespace std;

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

vector<int> Input(int n)
{
	vector<int> Tree(n);
	for(int i = 0; i < n; i++){
		cin >> Tree[i];
	}
	return Tree;
}

void PostorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	PostorderOutput(Node->LChild);
	PostorderOutput(Node->RChild);
	cout << Node->Id;
	if(Node->Parent){
		cout << ' ';
	}else{
		cout << endl;
	}
}

int FindIndex(vector<int> X, int a)
{
	int Count = 0;
	while(Count < X.size()){
		if(X[Count] == a){
			return Count;
		}
		Count++;
	}
	return Count;
}

vector<int> Subvec(vector<int> X, int m, int n)
{
	vector<int> Y;
	for(int i = m; i <= n; i++){
		Y.push_back(X[i]);
	}
	return Y;
}

TNode* MakeTree(const vector<int>& PreorderRow, const vector<int>& InorderRow)
{
	//PreorderRow????????????????´?Root?????¨???*
	int Root = PreorderRow[0];
	
	//InorderRow??????????????????Root??????InorderRowLeft?????¨???
	int RootIndex = FindIndex(InorderRow, Root);
	vector<int> InorderRowLeft = Subvec(InorderRow, 0, RootIndex-1);
	
	//PreorderRow???2??????????????????InorderRowLeft??¨???????????°???PreorderRowLeft?????¨???
	vector<int> PreorderRowLeft = Subvec(PreorderRow, 1, RootIndex);
	
	//PreorderRow??¨InorderRow???????????????PreorderRowRight,InorderRowRight?????¨???
	vector<int> PreorderRowRight = Subvec(PreorderRow, RootIndex+1, PreorderRow.size()-1);
	vector<int> InorderRowRight  = Subvec(InorderRow, RootIndex+1, InorderRow.size()-1);
	
	//ID???Root??¨????????????????????????**
	TNode* RootNode;
	RootNode = new TNode;
	*RootNode = {Root, NULL, NULL, NULL};
	
	//PreorderRowLeft,InorderRowLeft??????*~**??¨????§???????????????????(?????????????´????RootLeft??¨??????)
	if(PreorderRowLeft.size() > 0){
		TNode* LeftNode = MakeTree(PreorderRowLeft, InorderRowLeft);
		//Root??¨RootLeft???????????????
		RootNode->LChild = LeftNode;
		LeftNode->Parent = RootNode;
	}
	
	//PreorderRowRight,InorderRowRight??????*~**??¨????§???????????????????(?????????????´????RootRight??¨??????)
	if(PreorderRowRight.size() > 0){
		TNode* RightNode = MakeTree(PreorderRowRight, InorderRowRight);
		//Root??¨RootRight???????????????
		RootNode->RChild = RightNode;
		RightNode->Parent = RootNode;
	}
	
	return RootNode;
}

int main()
{
	int n;
	cin >> n;
	vector<int> PreorderRow = Input(n);
	vector<int> InorderRow  = Input(n);
	TNode* RootNode = MakeTree(PreorderRow, InorderRow);
	PostorderOutput(RootNode);
//	DeleteNode(RootNode);
    return 0;
}

Measured memory_bytes: 3176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0521
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = ReadInt();
                if (n == 0) break;

                int change = 1000 - n;
                int res = 0;
                int[] coins = new int[] { 500, 100, 50, 10, 5, 1 };

                for (int i = 0 ; i < coins.Length ; i++)
                {
                    res += change / coins[i];
                    change %= coins[i];
                }

                Console.WriteLine(res);
    
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 15932
#include <bits/stdc++.h>
#define reps(i,j,k) for(int i = j; i < k; ++i)
#define rep(i,j) reps(i,0,j)
#define pb push_back
#define fr first
#define fs fr
#define sc second
#define ll long long
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> Pii;


int main(){
	int n, m;
	while(cin >> n, n){
		vi m(n);
		vector<vi> p(n);
		rep(i,n){
			cin >> m[i];
			p[i].resize(m[i]);
			rep(j,m[i]){
				cin >> p[i][j];
				p[i][j]--;
			}
			sort(p[i].begin(), p[i].end());
		}
		int k;
		cin >> k;
		vi v(k);
		rep(i,k){
			cin >> v[i];
			v[i]--;
		}
		sort(v.begin(), v.end());
		int ans = -1;
		rep(i,n){
			bool f = true;
			rep(j, k){
				bool f2 = false;
				rep(l,m[i])
					if(p[i][l] == v[j]) f2 = true;
				if(!f2) f = false;
			}
			if(f){
				if(ans == -1) ans = i+1;
				else ans = -2;
			}
		}

		if(ans < 0) cout << (-1) << endl;
		else cout << ans << endl;

	}

	return 0;
}

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

int L;
int next(int x){
  vector<int> v1, v2;
  for(int i=0; i<L; i++){
    v1.push_back(x%10);
    v2.push_back(x%10);
    x/=10;
  }
  sort(v1.begin(), v1.end(), greater<int>());
  sort(v2.begin(), v2.end());
  int x1=0, x2=0;
  for(int i=0; i<L; i++){
    x1=x1*10+v1[i];
    x2=x2*10+v2[i];
  }
  return x1-x2;
}

int main(){
  while(true){
    int a;
    cin>>a>>L;
    if(a==0&&L==0)break;
    vector<int> v;
    while(true){
      v.push_back(a);
      a=next(a);
      bool flag=false;
      int i;
      for(i=0; i<v.size(); i++)
        if(a==v[i]){flag=true; break;}
      if(flag){cout<<i<<" "<<a<<" "<<v.size()-i<<endl; break;}
    }
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    i64 nsq = sqrt(n);
    i64 dmax = 1;
    for (i64 i = 1; i <= nsq; i++)
    {
        if (n % i != 0)
            continue;
        dmax = i;
    }

    i64 ans = dmax + (n / dmax) - 2;
    cout << ans << endl;

    return 0;
}

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

int main(){
  int n, d, x;
  // int a[101];

  cin >> n >> d >> x;

  int first = 0;
  for(int i=0; i<n; i++){
    int a, sumc = 0;
    cin >> a;
    for(int j=0; a*j+1<=d; j++){
      sumc++;
    }
    first+=sumc;
  }

  cout << first + x << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	char c[100000];
	int i=0,j;
	while(1){
		scanf("%c",&c[i]);
		if(i%2==0)
			printf("%c",c[i]);
		if(c[i]=='\n')
			break;
		i++;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    string S;
    cin >> S;
    if(S[0] == 'S'){
        if(S[1] == 'U') fin(7);
        else fin(1);
    }else if(S[0] == 'M') fin(6);
    else if(S[0] == 'T'){
        if(S[1] == 'U') fin(5);
        else fin(3);
    }else if(S[0] == 'W') fin(4);
    else fin(2);
    return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int dx[8] = {0, -1, -1, -1,  0,  1, 1, 1};
int dy[8] = {1,  1,  0, -1, -1, -1, 0, 1};
bool in_area(int x, int y, int W, int H){

  bool in;
  in = (0 <= x && x < W) && (0 <= y && y < H);
  return in;
}
string count_or_bomb(string s[], int x, int y, int W, int H){

  int k, _x, _y, count = 0;
  if (s[y].at(x) == '#')
    return "#";
  for (k = 0; k < 8; k++){
    _x = x + dx[k];
    _y = y + dy[k];
    if (in_area(_x, _y, W, H) && s[_y].at(_x) == '#')
      count ++;
  }
  return to_string(count);
}
int main(){
  int H, W, x, y;
  string S[50];
  cin >> H >> W;
  for (y = 0; y < H; y++){
    cin >> S[y];
  }
  for (y = 0; y < H; y++){
    for (x = 0; x < W; x++){
      cout << count_or_bomb(S, x, y, W, H);
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256