akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a <= b)
	{
		cout << a << "\n";
	}
	else {
		cout << a-1 << "\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

vector<int> xor_list;
vector<bool> visited;
vector<vector<pair<int, int>>> edge_list;
vector<int> result;

int dfs(int curr)
{
	visited[curr] = true;
	int curr_xor = xor_list[curr];

	for (pair<int, int> e : edge_list[curr])
	{
		int next = e.first;
		int curr_idx = e.second;

		if (visited[next]) continue;

		int ret_xor = dfs(next);
		if (ret_xor == 1)
		{
			result.push_back(curr_idx);
			curr_xor ^= 1;
		}
	}

	return curr_xor;
}

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

	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> bomb_list(N, make_pair(0, 0));
	for (int i = 0; i < N; i++)
	{
		cin >> bomb_list[i].first >> bomb_list[i].second;
	}

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

	xor_list.assign(N + 1, 0);
	xor_list[0] = bomb_list[0].second;
	for (int i = 1; i < N; i++)
	{
		xor_list[i] = bomb_list[i - 1].second ^ bomb_list[i].second;
	}
	xor_list[N] = bomb_list[N - 1].second;

	visited.assign(N + 1, false);
	edge_list.assign(N + 1, vector<pair<int, int>>());

	for (int i = 0; i < M; i++)
	{
		int l, r;
		cin >> l >> r;

		l = lower_bound(bomb_list.begin(), bomb_list.end(), make_pair(l, 0)) - bomb_list.begin();
		r = upper_bound(bomb_list.begin(), bomb_list.end(), make_pair(r, 1)) - bomb_list.begin();
		edge_list[l].emplace_back(r, i + 1);
		edge_list[r].emplace_back(l, i + 1);
	}

	for (int i = 0; i < N + 1; i++)
	{
		if (visited[i]) continue;
		if (dfs(i)) {
			cout << -1;
			return 0;
		}
	}

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

	cout << result.size() << "\n";
	for (int edge : result)
	{
		cout << edge << " ";
	}
	
	return 0;
}

Measured memory_bytes: 14076
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int D,G;
vector<int> P,C;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> D >> G;
    G/=100;
    for (int i = 0; i < D; i++)
    {
        int p,c;
        cin >> p >> c;
        c/=100;
        P.push_back(p);
        C.push_back(c);
    }
    
}

int max_score(int x){
    ll res=0;
    for (int bit = 0; bit < (1<<D); bit++)
    {
        int chk=x;
        ll scr=0;
        for (int j = 0; j < D; j++)
        {
            if(bit>>j&1) {chk-=P[j];scr+=C[j]+(j+1)*P[j];}
        }
        if(chk<0) continue;
        for (int j = D-1; j >=0; j--)
        {
            if(!(bit>>j&1)) {
                scr+=(j+1)*min(P[j]-1,chk);
                chk=chk-min(P[j]-1,chk);
                }
            if(chk<=0) break;
        }
        res = max(res,scr);
    }
    
    return res;
}

int solve(){
    int ng=0;
    int ok=accumulate(P.begin(),P.end(),0);
    while(ok-ng>1){
        int mid=(ng+ok)/2;
        if(max_score(mid)>=G) ok=mid;
        else ng=mid; 
    }
    cout << ok << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
//abc088_c.cpp
//Sun Feb 18 19:35:36 2018

#include <iostream>
#include <string>
using namespace std;

int main(){
	int c[3][3];
	cin >> c[0][0] >> c[0][1] >> c[0][2];
	cin >> c[1][0] >> c[1][1] >> c[1][2];
	cin >> c[2][0] >> c[2][1] >> c[2][2];

	if (c[2][0]-c[1][0] == c[2][1]-c[1][1] &&
		c[2][1]-c[1][1] == c[2][2]-c[1][2] &&
		c[1][0]-c[0][0] == c[1][1]-c[0][1] &&
		c[1][1]-c[0][1] == c[1][2]-c[0][2] &&
		c[0][2]-c[0][1] == c[1][2]-c[1][1] &&
		c[1][2]-c[1][1] == c[2][2]-c[2][1] &&
		c[0][1]-c[0][0] == c[1][1]-c[1][0] &&
		c[1][1]-c[1][0] == c[2][1]-c[2][0]
		){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll n;
	cin >> n;
	cout << pow(n,3) << endl;
	
    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
out  = []

steps = Array.new(n + 2, 1)

m.times do
  steps[gets.to_i + 1] = 0
end

steps[0] = 0
steps[1] = 1

for i in 2 .. n + 1
  if steps[i] != 0
    steps[i] = (steps[i - 1] + steps[i - 2]) % 1000000007
  end
end

puts steps[-1]


Measured memory_bytes: 2812
"""
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
配列サイズの無駄を減らした。m回の操作の際に入力をそのまま受け取る。
"""
n, m = map(int, input().split())
a = list(map(int, input().split()))

num_map = []
for i in range(n):
    num = a[i]
    num_map.append([num, 1])


for i in range(m):
    card_num, num = map(int, input().split())
    num_map.append([num, card_num])

num_map.sort(reverse=True)

rest_card = n
res_sum = 0
for i in range(len(num_map)):
    num, card_num = num_map[i]
    can_use = min(card_num, rest_card)
    rest_card -= can_use
    res_sum += num * can_use

    if rest_card == 0:
        break

print(res_sum)

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  char s ;
  cin >> s ;
  
  if(s=='T'){
    cout <<"A"<<endl ;
  }
  else if(s=='A'){
    cout <<"T"<<endl ;
  }
  else if(s=='G'){
    cout <<"C"<<endl ;
  }
  else{
    cout <<"G"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
# import math

N = int(input())
towns = [tuple(map(int, input().split())) for _ in range(N)]

total_distance = 0
count = 0
for start in range(N-1):
    for end in range(start+1, N):
        start_x, start_y = towns[start]
        end_x, end_y = towns[end]

        total_distance += ((end_x - start_x)**2 + (end_y - start_y)**2)**0.5
        count += 1

# factor = math.factorial(N)

# answer = total_distance * (factor * (N - 1) / count) / factor
answer = total_distance * ((N - 1) / count)
print(answer)

Measured memory_bytes: 9452
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		long[] X = new long[N];
		long[] Y = new long[N];
		for(int i = 0; i < N; i++)
		{
			X[i] = GetInt();
			Y[i] = GetInt();
		}
		long r = Math.Abs(X[0] + Y[0]) % 2;
		for(int i = 1; i < N; i++)
		{
			if(Math.Abs(X[i] + Y[i]) % 2 != r)
			{
				Console.WriteLine("-1");
				return;
			}
		}

		Console.WriteLine((r == 1L) ? 31 : 32);  // m

		StringBuilder d = new StringBuilder();
		if(r == 0L)
			d.AppendFormat("{0} ", 1L);
		for(int i = 0; i < 31; i++)
			d.AppendFormat("{0} ", 1L << i);
		Console.WriteLine(d);

		for(int i = 0; i < N; i++)
		{	
			StringBuilder w = new StringBuilder();
			if(r == 0L)
				w.Append("R");
			long U = X[i] + Y[i] - 1L^r;
			long V = X[i] - Y[i] - 1L^r;
			long S = (U + (1L << 31) - 1L) >> 1;
			long T = (V + (1L << 31) - 1L) >> 1;

			for(int j = 0; j < 31; j++)
			{
				if(((S >> j) & 1) == 1)
				{
					if(((T >> j) & 1) == 1)
						w.Append("R");
					else
						w.Append("U");
				}
				else
				{
					if(((T >> j) & 1) == 1)
						w.Append("D");
					else
						w.Append("L");
				}
			}
			Console.WriteLine(w);
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  ll n; cin >> n;
  vector<ll> h(n); for(ll i = 0; i < n; i++) cin >> h[i];
  ll ans = 0;
  ll active = 0;
  for(int i = 0; i < n; i++) {
    if(active >= h[i]) active = h[i];
    else {
      ans += h[i] - active;
      active = h[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  ll l0 = 2;
  ll l1 = 1;
  for(int i = 2; i <= n; i++){
    ll tmp = l0 + l1;
    l0 = l1;
    l1 = tmp;
  }
  cout << l1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 1e5;

int main()
{
	int a,b,c,d,vis;
	while(~scanf("%d %d %d %d",&a,&b,&c,&d))
	{
		vis = 0;
		if(abs(a - c) <= d) vis = 1;
		if(abs(a - b) <= d && abs(b - c) <= d) vis = 1;
		if(vis) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef struct Mag
{
	int MP,tag,Dam;//single:0 all:1
	bool operator < (const Mag &A)const{return tag==A.tag?A.MP>MP:tag<A.tag;}
}Mag;

int N,M,HP[105],A,SDP[100005],ADP[100005],res,tmp;
Mag SP[105];

int main()
{
	for(;scanf("%d",&N),N;)
	{
		res=1000000000;
		A=0;
		memset(SDP,0x7f,sizeof(SDP));
		memset(ADP,0x7f,sizeof(ADP));
		SDP[0]=ADP[0]=0;
		for(int i=0;i<N;i++)scanf("%d",HP+i);
		scanf("%d\n",&M);
		for(int i=0;i<M;i++)
		{
			char t[20];
			scanf("%*s%d%s%d\n",&SP[i].MP,t,&SP[i].Dam);
			A+=SP[i].tag=t[0]=='S'?0:1;
		}
		sort(SP,SP+M);
		for(int i=0;i<M-A;i++)
		{
			for(int j=0;j<=100000;j++)
			{
				int np=j+SP[i].Dam;
				if(np>100000)np=100000;
				SDP[np]=min(SDP[np],SDP[j]+SP[i].MP);
			}
		}
		for(int i=100000;i>=0;i--)
			SDP[i]=min(SDP[i],SDP[i+1]);

		for(int i=M-A;i<M;i++)
		{
			for(int j=0;j<=100000;j++)
			{
				int np=j+SP[i].Dam;
				if(np>100000)np=100000;
				ADP[np]=min(ADP[np],ADP[j]+SP[i].MP);
			}
		}
		if(A==M)
		{
			int mh=0;
			for(int i=0;i<N;i++)mh=max(mh,HP[i]);
			for(int i=mh;i<=100000;i++)
				res=min(res,ADP[i]);
		}
		else
		{
			for(int i=0;i<=100000;i++)
			{
				if(ADP[i]==2139062143)continue;
				tmp=ADP[i];
				for(int k=0;k<N;k++)
				{
					if(HP[k]-i>=0)
					{
						int np=HP[k]-i;
						if(np<0)np=0;
						if(SDP[np]==2139062143)
						{
							tmp=1000000000;
							break;
						}
						tmp+=SDP[np];
					}
				}
				res=min(res,tmp);
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    vector<ll> ABC(3);
    ll C;
    REP(i, 3) {
        cin >> ABC[i];
        if(i == 2) { C = ABC[i]; }
    }
    SORT(ABC);
    if(ABC[1] == C) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int x,a;
    cin >> x >> a;
    if(x<a)cout << 0 << endl;
    else cout << 10 << endl;

}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

int a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b;
	if (a < b)
		swap(a, b);
	cout << max(a * 2 - 1, a + b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n,m; cin >> n >> m;
  vector<int> ans(n,0);
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    ans[a]++;
    ans[b]++;
  }
  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, X;
    while(cin >> N >> X){
        int res = 1, x = 0;
        for(int i=0;i<N;i++){
            int L; cin >> L;
            x += L;
            if(x <= X) ++res;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long int lli;
typedef long long ll;
#define mod 10000000007
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   lli a,b,c,d,flag;
   cin>>a>>b>>c>>d;
   while(1)
   {
       c=c-b;
       if(c<=0)
       {
           flag=1;
           break;
       }
       a=a-d;
       if(a<=0)
       {
           flag=0;break;
       }
   }
   if(flag==1)
   cout<<"Yes"<<"\n";
   else
   cout<<"No"<<"\n";
}

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

using namespace std;

int f[100][10], p[100][11];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 10; j++)
			scanf("%d", f[i] + j);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 11; j++)
			scanf("%d", p[i] + j);
	int m = -2000000000;
	for (int i = 1; i < 1024; i++) {
		int P = 0;
		for (int j = 0; j < n; j++) {
			int c = 0;
			for (int k = 0; k < 10; k++)
				c += (i & 1 << k) && f[j][k];
			P += p[j][c];
		}
		m = max(m, P);
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
map<ll,ll>m;
int main() {
	ll n;
	cin>>n;
	ll a[n],ans=0ll;
	for(ll i=0ll;i<n;i++)
		cin>>a[i];
	for(ll i=n-1ll;i>=0ll;i--){
		ans+=m[i+a[i]];
		m[i-a[i]]++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 27744
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scn = new Scanner(System.in);
		while(scn.hasNext())
		{
			int a = scn.nextInt();
			int b = scn.nextInt();
			System.out.printf("%d %d\n", getCommonDivider(a, b), getCommonMultiplier(a, b));
		}
	}

	public static int getCommonDivider(int a, int b)
	{
		if (b == 0) return a;
		int q = a % b;
		return getCommonDivider(b, q);
	}

	public static int getCommonMultiplier(int a, int b)
	{
		int v = getCommonDivider(a, b);
		int va = a / v;
		int vb = b / v;
		return v*(va*vb);
	}
}

Measured memory_bytes: 18136
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  int n,i;
  double m,a;
  cin >> n;
  int s[1000];
  while (n!=0) {
    m=0;
    for(i=0;i<n;i++) {
      cin >> s[i];
      m+=s[i];
    }
    m/=n;
    a=0;
    for(i=0;i<n;i++) {
      a+=pow(s[i]-m, 2);
    }
    a/=n;
    a=sqrt(a);
    cin >> n;
    cout << fixed;
    cout << std::setprecision(5) << a << endl;
  }
  return 0;
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n&1){
  	cout<<b[n/2]-a[n/2]+1;
  }
  else{
  	cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
  }
}

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

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

int n,m;
bool g[25][21];
bool used[830];

int dfs(int pos,int cnt){
    if(cnt==n)return 1;
    int ret = 0;
    REP(to,n)if(g[pos][to] && !used[to]){
        used[to] = true;
        ret += dfs(to,cnt+1);
        used[to] = false;
    }
    return ret;
}

int main(void){
    cin>>n>>m;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;
        g[a][b] = g[b][a] = true;
    }
    used[0] = true;
    printf("%d\n",dfs(0,1));
    return 0;
}


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

int main(){
	int n,m;
	while(cin>>n>>m,n,m){
		int cost[114][514];
		int time[114][514];
		for(int i=0;i<=m;i++)
		for(int j=0;j<=m;j++)cost[i][j]=INF,time[i][j]=INF;
		
		for(int i=0;i<n;i++){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			cost[a-1][b-1]=c;
			cost[b-1][a-1]=c;
			time[a-1][b-1]=d;
			time[b-1][a-1]=d;
			}
			
		for(int k=0;k<m;k++)
		for(int i=0;i<m;i++)
		for(int j=0;j<m;j++)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]),time[i][j]=min(time[i][j],time[i][k]+time[k][j]);	
		
		int e;
		cin>>e;
		for(int i=0;i<e;i++){
			int p,q,r;
			cin>>p>>q>>r;
			if(r==0){
				cout<<cost[p-1][q-1]<<endl;
				}
			else cout<<time[p-1][q-1]<<endl;	
			}
		}
		return 0;
	}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int res;
  for (int i = n; i <= 999; i++) {
    string str = to_string(i);
    bool ok = true;
    for (int j = 0; j < str.length() - 1; j++) {
      if (str[j] != str[j + 1]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      res = i;
      break;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
  if ( !v.empty() ) {
    out << '[';
    copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

int check(vector<string> v, int n) {
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(v[i][j] != v[j][i]) {
                return 0;
            }
        }
    }

    return 1;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.precision(16);
    
    int n;
    cin >> n;
    vector<string> v(n);
    REP(i, n) cin >> v[i];

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans += check(v, n);

        string t = v.front();
        v.erase(v.begin());
        v.push_back(t);
    }
    ans *= n;

#if DEBUG
	cout << "** RESULT **" << endl; // debug
#endif
    cout << ans << endl;    
	return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
is_ac = [False] * 200050
count_wa = [0] * 100050
numok = 0
numwa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p]: # すでに正解
        continue
    else: # 未正解
        if s == "AC":
            numok += 1
            is_ac[p] = True
        else:
            count_wa[p] += 1
for i in range(100040):
    if is_ac[i]:
        numwa += count_wa[i]
print("{0} {1}".format(numok, numwa))

Measured memory_bytes: 51432
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FerrisWheel | diff FerrisWheel.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FerrisWheel.cpp && ./a.out

/*
 
 5/25/2019
 
 5:01-
 
 */

int A,B;

void solve() {
  int res=0;
  if(A>=13) res=B;
  else if(6<=A) res=B/2;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <deque>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
        A[i]--;
    }
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N-1;i++) cin >> C[i];

    ll ans=B[A[0]];
    ll pre=A[0];
    for(int i=1;i<N;i++){
        ans+=B[A[i]];
        if(A[i]==pre+1) ans+=C[pre];
        pre=A[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        ab: [(usize, usize); n],
    }

    let mut counter = vec![0; 100001];
    for (a, b) in ab {
        counter[a] += b;
    }
    let mut sum = 0;
    for n in 1..counter.len() {
        sum += counter[n];
        if sum >= k {
            println!("{}", n);
            break;
        }
    }
}


Measured memory_bytes: 5456
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;

int main(){
  /*処理系*/
  int A, B, C, X;
  int ansnum = 0;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  for (int i=0; i <= A; i++){
    for(int j=0; j <= B; j++){
      for (int k = 0; k <= C; k++){
        if(500 * i + j * 100 + 50 * k == X)
          ansnum++;
      }
    }
  }
  cout << ansnum;
  return 0;
}

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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   string a,b,c;
   cin >>a  >>b  >> c;
    cout << 'A' << b[0] << 'C';
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		
		int a = 1*scan.nextInt();
		int b = 5*scan.nextInt();
		int c = 10*scan.nextInt();
		int d = 50*scan.nextInt();
		int e = 100*scan.nextInt();
		int f = 500*scan.nextInt();
		
		if(a+b+c+d+e+f >=1000){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
}

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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool ng = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || __int128(ans)*a > MX) {
      ng = true;
    }
    ans *= a;
  }
  if (ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        Set<Integer> s = new HashSet<Integer>();
        for (int i = 0; i < 3; i++) {
            s.add(inp.nextInt());
        }
        System.out.println(s.size());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    string s, t;
    cin >> s >> t;
    int ns, nt;
    ns = s.size();
    nt = t.size();

    int str_max = 0;
    for (int i = 0; i < ns - nt + 1; i++)
    {
        int counter = 0;
        for (int j = 0; j < nt; j++)
        {
            if(s.at(i+j) == t.at(j)){
                counter++;
            }
        }
        if(counter > str_max) str_max = counter;
    }
    cout << nt - str_max << endl;
    return 0;
}

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

int x[1000],y[1000];
string lab[1000];

int main(){
	int n,m,s,g;
	while(cin >> n >> m >> s >> g && n){
		for(int i = 0 ; i < m ; i++){
			cin >> y[i] >> x[i] >> lab[i];
		}
		string memo[40];
		for(int i = 0 ; i < 40 ; i++) memo[i] = "~";
		memo[g] = "";
		int ref = 0;
		bool bad = 0;
		int p = 0;
		while(1){
			bool f = false;
			for(int j = 0 ; j < m ; j++){
				if(memo[x[j]]=="~") continue;
				string cost = lab[j]+memo[x[j]];
				if(cost < memo[y[j]]){
					memo[y[j]] = cost;
					f = true;
					if(s == y[j] && memo[y[j]].length() > 250){bad = true; f = false; break;}
				}
			}
			if(!f) break;
			ref++;
			if(ref == 300) { break;}
		}
		if(bad || memo[s] == "~") cout << "NO" << endl;
		else cout << memo[s] << endl;

	}
}

Measured memory_bytes: 0
import collections
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
c = collections.Counter(a_list)
v_list = []
c_v = c.values()
c_v = list(c_v)
c_v.sort()
if len(c_v)<k:
  print(0)
else:
  print(sum(c_v[:len(c_v) - k]))

Measured memory_bytes: 32564
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i;
    cin>>N;

    lli cnt=0;
    rep(i,0,N)
    {
        lli x,y;
        cin>>x>>y;

        cnt+=abs(x-y)+1;
    }

    cout<<cnt;






 return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <stack>

using namespace std;

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	int BobsAns;
	cin >> s >> BobsAns;
	int ansL = s[0] - '0';
	for (int i = 2; i < s.size(); i += 2)
	{
		if (s[i - 1] == '+')
		{
			ansL += s[i] - '0';
		}
		else
		{
			ansL *= s[i] - '0';
		}
	}
	int ansM = 0;
	stack<int> num;
	for (int i = 0; i < s.size(); ++i)
	{
		if ('0' <= s[i] && s[i] <= '9')
		{
			num.push(s[i] - '0');
		}
		else if (s[i] == '*')
		{
			int a = num.top();
			num.pop();
			a *= s[i + 1] - '0';
			num.push(a);
			++i;
		}
	}
	while (!num.empty())
	{
		ansM += num.top();
		num.pop();
	}
	if (ansL == BobsAns && ansM == BobsAns)
	{
		cout << "U" << endl;
	}
	else if (ansM == BobsAns)
	{
		cout << "M" << endl;
	}
	else if (ansL == BobsAns)
	{
		cout << "L" << endl;
	}
	else
	{
		cout << "I" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main()
{
	std::string a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	cout << char(toupper(a1[0])) << char(toupper(a2[0])) << char(toupper(a3[0]));
}

Measured memory_bytes: 384
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;


int main(void)
{
	ll n; cin >> n;
	vector<P> vs(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
		vs[i].first--;
		vs[i].second--;
	}
	sort(vs.begin(), vs.end());
	multiset<ll> right1;
	multiset<ll> right2;	
	for (int i = 0; i < n; i++) {
		right2.insert(vs[i].second);
	}
	ll m = 0;
	for (int i = 0; i < n; i++) {
		auto f = right2.find(vs[i].second);
		right2.erase(f);
		auto left2 = vs[n - 1].first;
		auto range2 = max(0LL, *right2.begin() - left2 + 1LL);
		auto range1 = max(0LL, vs[i].second - vs[i].first + 1LL);
		m = max(m, range1 + range2);
		right2.insert(vs[i].second);
	}
	for (int i = 0; i < n-1; i++) {
		auto left1 = vs[i].first;
		right1.insert(vs[i].second);
		auto range1 = max(0LL, *right1.begin() - left1 + 1LL);
		auto f = right2.find(vs[i].second);
		right2.erase(f);
		auto left2 = vs[n - 1].first;
		auto range2 = max(0LL, *right2.begin() - left2 + 1LL);
		m = max(m, range1 + range2);
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
int main()
{
    int a,b,c,i,m=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
            m=m+1;
    }
    printf("%d\n",m);
    return 0;
}



Measured memory_bytes: 2120
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, C;
  cin >> N >> C;

  vector<vector<int>> D(C, vector<int>(C, 0));
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> D[i][j];
    }
  }

  vector<vector<int>> CC(N, vector<int>(N, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> CC[i][j];
      CC[i][j]--; // 座標を合わせるため
    }
  }

  vector<vector<int>> cost(3, vector<int>(C, 0));
  for (int c = 0; c < C; c++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cost[(i + j) % 3][c] += D[CC[i][j]][c];
      }
    }
  }

  int res = INT_MAX;
  int c[3];
  for (c[0] = 0; c[0] < C; c[0]++) {
    for (c[1] = 0; c[1] < C; c[1]++) {
      if (c[1] == c[0])
        continue;

      for (c[2] = 0; c[2] < C; c[2]++) {
        if (c[2] == c[0] || c[2] == c[1])
          continue;

        int tmp = 0;
        for (int it = 0; it < 3; it++)
          tmp += cost[it][c[it]];

        res = min(res, tmp);
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>


typedef struct{
  int id;
  int left;
  int right;
  int p;
  int s;
  int dep;
  int deg;
  int h;
}Tree;

Tree A[25];

void preParse(int);
void inParse(int);
void postParse(int);


int main(){
  int in,n,i,s1,s2;
  int pa,pc,hc,he,box;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    A[i].p=-1;
    A[i].s=-1;
    A[i].deg=0;
    A[i].h=0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&in);
    A[in].id=in;
    scanf("%d %d",&A[in].left,&A[in].right);
    if(A[in].left!=-1&&A[in].right!=-1){
      A[in].deg=2;
    }else if(A[in].left!=-1||A[in].right!=-1){
      A[in].deg=1;
    }
 
    s1=A[in].left;
    s2=A[in].right;
    A[s1].p=A[in].id;
    A[s2].p=A[in].id;
    A[s1].s=s2;
    A[s2].s=s1;
  }
 
  for(i=0;i<n;i++){
    if(A[i].p==-1){
      A[i].dep=0;
    }else{
      pa=A[i].p;
      pc=1;
     
      while(A[pa].p!=-1){
    pc++;
    pa=A[pa].p;
      }
      A[i].dep=pc;
    }
  }
 
 
 
  for(i=0;i<n;i++){
    if(A[i].deg==0){
      hc=0;
      A[i].h=hc;
      pa=A[i].p;
 
      while(pa!=-1){
    hc++;
    if(A[pa].h<=hc){
      A[pa].h=hc;
      pa=A[pa].p;
    }
      }
    }
  }

  for(i=0;i<n;i++){
    if(A[i].p==-1){
      box = i;
      break;
    }
  }
  
  printf("Preorder\n");
  preParse(box);
  printf("\n");

  printf("Inorder\n");
  inParse(box);
  printf("\n");

  printf("Postorder\n");
  postParse(box);
  printf("\n");

  
  return 0;
}

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

void inParse(int u){
  if(u==-1)return;
  inParse(A[u].left);
  printf(" %d",u);
  inParse(A[u].right);
}

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

Measured memory_bytes: 616
import sys, math,os
from io import BytesIO, IOBase
from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
sys.setrecursionlimit(100000)
from fractions import Fraction
INF = float('inf')
mod = 998244353


def main():

    s=data()
    s1=''
    for i in s:
        if i=='?':
            s1+='D'
        else:
            s1+=i
    out(s1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10628
#include <iostream>
using namespace std;
typedef long long ll;

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

string s1;
int flag =0;
int N;
int N1, N2;

int code(){
    N = s1.size();
    N1 = (N-1)/2;
    N2 = (N+3)/2;
    //回文の判定
    FOR(i, 0, N/2-1){
        if(s1[i]!=s1[N-i-1])
            flag=1;
    }

    //回文2の判定
    FOR(i, 0, N1/2-1){
        if(s1[i] != s1[N1-i-1])
            flag =1;
    }
    
    //回文3の判定
    FOR(i, N2, (N2+N)/2-1){
        if(s1[i] != s1[N-i-1])
            flag =1;
    }
    
    return 0;
}

int main(){
    cin >> s1;
    code();
    if(flag==0){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
 
char str [100005],dr[10]="dream", er[10]="erase";
//dreamer的结尾的er与erase重合，到时候再判断i+3即可 
int main()
{
    gets(str);
    
        int len = strlen (str);
        int i,ok=1;
        for (i=0;i<len;i++)//dreameraser
        {
            if (str[i]=='d')
            {
                int j;
                for (j=i;j<=i+4;j++)
                {
                    if (j>=len||dr[j-i]!=str[j])
                    {
                        ok=0;
                        break;
                    }
                }
                if (j==i+5)//是dream
                {
                    i=j-1;
                    if (str[j]=='e'&&str[j+1]=='r'&&str[j+2]!='a')
                    {
                        i=j+1;
                    }
                }
            }
            else if (str[i]=='e')
            {
                int j;
                for (j=i;j<=i+4;j++)
                {
                    if (j>=len||er[j-i]!=str[j])
                    {
                        ok=0;
                        break;
                    }
                }
                if (j==i+5) //是erase
                {
                    i=j-1;
                    if (str[j]=='r') i=j;
                    else i=j-1;
                }
            }
            else ok=0;
            if (ok==0) break;
        }
        if (ok==1)
            printf("YES");
        else
            printf("NO");
    
    return 0;
}

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

int main(){
  int a , b ;
  cin >> a >> b ;
  if(a>=b){
    for(int i=0;i<a;i++){
      cout << b ;
    }
  }
   else if(a<b){
     for(int i=0;i<b;i++){
       cout << a ;
     }
   }
  
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, k; cin>>n>>k;
    vll v(n);
    for(i = 0; i < n; i++) cin>>v[i];
    for(i = k; i < n; i++){
        if(v[i] <= v[i-k]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 4784
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators 
//do not forget to change the sizes of arrays and value of contants and other things after debugging  
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)
 
#define SZ(x)  (ll)(x.size())
 
//comment the below if not required
 
/*
 
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
*/
 
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

//cout<<"Case #"<<c<<": "<<ans<<"\n" ;

int main()
{

    ld d,t,s,T;

    cin>>d>>t>>s;

    T = d/(1.0*s);

    if(T>t)
        cout<<"No\n";
    else
        cout<<"Yes\n";


    return 0;

}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a;
    cin>>a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>

using namespace std; 
#define Endl '\n'
int main()
{
    int n;
    cin>>n;
    int a[n],b[n]={0};
    b[n-1]=0;
    for (int i = 0; i < n-1; ++i)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for (int i = 1; i < n; ++i)
    {
        cout<<b[i]<<Endl;
    }
    cout<<0;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define vecadd emplace_back

int main(){
  int a,b,c;
  
  cin>>a>>b>>c;
  
  int sum=b+c-a;
  if(sum>0){}
  else sum=0;
  
  cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	bool answer = false;
	for(int i = 0; i + t.size() <= s.size(); ++i){
		bool match = true;
		for(int j = 0; j < t.size(); ++j){
			if(t[j] != '_' && s[i + j] != t[j]){ match = false; }
		}
		if(match){ answer = true; }
	}
	cout << (answer ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 1188