akhauriyash/Code-Regression huggingface dataset:
#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() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n){
        if(ans < k){
            ans *= 2;
        }else{
            ans += k;
        }
    }
    cout << ans << endl;
}

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

const double pi = 3.141592654;
 const int maxn = 1e6+5;
 int main(){
     long double a, b, x; cin >> a >> b >> x;
     long double c = a*a*b;
     if(x*2 >= c) {
        long double d = (c*2-x*2)/a/a;
        long double e = atan(d/a);
        e = e*180/pi;
        cout << fixed << setprecision(7) << e << endl;
     }
     else {
        long double d = x*2/a/b;
        long double e = atan(b/d);
        e = e*180/pi;
        cout << fixed << setprecision(7) << e << endl;
     }
 }


Measured memory_bytes: 256
def modpow(a, x, mod):
    if x == 0:
        return 1
    elif x % 2 == 0:
        return modpow((a * a) % mod, x // 2, mod)
    else:
        return (modpow((a * a) % mod, x // 2, mod) * a) % mod


N, M, K = map(int, input().split(' '))
max_K = 3 * 10 ** 5
mod = 998244353

inv = [0 for i in range(max_K + 1)]
inv[0] = 1
inv[1] = 1
for i in range(2, K + 1):
    inv[i] = modpow(i, mod - 2, mod)
choose = [0 for i in range(K + 1)]
choose[0] = 1
for i in range(1, K + 1):
    choose[i] = choose[i - 1] * (((N - i) * inv[i]) % mod)
    choose[i] %= mod

ans = 0
for i in range(N - 1 - K, N):
    ans += modpow((M - 1), i, mod) * choose[N - i - 1]
    ans %= mod
print((ans * M) % mod)

Measured memory_bytes: 89988
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define vout(i,n,v) for(int i=0;i<(int)n-1;i++){cout<<v[i]<<" ";}cout<<v[n-1]<<"\n";
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define VSORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve_old(long long N, std::vector<long long> a){
    RSORT(a);
    ll ans=0, Alice=0, Bob=0;
    for (ll i = 0; i < N; i++) {
        // i%2 ? Bob+=a[i] : Alice+=a[i];
        !(i%2) ? Alice+=a[i] : Bob+=a[i];
    }
    cout << Alice - Bob << "\n";
}

void solve_old2(long long N, std::vector<long long> a){
    RSORT(a);
    ll ret=0;
    rep(i,N) !(i%2) ? ret+=a[i] : ret-=a[i];
    cout << ret << "\n";
}

void solve(long long N, std::vector<long long> a){
    RSORT(a);
    REP(i,1,N) !(i%2) ? a[0]+=a[i] : a[0]-=a[i];
    cout << a[0] << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


string o,e;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>o>>e;

    int sz = max(o.size(),e.size()) * 2;

    o += "#####";
    e += "#####";

    string ans="";
    REP(i,sz){
        char s;
        if(i%2==0) 
            s = o[i/2];
        else
            s = e[i/2];

        if(s>='a' && s<='z') ans += s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  ll retval = 1, T;
  rep(i,N){
    cin >> T;
    retval = (retval/__gcd(retval, T))*T;
  }
  cout << retval << endl;




  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3620
H , W = input().split()
W = int(W)
H = int(H)
ans = int(0)

#Wが偶数なら(W//2)*H
#W.Hが奇数なら((W+1)//2)*((H+1)//2) + ((W - 1)//2*(H - 1)//2)
#Wが奇数Hが偶数(W+1)//2*(H//2) + ((W - 1)//2)*(H//2)

if(W == 1 or H == 1):
    ans = 1
elif(W%2 == 0):
    ans = (W//2)*H
elif(W%2 == 1 and H%2==1):
    ans = (((W+1)//2)*((H+1)//2)) + (((W - 1)//2)*((H - 1)//2))
elif(W%2 == 1 and H%2 ==0):
    ans = (((W+1)//2)*(H//2)) + (((W - 1)//2)*(H//2))
print(ans)

Measured memory_bytes: 3064
#include<iostream>


typedef unsigned long long ULL;
using namespace std;


int main(){
    ULL A,B,C;
    ULL ans;
    
    cin >> A >> B >> C;
    
    if( B >= C){
        ans = B + C;
    }else{
        ans = B * 2;
        C -= B;
        if( C <= A ){
            ans += C;
        }else{
            ans += A;
            C -= A;
            if( C > 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    
}


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

namespace AtCoderBeginnerContest100
{
    class QB
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long D = long.Parse(s[0]);
            long N = long.Parse(s[1]);
            long a = (long)Math.Pow(100, D) * N;
            if (D == 0 && N == 100) Console.WriteLine("101");//?
            else if (D == 1 && N == 100) Console.WriteLine("10100");//?
            else if (D == 2 && N == 100) Console.WriteLine("1010000");//?
            else Console.WriteLine(a);
        }
    }
}


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

int main(){
  int a[12],str1,str2,str3;
  for(int i=0;i<12;i++){
    scanf("%d",&a[i]);
  }
  sort(a,a+12);
  str1 = a[0]-a[1] + a[2]-a[3];
  str2 = a[4]-a[5] + a[6]-a[7];
  str3 = a[8]-a[9] + a[10]-a[11];
  if(str1 == 0 && str2 == 0 && str3 == 0){
    printf("yes\n");
  } else{
    printf("no\n");
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#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 SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int ans = 0;
  bool all_even = true;
  while(all_even){
  REP(i, n){
    if (a[i] % 2 != 0){
      all_even = false;
      break;
    }
    a[i] = a[i]/2;
  }
  if (all_even) ans++;
  }
  cout << ans << endl;
  return 0;
}



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

int main()
{
	int N,M,C,i,j;
	cin >>N>>M>>C;
	int B[M],A[N][M],ans=0,temp;
	for(i=0;i<M;i++){
		cin >>B[i];
	}
	for(i=0;i<N;i++){
		temp=0;
		for(j=0;j<M;j++){
			cin>>A[i][j];
			temp+=A[i][j]*B[j];
		}
		temp+=C;
		if(temp>0){
			ans++;
		}
	}
	cout << ans;
	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++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int H, W;
bool solve(vector<int> A) {
  int g = 0, k = 0;
  if (W % 2 == 1) k += H / 2;
  if (H % 2 == 1) k += W / 2;
  if (W % 2 == 1 && H % 2 == 1) {
    g = 1;
  }
  int l = (H * W - 2 * k - g) / 4;
  for (int c = 0; l--;) {
    while (c < 26 && A[c] < 4) ++c;
    if (c == 26) return 0;
    A[c] -= 4;
  }
  for (int c = 0; k--;) {
    while (c < 26 && A[c] < 2) ++c;
    if (c == 26) return 0;
    A[c] -= 2;
  }
  return 1;
}
int main() {
  cin >> H >> W;
  vector<int> A(50);
  REP(i, H) REP(j, W) {
    char c;
    cin >> c;
    A[c - 'a']++;
  }
  printf("%s\n", solve(A) ? "Yes" : "No");
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    vector<bool> visited(n, false);
    int cur = 0;
    while(!visited[cur]){
        visited[cur] = true;
        if(cur == 1) break;
        if(visited[a[cur]]){
            ans = -1;
            break;
        }
        ans++;
        cur = a[cur];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e12;

set<ll> st;

ll N,cur,sum;

void brute()
{
	cur=1;
	for(int A=1;A<N;A++)
	{
		while(cur%2 and cur%3)
			++cur;
		sum+=cur;
		cout<<cur++<<" ";
	}
	while((sum+cur)%6>0 or __gcd(cur,sum)==1)
		++cur;
	cout<<cur;
	exit(0);
	return ;
}

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N;
	if(N<=20)
		brute();
	cur=1;
	for(int A=1;A<=N;A++)
	{
		while(cur%2 and cur%3)
			++cur;
		sum+=cur;
		st.insert(cur++);
	}
	if(sum%6==1)
	{
		st.erase(2);
		st.erase(3);
		while(cur%6)
			++cur;
		st.insert(cur++);
		while(cur%6)
			++cur;
		st.insert(cur);
	}
	else if(sum%6==2)
	{
		st.erase(2);
		while(cur%6)
			++cur;
		st.insert(cur);
	}
	else if(sum%6==3)
	{
		st.erase(3);
		while(cur%6)
			++cur;
		st.insert(cur);
	}
	else if(sum%6==4)
	{
		st.erase(4);
		while(cur%6)
			++cur;
		st.insert(cur);
	}
	else if(sum%6==5)
	{
		st.erase(9);
		while(cur%6!=4)
			++cur;
		st.insert(cur);
	}
	for(auto A:st)
		cout<<A<<" ";
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <sstream>
using namespace std;

int main() {
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    string s;
    cin >> s;
    int a[8];
    for(int j=0; j<8; j++) {
      a[j]=(int)s[j];
    }

    string t;
    s="";
    t="";
    sort(a, a+8);
    for(int j=0; j<8; j++) {
      s+=a[j];
      t+=a[7-j];
    }
    int min, max;
    stringstream ss, st;
    ss << s;
    ss >> min;
    st << t;
    st >> max;
    cout << max-min << endl;
  }
  return 0;
}


Measured memory_bytes: 1244
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.util.Queue;
import java.util.stream.Stream;

/**
 *
 * @author Pradyumn Agrawal coderbond007
 */

public class Main{
    public static InputStream inputStream = System.in;
    public static StringTokenizer tok = null;
    public static BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32768);
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws java.lang.Exception{
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new Main().run();
                    out.close();
                } catch(IOException e){

                }
            }
        }, "1", 1 << 26).start();
    }
    public void run() throws IOException
    {
        int n = ni();
        long x = n * 800;
        long y = (n / 15) * 200;
        out.println(x - y);
    }
    public static int ni() throws IOException {
        return Integer.parseInt(ns());
    }
    public static long nl() throws IOException {
        return Long.parseLong(ns());
    }
    public static double nd() throws IOException {
        return Double.parseDouble(ns());
    }
    public static char nc() throws IOException {
        return ns().charAt(0);
    }
    public static BigInteger nextBigInteger() throws IOException {
        return new BigInteger(ns());
    }
    public static String ns() throws IOException {
        while(tok == null || !tok.hasMoreElements()){
            try {
                tok = new StringTokenizer(br.readLine());
            } catch (IOException e){
                throw new RuntimeException(e);
            }
        }
        return tok.nextToken();
    }
    public static int[] na(int n) throws IOException {
        int[] a = new int[n];
        for(int i = 0;i < n; i++){
            a[i] = ni();
        }
        return a;
    }
    public static long[] nal(int n) throws IOException {
        long[] a = new long[n];
        for(int i = 0;i < n; i++){
            a[i] = nl();
        }
        return a;
    }
    public static char[] ns(int n) throws IOException {
        char[] s = new char[n];
        for(int i = 0;i < n; i++){
            s[i] = nc();
        }
        return s;
    }
    public static char[][] nm(int n, int m) throws IOException{
        char[][] map = new char[n][];
        for(int i = 0;i < n; i++){
            map[i] = ns(m);
        }
        return map;
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll N,K,M=LongINF;
    cin>>N>>K;
    cout<<min(N%K,abs(N%K-K))<<endl;
    return 0;
}

//a=97,z=122

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    for (int i = n - 1; i >= 0; i--)
    {
        cout << a.at(i);
        if (i != 0)
        {
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int Maxn=110000;
int n,h[Maxn],f[Maxn];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	f[1]=0,f[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++) f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	printf("%d",f[n]);
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rg register
#define maxn 1200000
#define inf 0x7f7f7f7f
#define mod (ll)(1e9+7)
#pragma GCC optimize(3)
#pragma -fcrossjumping
#pragma -fdefer-pop
#pragma -fmerge-constans
#pragma -fthread-jumps
#pragma -floop-optimize
#pragma -fif-conversion
#pragma -fif-conversion2
#pragma -fdelayed-branch
#pragma -fguess-branch-probability
#pragma -fcprop-registers
#pragma -fforce-mem
#pragma -foptimize-sibling-calls
#pragma -fstrength-reduce
#pragma -fgcse
#pragma -fcse-follow-jumps
#pragma -frerun-cse-after-loop
#pragma -fdelete-null-pointer-checks
#pragma -fextensive-optimizations
#pragma -fregmove
#pragma -fschedule-insns
#pragma -fsched-interblock
#pragma -fcaller-saves
#pragma -fpeephole2
#pragma -freorder-blocks
#pragma -fstrict-aliasing
#pragma -funit-at-a-time
#pragma -falign-functions
#pragma -fcrossjumping
#pragma -finline-functions
#pragma -fweb
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline ll print(ll x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>=10)
    {
        print(x/10);
    }
    putchar(x%10+'0');
}
int n,k;
struct node
{
	int id;
	int val;
}a[maxn];
int cmp(node a,node b)
{
	return a.val<b.val;
}
int main()
{
	n=read();
	for(rg int i=1;i<=n;++i) a[i].val=read(),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(rg int i=1;i<=n;++i) 
	{
		cout<<a[i].id<<" ";
	}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long int
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define pb push_back
using namespace std;
long double arr[3000][3000];
int main() {
	IOS;
	int n;
	long double x,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i==1){
			arr[i][0]=1-x;
			arr[i][1]=x;
		}
		else 
		for(int j=0;j<=i;j++){
			if(j==0){
				arr[i][j]=(1-x)*arr[i-1][j];
			}else {
				arr[i][j]=(1-x)*arr[i-1][j]+x*arr[i-1][j-1];
			}
		}
	}
	for(int i=(n+1)/2;i<=n;i++){
		ans+=arr[n][i];
	}
	
	printf("%0.10Lf",ans);
	
	
}


Measured memory_bytes: 139008
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
#include<sstream>
using namespace std;
bool latte(int n){
    stringstream ss;
    ss<<n;
    string str;
    ss>>str;
    string rev=str;
    reverse(rev.begin(),rev.end());
    return str==rev;
}
 int intAbs(int a){
    if(a<0)a*=-1;
    return a;
}
int main(){
    int n;
    cin>>n;
    int Min=10000000,MinNum;
    for(int i=0;i<10001;i++){
        if(!latte(i))continue;
        if(intAbs(n-i)<Min){
            Min=intAbs(n-i);
            MinNum=i;
        }
    }
    cout<<MinNum<<endl;
    return 0;
}

Measured memory_bytes: 1228
#113 b-palce
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
mini=10**6
ans=0
for i in range(len(h)):
    kion=t-0.006*h[i]
    sa=abs(a-kion)
    if sa<mini:
        mini=sa
        ans=i+1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  string s;
  string left = "qwertasdfgzxcvb";

  while(cin>>s,s!="#"){
    int now = -1; //0:left 1:right
    int cnt = 0;

    rep(i,s.length()){
      int next = (left.find(s[i]) == string::npos);
      if(now != -1 && now != next){
        cnt++;
      }
      now = next;
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 0
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;

int n;
string s, t;
int solve() {
	rep(i, n) {
		if (s.substr(i) == t.substr(0, n - i)) {
			return i + n;
		}
	}
	return n * 2;
}


int main() {
	
	cin >> n >> s >> t;
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            string x = cin.next();
            int n = int.Parse(x[x.Length - 1] + "");

            if (n == 3)
            {
                Console.WriteLine("bon");
            }
            else if (n == 0 || n == 1 || n == 6 || n == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 27772
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n ;
	string a,b;
	cin >> a >> b;
	for(int i = 0; i < n; i++) {
		cout << a[i] << b[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,count,i;string bin = "";
  cin >> n;i = -1;
  do{
    i += 1;
    count = ((i%2==0) ? 1:-1);
    if (n%2==1 || n%2==-1){
      bin = "1"+bin;
      n -= count;
    } else {
      bin = "0"+bin;
    }
    n /= 2;
  } while (n != 0);
  cout << bin << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

const int MAX_V = 200010;

int par[MAX_V];
int rank_[MAX_V];

void init(int n) {

    for (int i = 0; i < n; ++i) {
        par[i] = i;
        rank_[i] = 0;
    }
}

int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]); //経路圧縮
}

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

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }
}

struct edge {
    ll u, v, cost;
};

vector<edge> E;

bool comp(edge &e1, edge &e2) {
    return e1.cost < e2.cost;
}

ll kruskal(int n) {
    sort(E.begin(), E.end(), comp);
    init(n);
    ll res = 0;
    for (auto e : E) {
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

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

    int n;
    cin >> n;
    pair<pll, int> p[100010];

    rep(i, n) {
        cin >> p[i].first.first >> p[i].first.second;
        p[i].second = i;
    }

    sort(p, p + n);

    rep(i, n - 1) {
        ll cost = abs(p[i].first.first - p[i + 1].first.first);
        E.push_back({p[i].second, p[i + 1].second, cost});
    }

    rep(i, n) swap(p[i].first.first, p[i].first.second);
    sort(p, p + n);

    rep(i, n - 1) {
        ll cost = abs(p[i].first.first - p[i + 1].first.first);
        E.push_back({p[i].second, p[i + 1].second, cost});
    }

    cout << kruskal(n) << endl;
    return 0;
}


Measured memory_bytes: 10864
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L;
	cin >> N >> L;
	string S[N];
	for(int i = 0; i < N; i++) {
		cin >> S[i];
	}
	asort(S, N);
	for(int i = 0; i < N; i++) cout << S[i];
	cout << endl;
}


Measured memory_bytes: 256
a = []
a = gets.split.map(&:to_i)
c = []
while s = gets
  c.push(s.split.map(&:to_i))
end
cnt = Array.new(10**5+1, 0)
for i in 0..a[0]-1
  cnt[c[i][0]] += c[i][1]
end
#p cnt[1]
total = 0
for j in 1..10**5
  total += cnt[j]
  if total >= a[1]
    puts j
    exit
  end
end
  

Measured memory_bytes: 10364
// ABC 110 C

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int gcd(int u, int v)
{
  return (v != 0) ? gcd(v, u % v) : u;
}

int getDigit(ll num) {
  int ans = 0;
  while (num != 0) {
    num /= 10;
    ans++;
  }
  return ans;
}

int main(int argc, char** argv) {
  ll N;
  cin >> N;

  ll a, b;

  for (ll i = ll(sqrt(N)); i > 0; i--) {
    if (N % i == 0) {
      a = i;
      b = N / a;
      break;
    }
  }

  cout << max(getDigit(a), getDigit(b)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b, c;
    cin >> n >>  a >> b >> c;
    vector<int> L(n);
    for (int i = 0; i < n; ++i) {
        cin >> L[i];
    }

    int N = 1 << n;
    vector<int> sums(N, 0);
    vector<int> cnts(N, 0);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                sums[i] += L[j];
                cnts[i] += 1;
            }
        }
    }

    vector<int> A{a, b, c};
    const int INF = 1 << 28;
    vector<vector<int>> dp(N, vector<int>(4, INF));
    dp[0][0] = 0;

    for (int j = 0; j < 3; ++j) {
        for (int i = 0; i < N; ++i) {
            if (dp[i][j] >= INF) {
                continue;
            }
            int s = i ^ (N - 1);
            for (int k = s; k > 0; --k) {
                k &= s;
                if (k == 0) {
                    break;
                }
                int cost = (cnts[k] - 1) * 10;
                cost += abs(sums[k] - A[j]);
                int ni = i | k;
                assert((i & k) == 0);
                int nj = j + 1;
                // cout << cost << " " << cnts[k] << " " << A[j] << " " << k << " " << i << " " << s <<   endl;
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + cost);
            }
        }
        // int mn = INF;
        // for (int i = 0; i < N; ++i) {
        //     mn = min(mn, dp[i][j + 1]);
        // }
        // cout << j << " " << mn << endl;
    }

    int res = INF;
    for (int i = 0; i < N; ++i) {
        res = min(res, dp[i][3]);
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			int D = sc.nextInt();
			if (N == 0) break;
			int sm = 0;
			Country[] cs = new Country[N];
			int mp = 0;
			int mc = 1;
			for (int i = 0; i < N; ++i) {
				cs[i] = new Country();
				sm += cs[i].m.length;
				if (cs[i].p > mp) {
					mp = cs[i].p;
					mc = 1;
				} else if (cs[i].p == mp) {
					++mc;
				}
			}
			boolean ok = true;
			for (int i = 0; i < sm; ++i) {
				int ci = -1;
				for (int j = 0; j < N && ci == -1; ++j) {
					Country c = cs[j];
					if (c.pos == -1) continue;
					if (c.p == mp && mc == 1) {
						int nmp = 0;
						for (int k = 0; k < N; ++k) {
							if (k == j) continue;
							nmp = Math.max(nmp, cs[k].p);
						}
						if (c.p - c.m[c.pos] >= nmp - D) {
							ci = j;
						}
					} else {
						if (c.p - c.m[c.pos] >= mp - D) {
							ci = j;
						}
					}
				}
				if (ci == -1) {
					ok = false;
					break;
				}
				cs[ci].p -= cs[ci].m[cs[ci].pos];
				cs[ci].pos--;
				mp = 0;
				mc = 0;
				for (int j = 0; j < N; ++j) {
					if (cs[j].p > mp) {
						mp = cs[j].p;
						mc = 1;
					} else if (cs[j].p == mp) {
						++mc;
					}
				}
			}
			System.out.println(ok ? "Yes" : "No");
		}
	}

	static class Country {
		int[] m;
		int p, pos;

		Country() {
			int s = sc.nextInt();
			m = new int[s];
			for (int i = 0; i < s; ++i) {
				m[i] = sc.nextInt();
				p += m[i];
			}
			pos = m.length - 1;
		}
	}

}

Measured memory_bytes: 63036
use proconio::input;

fn main() {
    input!{
        n: i64,
        x: i64,
        mut a: [i64; n],
    }

    let mut x = x;
    let mut ans = 0;

    a.sort();

    for i in 0..n {
        x -= a[i as usize];
        ans += 1;

        if x <= 0 {
            break;
        }
    }

    if x != 0 {
        ans -= 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    TSTART();
    ll sum = 0ll;
    vector<ll> a(n+1);
    a[0] = 0;
    FOR(i,1,n+1){
      ll newa;
      cin >> newa;
      sum += newa;
      a[i] = sum;
    }
    DUMP(a);
    sort(ALL(a));
    DUMP(a);
    ll ans = 0ll;
    ll cnt = 1ll;
    ll prev = a[0];
    FOR(i,1,n+1){
      if(a[i] == prev){
	ans += cnt;
	cnt++;
      }
      else{
	prev = a[i];
	cnt = 1ll;
      }
    }

    cout << ans << endl;
    TSTOP();
  }
  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int A[100000], B[100000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, M, K, a=0x7fffffff, b=0x7fffffff, ans;
	cin>>N>>M>>K;
	for(int i=0;i<N;i++) {
		cin>>A[i];
		a=min(a,A[i]);
	}
	for(int i=0;i<M;i++) {
		cin>>B[i];
		b=min(b,B[i]);
	}
	ans=a+b;
	while(K--) {
		int x, y, v;
		cin>>x>>y>>v;
		ans=min(ans,A[--x]+B[--y]-v);
	}
	cout<<ans<<'\n';
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n, t;
    cin >> n >> t;

    ll ans = t;
    int tmp = 0;
    rep(i, n){
        int x;
        cin >> x;

        ans += min(t, x-tmp);

        tmp = x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair < int , int >
#define vi vector < int >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define vll vector < long long int >
#define sll set < long long int >
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9+7;

int main()
{
	//fastIO;
	ll h,w;
    cin>>h>>w;
    char A[h][w];
    int i,j;
    fo(i,h)
    {
        fo(j,w)
        {
            cin>>A[i][j];
        }
    }
    bool row[h],column[w];
    int count = 0;
    int newh = h, neww=w;
    fo(i,h)
    {   
        row[i]=0;
        count=0;
        fo(j,w)
        {
            if(A[i][j]=='.') count++;
        }
        if(count==w) {row[i]=1;newh--;}
    }
    fo(j,w)
    {   
        column[j]=0;
        count=0;
        fo(i,h)
        {
            if(A[i][j]=='.') count++;
        }
        if(count==h) {column[j]=1;neww--;}
    }
    char ans[newh][neww];
    bool nop = 0;
    fo(i,h)
    {   
        nop=0;
        fo(j,w)
        {
            if(column[j]!=1 and row[i]!=1) {cout<<A[i][j];}
        }
        if(row[i]!=1) cout<<'\n';
    }
    //cout<<endl;   
}

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

const int MOD = 1000000007;

int main() {
    ll n, k;
    cin >>n >>k;
    vector<vector<ll>> DP(n+1, vector<ll> (k+1, 0));
    DP.at(0).at(0)=1;
    for (ll i=1; i<=n; i++)
        for (ll j=1; j<=k; j++) {
            DP.at(i).at(j) = DP.at(i-1).at(j-1);
                // Full j-1 box w/i-1 balls, add box j w/ ball i
            DP.at(i).at(j) += DP.at(i-1).at(j)*j%MOD;
                // Full j box w/i-1 balls, add ball i
            DP.at(i).at(j) %=MOD;
        }
    cout <<DP.at(n).at(k) <<endl;
    return 0;
}



Measured memory_bytes: 10756
nil = -1

class Node:
    def __init__(self):
        self.parent = nil
        self.left = nil
        self.right = nil

def pre_tw(node):
    print(' ' + str(node), end = '')

    if tree[node].left != nil:
        pre_tw(tree[node].left)

    if tree[node].right != nil:
        pre_tw(tree[node].right)

def in_tw(node):
    if tree[node].left != nil:
        in_tw(tree[node].left)

    print(' ' + str(node), end = '')

    if tree[node].right != nil:
        in_tw(tree[node].right)

def post_tw(node):
    if tree[node].left != nil:
        post_tw(tree[node].left)

    if tree[node].right != nil:
        post_tw(tree[node].right)

    print(' ' + str(node), end = '')


n = int(input())

tree = [Node() for i in range(n)]

for i in range(n):
    line = [int(j) for j in input().split()]
    id_t = line[0]
    left = line[1]
    right = line[2]

    if left != nil:
        tree[id_t].left = left
        tree[left].parent = id_t
    if right != nil:
        tree[id_t].right = right
        tree[right].parent = id_t

for i in range(n):
    if tree[i].parent == nil:
        root = i
        break

print('Preorder')
pre_tw(root)
print('')

print('Inorder')
in_tw(root)
print('')

print('Postorder')
post_tw(root)
print('')

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif

int main(void)
{
	ll m, d; cin >> m >> d;

	ll ans = 0;
	rep(i, 1, m+1)
	{
		rep(j, 1, d+1)
		{
			if (!(j % 10 >= 2))
				continue;
			if (!((j / 10) >= 2))
				continue;
			if ((j / 10) * (j % 10) == i)
				ans++;
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def main():
    s = int(input())
    memo = set([s])
    cnt = 1
    while True:
        cnt += 1
        s = f(s)
        if s in memo:
            break
        memo.add(s)
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<stdio.h>

int main(){
	int i,S=0,T=0,s,t;
	for(i=0;i<4;i++){
		scanf("%d",&s);
		S=S+s;
	}
	for(i=0;i<4;i++){
		scanf("%d",&t);
		T=T+t;
	}
	if(T>S){
		printf("%d\n",T);
	}
	else {
		printf("%d\n",S);
	}
return 0;
}

Measured memory_bytes: 592
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n,0,-1):
    s=0
    for j in range(1,n+1):
        if j*i<=n:
            s+=b[i*j-1]
        else:
            break
    if s%2!=a[i-1]:
        b[i-1]+=1
c=[]
for i in range(n):
    if b[i]==1:
        c.append(i+1)
m=sum(b)
print(m)
print(*c)

Measured memory_bytes: 98040
#include <stdio.h>
int main(void){
    int x, y;
    while(1) {// Your code here!
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        
        if(x<y) {
            printf("%d %d\n", x, y);
        }
        else {
            printf("%d %d\n", y, x);
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

ll sum_keta(ll a){
	ll A=a,SUM=0;
	while(A!=0){
		SUM=SUM+A%10;
		A=A/10;
	}
	return SUM;
}

int main()
{
	ll N,A,B;
	vector<ll>V;
	cin>>N;
	A=1;
	B=N-1;
	for(;;){
		ll sum=0;
		sum=sum_keta(A)+sum_keta(B);
		V.push_back(sum);
		if(A==B&&N%2==0)break;
		if(A-B==-1&&N%2==1)break;
		A++;
		B--;
	}
	sort(V.begin(),V.end());
	cout<<V.front()<<endl;
}

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

using namespace std;

const int N = 2e5+7;
int n, cnt[N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d", &n);
	
	for (int i = 1; i < n; i++){
		int a;
		scanf("%d", &a);
		cnt[a]++;
	}

	for (int i = 1; i <= n; i++){
		printf("%d\n", cnt[i]);
	}

	return 0;
}

Measured memory_bytes: 4456
using System;

class Sample29
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var result = "";
        int attempt = s.Length;
        
        //バリデーション
        try
        {
            if(1200 < attempt)
            {
                throw new ArgumentOutOfRangeException();
            }
        }
        catch(ArgumentOutOfRangeException e)
        {
            Console.WriteLine(e.StackTrace);
            Console.WriteLine("文字数が範囲外です。");
            Environment.Exit(0);
        }
            
        //処理
        for (int i = 0; i < attempt; i++)
        {
            if (char.IsUpper(s[i]))
            {
                result += s[i].ToString().ToLower();
            
            }else 
            {
            result += s[i].ToString().ToUpper();
            }
        }
        Console.WriteLine(result);
    }
}


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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define RFOR(i, a, n) for (ll i = (ll)a; i >= n; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FOR(i, 1, n + 1)
#define RREP(i, n) RFOR(i, n - 1, 0)
#define RREPN(i, n) RFOR(i, n, 1)
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll extGCD(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }

    ll d = extGCD(b, a & b, y, x);
    y -= a / b * x;
    return d;
}

inline ll mod(ll &a, ll m)
{
    a = (a % m + m) % m;
    return a;
}

ll modinv(ll a, ll m)
{
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}

ll modadd(ll &a, ll b)
{
    mod(a, MOD);
    mod(b, MOD);
    a += b;
    return mod(a, MOD);
}

ll modsub(ll &a, ll b)
{
    return modadd(a, -b);
}

ll modmulti(ll &a, ll b)
{
    mod(a, MOD);
    mod(b, MOD);
    a *= b;
    return mod(a, MOD);
}

ll moddiv(ll &a, ll b)
{
    mod(a, MOD);
    a *= modinv(b, MOD);
    return mod(a, MOD);
}

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

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

//a,bの最大公約数
inline ll gcd(ll a, ll b)
{
    ll temp;
    while (a % b != 0)
    {
        temp = a;
        a %= b;
        b = temp;
    }
    return b;
}

//a,bの最小公倍数
inline ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

const int MAX_N = 1e5 + 10;

int main()
{
    int mod = 2019;
    int L, R;
    cin >> L >> R;

    if (R - L >= mod)
    {
        cout << 0 << endl;
    } else
    {
        ll l = L % mod;
        ll d = (R - L);
        ll result = INF;
        for (ll i = l; i <= l + d; ++i)
        {
            for (ll j = i + 1; j <= l + d; ++j)
            {
                ll x = i % mod;
                ll y = j % mod;
                chmin(result, (x * y) % mod);
            }
        }
        cout << result << endl;
    }
    
}


Measured memory_bytes: 256
#include <cstdio>


using namespace std;
int lis[100000];
int tim[100000];
int main() {
    int n,r,l,d,t,x;
    scanf("%d %d %d",&n,&r,&l);
    int top = 0;
    int id  = 1;
    int nowtime = 0;
    int timemax = 0;
    int timemaxid = 0;
    for(int i = 0; i < r; i++) {
        scanf("%d %d %d",&d,&t,&x);
        tim[id] += t - nowtime;
        if(tim[id] > timemax) {
            timemax = tim[id];
            timemaxid = id;
        }
        nowtime = t;
        lis[d] += x;
        if(id == d) {
            top += x;
        }
        if(x < 0 && d == id) {
            for(int j = 1; j < n+1; j++) {
                if(top < lis[j] || (top == lis[j] && j < id)) {
                    top = lis[j];
                    id = j;
                }
            }
            
        }
        if(x > 0 && d != id) {
            if(top < lis[d] || (top == lis[d] && d < id)) {
                top = lis[d];
                id = d;
            }
        }

    }
    tim[id] += l - nowtime;
    if(tim[id] > timemax) {
        timemax = tim[id];
        timemaxid = id;
    }
    printf("%d\n",timemaxid);
}

Measured memory_bytes: 1804