akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p,l,r;
};

struct Node T[MAX];
int n;
void preOrder(int );
void inOrder(int );
void postOrder(int );

int main(){
  int i,d,v,l,r;
  scanf("%d", &n);
  for(i = 0 ; i<n; i++){
    T[i].p = NIL;
  }

  for(i = 0; i<n ;i ++){
    scanf("%d", &v);
    scanf("%d", &l);
    scanf("%d", &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) {
      T[l].p = v;
    }
    if(r != NIL){
      T[r].p = v;
    }
  }

    for( i= 0; i<n; i++){
      if(T[i].p == NIL){
	d = i;
      }
    }

    printf("Preorder\n");
    preOrder(d);
    printf("\n");
    printf("Inorder\n");
    inOrder(d);
    printf("\n");
    printf("Postorder\n");
    postOrder(d);
    printf("\n");
    return 0;
  }
  void preOrder(int z){
  if( z == NIL ) return;
  printf(" %d", z);
  preOrder(T[z].l);
  preOrder(T[z].r);
}


void inOrder(int z){
  if( z == NIL) return;
  inOrder(T[z].l);
  printf(" %d", z);
  inOrder(T[z].r);
}

void postOrder(int z){
  if( z == NIL ) return;
  postOrder(T[z].l);
  postOrder(T[z].r);
  printf(" %d", z);
}



Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    cout << std::fixed << std::setprecision(10);

    int x, t;
    cin >> x >> t;
    int answer = x - t > 0 ? x - t : 0;
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String...args) {
    	Scanner scan = new Scanner(System.in);
    	int times = scan.nextInt();
    	int[] x = new int[times];
    	int[] y = new int[times];
    	double p1   = 0;
    	double p2   = 0;
    	double p3   = 0;
    	List<Double> pMax = new ArrayList<>();
    	
    	for(int i = 0; i < 2; i++) {
    		for(int n = 0; n < times ; n++) {
    			if(i == 0) {
    				x[n] = scan.nextInt();
    			} else if(i == 1) {
    				y[n] = scan.nextInt();
    			}
    		}
    	}
		for(int m = 0; m < times ; m++) {
			double test = (x[m] - y[m]);
			test = Math.abs(test);
			pMax.add(Math.abs(test));
			p1 += Math.abs(test) ;
			p2 +=  Math.pow(Math.abs(x[m] - y[m]),2);
			p3 +=  Math.pow(Math.abs(x[m] - y[m]),3);
		}
		p2 = Math.sqrt(p2);
		p3 = Math.pow(p3 , 1.0/3.0);
		Collections.sort(pMax);
		System.out.println(p1);
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(pMax.get(pMax.size()-1));
	}
}


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

int main(){
    string s, t;
    cin >> s >> t;

    // ex s = "axyb", t = "abyxb";
    int m = (int)s.size(), n = (int)t.size();

    vector<vector<int>> nums(m+2, vector<int>(n+2,0));
    
    for (int i = 0; i < m; i++){
        for (int j = 0; j < n; j++){
            if (s[i] == t[j]) nums[i+1][j+1] = max(nums[i+1][j+1], nums[i][j] + 1);
            nums[i+1][j+1] = max(nums[i+1][j+1], nums[i][j+1]);
            nums[i+1][j+1] = max(nums[i+1][j+1], nums[i+1][j]);            
        }
    }

  
    // find one longest string
    string ans = "";

    int i = m, j = n;
    while (i > 0 && j > 0){
        if (nums[i][j] == nums[i-1][j]) i--;
        else if (nums[i][j] == nums[i][j-1]) j--;
        else if (nums[i][j] == nums[i-1][j-1] + 1) ans = s[i-1] + ans, i--, j--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 35584
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define rep(i, x, y) for (int i = x; i <= y; i ++)
using namespace std;

const int N = 1e5 + 50;
const int mod = 1e9 + 7;

struct Matrix {
  int a[3][3];
  Matrix() { memset(a, 0, sizeof a); }
  inline int* operator [] (int i) { return a[i]; }
  inline Matrix operator * (const Matrix &o) const {
    Matrix ret;
    long long tmp;
    rep(i, 0, 2) rep(j, 0, 2) {
      tmp = 0;
      rep(k, 0, 2) tmp += 1LL * a[i][k] * o.a[k][j];
      ret.a[i][j] = tmp % mod;
    }
    return ret;
  }
} cut, Ncut, ans;

int n, m, a[N];

inline Matrix Pow(Matrix x, int exp) {
  Matrix res;
  res[0][0] = res[1][1] = res[2][2] = 1;
  for (; exp; exp >>= 1, x = x * x)
    if (exp & 1) res = res * x;
  return res;
}

int main() {
  scanf("%d%d", &n, &m);
  rep(i, 1, m) scanf("%d", &a[i]);
  cut[0][0] = cut[1][0] = 2;
  cut[0][1] = cut[0][2] = cut[1][1] = cut[2][0] = cut[2][1] = cut[2][2] = 1;
  rep(i, 0, 2) rep(j, 0, i) Ncut[i][j] = 1;
  Ncut[1][0] = 2;
  rep(i, 0, 2) ans[0][i] = 1;
  rep(i, 1, m)
    ans = ans * Pow(cut, a[i] - a[i - 1] - 1) * Ncut;
  ans = ans * Pow(cut, n - a[m] - 1);
  printf("%d\n", ans[0][0]);
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int score=0;
        if(x==1&&y==1){
            score+=400000;
        }
        if(x==1){
            score+=300000;
        }
        if(x==2){
            score+=200000;
        }
        if(x==3){
            score+=100000;
        }

        if(y==1){
            score+=300000;
        }
        if(y==2){
            score+=200000;
        }
        if(y==3){
            score+=100000;
        }
        System.out.println(score);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  long long K,A,B;
  cin >> K >> A >> B;
  
  if (B-A <= 1 || A >= K+1){
    cout << K + 1 << endl;
  }
  else {
    long long sum = ((K-A+1)/2)*(B-A) + (K-A+1)%2 + A;
    cout << sum << endl;
  }
}

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

int main()
{
    int n, q;
    cin >> n;
    unordered_map<int, int> a;
    ll current = 0;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        a[temp]++;
        current += temp;
    }

    cin >> q;
    rep(i, q)
    {
        int b, c;
        cin >> b >> c;
        if (a.count(b))
        {
            int kosu = a.at(b);
            int erased = b * kosu;
            //current -= erased;
            int inserted = c * kosu;
            //current += inserted;
            current -= kosu *(b - c);
            a.erase(b);
            a[c] += kosu;

            //cout << "Changed: " << kosu << endl;
        }

        cout << current << endl;
    }
    return 0;
}

Measured memory_bytes: 6572
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
using namespace std;
#define ss second
#define ff first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    while(T --> 0)
    {
        cin>>a>>b>>c;
        cout<<c<<' '<<a<<' '<<b;
    }
    return 0;
}

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

class Dice {
	int m_top;
	int m_front;
	int m_right;
	int m_face[6];
public:
	Dice(int face[], int top, int front, int right);
	int faceNum(int face) {
		return m_face[face];
	}
	void roll(int news);
	int top() {
		return m_top;
	}
	int bottom() {
		return (5 - m_top);
	}
	int front() {
		return m_front;
	}
	int back() {
		return (5 - m_front);
	}
	int right() {
		return m_right;
	}
	int left() {
		return (5 - m_right);
	}
};

Dice::Dice(int face[], int top, int front, int right) {
	for (int i = 0; i < 6; i++) {
		m_face[i] = face[i];
	}
	m_top = top;
	m_front = front;
	m_right = right;
}

void Dice::roll(int news) {
	int temp = 0;
	switch (news)
	{
	case 0:		// N
		temp = bottom();
		m_top = m_front;
		m_front = temp;
		break;
	case 1:		// E
		temp = left();
		m_right = m_top;
		m_top = temp;
		break;
	case 2:		// S
		temp = back();
		m_front = m_top;
		m_top = temp;
		break;
	case 3:		// W
		temp = bottom();
		m_top = m_right;
		m_right = temp;
		break;
	default:
		break;
	}
}

int main()
{
	int f[6];
	for (int i = 0; i < 6; i++) {
		cin >> f[i];
	}
	Dice d(f, 0, 1, 2);

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int top, front;
		cin >> top >> front;

		while (d.faceNum(d.front()) != front)
		{
			for (int j = 0; j < 4; j++) {
				if (d.faceNum(d.front()) == front) {
					break;
				}
				else
				{
					d.roll(0);
				}
			}
			d.roll(1);
		}
		while (d.faceNum(d.top()) != top)
		{
			d.roll(1);
		}
		
		cout << d.faceNum(d.right()) << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public 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();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		
		int N=sc.nextInt();
		int K=sc.nextInt();
	
		int rest=N%K;
		
		if(rest==0){
			System.out.println(0);
		}else{
			System.out.println(1);	
		}
	
	}
}

Measured memory_bytes: 23508
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

#define int long long
#define double long double
#define endl '\n'
#define gcd __gcd
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(), x.end()
const int inf = __LONG_LONG_MAX__;

using namespace std;

void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

signed main() {
  fast_io();

  int n, m;
  cin >> n >> m;

  vector<int> penalties(n + 2, 0);
  vector<bool> accepted(n + 2, false);

  for (int i = 0; i < m; i++) {
    int id;
    string result;
    cin >> id >> result;

    if (!accepted[id]) {
      if (result == "WA") penalties[id]++;

      if (result == "AC") accepted[id] = true;
    }
  }

  int count = 0;
  int sum = 0;

  for (int i = 0; i <= n; i++) {
    if (accepted[i]) {
      count++;
      sum += penalties[i];
    }
  }

  cout << count << " " << sum << "\n";

  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int m = fs.nextInt();
        int res = 0;
        for (int p = 1; p * p <= m; p++) {
            if (m % p == 0) {
                if (p <= m / n) {
                    res = Math.max(res, p);
                }
                if (m / p <= m / n) {
                    res = Math.max(res, m / p);
                }
            }
        }
        System.out.println(res);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32864
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
   
   int A,B;
   
   scanf("%d%d",&A,&B);
   
   int ans1 = A + B;
   int ans2 = A - B;
   int ans3 = A * B;
   
   if (ans1 > ans2) {
      if (ans1 > ans3) {
         printf("%d\n",ans1);
      }
      else {
         printf("%d\n",ans3);
      }
   }
   else {
      if (ans2 > ans3) {
         printf("%d\n",ans2);
      }
      else {
         printf("%d\n",ans3);
      }
   }
   
   return 0;
}


Measured memory_bytes: 128
#include <algorithm> // for sorting 
#include <iostream> 
using namespace std; 
#define mod 1000000007
#define ll long long int
// Required function 
ll maxProductSubarrayOfSizeK(ll A[], ll n, ll k) 
{ 
    // sorting given input array 
    sort(A, A + n); 
  
    // variable to store final product of all element 
    // of sub-sequence of size k 
    ll product = 1; 
  
    // CASE I 
    // If max element is 0 and 
    // k is odd then max product will be 0 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    // CASE II 
    // If all elements are negative and 
    // k is odd then max product will be 
    // product of rightmost-subarray of size k 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (ll i = n - 1; i >= n - k; i--){ 
            product = (product*A[i])%mod;
        }
        return (product%mod)+mod; 
    } 
  
    // else 
    // i is current left poller index 
    ll i = 0; 
  
    // j is current right poller index 
    ll j = n - 1; 
  
    // CASE III 
    // if k is odd and rightmost element in 
    // sorted array is positive then it 
    // must come in subsequence 
    // Multiplying A[j] with product and 
    // correspondingly changing j 
    if (k & 1) { 
        product = (product*A[j])%mod;
        j--; 
        k--; 
    } 
  
    k >>= 1; 
  

    for (ll itr = 0; itr < k; itr++) { 
  

        ll left_product = (A[i] * A[i + 1]); 
  
        ll right_product = (A[j] * A[j - 1]);
        if (left_product > right_product) { 
            product = (((product*A[i])%mod)*A[i+1])%mod;
            i += 2; 
        } 
        else { 
            product = (((product*A[j])%mod)*A[j-1])%mod;
            j -= 2; 
        } 
    } 
    if(product<0)
        product=(product%mod)+mod;
    return product; 
} 
  
// Driver Code to test above function 
int main() 
{ 
    ll n,k;
    cin>>n>>k;
    ll A[n];
    for(ll i=0;i<n;i++)
        cin>>A[i];
    cout << maxProductSubarrayOfSizeK(A, n, k); 
  
    return 0; 
} 

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int N;
    cin >> N;
    int a[N];
    int One=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]==1){
            One++;
        }
    }
    if(One ==0){
        cout << -1 << endl;
        return 0;
    }
    int count =0;
    int j=0;
    if(N==1){
        if(a[0]==1){
            cout << 0 << endl;
            return 0;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=1;i<N;i++){
        for(j;j<N;j++){
            if(a[j]==i){
                j=j+1;
                break;
            }
            count++;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 4424
/**
*    author:  Taichicchi
*    created: 07.09.2020 00:30:52
**/

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

using namespace std;

int main() {

    for(int i=1;i<6;++i){
        int x;
        cin >> x;
        if(x == 0){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

long long int i, j;
int cmp(const void * a, const void * b) {
    return *(long long int*)a-*(long long int*)b;
}

int main(void) {
    long long int n, m;
    long long int a[100000][2];
    scanf("%lld %lld", &n, &m);
    
      for(i=0; i<n; i++)
      scanf("%lld %lld",&a[i][0], &a[i][1]);
      qsort(a, n, sizeof(a[0]), cmp);
      long long int sum = 0, cnt = 0;

      // for(int i=0; i<n; i++) printf("%d %d\n", a[i][0], a[i][1]);
      for(i=0; i<n; i++) {
          for(j=0; j < a[i][1]; j++) {
              sum += a[i][0];
              cnt++;
              if(cnt >= m) break;
          }
        if(cnt >= m) break;
      }
      printf("%lld", sum);
      return 0;
}

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

using namespace std;

typedef long long ll;

struct SHOP{
	int id;
	int no;
	string city;
	int s;
};

bool sx(SHOP& rh, SHOP& lh)
{
	if (rh.city < lh.city) return true;
	else if ((rh.city == lh.city)&&(rh.s > lh.s)) return true;
	return false;
}

bool sy(SHOP& rh, SHOP& lh)
{
	if (rh.id < lh.id) return true;
	return false;
}

int main(int, char**)
{
	ll  n;
	cin >> n;
	vector<SHOP> ss(n);

	for(int i = 0; i < n; i++) {
		ss[i].id = i + 1;
		cin >> ss[i].city >> ss[i].s;
	}
	sort(&(ss[0]), &(ss[n]), sx);
	// for(int i = 0; i < n; i++) {
	//	cerr << ss[i].city << "," << ss[i].s << "=" << ss[i].id << "\n";
	// }

	for(int i = 0; i < n; i++) {
		cout << ss[i].id << "\n";
	}
	// sort(&(ss[0]), &(ss[n]), sy);
	cout.flush();
	return 0;
}



Measured memory_bytes: 256
def main():
    num = int(input())
    if num > 1799:
        print(1)
    elif num > 1599:
        print(2)
    elif num > 1399:
        print(3)
    elif num > 1199:
        print(4)
    elif num > 999:
        print(5)
    elif num > 799:
        print(6)
    elif num > 599:
        print(7)
    elif num > 399:
        print(8)

if __name__ == '__main__':
    main()


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<bool> dp(11000);
	dp[0]=1;
	rep(i, n){
		int s; cin >>s;
		repr(j, 10001, 0) if(dp[j]) dp[j+s] =1;
	}
	repr(i, 10001, 0){
		if(dp[i] && i%10){ cout <<i <<"\n"; return 0;}
	}
	puts("0");
	return 0;
}


Measured memory_bytes: 256
N=int(input())
a=0
w=0
t=0
r=0
for _ in range(N):
	s=input()
	if s=='AC':
		a+=1
	elif s=='WA':
		w+=1
	elif s=='TLE':
		t+=1
	else:
		r+=1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = (2e9);
int main(){
  int V, E;
  cin >> V >> E;
  vector< vector<int> > D(V,vector<int>(V,INF));
  for(int i = 0; i < E; ++i){
    int s, t, d;
    cin >> s >> t >> d;
    D[s][t] = d;
  }
  for(int i = 0; i < V; ++i) D[i][i] = 0;
  for(int k = 0; k < V; ++k)
    for(int i = 0; i < V; ++i)
      for(int j = 0; j < V; ++j)
        if(D[i][k] != INF && D[k][j] != INF)
          D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
  for(int i = 0; i < V; ++i){
    if(D[i][i] < 0){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  for(int i = 0; i < V; ++i){
    for(int j = 0; j < V; ++j){
      if(D[i][j] < INF) cout << D[i][j];
      else cout << "INF";
      if(j < V-1) cout << " ";
      else cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node{int parent,left,right;};

vector<Node> T(MAX);
int n;
vector<int> D(MAX),H(MAX);

void setDepth(int u,int d){
    if(u == NIL) return;
    D.at(u) = d;
    setDepth(T.at(u).left,d+1);
    setDepth(T.at(u).right,d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T.at(u).left != NIL){
        h1 = setHeight(T.at(u).left) + 1;
    }
    if(T.at(u).right != NIL){
        h2 = setHeight(T.at(u).right) + 1;
    }
    return H.at(u) = max(h1,h2);
}

int getSibling(int u){
    if(T.at(u).parent == NIL) return NIL;
    if(T.at(T.at(u).parent).left != u && T.at(T.at(u).parent).left != NIL) return T.at(T.at(u).parent).left;
    if(T.at(T.at(u).parent).right != u && T.at(T.at(u).parent).right != NIL) return T.at(T.at(u).parent).right;
    return NIL;
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T.at(u).parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int deg = 0;
    if(T.at(u).left != NIL) deg++;
    if(T.at(u).right != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D.at(u) << ", ";
    cout << "height = " << H.at(u) << ", ";

    if(T.at(u).parent == NIL){
        cout << "root" << endl;
    }else if(T.at(u).left == NIL && T.at(u).right == NIL){
        cout << "leaf" << endl;
    }else{
        cout << "internal node" << endl;
    }
}

void preorder(int u){
    cout << " "  << u;
    if(T.at(u).left != NIL) preorder(T.at(u).left);
    if(T.at(u).right != NIL) preorder(T.at(u).right);
}

void inorder(int u){
    if(T.at(u).left != NIL) inorder(T.at(u).left);
    cout << " "  << u;
    if(T.at(u).right != NIL) inorder(T.at(u).right);
}

void postorder(int u){
    if(T.at(u).left != NIL) postorder(T.at(u).left);
    if(T.at(u).right != NIL) postorder(T.at(u).right);
    cout << " "  << u;
}
int main(){
    int v,l,r,root = 0;
    cin >> n;

    for(int i = 0; i < n; i++) T.at(i).parent = NIL;

    for(int i = 0; i < n; i++){
        cin >> v >> l >> r;
        T.at(v).left = l;
        T.at(v).right = r;
        if(l != NIL) T.at(l).parent = v;
        if(r != NIL) T.at(r).parent = v;
    }

    for(int i = 0; i < n; i++) if(T.at(i).parent == NIL) root = i;

    // setDepth(root,0);
    // setHeight(root);

    // for(int i = 0; i < n; i++) print(i);
    cout << "Preorder" << endl;
    preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(root);
    cout << endl;

    return 0;
}




Measured memory_bytes: 3228
#include <stdio.h>
int a, b, c, d;
int main (){
	scanf("%d%d%d%d", &a, &b, &c, &d);
	while (1){
		c = c - b;
		if(c <= 0){
			printf("Yes");
			break;
		}
		a = a - d;
		if (a <= 0){
			printf("No");
			break;
		}
    }
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<pair<int, int>> v(n);
  int ans=0;
  for(int i=0;i<n;i++) {
    int x;
    cin >> x;
    v[i] = make_pair(x, i+1);
  }
  sort(v.begin(),v.end());
  for(auto x: v) cout << x.second << " ";
  cout << endl;
}
                                          


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

ll h, w, m[3], mm;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  mm = h * w;
  if(h>w) swap(h, w);
  ll ans = h;
  if(h%3 && w%3){
    ll _h, _w;
    FOR(i, 0, 2){
      FOR(j, 0, 2){
        _h = h/3 + j;
        m[0] = w*_h;
        _h = h - _h;
        m[1] = _h * (w / 2);
        m[2] = mm - m[0] - m[1];
        sort(m, m+3);
        mins(ans, m[2] - m[0]);
      }
      swap(h, w);
    }
  }else{
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [n, x] <- getInts
  ; if n == 0 && x == 0 then return ()
    else print (length (filter (( x == ) . sum) (comb [1.. n] 3))) >> loop
  }

comb :: [Int] -> Int -> [[Int]]
comb ns 0 = [[]]
comb ns k = if length ns == k then [ns]
           else map (head ns :) (comb (tail ns) (k - 1)) ++ comb (tail ns) k
--
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords .  map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""




Measured memory_bytes: 5676
N = int(input())
a = list(map(int,input().split()))
b = [ a[i] for i in range(N)]

ans = 0
s= 0
for i in range(N):
    s += a[i]
    if i % 2 == 0 and s <= 0:
        a[i] += abs(1 - s)
        ans += abs(1 - s)
        s = 1
    elif i % 2 == 1 and s >= 0:
        a[i] -= abs(-1 - s)
        ans += abs(-1 - s)
        s = -1

ans2 = 0
s = 0
for i in range(N):
    s += b[i]
    if i % 2 == 0 and s >= 0:
        b[i] -= abs(-1 - s)
        ans2 += abs(-1-s)
        s = -1
    elif i % 2 == 1 and s <= 0:
        b[i] += abs(1 - s)
        ans2 += abs(1 - s)
        s = 1

print(min(ans,ans2))


Measured memory_bytes: 63828
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 2e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )
 
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
ll fac(ll n)
{
	if(n<=1) return 1 ;
	return n*fac(n-1);
}
 
int solve()
{
 	ll n ;
 	cin >> n ;
 	ld ans = 0;
 	vector<pair<ld,ld>> v(n);
 	rep(i,0,n) cin >> v[i].F >> v[i].S ;
 	sort(all(v));
 	do{
 		for(int i =1 ; i < n ; i++)
 			ans += sqrt((v[i].F-v[i-1].F)*(v[i].F-v[i-1].F)+(v[i].S-v[i-1].S)*(v[i].S-v[i-1].S));
 	}
 	while(next_permutation(all(v)));
 	cout << fixed << setprecision(9) << ans/ld(fac(n)) ; 
	
}
int main()
{
	fast;
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
 
	return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

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

#define ll long long

using namespace std;

struct pt
{
	ll r;
	ll c;
};

bool operator<(const pt &a, const pt &b)
{
	return (a.r == b.r) ? a.c < b.c : a.r < b.r;
}

int ans = 2147483647;
int N;
vector<pt> pts;
bool used[55];

int main()
{
	scanf("%d", &N);

	for (int i = 0; i < N; ++i)
	{
		ll r, c;
		scanf("%lld %lld", &r, &c);
		pts.push_back({ r, c });
	}

	sort(pts.begin(), pts.end());

	for (int i = 0; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			ll p = pts[j].r - pts[i].r, q = pts[j].c - pts[i].c;

			memset(used, 0, sizeof(used));
			int cnt = 0;

			for (int k = 0; k < N; ++k)
			{
				if (used[k]) continue;

				ll before_r = pts[k].r, before_c = pts[k].c;
				cnt++;

				while (true)
				{
					pt temp = { before_r + p, before_c + q };

					auto it = lower_bound(pts.begin(), pts.end(), temp);
					int idx = it - pts.begin();

					if (idx < N && pts[idx].r == before_r + p && pts[idx].c == before_c + q)
					{
						used[idx] = true;
						before_r += p, before_c += q;
					}
					else break;
				}
			}

			if (cnt < ans) ans = cnt;
		}
	}
	
	if(N != 1) printf("%d\n", ans);
	else printf("1\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main() 
{
	int a, b, C;
	double S, L, h, PI;
	PI = 3.14159265358979;
	cin >> a >> b >> C;
	S = 0.5 * a * b * sin(C * PI / 180);
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * PI / 180));
	h = b * sin(C * PI / 180);
	cout << fixed << setprecision(8) << S << endl;
	cout << fixed << setprecision(8) << L << endl;
	cout << fixed << setprecision(8) << h << endl;
	return 0;
}


Measured memory_bytes: 3460
#include<cstdio>

long long min(long long a,long long b){ return a>b?b:a; }

int main(){
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if((b-a)%2){
        long long ans = min(a-1+1+(b-a-1)/2,n-b+1+(b-a-1)/2);
        printf("%lld\n",ans);
    }
    else printf("%lld\n",(b-a)/2);
}


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

int main()
{
	int w;

	while (cin >> w, cin.eof() != true){
		for (int i = 1; i <= 512; i *= 2){
			if (w % (i * 2) != 0){
				cout << i;
				w -= i;
				if (w != 0){
					cout << " ";
				}
			}
			if (w == 0){
				cout << endl;
				break;
			}
		}
	}

	return (0);
}

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


int main() {
    char a;

    cin >> a;

    if(a == 'A'){
        cout << "T" << endl;
    }

    if(a == 'T'){
        cout << "A" << endl;
    }

    if(a == 'C'){
        cout << "G" << endl;
    }

    if(a == 'G'){
        cout << "C" << endl;
    }

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	state := make([]int, 101)
	for i := 0; i <= 100; i++ {
		if a <= i && i <= b {
			state[i]++
		}
		if c <= i && i <= d {
			state[i]++
		}
	}

	cnt := 0
	for _, v := range state {
		if v == 2 {
			cnt++
		}
	}
	if cnt > 0 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(0)
	}
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <numeric>
#include <cassert>
#include <queue>

const int MAXINT = 1000;

void bfs(std::vector<std::vector<int> >& adj_list, std::vector<int>& d, int root = 0 ){
  std::queue<int> target_q;
  // std::queue<int> dist_q;
  target_q.push(root);
  d[root] = 0;
  // dist_q.push(0;)
  while(!target_q.empty()){
    int vtx = target_q.front(); target_q.pop();
    for(int const&  u : adj_list[vtx]){
      if(d[vtx] + 1 < d[u]){
      target_q.push(u);
        // std::cout<< "/* message */" << std::endl;
        d[u] = d[vtx] + 1;
      }
    }
  }
}


int main(int argc, char const *argv[]) {
  int n; // .. 100
  std::cin >> n;
  std::vector<std::vector<int> > adj_list(n);
  std::vector<int> d(n, MAXINT);

  for(int q=0; q<n; ++q){
    int i_plus_1, k;
    std::cin >> i_plus_1;
    std::cin >> k;
    for(int p=0; p<k; ++p){
      int j_plus_1;
      std::cin >> j_plus_1;
      // adj[i_plus_1-1][j_plus_1-1] = true;
      adj_list[i_plus_1 - 1].push_back(j_plus_1-1);
    }
  }
  bfs(adj_list, d, 0);

  for(int i=0; i<n; ++i){

    // if(d[i] < MAXINT){
      std::cout << (i+1)
        << " " << (d[i]==MAXINT ? -1 : d[i])
        << std::endl;
  }


  // for(auto it = adj_list.begin(); it != adj_list.end(); ++it){
  //   std::cout << ": ";
  //   for(auto jt = (*it).begin(); jt != (*it).end(); ++jt){
  //     std::cout << (*jt) << ' ';
  //   }
  //   std::cout << std::endl;
  // }

  return 0;
}

Measured memory_bytes: 3160
using System;

namespace AtCoder0205
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');
            int[] x = new int[M];

            for(int i = 0; i < M; i++)
            {
                x[i] = int.Parse(s[i]);
            }

            Array.Sort(x);

            int[] l = new int[M - 1];

            for(int i=1;i<M;i++)
            {
                l[i - 1] = x[i] - x[i - 1];
            }

            Array.Sort(l);

            int total = 0;

            for(int i=0;i<M-N;i++)
            {
                total += l[i];
            }

            Console.WriteLine(total.ToString());
        }


    }
}


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

const int N=200005;

int n,m,a[N],b[N];
struct data{int l,r,c;}in[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

bool check(int lim)
{
	for (int i=1;i<=m;i++) b[i]=(a[i]>=lim);
	int tot=0;
	for (int l=1;l<=m;l++)
	{
		int r=l;
		while (r<m&&b[r+1]==b[l]) r++;
		if (l==r) continue;
		in[++tot]=(data){l,r,b[l]};
		l=r;
	}
	if (!tot) return b[1];
	in[0].r=0;
	for (int i=1;i<=tot;i++)
	{
		int l=in[i-1].r+1,r=in[i].l-1;
		if (l>r) continue;
		int mid=(l+r)/2;
		in[i-1].r=mid;in[i].l=mid+1;
	}
	int l=in[tot].r+1,r=m,mid=(l+r)/2;
	if (l<=r) in[tot].r=mid;
	for (int i=1;i<=tot;i++) if (in[i].l<=n&&in[i].r>=n) return in[i].c;
}

int main()
{
	n=read();m=n*2-1;
	for (int i=1;i<=m;i++) a[i]=read();
	int l=1,r=m;
	while (l<=r)
	{
		int mid=(l+r)/2;
		if (check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d",l-1);
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,s;cin>>n>>s;
    ll u=1;
    while(u*u<=n)u++;
    rep(i,2,u+1){
        ll sum=0;
        ll y=n;
        while(y>0){
            sum+=y%i;
            y/=i;
        }
        if(sum==s){
            cout<<i<<endl;
            return 0;
        }
    }
    rrep(i,u-1,1){
        ll cnt=s-i;
        if(cnt<0)continue;
        ll sum=n-cnt;
        if(sum%i!=0)continue;
        sum/=i;
        if(sum>i&&sum>cnt){
            cout<<sum<<endl;
            return 0;
        }
    }
    if(s==n)cout<<n+1<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, m; cin >> n >> m;
  vector<ll> v(n, 0);
  rep(i, m) {
    ll a, b; cin >> a >> b; --a, --b;
    if (a == 0) v[b] |= 1;
    if (b == n-1) v[a] |= 2;
  }
  rep(i, n) {
    if (v[i] == 3) {
      cout << "POSSIBLE" << endl;
      return;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = map(int, readline().split())
    if k % 2 == 0:
        diff = a - b
    else:
        diff = b - a

    if abs(diff) > 10 ** 18:
        print("Unfair")
    else:
        print(diff)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61856
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);

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

  vector<string> v(100);
  rep(i, 50) v[i] = string(100, '.');
  rep(i, 50) v[i+50] = string(100, '#');

  rep(i, b-1) {
    int x = (2*i)%100;
    int y = ((2*i)/100) * 2;
    v[y][x] = '#';
  }

  rep(i, a-1) {
    int x = (2*i)%100;
    int y = 99 - ((2*i)/100) * 2;
    v[y][x] = '.';
  }

  cout << "100 100" << endl;
  rep(i, 100) cout << v[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n, result;
	int i, j, k, l;
	while(scanf("%d",&n)!=EOF){
		result=0;
		for(i=0;i<10;i++)
			for(j=0;j<10;j++)
				for(k=0;k<10;k++)
					for(l=0;l<10;l++){
						if(i+j+k+l==n)
							result++;
					}
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string Yes[2] = {"Yes", "No"};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;

mint C1[2010], C2[2010];

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

    ll n, k; cin >> n >> k;

    C1[0] = 1;
    _rep(i, 1, n - k + 2){
        C1[i] = C1[i - 1] * (n - k + 2 - i) / i;
    }
    C2[0] = 1;
    _rep(i, 1, k){
        C2[i] = C2[i - 1] * (k - i) / i;
    }
    /*rep(i, n - k + 2) cout << C1[i] << " ";
    cout << endl;
    rep(i, k) cout << C2[i] << " ";
    cout << endl;*/
    _rep(i, 1, k + 1) cout << C1[i] * C2[i - 1] << endl;
}

Measured memory_bytes: 3660
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct Graph {
    graph: Vec<Vec<usize>>,
    v: usize,
}

type Edge = (usize, usize);
impl Graph {
    pub fn new_directed(edges: &[Edge], v: usize) -> Self {
        let mut graph = vec![Vec::new(); v];
        for &(u, v) in edges {
            graph[u].push(v);
        }
        Graph { graph, v }
    }

    pub fn solve(&self, mut indegreev: Vec<usize>) -> isize {
        let mut dp = vec![0; self.v];
        let mut que = VecDeque::new();
        for u in 0..self.v {
            if indegreev[u] == 0 {
                que.push_back(u);
                dp[u] = 1;
            }
        }
        while let Some(u) = que.pop_front() {
            for &v in &self.graph[u] {
                indegreev[v] -= 1;
                if indegreev[v] == 0 {
                    que.push_back(v);
                    dp[v] = dp[u] + 1;
                }
            }
        }

        let is_ok = indegreev.into_iter().all(|x| x == 0);
        if is_ok {
            dp.into_iter().max().unwrap_or(0) as isize
        } else {
            -1
        }
    }
}

fn key(a: usize, b: usize) -> (usize, usize) {
    (a.min(b), a.max(b))
}

fn solve() {
    input! {
        n: usize,
        matchv: [[Usize1; n - 1]; n]
    };

    let vn = n * (n - 1) / 2;
    let id_table = (0..n)
        .into_iter()
        .combinations(2)
        .enumerate()
        .map(|(i, ab)| (key(ab[0], ab[1]), i))
        .collect::<HashMap<_, _>>();
    let mut indegreev = vec![0; vn];
    let mut edges = Vec::new();
    for i in 0..n {
        let a = i;
        for mv in matchv[i].windows(2) {
            let b = mv[0];
            let u = *id_table.get(&key(a, b)).unwrap();
            let c = mv[1];
            let v = *id_table.get(&key(a, c)).unwrap();
            indegreev[v] += 1;
            edges.push((u, v));
        }
    }

    let graph = Graph::new_directed(&edges, vn);
    let res = graph.solve(indegreev);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 87056
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    cin>>d;
    if(d == 25) printf("Christmas");
    if(d == 24) printf("Christmas Eve");
    if(d == 23) printf("Christmas Eve Eve");
    if(d == 22) printf("Christmas Eve Eve Eve");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int H, W;

    cin >> H >> W;
    char pixel[H][W];
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> pixel[i - 1][j - 1];
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << pixel[i - 1][j - 1];
        }
        cout << endl;
        for (int j = 1; j <= W; j++) {
            cout << pixel[i - 1][j - 1];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<ll, ll>;
template<class T> inline bool chmax(T& a, T b) {if (a < b){a = b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if (a > b){a = b;return 1;}return 0;}
const long long LLINF = 1LL << 60;
using namespace std;

int main()
{
    bool ok = true;

    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b[i];

    vector<int> ans;
    rep(i, N) {
        int select = -1, cur = 0;
        rep(j, N) {
            if (!b[j]) continue;
            if (cur+1 == b[j]) {
                select = j;
            }
            cur++;
        }

        if (select == -1) {
            ok = false;
        }
        ans.push_back(b[select]);
        b[select] = 0;
    }

    reverse(ans.begin(), ans.end());

    if (ok) {
        rep(i, N) cout << ans[i] << endl;
    }
    else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256