akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_6_c
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = "####################";
			string[] t;
			List<int> list0 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list1 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list2 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list3 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list4 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list5 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list6 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list7 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list8 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list9 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list10 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
			List<int> list11 = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

			List<List<int>> lista = new List<List<int>>();//1棟目
			lista.Add(list0);
			lista.Add(list1);
			lista.Add(list2);

			List<List<int>> listb = new List<List<int>>();//2棟目
			listb.Add(list3);
			listb.Add(list4);
			listb.Add(list5);

			List<List<int>> listc = new List<List<int>>();//3棟目
			listc.Add(list6);
			listc.Add(list7);
			listc.Add(list8);

			List<List<int>> listd = new List<List<int>>();//4棟目
			listd.Add(list9);
			listd.Add(list10);
			listd.Add(list11);

			for (int i = 0; i < n; i++)
			{
				t = Console.ReadLine().Split(' ');

				int a = int.Parse(t[0]);//棟数
				int b = int.Parse(t[1]);//階数
				int c = int.Parse(t[2]);//部屋番号
				int d = int.Parse(t[3]);//増減人数
				int e = b - 1;
				int f = c - 1;

				if (a == 1)
				{
					lista[e][f] = lista[e][f] + d;
				}
				else if (a == 2)
				{
					listb[e][f] = listb[e][f] + d;
				}
				else if (a == 3)
				{
					listc[e][f] = listc[e][f] + d;
				}
				else
				{
					listd[e][f] = listd[e][f] + d;
				}
			}

			///　以下, 出力部分のみまとめてみました
			///　To前川さん: あくまでもコンパクトにまとめただけなので
			///　前川さんが書いてくれたコードそのものと内容は変わりません.
			for (int i = 0; i < 4; ++i) /// 棟数分のループ
			{
				for (int j = 0; j < 3; ++j) /// フロア数分のループ
				{
					for (int k = 0; k < 10; ++k) /// 部屋数分のループ
					{
						if (i == 0) // 1棟目のとき
						{
							Console.Write(" ");
							Console.Write(lista[j][k]);
						}
						else if (i == 1) // 2棟目のとき
						{
							Console.Write(" ");
							Console.Write(listb[j][k]);
						}
						else if (i == 2) // 3棟目のとき
						{
							Console.Write(" ");
							Console.Write(listc[j][k]);
						}
						else if (i == 3) // 4棟目のとき
						{
							Console.Write(" ");
							Console.Write(listd[j][k]);
						}
					}
					Console.Write('\n');
				}
				if (i != 3)
				{
					Console.Write(s);
					Console.Write('\n');
				}
			}
			Console.ReadKey();
		}
	}
}



Measured memory_bytes: 17976
function Main(input) {
    function Heap () {
        this.heap = new Array();
        this.size = 0;
    }
    Heap.prototype.push = function (val) {
        var k = this.size++;
    
        while( 0 < k ) {
            var p = Math.floor( (k - 1) / 2 );
            
            if( this.heap[p] <= val ) break; //★
            
            this.heap[k] = this.heap[p];
            k = p;
        }
        this.heap[k] = val;
    }
    Heap.prototype.pop = function () {
        var ret = this.heap[0];
        var x = this.heap[--this.size];
        
        var k = 0;
        while( k * 2 + 1 < this.size ) {
            var a = k * 2 + 1;
            var b = k * 2 + 2;
            if( b < this.size && this.heap[b] < this.heap[a] ) a = b;
            
            if( x <= this.heap[a] ) break; //★
    
            this.heap[k] = this.heap[a];
            k = a;
        }
        this.heap[k] = x;
        return ret;
    }
    Heap.prototype.top = function () {
        return this.heap[0];
    }
    Heap.prototype.size = function () {
        return this.size;
    }
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
    var lVl = parseInt(input[0][0]);
    var lEl = parseInt(input[0][1]);
    var r = parseInt(input[0][2]);
    var graph = Array.from({length: lVl}, () => []);
    var line;
    for (var i = 0; i < lEl; i++){
        line = input[i + 1].map(e => parseInt(e, 10));
        graph[line[0]].push([line[1], line [2]]);
        // graph[line[1]].push([line[0], line [2]]);
    }
    
    var q = new Heap();
    var tmpDList1 = [];
    tmpDList1[0] = [r];
    ansList = Array.from({length: lVl}, () => Number.MAX_SAFE_INTEGER);
    // var tmpDList2 = Array.from({length: lVl}, () => Number.MAX_SAFE_INTEGER);
    // tmpDList2[r] = 0;
    q.push(0);
    var fixedD, fixedNode;
    while (true){
        // console.log(q);
        fixedD = q.pop();
        fixedNode = tmpDList1[fixedD].pop();
        if (ansList[fixedNode] > fixedD) {
            ansList[fixedNode] = fixedD;
            for (var x of graph[fixedNode]){
                if (tmpDList1[x[1] + fixedD] == null ) tmpDList1[x[1] + fixedD] = [x[0]];
                else tmpDList1[x[1] + fixedD].push(x[0]);
                q.push(x[1] + fixedD);
            }
        }
        if (q.size === 0) break;
        // console.log(ansList);
        // console.log(tmpDList1);
    }
    var ans = ansList.map(e => {
        if (e === Number.MAX_SAFE_INTEGER) return "INF";
        else return e.toString(10);
    })

    console.log(ans.join("\n"));

}

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


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

int main(){

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }

    vector<int> M(N);

    int min = N+1;
    for (int i=0; i<N; i++){
        if (A.at(i) < min){
            min = A.at(i);
        }
        M.at(i) = min;
    }

    int count = 0;
    for (int i=0; i<N; i++){
        if (A.at(i) == M.at(i)){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> t(n), a(n);
  rep(i, n) cin >> t[i];
  rep(i, n) cin >> a[i];

  vector<P> l(n), r(n);
  reverse(ALL(a));

  l[0] = make_pair(t[0], t[0]+1);
  for(int i = 1; i < n; ++i) {
    l[i].second = t[i]+1;
    if(t[i-1] == t[i]) l[i].first = 1;
    else l[i].first = t[i];
  }

  r[0] = make_pair(a[0], a[0]+1);
  for(int i = 1; i < n; ++i) {
    r[i].second = a[i]+1;
    if(a[i-1] == a[i]) r[i].first = 1;
    else r[i].first = a[i];
  }

  reverse(ALL(r));

  mint ans = 1;

  rep(i, n) {
    if(min(l[i].second, r[i].second) - max(l[i].first, r[i].first) <= 0) {
      cout << 0 << endl;
      return 0;
    }
    ans *= min(l[i].second, r[i].second) - max(l[i].first, r[i].first);
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 2560
let st = stdin.ReadLine().Split()
let ab = stdin.ReadLine().Split() |> Array.map int
let u = stdin.ReadLine()
if u = st.[0] then (ab.[0] - 1, ab.[1]) else (ab.[0], ab.[1] - 1)
|> (fun (a, b) -> printf "%d %d" a b)

Measured memory_bytes: 13916
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = int(0)
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50 == X:
                ans+=1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

string a;
int main(){
    cin >> a;
    ll n = a.size();
    ll res = n*(n-1)/2;
    vector<ll> c(26,0);
    REP(i,n){
        c[(int)a[i]-(int)'a']++;
    }
    REP(i,26){
        res -= c[i]*(c[i]-1)/2;
    }
    put(res+1);
    return 0;
}


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


typedef long long ll;

int N,M,H,W,K,A,B,S,T;
int a,b;

using namespace std;

int gcd(int n,int m) {
  if(m == n) return m;
  int q = n%m;
  if(q == 0) return m;
  return gcd(m,q);
}

int main() {
  int c,temp,ans = 0;  
  cin >> N;
  vector<int> an(N,0),bn = {},cn = {};
  for(int i = 0; i < N; i++) cin >> an.at(i);
  for(int i = 0; i <N-1; i++) {
      if(i == 0) {
        a = an.at(0);
        bn.push_back(a);
        continue;
      }

      b = an.at(i);
      if(b > a) {
        c = a;
        a = b;
        b = c;
      }
      a = gcd(a,b);
      bn.push_back(a);
  }
  for(int i = N-1; i > 0 ; i--) {
    if(i == N-1) {
        a = an.at(i);
        cn.push_back(a);
        continue;
      }

      b = an.at(i);
      if(b > a) {
        c = a;
        a = b;
        b = c;
      }
      a = gcd(a,b);
      cn.push_back(a);
  }
  int k;
  for(int i = 0; i < N-2; i++) {
    k = N-3-i;
    a = bn.at(i);
    b = cn.at(k);
    if(b > a) {
        c = a;
        a = b;
        b = c;
    }
    temp = gcd(a,b);
    ans = max(ans,temp);
  }
  if(N != 2) {
    ans = max(ans,bn.at(N-2));
    ans = max(ans,cn.at(N-2));
  }
  if(N == 2) {
    temp = max(bn.at(0),cn.at(0));
    ans = max(ans,temp);
  }
  //cout << bn.at(0)<< bn.at(1)<< cn.at(0)<< cn.at(1) << endl;
  cout << ans << endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;


int main(){
    ll n; cin >> n;
    ll res = 0;
    for(int i=1;i<n;i++){
        res += (n-1)/i;
    }
    cout << res << endl;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;

	vector<int> nE(N);
	vector<int> nW(N);
	for (int i = 0; i < N; i++) {
		if (S[i] == 'E') nE[i]++;
		if (S[i] == 'W') nW[i]++;
	}

	for (int i = 1; i < N; i++) {
		nE[i] += nE[i - 1];
		nW[i] += nW[i - 1];
	}

	int ans = N;
	for (int i = 0; i < N; i++) {
		int buf = 0;
		if (i > 0) buf += nW[i - 1];
		if (i < N - 1) buf += nE[N - 1] - nE[i];
		ans = min(ans, buf);
	}

	cout << ans << endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include <algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
using LL = long long;
using namespace std;

const int M = 2e5 + 100;
const int mod = 1e9 + 7;

vector<int> e[M];
long long n, sz[M], ans[M];
long long fac[M], inv[M];

LL mul(LL a, LL b) {
	return a * b % mod;
}

void init() {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = mul(fac[i - 1], i);
	inv[1] = 1;
	for (int i = 2; i <= n; i++)
		inv[i] = mul((mod - mod / i), inv[mod % i]);
}

void dfs(int u, int fa) {
	sz[u] = 1;
	for (int v : e[u]) {
		if (v != fa) {
			dfs(v, u);
			sz[u] += sz[v];
		}
	}
}

void reroot(int u, int fa) {
	ans[u] = mul(mul(ans[fa], sz[u]), inv[n - sz[u]]);
	for (int v : e[u]) {
		if (v != fa) {
			reroot(v, u);
		}
	}
}

int main() {
	cin >> n;
	init();
	for (int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1, 0);
	ans[1] = fac[n];
	for (int i = 1; i <= n; i++)
		ans[1] =  ans[1] *inv[ sz[i]] % mod;
	for (int v : e[1]) reroot(v, 1);
	for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 20212
import math
import bisect
import collections
import itertools
import heapq
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
b = iln()
ans = []
for _ in range(N):
    if len(b) == 0: break
    matched = -1
    for j in range(0, len(b)):
        if b[j] == j+1: matched = j
    if matched != -1:
        ans.append(b.pop(matched))
    else:
        ans.clear()
        break
if len(ans) > 0:
    for _ in range(len(ans)):
        print(ans.pop())
else:
    print(-1)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
    int N;
    cin>>N;
    vector<int>X(N);
    rep(i,N){
        cin>>X[i];
    }
  	vector<int>Y(N);
  rep(i,N){
    Y[i]=X[i];
  }
  	sort(X.begin(),X.end());
        int mi=X[N/2-1];
        int ma=X[N/2];
        rep(i,N){
            if(ma<=Y[i]){
                cout<<mi<<endl;
            }
            else{
                cout<<ma<<endl;
            }
        }
    }


Measured memory_bytes: 4732
#include <iostream>
#define ll long long

using namespace std;
const int N=455;
ll dp[N][N];
ll pre[N];
ll a[N];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    pre[0]=a[0];
    for(int i=1;i<n;i++)
        pre[i]=pre[i-1]+a[i];
    for(int i=0,j=0,k=0;k<n;i++,j++)
    {
        if(j==n)
        {
            i=0;
            k++;
            j=k;
        }
        if(i==j)
            continue ;
        dp[i][j]=1e18;
        for(int c=1;c<=j-i;c++)
        {
            dp[i][j]=min(dp[i][j],dp[i][j-c]+dp[i+((j-i)-c)+1][j]);

        }
        dp[i][j]+=pre[j];
        if(i)
            dp[i][j]-=pre[i-1];
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1664
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[10000],a[300000], b[300000];
string str[2], ss;
bool f[200];
char c, ch[100][100];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<Pll,LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL gcd(LL a, LL b) {
	if (a < b) gcd(b, a);
	LL r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return a * b / gcd(a, b);
}

int main() {
	cin >> n >> m;
	cin >> str[0];
	cin >> str[1];
	h=gcd(n,m);
	rep(i,h) {
		if (str[0][n / h*i] != str[1][m / h*i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << lcm(n,m) << endl;
	return 0;
}
// 5/15 3/9


Measured memory_bytes: 6656
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        long sum = 0;
        List<Integer> list = new ArrayList<Integer>();
        if (s[0] == '>') {
            list.add(0);
        }
        int t = 1;
        for (int i = 0 ; i < s.length - 1 ; i++) {
            if (s[i] == s[i + 1]) {
                t++;
            } else {
                list.add(t);
                t = 1;
            }

        }
        list.add(t);
        if (s[s.length-1] == '<') {
            list.add(0);
        }
        for (int i = 0 ; i < list.size() ; i += 2) {
            int a = list.get(i);
            int b = list.get(i + 1);
            int max = Math.max(a, b);
            int min = Math.min(a, b);
            sum += (long) max * (max + 1) / 2 + min * (min - 1)/2;

        }


        System.out.println(sum);
    }

}

Measured memory_bytes: 33008
n = int(input().split()[0])

str_n = str(n)
keta = len(str_n)

c = 0
keta_list = list(range(0, 6))
keta_list.reverse()

# 1の桁
if 1 <= n < 10:
    c += n
else:
    c += 9

# 100の桁
if n >= 100:
    # 100 - 999
    if n <= 999:
        # print('100 - 999')
        c += (n - 99)
    else:
        # 1000 -
        # print('100 -')
        c += 900 # 100から999 までの数

# 10000の桁
if n >= 10000:
    if n <= 99999:
        # 10000 - 99999
        # print('10000 - 99999')
        # print('+ {}'.format(n-9999))
        c += n - 9999
    else:
        # 10000以上
        # print('10000以上')
        c += 90000 # 1000から99999までの個数

print(c)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

class program
{
    public static void Main()
    {
        while (true)
        {
            var strs = Console.ReadLine().Split(' ');

            var n = int.Parse(strs[0]);
            var x = int.Parse(strs[1]);

            if (n + x == 0) break;

            int count = 0;
            for (int i = 1; i <= n - 2; i++)
            {
                for (int j = i + 1; j <= n - 1; j++)
                {
                    for (int k = j + 1; k <= n; k++)
                    {
                        if (i + j + k == x) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 5624
#include<algorithm>
#include<iostream>
using namespace std;
int x[101],y[101];
int main()
{
	int n,m;
	int X,Y;
	cin>>n>>m>>X>>Y;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	x[++n]=X;
	sort(x+1,x+n+1);
	int z=x[n]+1;
	for(int i=1;i<=m;i++)
	{
		cin>>y[i];
	}
	sort(y+1,y+m+1);
	if(z>y[1]||z>Y)
	{
		cout<<"War";
		return 0;
	}
	cout<<"No War";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string x, y;
  cin >> x >> y;
  
  if (x > y){
    cout << ">" << endl;
  }else if (x < y){
    cout << "<" << endl;
  }else {
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll h,w;
    cin >> h >> w;
    vector<vector<char>> c(h,vector<char>(w));
    vector<ll> p(h),q(w);
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    rep(i,h){
        bool ok=true;
        rep(j,w){
            if(c[i][j]=='#') ok=false;
        }
        if(ok) p[i]=1;
    }
    rep(i,w){
        bool ok=true;
        rep(j,h){
            if(c[j][i]=='#') ok=false;
        }
        if(ok) q[i]=1;
    }
    rep(i,h){
        rep(j,w){
            if(p[i]==1 || q[j]==1){
                continue;
            }
            cout << c[i][j];
        }
        if(p[i]==0) cout << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s1[105],s2[105];
	scanf("%s%s",s1,s2);
	int i,j;
	char t;
	int n=strlen(s1);
	for(i=0;i<n;i++)
	{
		if(strcmp(s1,s2)==0)
		{
			printf("Yes\n");
			return 0;
		}
		t=s1[n-1];
		for(j=0;j<n;j++)
		{
			s1[n-1-j]=s1[n-2-j];
		}
		s1[0]=t;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
const double PI = acos(-1);
double radTodeg(double rad){
    double deg = rad * 180 / PI;
    return deg;
}
main(){
    double A,B,X;
    cin >> A >> B >> X;
    //if(A > B)return 0;
    double l = A * A * B;
    double rad;
    if(X >= l/2){
        //cout << "X > l/2" << endl;
        X = l - X;
        double b2 = 2 * X / (A * A);
        
        rad = atan2(b2, A);//y,x
        //cout << b2 << endl;
        //cout << rad << endl;
    
    }else{
        //cout << "X < l/2" << endl;
        double a2 = 2 * X / (A * B);
        rad = atan2(B, a2);
    }
    double deg = radTodeg(rad);
    printf("%.9lf\n",deg);
}

Measured memory_bytes: 384
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

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

        // 入力
        String n = sc.next();

        // 処理
        String out = "No";
        if(n.charAt(0) == '7' || n.charAt(1) == '7' || n.charAt(2) == '7'){
            out = "Yes";
        }

        // 出力
        System.out.println(out);
    }

}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

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

int main(void) {
  string s;
  cin >> s;

  sortall(s);
  if(s[2]=='A' || s[0]=='B'){
    prt("No");
  } else {
    prt("Yes");
  }
}


Measured memory_bytes: 256
#!/usr/bin/ruby                                                                                                                                   
# -*- coding: utf-8 -*-                                                                                                                           

cup = {:a => true, :b => false, :c => false}
while s = gets
  shuffle = s.chomp.split(',').map do|c|
    c.downcase
  end
  cup[shuffle[0].intern],cup[shuffle[1].intern] = cup[shuffle[1].intern],cup[shuffle[0].intern]
end

puts cup.select {|k, v| v}.keys[0].upcase

Measured memory_bytes: 6104
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string str;
    cin >> str;

    bool aflag = true;
    for(int i = a-1; i < c-1;i++ ){
        if(str[i] == '#' && str[i+1] == '#'){
            aflag = false;
        }
    }

    bool bflag = true;
    for(int i = b-1; i < d-1;i++ ){
        if(str[i] == '#' && str[i+1] == '#'){
            bflag = false;
        }
    }

    if(aflag && bflag){
        if(c < d){
            cout << "Yes" << endl;
        }else{
            bool triple = false;
            for(int i = b-2; i < d-1; i++){
                if(str[i] == '.' && str[i+1] == '.' && str[i+2] == '.'){
                    triple = true;
                }
            }
            if(triple){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
 
		System.out.println(Math.max(C - (A - B), 0));
		sc.close();

	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n==0) return 0;
        double x=0,a=0;
        int s[n];
        for(int i=0;i<n;++i){
            cin>>s[i];
            x+=s[i];
        }
        x/=n;
        for(int i=0;i<n;++i){
            a+=(s[i]-x)*(s[i]-x);
        }
        printf("%0.8f\n",sqrt(a/n));
    }
}



Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

const int MAX = 510000;

ll dp[100010][4];

ll pow_mod(ll n, ll x)
{
    ll res = 1;
    while (n > 0)
    {
        if ((n & 1) == 1)
        {
            res *= x;
            res %= MOD;
        }
        x = x * x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

ll a[100010], c[100010], q[100010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
    return 0;
}

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

// using namespace std;

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

constexpr int INF = 1001001001;

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

void Main() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> h(n);
    for (auto &hi : h) {
        std::cin >> hi;
    }

    std::vector<int> dp(n);
    for (auto &dpi : dp) {
        dpi = INF;
    }

    dp[0] = 0;
    for(int i = 0; i < n -1; ++i){
        for(int j = 1; j <= k; ++j){
            if(i+j > n-1)continue;
            chmin(dp[i+j], dp[i] + std::abs(h[i] - h[i+j]));
        }
    }
    std::cout << dp[n - 1] << std::endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
def sieve_of_eratosthenes(ub):
    # O(n loglog n) implementation.
    # returns prime numbers <= ub.
    if ub < 2:
        return []
    prime = [True]*(ub+1)
    prime[0] = False
    prime[1] = False
    p = 2
    while p*p <= ub:
        if prime[p]:
            # don't need to check p+1 ~ p^2-1 (they've already been checked).
            for i in range(p*p, ub+1, p):
                prime[i] = False
        p += 1
    return prime

Q = int(input())
primes = sieve_of_eratosthenes(10**5)
cum_sum = [0]*(10**5+1)
for i in range(1, 10**5+1):
    if primes[i] and primes[(i+1) // 2]:
        cum_sum[i] = cum_sum[i-1] + 1
    else:
        cum_sum[i] = cum_sum[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    ans = cum_sum[r] - cum_sum[l-1]
    print(ans)

Measured memory_bytes: 4980
#
def div(n): #約数を求める
 ret=[]
 for i in range(1,int(n**0.5)+1):
   if n%i==0:
     ret.append(i)
     if i!=n//i:
       ret.append(n//i)
 return ret

n,k=map(int,input().split())
arr=list(map(int,input().split()))
ans=1
d=div(sum(arr))
for val in d: #すべての約数について条件判定
 arr=sorted(arr,key=lambda x:x%val) #配列を、約数で割ったあまりが小さい順にソート
 parr=[] #配列の各要素を(x-arr[i]%x)足すときの操作回数
 narr=[] #配列の各要素をarr[i]%x引くときの操作回数
 for num in arr:
   narr.append(num%val)
   parr.append(val-num%val)
 for i in range(n-1): #上記の値の累積和を取る
   parr[i+1]+=parr[i]
   narr[i+1]+=narr[i]
 for i in range(n-1): #累積和を用いて条件判定
   ncnt=narr[i] #左からi番目の要素まで、各要素が約数の倍数になるように値を引くときの操作回数
   pcnt=parr[-1]-parr[i] #左からi+1番目の要素から右端の要素まで、各要素が約数の倍数になるように値を足すときの操作回数
   if ncnt!=pcnt: #足す回数と引く回数が一致していなければそもそも操作は不可能
     continue
   else:
     if pcnt<=k: #操作回数がK以下であればその約数は答えの候補になる
       ans=max(ans,val)
print(ans) #答えの候補となる約数の最大値が答えとなる


Measured memory_bytes: 3188
s=input()
ans=0
k=0
k2=[]
k1=[]
s1=""
i=0
while i<len(s) :
    for j in range(i,len(s)):
        if s1==s[i:j+1]:
            continue
        else:
            s1=s[i:j+1]
            #print(s1)
            ans+=1
            i=j
            break
    i+=1

        
    
if ans==0:
    ans=1


print(ans)

Measured memory_bytes: 3500
#include<cstdio>
#define R register
#define I inline
using namespace std;
const int S=503;
char s[S][S];
int f[S][S],g[S][S];
int main(){
	R int n,m,i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	for(i=1;i<=n;++i)
		f[i][1]=1,g[i][m]=1;
	for(i=1;i<=n;i+=2)
		for(j=2;j<m;++j)
			f[i][j]=1;
	for(i=2;i<=n;i+=2)
		for(j=2;j<m;++j)
			g[i][j]=1;
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			if(s[i][j]=='#')
				f[i][j]=g[i][j]=1;
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
			f[i][j]?putchar('#'):putchar('.');
		putchar('\n');
	}
	putchar('\n');
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
			g[i][j]?putchar('#'):putchar('.');
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] t = new int[N + 1];
        int [] x = new int[N + 1];
        int [] y = new int [N + 1];
        for (int i = 1 ; i <= N ; i++ ) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        //t とx + yのmod 2が等しくないとダメ・
        //t2 - t1秒間で (x2 - x1) + (y2 - y1)以上移動できないとダメ
        boolean isPossible = true;
        for (int i = 1 ; i <= N ; i++) {
            if (t[i] % 2 != (x[i] + y[i]) % 2) {
                isPossible = false;
                break;
            }
            if (t[i] - t[i -1] < Math.abs(x[i] - x[i -1]) + Math.abs(y[i] - y[i -1])) {
                isPossible = false;
                break;
            }
        }
        if (isPossible) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
    int R,G;
    cin >> R >> G;
    cout << 2*G - R <<endl;
}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n;
	cin >> n;
	vector<int> c(n-1),s(n-1),f(n-1);
	rep(i,n-1) cin >> c[i]>> s[i]>> f[i];

	rep(i,n-1){
		int x = 0;
		For(j,i,n-1){
			if(x<=s[j]) x = s[j]+c[j];
			else{
				x -=s[j];
				x = (x+f[j]-1)/f[j] *f[j];
				x+=s[j];
				x+=c[j];
			}
		}
		cout << x<<endl;
	}
	cout << 0 << endl;

}


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

int main(){
	
	char s[4];
	int b[2];
	int i;
	
	scanf("%s", &s);
	
	for(i = 0; i < 2; i++){
		if(s[i * 2] >= '2' || (s[i * 2] == '1' && s[i * 2 + 1] >= '3') || (s[i * 2] == '0' && s[i * 2 + 1] == '0'))
			b[i] = 0;
		else
			b[i] = 1;
	}
	
	if(b[0] == 1){
		if(b[1] == 1)
			printf("AMBIGUOUS");
		else
			printf("MMYY");
	}else{
		if(b[1] == 1)
			printf("YYMM");
		else
			printf("NA");
	}
	
	return 0;
}

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

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

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

const int inf = 1e18;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

const int N = 22;
int dp[(1 << N)], can[N][N], n;

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) cin >> can[i][j];
    }

    dp[0] = 1LL;
    for (int mask = 1; mask < (1 << n); mask++) {
        int j = __builtin_popcount(mask);
        for (int i = 0; i < n; i++) {
            if ((mask & (1 << i))) {
                dp[mask] = add(dp[mask], dp[mask ^ (1 << i)] * can[i][j - 1]);
            }
        }
    }

    cout << dp[(1 << n) - 1] << endl;

    return 0;
}

Measured memory_bytes: 18688
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    int a,b;
    cin>>a>>b;
    double x=0.08,y=0.1;
    REP(i,1,100000){
        if(int(i*x)==a&&int(i*y)==b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}

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

using namespace std;
typedef long long ll;

int main(){
    int x, y; cin >> x >> y;
    int ans;

    if (y > x)
    {
        int tmp = x;
        x = y;
        y = tmp;
    }

    while (x%y != 0)
    {
        int tmp = x%y;
        x = y;
        y = tmp;
    }
    
    cout << y << endl;
    
}


Measured memory_bytes: 3092
class Node:
    def __init__(self,key):
        self.key=key
        self.left=None
        self.right=None


def insert(root,node):#rootを根に持つ２分探索木にnodeを追加する
    if(root.key <= node.key):
        if(root.right is None):
            root.right=node
        else:
            insert(root.right,node)
    
    else:
        if(root.left is None):
            root.left=node
        else:
            insert(root.left,node)


def Preorder(root,order):
    order.append(root.key)
    if(root.left is not None):
        Preorder(root.left,order)
    
    if(root.right is not None):
        Preorder(root.right,order)




def Inorder(root,order):
    if(root.left is not None):
        Inorder(root.left,order)
    
    order.append(root.key)

    if(root.right is not None):
        Inorder(root.right,order)




n=int(input())

root=None

for loop in range(n):
    ope=input().split()

    if(ope[0]=="insert"):
        tmp_node=Node(int(ope[1]))
        try:
            insert(root,tmp_node)
        except:
            root=tmp_node
    
    else:
        in_order=[]
        p_order=[]
        
        Inorder(root,in_order)
        Preorder(root,p_order)

        for x in in_order:
            print(f" {x}",end="")
        print()
        for x in p_order:
            print(f" {x}",end="")
        print()


Measured memory_bytes: 112960
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 05/31/20 18:19:58
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n; cin>>n;
  int ans = 0;
  for (ll m = 2; m <= sqrt(n); m++) {
    int cnt = 0;
    while (n%m==0) {
      cnt++;
      n /= m;
    }
    for (int i = 1; cnt >= i; i++) {
      ans++;
      cnt -= i;
    }
  }
  if (n > 1)
    ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3692
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    # j-i == Ai + Aj -> i+Ai == j-Aj
    # L: i+Ai, R: i-Ai

    dic = {}
    ans = 0
    for i in range(N):
        L = i + A[i]
        R = i - A[i]
        if L not in dic:
            dic[L] = 1
        else:
            dic[L] += 1
        if R in dic:
            ans += dic[R]
    print(ans)

if __name__ == "__main__":
    resolve()

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

int main(){
  char n[4];
  
  for(int i = 0; i < 4; i++){
    cin >> n[i];
  }
  
  if(n[0]==n[1] && n[0]==n[2]){
    cout << "Yes";
  }
  else if(n[1]==n[2] && n[1]==n[3]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
  cout << endl;
  return 0;
}

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

using namespace std;

using ll = long long;

ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;

  int vsum = 0;
  for (int i = 0; i < 60; ++i) {
    int a = 0;
    for (int j = 0; j < n; ++j)
      if (vec[j] >> i & 1)
        ++a;
    int b = a * (n - a) % mod;
    for (int k = 0; k < i; ++k)
      b = b * 2 % mod;
    vsum = (vsum + b) % mod;
  }

  cout << vsum << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

typedef long long lli;

#define CHARMAX 256
char a[200001];
int freq[CHARMAX];

int main() {
    int i, n = 0;
    for(i=0; i<CHARMAX; ++i) {
        freq[i] = 0;
    }
    scanf("%s", a);
    for(n=0; a[n] != '\0'; ++n) {
        freq[(int)(a[n])]++;
    }
    lli res = (lli)(n-1) * n / 2ll + 1;
    for(i=0; i<CHARMAX; ++i) {
        int f = freq[i];
        if(f > 0) {
            res -= (lli)(f-1) * f / 2ll;
        }
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
    int X,Y,ans;
    cin>>X>>Y;
    ans=X+Y/2;
    cout<<ans<<endl;
    return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	int n = sz(s); int m = sz(t);
	vector<vector<int>>is(26);
	rep(i, n)is[s[i] - 'a'].push_back(i);
	rep(i, n)is[s[i] - 'a'].push_back(i + n);
	int ans = 0;
	int p = 0;
	rep(i, m) {
		int c = t[i] - 'a';
		if (sz(is[c]) == 0) {
			puts("-1");
			return 0;
		}
		p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
		if (p >= n) {
			p -= n;
			ans += n;
		}
	}
	ans += p;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2756
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    ans=0
    # 制約1<=x<=1000以下があるから、
    # i**jを考えるとき、iのmaxは33*33=961の33でjのmaxは2**9=512の9で
    for i in range(1,34):
        if i>x:
            break
        for j in range(2,10):
            y=i**j
            if y<x:
                ans=max(y,ans)
            elif y==x:
                ans=max(y,ans)
                break
            else:
                break
    print(ans)
resolve()

Measured memory_bytes: 3064
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True

p = None
XY = None
N = None


def main():
    N, M = MI()
    AB = [None] * N

    for i in range(N):
        A, B = MI()
        AB[i] = (A, B)

    AB = sorted(AB)

    ans = 0
    total = 0

    for i in range(N):
        price = AB[i][0]
        size = AB[i][1]

        if M < total + size:
            n = M - total
            ans += price * n
            total += n
        else:
            ans += price * size
            total += size

        if total >= M:
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45656
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int x1,y1,x2,y2;

    cin >> x1 >> y1 >> x2 >> y2;

    int x3 = x2 - y2 + y1;
    int y3 = y2 + x2 - x1;
    int x4 = x3 - x2 + x1;
    int y4 = y3 - y2 + y1;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
 
    return 0;
}

Measured memory_bytes: 256