akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    string s;
    //string ans;
    getline(cin,s);

    int i=0;
    while (s[i] != '\0' ){
        if (s[i] >='a' && s[i] <= 'z'){
            cout << char(toupper(s[i]));
        } else if (s[i] >='A' && s[i] <= 'Z'){
            cout << char(tolower(s[i]));
        } else {
            cout << s[i];
        }
        i++;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3156
local n, x = io.read("*n", "*n", "*l")
local str = io.read()
local a = {}
for v in str:gmatch("%d+") do
  table.insert(a, tonumber(v))
end
local cnt = 0
for i = 1, n - 1 do
  local rem = a[i] + a[i + 1] - x
  if 0 < rem then
    cnt = cnt + rem
    if rem <= a[i + 1] then
      a[i + 1] = a[i + 1] - rem
    else
      a[i + 1] = 0
      a[i] = a[i] - (rem - a[i + 1])
    end
  end
end
print(cnt)


Measured memory_bytes: 7204
s = str(input())

if s == 'SUN':
    ans = 7
elif s == 'MON':
    ans = 6
elif s == 'TUE':
    ans = 5
elif s == 'WED':
    ans = 4
elif s == 'THU':
    ans = 3
elif s == 'FRI':
    ans = 2
elif s == 'SAT':
    ans = 1

print(ans)


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

using namespace std;

int main(){
	int n, k, ans = 0;
	cin >> n >> k;
	vector<int> a(n);
	int p;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 1) p = i;
	}
	ans = (n - 1 + (k - 2)) / (k - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する


int main() {
    ll x, y;
    cin >> x >> y;

    ll tmp = x;
    ll ans = 1;
    while(true){
        tmp = tmp * 2;
        if(tmp > y){
            break;
        }else{
            ans++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;

	vector<pii>* man;
	man = new vector<pii>[n];

	rep(i, n) {
		int a;
		cin >> a;
		rep(j, a) {
			int x, y;
			cin >> x >> y;

			man[i].push_back(pii(x-1, y));
		}
	}

	int p = 1 << n;

	int ans = 0;

	rep(i, p) {
		int t = 0;
		bool flag = true;
		rep(j, n) {
			if (i&(1 << j)) {
				rep(l, man[j].size()) {
					if ((i&(1<< man[j][l].first)) ^ (man[j][l].second << man[j][l].first)) {
						flag = false;
						break;
					}
				}

				++t;

				if (!flag) break;
			}
		}

		if (flag) ans = max(ans, t);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
# 解けなかったので解説を見た
# 竹の総数が8と少なく、それぞれの竹の利用パターンもA/B/Cの材料とするor使わないの4種類なので全列挙する
# 可能なパターンを全列挙するのであればdfsを用いて、消費MPの最小値を考えれば良い

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]


def dfs(i, a_len, b_len, c_len):
    # 探索の葉に達したときは残りの延長・短縮の工数を調べて返す
    if i == N:
        if a_len == 0 or b_len == 0 or c_len == 0:  # 0を延長して竹を作ることはできない
            return float('inf')
        else:
            return abs(a_len - A) + abs(b_len - B) + abs(c_len - C) - 30

    br1 = dfs(i + 1, a_len + L[i], b_len, c_len) + 10  # L[i]をaに連結する場合
    br2 = dfs(i + 1, a_len, b_len + L[i], c_len) + 10  # L[i]をbに連結する場合
    br3 = dfs(i + 1, a_len, b_len, c_len + L[i]) + 10  # L[i]をcに連結する場合
    br4 = dfs(i + 1, a_len, b_len, c_len)  # L[i]を使わない場合

    return min(br1, br2, br3, br4)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#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++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, sum, M, cnt[26];
char S;

int main()
{
  M = 1e9 + 7;
  cin >> N;

  REP(i, N)
  {
    cin >> S;
    cnt[S - 'a']++;
  }

  sum = 1;
  REP(i, 26)
  {
    sum *= (cnt[i] + 1);
    sum %= M;
  }

  cout << sum - 1 << '\n';

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<char,long long int> mp;
    string s;
    for(int i=0;i<n;i++){
        cin >> s;
        mp[s[0]]++;
    }
    long long int ans=0;
    vector<char> v = {'M','A','R','C','H'};
    for(auto u:v){
        for(auto x:v){
            for(auto y:v){
                if(u!=x && u!=y && x!=y)ans += mp[u]*mp[x]*mp[y];
            }
        }
    }
    ans /= 6;
    cout << ans;
}

Measured memory_bytes: 3596
N = input()
A = map(int, raw_input().split())
A = [0] + A + [0]
cost = sum([abs(A[i] - A[i + 1]) for i in range(N + 1)])
for i in range(N):
    a, b, c = A[i:i + 3]
    if max(a, b, c) == b or min(a, b, c) == b:
        diff = - abs(a - b) - abs(b - c) + abs(a - c)
    else:
        diff = 0
    print cost + diff


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

using namespace std;

void solve(){

	string strs[] = { "SAFE", "SUSPICIOUS" };

	int h, w;
	cin >> h >> w;

	vector< string > screen( h );
	vector< int > maxx( 26, 0 );
	vector< int > maxy( 26, 0 );
	vector< int > minx( 26, w );
	vector< int > miny( 26, h );

	for( int i = 0; i < h; i++ )
		cin >> screen[ i ];
	
	bool fig = true;

	for( int x = 0; x < w; x++ ) {
		for( int y = 0; y < h; y++ ) {
			if( screen[y][x] != '.' ) {
				int i = screen[y][x] - 'A';
				maxx[i] = max( maxx[i], x );
				minx[i] = min( minx[i], x );
				maxy[i] = max( maxy[i], y );
				miny[i] = min( miny[i], y );
			}
		}
	}


	while( fig ) {

		fig = false;

		for( int x = 0; x < w; x++ ) {
			for( int y = 0; y < h; y++ ) {

					char ch = screen[ y ][ x ];
					if( ch == '.' || ch == '*' ) continue;
					int i = ch - 'A';

					bool fflg = true;
					for( int tx = minx[i]; tx <= maxx[i] && fflg; tx ++ )
						for( int ty = miny[i]; ty <= maxy[i] && fflg; ty ++ )
							fflg &= ( screen[ ty ][ tx ] == ch || screen[ ty ][ tx ] == '*' );
					
					fig |= fflg;
					if( !fflg ) continue;

					for( int tx = minx[i]; tx <= maxx[i]; tx ++ )
						for( int ty = miny[i]; ty <= maxy[i]; ty ++ ) 
							screen[ ty ][ tx ] = '*';

				}
			}
		}
	

	bool b = false;
	for( int x = 0; x < w; x++ )
		for( int y = 0; y < h; y++ )
			b |= ( screen[ y ][ x ] != '.' && screen[ y ][ x ] != '*' );
	cout << strs[ b ] << endl;
}

int main( void ) {
	int n;
	cin >> n;
	for( int i = 0; i < n; i++ )
		solve();
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc095_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  vector<int> d(c.begin(), c.end());
  sort(d.begin(), d.end());

  int mean = d[N / 2];
  rep(i, N) {
    int l;
    if (c[i] < mean)
      l = mean;
    else
      l = d[(N - 1) / 2];
    cout << l << endl;
  }

}

Measured memory_bytes: 3840
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def sum(i,bit):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    def index_permutations(p):
        res = 0
        bit = [0]*(n+1)
        for i in range(len(p)):
            res += (p[i]-sum(p[i],bit))*f[n-i-1]
            j = p[i]
            while j <= n:
                bit[j] += 1
                j += j&-j
        return res
    n = I()
    p = LI()
    q = LI()
    f = [1]
    for i in range(1,n+1):
        f.append(f[-1]*i)
    print(abs(index_permutations(p)-index_permutations(q)))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38640
X, Y, A, B, C  = list(map(int, input().split()))

P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

P = P[:X]
Q = Q[:Y]

ip = len(P) - 1
iq = len(Q) - 1
ir = 0

while iq >= 0 and ip >= 0 and ir < len(R):
    rv = R[ir]
    pv = P[ip]
    qv = Q[iq]
    if rv <= pv and rv <= qv:
        break
    if pv >= qv:
        Q[iq] = rv
        iq -= 1
    else:
        P[ip] = rv
        ip -= 1
    ir += 1

while iq >= 0 and ir < len(R) and Q[iq] < R[ir]:
    Q[iq] = R[ir]
    iq -= 1
    ir += 1

while ip >= 0 and ir < len(R) and P[ip] < R[ir]:
    P[ip] = R[ir]
    ip -= 1
    ir += 1


print(sum(P) + sum(Q))



Measured memory_bytes: 105444
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

  string s;
  cin >> s;

  int64_t l = 0;
  int64_t m = 0;
  for (auto c : s) {
    if (c == '(') {
      ++m;
    } else {
      if (m > 0) {
        --m;
      } else {
        ++l;
      }
    }
  }

  for (auto i : irange(0L, l)) {
    cout << "(";
  }
  cout << s;
  for (auto i : irange(0L, m)) {
    cout << ")";
  }

  cout << endl;
}

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

int main()
{
  string red, green, down;
  while (cin >> red && red != "-") {
    cin >> green >> down;
    queue<char> top, left;
    for (string::const_iterator it(red.begin()); it != red.end(); ++it) {
      top.push(*it);
    }
    for (string::const_iterator it(green.begin()); it != green.end(); ++it) {
      left.push(*it);
    }

    char center = left.front();
    left.pop();
    string ans;
    for (string::const_iterator it(down.begin()); it != down.end();) {
      if (center == *it) {
        // push_down
        center = top.front();
        top.pop();
        ++it;
      } else {
        // push_right
        ans += center;
        center = left.front();
        left.pop();
      }
    }
    while (!left.empty()) {
      ans += center;
      center = left.front();
      left.pop();
    }
    ans += center;
    cout << ans << endl;
  }
  return 0;
}

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

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for_each(begin(h), end(h), [](int& e) { cin >> e; });
  sort(begin(h), end(h));
  long long res = accumulate(begin(h), begin(h) + max(n - k, 0), 0LL);
  cout << res << '\n';
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            String S = in.next();
            int passed_cnt = 0;
            int foreigners_cnt = 0;

            for (int i = 0; i < n; i++) {
                if (S.charAt(i) == 'a') {
                    if (passed_cnt < a + b) {
                        // 出力
                        out.println("Yes");
                        passed_cnt++;
                    } else {
                        out.println("No");
                    }
                } else if (S.charAt(i) == 'b') {
                    if (passed_cnt < a + b && foreigners_cnt < b) {
                        // 出力
                        out.println("Yes");
                        passed_cnt++;
                        foreigners_cnt++;
                    } else {
                        out.println("No");
                    }
                } else {
                    // 出力
                    out.println("No");
                }
            }

        }

    }
}



Measured memory_bytes: 24452
N = int(input())
S = input()

ecnt = 0
wcnt = 0
eLst = [0] * N
wLst = [0] * N
for i in range(1, N):
    if S[i - 1] == 'W':
        wcnt += 1
    eLst[i] = wcnt

    if S[-i] == 'E':
        ecnt += 1
    wLst[-i - 1] = ecnt

ans = 10 ** 6
for i in range(N):
    tmp = eLst[i] + wLst[i]
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 19472
#include <map>
#include <cstdio>
#include <algorithm>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const ll p = 1000000007;
const int maxn = 200005;
int n;
map<pi,ll>mp;
map<pi,bool>vis;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
ll qpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1ll)ans=(ans*a)%p;
		a=(a*a)%p;
		b>>=1ll;
	}
	return ans;
}
int main(){
	scanf("%d",&n);
	ll zero_cnt=0;
	FOR(i,0,n){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		if(!a&&!b){
			zero_cnt++;
			continue;
		}
		ll c=gcd(a,b);
		a/=c,b/=c;
		if(b<0)a=-a,b=-b;
		if(b==0)a=-1;else if(a==0)b=1;
		mp[pi{a,b}]++;
	}
	map<pi,ll>::iterator it;
	ll ans=1;
	for(it=mp.begin();it!=mp.end();++it){
		pi pp = it->first;
		pp = pi{-pp.second,pp.first};
		if(pp.second<0)pp=pi{-pp.first,-pp.second};
		if(vis[pp] || vis[it->first])continue;
		ll num1=mp[it->first],num2=mp[pp];
		ll add=(qpow(2,num1)+qpow(2,num2)-1ll)%p;
		ans=(ans*add)%p;
		vis[pp]=vis[it->first]=true;
	}
	ans+=zero_cnt-1ll;
	ans%=p;
	printf("%lld\n",(ans+p)%p);
}

Measured memory_bytes: 53212
#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>;

ll solve(ll ai, ll aj, ll bi, ll bj) {
  if (aj > bj) {
    swap(ai,bi);
    swap(aj,bj);
  }
  ll s = 1;
  rep(i,30) s *= 3;
  ll dist = abs(ai-bi) + abs(aj-bj);
  ll res = dist;
  while (s>1) {
    s /= 3;
    ll nai = ai/s, nbi = bi/s;
    if (nai != nbi) break;
    ll naj = aj/s, nbj = bj/s;
    if (nai%3 == 1 && abs(naj-nbj) > 1) {
      ll up = s*nai-1;
      ll bot = nai*s + s;
      ll loss = min(ai,bi) - up;
      loss = min(loss, bot - max(ai,bi));
      res += loss*2;
      break;
    }
  }
  return res;
}

int main() {
  int q;
  cin >> q;
  while(q--) {
    ll ai,aj,bi,bj;
    cin >> ai >> aj >> bi >> bj;
    ai--; aj--; bi--; bj--;
    ll ans1 = solve(ai,aj,bi,bj);
    ll ans2 = solve(aj,ai,bj,bi);
    cout << max(ans1, ans2) << endl;
  }
  return 0;
}


Measured memory_bytes: 384
S = raw_input()
N = len(S)
S_list = map(int, list(S))
S_list.reverse()
res = 0
for i in range(N):
    res += S_list[i] * ((5**(i+1) - 1) / 4 + 5**i)
if N == 1:
    res /= 2
else:
    res *= (2**(N-2))

print res
# N-1 places
# 2^(N-1)
# k
# k=1 2^(N-2) + 2^(N-2) = 2^(N-2) * (1 + 1)
# k=2 2^(N-2), 2^(N-2) = 2^(N-2) * (1+5 + 5)
# k=3 2^(N-2), 2^(N-3), 2^(N-3) =  2^(N-2) * (1 + 5 + 25 + 25)




Measured memory_bytes: 2692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

vector<pair<int, int>> st[30];
int cnts[200005];

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

  long n, c;
  cin >> n >> c;

  rep(i, n) {
    long s, t, ch;
    cin >> s >> t >> ch;
    ch--;
    st[ch].push_back({s, t});
  }

  rep(i, c) {
    sortv(st[i]);
    rep(j, st[i].size()) {
      int fst = max(0, st[i][j].first-1);
      if (j > 0 && st[i][j].first == st[i][j-1].second) fst = st[i][j].first;
      for(int k = fst; k < st[i][j].second; k++) {
        cnts[k]++;
      }
    }
  }

  sort(cnts, cnts+200005, greater<int>());

  cout << cnts[0] << endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int main(){
	int ave=0;
	for(int i=0;i<5;i++){
		int a;
		scanf("%d",&a);
		ave+=max(40,a);
	}
	printf("%d\n",ave/5);
}

Measured memory_bytes: 1188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BExactlyNPoints solver = new BExactlyNPoints();
        solver.solve(1, in, out);
        out.close();
    }

    static class BExactlyNPoints {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            long res = 0;

            for (int i = 0; i < n; i++) {
                if (res * (res + 1) / 2 >= n) {
                    break;
                }
                res++;
            }

            while (n > 0) {
                if (res > n) {
                    out.println(n);
                    n = 0;
                } else {
                    out.println(res);
                    n -= res;
                    res--;
                }
            }


        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif
int a, b, c, d;
int N = 3001;
int mod = 998244353;
vector<vector<int>> v(N, vector<int>(N, -1));

int dp(int x, int y) {
	if (v[x][y] == -1) {
		if (x <= a && y <= b) v[x][y] = 1;
		else if (x <= a) v[x][y] = dp(x, y-1) * x;
		else if (y <= b) v[x][y] = dp(x-1, y) * y;
		// return dp(x-1, y) * y + dp(x, y-1) * x;
		else v[x][y] = dp(x-1, y) * y % mod + dp(x, y-1) * x % mod - (x-1)*(y-1) % mod * dp(x-1, y-1) % mod;
		v[x][y] %= mod;
		if (v[x][y] < 0) v[x][y] += mod;
	}
	return v[x][y];
}

signed main() {
    cin >> a >> b >> c >> d;

    cout << dp(c, d) << endl;
}


Measured memory_bytes: 74116
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
int c=0;
for(int i=0;i<n;i++)
{
if(a[i]>=k)
c++;
}
System.out.println(c);


}
}

Measured memory_bytes: 48904
#include <iostream>

using namespace std;

int main() {
  int d, sum;
  while (cin >> d) {
    sum = 0;
    for (int i = 1; d * i <= 600 - d; i++) {
      sum += d * (d * i) * (d * i);
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>

double PI;

double deg2rad(double deg){
    return (deg / 360) * 2 * PI;
}

int main(){
    int a, b, c;
    double cr;
    
    PI = acos(-1);
    
    scanf("%d %d %d", &a, &b, &c);
    
    cr = deg2rad(c);
    
    printf("%f\n", (a * b * sin(cr)) / 2); // (1/2)(a b sin c)
    printf("%f\n", a + b + sqrt(a * a + b * b - 2 * a * b * cos(cr)));
    printf("%f\n", b * sin(cr));
    
    return 0;
}

Measured memory_bytes: 632
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
ll n,ans = 0;
void dfs(ll a){
    if(a > n)
        return ;
    ll tmp = a;
    ll seven = 0,five = 0,three = 0;
    while(tmp){
        if(tmp % 10 == 3)
            three++;
        if(tmp % 10 == 5)
            five++;
        if(tmp % 10 == 7)
            seven++;
        tmp /= 10;
    }
    if(three && five && seven)
        ans++;

    for(ll i = 1; i <= 3; i++){
        dfs(a * 10 + (2 * i) + 1);
    }
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);

cin >> n;

for(ll i = 1; i <= 3; i++){
    dfs((2 * i) + 1);
}

cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string S, T;
    cin >> S >> T;

    ll ans = 9999999;
    for(int i = 0; i < S.size() - T.size()+1; i++ ){
        ll diff=0;
        for(int j = 0; j < T.size(); j++ ){
            if( T[j] != S[i+j] ) diff++;
        }
        ans = min(ans, diff);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#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)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int d;
  cin >> d;
  if (d == 25) cout << "Christmas" << endl;
  else if (d == 24) cout << "Christmas Eve" << endl;
  else if (d == 23) cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    cnt = 0
    for a in range(1, n-1):
        for b in range(a+1, n):
            c = x - a - b
            if b < c <= n:
                #print(f"{a}, {b}, {c}")
                cnt += 1
    print(cnt)



Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char W[10], T[1];
    int count = 0, i;
    scanf("%s", W);
    while (scanf("%s", T) && strcmp(T, "END_OF_TEXT")) {
        for (i = 0; T[i]; i++) {
            T[i] = tolower(T[i]);
        }
        if (!strcmp(W, T)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 552
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

l,r,d=map(int,input().split())
print(r//d-(l-1)//d)

Measured memory_bytes: 61736
#include <iostream>
using namespace std;
int main(){
int X;
  cin>>X;
  int counter=0;
  while(X>499){
    X-=500;
      counter++;
  }
  int bounter=0;
  while(X>4){
    X-=5;
      bounter++;
  }
  cout<<1000*counter+5*bounter<<endl;
}

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

// DEBUG - Start of snippet
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char& c){
	string res;
	return "'" + res + c + "'";
}
 
string to_string(bool b) {
	return (b ? "True" : "False");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
	if (!first) {
    	res += ", ";
  	}
  	first = false;
	res += to_string(v[i]);
	}
	res += "}";
	return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}
 
template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
   	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
   	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr<<endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "\t[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else		
#define debug(...) 0
#endif
// DEBUG - End of snippet

// THINK: INT vs LONG LONG?

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

	int numA, numB, A, B, C;
	cin >> numA >> numB >> A >> B >> C;

	vector<int> a1(A), b1(B), c(C);
	for (int i = 0; i < A; ++i)
		cin >> a1[i];
	for (int i = 0; i < B; ++i)
		cin >> b1[i];
	for (int i = 0; i < C; ++i)
		cin >> c[i];

	sort(a1.rbegin(), a1.rend());
	sort(b1.rbegin(), b1.rend());
	sort(c.rbegin(), c.rend());

	vector<int> a(a1.begin(), a1.begin() + numA);
	vector<int> b(b1.begin(), b1.begin() + numB);
	long long a_sum = accumulate(a.begin(), a.end(), (long long) 0);
	long long b_sum = accumulate(b.begin(), b.end(), (long long) 0);

	debug(a, b);

	for (int i = 0; i < C; ++i) {
		int diff1 = (a.empty() ? - 1 : c[i] - a.back());
		int diff2 = (b.empty() ? -1 : c[i] - b.back());
		if (diff1 >= diff2 && diff1 > 0) {
			a_sum += diff1;
			a.pop_back();
		}
		else if (diff2 > diff1 && diff2 > 0) {
			b_sum += diff2;
			b.pop_back();
		}
	}

	long long ans = a_sum + b_sum;

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5000
#include<iostream>

int main(){
  int a,b;
  std::cin>>a>>b;
  if(0<a){
    std::cout<<"Positive"<<std::endl;
  }else if((b-a+1)%2==0&&b<0){
    std::cout<<"Positive"<<std::endl;
  }else if(a<=0&&b>=0){
    std::cout<<"Zero"<<std::endl;
  }else std::cout<<"Negative"<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int s;
    cin>>s;
    int k[1000000]={};
    k[s]++;
    for(int i=2;;i++){
        if(s%2==0){
            s/=2;
        }else{
            s=3*s+1;
        }
        k[s]++;
        if(k[s]==2){
            cout<<i<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector<int> h(N);
		for (int i = 0; i < N; i++)
			cin >> h[i];
		int M; cin >> M;
		vector<string> t(M);
		vector<int> m(M), d(M);
		for (int j = 0; j < M; j++) {
			string s;
			cin >> s >> m[j] >> t[j] >> d[j];
			d[j] = min(d[j], 100000);
		}
		vector<int> dps(100001, INF), dpa(100001, INF);
		dps[0] = dpa[0] = 0;
		for (int j = 0; j < M; j++) {
			vector<int>& dp = (t[j] == "Single" ? dps : dpa);
			for (int k = 0; k < d[j]; k++)
				dp[k] = min(dp[k], m[j]);
			for (int k = d[j]; k <= 100000; k++)
				dp[k] = min(dp[k], dp[k - d[j]] + m[j]);
		}
		ll mini = INF;
		for (int k = 0; k <= 100000; k++) {
			ll sum = dpa[k];
			for (int i = 0; i < N; i++) {
				int x = max(0, h[i] - k);
				sum += dps[x];
			}
			mini = min(mini, sum);
		}
		cout << mini << endl;
	}
}

Measured memory_bytes: 1868
# p (0..6).to_a.map{|j| [6 ** j, 9 ** j] }.flatten.uniq
a = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 59049, 46656, 531441]

m, dp = gets.to_s.to_i, [0]
(1..m).each {|i|
  t = 987654321
  a.select {|j| i - j >= 0 }.map{|j| i - j }.each{|c| t = dp[c] if t > dp[c] }
  dp.push(t + 1)
}
puts dp[-1]

Measured memory_bytes: 3196
package main

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

func main() {
	var ans, n, m, a, b int
	n = readi()
	m = readi()
//	h := atoi(readSlice()) バージョンの壁、許さん
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	l := make([]int, n)

	for i:=0; i<m; i++ {
		a = readi()
		b = readi()
		a--
		b--

		if h[a] >= h[b]{
			l[b]++
		}
		if h[a] <= h[b] {
			l[a]++
		}
	}

	for _, n := range l {
		if n == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 6584
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  string s,t;
  cin >> N >> s >> t;

  for(int i = 0;i <= N;i++) {
    bool ok = true;
    for(int j = i;j < N;j++) {
      if(s.at(j) != t.at(j-i)) {
        ok = false;
        break;
      }
    }
    if(ok) {
      cout << N+i << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

ll modbeki(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1){
      res *= x % MOD;
      res %= MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vll dp(K+1, 0LL);
  ll ans = 0LL;
  for(int i = K; i >= 1; i--){
    ll num = K / i;
    dp.at(i) = modbeki(num, N);
    for(int j = 2; i*j <= K; j++){
      dp.at(i) += MOD - dp.at(i*j);
      dp.at(i) %= MOD;
    }
    ans += dp.at(i) * i;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    string n;
    int mp[127], i;
    mp['I'] = 1;
    mp['V'] = 5;
    mp['X'] = 10;
    mp['L'] = 50;
    mp['C'] = 100;
    mp['D'] = 500;
    mp['M'] = 1000;
    while (cin >> n) {
        int ans = 0;
        for (i = 0; i < n.length()-1; i++) {
            if (mp[n[i+1]] <= mp[n[i]]) {
                ans += mp[n[i]];
            } else {
                ans -= mp[n[i]];
            }
        }
        ans += mp[n[i]];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int n;
    cin >> n;
    vector<set<int>> graph(n, set<int>());
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            --v;
            graph[u].insert(v);
        }
    }

    queue<pair<int, int>> q;
    vector<int> distances(n, -1);
    q.push(make_pair(0, 0));
    distances[0] = 0;
    while (!q.empty()) {
        pair<int, int> curr_dist = q.front();
        q.pop();
        int curr = curr_dist.first;
        int dist = curr_dist.second;
        const set<int>& nexts = graph.at(curr);
        for (int e : nexts) {
            if (distances[e] < 0) {
                q.push(make_pair(e, dist + 1));
                distances[e] = dist + 1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << distances[i] << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans;
	if (n > m / 2)ans = m / 2;
	else ans = (n + (m - 2 * n) / 4);
	cout << ans<< endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    private static int H = 0;
    private static int W = 0;
    private static char[][] AHW;

    public static void main(String[] args) {
        Main main = new Main();

        Scanner sc = new Scanner(System.in);

        String[] HW = sc.nextLine().split(" ");
        H = Integer.parseInt(HW[0]);
        W = Integer.parseInt(HW[1]);

        AHW = new char[H][W];
        Queue<Cell> queue = new ArrayDeque<>();

        for (int i = 0; i < H; i++) {
            String A = sc.nextLine();
            AHW[i] = A.toCharArray();
            for (int j = 0; j < W; j++) {
                if (AHW[i][j] == '#') {
                    queue.add(main.new Cell(i, j, 0));
                }
            }
        }

        int times = 0;
        while (!queue.isEmpty()) {

            Cell cell = queue.poll();
            int row = cell.row;
            int col = cell.col;
            int layer = cell.layer;

            if (row > 0 && AHW[row - 1][col] == '.') {
                // 上のセルが白だった場合
                AHW[row - 1][col] = '#';
                queue.add(main.new Cell(row - 1, col, layer + 1));
            }

            if (row < H - 1 && AHW[row + 1][col] == '.') {
                // 下のセルが白だった場合
                AHW[row + 1][col] = '#';
                queue.add(main.new Cell(row + 1, col, layer + 1));
            }

            if (col > 0 && AHW[row][col - 1] == '.') {
                // 左のセルが白だった場合
                AHW[row][col - 1] = '#';
                queue.add(main.new Cell(row, col - 1, layer + 1));
            }

            if (col < W - 1 && AHW[row][col + 1] == '.') {
                // 右のセルが白だった場合
                AHW[row][col + 1] = '#';
                queue.add(main.new Cell(row, col + 1, layer + 1));
            }
            times = layer;
        }

        System.out.println(times);
    }

    private class Cell {
        int row;
        int col;
        int layer;

        Cell(int row, int col, int layer) {
            this.row = row;
            this.col = col;
            this.layer = layer;
        }
    }
}


Measured memory_bytes: 67540
#include<stdio.h>

int main() {
    int r, d;
    long long x;
    scanf("%d %d %lld", &r, &d, &x);
    for(int i = 0; i < 10; i++) {
        x = x * r - d;
        printf("%lld\n", x);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && b != c) || (a == c && a != b) || (b == c && b != a))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    int n = 50;
    vector<ll> v(n,n-1);
    rep(i,0,n) v[i] += k/n;
    rep(i,0,k%n) v[i] += n+1;
    rep(i,0,n) v[i] -= k%n;
    cout<<n<<endl;
    rep(i,0,n) cout<<v[i]<<" \n"[i==n-1];
    return 0;
}


Measured memory_bytes: 256
a, b, c, d = input()
ops = ['+', '+', '+']
ans = []

def dfs(i, ops):
    ops = ops.copy()
    if eval(a + ops[0] + b + ops[1] + c + ops[2] + d) == 7:
        ans.append(a + ops[0] + b + ops[1] + c + ops[2] + d + '=7')
    elif i == 3:
        pass
    else:
        dfs(i + 1, ops)
        ops[i] = '-'
        dfs(i + 1, ops)

dfs(0, ops)

print(ans[0])

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 131072;
const int maxh = 1e5 + 5;
const int INF = 998244353;
const int G = 3;

int n, ans;
int cnt[maxh], fac[maxn], ifac[maxn], g[maxn];
vector<int> a, f;

inline int qpow(ll x, ll y){
	ll ret = 1;
	for(; y; y >>= 1){
		if(y & 1)
			(ret *= x) %= INF;
		(x *= x) %= INF;
	}
	return ret;
}

inline int C(int x, int y){ return 1ll * fac[x] * ifac[y] % INF * ifac[x - y] % INF; }

inline void fft(vector<int> &coe, int siz, int IDFT){
	for(; coe.size() < siz; coe.PB(0));
	for(int i = 0, j = 0; i < siz; ++i){
		if(i < j)
			swap(coe[i], coe[j]);
		for(int l = siz >> 1; (j ^= l) < l; l >>= 1);
	} 
	for(int step = 1; step < siz; step <<= 1){
		ll w;
		if(~IDFT)
			w = qpow(G, (INF - 1) / (step << 1));
		else
			w = qpow(G, INF - 1 - (INF - 1) / (step << 1));
		for(int i = 0; i < siz; i += step << 1){
			ll cur = 1;
			FOR(j, 0, step){
				int x = coe[i + j], y = 1ll * cur * coe[i + j + step] % INF;
				coe[i + j] = (x + y) % INF;
				coe[i + j + step] = (x - y + INF) % INF;
				(cur *= w) %= INF; 
			}
		}
	}
	if(!~IDFT){
		int inv = qpow(siz, INF - 2);
		FOR(i, 0, siz)
			coe[i] = 1ll * coe[i] * inv % INF;
	}
	return;
}

inline vector<int> mul(vector<int> a, vector<int> b){
	int siz = 1;
	for(; siz < a.size() + b.size(); siz <<= 1);
	fft(a, siz, 1);
	fft(b, siz, 1);
	vector<int> c;
	c.resize(siz);
	FOR(i, 0, siz)
		c[i] = 1ll * a[i] * b[i] % INF;
	fft(c, siz, -1);
//	FOR(i, 0, c.size())
//		printf("%d ", c[i]);
//	puts("");
	return c;
}

inline vector<int> solve(int l, int r){
	vector<int> ret; ret.PB(1);
	if(l == r){
   		REP(i, 1, a[l] / 2)
			ret.PB(1ll * C(a[l], i * 2) * g[i * 2] % INF);
//		FOR(i, 0, ret.size())
//			printf("%d ", ret[i]);
//		puts(""); 
		return ret;
	}
	int md = l + r >> 1;
//	printf("l = %d r = %d\n", l, r);
	return mul(solve(l, md), solve(md + 1, r));
}

inline void precalc(){
	g[0] = 1;
	for(int i = 2; i < maxn; i += 2)
		g[i] = 1ll * g[i - 2] * (i - 1) % INF;
	fac[0] = 1;
	FOR(i, 1, maxn)
		fac[i] = 1ll * fac[i - 1] * i % INF;
	ifac[maxn - 1] = qpow(fac[maxn - 1], INF - 2);
	for(int i = maxn - 2; i >= 0; --i)
		ifac[i] = 1ll * ifac[i + 1] * (i + 1) % INF;
	return;
}

int main(){
	precalc();
	scanf("%d", &n);
	FOR(i, 0, n * 2){
		int x; scanf("%d", &x);
		++cnt[x];
	} 
	REP(i, 1, 100000) if(cnt[i])
		a.PB(cnt[i]);
	f = solve(0, a.size() - 1);
	REP(i, 1, n){
		int res = 1ll * f[i] * g[n * 2 - i * 2] % INF;
		if(i & 1)
			(ans += res) %= INF;
		else
			((ans -= res) += INF) %= INF;
	}
	
	ans = INF - ans;
	(ans += g[n * 2]) %= INF;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12356
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = A[0]
ans = 0
for i in range(N):
    b = B[i]
    if s >= b:
        ans += b
        b = 0
    else:
        ans += s
        b -= s
    s = A[i+1]
    if s >= b:
        ans += b
        s -= b
    else:
        ans += s
        s = 0
print(ans)

Measured memory_bytes: 82020
import sys
input=sys.stdin.readline
n,k,s=map(int,input().split())
if s==10**9:
    for i in range(k):
        print(s,end='')
        print(' ',end='')
    for i in range(n-k):
        print(1,end='')
        print(' ',end='')
else:
    for i in range(k):
        print(s,end='')
        print(' ',end='')
    for i in range(n-k):
        print(10**9,end='')
        print(' ',end='')


Measured memory_bytes: 63448
#include<stdio.h>
int main(){
	char a[10],b[10],t[10];
  	int anum,bnum;
  scanf("%s %s",&a,&b);
  scanf("%d %d",&anum,&bnum);
  scanf("%s",&t);
  
  if(strcmp(a,t) == 0){
    printf("%d %d",anum - 1,bnum);
  }else{
    printf("%d %d",anum,bnum - 1);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <string>
#include <bitset>
#include <algorithm>
#include <functional>
#include <limits.h>
using namespace std;
using ll = long long;

int main(){
    ll N,K;
    string S;
    cin >> N >> K >> S;
    
    ll L=0,R=0,cnt=0;
    ll ans = 0;

    char flag = '1';
    while(1){
        if (R==N) break;
        if (cnt==K+1) break;
        
        if(flag=='0' && S[R]=='0') {R++;continue;}
        if(flag=='0' && S[R]=='1') {flag='1';continue;}
        if(flag=='1' && S[R]=='1') {R++;continue;}
        if(flag=='1' && S[R]=='0') {flag='0';cnt++;continue;}
    }

    ans = max(ans,R-L);

    while(1){
        
        char flag = '0';
        while(1){//Rを進める
            if (R == N) break;
            if(flag=='0' && S[R]=='0') {R++;continue;}
            if(flag=='0' && S[R]=='1') {flag='1';continue;}
            if(flag=='1' && S[R]=='1') {R++;continue;}
            if(flag=='1' && S[R]=='0') {break;}
        }

        flag = '1';
        while(1){//Lを進める
            if (L==N) break;
            if(flag=='1' && S[L]=='1') {L++;continue;}
            if(flag=='1' && S[L]=='0') {flag='0';continue;}
            if(flag=='0' && S[L]=='0') {L++;continue;}
            if(flag=='0' && S[L]=='1') {break;}
        }

        ans = max(ans,R-L);
        if (R==N && L==N) break;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
ans = []
f = [0 for _ in range(10**4+1)]
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if tmp <= n:
                f[tmp] += 1
for i in range(1, n+1):
    ans.append(str(f[i]))
print("\n".join(ans))

Measured memory_bytes: 68160