akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,    // 縦棒の長さ - 1
        w: usize,    // 縦棒の本数
        k: usize,    // 最終的に辿り着かなければならない縦棒は左から何番目か
    }

    let m = 1_000_000_007;

    // a[h][x] h = 上からh列目を通過した直後, x = 左からx番目の縦棒にいる
    // その場合の数
    let mut a = [[0u64; 1000]; 1000];

    a[0][0] = 1;

    for h in 1..(h+1) {
        for bars in 0u8..(1 << (w-1)) {
            // 連結があるならスキップ
            if bars & (bars << 1) != 0 {
                continue;
            }

            for x in 0..w {
                let left = x > 0 && (bars & (1 << (x-1)) != 0);
                let right = x < w-1 && (bars & (1 << x) != 0);

                // println!("h = {}, x = {}", h, x);
                // println!("bar = {:b}, left = {}, right = {}", bars, left, right);
                // 左へ行くか
                if left {
                    a[h][x-1] += a[h-1][x];
                    a[h][x-1] %= m;
                }
                // 右へ行くか
                else if right {
                    a[h][x+1] += a[h-1][x];
                    a[h][x+1] %= m;
                }
                // まっすぐ降りるか
                else {
                    a[h][x] += a[h-1][x];
                    a[h][x] %= m;
                }

                // for x in 0..w {
                    // print!("{} ", a[h][x]);
                // }
                // println!("");

            }
        }

        // println!("h = {}, result ...", h);
        // for x in 0..w {
            // print!("{} ", a[h][x]);
        // }
        // println!("");
    }

    println!("{}", a[h][k-1] % m);
}


Measured memory_bytes: 12156
# -*- coding: utf-8 -*-


def main():
    # 入力
    # st = input()

    # 右からi文字目から最後の数字までを数値化したものについてmodを計算していく
    mod_res_dic = {0: 1}
    tmp_mod_val = 0
    # r_st = ''.join(list(reversed(st)))
    cnt = 0
    i = 0
    for s in reversed(input()):
        tmp_mod_val += int(s) * pow(10, i, 2019)
        tmp_mod_val %= 2019
        ls = mod_res_dic.setdefault(tmp_mod_val, 0)
        mod_res_dic[tmp_mod_val] = ls + 1
        i += 1
        if ls > 0:
            cnt += ls

    print(cnt)


main()


Measured memory_bytes: 9308
#include<stdio.h>
int main(void)
{
	int a, b, c, i;
	int d = 0;

		scanf("%d %d %d", &a, &b, &c);

		for (i = a; i <= b; i++) {
			if (c % i == 0) {
				d++;
			}
			else;
		}

		printf("%d\n", d);

	return(0);
}


Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
using namespace std;

int collatz(int n)
{
	if (n % 2 == 0)
		return n / 2;
	else
		return 3 * n + 1;
}

int main()
{
	int s, t, m;
	int cnt = 1;
	set<int> x;
	cin >> s;
	t = s;
	while (true) {
		if (x.find(t) == x.end()) {
			x.insert(t);
		}
		else {
			cout << cnt << endl;
			return 0;
		}
		cnt++;
		t = collatz(t);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include<set>
using namespace std; 
int main(void){
    int N,M;
  	scanf("%d%d",&N,&M);
  vector<int> H(N);
  set<int>st;
  for(int i= 0;i<N;i++){
  	cin >>  H.at(i);
    st.insert(i+1);
  }
  for(int j = 0;j<M;j++){
    int a,b;
    scanf("%d%d",&a,&b);
    if(H[a-1]-H[b-1]<0){
      st.erase(a);
    }else if(H[a-1]-H[b-1]>0){
      st.erase(b);
    }
    if(H[a-1]-H[b-1]==0){
      st.erase(a);
      st.erase(b);
    }

  }
      cout << st.size();
}

Measured memory_bytes: 7932
# 駅jjを出発する時刻は、
#S[j]+F[j]×kS[j]+F[j]×kとなる(kは車両数)。
#出発する時刻は現在時刻tt以上である必要があるので、
#S[j]+F[j]×k≥tS[j]+F[j]×k≥tとする。 式変形

N = int(input())
C = [0]*(N+1)
S = [0]*(N+1)
F = [0]*(N+1)
for i in range(N-1):
  c, s, f = map(int, input().split())
  C[i] = c
  S[i] = s
  F[i] = f

for i in range(N): # 駅iを始点とする
  t = 0 # 現在時刻
  for j in range(i, N-1):
    # kはマイナスの値になる場合もあるので、その時はk=0k=0にする。
    k = max(0, (t-S[j]+F[j]-1) // F[j])
    t = S[j] + F[j]*k + C[j]
  print(t)





Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N;
    cin >> N;
    
    vector<ll> A(N + 1, 0), S(N + 1, 0);
    A[1] = N;
    S[1] = N;
    A[2] = N * N % mod;
    S[2] = (A[2] + S[1]) % mod;
    rep(i, 3, N + 1){
        A[i] = (N - 1) * (N - 1) % mod;
        (A[i] += A[i - 1]) %= mod;
        (A[i] += S[i - 3] + N - 1 - (i - 3)) %= mod;
        
        S[i] = S[i - 1] + A[i];
        S[i] %= mod;
    }
    output(A[N]);
    
    
    
    return 0;
}

Measured memory_bytes: 15872
from collections import defaultdict

N = input().strip()
K = int(input().strip())
lenN = len(N)

memo = defaultdict(lambda :defaultdict(lambda :defaultdict(int)))
def f(keta, flag, k):
    if keta == lenN-1:
        if k == K:
            return 1
        else:
            return 0
    if keta in memo and flag in memo[keta] and k in memo[keta][flag]:
        return memo[keta][flag][k]
    nketa = keta + 1
    maxi = int(N[nketa]) if flag else 9
    res = 0
    for i in range(maxi+1):
        nflag = flag and (int(N[nketa]) == i)
        nk = k if i == 0 else k + 1
        if nk > K:
            continue
        res += f(nketa, nflag, nk)
    memo[keta][flag][k] = res
    return res

print(f(-1, True, 0))


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

int main(){
    int PRIZE[3] = {300000, 200000, 100000};
    int SPECIALPRIZE = 400000;

    int codeNumber;
    int deviceNumber;
    int resultPrize = 0;

    cin >> codeNumber >> deviceNumber;

    if( codeNumber < 4 ){
        resultPrize += PRIZE[codeNumber - 1];
    }

    if( deviceNumber < 4 ){
        resultPrize += PRIZE[deviceNumber - 1];
    }

    if( deviceNumber == 1 && codeNumber == 1 ){
        resultPrize += SPECIALPRIZE;
    }

    cout << resultPrize << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int F[110][10];
    int P[110][12];
    rep(i, N) {
        rep(j, 10) {
            cin >> F[i][j];
        }
    }
    rep(i, N) {
        rep(j, 11) {
            cin >> P[i][j];
        }
    }
    int ans = 0;
    rep(i, N) {
        int cnt = 0;
        rep(j, 10) {
            if((1 & (1<<j)) && F[i][j] == 1) {
                cnt ++;
            }
        }
        ans += P[i][cnt];
    }
    for(int bit = 1; bit < (1<<10); bit++) {
        int res = 0;
        rep(i, N) {
            int cnt = 0;
            rep(j, 10) {
                if((bit & (1<<j)) && F[i][j] == 1) {
                    cnt ++;
                }
            }
            res += P[i][cnt];
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int ans=0;
    int n=sz(s);
    for(int i=n-3;i>=0;i-=2){
        bool valid=true;
        for(int j=0;j<=i/2;++j){
            if(s[j]!=s[(i/2)+1+j]){
                valid=false;
                break;
            }
        }
        if(valid){ ans=i+1;break;}
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    ll calc(int n,int k){
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
};

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    pair<int,int> p[n+1];
    for(int i=0;i<n;i++){
        int r,c;
        cin>>r>>c;
        p[i]={r,c};
    }
    p[n]={h,w};
    sort(p,p+n+1);
    Combination comb(200000);
    ll dp[n+1];
    for(int i=0;i<n+1;i++){
        int ri=p[i].first;
        int ci=p[i].second;
        dp[i]=comb.calc(ri+ci-2,ri-1);
        for(int j=0;j<i;j++){
            int rj=p[j].first;
            int cj=p[j].second;
            if(rj<=ri&&cj<=ci){
                ll t=comb.calc(ri-rj+ci-cj,ri-rj);
                dp[i]-=(dp[j]*t)%MOD;
            }
        }
        dp[i]%=MOD;
    }
    cout<<(dp[n]+MOD)%MOD<<endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include<string>
using namespace std;
int main(){
    int y=0;
    string a,b;
    cin>>a;
    cin>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            y++;
        }
    }
    cout<<y;
}

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

int main(){
    int n, m; cin >> n >> m;
    P p[m];
    rep(i, m){
        int a, b; cin >> a >> b;
        p[i].first = b;
        p[i].second = a;
    }
    sort(p, p+m);

    int ans = 0;
    bool b[n];
    memset(b, 0, sizeof(b));
    int pre_b = -1;
    rep(i, m){
        if(p[i].second > pre_b) {
            b[p[i].first-1] = true;
            pre_b = p[i].first-1;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
 
int main()
{
  int i,j,k;
  ll H,W,N;
  ll a;
  
  cin >> a;
  
  cout << a + a*a + a*a*a << endl;
  
  
  return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;

bool pal(string s){
    string t = s;
    reverse(t.begin() , t.end());
    return s == t;
}

void solve(int testCase){

    string s;
    cin >> s;

    n = s.length();

    string s1 = s.substr(0 , (n - 1) / 2);
    string s2 = s.substr((n + 3) / 2 - 1 , n);


    if(pal(s) && pal(s1) && pal(s2)){
            printf("Yes\n");
    }
    else{
            printf("No\n");
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
	ll H,W; cin>>H>>W;
	ll cnt=0;
	rep(i,H){
		string tmp; cin>>tmp;
		rep(j,W){
			if(tmp[j]=='#') cnt++;
		}
	}	
	if(cnt==H+W-1) cout<<"Possible";
	else cout<<"Impossible";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b {
		fmt.Println(c)
	} else if b == c {
		fmt.Println(a)
	} else {
		fmt.Println(b)
	}
}


Measured memory_bytes: 1768
from collections import Counter

n = int(input())
s_list = sorted(list(input() for _ in range(n)))

s = Counter(s_list)

ans_num = s.most_common(1)[0][1]

s_1 = sorted(list(s.items()), key=lambda x: x[0])

for i in range(len(s_1)):
    if s_1[i][1] == ans_num:
        print(s_1[i][0])

Measured memory_bytes: 50284
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = S()
    n1 = n[::-1]
    for i in range(len(n)):
        if n1[i] != n[i]:
            print("No")
            return
    print("Yes")
    return

#B
def B():
    a, b, c, d = LI()
    ans = [0 for i in range(101)]
    ans[a] += 1
    ans[b] -= 1
    ans[c] += 1
    ans[d] -= 1
    for i in range(100):
        ans[i+1] += ans[i]
    print(ans.count(2))
#C
def C():
    n = II()
    ans = 1
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    for _ in range(n):
        t = II()
        ans = ans // gcd(ans, t) * t
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 38768
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
L = []
for i in range(N):
    c = int(input())
    a = [[int(v) for v in input().split()] for _ in range(c)]
    L.append(a)

def dfs(index, al):
    for v in L[index]:
        c = v[0] - 1
        if c not in al:
            if v[1]:
                al = dfs(c, al + [c])

    return al

t = [None] * N
for i in range(N):
    t[i] = dfs(i, [i])

ans = 0
for i in range(1 << N):
    a = set()
    for j in range(N):
        if (i >> j) & 1:
            a.add(j)

    for p in list(a):
        for v in t[p]:
            a.add(v)

    s = [-1] * N
    f = True

    for v in a:
        s[v] = 1

    for v in a:
        for x, y in L[v]:
            if s[x-1] == -1:
                s[x-1] = y
            elif s[x-1] != y:
                f = False
    if f:
        ans = max(ans, len(a))

print(ans)

Measured memory_bytes: 44012
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n, a, b) = get!(usize, usize, usize);
    if n + 1 < a + b || n > a * b {
        println!("-1");
        return;
    }

    if a > b {
        let mut current = 0;
        for i in n - a..n {
            print!("{} ", i + 1);
            for j in (current..min!(current + b - 1, n - a)).rev() {
                print!("{} ", j + 1);
            }
            current = min!(current + b - 1, n - a);
        }
        println!("");
    } else {
        let mut current = b;
        for i in (0..b).rev() {
            print!("{} ", i + 1);
            for j in (current..min!(current + a - 1, n)).rev() {
                print!("{} ", n - j + b);
            }
            current = min!(current + a - 1, n);
        }
        println!("");
    }
}


Measured memory_bytes: 10492
from collections import deque

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def submit():
    n, alist = read_input()
    b = deque()

    if n % 2 == 0:
        side = 'right'
    else:
        side = 'left'

    for a in alist:
        if side == 'left':
            b.appendleft(a)
            side = 'right'
        else:
            b.append(a)
            side = 'left'


    print(' '.join(map(str, list(b))))


if __name__ == '__main__':
    submit()

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

using namespace std;

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

#define N 100010
#define M 200010
#define A 110
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int n, m;
	int arr[10010];
	ll tot = 0;
	
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> arr[i];
		tot += arr[i];
	}
	
	if(tot > n){
		cout << -1 << endl;
	}
	else{
		cout << n - tot << endl;
	}
	
	return 0;
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;


  bool ans = false;

  for(int i = A; i <= B; i++){
    if(i % K == 0)
    ans = true;
  }

  if(ans) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3636
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0])
    var X = Number(lines[0].split(" ")[1])

    var x = lines[1].split(" ").map(i => Number(i));

    x.push(X); x.sort((a, b) => a - b);

    var sum = [];
    for (var i = 0; i < x.length - 1; i++) { sum[i] = x[i + 1] - x[i] }

    var ans = 0;
    for (var i = 0; i < sum.length; i++) { ans = gcd(ans, sum[i]) }

    console.log(ans);

});

function gcd(a, b) {
    var r = a % b;
    if (r === 0) { return (b) }
    else { return (gcd(b, r)); }
}

Measured memory_bytes: 29200
#include <iostream>
using namespace std;
int dp[100000],s[100000];
int main(void){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(s[i]-s[i-1]);
        for(int j=1;j<=min(i,k);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(s[i]-s[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


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

using namespace std;

int main()
{
    int n, q, l, r;
    string s;
    cin >> n >> q >> s;
    vector<int> arr(n);
    arr[0] = 0;
    for(int i = 1; i < n; i++)
    {
        if(s[i] == 'C' && s[i - 1] == 'A')
        {
            arr[i] = arr[i - 1] + 1;
        }
        else
        {
            arr[i] =  arr[i - 1];
        }
    }

    while(q > 0)
    {
        cin >> l >> r;
        cout << arr[r - 1] - arr[l - 1] << endl;
        q--;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;
    int carry_over = 0;
    rep(i,n+1) {
        if(b[i] + carry_over >= a[i]){
            ans += a[i];
            carry_over = max(b[i] - max((a[i] - carry_over),0), 0);
        }else{
            ans += b[i] + carry_over;
            carry_over = 0; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

# input
w = input()

# solve
ans = True
for i in range(len(w)):
    if len(w) != 0:
        tmp = w[0]
        count = w.count(tmp)
        w = w.replace(tmp, '')
        if count % 2 != 0:
            ans = False
    else:
        break

# output
print('Yes' if ans else 'No')


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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll a, ll b) {
	ll ret = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)ret *= kakeru, ret %= MOD;
		kakeru *= kakeru, kakeru %= MOD;
		b >>= 1;
	}
	return ret;
}

ll fact[200000 + 100];
ll fact_inv[200000 + 100];

void calc_inv() {
	fact[0] = 1, fact[1] = 1;
	for (int i = 2; i <= 200000 + 10; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}

	fact_inv[200000 + 10] = modpow(fact[200000 + 10], MOD - 2);
	for (int i = 200000 + 9; i >= 0; i--) {
		fact_inv[i] = fact_inv[i + 1] * (i + 1);
		fact_inv[i] %= MOD;
	}
}

ll comb(int a, int b) {
	ll ret = fact[a] * fact_inv[b] % MOD;
	ret = ret * fact_inv[a - b] % MOD;
	return ret;
}

ll N, A, B, C;

int main() {

	calc_inv();

	cin >> N >> A >> B >> C;

	ll ans_bunshi = 0;
	//分母はこの場合だと、100^(2N-1)でいく。
	//100/100-C CとA,Bの試行は独立なので、独立な期待値の積となる。よってかけちゃっていい。
	//これは最後にかける
	ll apb = A + B;
	for (int i = N; i <= 2 * N - 1; i++) {
		//i回目は
		//comb(i - 1, N - 1) * ((A/100)^N * (B/100)^(i - N) + (A/100)^(i - N) * (B/100)^N) * i
		ll tmp = ((comb(i - 1, N - 1) *
			((modpow(A, N) * modpow(B, i - N) % MOD) + (modpow(A, i - N) * modpow(B, N) % MOD)) % MOD)*
			modpow(apb, 2 * N - 1 - i) % MOD);
		tmp *= i, tmp %= MOD;
		ans_bunshi += tmp;
		ans_bunshi %= MOD;
	}
	//ここでCによる期待値補正をかける。
	ans_bunshi *= 100, ans_bunshi %= MOD;
	//分母は100^(2N-1)*(100-C)である。

	cout << (modpow(((modpow(apb, 2 * N - 1) * (100 - C)) % MOD), MOD - 2) * ans_bunshi) % MOD << endl;

	return 0;
}

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

const int N = 200010;

int num[N], n, m, ans = 1e9;

inline bool check(int mid) {
    int res = 0;
    for (int i = 1; i <= mid; i++) res = max(res, num[i] + num[mid * 2 - i + 1]);
    for (int i = 1; i <= n - mid; i++) {
        int t = num[mid * 2 + i] + num[n * 2 - i + 1];
        if (t < m) return false;
        res = max(res, t - m);
    }
    ans = min(ans, res);
    return true;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n * 2; i++) scanf("%d", &num[i]);
    sort(num + 1, num + n * 2 + 1);
    int l = 0, r = n;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) r = mid - 1;
        else l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    deque<int> deq;
    rep(i, 0, N) {
        if (i % 2 == 0) deq.push_back(A[i]);
        else deq.push_front(A[i]);
    }

    rep(i, 0, N) {
        if (0 < i) printf(" ");
        
        int x;
        if (N % 2 == 0) x = deq.front(), deq.pop_front();
        else x = deq.back(), deq.pop_back();
        printf("%d", x);
    }
    printf("\n");
}

Measured memory_bytes: 3840
n,p = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a_odd = [x for x in a if x % 2 == 1]

if len(a_odd) == 0:
    if p == 0:
        print(2 ** n)
    else:
        print(0)
else:
    print(2 ** (n-1))

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

int main(){
    int N,M;cin>>N>>M;
    vector<int> lst(N,-1);
    rep(i,M){
        int s,c;cin>>s>>c;
        s--;
        if(s==0 && c==0 && N!=1){
            cout<<-1<<endl;
            return 0;
        }
        if(lst[s] != c){
            if(lst[s] == -1){
                lst[s] = c;
            }else{
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    int ans = 0;
    rep(i,N){
        if(i == 0){
            if(lst[i]==-1){
                if(N == 1){
                    cout<<0<<endl;
                    return 0;
                }else{
                    ans += pow(10,N-1);
                }
            }else{
                ans += lst[i] * pow(10,N-1);
            }
        }else{
            if(lst[i]!=-1){
                ans += lst[i] * pow(10,N-1-i);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
	public static String s, ans = "Yes";
	public static HashMap<Character, Integer> h = new HashMap<Character, Integer>();
	public static void main(String[] args) throws FileNotFoundException {
//		Scanner in = new Scanner(new File("input.txt"));
		Scanner in = new Scanner(System.in);
		s = in.next();
		char[] sa = s.toCharArray();
		for(char c : sa){
			if(!h.containsKey(c)) h.put(c,  1);
			else h.put(c,  h.get(c) + 1);
		}
		for(char c : h.keySet()){
			if(h.get(c) % 2 == 1){
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 9428
#include <cstdio>
#include <algorithm>

const int MAXN = 1e5 + 5;

int n, k, sum, cnt;
int arr[MAXN], ans[MAXN], more[MAXN];

bool judge(int key) {
    int diff = 0, need;
    for (int i = 1; i <= n; ++i) {
        more[i] = arr[i] % key;
        diff += more[i];
    }
    need = diff;
    diff /= key;
    diff = n - diff + 1;
    std::sort(more + 1, more + n + 1);
    for (int i = n; i >= diff; --i) {
        need -= more[i];
    }
    return k >= need;
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
        sum += arr[i];
    }
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            int tmp = sum / i;
            ans[++cnt] = tmp;
            if (tmp != i)
                ans[++cnt] = i;
        }
    }
    std::sort(ans + 1, ans + cnt + 1);
    for (int i = cnt; i; --i) {
        if (judge(ans[i])) {
            printf("%d", ans[i]);
            break;
        }
    }
    return 0;
}

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

int main(void) {
  int N, M, ma = -100000;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < N; i++) {
    int p = 0, m = 0;
    for (int j = i; j < N; j++) {
      if (s[i] == s[j]) p++;
    }
    for (int j = 0; j < M; j++) {
      if (s[i] == t[j]) m++;
    }
    ma = max(ma, p - m);
  }
  cout << max(0, ma) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

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

    ll n; cin>>n;
    vector<int> h(n);
    loop(n) cin>>h[i];
    vector<ll> dp(n+1, 1e12);
    dp[0] = 0;
    loop(n){
        for(ll j = 1; j<=2 && i+j<n; j++){
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

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

long long Calc(long long A, long long B, long long M) {
	if (B == 0) return 1 % M;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2, M);
		return (C * C) % M;
	}
	return (A * Calc(A, B - 1, M)) % M;
}

int main() {
	long long N;
	cin >> N;
	vector<long long> A(N), B(N), XA(N), XB(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N - 1; i++) XA[i] = A[i] ^ A[i + 1];
	XA[N - 1] = A[0] ^ A[N - 1];
	for (int i = 0; i < N - 1; i++) XB[i] = B[i] ^ B[i + 1];
	XB[N - 1] = B[0] ^ B[N - 1];
	vector<long long> Divs;
	for (long long i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			Divs.push_back(i);
			if (i != N / i && i != 1) Divs.push_back(N / i);
		}
	}
	vector<long long> Loops;
	for (long long D : Divs) {
		bool check = true;
		for (int i = 0; i < N; i++) {
			if (XA[i] != XA[(i + D) % N]) check = false;
		}
		if (check) Loops.push_back(D);
	}
	vector<long long> Loops2;
	for (long long D : Divs) {
		bool check = true;
		for (int i = 0; i < N; i++) {
			if (XB[i] != XB[(i + D) % N]) check = false;
		}
		if (check) Loops2.push_back(D);
	}
	vector<bool> ANS1(N, false);
	for (long long L : Loops) {
		for (long long i = 0; i * L < N; i++) {
			ANS1[L * i] = true;
		}
	}
	vector<bool> ANS2(N, false);
	for (long long L : Loops2) {
		for (long long i = 0; i * L < N; i++) {
			ANS2[L * i] = true;
		}
	}
	vector<long long> ANS;
	for (int i = 0; i < N; i++) {
		if (ANS1[i] && ANS2[i]) ANS.push_back(i);
	}
	if (ANS.size() == 0) ANS.push_back(0);
	long long Hash = 0, HashB = 0, MOD = 998244353, X = 5, Z = Calc(X, N - 1, MOD);
	for (int i = 0; i < N; i++) Hash = (Hash * X) % MOD, Hash = (Hash + XA[i]) % MOD;
	for (int i = 0; i < N; i++) HashB = (HashB * X) % MOD, HashB = (HashB + XB[i]) % MOD;
	bool Acheck = false;
	long long ANSX = 0;
	for (int i = 0; i < N; i++) {
		if (Hash == HashB) {
			bool check = true;
			long long XOR = A[i] ^ B[0];
			for (int j = 0; j < N; j++) {
				if ((A[(i + j) % N] ^ XOR) != B[j]) check = false;
			}
			if (check) {
				Acheck = true;
				ANSX = i;
				break;
			}
		}
		Hash = (Hash + MOD - (XA[i] * Z) % MOD) % MOD;
		Hash = (Hash * X) % MOD;
		Hash = (Hash + XA[i]) % MOD;
	}
	if (!Acheck) cout << endl;
	else {
		for (long long i : ANS) {
			cout << ANSX + i << " " << (A[ANSX + i] ^ B[0]) << endl;
		}
	}
}

Measured memory_bytes: 11508
import java.util.Scanner;
import java.util.PriorityQueue;

public class Main
{
  public static void main(String[] args)
  {
    Scanner scan=new Scanner(System.in);
    PriorityQueue q=new PriorityQueue();
    int n=scan.nextInt();
    int m=scan.nextInt();
    //int[] a=new int[n];
    for(int i=0;i<n;i++)
    {
      q.add(-1*scan.nextInt());
    }
    for(int i=0;i<m;i++)
    {
      int tmp=(int)q.poll();
      tmp/=2;
      q.add(tmp);
    }
    long ans=0;
    while(!q.isEmpty())
    {
		ans-=(int)q.poll();
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 52592
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
ll N, A, B, C, D;
map<ll,ll> mp;

ll rec(ll d){
    if(d == 0) return 0;
    if(d == 1) return D;
    if(mp.count(d)){
        return mp[d];
    }
    
    //cout << d << endl;
    ll res = 1e18;
    if(d < res / D) res = d*D;
    bool f2=false,f3=false,f5=false;
    for(int i=0; i<5; i++){
        if((d+i)%2 == 0 && !f2){

            res = min(res, rec((d+i)/2) + A + i*D);
            f2 = true;
        }
        if((d+i)%3 == 0 && !f3){
            res = min(res, rec((d+i)/3) + B + i*D);
            f3 = true;
        }
        if((d+i)%5 == 0 && !f5){
            res = min(res, rec((d+i)/5) + C + i*D);
            f5 = true;
        }
    }
    f2=false,f3=false,f5=false;
    for(int i=0; i<5; i++){
        if(d-i<0) break;
        if((d-i)%2 == 0 && !f2){

            res = min(res, rec((d-i)/2) + A + i*D);
            f2 = true;
        }
        if((d-i)%3 == 0 && !f3){
            res = min(res, rec((d-i)/3) + B + i*D);
            f3 = true;
        }
        if((d-i)%5 == 0 && !f5){
            res = min(res, rec((d-i)/5) + C + i*D);
            f5 = true;
        }
    }

    return mp[d] = res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int t; cin >> t;
    while(t--){
        cin >> N >> A >> B >> C >> D;

        mp.clear();
        cout << rec(N) << endl;
    }
    return 0;
}


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

int main(){
	int x1,x2,x3,x4,x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;

	if( x1 == 0 ) cout << "1" << endl;
	if( x2 == 0 ) cout << "2" << endl;
	if( x3 == 0 ) cout << "3" << endl;
	if( x4 == 0 ) cout << "4" << endl;
	if( x5 == 0 ) cout << "5" << endl;

}


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

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

  for (int i = 0; i < s.size(); i += 2) {cout << s[i];}
  cout << '\n';
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n, m;
    cin>>n>>m;
    vector<string> v(n);
    vector<string> tmp(m);
    rep(i, n) cin>>v[i];
    rep(i, m) cin>>tmp[i];
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            bool ok=true;
            rep(x, m){
                rep(y, m){
                    if(v[i+x][j+y]!=tmp[x][y]) {
                        ok=false;
                        break;
                    }
                }
                if(!ok) break;
            }
            if(ok) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

int n;
vvec G(n);
vec cost(n);


void dfs(int pre,int now){
    for(auto &next : G[now]){
        if(pre==next) continue;
        cost[next]+=cost[now];
        dfs(now,next);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int q;
    cin>>n>>q;
    G.resize(n);
    cost.resize(n,0);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb((b));
        G[b].pb(a);
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        cost[p]+=x;
    }
    dfs(-1,0);
    rep(i,n){
        cout<<cost[i]<<endl;
    }
}

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



int main() {
    
 
    string str;
    cin >> str;
    long A = 0;
    long B = 0;
    vector<int> vec(str.size());

    for (long i = 0; i < str.size(); ++i) {
        
        vec.at(i) = (int)(str.at(i) - '0');  //str[i]　はchar型なのでchar→intへ変換
        if (vec.at(i) == 0){A++;} else {B++;}
    
        
    }
    
cout << 2 * min(A,B) << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int n;
  while(cin>>n,n) {
    int a[n];
    REP(i,n)
      cin >> a[i];
    int b = 32;
    int ct = 0;
    while(b>0) {
      b -= (b-1)%5;             // ツ暗ェツ郎
      cout << b << endl;
      b = max(0,b-a[(ct++)%n]);
      cout << b << endl;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5;
ll a[N], lb[N], rb[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

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

    rb[n] = lb[n] = a[n];

    for (int i = n - 1; i >= 0; i--) {
        lb[i] = (lb[i + 1] + 1) / 2;
        rb[i] = rb[i + 1];
        lb[i] += a[i];
        rb[i] += a[i];        
    }

    if (1 < lb[0] || 1 > rb[0]) {
        cout << "-1\n";
        return 0;
    }

    ll ans = 1;

    ll x = 1;

    for (int i = 1; i <= n; i++) {
        x = min(x * 2, rb[i]);

        if (x < lb[i]) {
            cout << "-1\n";
            return 0;
        }
        else {
            ans += x;
        }

        x -= a[i];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 5924
#入力
N = int(input())
d = list(map(int,input().split()))
#美味しさの総和をsとする
s = 0
#相異なる2つの数の全ての掛け算の和を計算
for i in range(N-1):
  for j in range(i+1,N):
    s += d[i] * d[j]
#結果
print(s)

Measured memory_bytes: 2940
#include <stdio.h>

#define MAX 20

int main()
{
  int n, m, c, b[MAX], a[MAX][MAX];
  int i, j, ans, count = 0;

  scanf("%d%d%d", &n, &m, &c);

  for (i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  for (i = 0; i < n; i++) {
    ans = 0;
    for (j = 0; j < m; j++) {
      ans += a[i][j] * b[j];
    }
    if (ans + c > 0) {
      count++;
    }
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
abcde=[int(input()) for _ in range(5)]
x=[]
for i in range(5):
  if abcde[i]%10!=0:
    x.append(abcde[i]%10)
s=sum(abcde)
if len(x)==0:
  print(s)
else:
  print(s+10*(len(x)-1)-sum(x)+min(x))

Measured memory_bytes: 3060
from sys import stdin
import queue
import sys

k=int(input())
q=queue.Queue()
for i in range(1,10):
    q.put(i)
if k<10:
    print(k)
    sys.exit()
i=0
while i!=k:
    i+=1
    now=q.get()
    nowm=now%10
    if nowm!=0 and nowm!=9:
        q.put(now*10+nowm-1)
        q.put(now * 10 + nowm)
        q.put(now * 10 + nowm +1)
    elif nowm==0:
        q.put(now * 10 + nowm)
        q.put(now * 10 + nowm + 1)
    elif nowm==9:
        q.put(now * 10 + nowm - 1)
        q.put(now * 10 + nowm)
print(now)



Measured memory_bytes: 58324
n = int(input())
n_list = [[0  for s in range(10)] for i in range(10)]
for m in range(1,n+1):
  str_m = str(m)
  n_list[int(str_m[0])][int(str_m[-1])] += 1
ans = 0
for a in range(1,10):
    for b in range(1,10):
        ans += n_list[a][b] * n_list[b][a]
print(ans)

Measured memory_bytes: 3064
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n>=3200){
		cout<<s;
	} 
	else{
		cout<<"red";
	}
    return 0;
} 

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

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    if (k > (a + b))
    {
        cout << 0 << " " << 0;
    }
    else if (k > (a))
    {
        cout << 0 << " " << a + b - k;
    }
    else
    {
        cout << a - k << " " << b;
    }
  	cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		
		if(s.equals("Sunny")){
			System.out.println("Cloudy");
		}
		else if(s.equals("Cloudy")){
			System.out.println("Rainy");
		}
		else{
			System.out.println("Sunny");
		}
	}
}

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

using namespace std;

int main(){
	char b, ans; cin >> b;
	
	if(b == 'A') ans = 'T';
	else if(b == 'T') ans = 'A';
	else if(b == 'C') ans = 'G';
	else if(b == 'G') ans = 'C';
	
	cout << ans << endl;
}

Measured memory_bytes: 256