akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
typedef pair < ll, ll > cp2;
typedef pair <ll, cp2 > cp3;
#define fi first
#define se second
#define sec se.fi
#define thr se.se
const ll mod = 1000000007;
//              123456789

int main(){
	int e, y;
	
	cin >> e >> y;
	
	if (e == 0){
		if (1868 <= y && y <= 1911){
			cout << "M" << y - 1867 << endl;
		}
		else if (1912 <= y && y <= 1925){
			cout << "T" << y - 1911 << endl;
		}
		else if (1926 <= y && y <= 1988){
			cout << "S" << y - 1925 << endl;
		}
		else if (1989 <= y && y <= 2016){
			cout << "H" << y - 1988 << endl;
		}
	}
	else if (e == 1){
		cout << 1868 + y - 1 << endl;
	}
	else if (e == 2){
		cout << 1912 + y - 1 << endl;
	}
	else if (e == 3){
		cout << 1926 + y - 1 << endl;
	}
	else if (e == 4){
		cout << 1989 + y - 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define ll long long
#define ld long double
#define MAX (int)(2*pow(10,5)+10)
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,9);
ll INF = inf;
ll modulo = pow(10,9)+7;
double eps = 1e-10;
ifstream in;
ofstream out;

vector<pair<char,char> > que;
vector<char> all;
string dir = "LR";
ll dif[2] = {-1, 1};

ll calc(ll ind){
//	cout<<"begin "<<ind<<endl;
	for(auto el: que){
		if(el.ff == all[ind]){
			ind+=dif[dir.find(el.ss)];
			if(ind<0 || ind >= all.size())
				break;
		}
//		cout<<ind<<endl;
	}
	return ind;
}

void deal(){
	ll n , q;
	cin>>n>>q;
	all.resize(n);
	fori(n)
		cin>>all[i];
	que.resize(q);
	fori(q)
		cin>>que[i].ff>>que[i].ss;
	ll ans = 0;
	if(calc(0) < 0){
		ll lo = 0, hi = n-1;
		while(lo < hi){
			ll mid = (lo+hi)/2+1;
			if(calc(mid) <0 )
				lo = mid;
			else
				hi = mid-1;
		}
		ans+=lo+1;
	}
	if(calc(n-1) > n-1){
		ll lo = 0, hi = n-1;
		while(lo < hi){
			ll mid = (lo+hi)/2;
			if(calc(mid) > n-1)
				hi = mid;
			else
				lo = mid+1;
		}
		ans+=((n-1)-lo)+1;
	}
	cout<<n-ans;
}



int main(){
//	test();
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



/*
	
*/

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;
using lli = long long int; 
using dequtor = std::deque<lli>;

void trace(dequtor de, lli size){
	for(int i=0; i<size; i++){
		cout << de[i] << " ";
	}
	cout << endl;
}

int main(){
	lli N;
	cin >> N;
	dequtor a;
	for(int i=0; i < N; i++){
		lli a_i;
		cin >> a_i;
		a.push_back(a_i);
	}
	lli count = 0;
	lli pointer = 0;
	//lli size = N;
	for(int i=0; i < N; i++){
		//trace(a, a.size());
		//cout << endl;
		//cout << count << endl;
		/*if(a.size() == 0){
			count = -1;
			break;
		}*/
		if(a[i] != pointer+1){
			//size --;
			a[i] = -1;
			count ++;
		}else{
			pointer ++;
		}
	}
	pointer = 0;
	for(int i=0; i<a.size(); i++){
		if(a[i] != pointer+1 && a[i] != -1){
			count = -1;
		}else if(a[i] != -1){
			pointer ++;
		}
	}
	lli counter = count;
	count = -1;
	for(int i=0; i<a.size(); i++){
		if(a[i] != -1){
			count = counter;
		}
	}
	//trace(a, a.size());
	cout << count;
}

Measured memory_bytes: 1920
h,w = map(int,input().split())
ls = [list(input()) for _ in range(h)]
num = []
di = [0]*w
for i in range(h):
    if "#" not in ls[i]:
        num.append(i)
    for j in range(w):
        if ls[i][j] == "#":
            di[j] += 1
num = sorted(num,reverse=True)
for k in range(h-1,-1,-1):
    if k in num:
        ls.pop(k)
        continue
    for l in range(w-1,-1,-1):
        if di[l] == 0:
            ls[k] = ls[k][:l] + ls[k][l+1:]
for p in range(h-len(num)):
    print("".join(ls[p]))



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

class Program
{
    static void Main(string[] args)
    {
        var k = long.Parse(Console.ReadLine());
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var a = inputs[0];
        var b = inputs[1];

        bool ans = false;

        for(long i = a; i <= b; i++)
        {
            if (i % k == 0) ans = true; ;
        }

        Console.WriteLine(ans ? "OK" : "NG");
    }

}

Measured memory_bytes: 28080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

template<typename T>
map<T, int> prime_factorize(T n) {
  T tmp = n;
  map<T, int> mp;
  for (T i = 2; i * i <= n; ++i) {
    ll cnt = 0;
    while (tmp % i == 0) {
      tmp /= i;
      cnt++;
    }
    if (cnt) mp[i] = cnt;
  }
  if (tmp != 1) mp[tmp] = 1;
  return mp;
}

void solve() {
  ll a, b;
  cin >> a >> b;
  auto x = prime_factorize(a), y = prime_factorize(b);
  map<ll, int> mp;
  for (auto e : y) {
    if (x.count(e.F)) mp[e.F] = min(x[e.F], y[e.F]);
  }
  cout << sz(mp) + 1 << endl;
  // for (auto e : mp) cerr << e << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  if(a >= k) {
    ans = k;
  } else if(a + b >= k) {
    ans = a;
  } else {
    ans = a - (k - a - b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

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

def factorization(n):
    #素因数分解

    factor = []

    for i in list(range(2,3)) + list(range(3, int(n**0.5)+ 1, 2)):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                n //= i
                factor.append(i)
    if n != 1:
        factor.append(n)

    return factor

def main():
    a, b = list(map(int,ipti().split()))
    a_fac = set(factorization(a))
    b_fac = set(factorization(b))
    ab_common = a_fac & b_fac
    print(len(ab_common)+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 55152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  string pre = S.substr(0,N);
  string suf = S.substr(N);
  map<pair<string,string>,ll> from_pre;
  int pre_num = pre.size();
  for(int i=0; i<(1LL<<(pre_num)); i++){
    string a = "",b = "";
    for(int j=0; j<pre_num; j++){
      if(i & (1LL<<j)){
        a += pre[j];
      }else{
        b += pre[j];
      }
    }
    from_pre[pair<string,string>(a,b)]++;    
  }
  map<pair<string,string>,ll> from_suf;
  reverse(suf.begin(),suf.end());
  int suf_num = suf.size();
  for(int i=0; i<(1LL<<(suf_num)); i++){
    string a="",b="";
    for(int j=0; j<suf_num; j++){
      if(i & (1LL<<j)){
        a += suf[j];
      }else{
        b += suf[j];
      }
    }
    from_suf[pair<string,string>(a,b)]++;
  }
  ll ans = 0;
  for(auto m: from_pre){
    // cout << m.first.first << " " << m.first.second << " " << m.second << "\n"; 
    ans += m.second * from_suf[m.first];
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 89696
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = LongArray(N) { readLine()!!.toLong() }

    A.sort()

    if (N % 2 == 0) {
        val m = N / 2
        println(A.slice(m until A.size).sum() * 2 - A.slice(0 until m).sum() * 2 - A[m] + A[m - 1])
    } else {
        val m = N / 2
        val res = Math.max(
            A.slice(m until A.size).sum() * 2 - A.slice(0 until m).sum() * 2 - A[m] - A[m + 1],
            A.slice(m + 1 until A.size).sum() * 2 - A.slice(0 until m + 1).sum() * 2 + A[m] + A[m - 1]
        )

        println(res)
    }
}


Measured memory_bytes: 46296
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var A1 = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
        var A2 = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans = Math.Max(ans, A1.Take(i + 1).Sum() + A2.Skip(i).Sum());
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13396
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto cnt = new long[](26);
	foreach (c; S)
		++cnt[c-'a'];
	cnt.sort!"a > b"();

	writeln(cnt[0] <= 1 ? "yes" : "no");
	stdout.flush();
	debug readln();
}

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

#define ll long long int
#define loop(a,b,c) for(ll a=b; a<c; a++)
#define eloop(a,b,c) for(ll a=b; a<=c; a++)
#define nl printf("\n");

using namespace std;



int main(){
    ll T = 1; //cin >> T;
    while(T--){
        ll n; cin >> n; 
        string s; cin >> s;
      //  vector<ll> v(n);
        ll sum =0, rc =0 , gc = 0, bc = 0, ans =0;
        loop(i,0,n){
            if(s[i] == 'R')rc++;
            else if(s[i] == 'G')gc++;
            else if(s[i] == 'B') bc++;
        }
        ans = rc * gc * bc;
       // cout << "initial ans: " << ans << endl;
        ll k =0;    
        loop(i,0,n){
            loop(j,i+1,n){
                k = 2 * j - i;
                if(k > n-1)break;
                if((s[i] != s[j]) && (s[j] != s[k] ) && (s[i] != s[k]) ) ans--; 




                }
                    
                  //  sum++;

            }
                    
                cout << ans << endl;
            }
            

        
        
       

        
        
        

    
    return 0;
}
/*

*/


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

using namespace std;

int main() {
  string s,t;
  cin >> s >> t;
  int cont = 0;
  for (int i = 0 ; i < t.size() ; i++){
    if (t[i] != s[i])cont++;
  }

  cout << cont << endl;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=3e5+10,size=1<<20,mod=998244353,inf=2e9;
const ll INF=1e15;

//char buf[size],*p1=buf,*p2=buf;
TP void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
TP void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
TP void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
TP void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

//math
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
    ll c=1;
    while(b) {
        if(b&1) c=c*a%mod;
        b /= 2; a=a*a%mod;
    }
    return c;
}

TP void cmax(o &x,o y) {if(x < y) x=y;}
TP void cmin(o &x,o y) {if(x > y) x=y;}

//dbinom

//ll jc[N],inv[N];
//void init(int n) {
//	jc[0]=1; for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
//	inv[n]=power(jc[n]); for(int i=n;i;i--) inv[i-1]=inv[i]*i%mod;
//}
//ll C(int x,int y) {
//	if(x<y || y<0) return 0;
//	return jc[x]*inv[y]%mod*inv[x-y]%mod;
//}

int n,a[N],k,mx[N*8];

int ask(int x,int l,int r,int L,int R) {
	if(L<=l&&r<=R) return mx[x];
	if(!mx[x]) return 0;
	int mid=(l+r)>>1,s=0;
	if(L<=mid) cmax(s,ask(lc,l,mid,L,R));
	if(mid< R) cmax(s,ask(rc,mid+1,r,L,R));
	return s;
}

void add(int x,int l,int r,int pos,int d) {
	if(l == r) {mx[x]=d; return ;}
	int mid=(l+r)>>1;
	if(pos<=mid) add(lc,l,mid,pos,d);
	else add(rc,mid+1,r,pos,d);
	cmax(mx[x]=mx[lc],mx[rc]);
}

void solve() {
	qr(n); qr(k);
	for(int i=1,x;i<=n;i++) {
		qr(x);
		int y=ask(1,-N,2*N,x-k,x+k)+1;
		add(1,-N,2*N,x,y);
	}
	pr2(mx[1]);
}

int main() {
	int T=1;
//	qr(T);
	while(T--)
		solve();
}





Measured memory_bytes: 6420
'use strict'
function gcd() {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arguments[0]
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]); 
    }
    return ans 
}
const Main=input=>{
    const num=parseInt(input);
    let sum=0;
    for(let i=1;i<num+1;i++){
        for(let j=1;j<num+1;j++){
            for(let k=1;k<num+1;k++){
                sum+=gcd(i,j,k);
            }
        }
    }
    
    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 34572
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int get_NumTimes(int n)
{
  int x = 8*n+1;
  x = (int)floor(sqrt(x));
  return (x-1)/2;
}
int main()
{
  long long int n;
  cin>>n;
  map<long long int,int> m;
  long long int N = n;
  for(long long int i = 2;i*i<=N;i++)
  {
    while(n%i == 0)
    {
      // cout<<i<<" "<<"YES"<<endl;
      n = n/i;
      m[i] += 1;
    }
  }
  if (n!=1)
  {
    m[n] += 1;
  }
  int count = 0;
  for(pair<long long int ,int >p:m)
  {
    count += get_NumTimes(p.second);
  }
  cout<<count<<"\n";
  return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 500005
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n)
 
#define ll 	  long long 
 
#define mod  1000000007
 
 ll h , w , t;
ll x , y;
ll a[MAXX];
ll b[MAXX];

int main()
{
	FAST;
	cin >> h >> w >> t;
    map<ll , bool> m;
    while(t--){
        cin >> x >> y;
        a[x]++;
        b[y]++;
        ll k = (x - 1) * w + y;
        m[k] = true;
    }
    vector<pair<ll , ll> > v;
    for(ll i = 1; i <= h; i++){
        v.push_back({a[i] , i});
    }
    vector<pair<ll , ll> > p;
    for(ll i = 1; i <= w; i++){
        p.push_back({b[i] , i});
    }
    sort(v.begin() , v.end());
    reverse(v.begin() , v.end());
    sort(p.begin() , p.end());
    reverse(p.begin() , p.end());
    x = v[0].first;
    y = p[0].first;
    ll k = x + y;
    ll ans = k - 1;
    for(ll i = 0; i < v.size(); i++){
        bool f = false;
        for(ll j = 0; j < p.size(); j++){
            ll c = v[i].first;
            ll d = p[j].first;
            if(d < y){
                break;
            }
            if(c < x){
                f = true;
                break;
            }
            c = v[i].second;
            d = p[j].second;
            ll sum = (c - 1) * w + d;
            if(m[sum] == false){
                ans++;
                f = true;
                break;
            }
        }
        if(f == true){
            break;
        }
    }
    int h2 = 0;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 43688
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
int i[11111111];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  string s;
  cin >>a;
  for(int n=1;n<=inf;n++){
    d+=n;
    if(a<=d){
      e=n;
      break;
    }
  }
  cout <<e<<'\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++)
int main(){
  int n,ans,b; cin>>n; ans=0;
  vector<int> a(n); rep(i,n) cin>>a[i];
  rep(i,n) {cin>>b; ans+=b;}
  vector<int> c(n-1); rep(i,n-1) cin>>c[i];
  
  rep(i,n-1) if(a[i]+1==a[i+1]) ans+=c[a[i]-1];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n;
	cin >> n;
	vector<int> v(n);
	r(i,n) cin >>v.at(i);
  sort(v.begin(),v.end());
  cout << abs(v.at(0)-v.at(n-1)) << endl;

}


Measured memory_bytes: 256
from time import time
from math import factorial

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    N = int(input())
    s = []
    answer = 0
    for i in range(N):
        s.append(input())
        s[i] = ''.join(sorted(s[i]))

    d = {}
    for i in s:
        if i in d.keys():
            d[i] += 1
        else:
            d[i] = 1

    for i in d.values():
        if i >= 2:
            answer += combinations_count(i, 2)


    print(answer)

if __name__ == '__main__':
    start = time()
    main()
    # print(time() - start)



Measured memory_bytes: 19508
import numpy as np
N, M, C = map(int, input().split())
B = np.array([int(b) for b in input().split()])
A = []
for _ in range(N):
    A.append([int(a) for a in input().split()])

A = np.array(A)
print((np.dot(A, B) + C > 0).sum())

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	int n,k;
	cin>>n>>k;
	int a[200010];
	for (int i = 0; i < n; ++i){
		cin>>a[i];
	}

	sort(a,a+n);
	vector<int> v;

	int sum=1;
	for (int i = 1; i < n; ++i){
		if(a[i-1]==a[i]){
			sum++;
		}else{
			v.push_back(sum);
			sum=1;
		}
	}

	v.push_back(sum);
	sort(all(v));

	int ans=0;
	if(v.size()>k){
		for (int i = 0; i < v.size()-k; ++i){
			ans+=v[i];
		}
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 2168
s = list(input())

flag = 0

for i in range(len(s)):
    if (i+1)%2==0:
        if s[i] == 'R':
            flag = 1
    else:
        if s[i] == 'L':
            flag = 1


if flag == 1:
    print('No')
else:
    print('Yes')


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

using namespace std;

typedef long long ll;

int main(){
  string S; cin >> S;
  ll N = S.length(); 
  ll ans = 0;
  for(ll i = 0; i < ( 1 << N - 1); i++){
 
    ll sm = 0;  ll a = S[0] - '0';
    for(ll j = 0; j < N - 1; j++){
      if( i & ( 1 << j)){ sm += a; a = 0;}
      a = a * 10 + S[j + 1] - '0';}
    sm += a;
    ans += sm;}
  cout << ans << endl; return 0;}
                    

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const ll pos = replacedStr.find(from);
    const ll len = from.length();
 
    if (pos == (ll)std::string::npos || from.empty()) {
        return replacedStr;
    }
 
    return replacedStr.replace(pos, len, to);
}


signed main() {
    string s;
    cin >> s;
    
    stack<char> stk;
    
    rep(i, (ll)s.length()) {
        if (stk.empty()) {
            stk.push(s[i]);
        } else {
            if (stk.top() == 'S' && s[i] == 'T') {
                stk.pop();
            } else {
                stk.push(s[i]);
            }
        }
    }
    mes(stk.size());
    re0;
    
    
    
}

Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;


int main()
{
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    ll* x = new ll[N];
    ll* y = new ll[M];
    for(ll i = 0; i < N; i ++){
        cin >> x[i];
    }
    for(ll i = 0; i < M; i ++){
        cin >> y[i];
    }

    sort(x, x + N);
    sort(y, y + M);
    if(x[N - 1] < y[0] && X < y[0] && Y > x[N - 1]){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;


int main()
{
	int n;
	cin>>n;
	map<int,int> numMap;
	rep(i,n){
		int num;
		cin>>num;
		if( numMap.count(num) == 0){
			numMap.insert(make_pair(num,1));
		}else{
			numMap[num]++;
		}
	}
	ll ans = 0;
	for(auto iter = numMap.begin(); iter != numMap.end(); iter++){
		if(iter->second % 2 != 0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4992
a1, a2, a3 = map(int, input().split())
c1 = abs(a1 - a2) + abs(a2 - a3)
c2 = abs(a1 - a3) + abs(a3 - a2)
c3 = abs(a2 - a1) + abs(a1 - a3)
c4 = abs(a2 - a3) + abs(a3 - a1)
c5 = abs(a3 - a1) + abs(a1 - a2)
c6 = abs(a3 - a2) + abs(a2 - a1)
print(min([c1, c2, c3, c4, c5, c6]))

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, a[200000];
unordered_map<int, int> c;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  if (n % 3 != 0) {
    for (int i = 0; i < n; i++)
      if (a[i] != 0) {
        cout << "No\n";
        return 0;
      }
    cout << "Yes\n";
    return 0;
  }
  vector<int> num;
  for (int i = 0; i < n; i++) {
    c[a[i]]++;
  }
  for (auto it : c) {
    if (it.second % (n / 3) != 0) {
      cout << "No\n";
      return 0;
    }
    for (int i = 0; i < (it.second / (n / 3)); i++)
      num.push_back(it.first);
  }
  if ((num[0] ^ num[1]) != num[2] || (num[0] ^ num[2]) != num[1] || (num[1] ^ num[2]) != num[0]) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
}


Measured memory_bytes: 4004
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;


int n,a,b,c,d;
string s;

bool can_reach(int start, int end){
    for(int i = start; i+1 <= end; i++){
        if(s[i] == '#' && s[i+1] == '#') return false;
    }
    return true;
}

int main(){
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    a--;
    b--;
    c--;
    d--;

    s = '#' + s + '#';

    if(!can_reach(a,c) || !can_reach(b,d)){
        cout << "No" << endl;
        return 0;
    }

    if(c > d){
        bool check = false;;
        for(int i = b; i <= d; i++){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                check = true;
                break;
            }
        }
        if(!check){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 960
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)


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

    if(u == s){
        a -= 1;
    }else if(u == t){
        b -= 1;
    }

    cout << a << " " << b << endl;





	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n;
int c[601],s[601],f[601];
int dist[601];

int dijk(int sv){
	int ans=0;
	for(int i=sv;i<n-1;i++){
		if(ans<s[i]){
			ans=s[i]+c[i];
		}else{
			int v=s[i];
			while(ans>v){
				v+=f[i];
			}
			ans=v+c[i];
		}
	}
	return ans;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		scanf("%d%d%d",&c[i],&s[i],&f[i]);
	}
	for(int i=0;i<n;i++){
		printf("%d\n",dijk(i));
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    from collections import Counter
    n=int(input())
    a=Counter(map(int,input().split()))
    mod=10**9+7

    if n%2==1:
        if 0 not in a:
            print(0)
            exit()
        else:
            if a[0]!=1:
                print(0)
                exit()
            else:
                a[0]=2
    
    for k,v in a.items():
        if v!=2 or (n-k-1)%2==1:
            print(0)
            exit()
            
    print(2**(n//2)%mod)  
if __name__=='__main__':
    main()

Measured memory_bytes: 16624
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    long long K;
    cin >> S >> K;
    
    vector<int> renzoku;
    int cnt = 1;
    REP(i, S.size()) {
        if (S[i - 1] != S[i]) {
            renzoku.push_back(cnt);
            cnt = 1;
        } else {
            ++cnt;
        }
    }
    renzoku.push_back(cnt);
    
    if (renzoku.size() == 1) {
        cout << renzoku[0] * K / 2 << endl;
        return 0;
    }
    long long ans = 0;
    if (S[0] == S[S.size() - 1]) {
        ans += renzoku[0] / 2;
        ans += renzoku[renzoku.size() - 1] / 2;
        ans += (renzoku[0] + renzoku[renzoku.size() - 1]) / 2 * (K - 1);
        REP(i, renzoku.size() - 1) ans += renzoku[i] / 2 * K;
    } else {
        for (int x : renzoku) ans += x / 2 * K;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {

int i,j,r,c,s;

cin >> r >> c;

vector<vector<int> > a(r,vector<int>(c));

for(i=0;i<=r-1;++i){
for(j=0;j<=c-1;++j){
cin >> a.at(i).at(j);
}
}

for(i=0;i<=r-1;++i){
s=0;
for(j=0;j<=c-1;++j){
cout << a.at(i).at(j) << " ";
s += a.at(i).at(j);
}
cout << s << endl;
}

for(j=0;j<=c-1;++j){
s=0;
for(i=0;i<=r-1;++i){
s += a.at(i).at(j);
}
cout << s << " ";
}

s=0;

for(i=0;i<=r-1;++i){
for(j=0;j<=c-1;++j){
s += a.at(i).at(j);
}
}

cout << s << endl;

}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;

int main() {
    int n;
    cin >> n;
    vector<ll> as(n);
    rep(i, n) cin >> as[i];
    sort(all(as));
    ll tot = 0;
    int lc = 0;
    rep(i, n-1) {
        tot += as[i];
        if (2*tot < as[i+1]) lc = i+1;
    }
    int ret = n - lc;
    cout << ret << endl;
    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll ret = n * (n + 1) / 2 - (n / 3) * (n / 3 + 1) / 2 * 3 - (n / 5) * (n / 5 + 1) / 2 * 5 + (n / 15) * (n / 15 + 1) / 2 * 15;
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=0;
  rep1(i,a){
  if(b<=ketawa(i)&&ketawa(i)<=c){
  d+=i;
  }
  }
  out(d);
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i= 0; i<3; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        
        System.out.println(a[0]+a[1]);
    }
}

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

int main()
{
	int h, m, s, h3, m3, s3, t, t3;
	
	while (cin>>h>>m>>s)
	{
		if ((h == -1) && (m = -1) && (s == -1)) break;
		//cout << setfill('0') << setw(2) << h << endl;
		t = 7200;	//通常録画前の残り時間

		t =t-(h*3600 + m*60 + s);		//録画後の残り時間

		t3 = t * 3;		//3倍録画後の残り時間

		h = t / 3600;
		m = (t % 3600) / 60;
		s = t % 3600 % 60;

		h3 = t3 / 3600;
		m3 = (t3 % 3600) / 60;
		s3 = t3 % 3600 % 60;
		
		cout << setfill('0') << setw(2) << h << ":" << setfill('0') << setw(2) << m << ":" << setfill('0') << setw(2) << s << endl;
		cout << setfill('0') << setw(2) << h3 << ":" << setfill('0') << setw(2) << m3 << ":" << setfill('0') << setw(2) << s3 << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
from enum import Enum, auto
from collections import deque

class Color(Enum):
    WHITE = auto()
    GRAY = auto()
    BLACK = auto()

class BinaryTreeNode():
    def __init__(self, parent=None, left=None, right=None):
        self.parent = parent
        self.left = left
        self.right = right
        self.sibling = None
        self.color = Color.WHITE

def print_elements(ordered):
    for ele in ordered:
        print(' {}'.format(ele), end='')
    print('')

n = int(input())
nodes = [BinaryTreeNode() for i in range(n)]
for i in range(n):
    id, left, right = list(map(int, input().split(' ')))
    if left != -1:
        nodes[id].left = left
        nodes[left].parent = id
        nodes[left].sibling = right
    if right != -1:
        nodes[id].right = right
        nodes[right].parent = id
        nodes[right].sibling = left

root = 0
for i in range(n):
    if nodes[i].parent == None:
        root = i

def init_color():
    global nodes
    for i in range(len(nodes)):
        nodes[i].color = Color.WHITE

def preorder_bfs(s):
    preordered.append(s)
    nodes[s].color = Color.GRAY
    if nodes[s].left != None and nodes[nodes[s].left].color == Color.WHITE:
        preorder_bfs(nodes[s].left)
    if nodes[s].right != None and nodes[nodes[s].right].color == Color.WHITE:
        preorder_bfs(nodes[s].right)
    nodes[s].color = Color.BLACK

inorder_stack = deque([])
def inorder_dfs_init(s):
    init_color()
    inorder_stack.append(s)
    inorder_dfs()

def inorder_dfs():
    u = inorder_stack.pop()
    if nodes[u].left != None and nodes[nodes[u].left].color == Color.WHITE:
        inorder_stack.append(u)
        inorder_stack.append(nodes[u].left)
        inorder_dfs()
    inordered.append(u)
    if nodes[u].right != None and nodes[nodes[u].right].color == Color.WHITE:
        inorder_stack.append(nodes[u].right)
        inorder_dfs()

postorder_stack = deque([])
def postorder_dfs_init(s):
    init_color()
    postorder_stack.append(s)
    postorder_dfs()

def postorder_dfs():
    u = postorder_stack.pop()
    if nodes[u].left != None and nodes[nodes[u].left].color == Color.WHITE:
        postorder_stack.append(u)
        postorder_stack.append(nodes[u].left)
        postorder_dfs()
    if nodes[u].right != None and nodes[nodes[u].right].color == Color.WHITE:
        postorder_stack.append(nodes[u].right)
        postorder_dfs()
    postordered.append(u)

print('Preorder') # 根節点、左部分木、右部分木の順
preordered = []
preorder_bfs(root)
print_elements(preordered)

print('Inorder') # 左部分木、根節点、右部分木の順
inordered = []
inorder_dfs_init(root)
print_elements(inordered)

print('Postorder') # 左部分木、右部分木、根節点の順
postordered = []
postorder_dfs_init(root)
print_elements(postordered)



Measured memory_bytes: 6360
#include<iostream>
#include<map>
#include<stdio.h>
using namespace std;

int main(){
	map<char, int> cup;
	char s1, s2, hoge;
	cup['A'] = 1;
	cup['B'] = cup['C'] = 0;
	while(cin >> s1 >> hoge >> s2){
		swap(cup[s1], cup[s2]);
	}
	for(char i = 'A'; i <= 'C'; i++){
		if(cup[i]) cout << i << endl;
	}
}

Measured memory_bytes: 1168
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        Map<Integer, Integer> num = new HashMap<>();
        for (int i = 0; i < 4; ++i) {
            int current = str.charAt(i) - 'A';
            int count = num.getOrDefault(current, 0);
            num.put(current, count + 1);
        }
        if (num.size() == 2) {
            for (int value : num.values()) {
                if (value != 2) {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


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

using namespace std;
typedef string::const_iterator iter;

int expr(iter &p);
int term(iter& p);
int factor(iter& p);
int number(iter& p);

int expr(iter& p) {
    int r = term(p);
    while(true) {
        if(*p == '+') {
            ++p;
            int rs = term(p);
            r += rs;
        }
        else if(*p == '-') {
            ++p;
            int rs = term(p);
            r -= rs;
        }
        else {
            break;
        }
    }
    return r;
}

int term(iter& p) {
    int r = factor(p);
    while(true) {
        if(*p == '*') {
            p++;
            int rs = factor(p);
            r *= rs;
        }
        else if(*p == '/') {
            p++;
            int rs = factor(p);
            r /= rs;
        }
        else {
            break;
        }
    }
    return r;
}

int factor(iter& p) {
    if(*p == '(') {
        ++p; // skip (
        int r = expr(p);
        ++p; // skip )
        return r;
    }
    
    return number(p);
}

int number(iter& p) {
    int r = 0;
    while(isdigit(*p)) {
        r *= 10;
        r += *p -'0';
        p++;
    }
    return r;
}

int main() {
    int n; cin >> n;
    while(n--) {
        string s; cin >> s;
        iter it = s.begin();
        int res = expr(it);
        cout << res << endl;
    }
}

Measured memory_bytes: 1208
#include<iostream>
#include<queue>
using namespace std;
const int SIZE=1024;
struct node{
	int x,y,z,k;
	node(int x1,int x2,int x3,int x4){
		x=x1;
		y=x2;
		z=x3;
		k=x4;
	}
};
int n,m,a[SIZE][SIZE],curr;
queue<node> st;
int main(){
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		int op=i&1;
		if(op){
			for(int j=1;j<=m;j++){
				if(!curr&&!(a[i][j]&1)){
					continue;
				}
				a[i][j]+=curr;
				if(a[i][j]&1){
					curr=1;
					if(j==m){
						if(i==n){
							break;
						}
						st.push(node(i,j,i+1,m));
					}else{
						st.push(node(i,j,i,j+1));
					}
				}else{
					curr=0;
				}
			}
		}else{
			for(int j=m;j>=1;j--){
				if(!curr&&!(a[i][j]&1)){
					continue;
				}
				a[i][j]+=curr;
				if(a[i][j]&1){
					curr=1;
					if(j==1){
						if(i==n){
							break;
						}
						st.push(node(i,j,i+1,1));
					}else{
						st.push(node(i,j,i,j-1));
					}
				}else{
					curr=0;
				}
			}
		}
	}
	cout << st.size() << endl;
	while(st.size()){
		node ii=st.front();
		st.pop();
		cout << ii.x << ' ' << ii.y << ' ' << ii.z << ' ' << ii.k << endl;
	}
	return 0;
} 

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, A;
    cin >> N >> A;
    N %= 500;
    cout << (N <= A ? "Yes" : "No") << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    if (N % 2 == 1) {
      cout << "No" << endl;
    } else {
      string T = S.substr(0, N / 2);
      cout << (S == T + T ? "Yes" : "No") << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp

if s == 'SUN'
  puts 7
elsif s == 'SAT'
  puts 1
elsif s == 'FRI'
  puts 2
elsif s == 'THU'
  puts 3
elsif s == 'WED'
  puts 4
elsif s == 'TUE'
  puts 5
elsif s == 'MON'
  puts 6
end

Measured memory_bytes: 1788
s = input()
t = input()
l = []
for i in range(len(s)-len(t) + 1):
    cnt = 0
    w = s[i:i+len(t)]
    for d in range(len(t)):
        if t[d] == w[d]:
            cnt += 1
    l.append(cnt)
print(len(t) - max(l))

Measured memory_bytes: 9104
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();

        sc.close();

        int ans = (a + b) * h / 2;

        System.out.println(ans);

    }
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

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

    int n;
    int x;
    cin >> n >> x;
    vector<int> a(n);
    for (int &w : a)
        cin >> w;
    sort(all(a));
    int cnt = 0;
    for (int w : a) {
        if (w <= x) {
            x -= w;
            ++cnt;
        } else {
            break;
        }
    }
    if (cnt == n && x != 0)
        --cnt;
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256