akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    int X, A, B;
    cin >> X >> A >> B;
    if (B-A <= 0) cout << "delicious\n";
    else if (B-A <= X) cout << "safe\n";
    else cout << "dangerous\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  //freopen("input.txt", "rt", stdin);
  int n;
  string s;
  cin >> n;
  cin >> s;
  int len = s.size();
  for(int i = 0; i < len; i++) {
    int x = s[i] - 'A';
    x = (x+n)%26;
    char ans = (char)('A' + x);
    cout << ans;
  }
  cout << endl;
  return 0;
}

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

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

    int64_t sum = 0;
    if(a >= k) sum += k;
    else {
        if(a < k) {
            sum += a;
            k = k-a;
        }
        if(k != 0) {
            k = k-b;
            if(k != 0) sum += (-1)*k;
        }
    }

    cout << sum << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC144B()
{
	int N;
	cin >> N;
	for (int i = 1; i <= 9; ++i)
	{
		for (int j = 1; j <= 9; ++j)
		{
			if (i * j == N)
			{
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}

int main()
{
	ABC144B();
	return 0;
}


Measured memory_bytes: 256
#1:初期化
N = int(input())
a = [None]*N
for i in range(N):
    a[i] = list(map(int,input().split()))
dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
#print(a, sep="\n")

#2:初期値(元からゼロなので記述無し)

#3:dp実行部(貰うDP)
for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i-1][j]) #dpは[1]からだが，aは[0]からに注意

#4:出力
dpmax = 0
for i in range(3):
    dpmax= max(dp[N][i], dpmax)
#print(*dp, sep="\n")
print(dpmax)


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	LL N; cin >> N;
	if(N == 0) cout << 0 << endl;
	string S;
	while(N){
		if(N%2){
			S = "1" + S;
			--N;
		} else {
			S = "0" + S;
		}
		N = -N/2;
	}
	cout << S << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

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

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

const ll MAX_A = 100000;

ll cond(const ll mid, const ll N, const vector<ll> &A) {
    ll count = 0;

    for (int i = 0; i < N; i++) {
        auto it = lower_bound(A.begin(), A.end(), mid - A[i]);
        count += A.end() - it;
    }

    return count;
}

ll calc_sum(const ll threshold, const ll N, const ll M, const vector<ll> &sums, const vector<ll> &A) {
    ll acc = 0;
    ll acc_pair = 0;

    for (int i = 0; i < N; i++) {
        auto it = lower_bound(A.begin(), A.end(), threshold - A[i]);
        acc += sums[N] - sums[it - A.begin()] + (A[i] * (A.end() - it));
        acc_pair += (A.end() - it);
        // cout << (it - A.begin()) << "," << acc << endl;
    }

    // there more than one pair whose sum is threshold (like sample2)
    if (acc_pair > M) {
        acc -= threshold * (acc_pair - M);
    }

    return acc;
}

ll solve(const ll N, const ll M, const vector<ll> &A) {
    ll left = 1, right = MAX_A * 2 + 1, mid;

    while (right - left > 1) {
        mid = left + (right - left) / 2;
        if (cond(mid, N, A) < M) {
            right = mid;
        } else {
            left = mid;
        }
    }

    // the threshold of pairs (of sum) to accumulate
    ll threshold = left;
    // cout << "threshold: " << threshold << endl;

    vector<ll> sums(N + 1);
    sums[0] = 0;
    for (int i = 1; i <= N; i++) {
        sums[i] = sums[i - 1] + A[i - 1];
        // printf("sums[%d]: %lld\n", i, sums[i]);
    }
    return calc_sum(threshold, N, M, sums, A);
}

int main(void) {
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    cout << solve(N, M, A) << endl;

    return 0;
}


Measured memory_bytes: 1792
#
# abc147 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1
2 1
1
1 1
1
2 0"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2
1
2 0
1
1 0"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    C = []
    for i in range(N):
        a = int(input())
        C.append([list(map(int, input().split())) for j in range(a)])

    ans = 0
    for bit in range(1 << N):
        t = 0
        for i in range(N):
            if bit & (1 << i):
                for c in C[i]:
                    if bit & (1 << c[0]-1) != (1 << c[0]-1)*c[1]:
                        break
                else:
                    t += 1
        if t == bin(bit).count("1"):
            ans = max(ans, t)
    print(ans)


if __name__ == "__main__":
     # unittest.main()
     resolve()


Measured memory_bytes: 16348
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    int sum = 0;
    rep(i,n){
        if(v[i]>=k) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 768
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

ans = [[0 for j in range(w)] for i in range(h)]
nextColor = 0
H = 0
W = 0

while nextColor < n:
    # ai回マスを塗る
    for j in range(a[nextColor]):
        ans[H][W] = nextColor+1
        W += 1

        # 行末まで来たら次の行の先頭へ
        if W >= w:
            H += 1
            W = 0
    
    # 塗り終えたら次の色へ
    nextColor += 1

for i in range(h):
    # 奇数行は反転させる
    if i%2 != 0:
        ans[i] = ans[i][::-1]
    print(*ans[i])

Measured memory_bytes: 3920
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;

    forn(i,n) cout<<s[i]<<t[i];
}

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

int main() {
	int n,k,sum=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(sum>=k){
			sum+=k;
		}
		else{
			sum+=sum;
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
	string taroNomber;
	string hanakoNomber;
	int hitCount = 0;
	int blowCount = 0;
	while(true){
		cin >> taroNomber >> hanakoNomber;
		if(taroNomber=="0" && hanakoNomber=="0"){
			break;
		}
		hitCount = 0;
		blowCount = 0;
		int taroSize = taroNomber.size();
		int hanakoSize = hanakoNomber.size();
		for(int i=0;i<taroSize;i++){
			for(int j=0;j<hanakoSize;j++){
				if(taroNomber[i] == hanakoNomber[j]){
					if(i == j){
						hitCount++;
					}else{
						blowCount++;
					}
				}
			}
		}
		cout << hitCount << ' ' << blowCount << '\n';
	}

	return 0;
}

Measured memory_bytes: 1184
import sys
import os
from collections import defaultdict
adj = defaultdict(list)
vis =[0 for i in range(1000000)]
dis =[0 for i in range(1000000)]
# since it's a tree shortest path will be only one and unique between two node
# find distance from k to each and every node 
def dfs(u, p):
	for v, w in adj[u]:
		if v==p:
			continue
		dis[v]=dis[u]+w
		dfs(v, u)

def main():
	n = int(input())
	for i in range(n-1):
		a, b, w = map(int , input().split())
		adj[a].append((b, w))
		adj[b].append((a, w))

	q, k = map(int , input().split())
	sys.setrecursionlimit(1000000)
	dfs(k , 0)
	for i in range(q):
		x, y  =map(int , input().split())
		# print the sum of the two distance from k 
		print(dis[x]+dis[y])
#	rec_limit= sys.getrecursionlimit()
#	print(rec_limit)


if __name__ == "__main__":
	main()

Measured memory_bytes: 248240
import java.util.*;
import java.text.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    Date date, heisei;
    try{
      date = sdf.parse(str);
      heisei = sdf.parse("2019/04/30");
      System.out.println((date.compareTo(heisei) <= 0) ? "Heisei" : "TBD");
    }catch(Exception e){
      
    }
  }
}

Measured memory_bytes: 22096
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int N, M, a, b;
  cin >> N >> M;
  priority_queue<pair<int, int>> Q;
  for (int i=0; i<M; i++){
    cin >> a >> b;
    Q.emplace(pair<int, int>(-b, a));
  }
  int ans = 0;
  int p = 0;
  while (!Q.empty()){
    cerr << Q.top().first << " " << Q.top().second << endl;
    if (p > Q.top().second){
      Q.pop();
    }
    else{
      ans++;
      p = -Q.top().first;
      Q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int h[200000];

int main()
{
 	int n, k;
  	cin >> n >> k;
  	for (int i = 0; i < n; ++i)
    {
      	cin >> h[i];
    }
  	sort(h, h+n);
  	ll sol = 0;
  	for (int i = 0; i < n-k; ++i)
    {
     	sol += h[i]; 
    }
  	cout << sol;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


int vs[100000+10];
int dp[100000+10];
int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }
  int res = 0;
  dp[n-1] = 0;
  for(int i = n-2; i >= 0; --i) {
    if(vs[i] >= vs[i+1]) {
      dp[i] = dp[i+1] + 1;
    } else {
      dp[i] = 0;
    }
    res = max(res, dp[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n) for(int i=(int)k; i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
using namespace std;
using namespace boost;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  string s;
  cin>>s;
  boost::reverse(s);
  int n = s.size();
  int p10 = 1;
  int sum = 0;
  constexpr int MOD = 2019;
  vecll hist(MOD);
  hist[0] = 1;
  REP(i,n) {
    sum += (s[i] - '0') * p10 % MOD;
    sum %= MOD;
    ++hist[sum];
    p10 *= 10;
    p10 %= MOD;
  }
  ll ans = 0;
  REP(i,MOD) {
    ans += hist[i] * (hist[i]-1) / 2;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n,m;
ll a[100001],b,c;
vector<ll> d(0);
l_l cb[100001];

ll ans;

int main() {
    cin >> n >> m;
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    for (int i=0;i<m;i++) {
        cin >> b >> c;
        cb[i] = make_pair(c,b);
    }
    sort(a,a+n);
    sort(cb,cb+m,greater<l_l>());
    for (int i=0;i<m;i++) {
        for (int j=0;j<cb[i].second;j++) {
            d.push_back(cb[i].first);
            if(d.size()>=n) break;
        }
        if(d.size()>=n) break;
    }
    while(d.size()<n) {
        d.push_back(0);
    }

    for (int i=0;i<n;i++) {
        ans += max(a[i],d[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3832
/**
 * Author : Deep Raval
 * There are no two words in the English language more harmful than "good job".
 * 1729 0_0
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
    string s;
    cin >> s;
    int ans= 0;

    if(s == "RRR")
    {
        cout << '3' << endl;
        return;
    }

    if(s == "SSS")
    {
        cout << '0' << endl;
        return;
    }

    if(s == "RRS")
    {
        cout << '2' << endl;
        return;
    }

    if(s == "SRR")
    {
        cout << '2' << endl;
        return;
    }

    cout << '1' << endl;
	return ;
}
int main()
{
	FAST_IO
    int t = 1;
    //cin >> t;
    while(t--)
        test_case();
	return 0;
}

Measured memory_bytes: 3656
while True:
    a, op, b =input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '%':
        print(a % b)


Measured memory_bytes: 5596
#N = int(input())
#J,K = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for _ in range(N)]
#for i in range():

K = int(input())
S = input()

if K >= len(S):
    print(S)
else:
    ans = S[:K] + "..."
    print(ans)


Measured memory_bytes: 61664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

// O(N^2)
// 配列Aを作成
// 数値に対して、値の出現数を記録したハッシュテーブルを作成
// ハッシュテーブルの値に対して、組み合わせ数を記録したハッシュテーブルを作成

func combinationTwo(a int) int64 {
	var n int64 = int64(a)
	return n * (n - 1) / 2
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var a = make([]int, n)
	var values = make(map[int]int)
	var combinations = make(map[int]int64)
	var all int64
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		values[a[i]]++
	}
	for k, v := range values {
		combi := combinationTwo(v)
		combinations[k] = combi
		all += combi
	}
	for i := 0; i < n; i++ {
		k := a[i]
		balls := values[k] - 1
		combi := combinations[k]
		newCombi := combinationTwo(balls)
		pattern := all + newCombi - combi
		fmt.Println(pattern)
	}
}


Measured memory_bytes: 23484
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    rep(a,1,1000000) {
        ans += (N-1) / a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
import operator as op
from functools import reduce



def fact(n):
    x = n
    t = 1
    while(x>0):
        t *= x
        t %= (10**9+7)
        x -= 1
    return t



valid = True
n = sorted([int(i) for i in input().split()])
a = n[0]
b = n[1]
x = 0
y = 0

x += b-a
t = a
a -= b-a
b -= 2*(b-t)

if(a>=0 and b>=0 and a%3==0):
    x += a//3
    y += a//3
else:
    valid = False

if(valid):
    print ((fact(x+y)*pow(fact(x)*fact(y), 10**9+5, 10**9+7)) % (10**9+7))
else:
    print(0)


Measured memory_bytes: 3572
//In the name of Allah
//#ISART
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2010, mod = 1e9 + 7;
ll ch[N * N], dp[N][N], sdp[N][N];

ll po(ll a, ll b){
	if(b == 1)
		return a;
	ll p = po(a, b / 2);
	if(b % 2 == 1)
		return p * p % mod * a % mod;
	return p * p % mod;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	if(k == 1){
		cout << 1;
		return 0;
	}
	ch[k - 2] = 1;
	for(int i = k - 1; i < (n + 2) * (k + 2); i ++)
		ch[i] = ch[i - 1] * 1ll * i % mod * po(i - k + 2, mod - 2) % mod;
	ll fact = 1;
	for(int i = 1; i <= n; i ++)
		fact = fact * 1ll * i % mod;
	dp[0][0] = 1;
	sdp[0][0] = 1;
	for(int i = 1; i < n; i ++){
		for(int j = 0; j <= i; j ++){
			dp[i][j] = ch[i * (k - 1) + j + k - 2] * sdp[i - 1][min(j, i - 1)] % mod;
			sdp[i][j] = dp[i][j];
			if(j > 0)
				sdp[i][j] = (sdp[i][j] + sdp[i][j - 1]) % mod;
		}
	}
	cout << sdp[n - 1][n - 1] * fact % mod;
	return 0;
}

Measured memory_bytes: 76800
#include <stdio.h>
#include <stdlib.h>

int lc(int a, int b) {
    int tmp;
    if(a > b) { tmp = a; a = b; b = tmp; }

    while(1){
        if(b == 0) { break; }
        a = a % b;
        tmp = a; a = b; b = tmp;
    }
    return a;
}

int lcursion(int *a, int i, int j) {
    if(i == j) { return a[i]; }
    else if(j - i == 1) { return lc(a[i], a[j]); }
    else { 
        int h = (i + j)/2;
        return lc(lcursion(a, i, h), lcursion(a, h+1, j) );
    }
}

int lcm(int *a, int n) {
    return lcursion(a, 0, n-1);
}

int main(void)
{
    int n, i; scanf("%d", &n);
    int *a = (int*)malloc((n+2) * sizeof(int));
    for(i = 0; i < n; ++i) { scanf("%d", &a[i]); }
    printf("%d\n", lcm(a, n));
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <string.h>
#include <algorithm>

using namespace std;


int main(){
  int k,s;
  cin >> k >> s;
  int count=0;
  for(int x=0; x<k+1; x++){
    for(int y=0; y<k+1; y++){
        if(s - x-y >=0 && s-x-y <=k){
         //cout << count << " "<< x << " "<< y << " "<< z << endl;
          count++;
      }  
    }
  }
  cout << count << endl;
  return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  uint64_t g = gcd(m,n);
  if(m%g==0) return (m/g)*n;
  if(n%g==0) return (n/g)*m;
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n,m;
  cin >> n >> m;
  
  int graph[8][8] = {};
  
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b; a--;b--;
    graph[a][b] = 1;
    graph[b][a] = 1;
  }

  vector<int> path;
  for(int i=1;i<n;i++){
    path.push_back(i);
  }
  
  int count = 0;
  do{
    if(graph[0][path[0]]==0){
      continue;
    }
    bool found = true;
    for(int i=1;i<n-1;i++){
      if(graph[path[i]][path[i-1]]==0){
        found = false;
        break;
      }
    }
    if(found){
      count++;
    }
  }while(next_permutation(path.begin(),path.end()));
  
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3672
#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 x,n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int c=1;
    int ans=0;
    while(true) {
        if(n==0) {
            ans = x;
            break;
        }
        if (count(p.begin(), p.end(), x) == 0){
            ans = x;
            break;
        }
        if (count(p.begin(), p.end(), x-c) == 0) {
            ans = x-c;
            break;
        } else if(count(p.begin(), p.end(), x+c) == 0) {
            ans = x+c;
            break;
        }
        ++c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
// This code wrote by chtholly_micromaker(MicroMaker)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define reg register
using namespace std;
const int MaxN=2050;
const int dir[4][2]={1,0,0,1,-1,0,0,-1};
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
char G[MaxN][MaxN];
int f[MaxN][MaxN],g[MaxN][MaxN],h[MaxN][MaxN];
int n,m;
signed main(void)
{
	// freopen("big.in","r",stdin);
	int q;
	cin>>n>>m>>q;
	for(int i=1;i<=n;++i)
		scanf("%s",G[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(G[i][j]=='1'?1:0);
			g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1];
			h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1];
			if(G[i][j]=='1')
			{
				if(G[i-1][j]=='1')
					++g[i][j];
				if(G[i][j-1]=='1')
					++h[i][j];
			}
		}
	reg int U,V,X,Y;
	for(int qq=0;qq<q;++qq)
	{
		read(U);read(V);read(X);read(Y);
		reg int ans=f[X][Y]-f[U-1][Y]-f[X][V-1]+f[U-1][V-1];
		// printf("t1 %d\n",f[X][Y]-f[U-1][Y]-f[X][V-1]+f[U-1][V-1]);
		ans-=g[X][Y]-g[U][Y]-g[X][V-1]+g[U][V-1];
		// printf("t2 %d\n",g[X][Y]-g[U][Y]-g[X][V-1]+g[U][V-1]);
		ans-=h[X][Y]-h[U-1][Y]-h[X][V]+h[U-1][V];
		// printf("t3 %d\n",h[X][Y]-h[U-1][Y]-h[X][V]+h[U-1][V]);
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 55040
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  cin>>n>>k;
  set<ll>a;
  ll d,ele;
  while(k--){
    cin>>d;
    while(d--){
      cin>>ele;
      a.insert(ele);
    }
  }
  cout<<n-a.size()<<"\n";
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    bool found=false;
    char s[105], t[105], character;
    int len;

    cin >> s;
    cin >> t;

    len = strlen(s);
    if(len != strlen(t))
        printf("No\n");

    else
    {
        for(int rotation=1; rotation<=len; rotation++)
        {
            character = s[len-1];
            for(int i=len-1; i>=1; i--)
                s[i] = s[i-1];
            s[0] = character;

            if(strcmp(s, t) == 0)
            {
                found = true;
                break;
            }
        }

        if(found == true)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N, D, X;
	cin >> N >> D >> X;
	vll A(N);
	rep(i, N) cin >> A[i];

	ll eat = 0;
	rep(i, N) {
		ll tmp = 0;
		rep(j, 100) {
			if (D < j * A[i] + 1) break;
			else tmp = j + 1;
		}
		eat += tmp;
	}
	cout << eat + X << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
##任意の置換が可能
if len(s)!=len(t):
    print("No")
    exit()

l = len(s)

chng = {}

for i in range(l):
    if s[i] in chng:
        if chng[s[i]]!=t[i]:
            print("No")
            exit()
    else:#この置換のみ考えればよい
        chng[s[i]] = t[i]
        #これだとt[i]重複の可能性あり
chng = {}
#両方要るらしい
for i in range(l):
    if t[i] in chng:
        if chng[t[i]]!=s[i]:
            print("No")
            exit()
    else:#この置換のみ考えればよい
        chng[t[i]] = s[i]
        
    
print("Yes")





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

class Mode_Value{
	int mode[100];
	int max;
public:
	Mode_Value();
	void setMode(int);
	void getMaxValue();
};

Mode_Value::Mode_Value(){
	max = 0;
	for(int i = 0; i < 100; i ++)
		mode[i] = 0;
}

void Mode_Value::setMode(int n){
	if(++mode[n - 1] > max)
		max = mode[n - 1];
}

void Mode_Value::getMaxValue(){
	for(int i = 0; i < 100; i ++){
		if(mode[i] == max)
			cout << i + 1 << endl;
	}
}

int main(){
	int a;
	Mode_Value m;
	while(scanf("%d",&a) != EOF)
		m.setMode(a);
	m.getMaxValue();
	return 0;
}

Measured memory_bytes: 1208
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
m500 = n//500
n -= 500 * m500
m5 = n//5
print(1000 * m500 + m5 * 5)


Measured memory_bytes: 10448
def main():
    numbers = list(map(int, input().split(" ")))
    numbers.sort()
    diff = 3 * numbers[2] - sum(numbers)
    if diff % 2:
        answer = (diff + 3) // 2
    else:
        answer = diff // 2
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def INT_(n): return int(n)-1
def MI(): return map(int, input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_, input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n: int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split())) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')


def main():
    N = I()
    A = LI()
    B = LI()

    total = 0

    res = 0
    for i in range(N):
        monster = max(0, A[i] - res)
        if res + B[i] <= A[i]:
            total += B[i] + res
            res = 0
        else:
            total += A[i]
            res = B[i] - monster
    total += min(res, A[N])
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19500
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
        ll n;
    cin >> n;
    ll now = 26;
    ll cnt = 1;
    string ans;
    while(true){
        if(n - now <= 0){
            n--;
            while(cnt--){
                ans.push_back('a' + (n % 26));
                n /= 26;
            }
            reverse(all(ans));
            cout << ans << endl;
            return 0;
        }
        n -= now;
        now *= 26;
        cnt++;

    }
    reverse(all(ans));
    cout << ans << endl;
}


Measured memory_bytes: 3632
N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = min([abs(x[0]) + abs(x[0] - x[K-1]), abs(x[K-1]) + abs(x[0] - x[K-1])])

for i in range(N-K+1):
  tmp = min([abs(x[i]) + abs(x[i] - x[i+K-1]), abs(x[i+K-1]) + abs(x[i] - x[i+K-1])])
  ans = min([ans, tmp])
print(ans)

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

int main() {
    int r;
    cin >> r;
    cout << "A";
    if(r < 1200) {
        cout << "B";
    } else if(r < 2800) {
        cout << "R";
    } else {
        cout << "G";
    }
    cout << "C" << endl;
}


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

int main(){
	string s1,s2;
	while(cin >> s1){
		cin >> s2;
		int ma = 0;
		for(int i = 0;i < s1.size();i++){
			int cnt = 0;
			for(int j = 0; j < min(s1.size() - i,s2.size());j++){
				if(s1[j + i] == s2[j]) ma = max(ma,++cnt);
				else cnt = 0;
			}
		}
		for(int i = 0;i < s2.size();i++){
			int cnt = 0;
			for(int j = 0; j < min(s2.size() - i,s1.size());j++){
				if(s2[j + i] == s1[j]) ma = max(ma,++cnt);
				else cnt = 0;
			}
		}
		cout << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec h(N); cin >> h;
    int ans = 0;
    REP(i, N) if(h[i] >= K) ans++;
    Out(ans);

    return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N;
  	string S;
  	cin >> N >> S;
  	int count = 0;
  	rep(i,N-2){
    	if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') count++;    
    }
  	cout << count << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

using namespace std;

int main (){
  //float a, b, d, r, f;
  double f, a_f, b_f;
  int a, b, d, r;
  cin >> a >> b;

  //a_f = a;
  //b_f = b;

  //d = a / b;
  //r = a % b;
  //f = a_f / b_f;

  cout << a / b << " " << a % b << " ";
  cout << fixed << setprecision(5) << (double) a / b << endl;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,e) for(ll i = 0;i<e;i++)
#define foa(i,s,e) for(ll i=s;i<e;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll n,k;
    cin>>n>>k;
    vll cnt(n+1);
    fo(i,k){
        ll d;
        cin>>d;
        fo(i,d){
            ll a;
            cin>>a;
            cnt[a]++;
        }
    }
    ll ans = 0;
    foa(i,1,n+1){
        if(!cnt[i])ans++;
    }
    cout<<ans<<endl;
    
    
    

    

}

Measured memory_bytes: 3600
#include <cstdio>
#include <string>
 
class List
{
    int* data_; //[4000000];
    int begin_;
    int end_;
public:
    List()
    {
        data_ = new int[4000000];
        begin_ = 2000000;
        end_  = 2000000;
    }
    // ~List()
    // {
    //     delete[] data_;
    // }
    void Insert(int X)
    {
        --begin_;
        data_[begin_] = X;
    }
    void Delete(int X)
    {
        int Index = end_;
        for(int i = begin_; i < end_; ++i){
            if(X == data_[i]){
                Index = i;
                break;
            }
        }
        if(Index == end_) return;
        for(int i = Index; i < end_; ++i){
            data_[i] = data_[i+1];
        }
        end_--;
    }
    void DeleteFirst()
    {
        begin_++;
    }
    void DeleteLast()
    {
        end_--;
    }
    void Show()const
    {
        printf("%d", data_[begin_]);
        for(int i = begin_ + 1; i < end_; ++i){
            printf(" %d", data_[i]);
        }
        printf("\n");
    }
};
 
int main()
{
    List list;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            list.DeleteFirst();
        }else
        if(com[6] == 'L'){
            list.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                list.Insert(v);
            }else
            if(com[0] == 'd'){
                list.Delete(v);
            }
        }
    }
    list.Show();
    return 0;
}
 

 

Measured memory_bytes: 6632
#include<bits/stdc++.h>
using namespace std;
 
#define abs(a) ((a)>0?(a):-(a))
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.14159265358979323846
#define endl "\n"
#define int long long int
int gcd(int a,int b){for(int c;b;c=a,a=b,b=c%b);return a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
// int MOD = 1000000000;
 
signed main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int T;
    T = 1;
    // int k=0;
    while(T>0){
        int R;
        cin >> R;
        cout << 2*PI*R << endl;
    T--;
    }
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i==4)cout<<' ';
    cout<<s[i];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
// Last Change: 12/19/2019 18:34:55.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;

  ll table[7] = {0};
  for (int i = 0; i < 7; ++i) {
    table[i] = A;
  }
  table[6] += B;

  ll day, score;
  day = score = 0;
  while (score < C) {
    score += table[day % 7];
    ++day;
  }

  cout << day << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Froeach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))

int main(){
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) { out("error"); return 0; }
	out(A + B);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    queue<int> qs[10];
    int n, q;
    cin >> n >> q;
    vector<int> v;
    while (q--) {
        int t, a;
        cin >> t >> a;
        if (t == 0) {
            --a;
            v.push_back(qs[a].front());
            qs[a].pop();
        } else {
            int mi = INF, id = -1;
            for (int i = 0; i < n; i++) {
                if (qs[i].size() < mi) {
                    mi = qs[i].size();
                    id = i;
                }
            }
            qs[id].push(a);
        }
    }
    for (auto e : v) {
        cout << e << endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int numa[252521], numb[252521];
int rana[252521][2], ranb[252521][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a[252521], b[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
    ++numa[a[i]];
  }
  REP(i, n){
    cin>>b[i];
    ++numb[b[i]];
  }
  FOR(i, 1, n+1){
    if(numa[i]>n-numb[i]){
      cout<<"No"<<'\n';
      return 0;
    }
  }
  FOR(i, 1, n+1){
    rana[i][0]=rana[i][1]=-1;
    ranb[i][0]=ranb[i][1]=-1;
  }
  REP(i, n){
    if(rana[a[i]][0]==-1){
      rana[a[i]][0]=i;
    }
    rana[a[i]][1]=i;
  }
  REP(i, n){
    if(ranb[b[i]][0]==-1){
      ranb[b[i]][0]=i;
    }
    ranb[b[i]][1]=i;
  }
  int ma=0;
  REP(i, n){
    if(!numb[a[i]]){
      continue;
    }
    if(ranb[a[i]][0]<=rana[a[i]][1]){
      CHMAX(ma, rana[a[i]][1]-ranb[a[i]][0]+1);
      // DEBUG(rana[a[i]][1]-ranb[a[i]][0]);
    }
  }
  rotate(b, b+n-ma, b+n);
  cout<<"Yes"<<'\n';
  REP(i, n){
    cout<<b[i]<<" \n"[i==n-1];
  }
  return 0;
}


Measured memory_bytes: 9876
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
int main() {
	string str; cin >> str;
	int left =0;
	int right = 0;;
	for (int i = 0;i < str.size(); i++){
		if ( str[i] == 'Z'){
			right = i;
		}
	}
	for (int i = str.size() - 1;i != -1; i--){
		if ( str[i] == 'A'){
			left = i;
		}
	}

	cout << right - left + 1 << endl;
	return 0;
}





Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll =long long ;
ll gcd(ll p,ll q){
  if(p%q==0)return q;
  return gcd(q,p%q);
}
int main() {
  ll a,b;
  cin>>a>>b;
  cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 3492
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int K = input.nextInt();
		long ans = 0;
		long R = input.nextLong();
		long S = input.nextLong();
		long P = input.nextLong();
		String T = input.next();
		boolean[] v = new boolean[N];
		for (int i = 0; i < N; i++) {
			if (i-K>=0&&T.charAt(i-K)==T.charAt(i)&&v[i-K]) continue;
			else {
				v[i]=true;
				char cur = WIN(T.charAt(i));
				if (cur=='p') ans+=P;
				else if (cur=='r') ans+=R;
				else if (cur=='s') ans+=S;
			}
		}
		System.out.println(ans);
	}
	public static char WIN(char x) {
		if (x=='r') return 'p';
		if (x=='p') return 's';
		return 'r';
	}
}

Measured memory_bytes: 30344
def parse str
  answer = ''
  ary = str.split(/ /)
  ary.each do |word|
    answer << word.length.to_s
  end
  answer.to_i
end

answers = []

loop do
  str = gets.chomp
  break if str.eql?('END OF INPUT')
  answers << parse(str)
end

answers.each{|answer|puts answer}

Measured memory_bytes: 6104