akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <limits.h>
#include <iomanip>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <set>
#include <bitset>
#include <unordered_map>
#include <string.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MOD 1000000007

using namespace std;
int main()
{
    fastIo;
    ll d,t,s;
    cin>>d>>t>>s;

    ll time = d/s;
    if(d%s!=0)
        time++;
    if(time<=t)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    


   
    return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, X, ans=1, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> X;
    A.resize(2*N-1);
    if(X==1||X==2*N-1) {
        cout << "No" << endl;
        return 0;
    }
    while(2*N-1-X>=tmp&&X-1>=tmp) {
        A[N-1-tmp] = X+ans*tmp;
        A[N-1+tmp] = X-ans*tmp;
        tmp++;
        ans *= (-1);
    }
    ll now = tmp;
    if(X-1<tmp) {
        while(tmp<=N-1) {
            A[N-1-tmp] = X+now;
            now++;
            A[N-1+tmp] = X+now;
            now++;
            tmp++;
        }
    }
    else {
        while(tmp<=N-1) {
            A[N-1-tmp] = X-now;
            now++;
            A[N-1+tmp] = X-now;
            now++;
            tmp++;
        }
    }
    cout << "Yes" << endl;
    for(int i=0;i<2*N-1;i++) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4788
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

long int f(long int x,long int A[], long int s,long int e){
    while (e-s>=1){
        long int k=(s+e)/2;
        if (A[k]==x) return 1;
        else if (A[k]<x) s=k+1;
        else e=k;
    }
    return 0;
}


int main(){
    long int N;
    cin>>N;
    long int R[N],G[N],B[N],r=0,g=0,b=0;
    long long ans;
    string S;
    cin>>S;
    for (int i=0;i<N;i++){
        if (S[i]=='R'){
            R[r]=i;
            r+=1;
        }
        else if (S[i]=='G'){
            G[g]=i;
            g+=1;
        }
        else{
            B[b]=i;
            b+=1;
        }
    }
    ans=r*g*b;
    for (long int i=0;i<r;i++){
        for (long int j=0;j<g;j++){
            if ((R[i]+G[j])%2==0) ans-=f((R[i]+G[j])/2,B,0,b);
            ans-=f(2*R[i]-G[j],B,0,b);
            ans-=f(2*G[j]-R[i],B,0,b);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3668
import math, itertools

N = int(input())

n_digit = int(math.log10(N))+1

# N = 10**9-1のときでも七五三数は26484個しかないので、これを全て列挙する

# 桁数を渡すと、その桁数の七五三数を返す関数
memo = [-1]*10
def shichigosan(digit):
    if memo[digit] != -1:
        output = memo[digit]
    else:
        output = set(itertools.product([3, 5, 7], repeat=digit))
        tmp = set(itertools.product([3,5], repeat=digit))|set(itertools.product([5,7], repeat=digit))|set(itertools.product([3,7], repeat=digit))
        output -= tmp
        memo[3] = output
        memo[digit] = output
    return output

ans = 0
for i in range(3,n_digit):
    ans += len(shichigosan(i))

ans += len([x for x in shichigosan(n_digit) if int("".join(map(str, x))) <= N])

print(ans)

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

int main()
{
    string str1;
    int sum = 0;
    cin>>str1;

    while(str1!="0"){
        sum=0;
        for(int i=0;i<str1.length();i++){
            sum += str1[i] - '0';
        }
        cout << sum <<endl;
        cin >> str1;
    }


    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N;
    pair<int,pair<int,int> > pos[100005];
    cin >> N;
    pos[0].first =0;
    pos[0].second.first = 0;
    pos[0].second.second = 0;
    FOR(i,1,N+1){
        cin >>pos[i].first >>pos[i].second.first >>pos[i].second.second;
    }
    int kyori,jikan;
    FOR(i,1,N+1){
        kyori = abs(pos[i].second.first -pos[i-1].second.first)+abs(pos[i].second.second -pos[i-1].second.second);
        jikan = (pos[i].first-pos[i-1].first);
        if(jikan < kyori || (jikan-kyori)%2 != 0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    
    string ans = "No";
    if(a==b && b==c){
        ans = "Yes";
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
rests = []
for i in range(N):
    s, p = input().split()
    rests.append((i+1, s, int(p)))
restsSorted = sorted(rests, key=(lambda x: x[2]), reverse=True)
restsSorted = sorted(restsSorted, key=(lambda x: x[1]))
for x in restsSorted:
    print(x[0])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  long long a[5];
  long long n,ans=0,x=0;
  cin>>n;
  for(int i=0;i<5;i++){
    cin>>a[i];
    x=max(x,(n+a[i]-1)/a[i]);
  }
  if(x!=0)
  cout<<5+x-1<<endl;
  else
  cout<<5<<endl;
}

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

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
#include "/home/koji0708/go/src/github.com/kjnh10/pcl/template/codes/lib/dump.hpp"
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s = "0";
  string t;cin>>t;
  s += t;
  int n = sz(s)-1;
  dump(s, n);

  if (!(s[1]=='1' && s[n]=='0')){
    cout << -1 << endl;
    return 0;
  }
  rep(i, 1, n){
    if (s[i]!=s[n-i]){
      cout << -1 << endl;
      return 0;
    }
  }

  int last = 1;
  vector<pii> e;
  rep(i, 1, n){
    e.pb(mp(last, i+1));
    if (s[i]=='1') {
      last = i+1;
    }
  }
  dump(e);
  each(el, e){
    cout << el.first << " " << el.second << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 3264
#include<stdio.h>
int main(void){
    while(1){
        int N,Q,R;
        int M,hoge;
        scanf("%d%d",&N,&Q);
        if(N+Q==0) break;
        int cnt[100]={0};
        for(int i=0;i<N;i++){
            scanf("%d",&M);
            for(int j=0;j<M;j++){
                scanf("%d",&hoge);
                cnt[hoge]++;
            }
        }
        int max=0;
        int maxi=0;
        for(int i=0;i<100;i++){
            if(max<cnt[i]){
                max=cnt[i];
                maxi=i;
            }
        }
        if(max<Q) printf("0\n");
        else printf("%d\n",maxi);
    }
}



Measured memory_bytes: 1976
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    print!("{}",read::<f32>()/read::<f32>())
}

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

int n;
int a;
int maxx,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		maxx=max(maxx,a);
		if(a>=maxx){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {

  input = input.split(" ");
	// input = input.split("\n");
	// tmp = input[1].split(" ");

	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

// Convert String to Integer
  var a = ~~input[0];
  var b = ~~input[1];

var AtCoder = function(){};

AtCoder.prototype.check = function(a, b){
  if(a*b%2 == 0){
    console.log("Even");
    return
  }else{
    console.log("Odd");
    return
  }
}
	// console.log('%d %d',N,Q);
  var AtCoder = new AtCoder();
  AtCoder.check(a,b);
}


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


Measured memory_bytes: 21064
def get(num):
    n=0
    is_prime=[0]*300050
    for i in range(0,num+1):
        is_prime[i]=True
    is_prime[0]=is_prime[1]=False
    for i in range(2,num+1):
        if(is_prime[i]):
            n+=1
            for j in range(2*i,num+1,i):
                is_prime[j]=False
    return n

while True:
    a=map(int,raw_input().strip().split())
    b=a[0]
    if(b==0):
        break
    p=get(2*b)-get(b)

#        p=0
#        for i in range(b+1,2*b+1):
#            if(judge(i)):
#                p+=1
    print(p)



Measured memory_bytes: 18744
#include <cstdio>
using namespace std;


int N, X;
int m[100];


int main() {
    scanf("%d %d", &N, &X);
    for(int i = 0; i < N; i++) {
        scanf("%d", m + i);
    }

    int ans = N;
    int sum = 0;
    for(int i = 0; i < N; i++) {
        sum += m[i];
    }
    X -= sum;

    int min_index = 0;
    int min_vol = m[0];
    for(int i = 1; i < N; i++) {
        if(m[i] < min_vol) {
            min_vol = m[i];
            min_index = i;
        }
    }

    while(X >= m[min_index]) {
        ans++;
        X -= m[min_index];
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    char a,b;
    cin >> a >> b;

    if(a == b)P("=");
    else if( a < b) P("<");
    else P(">");
	
	return  0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc82_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(input);

            int sequence=0;
            int seq_num=0;

            int cnt=0;

            for(int i=0; i<n; i++){
                if(seq_num == input[i]){
                    sequence++;
                }else{
                    if(sequence<seq_num)cnt += sequence;
                    else cnt += sequence - seq_num;

                    //WriteLine($"{input[i]} {sequence} {seq_num}");

                    sequence = 1;
                    seq_num = input[i];
                }
            }
            if(sequence<seq_num)cnt += sequence;
            else cnt += sequence - seq_num;

            WriteLine($"{cnt}");
        }
    }
}

Measured memory_bytes: 30300
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;
long long int mpown(long long int m, int n);
long long int bign=1000000007;
int bitCount(int bits);
int main()
{
    int n,m;
    cin >> n >> m;
    int st=1,en=n;
    int l,r;
    for(int i=0;i<m;i++){
        cin >> l >> r;
        st=max(l,st);
        en=min(r,en);
    }
    if((en-st+1)>0)cout << (en-st+1) << endl;
    else cout << 0 << endl;
    return 0;
}

int bitCount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);             //  32ビット分を計算
}
long long int mpown(long long int m, int n)
{
    if (n == 0)
        return 1;
    else if (n == 1)
        return m;
    else
    {
        long long int temp = mpown(m, n / 2);
        return temp * temp * (n & 1 ? m : 1);
    }
}

Measured memory_bytes: 3136
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
#include <boost/math/common_factor_rt.hpp>

#define ll long long
using namespace std;
ll t[105] = {};
int main()
{
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	ll ans = t[0];

	for (int i = 1; i < n; i++)
	{
		ans = boost::math::lcm(ans, t[i]);
	}

	cout << ans << endl;
}

int dsum(ll a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}


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

int main(){
    int n,w;
    cin >> n >> w;

    vector<int> value(n),weight(n);

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

    int dp[n+1][w+1];

    for(int i=0;i<=w;i++){
        dp[0][i] = 0;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if(j-weight[i]>=0){
                dp[i+1][j] = max(dp[i][j],dp[i+1][j-weight[i]]+value[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    int ans = 0;

    for(int i=0;i<=w;i++){
        ans = max(ans,dp[n][i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 7028
import java.util.Scanner;

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

        String S = scanner.nextLine();
        switch (S) {
            case "MON":
                System.out.println(6); break;
            case "TUE":
                System.out.println(5); break;
            case "WED":
                System.out.println(4); break;
            case "THU":
                System.out.println(3); break;
            case "FRI":
                System.out.println(2); break;
            case "SAT":
                System.out.println(1); break;
            case "SUN":
                System.out.println(7); break;
        }
    }
}

Measured memory_bytes: 21588
class UnionFind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])
        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)
        if u == v:
            return
        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0
            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

N, M = map(int, input().split())
uf = UnionFind(N+1)
for _ in range(M):
    a, b = map(int, input().split())
    uf.unite(a, b)
ans = max(uf.count(i) for i in range(1, N+1))
print(ans)


Measured memory_bytes: 20084
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

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

	int n;
	cin >> n;
	long long a;

	long long ans=0;
	for(int i=0;i<n;i++){
		cin >> a;
		while(true){
			if(a%2 == 0) {
				ans++;
				a /= 2;
			}
			else break;

			if(a  < 2) break;
		}
	}
	cout << ans << "\n";
	return 0;
}

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

int max,sign;
char line[100],line1[100];
void plus(int place,int add){
    int sum;
    if(place == max+1)
        return;
    sum=line[place]+line1[place]+add;
    if(sum > '9'+'0'){
        if(place+1 == 80){
            sign=1;
            return;
        }
        line[place]=sum-'0'-10;
        plus(place+1,1);

    }
    else{
        line[place]=sum-'0';
        plus(place+1,0);
    }
    return;
}

int main(void){
    int num,i,o,num1,num2,s;
    char temp;
    scanf("%d",&num);
    for(i=0;sign=0,memset(line,'0',sizeof(line)),memset(line1,'0',sizeof(line1)),i<num;i++){
        scanf("%s%s",line,line1);
        num1=strlen(line);
        line[num1]='0';
        num2=strlen(line1);
        line1[num2]='0';
        for(o=0,s=num1-1;o<s;o++,s--){
            temp=line[o];
            line[o]=line[s];
            line[s]=temp;
        }
        for(o=0,s=num2-1;o<s;o++,s--){
            temp=line1[o];
            line1[o]=line1[s];
            line1[s]=temp;
        }
        num1>num2?max=num1:(max=num2);
        max>=81?:plus(0,0);
        if(max >= 81 || sign)
            puts("overflow");
        else{
            if(line[max] == '0')
                for(o=max-1;o != -1;o--)
                    putchar(line[o]);
            else
                for(o=max;o != -1;o--)
                    putchar(line[o]);
            puts("");
        }
    }
    return 0;
}

Measured memory_bytes: 1648
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<vector<int>> tree;
	int ans = 0;
	
	cin>>N;
	
	tree.resize(N);
	
	for(int i = 0; i < N-1; i++){
		int a, b;
		
		cin>>a>>b;
		
		a--, b--;
		
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	
	for(int i = 1; i <= N; i++){
		ans += i * (N - i + 1) ;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < tree[i].size(); j++){
			if(tree[i][j] > i) continue;
			
			ans -= (tree[i][j] + 1) * (N - i);
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 15816
import heapq
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n):
    c.append(b[i]-a[i])
#print(c)
ans = 0
su = 0
for i in c:
    if (i > 0):
        ans += 1
        su += i
#print(ans, su)
heapq.heapify(c)
#print(c)
while (su > 0):
    t = heapq.heappop(c)
    if (t >= 0):
        print(-1)
        exit(0)
    su += t
    ans += 1
print(ans)

Measured memory_bytes: 93488
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[100010];

ll rui(ll a,ll n){
	ll ans=1;
	while(n>0){
		if(n&1) ans=ans*a%mod;
		a=a*a%mod;
		n/=2;
	}
	return ans;
}

int main(){
	ll n,k; cin >> n >> k;
	for(int i=k;i>=1;i--){
		dp[i]=rui(k/i,n);
		ll cnt=2;
		while(i*cnt<=k){
			dp[i]-=dp[i*cnt];
			if(dp[i]<0) dp[i]+=mod;
			cnt++;
		}
	}
	ll ans=0;
	for(int i=1;i<=k;i++){
		ans+=i*dp[i]%mod;
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4372
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fill(x,c) memset(x,c,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int SIZE = 1e6+10;
ll a[SIZE];
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	char c;cin>>c;
	cout<<(char)(c+1);
  	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int x, y, z;
  scanf("%d", &x);
  z = x / 3600;
  x = x - z * 3600;
  y = x / 60;
  x = x - y * 60;
  printf("%d:%d:%d\n", z, y, x);
  return 0;
}


Measured memory_bytes: 2104
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
L.sort()
tmp = [[] for _ in range(C)]
for s, t, c in L:
    if tmp[c - 1]:
        if tmp[c - 1][-1][1] == s:
            tmp[c - 1][-1][1] = t
            continue
    tmp[c - 1].append([s, t])
l = []
for v in tmp:
    for i in v:
        l.append(i)
l.sort()

r = [0] * C
for s, t in l:
    for i in range(C):
        if r[i] < s:
            r[i] = t
            break
print(sum(1 for i in r if i))            

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

int main()
{
  int n;
  cin >> n;

  char str[100] = "";

  for (int i = 0; i < n; i++)
  {
    str[i] = 'a';
  }

  cout << str << endl;
  while (1)
  {
    for (int i = n - 1; i > 0; i--)
    {
      for (int j = i - 1; j > -1; j--)
      {
        if (str[i] <= str[j])
        {
          str[i]++;
          for (int k = i + 1; k < n; k++)
          {
            str[k] = 'a';
          }
          goto ok;
        }
      }
    }
    return 0;
  ok:
    cout << str << endl;
  }
}


Measured memory_bytes: 1536
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			// 個々の数字の出現回数を保存するマップ
			Map<Integer, Integer> map = new HashMap<>();
			long sum = IntStream.range(0, n).mapToLong(i -> {
				int a = scanner.nextInt();
				map.put(a, map.getOrDefault(a, 0) + 1);
				return a;
			}).sum();
			int q = scanner.nextInt();
			for (int i = 0; i < q; i++) {
				int b = scanner.nextInt(), c = scanner.nextInt();
				int count = map.getOrDefault(b, 0);
				if (count > 0) {
					map.remove(b);
					map.put(c, map.getOrDefault(c, 0) + count);
					sum = sum + (c - b) * (long) count;
				}
				System.out.println(sum);
			}
		}
	}
}


Measured memory_bytes: 63492
#include <bits/stdc++.h>
#define N 100010
using namespace std;

double mem[N][50];
bool used[N][50];
double dfs(int day,int cnt,double p){
  if(day == 0) return 0;
  if(cnt >= 50) return 0;
  if(used[day][cnt])return mem[day][cnt];
  used[day][cnt] = 1;
  double res = 0;
  res+=p*(1+dfs(day-1,cnt+1,p/2));
  if(cnt)res+=(1-p)*dfs(day-1,0,1);
  return mem[day][cnt] = res;
}

int main(){
  int n;
  while(cin>>n,n)printf("%f\n",dfs(n,0,1));
  return 0;
}

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

using namespace std;

#define mp make_pair
#define ll long long

int
main(void){
	int h, w, n;
	cin >> h >> w >> n;
	map<pair<int, int>, int> black;
	map<pair<int, int>, int> used;
	vector<pair<int, int> > vec(n);
	for(int i = 0; i < n; i++){
		cin >> vec[i].first >> vec[i].second;
		black[vec[i]] = 1;
	}
	vector<int> ans(10, 0);
	for(int i = 0; i < n; i++){
		int x = vec[i].first;
		int y = vec[i].second;
		for(int r = x; x - r < 3; r--){
			for(int c = y; y - c < 3; c--){
				if(r < 1 || c < 1 || r > h || c > w || used[mp(r, c)] == 1 || r + 2 > h || c + 2 > w){
					continue;
				}
				int count = 0;
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						count += black[mp(r + j, c + k)];
					}
				}
				used[mp(r, c)] = 1;
				ans[count]++; 
			}
		}
	}
	ll zero = (h - 2) * 1ll * (w - 2);
	for(int i = 1; i <= 9; i++) zero -= ans[i];
	cout << zero << "\n";
	for(int i = 1; i <= 9; i++) cout << ans[i] << "\n";
	
}

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

int main()
{
  int n;
  cin >> n;
  
  //1円単位の税込価格nを108で割って、それに100を掛けて税抜価格として...とやるが、
  double n_double = (double)n;
  double x_one = n_double / 108;

  //整数の税抜価格の候補を求めるときの誤差としては、100を掛けたときのfloorとceilで十分と思われる
  double x_proto = x_one * 100;

  int x_int_proto_1 = (int)x_proto;
  int x_int_proto_2 = x_int_proto_1 + 1;
  
  //1.08を掛けた値をintキャストでfloorして、nと比較。
  if (n == (int)(x_int_proto_1 * 1.08)) cout << x_int_proto_1 << endl;
  else if(n == (int)(x_int_proto_2 * 1.08)) cout << x_int_proto_2 << endl;
  else cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
p = [0]*m
s = [0]*m
ans = [0]*n
anp = 0
pe = [0]*n

for i in range(m):
	p[i],s[i] = map(str,input().split())
	p[i] = int(p[i])

	if s[i] == 'AC' and ans[p[i]-1] == 0:
		ans[p[i]-1] += 1
		
	if ans[p[i]-1] == 0 and s[i] == 'WA':
		pe[p[i]-1] += 1
for i in range(n):
	if ans[i] == 1:
		anp += pe[i]

print(*[sum(ans),anp])

Measured memory_bytes: 21424
#include<bits/stdc++.h>
using namespace std;
int x,y,du[5];
int main()
{
	for(int i=1;i<=3;i++)scanf("%d%d",&x,&y),du[x]++,du[y]++;
	for(int i=1;i<=4;i++)if(du[i]>=3){puts("NO");return 0;}
	puts("YES");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> Graph[N];
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }
    vector<bool> Judge(N, false);
    vector<int> End0, End1;
    End0.push_back(0);
    Judge[0] = true;
    int now = 0;
    while(true) {
        bool judge = true;
        for(auto x : Graph[now]) {
            if(Judge[x]) continue;
            judge = false;
            now = x;
            Judge[now] = true;
            End0.push_back(x);
            break;
        }
        if(judge) break;
    }
    now = 0;
    while(true) {
        bool judge = true;
        for(auto x : Graph[now]) {
            if(Judge[x]) continue;
            judge = false;
            now = x;
            Judge[now] = true;
            End1.push_back(x);
            break;
        }
        if(judge) break;
    }
    reverse(all(End1));
    int s0 = End0.size(), s1 = End1.size();
    cout << s0 + s1 << endl;
    for(auto x : End1) cout << x + 1 << ' ';
    for(auto x : End0) cout << x + 1 << ' ';
}


Measured memory_bytes: 7156
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;


int main() {
	int a,b;

	cin >> a >> b;

	cout << a * b << endl;

	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pii;

int32_t main()
{
	int a[5] ;
	for(int i = 0 ; i < 5 ; i++)
	{
		cin >> a[i] ;

		if(a[i] == 0){
			cout << i + 1 ;
			return 0 ;
		}
	}
	return 0;
}        

Measured memory_bytes: 3628
/**
 *      ABC 43 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 07:28:19
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}

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


int main() {
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  
  std::sort(a.begin(), a.end(), std::greater<int>());
  
  int m = n - 2;
  
  long long ans = a[0];
  
  for (int i = 1; i < n; ++i) {
    if (m == 0) break;
    if (m == 1) {
      ans += a[i];
      break;
    }
    ans += a[i] * 2;
    m -= 2;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 4060
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

if n > 1:
    a.append(0)
    biggest = a[0]
    now = 0
    while m > 0:
        a[now] = a[now]//2
        m -= 1
        biggest = a[0]
        for i in range(n-1):
            if a[i+1] >= biggest and m > 0:
                a[i+1] = a[i+1]//2
                m -= 1
            else:
                a.sort(reverse=True)
                break
    else:
        quit

else:
  for j in range(m):
    a[0] //= 2

print(sum(a))

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

int main(){
  int d[3], mini=300, i, k;

  for(i=0; i<3; i++) cin >> d[i];

  for(i=0; i<3; i++){
    for(k=0; k<3; k++){
      if(i!=k){
        mini = (mini>d[i]+d[k]) ? d[i]+d[k] : mini;
      }
    }
  }

  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <tuple>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for(int i=(is), i##_end=(ie); i<=i##_end; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFF
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")

typedef long long ll;
using namespace std;

int main() {
    
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    REP(i, n) cin >> a[i];

    vector<vector<ll>> dp(n, vector<ll>(n, 1145141919810893ll));
    vector<ll> imos(n+1, 0);

    // 初期値
    REP(i, n) dp[i][i] = 0;
    REP(i, n) imos[i+1] = imos[i] + a[i];

    // 漸化式
    RANGE(r, 1, n) RANGE(left, 0, n-r-1) {
        int right = left + r;
        RANGE(subright, left, right-1) {
            chmin(dp[left][right], dp[left][subright] + dp[subright+1][right] + imos[right+1] - imos[left]);
        }
    }

    cout << dp[0][n-1] << endl;
    
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    int r = 0;
    int cnt = 0;
    cin >> N;
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i]=='R') r++;
    }
    rep(i, r){
        if(s[i]!='R') cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;

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

  int multi4 = 0, multi2 = 0, odd = 0;
  for(i = 0; i < n; i++){
    if(a[i]%4 == 0) multi4 += 1;
    else if(a[i]%2 == 0) multi2 += 1;
  }
  odd = n - multi4 - multi2;

  int enable_range = 0;
  if(multi4 >= n/2) enable_range = multi4*2 + 1;
  else enable_range = multi4*2;

  if(multi2%2 == 0 || odd - multi4 <= 0) enable_range += multi2;
  else enable_range += multi2/2;

  if(n <= enable_range){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  string s;
  cin >> s;
  int s_size = s.size();
  int mn = 10000;
  for (int i = 0; i < 26; i++) {
    s_size = s.size();
    vector<int> pos(s_size);
    int cnt = 0;
    for (int j = 0; j < s_size; j++) {
      if (s[j] - 'a' == i) pos[j] = 1;
    }
    if (accumulate(pos.begin(), pos.end(), 0) == 0) continue;
    debug(pos);
    while (accumulate(pos.begin(), pos.begin() + s_size, 0) != s_size) {
      for (int j = 1; j < s_size; j++) {
        if (pos[j] == 0) continue;
        pos[j - 1] = 1;
      }
      cnt++;
      s_size--;
    }
    mn = min(cnt, mn);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		String s = sc.next();
		
		for (int i = 0; i < s.length(); i+=2) {
			sb.append(s.charAt(i));
		}
		
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 25524
//by OIerC
//Forca Barcelona!
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

map<vector<int>, int> Map;

int main()
{
	vector<int> ch(26);
	
	int n = read();
	
	long long ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int i = 0; i < 26; ++i) ch[i] = 0;
		
		char s[100];
		scanf("%s", s);
		for (int i = 0; i < 10; ++i) ++ch[s[i] - 'a'];
		
		if (Map[ch] > 0) ans += Map[ch];
		++Map[ch];
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e6+5;
ll inf=1e15;
ll spf[sz];
ll cnt[sz];

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    for(int i=1;i<sz;i++){
        spf[i]=i;
    }
    for(int i=4;i<sz;i+=2){
        spf[i]=2;
    }

    for(int i=3;i*i<sz;i++){
        if(spf[i]==i){
            for(int j=i*i;j<sz;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
    while(t--)
    {
        ll n;
        cin>>n;
        for(int i=0;i<n;i++){
            ll x;
            cin>>x;
            map<int,int> mp;
            while(x!=1){
                mp[spf[x]]++;
                x/=spf[x];
            }
            for(auto y:mp){
                cnt[y.first]++;
            }
        }
        int cntn=0,cnt1=0;
        for(int i=2;i<sz;i++){
            if(cnt[i]){
                if(cnt[i]>1){
                    cnt1++;
                }
                if(cnt[i]==n){
                    cntn++;
                }
            }
        }
        if(cntn){
            cout<<"not coprime";
        }
        else if(cnt1){
            cout<<"setwise coprime";
        }
        else
            cout<<"pairwise coprime";
    }

    return 0;
}

Measured memory_bytes: 19280
def main():
    N = int(input())
    A = list(map(int, input().split()))
    all_leave_num = sum(A)

    if((len(A) != 1 and A[0] != 0) or (len(A) == 1 and A[0] != 1)):
        print(-1)
        return

    # Init
    node_num = 0
    next_node_w_children = 1
    next_node_num = 1
    
    for i in range(N+1):
        node_in_the_dept = next_node_num
        node_w_children = next_node_w_children      

        if(i == N):
            node_num += node_in_the_dept
            print(node_num)
        else:
            next_leaf_num = A[i+1]
            all_leave_num -=A[i]

            next_node_num = min(2 * node_w_children, all_leave_num)
            next_node_w_children = next_node_num - next_leaf_num
            if(next_node_num > node_w_children * 2 or next_node_num < node_w_children or next_node_w_children < 0):
                print(-1)
                return
            node_num += node_in_the_dept
    

main()

Measured memory_bytes: 20520
def main():
    N,Y = map(int,input().split())
    for i in range(Y//10000+1):
        for j in range(N-i+1):
            if Y == i *10000 + j * 5000 + (N-i-j) * 1000:
                print(*[i,j,N-i-j])
                return
    print(*[-1,-1,-1])
main()

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()

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

    map<ll, ll> mp;
    mp[0] = 1;
    ll tmp = 0;
    REP(i, n) {
        tmp += a[i];
        mp[tmp]++;
    }

    ll ans = 0;
    for(auto x: mp) {
        if(mp[x.first] == 0) continue;
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
/* C++のstdio.hみたいなもの、cin (scanf), cout (printf) のためにincludeします。 */
using namespace std;
/* 名前空間にstdを指定する。毎回、std::cin , std::cout と記述するのはうっとおしいので省略するため。*/

#define MAX 500000
#define SENTINEL 2000000000 // 番兵

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
// C++forループ専用のint型を宣言できる
// ループの中のみ有効なので安全
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int left,int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,left,mid);
    mergeSort(A,mid, right);
    merge(A,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

	cin >> n; // scanf("%d",&n);
  for(i=0;i<n;i++) cin >> A[i];

  mergeSort(A, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
  	cout << A[i]; // printf("%d",A[i]);
  }
  cout << endl; // endlは改行

  cout << cnt << endl; // printf("\n");

  return 0;
}



Measured memory_bytes: 6964
#include<iostream>

using namespace std;

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

	int a[5];
	int mod10;
	int mod10max = -1;
	int ans = 0;
	for(int i=0; i<5; i++){
		cin >> a[i];
		if(a[i]%10==0) mod10 = 0;
		else mod10 = 10-(a[i]%10);
		mod10max = max(mod10, mod10max);
		ans += a[i] + mod10;
	}
	cout << ans-mod10max;
	return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var WHN = ReadIntArray();
            int[] rect = new int[4];
            rect[0] = 0;
            rect[1] = WHN[0];
            rect[2] = 0;
            rect[3] = WHN[1];

            for (int i = 0; i < WHN[2]; i++)
            {
                var xya = ReadIntArray();
                switch (xya[2])
                {
                    case 1:
                        rect[0] = Math.Max(xya[0], rect[0]);
                        break;
                    case 2:
                        rect[1] = Math.Min(xya[0], rect[1]);
                        break;
                    case 3:
                        rect[2] = Math.Max(xya[1], rect[2]);
                        break;
                    case 4:
                        rect[3] = Math.Min(xya[1],rect[3]);
                        break;
                }
            }

            // -width * -heightの場合にプラスになって不正な値になってしまう
            var ret = Math.Max(0, (rect[1] - rect[0]) * Math.Max(0, (rect[3] - rect[2])));
            Console.WriteLine(ret);
        }


        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int a, b, c; cin >> a >> b >> c;

    if(a + b + 1 < c) {
        cout << (a + 2 * b + 1) << endl;
        return 0;
    }

    cout << b + c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	if(s=="RRR")cout<<3<<endl;
	else{
		if(s=="RRS"||s=="SRR")cout<<2<<endl;
		else if(s!="SSS")cout<<1<<endl;
		else cout<<0<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 3596
n = int(input())

w = []

for i in range(n):
    w.append(list(input()))

#print(w)

for i in range(n):
    if i != 0:
        if w[i] in w[0 : i - 1]:
            print("No")
            exit(0)
        
        if w[i][0] != w[i - 1][-1]:
            print("No")
            exit(0)

print("Yes")


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

int main(){
  int N;
  cin >> N;
  if(888<N){
    cout << "999" << endl;
  }else if(777<N){
    cout << "888" << endl;
  }else if(666<N){
    cout << "777" << endl;
  }else if(555<N){
    cout << "666" << endl;
  }else if(444<N){
    cout << "555" << endl;
  }else if(333<N){
    cout << "444" << endl;
  }else if(222<N){
    cout << "333" << endl;
  }else if(111<N){
    cout << "222" << endl;
  }else if(99<N){
    cout << "111" << endl;
  }
}


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


int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624