akhauriyash/Code-Regression huggingface dataset:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


S = sys.stdin.buffer.readline().decode().rstrip()
if string.ascii_lowercase[::-1].startswith(S):
    print(-1)
    exit()

for i in reversed(range(len(S))):
    # なんか1文字つける
    for c in list(string.ascii_lowercase):
        if c not in S:
            print(S + c)
            exit()
    for j in range(ord(S[i]) + 1, ord('z') + 1):
        if chr(j) not in S[:i]:
            print(S[:i] + chr(j))
            exit()



Measured memory_bytes: 13624
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

map<string,int> mp;
string s[200020];
vector<string > ss;

int main(){
  int n;
  cin>>n;
  REP(i,n){
    cin>>s[i];
    mp[s[i]]=0;
  }
  int count=0;
  REP(i,n){
    mp[s[i]]++;
    count=max(count,mp[s[i]]);
  }

  for(auto itr =mp.begin();itr!=mp.end();++itr){
    if(itr->second==count){
      ss.push_back(itr->first);
    }
  }

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

  REP(i,ss.size()){
    cout<<ss[i]<<endl;
  }
}


Measured memory_bytes: 28404
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  while (n != 0) {
    int inputA, inputB;
    int outA(0), outB(0);
    for (int i=0; i<n; i++) {
      cin >> inputA >> inputB;
      if (inputA > inputB) outA += inputA + inputB;
      else if (inputA < inputB) outB += inputA + inputB;
      else { outA += inputA; outB += inputB;}
    }
    cout << outA << ' ' << outB << endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 2988
x,n = map(int,input().split())
p = set()
if n:
    p = set(map(int,input().split()))
mini = float('inf')
ans = float('inf')
for i in range(-400,400):
    if i not in p:
        if abs(x-i)<mini:
            mini = abs(x-i)
            ans = i
        elif abs(x-i)==mini and ans>i:
            ans=i
print(ans)

Measured memory_bytes: 9200
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=1e7+5,mod=1e9+7;
int n,m,fact[N],inv[N],ans;
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline void dec(int& x,CI y)
{
	if ((x-=y)<0) x+=mod;
}
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline void init(CI n)
{
	RI i; for (fact[0]=i=1;i<=n;++i) fact[i]=1LL*fact[i-1]*i%mod;
	for (inv[n]=quick_pow(fact[n]),i=n-1;~i;--i) inv[i]=1LL*inv[i+1]*(i+1)%mod;
}
inline int C(CI n,CI m)
{
	return 1LL*fact[n]*inv[m]%mod*inv[n-m]%mod;
}
inline int calc(CI a,CI b,CI c)
{
	return 1LL*fact[a+b+c]*a%mod*quick_pow(a+b)%mod;
}
int main()
{
	RI i,j; for (scanf("%d%d",&n,&m),init(n),i=1;i<=m+1;++i)
	for (j=0;j<i;++j) if (j&1) dec(ans,1LL*calc(i-1-j,n-m,max(m-i,0))*C(i-1,j)%mod);
	else inc(ans,1LL*calc(i-1-j,n-m,max(m-i,0))*C(i-1,j)%mod);
	return printf("%d",ans),0;
}

Measured memory_bytes: 81916
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    double p[n],num=0.0;
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]=(p[i]+1)/2;
    }
    for(int i=0;i<k;i++){
        num+=p[i];
    }
    double ans=num;
    for(int i=k;i<n;i++){
        num+=p[i];
        num-=p[i-k];
        ans=max(ans,num);
    }
    doublecout(ans);
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
List = [int(i) for i in input().split(" ")]

s1 = List[0]
s2 = sum(List[1:])
Min = abs(s2-s1)

for i in range(1,N):
    s1 += List[i]
    s2 -= List[i]
    s = abs(s2-s1)
    if s<Min:
        Min=s
        
print(Min)

Measured memory_bytes: 3064
n, k = map(int, input().split())
l = [int(input()) for _ in range(n)]
l.sort()
ans = 10**9+7
for i in range(n-k+1):
    if ans > l[i+k-1]-l[i]:
        ans = l[i+k-1]-l[i]
print(ans)


Measured memory_bytes: 7384
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N, Q;
vector<int> es[200005];
P is[200005];
int cs[200005];
int p[200005];

#if 0
void rec(int v, int prev)
{
    for(int next: es[v]){
        if(next == prev) continue;
        sts[v].pb(next);
    }
    if(prev == -1) return;
    for(int nv: sts[v]){
        sts[prev].pb(nv);
    }
    sts[prev].pb(v);
}
#else
void find_parent(int v, int par)
{
    //cout << v << "$" << par << endl;
    p[v] = par;
    for(int next: es[v]){
        if(next == par) continue;
        find_parent(next, v);
    }
}
void count_all(int v, int par)
{
    //cout << v << "#" << par << endl;
    if(par != -1) cs[v] += cs[par];
    for(int next: es[v]){
        if(next == par) continue;
        count_all(next, v);
    }
}
#endif

void solve()
{
    find_parent(0, -1);
    REP(i, Q) cs[is[i].fi] += is[i].se;
    count_all(0, -1);
    REP(i, N-1){
        cout << cs[i] << " ";
    }
    cout << cs[N-1] << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Q;
    REP(i, N-1){
        int v, w;
        cin >> v >> w;
        v--; w--;
        es[v].pb(w);
        es[w].pb(v);
    }
    REP(i, Q){
        cin >> is[i].fi >> is[i].se;
        is[i].fi--;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 25856
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, c, s, t;
vector<edge> G[100005];
bool path[100005];

bool pdfs(int v, int p)
{
	if(v == t){
		return path[v] = true;
	}
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == p) continue;
		if(pdfs(G[v][i].to, v)) return path[v] = true;
	}
	return false;
}

bool dfs(int v, int p)
{
	vector<int> vec;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == p) continue;
		if(!dfs(G[v][i].to, v)) return false;
		if(path[v] && path[G[v][i].to]){
			if((G[v][i].cost-1) / c < (llint)G[v].size()-1) return false;
		}
		else{
			if(G[v][i].cost - (llint)G[G[v][i].to].size() * c - 1 < 0) vec.push_back(-1);
			else vec.push_back((G[v][i].cost - (llint)G[G[v][i].to].size() * c - 1) / c);
		}
	}
	sort(vec.begin(), vec.end());
	
	for(int i = 0; i < vec.size(); i++){
		if(v != s){
			if(vec[i] < i+1) return false;
		}
		else{
			if(vec[i] < i) return false;
		}
	}
	return true;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> c >> s >> t;
	llint u, v, w;
	for(int i = 0; i < n-1; i++){
		cin >> u >> v >> w;
		G[u].push_back(edge(v, w));
		G[v].push_back(edge(u, w));
	}
	if(c == 0){
		cout << "Yes" << endl;
		return 0;
	}
	
	pdfs(s, -1);
	
	/*for(int i = 1; i <= n; i++){
		cout << path[i] << " ";
	}
	cout<< endl;*/
	
	if(dfs(s, -1)) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


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

hon = [2, 4, 5, 7, 9]
bon = [3]
pon = [1, 6, 0]
if int(str(n)[-1]) in hon:
  print("hon")
elif int(str(n)[-1]) in bon:
  print("bon")
else:
  print("pon")

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

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

    int sum = 0;
    for(int i=0;i<m;i++)
    {
            int a;cin>>a;
            sum +=a;
    }

    if(sum >n)
        cout<<"-1"<<endl;
    else
        cout<<(n-sum)<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    int n;
    cin >> n;
    vector<string> w(n);
    unordered_map<string, int> um;

    for (int i = 0; i < n; i++) {
        cin >> w[i];
        um[w[i]] = 0;
    }
    um[w[0]]++;
    for (int i = 1; i < n; i++) {
        um[w[i]]++;
        if (w[i][0] != w[i - 1][w[i-1].size() - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if (um[w[i]] >= 2) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];
int deg[111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N)deg[(i+A[i])%N]++;

    queue<int>que;
    rep(i,N)if(deg[i]==0)que.push(i);
    while(que.size()){
        int v=que.front();
        que.pop();
        if(--deg[(v+A[v])%N]==0)que.push((v+A[v])%N);
    }
    int ans=0;
    rep(i,N)if(deg[i])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4600
import math
import numpy as np
def yn(a, f, k, x):
  k_yt = np.maximum(np.zeros(a.shape),a - np.floor(np.divide(x, f)))
  k_yt = np.sum(k_yt)
  if k_yt <= k:
    return True
  else:
    return False

n, k = map(int, input().split())
a = list((map(int, input().split())))
f = list((map(int, input().split())))
a.sort()
f.sort(reverse = True)
xo = max([a[i]*f[i] for i in range(n)])
a = np.array(a)
f = np.array(f)
# binary search
if xo == 0:
  print(0)
else:
  l = 0
  r = xo
  m = xo
  while l <= r:
    piv = int((r+l)/2)
    if yn(a, f, k, piv):
      r = piv - 1 
      m = piv
    else:
      l = piv +1
  print(m)
   
    



Measured memory_bytes: 43504
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: u64,
        s: chars,
    }
    const MOD: u64 = 1_000_000_007;
    let mut cnt = 0;
    let mut ans = 1;
    for c in s {
        if c == 'B' {
            if cnt % 2 != 0 {
                ans = cnt * ans % MOD;
                cnt -= 1;
            } else {
                cnt += 1;
            }
        } else {
            if cnt % 2 == 0 {
                if cnt == 0 {
                    println!("0");
                    return;
                }
                ans = cnt * ans % MOD;
                cnt -= 1;
            } else {
                cnt += 1;
            }
        }
    }
    if cnt > 0 {
        println!("0");
        return;
    }
    for i in 1..(n + 1) {
        ans = ans * i % MOD;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>

using namespace std;

long long fib[45];

int main(void) {

    int n;
    cin >> n;

    fib[0] = fib[1] = 1;
    for (int i = 2; i <= n; ++i) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }

    printf("%lld\n", fib[n]);

    return 0;
}

Measured memory_bytes: 1148
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back
 
using namespace std;

int main(){

    int k,x;
    cin >> k >> x;

    for(int i = x - k + 1;i < k + x;i++){
        cout << i <<" ";
    }

    cout << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ALL(x) x.begin(), x.end()
 
typedef long long int lld;
typedef pair<int, int> pii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;
 
	int a, b;
	cin >> a >> b;

	if (b - a >= 2018) {
		cout << 0 << '\n';
		return 0;
	}

	int res = 2e9;
	set<int> st;
	
	for (; a <= b; a++)
		st.insert(a % 2019);

	for (auto &i : st) {
		for (auto &j : st) {
			if (i != j)
				res = min(res, i * j % 2019);
		}
	}

	cout << res << '\n';
	
 
	return 0;
}

Measured memory_bytes: 384
n, m, s, t = gets.split(' ').map(&:to_i)

rails = Array.new(n + 1){Array.new}
m.times do
	u, v, a, b = gets.split(' ').map(&:to_i)
	rails[u].push([v, a, b])
	rails[v].push([u, a, b])
end

yen = [-1] * (n + 1)
yen[s] = 0
yqueue = [s]
while !yqueue.empty?
	now = yqueue.shift
	rails[now].each do |rail|
		nxt = rail[0]
		fee = yen[now] + rail[1]
		if yen[nxt] < 0 || fee < yen[nxt]
			yen[nxt] = fee
			yqueue.push(nxt)
		end
	end
end

snk = [-1] * (n + 1)
snk[t] = 0
squeue = [t]
while !squeue.empty?
	now = squeue.shift
	rails[now].each do |rail|
		nxt = rail[0]
		fee = snk[now] + rail[2]
		if snk[nxt] < 0 || fee < snk[nxt]
			snk[nxt] = fee
			squeue.push(nxt)
		end
	end
end

exchange = Array.new(n){|i| [i + 1, yen[i + 1] + snk[i + 1]]}
exchange.sort_by!{|ex| ex[1]}
n.times do |i|
	while exchange[0][0] <= i
		exchange.shift
	end
	puts 10 ** 15 - exchange[0][1]
end

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

int main() {

  int N;
  cin >> N;
  string op;
  
  for (int i = 0; i < N; i++) {
    cin >> op;
    if (op == "Y") {
      cout << "Four" << endl;
      break;
    }
  }
  if (op != "Y")
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    int cnt = 0;
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    int sz;
    sz = s.size();
    cout << sz << endl;
    //for(int i=0; i<n; i++){
    //    cout << s[i];
    //}

}




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

int main () {
  int A, B;
  cin >> A >> B;
  
  if (A == 1) {
    if (B == 2) cout << 3 << endl;
    if (B == 3) cout << 2 << endl;
  }
  else if (A == 2) {
    if (B == 1) cout << 3 << endl;
    if (B == 3) cout << 1 << endl;
  }
  else {
    if (B == 2) cout << 1 << endl;
    if (B == 1) cout << 2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1e+9
using namespace std;

vector<int> G[100000];

signed main(){
	int n,s = -1,t = -1;
	vector<int> ans[2];
	cin >> n;
	if(n == 2){
		printf("1 2\n");
		return 0;
	}
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i = 0;i < n;i++){
		int cnt = 0;
		for(int v : G[i]){
			if(G[v].size() >= 2) cnt++;
		}
		if(cnt <= 1){
			if(G[i].size() >= 2) (s == -1 ? s : t) = i;
		}
		else if(cnt >= 3){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i = 0;i < 2;i++){
		ans[i].push_back(1);
		int pos = s,cnt = 1,prev = -1;
		while(1){
			int nxt = -1;
			for(int j = 0;j < (int)G[pos].size() - 2;j++) ans[i].push_back(cnt + j + 2);
			for(int v : G[pos]){
				if(v != prev && G[v].size() >= 2) nxt = v;
			}
			ans[i].push_back(cnt + 1);
			cnt += G[pos].size() - 1;
			if(pos == t || nxt == -1) break;
			prev = pos;
			pos = nxt;
		}
		ans[i].push_back(n);
		if(t != -1) swap(s,t);
	}
	for(int i = 0;i < n;i++){
		if(ans[0][i] > ans[1][i]){
			for(int j = 0;j < n;j++) cout << (j ? " " : "") << ans[1][j];
			cout << endl;
			break;
		}else if(ans[0][i] < ans[1][i] || i == n - 1){
			for(int j = 0;j < n;j++) cout << (j ? " " : "") << ans[0][j];
			cout << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m, d;

bool read() {
    if (!(cin >> n >> m >> d))
        return false;

    return true;
}

void solve() {
    if (d & 1) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j)
                cout << "RG"[(i + j) & 1];

            cout << endl;
        }
    } else {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j)
                cout << "RGYB"[2 * (((i + j) / d) % 2) + ((n * m * d + j - i) / d) % 2];

            cout << endl;
        }
    }
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 512
object Main extends App {

  val Array(l, r) = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def solve(): Long = {
    var ans = l * r
    for {
      i <- l to r
      j <- i+1 to r
    } yield {
      val mod = i * j % 2019
      if(mod == 0) return 0
      ans = Math.min(ans, mod)
    }
    ans
  }
  println(solve)

}


Measured memory_bytes: 33060
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

int main()
{
	vector<int> v;

	int n,value;

	cin >> n;

	while( --n >= 0 )
	{
		cin >> value;
		v.push_back( value );
	}

	cout << *min_element(v.begin(),v.end()) << " ";
	cout << *max_element(v.begin(),v.end()) << " ";
	cout << accumulate(v.begin(),v.end(),0LL);
	cout << endl;

return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define int	long long
#define sz(x)	((int)(x).size())
#define w(x)	int x; cin>>x; while(x--)
#define db(x)	{ cerr << #x << " = " << x << endl; }
using namespace std;

void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r",stdin);
// 	freopen("output.txt", "w", stdout);
// 	freopen("debug.txt", "w", stderr);
// #endif
}

int32_t main(){
	c_p_c();
	string s,t,id; cin>>s>>t;
	id = t.substr(0, sz(s));
	if(id == s){cout<<"Yes";}
	else {cout<<"No";}
	return 0;
}

// g++ -std=c++17 -Wshadow -Wall -o "sol" "sol.cpp" -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c;
    cin>>a>>b>>c;
   if(c-a+b>=0){
    cout<<c-a+b<<endl;
   }
   else{
    cout<<0<<endl;
   }

}


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

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

    int n, m, x;
    cin >> n >> m >> x;
    int count = 0;
    REP(i, m) {
        int tmp;
        cin >> tmp;
        if (tmp < x) count++;
    }
    cout << min(count, m - count) << '\n';
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		cs: Chars,
	}

	let mut sum = 0;
	for i in 0..cs.len() {
		sum += cs[i].to_digit(10).unwrap();
	}
	if sum % 9 == 0 {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



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

int f(int x){
  x = x*x;
  return x;
}

int main() {
  
  int d;
  while(cin >> d){
    int i,menseki=0;
    for(i=0;i<600/d;i++){
      menseki += f(i*d) * d;
    }
    cout << menseki <<endl;
  }    
  return 0;
  
}

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

using namespace std;
typedef long long int ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;

using std::chrono::system_clock;

int D;
int C[26];
std::vector<std::vector<int>> S;
const int INF = 1e9;

std::vector<int> T;

system_clock::time_point start;

void init() {
  std::cin >> D;
  REP(i, 26) std::cin >> C[i];
  S.resize(D);
  REP(i, D) {
    S[i].resize(26);
    REP(j, 26) std::cin >> S[i][j];
  }

  T.resize(D, -1);
}

std::vector<int> prev_days;

int calc_score(std::vector<int> &contests, bool verbose = false) {
  int score = 0;
  prev_days.assign(26, -1);
  REP(i, contests.size()) {
    prev_days[contests[i]] = i;
    if (verbose) {
      for (int d : prev_days) std::cerr << d << ' ';
      std::cerr << endl;
    }
    REP(j, 26) {
      score -= C[j] * (i - prev_days[j]);
    }
    score += S[i][contests[i]];
    if (verbose) {
      std::cerr << score << std::endl;
    }
  }
  return score;
}

void output() {
  for (int t : T) std::cout << t + 1 << '\n';
}

void greedy() {
  std::vector<int> contests;
  REP(d, D) {
    int max_score = -INF, max_con = -1;
    REP(i, 26) {
      contests.emplace_back(i);
      int new_score = calc_score(contests);
      if (new_score > max_score) {
        max_score = new_score;
        max_con = i;
      }
      contests.pop_back();
    }
    contests.emplace_back(max_con);
  }
  T = contests;
  std::cerr << calc_score(T) << endl;
}

bool update_greedy() {
  int score = calc_score(T);
  bool is_updated = false;
  int day = -1, cont = -1;
  REP(d, D) {
    REP(i, 26) {
      int tmp = T[d];
      T[d] = i;
      int new_score = calc_score(T);
      if (new_score > score) {
        new_score = score;
        is_updated = true;
        day = d, cont = i;
      }
      T[d] = tmp;
    }
  }
  if (is_updated) T[day] = cont;
  return is_updated;
}

void greedy2() {
  while (true) {
    double diff = std::chrono::duration_cast<std::chrono::milliseconds>(
        system_clock::now() - start).count() / 1000.;
    if (diff > 1.95) break;
    if (not update_greedy()) {
      break;
    }
  }
  std::cerr << calc_score(T) << endl;
}

int main() {
  start = system_clock::now();

  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  init();

  greedy();
  greedy2();

  output();

  return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>
#include<stdlib.h>
int compare_long(const void *a, const void *b){
    return *(long*)a - *(long*)b;
}

int main(void){
	int n, k;
	long *h;
	long x = 0;
	scanf("%d", &n);
	scanf("%d", &k);
	h = (long *)malloc(sizeof(long) * n);
	for(int i=0; i<n; i++){
		scanf("%ld", &h[i]);
	}
	qsort(h, n, sizeof(long), compare_long);
	for(int j=0; j<n-k; j++){
		x += h[j];
	}
	printf("%ld\n", x);
	return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n,x;
    cin >> n >> x;
    vector <int> l(n);
    for(int i=0;i<n;++i) cin >> l[i];
    vector <int> v(n);
    int ans=1;
    v[0]=0;
    for(int i=1;i<=n;++i) {
        v[i]=v[i-1]+l[i-1];
        if(v[i]<=x)++ans;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

vector<ll> dijkstra(int s,int V,vector<vector<tll>> g) {
	vector<ll> d(V);
	fill(all(d),LINF);
	d[s]=0;
	vb vstd(V, false);
	priority_queue<tll, vector<tll>, compare> q;
	q.push(tll(s, 0));
	while (!q.empty()) {
		ll to, dist;
		tie(to, dist) = q.top(); q.pop();
		if (vstd[to])continue;
		vstd[to] = true;
		d[to] = dist;
		rep(i, g[to].size()) {
			ll next = get<0>(g[to][i]);
			ll cost = get<1>(g[to][i]);
			if (d[next] < dist + cost)continue;
			q.push(tll(next, dist + cost));
		}
	}
	return d;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;t--;
	ll u,v,a,b;
	vector<vector<tll>> g1(n),g2(n);
	rep(i,m){
		cin>>u>>v>>a>>b;
		u--;v--;
		g1[u].push_back(tll(v,a));
		g1[v].push_back(tll(u,a));
		g2[u].push_back(tll(v,b));
		g2[v].push_back(tll(u,b));
	}
	
	vl dist1,dist2;
	dist1=dijkstra(s,n,g1);
	dist2=dijkstra(t,n,g2);
	vl ans(n+1,LINF);
	rrep(i,n){
		ans[i]=min(ans[i+1],(ll)(dist1[i]+dist2[i]));
	}
	rep(i,n){
		cout<<(1000000000000000-ans[i])<<"\n";
	}
}

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

int main(){
    int q;
    cin >> q;
    //準備
    long long sum_b = 0;
    long long left = 0;
    long long right = 0;
    int med;
    priority_queue<int> que_left;
    priority_queue<int, vector<int>, greater<int>> que_right;
    
    int mode;
    int a, b;
    cin >> mode >> a >> b;
    int x;
    
    sum_b += b;
    que_left.push(a);
    que_right.push(a);
    med = a;
    left += a;
    right += a;
    
    for (int i = 1; i < q; i++){
        cin >> mode;
        if (mode == 1){
            cin >> a >> b;
            sum_b += b;
            if (a > med){
                right += a;
                right -= med;
                que_right.pop();
                que_right.push(a);
            }
            else{
                left += a;
                left -= med;
                que_left.pop();
                que_left.push(a);
            }
            if (que_left.size() >= que_right.size()){
                x = que_left.top();
                med = x;
                que_right.push(x);
                right += x;
            }
            else{
                x = que_right.top();
                med = x;
                que_left.push(x);
                left += x;
            }
        }
        else{
            cout << med << " " << right - left + med * ((int)que_left.size() - (int)que_right.size()) + sum_b << endl;
        }
    }
}



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

int main()
{
int H,A,i,sum=1;
cin>>H>>A;
if(A>=H){
    cout<<"1"<<endl;
}
else{
    for(i=A; A<H; i++){
        H=H-A;
        sum++;
    }cout<<sum<<endl;
}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin >> n;
    double x[n],ans = 0,cnt1 = 0,cnt2 = 0;
    string u[n];
    for(int i = 0;i < n;i++){
        cin >> x[i] >> u[i];
        if(u[i] == "JPY") cnt1 += x[i];
        else cnt2 += x[i];
    }
    cnt2 *= 380000.0;
    ans += cnt1 + cnt2;
    cout << fixed << setprecision(6) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

// 0-indexd
struct UnionFind {
  vector<int> root, sizes;

  UnionFind(int max) : root(max), sizes(max, 1) {
    REP(i, max) { root[i] = i; }
  }

  int find(int x) {
    assert(root.size() > x);
    if (x == root[x])
      return x;

    return root[x] = find(root[x]);
  }

  //まとめる
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    assert(sizes[x]);
    assert(sizes[y]);

    if (x == y)
      return;

    if (sizes[x] < sizes[y])
      swap(x, y);

    root[y] = x;
    sizes[x] += sizes[y];

    sizes[y] = -1;
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sizes[find(x)]; }

  void print() {
    cerr << "index\tunion" << endl;
    REP(i, root.size()) { cerr << i << "\t" << find(i) << endl; }
  }
};

void solve(long long N, long long M, vector<long long> a, vector<long long> b) {
  if (M == N - 1) {
    cout << M << endl;
    return;
  }

  ll ans = 0;

  REP(m, M) {
    UnionFind uf(N);

    REP(i, M) if (m != i) { uf.unite(a[i] - 1, b[i] - 1); }

    int c = 0;
    REP(i, N) { c += uf.same(0, i); }

    ans += c != N;
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  cin >> M;
  vector<long long> b(M - 1 + 1);
  vector<long long> a(M - 1 + 1);
  for (int i = 0; i <= M - 1; i++) {
    cin >> a[i];
    cin >> b[i];
  }
  solve(N, M, a, b);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

bool visited[200000];

vector<int> v[200000];

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i <= N; i++){
		v[i].erase(v[i].begin(), v[i].end());
	}
	
	for(int i = 0; i < N - 1; i++){
		int num1, num2;
		cin >> num1 >> num2;
		v[num1].push_back(num2);
		v[num2].push_back(num1);
	}
	
	queue<int> q1, q2;
	
	int count1 = 1;
	int count2 = 1;
	
	q1.push(1);
	q2.push(N);
	
	for(int i = 0; i <= N; i++){
		visited[i] = false;
	}
	
	for(int loop = 0; loop < N; loop++){
		if(q1.empty() && q2.empty()){
			break;
		}
		int size = q1.size();
		for(int i = 0; i < size; i++){
			int num = q1.front();
			q1.pop();
			if(visited[num]){
				continue;
			}
			visited[num] = true;
			count1++;
			for(int j = 0; j < v[num].size(); j++){
				q1.push(v[num][j]);
			}
			//cout << num << " ";
		}
		//cout << endl;
		size = q2.size();
		for(int i = 0; i < size; i++){
			int num = q2.front();
			q2.pop();
			if(visited[num]){
				continue;
			}
			visited[num] = true;
			count2++;
			for(int j = 0; j < v[num].size(); j++){
				q2.push(v[num][j]);
			}
			//cout << num << " ";
		}
		//cout << endl;
	}
	
	//cout << count1 << " " << count2 << endl;
	
	if(count1 > count2){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  int ansa, ansb, ansc, ans;
  ansa = x+y;
  ansb=x*2-1;
  ansc=y*2-1;
  ans=max(ansa,max(ansb, ansc));
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
for i in range(n):
    if i+1 < n:
        if s[i] == s[i+1]:
            print(str(i+1)+" "+str(i+1+1))
            exit()
    if i+2 < n:
        if s[i] == s[i+2]:
            print(str(i+1)+" "+str(i+2+1))
            exit()
    if i > 0:
        if s[i] == s[i-1]:
            print(str(i)+" "+str(i+1))
            exit()
    if i > 1:
        if s[i] == s[i-2]:
            print(str(i-1)+" "+str(i+1))
            exit()
print("-1 -1")
exit()

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, X;
  cin >> N >> X;
  vector<ll> x(N);
  REP(i, N) cin >> x[i];

  x.push_back(X);
  sort(x.begin(), x.end());

  vector<ll> d(N);
  for(ll i = 0; i < N; i++) {
    d[i] = x[i + 1] - x[i];
  }

  ll gcd = d[0];
  for(ll i = 1; i < N; i++) {
    gcd = __gcd(gcd, d[i]);
  }
  cout << gcd << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
	int a,b;
	while(1)
	{
	scanf("%d%d",&a,&b);
	if(a==0&&b==0)
	break;
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=b;j++)
		printf("#");
		printf("\n");
	}
	printf("\n");
	}	 
	return 0;
}


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

int main() {
	int K, X,min,max;
	cin >> K;
	cin >> X;
	min = X - K + 1;
	max = X + K - 1;
	if (min < -1000000) {
		min = 1000000;
	}
	if (max > 1000000) {
		max = 1000000;
	}
	for (int i = min; i <= max; i++) {
		cout << i << ' ';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int64_t> p(n);
  rep(i,n){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  p.at(n-1) /= 2;
  cout << accumulate(p.begin(),p.end(),0L) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        String[] str=new String[3];
        int[] length=new int[3];
        int i=0,j=0;

        for(i=0;i<3;i++){
            str[i]=scan.next();
            length[i]=str[i].length();
        }
        int a=0,b=0,c=0;
        char work;
        work=str[0].charAt(0);
        length[0]--;
        a++;

        while(1==1){
            if(work=='a'){
                if(length[0]==0){
                    System.out.println("A");
                    return;
                }
                work=str[0].charAt(a);
                length[0]--;
                a++;
            }
            else if(work=='b'){
                if(length[1]==0){
                    System.out.println("B");
                    return;
                }
                work=str[1].charAt(b);
                length[1]--;
                b++;
            }
            else if(work=='c'){
                if(length[2]==0){
                    System.out.println("C");
                    return;
                }
                work=str[2].charAt(c);
                length[2]--;
                c++;
            }
        }
    
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll l[10];
ll a, b, c;

ll dfs(ll cur, ll ta, ll tb, ll tc) {
    if(cur==N) {
        if(min(ta, min(tb, tc))>0)
            //-30:竹の分類先を決めるたびに+10しているのでそれぞれ一回分余計に合成のMPが足されているため
            //(k本の竹を1本にするのに必要なMPは(k-1)*10)
            return abs(a-ta)+abs(b-tb)+abs(c-tc)-30;
        
        else
            return INF;
    }
    
    ll res=INF;
    chmin(res, dfs(cur+1, ta, tb, tc));
    chmin(res, dfs(cur+1, ta+l[cur], tb, tc)+10);
    chmin(res, dfs(cur+1, ta, tb+l[cur], tc)+10);
    chmin(res, dfs(cur+1, ta, tb, tc+l[cur])+10);
    return res;
}

int main(void) {
    cin >> N;
    cin >> a >> b >> c;
    for(ll i=0; i<N; i++) cin >> l[i];
    
    pt(dfs(0, 0, 0, 0));
}




Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    int n = sc.nextInt();

    BigInteger fact = BigInteger.ONE;
    for(long i = 1; i <= n; i++) {
      fact = fact.multiply(BigInteger.valueOf(i));
    }

    System.out.println(fact);
  }

  private final Scanner sc = new Scanner(System.in);
}

Measured memory_bytes: 11000
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>
#include <tuple>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b){
	if(a<b){
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b){
	if(a>b){
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) {return std::vector<T>(len, elem);}
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i] <<std:: endl;
		else std::cout << da[i] << ' ';
	}
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;


int main(){
	int n, d, a;
	cin >> n >> d >> a;
	vector<Pll> da(n);
	rip(i,n,0) cin >> da[i].first >> da[i].second;
	MinHeap<Pll> pq;
	rip(i,n,0) pq.push(da[i]);
	ll ans = 0, dm = 0;
	while(!pq.empty()){
		//cout << dm << endl;
		Pll now  = pq.top();pq.pop();
		if(now.second <= 0) dm += now.second;
		else{
			now.second -= dm;
			if(now.second <= 0) continue;
			ll add = ((now.second - 1)/a + 1);
			dm += add*a;
			pq.push(mapa(now.first + 2 * d +1, -add * a));
			ans += add;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9328
# 入力のみ
# 入力をいい感じに

def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def eular_tour(G, root):
    # G は破壊的に有向木にされる
    # グラフは 1-indexed が良い
    n = len(G)
    stack = [root]
    tour = [0] * 0
    firsts = np.full(n, -100, dtype=np.int64)
    lasts = np.full(n, -100, dtype=np.int64)
    parents = np.full(n, -100, dtype=np.int64)
    while stack:
        v = stack.pop()
        if firsts[v] >= 0:
            lasts[v] = len(tour)
            tour.append(-v)  # 帰りがけの辺の表現をマイナス以外にしたい場合ここを変える
            continue
        firsts[v] = len(tour)
        tour.append(v)
        stack.append(v)
        for u in G[v]:
            G[u].remove(v)
            parents[u] = v
            stack.append(u)
    tour = np.array(tour, dtype=np.int64)
    return tour, firsts, lasts, parents

def solve(N, C, AB):
    G = [[0]*0 for _ in range(N+1)]
    for i in range(N-1):
        a, b = AB[i]
        G[a].append(b)
        G[b].append(a)
    tour, firsts, lasts, parents = eular_tour(G, 1)
    Siz = lasts - firsts + 1 >> 1

    Cnt = np.zeros(N+1, dtype=np.int64)
    Ans = np.zeros(N+1, dtype=np.int64)
    Cnt_old = np.empty_like(Cnt)
    Siz_tmp = np.full_like(Cnt, 1)
    for v in tour:
        if v >= 0:
            p = parents[v]
            if p != -100:
                Cnt[C[p]] = N - Siz[v]  # 上を塞ぐ

            color = C[v]
            Cnt_old[v] = Cnt[color]
        else:
            v = -v
            Ans[C[v]] += N - Siz_tmp[v] + 1 - Cnt_old[v]
            Cnt[C[v]] = Cnt_old[v] + Siz_tmp[v]

            p = parents[v]
            if p != -100:
                Siz_tmp[p] += Siz[v]
                Ans[C[p]] += Siz[v] * (N - Siz_tmp[p] + 1 - Cnt_old[p])

    return Ans[1:]


numba_compile([
    [eular_tour, "Tuple((i8[:],i8[:],i8[:],i8[:]))(List(List(i8)),i8)"],
    [solve, "i8[:](i8,i8[:],i8[:,:])"],
])


import sys
def main():
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read
    N = int(input())
    C = np.empty(N+1, dtype=np.int64)
    C[1:] = input().split()
    AB = np.array(read().split(), dtype=np.int64).reshape(N-1, 2)
    Ans = solve(N, C, AB)
    print("\n".join(map(str, Ans.tolist())))

main()


Measured memory_bytes: 100864
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

using namespace std;

int main(void)
{
    long long N;
    set<string> st;
    cin >> N;
    for (long long i = 0; i < N; ++i)
    {
        string tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    cout << st.size();
}


Measured memory_bytes: 19108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[11],t[11],u[11];
    scanf("%s %s",s,t);
    int a,b;
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    int len1,len2,len3;
    len1=strlen(s);
    len2=strlen(t);
    len3=strlen(u);
    if(s[0]==u[0]&&s[len1-1]==u[len3-1])
    {
        a--;
    }
    else if(t[0]==u[0]&&t[len2-1]==u[len3-1])
    {
        b--;
    }
    printf("%d %d\n",a,b);
    return 0;
}



Measured memory_bytes: 256