akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def pi(n):
    v = 1
    for i in range(2, n + 1):
        v *= i
    return v


def main():
    N, M = li_input()

    if abs(N - M) >= 2:
        print(0)
        return

    if abs(N - M) == 0:
        print((2 * math.factorial(N) * math.factorial(M)) % (10**9 + 7))
    else:
        print((math.factorial(N) * math.factorial(M)) % (10**9 + 7))


main()


Measured memory_bytes: 6816
import sys
sys.setrecursionlimit(10010010)

def abc146_d():
    n = int(input())
    Q = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(n-1)]

    deg = [0] * n
    adj = [[] for _ in range(n)]
    color = dict()

    for a, b in Q:
        deg[a] += 1
        deg[b] += 1
        adj[a].append(b)
        adj[b].append(a)

    def dfs(s, p):
        nouse = -1
        if p > -1: nouse = color[(min(s, p), max(s, p))]
        c = 1
        for t in adj[s]:
            if t == p: continue
            if c == nouse: c += 1
            color[(min(s, t), max(s, t))] = c
            dfs(t, s)
            c += 1

    dfs(1, -1)

    print(max(deg))
    for a, b in Q:
        print(color[(a, b)])

if __name__ == '__main__':
    abc146_d()

Measured memory_bytes: 99900
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define p 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n+1]={0};
	int k=m;
	while(m--){
		int x,y;
		cin>>x>>y;
		x--;y--;
		a[x]++;
		a[y+1]--;
	}
	int x=0,y=0;
	for(int i=0;i<n;i++){
		x=x+a[i];
		if(x==k)y++;
	}
	cout<<y;
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

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

    int n = 0;
    LL sum = 0;
    for(int i = 0; i < N; ++i) {
        cin >> B[i];
        if(A[i] <= n) {
            sum += A[i];
            n = B[i];
        } else {
            sum += n;
            A[i] -= n;
            if(B[i] >= A[i]) {
                n = B[i] - A[i];
                sum += A[i];
                B[i] -= A[i];
                n = B[i];
            } else {
                sum += B[i];
                n = 0;
            }
        }
    }
    cout << sum + min(n, A[N]) << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    int a, b;
    cin >> a >> b;
    for(int i=1;i<=1009;i++){
        int c, d;
        c = (double)i * 0.1;
        d = (double)i * 0.08;
        if(d == a && c == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int H[200005];
int  comp(const void*a,const void*b)//用来做比较的函数。
{    return *(int*)a-*(int*)b;}//从小到大排序
int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    long long i;
    for(i=0;i<N;i++)
    {
        scanf("%d",&H[i]);
    }
    qsort(H,N,sizeof(int),comp);//排序
    long long sum;
    if(K>=N)
    {        printf("0");
    }
    else
    {
        sum=0;
        for(i=0;i<N-K;i++)
        {
            sum=sum+(long long)H[i];
        }
        printf("%lld",sum);
    }
    return 0;
}

Measured memory_bytes: 1788
n,m=map(int, input().split())
l_ans=1
r_ans=n
for i in range(m):
    l,r=map(int, input().split())
    l_ans=max(l_ans,l)
    r_ans=min(r_ans,r)

if r_ans>=l_ans:
    print(r_ans-l_ans+1)
else:
    print(0)

Measured memory_bytes: 74464
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();

		int ans = 0;

		for(int i = 0;i<S.length() ; i++) {
			char s = S.charAt(i);
			char t = T.charAt(i);

			if(s !=t) {
				ans++;
			}
		}

		System.out.println(ans);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 41044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k;
  cin>>n>>k;
  int w[2*k][2*k];
  int b[2*k][2*k];
  rep(i,0,2*k){
    rep(j,0,2*k){
      w[i][j]=0;
      b[i][j]=0;
    }
  }
  rep(i,0,n){
    int x,y;
    char c;
    cin>>x>>y>>c;
    if(c=='W') w[x%(2*k)][y%(2*k)]++;
    else b[x%(2*k)][y%(2*k)]++;
  }
  int sw[2*k+1][2*k+1];
  int sb[2*k+1][2*k+1];
  rep(i,0,2*k+1){
    sw[0][i]=0;
    sb[0][i]=0;
    sw[i][0]=0;
    sb[i][0]=0;
  }
  rep(i,0,2*k){
    rep(j,0,2*k){
      sw[i+1][j+1]=sw[i+1][j]+sw[i][j+1]-sw[i][j]+w[i][j];
      sb[i+1][j+1]=sb[i+1][j]+sb[i][j+1]-sb[i][j]+b[i][j];
    }
  }
  /*rep(i,0,2*k+1){
    rep(j,0,2*k+1){
      cout<<sb[i][j];
    }
    cout<<endl;
  }*/
  int ans=0;
  rep(i,0,k){
    rep(j,0,k){
      int cur=0;
      cur+=sw[i+k][j+k]-sw[i+k][j]-sw[i][j+k]+sw[i][j];
      cur+=sw[i][j];
      cur+=sw[i][2*k]-sw[i][j+k];
      cur+=sw[2*k][j]-sw[i+k][j];
      cur+=sw[2*k][2*k]-sw[2*k][j+k]-sw[i+k][2*k]+sw[i+k][j+k];
      cur+=sb[i+k][j]-sb[i][j];
      cur+=sb[i][j+k]-sb[i][j];
      cur+=sb[i+k][2*k]-sb[i+k][j+k]-sb[i][2*k]+sb[i][j+k];
      cur+=sb[2*k][j+k]-sb[i+k][j+k]-sb[2*k][j]+sb[i+k][j];
      ans=max(ans,cur);
      cur=0;
      cur+=sb[i+k][j+k]-sb[i+k][j]-sb[i][j+k]+sb[i][j];
      cur+=sb[i][j];
      cur+=sb[i][2*k]-sb[i][j+k];
      cur+=sb[2*k][j]-sb[i+k][j];
      cur+=sb[2*k][2*k]-sb[2*k][j+k]-sb[i+k][2*k]+sb[i+k][j+k];
      cur+=sw[i+k][j]-sw[i][j];
      cur+=sw[i][j+k]-sw[i][j];
      cur+=sw[i+k][2*k]-sw[i+k][j+k]-sw[i][2*k]+sw[i][j+k];
      cur+=sw[2*k][j+k]-sw[i+k][j+k]-sw[2*k][j]+sw[i+k][j];
      ans=max(ans,cur);
    }
  }
  cout<<ans<<endl;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli a,b,c,x;
    cin3(a,b,c);
    cin1(x);

    lli ans = 0;
    REPE(i, 0, a) {
        REPE(j, 0, b) {
            REPE(k, 0, c) {
                if (i * 500 + j * 100 + k * 50 == x)
                    ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

N = int(input())
for n in range(N):
  b = int(input())
  if my_index(A1, b) is not False:
    A1[my_index(A1, b)] = -1
  if my_index(A2, b) is not False:
    A2[my_index(A2, b)] = -1
  if my_index(A3, b) is not False:
    A3[my_index(A3, b)] = -1

if (sum(A1) == -3) or (sum(A2) == -3) or (sum(A3) == -3):
  print("Yes")
elif (A1[0]+A2[0]+A3[0]==-3) or (A1[1]+A2[1]+A3[1]==-3) or (A1[2]+A2[2]+A3[2]==-3):
  print("Yes")
elif (A1[0]+A2[1]+A3[2]==-3) or (A1[2]+A2[1]+A3[0]==-3):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 62244
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0; i<n; i++){
    int l,r;
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
}
    
    

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




int main(){
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for(int i=0; i<N; i++) cin >> p[i];

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

	int ans = 0;
	for(int i=0; i<K; i++) ans += p[i];

	cout << ans << endl;




}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    ll n;
    cin >> n;
    ll ans = modpow(10, n) + modpow(8, n) - 2 * modpow(9, n);
    ans %= mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;
}



Measured memory_bytes: 3628
n = int(input())
cnt = 0

for i in range(1, n+1):
    if i % 2 == 1:
        l = []
        for d in range(1, i+1):
            if i % d == 0:
                l.append(d)
                if len(l) == 8:
                    cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>

 int main(void) {
	 int a, b, c;
	
		 scanf("%d%d%d", &a, &b, &c);
	
		 int result = 0;
	 if (a == b && b != c) result = 1;
	 if (b == c && c != a) result = 1;
	 if (c == a && a != b) result = 1;
	
		 if (result) {
		 puts("Yes");
		
	}
		else {
		 puts("No");
		
	}
	
		 return 0;
	
}

Measured memory_bytes: 128
using System;

class BCommonRaccoonVsMonster {
    static void Main(string[] args) {
        string[] line1 = System.Console.ReadLine().Trim().Split(' ');
        string[] line2 = System.Console.ReadLine().Trim().Split(' ');
        int A = 0;
        for (int i = 0; i < int.Parse(line1[1]); i++){
            A = A + int.Parse(line2[i]);
        }
        if (int.Parse(line1[0]) <= A) {
            System.Console.WriteLine("Yes");
        } else {
            System.Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 16480
from sys import stdin
input = stdin.readline

def depthcheck(idx, depth):
    global depthlist, childlist
    depthlist[idx]['depth'] = depth + 1
    if childlist[idx] != []:
        for child in childlist[idx]:
            depthcheck(child, depth+1)
    else:
        depthlist[idx]['type'] = 'leaf'

n = int(input())
childlist = [[]]*n
parentlist = [-1]*n
depthlist = [{'depth':0, 'type':'internal node'} for _ in range(n)]
for i in range(n):
    idx, c, *childs = map(int, input().split())
    childlist[idx] = list(childs)
    for childidx in childs:
        parentlist[childidx] = idx

for idx in range(n):
    if parentlist[idx] == -1:
        depthlist[idx]['type'] = 'root'
        for child in childlist[idx]:
            depthcheck(child, 0)
        break
for i in range(n):
    print('node %s: parent = %d, depth = %d, %s, %s'%(i, parentlist[i], depthlist[i]['depth'], depthlist[i]['type'], childlist[i]))


Measured memory_bytes: 44516
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;

/*--------------------template--------------------*/

int main() {
	cin >> n;
	ans = n*(n + 1) / 2;
	cout << ans << endl;
}

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

using namespace std;
#define int long long
#define inf 9999999999
#define N 666666
int arr[N];int f[N];
map<int,int> mp;
signed main(){
	int ans=0;
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int t;cin>>t;
		if(!mp[t]){
			ans++;mp[t]=1;
		} else{
			mp[t]=0;ans--;
		}
	} 
	cout<<ans;
    return 0;
}
/*

*/

Measured memory_bytes: 6528
#include <stdio.h>

int main()
{
  int price,num;
  int sum_p=0,sum_n=0,n=0;
  while (scanf("%d,%d",&price,&num)!=EOF){
      sum_p+=price*num;
      sum_n+=num;
      n++;
    }
  printf("%d\n%d\n",sum_p,(int)((double)sum_n/n+0.5));
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6
ll fastexp(ll a,ll n){
    ll nod=(ll)1e18;
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%nod;
        a=(a*a)%nod;
        n>>=1;
    }
    return ans;
}
void fun(){
    int n;
    cin>>n;
    n=!n;
    cout<<n<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3636
import sys

N = int(input())

jobs = []

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.append([B, A])

jobs = sorted(jobs)

time = 0

for job in jobs:
    time += job[1]
    if time > job[0]:
        print('No')
        sys.exit(0)

print('Yes')


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;
  vector<std::pair<int, int>> red(N);
  vector<std::pair<int, int>> blue(N);

  int a, b;
  rep(i, N) {
    cin >> a >> b;
    red[i] = std::make_pair(a, b);
  }
  rep(i, N) {
    cin >> a >> b;
    blue[i] = std::make_pair(a, b);
  }

  std::sort(blue.begin(), blue.end());

  int sum = 0;
  rep(i, N) {
    int x1 = blue[i].first;
    int y1 = blue[i].second;
  
    int dist = 2 * N;
    int pos = -1;
    rep(j, red.size()) {
      int x2 = red[j].first;
      int y2 = red[j].second;

      int dist2 = std::abs(y1-y2);
      if (x1 > x2 && y1 > y2 && dist > dist2) {
        pos = j;
        dist = dist2;
      }
    }

    if (pos != -1) {
      sum++;
      red.erase(red.begin() + pos);
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import math

def distance(X1, X2):
    res = 0
    for x1, x2 in zip(X1, X2):
        res += pow(x1-x2, 2)
    return math.sqrt(res)

N, D = map(int, input().split())

X = []
for _ in range(N):
    X.append(list(map(int, input().split())))

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        d = distance(X[i], X[j])
        if d.is_integer():
            ans += 1
print(ans)

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

using namespace std;

class State{
public:
  string name;
  int data;
  int x1, y1, x2, y2;
};

vector<State> data[1000];
string str;
int idx, size;

void calc2(int r, int l, State& p){
  int tmp = r;
  for(int i=tmp;i<=l;i++){
    if(str[i] == ','){
      p.x1 = atoi(str.substr(tmp, i-tmp).c_str());
      tmp = i+1;
      break;
    }
  }
  for(int i=tmp;i<=l;i++){
    if(str[i] == ','){
      p.y1 = atoi(str.substr(tmp, i-tmp).c_str());
      tmp = i+1;
      break;
    }
  }
  for(int i=tmp;i<=l;i++){
    if(str[i] == ','){
      p.x2 = atoi(str.substr(tmp, i-tmp).c_str());
      tmp = i+1;
      break;
    }
  }
  p.y2 = atoi(str.substr(tmp, l-tmp+1).c_str());
}

void calc(int pos){
  if(idx >= str.size()) return;
  size = max(size, pos);
  int r = idx;
  int l;
  for(int i=r;i<str.size();i++){
    if(str[i] == '>'){
      l = i;
      break;
    }
  }
  State p;
  p.name = str.substr(r+1, l-r-1);
  r = l+1;
  for(int i=r;i<str.size();i++){
    if(str[i] == '<'){
      l = i-1;
      break;
    }
  }
  calc2(r, l, p);
  r = l+1;
  p.data = 0;
  idx = r;
  while(1){
    bool f = false;
    for(int i=idx;i<str.size();i++){
      if(str[i] == '/') f = true;
      if(str[i] == '>'){
        l = i;
        break;
      }
    }
    if(f){
      data[pos].push_back(p);
      idx = l+1;
      break;
    }else{
      p.data ++;
      calc(pos+1);
    }
  }
}

main(){
  int n;
  while(cin >> n && n){
    for(int i=0;i<1000;i++) data[i].clear();
    getline(cin, str);
    getline(cin, str);
    idx = size = 0;
    while(idx < str.size()) calc(0);
    for(int k=0;k<n;k++){
      int x, y;
      cin >> x >> y;
      for(int i=size;i>=0;i--){
        for(int j=0;j<data[i].size();j++){
          if(data[i][j].x1 <= x && x <= data[i][j].x2){
            if(data[i][j].y1 <= y && y <= data[i][j].y2){
              cout << data[i][j].name << ' ' << data[i][j].data << endl;
              goto END;
            }
          }
        }
      }
      cout << "OUT OF MAIN PANEL 1" << endl;
      END:;
    }
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << (set<char>(s.begin(), s.end()).size() == s.size() ? "yes" : "no") << endl;
}



Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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

    int N, M; cin >> N >> M;
    vi A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    vvi bs(M+1);
    REP(i,N) {
        if (A[i] > M) continue;
        bs[A[i]].push_back(B[i]);
    }

    priority_queue<int> pq;

    ll ans = 0;
    for (int d = M - 1; d >= 0; d--) {
        int rest = M - d;

        for(int b : bs[rest]) {
            pq.push(b);
        }

        if (!pq.empty()) {
            ans += pq.top(); pq.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
using Pos = std::pair<int, int>;
//cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
constexpr int mod = 1e9 + 7;

int main() {
    int N,M;
    cin>>N>>M;
    vector<vector<bool>> Edge(N,vector<bool>(N,false));
    while(M--){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        Edge[a][b]=true;
        Edge[b][a]=true;
    }

    vector<int> p(N);
    for(int i=0;i<N;++i)
        p[i]=i;

    int ans=0;
    do{
        if(p[0]==0){
            for(int i=0;i<N-1;++i){
                if(!Edge[p[i]][p[i+1]])break;
                if(i==N-2)++ans;
            }
        }
    }while(std::next_permutation(begin(p),end(p)));

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main(){
	int x, y;
	cin>>x>>y;
	
	for(int i=0; i<x; i++){
		//cout<<"x:"<<i<<" y:"<<x-i<<"ans:"<<2*i + 4*(x-i)<<'\n';
		if(2*i + 4*(x-i) ==y || 2*(x-i) + 4*i ==y){
			cout<<"Yes"<<'\n';
			return 0;
		}
		
	}
	cout<<"No"<<'\n';
	return 0;
}

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

#define int long long

int n, m, ans;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	ans = min(n, m / 2);
	n -= ans;
	m -= 2 * ans;
	cout << ans + m / 4 << endl;
}

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

vector<long long> a, p;

long long f(int N, long long X) {
	if (N == 0) {
		if (X <= 0) {
            return 0;
        }
        else {
            return 1;
        }
	}
	else if (X <= 1 + a.at(N - 1)) {
		return f(N - 1, X - 1);
	}
	else if (X == 2 + a.at(N - 1)) {
		return (p.at(N - 1) + 1);
	}
	else {
		return (p.at(N - 1) + f(N - 1, X - (2 + a.at(N - 1))) + 1);
	}
}

int main() {
	int N;
	long long X;
	cin >> N >> X;
	
	
	a = {1};
	p = {1};
	for (int i = 1; i <= N; i++) {
		a.push_back(a.at(i - 1) * 2 + 3);
		p.push_back(p.at(i - 1) * 2 + 1);
	}
	cout << f(N, X) << endl;
}

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

typedef long long ll;

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

    int N;
    cin >> N;

    if(N % 111 == 0) {
        cout << N << endl;
    } else {
        cout << (N / 111 + 1) * 111 << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        string[] input = new string[3];
        for (int a = 0; a < 3; a++)
        {
            input[a] = Console.ReadLine();
        }
        //int input =int.Parse(input[0]+""+input[3+1]+""+input[3*2+2]);
        Console.WriteLine(input[0][0] + "" + input[1][1] + "" + input[2][2]);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin >> N >> D;
  
  vector<vector<int>> X(N,vector<int>(D));
  
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X.at(i).at(j);
    }
  }
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      int d=0;
      for(int k=0;k<D;k++){
        d += (X.at(i).at(k)-X.at(j).at(k))*(X.at(i).at(k)-X.at(j).at(k));
      }
      
      bool h=false;
      
      for(int k=1;k<sqrt(d)+1;k++){
        if(k*k==d)h=true;
      }
      
      if(h==true)ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3744
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var A=[];
  var B=[];
  while(input.length>0){
    B.push(input.pop());
    A.push(input.pop());
  }
  var M=Math.max.apply(null,A);
  var S=B[A.indexOf(M)];
  console.log(M+S);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 56488
import java.awt.Point;
import java.util.*;
public class Main {
	
	static List<Point>[] edge;
	static boolean[] used;
	static int[] d;
	
	static boolean dfs(int a, int b) {
		if(used[a])
			return d[a] == b;
		used[a] = true;
		d[a] = b;
		for(Point p : edge[a])
			if(!dfs(p.x, d[a] + p.y))
				return false;
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		edge = new ArrayList[N];
		for(int i = 0; i < N; i++)
		    edge[i] = new ArrayList<>();
		for(int i = 0; i < M; i++) {
			int L = sc.nextInt()-1;
			int R = sc.nextInt()-1;
			int D = sc.nextInt();
			edge[L].add(new Point(R, D));
			edge[R].add(new Point(L, -D));
		}
		boolean ok = true;
		used = new boolean[N];
		d = new int[N];
		for(int i = 0; i < N; i++)
			if(!used[i])
				if(!dfs(i, 0))
					ok = false;
		System.out.println(ok ? "Yes" : "No");
	}

}


Measured memory_bytes: 175100
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;


double d(double x, double y, double a, ll b) {
	return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}


ll fact(ll n) {
	if(n == 0) return 1;
	return n * fact(n - 1);
}


void solve() {
	int n;
	cin >> n;
	int arr[n];
	vector<pair<int,int>> c(n);
	double ans = 0;
	for(int i = 0; i < n; ++i) cin >> c[i].first >> c[i].second;
	for(int i = 0; i < n; ++i) arr[i] = i + 1;
		do{
			for(int i = 0; i < n - 1; ++i) {
				ans += d(c[arr[i] - 1].first, c[arr[i] - 1].second, c[arr[i + 1] - 1].first	, c[arr[i + 1] - 1].second);
					}
			}while(next_permutation(arr, arr + n));
			cout << ans / fact(n) << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



Measured memory_bytes: 3844
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;

class MyStack
{
public:
    int S[1000];
    int top;
    void push(int x)
    {
        S[++top] = x;
    }

    int pop()
    {
        top--;
        return S[top + 1];
    }
};

int main()
{
    int a, b;
    char st[100];
    MyStack stack;
    stack.top = 0;
    while (scanf("%s", st) != EOF)
    {
        if (st[0] == '+')
        {
            a = stack.pop();
            b = stack.pop();
            stack.push(a + b);
        }
        else if (st[0] == '-')
        {
            a = stack.pop();
            b = stack.pop();
            stack.push(b - a);
        }
        else if (st[0] == '*')
        {
            a = stack.pop();
            b = stack.pop();
            stack.push(a * b);
        }
        else
        {
            stack.push(atoi(st));
        }
    }
    printf("%d\n", stack.pop());
    return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
 
// >= 91
ll A, M;
ll getPhi(ll m) {
	ll res = 1;
	for(int i=2; i*i<=m; i++) {
		if(m%i == 0) {
			m /= i; res *= i-1;
			while(m%i == 0) m /= i, res *= i;
		}
	}
	if(m != 1) res *= m-1;
	return res;
}
ll getMul(ll a, ll b, ll m) {
	ll r = 0, p = a;
	while(b) {
		if(b%2) r = (r + p) % m;
		p = (p + p) % m;
		b >>= 1;
	}
	return r;
}
ll getPow(ll a, ll b, ll m) {
	ll r = 1, p = a;
	while(b) {
		if(b%2) r = getMul(r, p, m);
		p = getMul(p, p, m);
		b >>= 1;
	}
	return r;
}
ll ee(ll a, ll b, ll &s, ll &t) {
	if(b == 0) {
		s = 1; t = 0;
		return a;
	}
	ll ss, tt, g = ee(b, a%b, ss, tt);
	ll q = a / b;
	s = tt;
	t = ss - q * tt;
	return g;
}
ll toPlus(ll a, ll m) {
	a %= m; if(a < 0) a += m;
	return a;
}
ll getCRT(ll a, ll c, ll b, ll d) {
	//printf("%lld %lld %lld %lld\n", a, c, b, d);
	ll s, t;
	ll g = ee(c, d, s, t);
	s = toPlus(s, d), t = toPlus(t, c);
	if(g > 1) {
		return getCRT(a/g, c/g, b/g, d/g) * g + a%g;
	}
	ll av = getMul(getMul(a, d, c*d), t, c*d);
	ll bv = getMul(getMul(b, c, c*d), s, c*d);
	ll k = (av + bv) % (c*d);
	if(k == 0) k = c*d;
	return k;
}
ll getAns(ll a, ll m) {
	ll pm = getPhi(m);
	if(m < 91) {
		for(int i=150; i<=pm*m+150; i++) if(getPow(a, i, m) == (i % m)) return i;
		return -1;
	}
	ll c, d;
	ll g = ee(pm, m, c, d);
	ll y = getAns(a, g);
	if(y == -1) return -1;
	ll Ay = getPow(a, y, m);
	ll yg = y / g, Ayg = Ay / g;
 
	//printf("%lld %lld - > %lld [%lld %lld]\n", a, g, y, c, d);
	ll x = getCRT(getPow(a, y, m), m, y, pm);
	//printf("[%lld %lld] (%lld) %lld %lld\n", a, m, x, getPow(a, x, m), x % m);
	return x;
}
int main() {
	int T; cin >> T;
	for(int tc=1; tc<=T; tc++) {
		scanf("%lld%lld", &A, &M);
		//printf("%lld\n", getAns(A, M));
		ll v = getAns(A, M);
		printf("%lld\n", v);
		//if(v > 0) printf("%lld %lld\n", getPow(A, v, M), v % M);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int rmax = N / R;
    int gmax = N / G;
    int count = 0;
    for (int r = 0; r <= rmax; ++r) {
        for (int g = 0; g <= gmax; ++g) {
            int mid = R * r + G * g;
            if (mid > N) continue;
            if ((N - mid) % B != 0) continue;
            else ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

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

void dfs(int x,int y){
  in[y][x] = '0';
  rep(i,4){
    loop(j,1,4){
      int nx = x + dx[i] * j;
      int ny = y + dy[i] * j;
      if(nx < 0 || 8 <= nx)break;
      if(ny < 0 || 8 <= ny)break;
      if(in[ny][nx] == '1')dfs(nx,ny);
    }
  }
}

int main(void){
  int n;
  cin>>n;
  rep(i,n){
    rep(j,8)rep(k,8)cin>>in[j][k];
    int x,y;
    cin>>x>>y;
    dfs(--x,--y);

    cout<<"Data " << (i+1) << ":" <<endl;

    rep(j,8){
      rep(k,8)cout<<in[j][k];
      cout<<endl;
    }
  }

}

Measured memory_bytes: 1160
import bisect
import numpy as np
import sys

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j] == "?":
            continue
        else:
            break
    else:
        a = s[:i]+t+s[i+len(t):]
        print(a.replace('?', 'a'))
        break
else:
    print("UNRESTORABLE")

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

int main() {
  string s;
  cin >> s;
  s.erase(s.begin() + 4);
  s.erase(s.end() - 3);
  if (stoi(s) <= 20190430) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  //less_equal
             tree_order_statistics_node_update> oset; 
typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int MAXK = 2e3 + 2;
#define sz(x) (int)(x).size()
#define f first
#define s second

int main()
{
 
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int ans = 0;
for(int i = 1 ; i <= n ; i++)
	 {
	    ans+=(int)((floor(log10(i))) + 1) & 1;
	 }

cout << ans ;
}


Measured memory_bytes: 512
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int cnt = 0; 
        for(int i = 0; i < str.length(); i++){
            if(str.charAt(i) == '1') cnt++;
        }
        System.out.println(cnt);

    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int n,m,k,i;
    scanf("%d%d%d",&k,&n,&m);
    for(i=1;k-n-i*m>=0;i++);
    printf("%d\n",k-n-(i-1)*m);
    return 0;
}


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

int main(void){
  ll x;
  cin >> x;
  ll m = 100;
  int cnt = 0;
  while(m < x){
    m += m / 100;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3604
function main(input) {
  const x = input[0].trim().split(" ").map(i => parseInt(i));

  let index = 0;
  for(let i of x){
    index++;
    if(i===0){
      console.log(index);
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define fi first
#define se second

int n;

int cal(int u) {
  int res = 0;
  while (u) {
    res += u % 10;
    u /= 10;
  }
  return res;
}

int main() {
  cin >> n;

  int ans = 1e9 + 8;
  rep(i, 1, n) {
    int j = n - i;
    int now = cal(i) + cal(j);
    ans = min(ans, now);
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 764
import sys
input = sys.stdin.readline
R, C = map(int, input().split())
n = int(input())
G = [[] for _ in range(R+C)]
for _ in range(n):
  r, c, a = map(int, input().split())
  r -= 1
  c -= 1
  G[r].append((R+c, a))
  G[R+c].append((r, a))
D = [-1]*(R+C)
def dfs(v):
  rmin, cmin = float("inf"), float("inf")
  stack = [(v, 0)]
  while stack:
    nv, cost = stack.pop()
    D[nv] = cost
    if nv<R:
      rmin = min(rmin, cost)
    else:
      cmin = min(cmin, cost)
    for i, nc in G[nv]:
      if D[i] != -1:
        if D[nv]+D[i] != nc:
          return False
      else:
        stack.append((i, nc-D[nv]))
  return rmin+cmin >= 0

for i in range(R+C):
  if D[i] == -1:
    if not dfs(i):
      print("No")
      break
else:
  print("Yes")

Measured memory_bytes: 53540
#include<stdio.h>
 
int main()
{
	int a[100],i,n,large,small;
	scanf("%d",&n);
 
	for(i=0;i<n;++i)
		scanf("%d",&a[i]);
	
	large=small=a[0];
	for(i=1;i<n;++i)
	{
		if(a[i]>large)
			large=a[i];
		if(a[i]<small)
			small=a[i];
	}
	
	printf("%d",large-small);
 
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#include<cmath>
#define int long long int
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int val=1900*m+(100)*(n-m);
	int p=pow(2,m);
	val*=p;
	cout<<val<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
num = list(map(int, input().split()))
string = input()
length = num[0] + num[1] + 1
flag = False

for i in range(num[0]):
    if string[i].isdigit():
        flag = True
    else :
        flag = False
        break

if string[num[0]] == '-' and flag:
    for i in range(num[0] + 1, length):
        if string[i].isdigit():
            flag = True
        else:
            flag = False
            break
else:
    flag = False

if flag == True:
    print("Yes")
else:
    print("No")

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

int main() {
  int N,M;
  cin >> N >> M;
  map<long,long> AB;
  int a,b;
  for (int i=0; i<N; i++) {
    cin >> a >> b;
    AB[a] += b;
  }
  int numm = 0;
  long ans = 0;
  for (auto i=AB.begin(); i!=AB.end(); i++) {
    if (numm + i->second >= M) {
      ans += (M - numm) * i-> first;
      break;
    }
    else {
      ans += i->first * i->second;
      numm += i -> second;
    }
  }
  cout << ans << endl;
}

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

struct SegTree{

    int sz;
    vector<long long> dat,laz;

    SegTree(){
        sz=1<<18;
        dat.resize(sz<<1);
        laz.resize(sz<<1);
    };

    void upd(int id,int l,int r,int ql,int qr,long long val){
        if(qr<l||r<ql)return;
        if(ql<=l&&r<=qr){
            laz[id]+=val;
            dat[id]+=val;
            return;
        }
        laz[id<<1]+=laz[id];
        dat[id<<1]+=laz[id];
        laz[id<<1|1]+=laz[id];
        dat[id<<1|1]+=laz[id];
        laz[id]=0;
        upd(id<<1,l,l+r>>1,ql,qr,val);
        upd(id<<1|1,(l+r>>1)+1,r,ql,qr,val);
        dat[id]=min(dat[id<<1],dat[id<<1|1]);
    }

    long long qry(int id,int l,int r,int ql,int qr){
        if(qr<l||r<ql)return 1e18;
        if(ql<=l&&r<=qr){
            return dat[id];
        }
        laz[id<<1]+=laz[id];
        dat[id<<1]+=laz[id];
        laz[id<<1|1]+=laz[id];
        dat[id<<1|1]+=laz[id];
        laz[id]=0;
        return min(qry(id<<1,l,l+r>>1,ql,qr),qry(id<<1|1,(l+r>>1)+1,r,ql,qr));
    }

    void upd(int l,int r,long long d){
        upd(1,1,sz,l,r,d);
    }

    long long qry(int l,int r){
        return qry(1,1,sz,l,r);
    }
};

int n,m;
int a[200005],b[200005];
SegTree y,x;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=1;i<=m;i++)y.upd(i,i,m-i);
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
        x.upd(b[i]+1,b[i]+1,min(y.qry(1,b[i])-(m-b[i]-1)-x.qry(b[i]+1,b[i]+1),0ll));
        y.upd(b[i]+1,b[i]+1,min(y.qry(1,b[i])-y.qry(b[i]+1,b[i]+1),0ll));
        x.upd(a[i],b[i],1e9);
        y.upd(a[i],b[i],1e9);
        x.upd(1,m,1);
        y.upd(1,m,1);
        if(x.qry(1,m)>=1e9)cout<<"-1\n";
        else cout<<x.qry(1,m)<<'\n';
    }

    return 0;
}


Measured memory_bytes: 21220
#include<iostream>
using namespace std;
int main(){
	double a[2],b[2],c[2],d[2];
	int n;
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1]>>d[0]>>d[1];
		b[0] = b[0]-a[0];
		b[1] = b[1]-a[1];
		d[0] = d[0]-c[0];
		d[1] = d[1]-c[1];
		if(d[1]*b[0] == b[1]*d[0]){cout<<"YES"<<endl;}
		else{cout<<"NO"<<endl;}
	}
}

Measured memory_bytes: 0