akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
   int n;
    cin >> n;
    int cnt = 0, y = 0;
    while (cnt < n) {
      y++;
      cnt += y;
    }
    rep(i, 0, y) {
      if (cnt - n == i + 1) continue;
      cout << i + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto dat = new int[][][](4, 3, 10);
  foreach (_; 0..n) {
    auto rd = readln.split.map!(to!int);
    auto b = rd[0] - 1, f = rd[1] - 1, r = rd[2] - 1, v = rd[3];
    dat[b][f][r] += v;
  }

  foreach (i, b; dat) {
    foreach (f; b) {
      writeln(" " ~ f.map!(to!string).join(" "));
    }
    if (i < dat.length - 1)
      writeln("####################");
  }
}

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

using namespace std;

#define INF 1e9

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

    while(1){
        int n,m,a;
        cin>>n>>m>>a;

        if(n==0)break;

        vector<pair<int,pair<int,int>>> v(m);

        for(int i=0;i<m;i++){
            cin>>v[i].first>>v[i].second.first>>v[i].second.second;
        }

        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());

        int H=v[0].first;

        for(int i=0;i<m;i++){
            if(v[i].first<=H && v[i].second.first==a){
                a=v[i].second.second;
                H--;
            }
            else if(v[i].first<=H && v[i].second.second==a){
                a=v[i].second.first;
                H--;
            }
        }

        cout<<a<<endl;

    }

}


Measured memory_bytes: 3208
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;

  if(s==u) a--;
  else b--;

  cout << a SP b << endl;

  return 0;
}

Measured memory_bytes: 256
// In the name of Allah the Lord of the Worlds.

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

typedef long long ll;
const int MAX = 5005;
int dp[MAX][MAX][3];
string ar;

int f(int i , int j , int now)
{
    if(j==ar.size()){
        return 0;
    }
    if(dp[i][j][now]!=-1)return dp[i][j][now];
    int value = 0;
    if(i==j){
        value = f(i , j+1 , now);
    }
    else if(now==1){
        if(ar[i]==ar[j]){
            value = f(i+1 , j+1 , now)+1;
        }
        else return 0;
    }
    else{
        value = max(value , f(i+1 , j , now));
        value = max(value , f(i , j+1 , now));
        if(ar[i]==ar[j]){
            int temp = j-i;
            temp = min(temp , f(i+1 , j+1 , 1)+1);
            value = max(temp , value);
        }
    }
    return dp[i][j][now] = value;
}

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

    int n;
    cin >> n >> ar;
    memset(dp , -1 , sizeof(dp));
    cout << f(0 , 0 , 0) << endl;
    return 0;
}


Measured memory_bytes: 294656
#include <bits/stdc++.h>
using namespace std;
bitset <26> zero, s[500000*4+1];
string tar;
void build (int id, int l, int r){
    if (l==r){
        s[id][tar[l]-'a']=true;
        return;
    }
    int mid=l+(r-l)/2;
    build (id*2, l, mid);
    build (id*2+1, mid+1, r);
    s[id]=(s[id*2]|s[id*2+1]);
}
void update (int id, int l, int r, int pos, char val){ // REMEMBER: update only to follow one chain
    if (l==r){ //the bottomost nodes of the segment tree
        s[id]=(s[id]&zero);
        s[id][val-'a']=true;
        return;
    }
    int mid=l+(r-l)/2;
    if (pos<=mid) update (id*2, l, mid, pos, val);
    else update (id*2+1, mid+1, r, pos, val);
    s[id]=(s[id*2]|s[id*2+1]);
}
bitset <26> query (int id, int l, int r, int L, int R){
    if (L<=l && r<=R) return s[id];
    // above is completely in range case. REMEMBER: query is dividing segment trees parts into different queries
    if (R<l || r<L) return zero;
    //above is completely out of range case. REMEMBER: return something not affecting the result
    int mid=l+(r-l)/2;
    return query (id*2, l, mid, L, R) | query (id*2+1, mid+1, r, L, R);
    //above is partially in range case.
}
int main(){
    int a, q, val, pos, ql, qr;
    char change;
    cin>>a>>tar>>q;
    build (1, 0, a-1);
    for (int t=0; t<q; t++){
        cin>>val;
        if (val==1){
            cin>>pos>>change;
            update(1, 0, a-1, pos-1, change);
        }
        else {
            cin>>ql>>qr;
            cout<<query(1, 0, a-1, ql-1, qr-1).count()<<endl;
        }
    }
}

Measured memory_bytes: 11140
import Control.Applicative
import Control.Monad

oddRow :: Int -> Int -> [String]
oddRow 0 _ = []
oddRow h w =
  if odd w
    then (concat (replicate (w `div` 2) "#.") ++ "#") : evenRow (h-1) w
  else
    concat (replicate (w `div` 2) "#.") : evenRow (h-1) w

evenRow :: Int -> Int -> [String]
evenRow 0 _ = []
evenRow h w =
  if odd w
    then (concat (replicate (w `div` 2) ".#") ++ ".") : oddRow (h-1) w
  else
    concat (replicate (w `div` 2) ".#") : oddRow (h-1) w


solver :: Int -> Int -> [String]
solver = oddRow

main :: IO()
main = do
  (h:w:_) <- map (read :: String -> Int) . words <$> getLine
  unless (h == 0 && w == 0) $ do
    mapM_ putStrLn $ solver h w
    putStrLn ""
    main

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

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	if (S.length() != T.length() - 1) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	

}






Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

signed main(){

	string s;
	cin>>s;

	lli data[s.size()];
	REP(i,0,s.size())data[i]=-1;

	lli left=0;
	lli right=0;

	lli state=0;
	lli sum=0;
	for(lli i=0;i<s.size();i++){
		if(DEBUG)cout<<"i="<<i<<" left="<<left<<" right="<<right<<" state="<<state<<" sum="<<sum<<endl;
		if(state==0){
			if(s.at(i)=='<'){
				state=1;
				left++;
			}
			else{
				state=2;
				right++;
			}
		}
		else if(state==1){
			if(s.at(i)=='<')left++;
			else{
				state=2;
				right++;
			}
		}
		else{
			if(s.at(i)=='>')right++;
			else{
				lli big = max(left,right);
				lli small = min(left,right)-1;

				sum += (big+1)*big/2;
				sum += (small+1)*small/2;
				state=1;
				left=1;
				right=0;
			}
		}
	}
	if(state!=0){
		lli big = max(left,right);
		lli small = min(left,right)-1;

		sum += (big+1)*big/2;
		sum += (small+1)*small/2;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 4740
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Measured memory_bytes: 9140
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        String s = scanner.next();

        if(a>=3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 21204
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	cout << (s[0] == '9' || s[1] == '9' ? "Yes" : "No") << endl;
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> result(H+2, vector<char>(W+2, '#'));
  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      cin >> result[i][j];
    }
  }
  for (int i = 0; i < H + 2; ++i) {
    for (int j = 0; j < W + 2; ++j) {
      cout << result[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d %d\n" @@ fun r c k ->
  let vss = Array.make_matrix c r 0 in
  for i = 0 to k - 1 do
    Scanf.scanf "%d %d %d\n" @@ fun r c v ->
      vss.(c - 1).(r - 1) <- v
  done;
  let dp =
    Array.init c @@ fun _ ->
      Array.init r @@ fun _ ->
        Array.init 4 @@ fun _ -> min_int in
  dp.(0).(0).(0) <- 0;
  dp.(0).(0).(1) <- vss.(0).(0);
  for i = 1 to c - 1 do
    for k = 0 to 3 do
      dp.(i).(0).(k) <- max dp.(i).(0).(k) dp.(i - 1).(0).(k)
    done;
    for k = 3 downto 1 do
      dp.(i).(0).(k) <- max dp.(i).(0).(k) (dp.(i).(0).(k - 1) + vss.(i).(0))
    done
  done;
  for j = 1 to r - 1 do
    for k = 0 to 3 do
      dp.(0).(j).(0) <- max dp.(0).(j).(0) dp.(0).(j - 1).(k)
    done;
    dp.(0).(j).(1) <- max dp.(0).(j).(1) (dp.(0).(j).(0) + vss.(0).(j))
  done;
  for i = 1 to c - 1 do
    for j = 1 to r - 1 do
      for k = 0 to 3 do
        dp.(i).(j).(k) <- max dp.(i).(j).(k) dp.(i - 1).(j).(k)
      done;
      for k = 0 to 3 do
        dp.(i).(j).(0) <- max dp.(i).(j).(0) dp.(i).(j - 1).(k)
      done;
      for k = 3 downto 1 do
        dp.(i).(j).(k) <- max dp.(i).(j).(k) (dp.(i).(j).(k - 1) + vss.(i).(j))
      done
    done
  done;
  Printf.printf "%d\n" @@ Array.fold_left max min_int dp.(c - 1).(r - 1)


Measured memory_bytes: 500336
import java.util.*;

class Main{

    int n, max;
    int[] S, color;
    HashSet<Integer> set;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            if(n==0) break;

            int[] x = new int[n], y = new int[n], r = new int[n];
            color = new int[n];
            for(int i=0; i<n; i++){
                x[i] = sc.nextInt(); y[i] = sc.nextInt();
                r[i] = sc.nextInt(); color[i] = sc.nextInt();
            }
            S = new int[n];
            for(int i=0; i<n; i++){
                int T = 0;
                for(int j=0; j<i; j++){
                    if(i==j) continue;
                    int dist = (x[i]-x[j]) * (x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]);
                    int hankei = (r[i]+r[j]) * (r[i]+r[j]);
                    if(dist<hankei) T = T | (1<<j);
                }
                S[i] = T;
            }

            max = 0;
            set = new HashSet<Integer>();
            rec((1<<n)-1);
            System.out.println(max);
        }
    }

    void rec(int T){
        if(!set.add(T)) return;
        else max = Math.max(max, n - Integer.bitCount(T));
        for(int i=0; i<n; i++){
            if((T&(1<<i))==0 || (S[i]&T)!=0) continue;
            for(int j=i+1; j<n; j++){
                if((T&(1<<j))==0 || (S[j]&T)!=0) continue;
                if(color[i]==color[j]){
                    int newT = T;
                    newT ^= (1<<i); newT^= (1<<j);
                    rec(newT);
                }
            }
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 201032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0)cout << 1 << endl;
    else if(b == 0)cout << 2 << endl;
    else if(c == 0)cout << 3 << endl;
    else if(d == 0)cout << 4 << endl;
    else cout << 5 << endl;
}

Measured memory_bytes: 3560
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        int cnt2=0;

        for(int i =1;i<=n;i++){
            for(int j =1;j<=i;j++){
                if(i%j==0 && j%2==1){
                    cnt++;
                }
            }
            if(cnt==8){
                cnt2++;
                //System.out.println(i);
            }
            cnt=0;
        }

            System.out.println(cnt2);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long
#define pb(x) push_back((x))
#define line() cerr << "DEBUG @" << __LINE__ << endl;
#define debug(x) \
  cerr << "DEBUG @" << __LINE__ << " -> " << #x << " = " << x << endl;
using namespace std;

const ll mod = 1e9 + 7;

ll fast_pow(ll base, ll e) {
  ll ans = 1;
  while (e > 0) {
    if (e & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    e >>= 1;
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll ans = (fast_pow(10, n) - fast_pow(9, n) + mod) % mod;
  ans = (ans - fast_pow(9, n) + mod) % mod;
  ans = (ans + fast_pow(8, n) + mod) % mod;
  cout << ans << endl;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	CIN(int, N);
	ll sum = 0;
	vector<ll> v;
	rep(i, N) {
		CIN(ll, t);
		sum += t;
		v.PB(t);
	}
	ll res = 1e18;
	ll tmp = v[0];
	reps(i, 1, N) {
		res = min(res, abs(tmp-(sum-tmp)));
		tmp += v[i];
	}
	cout << res << endl;



}


Measured memory_bytes: 2420
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a=int(input())
print(a+a**2+a**3)

Measured memory_bytes: 72688
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

int main(){
    string s;
    cin>>s;
    ll ans=0;
    int len=s.size();
    int n=1<<(len-1);
    rep(i,0,n-1){
        ll t=s[0]-'0';
        rep(j,0,len-1){
            if(j==len-1||i&(1<<j)){
                ans+=t;
                t=0;
                if(j==len-1) break;
            }
            t=t*10+s[j+1]-'0';
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int x,y;
  while(1){
    cin>>x>>y;
    if(x == 0 && y == 0)break;
    if(x < y){cout<<x<<" "<<y<<endl;}
      else{cout<<y<<" "<<x<<endl;}
  }
}


Measured memory_bytes: 3088
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		ArrayList<Integer> hoge = new ArrayList<>();
		int i;
		int n;
		int []a;
		int sum;

		while(true) {
			sum=0;
			n=sc.nextInt();
			if(n==0)
				break;
			a=new int[n];
			for(i=0;i<n;i++) {
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			for(i=1;i<n-1;i++)
				sum+=a[i];
			hoge.add(sum/(n-2));
		}
		for(i=0;i<hoge.size();i++) {
			System.out.println(hoge.get(i));
		}
	}
}


Measured memory_bytes: 29780
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn = 6 + 5;

int n, C, a[maxn];
int dp[300 + 5][(1 << 6) + 5];

inline int solve() {
	memset(dp,0,sizeof(dp));
	dp[n * a[n]][0] = 1;
	for(int i = 0;i < (n * C);i ++) {
		for(int j = i;j <= (n * C);j ++) {
      for(int sta = 0;sta < (1 << (n - 1));sta ++) {
				if((i % n != 0) && ((sta & (1 << (i % n - 1))) == 0)) {
					dp[min(n * C,max(j,i + a[i % n] * n))][sta | (1 << (i % n - 1))] += dp[j][sta];
				}
			}
		}
	}
	return dp[n * C][(1 << (n - 1)) - 1];
}

int main() {
  scanf("%d%d", &n, &C);
	for(int i = 1;i <= n;i ++) scanf("%d", &a[i]);
	sort(a + 1,a + n + 1);
	ll ans = 0, cnt = 0;
	do{
		ans += solve();
		cnt ++;
	}while(next_permutation(a + 1,a + n));
	for(int i = 1;i < n;i ++) cnt = cnt * C;
	printf("%.12lf\n", 1.0 * ans / cnt);
	return 0;
}


Measured memory_bytes: 384
while True:
    n, m, a = map(int, input().split())
    if n==0 and m==0 and a==0:
        break

    branch = [[0 for _ in range(1001)] for _ in range(n+1)]
    for i in range(m):
        h, p, q = map(int, input().split())
        branch[p][h] = q
        branch[q][h] = p

    cur = a
    for i in range(1000, 0, -1):
        if branch[cur][i]:
            cur = branch[cur][i]
    print(cur)



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

using ll = long long;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> pos(N);
    vector<pair<ll, ll>> checks(M);
    for (int i = 0; i < N; i++)
        cin >> pos[i].first >> pos[i].second;
    for (int i = 0; i < M; i++)
        cin >> checks[i].first >> checks[i].second;
    vector<int> ans(N);
    for (int i = 0; i < N; i++)
    {
        ll tmp = 1001001001LL;
        for (int j = 0; j < M; j++)
        {
            ll n = abs(pos[i].first - checks[j].first) + abs(pos[i].second - checks[j].second);
            if (n < tmp)
            {
                tmp = n;
                ans[i] = j;
            }
        }
    }

    for (int i = 0; i < N; i++)
        cout << ans[i] + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
a = list(input())

for bit in range(2**3):
    ans = a[0]
    
    for i in range(3):
        if ((bit >> i) & 1):
            ans += "+"
        else:
            ans += "-"
        ans += a[i + 1]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Measured memory_bytes: 3060
from fractions import gcd
from functools import reduce
a, b, c, d = map(int, input().split())


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(*numbers):
    return reduce(lcm, numbers)


cbai = 0
dbai = 0
cdbai = 0
if a % c == 0:
    cbai += 1
if a % d == 0:
    dbai += 1
if a % (lcm(c, d)) == 0:
    cdbai += 1
cbai += b//c-a//c
dbai += b//d-a//d
cdbai += b//(lcm(c, d))-a//(lcm(c, d))
print(b-a+1-(cbai+dbai-cdbai))


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
IP(t);
cout<<(t+1)/2;
return 0;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  char c;
  int a = 700;
  rep(i,3){
    cin >> c;
    if(c == 'o') a+=100;
  }
  cout << a << endl;
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,l; cin >> n >> l;
  vector<string> s(n); rep(i,n) cin >> s[i];

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

  string ans = "";
  rep(i,n){
    rep(j,l) ans+=s[i][j];
  }

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


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
//int a[N];
int main()
{
	int n,h;
	cin>>n>>h;
	int sum=0;
	int t;
	for (int i=0;i<n;i++)
	{
		scanf("%d",&t) ;
		if (t>=h)
			sum++;
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int r, g, b, x;
  scanf("%d %d %d", &r, &g, &b);
  x = g * 10 + b;
  if (x % 4 == 0)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();

        System.out.println(n - k + 1);

    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 21076
#include <iostream>
using namespace std;
using ll = long long;

int main() {
	int n, k, sunuke[100] = { 0 }, d, pt = 0, num;

	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> num;
			sunuke[num - 1]++;
		}
	}

	for (int i = 0; i < n; i++) {
		if (sunuke[i] == 0)
			pt++;
	}
	
	cout << pt << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<P> pa(n);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        pa[i]={a,b};
    }
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        pa[i].first+=ans;
        ans+=(pa[i].second-(pa[i].first%pa[i].second))%pa[i].second;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import math
n,m = map(int, input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = 0
b = 0
if n >=2:
    a = combinations_count(n, 2)
if m >= 2:
    b = combinations_count(m, 2)
print(a+b)

Measured memory_bytes: 38384
//#include"pch.h"
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<algorithm>

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

	if (X == 3 || X == 5 || X == 7) puts("YES");
	else puts("NO");


	return(0);
}

Measured memory_bytes: 128
'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(x=>x*1);
  let ans = new Array(3);
  ans[0] = inp[2];
  ans[1] = inp[0];
  ans[2] = inp[1];

  console.log(`${ans[0]} ${ans[1]} ${ans[2]}`);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMinimum(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMaximum(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {



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

    cout << c << " " << a << " " << b;
}

Measured memory_bytes: 384
#include <cstdint>
#include <vector>
#include <iostream>
#include <algorithm>
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; cin >> N;
	vector<ll> P(N), q(N);
	rep(n, N) { cin >> P[n]; }
	rep(n, N) { cin >> q[n]; }
	long long sa{0};
	if (P > q) swap(P, q);
	do {
		if (P == q) break;
		++sa;
	} while (next_permutation(begin(P), end(P)));
	p(sa);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string X;
    cin >> X;
    int ans = 0, tmp = 0;
    REP(i, X.size()){
        if(X[i] == 'T'){
            tmp++;
        }else{
            tmp--;
        }
        ans = max(ans, tmp);
    }
    printf("%d\n", ans * 2);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;


int main() {
	int n, k, num = 0;
	string s;
	cin >> n >> k;
	cin >> s;
	char hoge = 'a';
	for (int i = 0; i < n; i++) {
		if (hoge != s[i]) {
			num++;
			hoge = s[i];
		}
	}
	for (int i = 0; i < k; i++) {
		if (num > 3) {
			num -= 2;
		}
		else if (num == 3) {
			num = 1;
		}
		else {
			num = 1;
			break;
		}
	}
	cout << max(n - num,0) << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int num, ss;
  ss = 0;
  num = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(a == 1) num++;
    else num = 0;
    if(ss < num) ss = num;
  }
  cout << ss + 1 << endl;
}



Measured memory_bytes: 3100
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
	int l[11];
	int v1,v2,i,n;
	double tmp,tmp2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&l[10],&v1,&v2) != EOF)
	{
		n=0;
		for(i=1;i<=10;i++)
		{
			n += l[i];
		}
		tmp = (double)n/(v1+v2);
		tmp2 = (double)v1*tmp;
		n = 0;
		for(i=1;i<=10;i++)
		{
			n += l[i];
			if(n>=tmp2)
			{
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
int main() {
	char str[5]={};
	scanf("%s", str);
	if(((str[0]==str[1])&&(str[2]==str[3])&&(str[0]!=str[3]))
	 ||((str[0]==str[2])&&(str[1]==str[3])&&(str[0]!=str[1]))
	 ||((str[0]==str[3])&&(str[1]==str[2])&&(str[0]!=str[1])))
	 	printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
#define int int_fast32_t
	io_optimized
	int a[3];
	while(cin>>a[0]>>a[1]>>a[2])
	{
		sort(a,a+3);
		cout<<(((a[0]==a[1]&&a[1]!=a[2])||(a[1]==a[2]&&a[0]!=a[1]))?"Yes\n":"No\n");
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main{
	private static int n;
	
	static class Point{
		int score;
		int place;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		
		List<Point> list = new ArrayList<Point>();
	    for(int i=0;i<n;i++){
	    		int ai = in.nextInt();
	    		int bi = in.nextInt();
	    		
	    		Point t = new Point();
	    		t.score = bi;
	    		t.place = ai;
	    		
	    		list.add(t);
	    		
	    }
	    
	   Collections.sort(list,new Comparator<Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return o1.place  -  o2.place;
		}
	   });
		
	boolean flag = false;
	   for(int i=1;i<n;i++){
		   int diffPlace = list.get(i).place  - list.get(i-1).place;
		   int score = list.get(i-1).score - list.get(i).score;
		   
		   if( score < diffPlace){
			   flag = true;
		   }
	   }
	
	   if(flag){
		   System.out.println(0);
		   return;
	   }
	   
	   System.out.println(list.get(list.size()-1).place+list.get(list.size()-1).score);
	}
	
}


Measured memory_bytes: 95484
#include<stdio.h>
#include<stdlib.h>

typedef struct{
  int u;
  int k;
}DATA;

int main(){
  int i, j, n, graph[100][100], next;
  DATA a[100];

  scanf("%d", &n);
  if(n >= 1 && n <= 100){
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
	graph[i][j] = 0;
    
    for(i = 0; i < n; i++){
      scanf("%d %d", &a[i].u, &a[i].k);

      for(j = 0; j < a[i].k; j++){
	scanf("%d", &next);
	graph[i][next-1] = 1;
      }
    }

    for(i = 0; i < n; i++){
      for(j = 0; j < n-1; j++){
	printf("%d ", graph[i][j]);
      }
      printf("%d\n", graph[i][j]);
    }
    
  }
  return 0;
}



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


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

Node T[MAX];
int n, D[MAX], H[MAX];

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

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

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

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].left);
  preParse(T[u].right);
}

void inOrder(int u) {
  if (u == NIL) return;
  inOrder(T[u].left);
  printf(" %d", u);
  inOrder(T[u].right);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d", u);
}

int main () {
  int v, l, r, root = 0;
  scanf("%d", &n);

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

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

    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = v;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }

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

  cout << "Preorder" << endl;
  preParse(root); printf("\n");
  cout << "Inorder" << endl;
  inOrder(root); printf("\n");
  cout << "Postorder" << endl;
  postParse(root); printf("\n");

  return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main(void){
    int H,W;
    for(int i = 0;;i++){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int j = 0; j<H;j++){
            for(int k = 0; k<W;k++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3092
N=int(input())
L=sorted(list(map(int,input().split())))

c=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]==L[j]:
            continue
        for k in range(j+1,N):
            if L[j]==L[k]:
                continue
            if L[i]+L[j]>L[k]:
                c+=1
            else:
                break
print(c)


Measured memory_bytes: 9200
s = input()
t = input()
l = len(s)

for i in range(l):
  L = s[:(l-i)]
  R = s[(l-i):]
  ns = R + L
  if (ns == t):
    print("Yes")
    break
  else:
    if (i == (l-1)):
      print("No")
    else:
        continue
  
  

Measured memory_bytes: 2940
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e18;
const int mod = 1e9 + 7;

signed main() {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    int ans = 0;
    if (N <= K) {
        for (int i = 0; i < N; i++) {
            if (T[i] == 'r') ans += P;
            else if (T[i] == 's') ans += R;
            else ans += S;
        }
        cout << ans << endl;
        return 0;
    }
    for (int i = 0; i < K; i++) {
        int TP = 0, TR = 0, TS = 0;
        int count = 0;
        for (int j = 0; K * j + i < N; j++) {
            if (count != 0) {
                if (T[K * j + i] == T[K * j + i - K]) {
                    if (count % 2 == 1) {
                        ++count;
                        continue;
                    }
                } else {
                    count = 0;
                }
            }
            if (T[K * j + i] == 'r') ans += P;
            else if (T[K * j + i] == 's') ans += R;
            else ans += S;
            ++count;
        }
    }
    cout << ans << endl;
}


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

int main(){
while(1){
	int n,c,a[100000+2],b[100000+2],k=0,ans=0;
	scanf("%d",&n);
	if(n==0)break;
	scanf("%d",&a[0]);
	b[0]=1;
	for(int i=2;i<=n;i++){
		scanf("%d",&c);
		if(i%2!=0){
			if(c==a[k])b[k]++;
			else {a[k+1]=c; b[k+1]=1; k++;}
		}
		else {
			if(c==a[k])b[k]++;
			else {
				if(k==0){a[0]=c; b[0]+=1;}
				else {b[k-1]+=b[k]+1; k--;}
			}
		}
	}
	for(int i=0;i<=k;i++){
		if(a[i]==0)ans+=b[i];
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1200
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
a.sort()
d=defaultdict(int)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

for i in make_divisors(a[0]):
    d[i]+=1
for g in make_divisors(a[1]):
    d[g]+=1

for g in range(2,n):
    for i,m in d.items():
        if a[g]%i==0:
            d[i]+=1

ans=1
for i,m in d.items():
    if m==n-1 or m==n:
        ans=max(ans,i)
print(ans)

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

int main() {
  int N, ans = 0;
  string s;
  cin >> s;  
  N = s.size();
  
  for (int i = 0; i < N/2; i++) {
    if (s[i] != s[N-i-1]) ans += 1;
  }
  
  cout << ans << endl;;
}

Measured memory_bytes: 3612
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    for i in range(a):
        for j in range(b):
            if (i+j)%2==0:
                print("#",end='')
            else:
                print(".",end='')
        print()
    print()
    



Measured memory_bytes: 7000
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

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

Measured memory_bytes: 256
//   :(
#include<bits/stdc++.h>
#define read(i) scanf("%d", &i)
#define mem(a, b) memset(a, b, sizeof(a))
#define MX 100005
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
     int i, j, k;
     int n1, n2;
     cin >> n1 >> n2;
     if((n1>=0 && n2<=0) || (n1<=0 && n2>=0)) puts("Zero");
     else if(n1<0 && !(abs(n1-n2)%2)) puts("Negative");
     else puts("Positive");
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,coin[6] = {500,100,50,10,5,1};
    
    while(cin>>N,N!=0){
        N = 1000 - N;
        int ans = 0;
        for(int i=0;i<6&&N!=0;){
            if(coin[i] <= N){
                N -= coin[i];
                ++ans;
            }
            else ++i;
        }
        put(ans);
    }
}


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

int main(){
	int h, w;
	cin >> h >> w;
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++){
		string s;
		cin >> s;
		if(s == "snuke") cout << char('A' + j) << i + 1 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,m;
  cin >> n >> m;
  if(n==2 || m==2){
    cout << 0 << endl;
  }
  else if(n==1 && m==1){
    cout << 1 << endl;
  }
  else if(n==1){
    cout << max((ll)0,m-2) << endl;
  }
  else if(m==1){
    cout << max((ll)0,n-2) << endl;
  }
  else{
    cout << (m-2)*(n-2) << endl;
  }
}

Measured memory_bytes: 3640