akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 998244353
int n, k; 
int a,b,c,d;
int main() {
	io
	cin>>b>>a>>d>>c;
	string ans = "No";
	while(b> 0 && d > 0) {
		d -= a;
		if(d <= 0) {
			ans = "Yes";
			break;
		} 
		b -= c;
		if(b <= 0) break;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
n=int(input())
A=list(map(int,input().split()))
X=[0]*n
S=sum(A)
A2=0
for i in range(1,n-1,2):
  A2+=A[i]
X[0]=S-2*A2
for i in range(1,n):
  X[i]=2*A[i-1]-X[i-1]
print(*X)

Measured memory_bytes: 20588
// D - Anything Goes to Zero

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll rem[2][200000];
ll rem_sum[2];

// aのn乗をmodで割った余りを計算
ll mod_pow(ll a, ll n, ll mod) {
	ll result = 1;
	while (n > 0) {
		if (n & 1) result = result * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return result;
}

int popcount (int n) {
	int result = 0;
	while(n) {
		if (n % 2 == 1) result++;
		n /= 2;
	}
	return result;
}

ll f(int n, int k) {
	if (n == 0) return k;

	return f(n % popcount(n), k+1);
}

int main() {
	int N;
	string X;
	cin >> N >> X;

	int pop_cnt = 0;
	for (int i=0; i<N; i++) {
		if (X[i] == '1') pop_cnt++;
	}

	for (int i=0; i<N; i++) {
		if (X[i] == '1') {
			rem_sum[0] += mod_pow(2, N-i-1, pop_cnt + 1);
			if (pop_cnt != 1) rem_sum[1] += mod_pow(2, N-i-1, pop_cnt - 1);
		}
	}

	vector<ll> ans_list;
	ans_list.reserve(N);

	for (int i=0; i<N; i++) {
		ll r;

		if (X[i] == '0') {
			r = (rem_sum[0] + mod_pow(2, N-i-1, pop_cnt + 1)) % (pop_cnt + 1);
		} else {
			if (pop_cnt == 1) {
				ans_list.push_back(0);
				continue;
			}

			r = (rem_sum[1] - mod_pow(2, N-i-1, pop_cnt - 1)) % (pop_cnt - 1);
		}

		ans_list.push_back(f(r, 1));
	}

	for (ll ans : ans_list) {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 5220
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll solve() {
    int n;
    cin>>n;
    vector<int> l(n),r(n);
    vector<vector<int>> evL(n+10), evR(n+10);
    
    ll res = 0;
    for (int i=0; i<n; i++) {
	int k;
	cin>>k>>l[i]>>r[i];
	if (l[i]>=r[i]) {
	    evL[k].push_back(i);
	} else {
	    evR[k+1].push_back(i);
	}
	res += min(l[i],r[i]);
    }

    // left
    {
	priority_queue<ll,vector<ll>,greater<ll>> pq;
	for (int i=1; i<=n; i++) {
	    for (int j: evL[i]) {
		pq.push(l[j]-r[j]);
		res += (l[j]-r[j]);
	    }
	    while ((int)pq.size() > i) {
		res -= pq.top();
		pq.pop();
	    }
	}
    }


    // right
    {
	priority_queue<ll,vector<ll>,greater<ll>> pq;
	for (int i=n; i>=1; i--) {
	    for (int j: evR[i]) {
		pq.push(r[j]-l[j]);
		res += (r[j]-l[j]);
	    }
	    while ((int)pq.size() > n-i+1) {
		res -= pq.top();
		pq.pop();
	    }
	}
    }

    return res;
}

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

    int t; cin>>t;
    while (t--) {
	cout<<solve()<<"\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 20544
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key)i++;
	return i!=n;
}

int main() {
	int i, n, A[10000 + 1], q, key, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(A, n, key))sum++;
	}
	printf("%d\n", sum);

	return 0;
}

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

int main(){
    int N, T, c[100], t[100];
    int min = -1;
    bool flag = false;
    scanf("%d%d", &N, &T);
    for (int i = 0; i < N; i++) {
        scanf("%d%d", &c[i], &t[i]);
        if(t[i] <= T){
            if(flag == false){
                min = c[i];
                flag = t;
            }else if(min > c[i]){
                min = c[i];
            }
        }
    }
    if(flag){
        printf("%d\n", min);
    }else{
        printf("TLE\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void print_vec(vector<int>& a, int n=-1){
    n=(n==-1?a.size():n);
    for(int i=0;i<n;i++)
        cout<<a[i]<<(i<n-1?" ":"\n");
}

void solve(){
    string s;
    cin>>s;
    vector<int> rem(2019,0);
    rem[0]=1;
    int r=0;
    long long mul=1;
    for(int i=s.size()-1;i>=0;i--){
        r=(r)+int(s[i]-'0')*mul;
        r%=2019;
        rem[r]++;
        mul=(mul*10)%2019;
    }

    // for(int i=0;i<rem.size();i++) if(rem[i]>0) cout<<i<<" "<<rem[i]<<"\n";

    long long ans=0;
    for(int i=0;i<rem.size();i++){
        ans+=(1ll*rem[i]*rem[i]-rem[i])/2;
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3784
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
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

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    for i in range(2*n):
        s[i] = ord(s[i])-96
    k = 27
    m = 1<<n
    p = [1<<j for j in range(n)]
    d = defaultdict(lambda : 0)
    l = [(0,0)]
    for i in s[:n][::-1]:
        l = [(x[0]*k+i, x[1]) for x in l]+[(x[0], x[1]*k+i) for x in l]
    for i in l:
        d[i] += 1
    ans = 0
    l = [(0,0)]
    for i in s[n:]:
        l = [(x[0]*k+i, x[1]) for x in l]+[(x[0], x[1]*k+i) for x in l]
    for i in l:
        ans += d[i]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

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


Measured memory_bytes: 128964
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;

namespace ABC121D_1
{
    //ref: https://atcoder.jp/contests/abc121/submissions/4530935 by Chokudai さん
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var A = ss.Next(long.Parse);
            var B = ss.Next(long.Parse);
            sw.WriteLine(F(A - 1) ^ F(B));
            //---------------------------------
        }

        long F(long n)
        {
            n++;
            var ret = 0L;

            for (var i = 1; i < 50; i++)
            {
                var cycle = 1L << i;
                var loop = (n / cycle) * (cycle / 2);
                var extra = Max(0, n % cycle - cycle / 2);
                var bit = (loop + extra) % 2;
                ret += bit * (1L << (i - 1));
            }

            return ret;
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = (n - 1); i >= 0; i--)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

int main() {

	ll n;
	cin >> n;
	vector<ll> name;

	while (n > 0) {
	
		name.push_back(n%26);
		n--;
		n /= 26;
	}
	
	ll s = name.size();

	for (ll i = s - 1; i >= 0; i--) {
		if (name[i] == 0) {
			cout << 'z';
		}
		else {
			char a = 96 + name[i];
			cout << a;
		}
	}

	cout << endl;

	return 0;
}

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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();

    string s;   cin >> s;
    int fr[26] = {0};
    loop(i, 0, s.size()){
        fr[s[i] - 'a']++;
    }


    loop(i, 0, 26){
        if(fr[i] & 1)
            return cout << "No", 0;
    }

    cout << "Yes";
}

Measured memory_bytes: 256
import math
import numpy

s = input().split(' ')
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = c - a - b
#print(numpy.float128(math.sqrt(a)), numpy.float128(math.sqrt(b)), numpy.float128(math.sqrt(a)) + numpy.float128(math.sqrt(b)), numpy.float128(math.sqrt(c)))
if d**2 > 4*a*b and d > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,a[N],d,fac[N],inv[N],pos[N];
inline int poww(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%dalao)if(b&1)r=1ll*r*a%dalao;return r;}
inline int C(int a,int b){return a<b?0:1ll*fac[a]*inv[b]%dalao*inv[a-b]%dalao;}
int main(){
	scanf("%d",&n);fac[0]=1;
	for(int i=1;i<=n+1;i++){
		fac[i]=1ll*fac[i-1]*i%dalao,scanf("%d",&a[i]);
		if(!pos[a[i]])pos[a[i]]=i;
		else d=i-pos[a[i]];
	}
	inv[n+1]=poww(fac[n+1],dalao-2);
	for(int i=n;~i;i--)inv[i]=1ll*inv[i+1]*(i+1)%dalao;
	for(int i=1;i<=n+1;i++)printf("%d\n",(C(n+1,i)-C(n-d,i-1)+dalao)%dalao);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char s[maxn];
int ind[maxn];
int main()
{
    scanf("%s", s+1);
    int n=strlen(s+1);
    ind[0]=0;
    int k=1;
    for(int i=1; s[i]; i++)
    {
        if(s[i]!='x')ind[k++]=i;
    }
    ind[k]=n+1;
    int ans=0;
    for(int i=1, j=k-1; i<=j; i++, j--)
    {
        if(s[ind[i]]!=s[ind[j]])return 0*printf("-1\n");
//        printf("i%d %d+j%d %d\n", ind[i],ind[i-1], ind[j+1],ind[j]);
        int ma=max(ind[i]-ind[i-1]-1, ind[j+1]-ind[j]-1);
        ans+=ma-(ind[i]-ind[i-1]-1)+ma-(ind[j+1]-ind[j]-1);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 768
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
struct kek{
    int a,b,c,d;
};




vector<kek> arr;
int ans=0;
void gogo(int n, int m, int kolvo, vector<int> &now, int last){
    if(kolvo==n){
        int sm=0;
        for(int j=0;j<arr.size();j++){
            if(now[arr[j].b-1]-now[arr[j].a-1]==arr[j].c){
                sm+=arr[j].d;
            }
        }
        ans=max(ans, sm);
        return;
    }
    for(int i=last;i<=m;i++){
        now[kolvo]=i;
        gogo(n,m,kolvo+1, now, i);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vector<int> arr(n+1);
    for(int i=0;i<n;i++){
        cin>>arr[i+1];
    }
    vector<vector<int>> vert(n+1, vector<int>(0));
    vector<bool> ans(n+1, true);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(arr[a]>=arr[b]){
            ans[b]=false;
        }
        if(arr[b]>=arr[a]){
            ans[a]=false;
        }
    }
    int ans1=0;
    for(int i=1;i<n+1;i++) ans1+=ans[i];
    cout<<ans1;
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 6168
#include <iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  int ans;
  for (int i = 0; ; ++i) {
    if (i * a - i + 1 >= b) {
      ans = i;
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

    int min = *min_element(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());

    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX_ELEMENTS 100000
#define INFTY  1000000001

typedef struct {
  char m;
  int n;
} Card;

Card L[MAX_ELEMENTS],R[MAX_ELEMENTS];
int n;

void swap(Card *A,Card *B){
  Card t;
  t=*A;
  *A=*B;
  *B=t;
}

void merge(Card *A,int left,int mid,int right){
  
    int n1, n2,i,j,k;

    n1 = mid - left;
    n2 = right - mid;

    //L[0...n1], R[0...n2] を生成
    for(i=0; i<=n1-1; i++)  L[i] = A[left + i];
    for(i=0; i<=n2-1; i++)  R[i] = A[mid + i];
    
    L[n1].n = INFTY;
    R[n2].n = INFTY;

    i = 0;
    j = 0;

    for(k=left; k<=right-1; k++){
        if(L[i].n<=R[j].n) A[k] = L[i++];
        else               A[k] = R[j++];
    }
}

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

int partition(Card *A, int p, int r){
    int x = A[r].n;
    int i = p-1;
    int t;
    for(int j=p;j<r;j++){
        if(A[j].n <= x){
            i++;
            swap(&A[i], &A[j]);
        }
    }
    swap(&A[i+1],&A[r]);
    return i+1;
}

void quicksort(Card *A,int p,int r){
    int q;
    if(p < r){
        q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
}

int main(void){

    int i,flag=0;
    char S[10];
    Card A[MAX_ELEMENTS],B[MAX_ELEMENTS];

    // printf("number of element:");
    scanf("%d", &n);
    for(i=0; i<n; i++){
    scanf("%s %d", S, &A[i].n);
    B[i].m = A[i].m = S[0];
    B[i].n = A[i].n;
    }

    quicksort(A, 0, n-1);
    mergeSort(B, 0, n);

    for(i=0;i<n;i++){
        if(A[i].m != B[i].m) flag=1;
    }
    if(flag==1) printf("Not stable\n");
    else        printf("Stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n", A[i].m, A[i].n);
    }
    return 0;
}



Measured memory_bytes: 4072
import java.util.*;
import java.lang.*;


public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> stack = new ArrayList<>();
        int pointer = -1;

        while(sc.hasNext()) {
            String x = sc.next();
            //if (x == "$") break;
            if (Character.isDigit(x.charAt(0))) {
                stack.add(Integer.parseInt(x));
                pointer++;
                //System.out.println("add " + x);
            } else {
                int a1 = stack.get(pointer - 1);
                int a2 = stack.get(pointer);
                int res = 0;
                switch (x){
                    case "+":
                        res = a1 + a2;
                        break;
                    case "-":
                        res = a1 - a2;
                        break;
                    case "*":
                        res = a1 * a2;
                        break;
                }
                stack.remove(pointer);
                stack.remove(pointer - 1);
                stack.add(res);
                //System.out.println(a1 + x + a2 + " = " + res);
                pointer--;
            }
        }
        System.out.println(stack.get(0));
    }
}


Measured memory_bytes: 26220
mod stdin_reader {
  use std::io::stdin;
  use std::io::Read;

  pub struct StdinReader {
    pub buf: Vec<String>,
    pub cursor: usize,
  }

  pub fn new() -> StdinReader {
    StdinReader::new()
  }

  impl StdinReader {
    pub fn new() -> Self {
      let mut s = String::new();
      let stdin = stdin();
      stdin.lock().read_to_string(&mut s).unwrap();
      let buf = s.split_whitespace().map(|s| s.to_string()).collect();
      return StdinReader { buf: buf, cursor: 0 }
    }

    pub fn read_all(&self) -> Vec<String> {
      return self.buf.clone()
    }

    pub fn next(&mut self) -> Option<String> {
      let val = self.buf.get(self.cursor).cloned();
      self.cursor += 1;
      return val
    }

    pub fn as_i64(&mut self) -> Option<i64> {
      self.next().and_then(|s| s.parse::<i64>().ok())
    }

    pub fn as_f64(&mut self) -> Option<f64> {
      self.next().and_then(|s| s.parse::<f64>().ok())
    }

    pub fn as_usize(&mut self) -> Option<usize> {
      self.next().and_then(|s| s.parse::<usize>().ok())
    }
  }
}

mod utils {
  pub fn is_int(n: f64) -> bool {
    let trunc = (n.trunc() as i64) as f64;
    return (n - trunc) < 0.0001
  }
}

fn main() {
  // stdout
  use std::io::{stdout, Write, BufWriter};
  let stdout = stdout();
  let mut writer = BufWriter::new(stdout.lock());

  // stdin
  let mut reader = stdin_reader::new();

  let n = reader.as_usize().unwrap();
  let mut a_list = vec![0];
  a_list.extend((0..n).map(|_| reader.as_i64().unwrap()));
  let mut boxes = vec![0; n+1];
  let mut result_rev = vec![];
  for i in (1..(n+1)).rev() {
    let mut bigger_sum: i64 = 0;
    let mut bigger_i = i;
    loop {
      bigger_sum += boxes[bigger_i];
      bigger_i += i;
      if bigger_i > n {
        break;
      }
    }

    if bigger_sum % 2 == a_list[i] {
      // do nothing
    } else {
      boxes[i] = 1;
      result_rev.push(i);
    }
  }

  println!("{}", result_rev.len());
  println!("{}", result_rev.into_iter().rev().map(|i| format!("{}", i)).collect::<Vec<String>>().connect(" "));
}

Measured memory_bytes: 21368
n,k = map(int,input().split())
arr = list(map(int,input().split()))

pro = 0
for i in range(k):
    pro += arr[i]


ans = pro
for i in range(k,n):
    pro = pro + arr[i]-arr[i-k]
    if pro > ans:
        ans = pro

# print(ans)
print((ans+k)/2)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("/home/pushkar/cpp/input.txt", "r", stdin);
    // freopen("/home/pushkar/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n][2], i, j, k = 0;
    for (i=0;i<n;i++)
    {
        for (j=0;j<2;j++)
        {
            cin >> a[i][j];
        }
    }
    for (i=0;i<n;i++)
    {
        if (a[i][0] == a[i][1])
        k++;
        else
        k = 0;
        if (k == 3)
        break;
    }
    if (k == 3)
    cout << "Yes\n";
    else
    cout << "No\n";
    return 0;
}

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

//2次元累積和 
//初期化
const int H = 2001;
const int W = 2001;
vector<vector<int>> v(H, vector<int>(W, 0));
vector<vector<int>> sum(H+1, vector<int>(W+1, 0));
void init() {
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + v[i][j];
}
//[x1, x2) × [y1, y2) の長方形区域の和
int get_sum(int x1, int x2, int y1, int y2) {
    return sum[y2][x2] - sum[y1][x2] - sum[y2][x1] + sum[y1][x1];
}

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') y += k;
        x %= k * 2;
        y %= k * 2;

        v.at(y).at(x)++;
    }
    init();

    auto to_inside = [&](int a){return max(0, min(k * 2 + 1, a));};

    int dx[8] = {0, -k, -k, k, k, 0     , -k * 2, -k * 2};
    int dy[8] = {0, -k, k, -k, k, -k * 2, 0     , -k * 2};

    int maxi = 0;
    for (int i = 0; i <= k * 2; i++) {
        for (int j = 0; j <= k * 2; j++) {
            int cnt = 0;
            for (int d = 0; d < 8; d++) {
                int y1 = to_inside(i + dy[d]), y2 = to_inside(i + dy[d] + k);
                int x1 = to_inside(j + dx[d]), x2 = to_inside(j + dx[d] + k);

                cnt += get_sum(x1, x2, y1, y2);
            }
            maxi = max(maxi, cnt);
        }
    }
    cout << maxi << endl;
}

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

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,i;
    cin>>n;
    string s;
    int num;
    map<pair<string,int>,int>m;
    map<pair<string,int>,int>::iterator it;
    for(i=1;i<=n;i++)
    {
    	cin>>s>>num;
    	m[{s,100-num}]=i;
	}
	for(it=m.begin();it!=m.end();it++)
	cout<<it->second<<"\n";
	
	
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main( void )
{
  /* ボール数入力 */
  long n;
  cin >> n;
  
  /* ボールの番号と番号の数を入力 */
  vector<long> a(n), c(n);
  long ans = 0;
  for ( auto &i : a ) {
    cin >> i;
    ans += c[i]++;
  }

  for ( const auto &i : a ) {
    cout << (ans - (c[i] - 1)) << endl;  
  }
  
  return 0;
}

Measured memory_bytes: 5760
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{

	const int mod = 1000000007;
	static void Main(string[] args)
	{

		var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);
		string[] inputnq = Console.ReadLine().Split(' ');
		int n = int.Parse(inputnq[0]);
		int q = int.Parse(inputnq[1]);
		string S = Console.ReadLine();
		char[] s = new char[n];
		for (var i = 0; i < n; i++)
		{
			s[i] = S[i];
		}

		int[] l = new int[q];
		int[] r = new int[q];
		for (var i = 0; i < q; i++)
		{
			string[] input = Console.ReadLine().Split(' ');
			l[i] = int.Parse(input[0]);
			r[i] = int.Parse(input[1]);
		}
		int[] t = new int[n];
		for (var i = 0; i < n - 1; i++)
		{
			if (s[i] == 'A' && s[i + 1] == 'C')
			{
				s[i] = 'a';
			}
		}
		for (var i = 0; i < n; i++)
		{
			if (i == 0)
			{
				if (s[0] == 'a') { t[0] = 1; }
				else { t[0] = 0; }
			}
			else
			{
				if (s[i] == 'a') { t[i] = t[i - 1] + 1; }
				else { t[i] = t[i - 1]; }
			}

		}

		for (var i = 0; i < q; i++)
		{
			int ans = 0;
			if (r[i] == 1) { ans = 0; }
			else if (l[i] == 1) { ans = t[r[i] - 2]; }
			else { ans = t[r[i] - 2] - t[l[i] - 2]; }
			Console.WriteLine(ans);
		}
		Console.Out.Flush();
	}
}

Measured memory_bytes: 17348
#include <iostream>
#include <cmath>

using namespace std;

long long fact(long long x) {
  if (x == 1)
    return 1;
  else
    return (x * fact(x - 1)) % 1000000007;
}

int main(int argc, char* argv[]) {
  long long N, M;
  cin >> N >> M;

  if (abs(N - M) >= 2) {
    cout << 0 << endl;
    return 0;
  }

  long long ret = 0;
  if (N == M) {
    ret += (fact(N) * fact(M) * 2) % 1000000007;
  } else {
    ret += (fact(N) * fact(M)) % 1000000007;
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    ans = 0
    for C in range(1, N):
        tmp = 0
        L = 0
        lim = (N - 1 - C) if (N - 1) % C else (N // 2)
        while L < lim:
            tmp += S[L] + S[-1 - L]
            ans = max(ans, tmp)
            L += C
    return ans

print(main())

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

int main()
{
    ll X,Y;
    cin >> X >> Y;

    vector<ll> A(1);
    A[0] = X;

    ll i = 0;
    while(1)
    {
        ll tmp = A[i] * 2;
        if(tmp > Y)break;
        else
        {
            A.push_back(tmp);
        }
        i++;
    }
    cout << A.size() << endl;
}

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

long long keta(long long num){
  int tmp=0;
  while(num){
    tmp++;
    num/=10;
  }
  ans=min(ans,tmp);
  return 0;
}

int main(){
  long long n;
  cin>>n;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      if(i>=n/i){
        keta(i);
      }
      else
        keta(n/i);
    }
  }
  cout <<ans<<endl;
}

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

int main() {
	int N; int A; int B;
	cin >> N >> A >> B;

	int max = min(A, B);
	int min = 0;
	if ((A + B) - N > 0) {
		min = (A + B) - N;
	}

	cout << max << " " << min << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()

typedef vector<int> vi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef long long ll;

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  if (B - A < 2) {
    cout << K + 1 << endl;
  } else {
    ll x = K - A + 1;
    ll ans = A + (x / 2) * (B - A) + x % 2;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    A = str(input())
    a.append(A)
for j in range(m):
    B = str(input())
    b.append(B)
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = 0
        for k in range(m):
            if a[i + k][j:j + m] != b[k]:
                flag += 1
        if flag == 0:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[10004] = {};
	ll y[10004] = {};
	ll z[10004] = {};
	ll connect[10004] = {};
	ll x2[10004] = {};
	ll z2[10004][10004] = { {} };
	vector<tuple<ll, ll>> vec;
	string s;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	//cout << LLONG_MAX<< endl;
	cin >> a;
	cin >> b;
	cin >> c;
	
	cout << min({a+b,b+c,c+a}) << endl;





	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え


/*vector<pair<ll, ll> > hoges(a);
for (int i = 0; i < a; i++)
{
cin >> x[i];
cin >> y[i];
hoges[i] = make_pair(x[i], y[i]);
}
sort(hoges.begin(),hoges.end(),comp);
for (int i = 0; i < a; i++)
{
if (hoges[i].second>=b)
{
ans += hoges[i].first*b;
break;
}
else
{
ans += hoges[i].first*hoges[i].second;
b -= hoges[i].second;

}
}*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n, m;
	cin>>n>>m;
	ll ans = 0, a[m];
	for(int i = 0 ; i< m; i++)
		cin>>a[i];
	ll l = 0;
	while(n>0)
	{
		n = n - a[l];
		l++;
		
	}
	if(l<=m)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

	int n, t, e;
	cin >> n >> t >> e;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];

	int ans = -1;
	for (int i = 0; i < n; i++) {
		for(int j = -e; j <= e; j++){
			if ((t + j) % x[i] == 0) {
				ans = i + 1;
				break;
			}
		}
		if (ans != -1) break;
	}

	cout << ans << endl;
}


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

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	k=n*m-k;
	for (int a=0;a<=n;a++)
	{
		if (n==2*a)
		{
			if (n*m==a*m+k)
			{
				puts("Yes");
				return 0;
			}
			else continue;
		}
		int b=(n*m-a*m-k)/(n-2*a);
		if (n*m-a*m-b*n+2*a*b==k&&b>=0&&b<=m)
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
int main(){
  int n;cin>>n;
  string s;
  cin>>s;
  int arr['z'-'a'+1];
  long long ret = 0;
  for(char i = 'a'; 'z' >= i; i++)arr[i-'a'] = 0;
  for(int i = 0; n-1 > i; i++){
    long long tmp = 1;
    arr[s[i] - 'a']++;
    for(char j = 'a'; 'z' >= j; j++){
      if(s[i+1] == j )continue;
      int chose = 1;
      if(arr[j-'a'] > 0){
        chose = chose + arr[j-'a'];
      }
      tmp = (long long)(tmp*chose)%MOD;
    }
    //cout <<tmp << endl;
    ret = (long long)(ret + tmp) % MOD;
  }
  ret = (long long)(ret + 1) % MOD;
  cout << ret << endl;
}

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

int main(){
    int N, M, i, L, R, l, r, ans;
    scanf("%d %d", &N, &M);
    l=0;
    r=N;
    for (i=0; i<N; i++){
      scanf("%d %d", &L, &R);
      if (L>l){
        l = L;
      }
      if (R<r){
        r = R;
      }
    }

    if (r-l+1>0){
      ans = r-l+1;
    }else{
      ans = 0;
    }
    printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	//初期化
    int dz[13]={0,0,0,0,1,1,1,1,1,1,1,1,1};
    int dy[13]={1,1,0,-1,1,1,0,-1,-1,-1,0,1,0};
	int dx[13]={0,1,1,1,0,1,1,1,0,-1,-1,-1,0};
    int n,m,p;
	while(cin>>n>>m>>p&&n){
		//ballの座標と色
		int ball[n][n][n]; rep(i,n)rep(j,n)rep(k,n) ball[i][j][k]=0;
		//答え
		int ansCnt=0;
		//見つかっているかどうか
		bool flg=0;

		for(int cnt=1;cnt<=p;cnt++){
			int x,y,z; cin>>x>>y; x--; y--;
			if(!flg){
				rep(i,n){
					if(!ball[x][y][i]){
						//black=10,white=100
						z=i;
						cnt%2?ball[x][y][i]=10:ball[x][y][i]=100;
						break;
					}
				}
				rep(i,13){
					int num=1,mul=0;
					//片方を延伸
					while(1){
						mul++;
						int cx=x+dx[i]*mul,cy=y+dy[i]*mul,cz=z+dz[i]*mul;
						if(0<=cx&&cx<n&&0<=cy&&cy<n&&0<=cz&&cz<n){
							if(ball[x][y][z]==ball[cx][cy][cz]) num++;
							else break;
						}
						else break;
					}
					//反対方向も
					mul=0;
					while(1){
						mul--;
						int cx=x+dx[i]*mul,cy=y+dy[i]*mul,cz=z+dz[i]*mul;
						if(0<=cx&&cx<n&&0<=cy&&cy<n&&0<=cz&&cz<n){
							if(ball[x][y][z]==ball[cx][cy][cz]) num++;
							else break;
						}
						else break;
					}
					if(num>=m){
						ansCnt=cnt;
						flg=1;
					}
				}
			}
		}
		if(!ansCnt) cout<<"Draw"<<endl;
		else{
			string ansColor;
			ansColor=ansCnt%2?"Black":"White";
			cout<<ansColor<<" "<<ansCnt<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define maxn 30
#define u32d unsigned int
#define LL   long long
#define INF  0x7FFFFFFF
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	if(ceil(n / 2019.0) != ceil(m / 2019.0)){
		cout << 0 << endl;
	}
	else{
		LL mul;
		LL ans = INF;
		for(int i = n; i <= m; ++i){
			for(int j = i + 1; j <= m; ++j){
				mul = 1;
				mul = mul * i;
				mul = mul * j;
				ans = min(mul % 2019, ans);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

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

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r,d,x;
	cin>>r>>d>>x;
	rep(i,10){
		x=x*r-d;
		cout<<x<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
#include<map>

using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	map<char,int>ss;
	
	ss['a']=1;
	ss['b']=2;
	ss['c']=3;
	ss['d']=4;
	ss['e']=5;
	ss['f']=6;
	ss['g']=7;
	ss['h']=8;
	ss['i']=9;
	ss['j']=10;
	ss['k']=11;
	ss['l']=12;
	ss['m']=13;
	ss['n']=14;
	ss['o']=15;
	ss['p']=16;
	ss['q']=17;
	ss['r']=18;
	ss['s']=19;
	ss['t']=20;
	ss['u']=21;
	ss['v']=22;
	ss['w']=23;
	ss['x']=24;
	ss['y']=25;
	ss['z']=26;

	
	string s,t;
	
	int sm=30,tm=0;
	int sn=0,tn=0;
	
	cin >> s >> t;
	
	if(s==t){
	 cout<<"No";
	}
	else{
		while(1){
		int sm=30,tm=0;
		for(int i=0,n=s.size();i<n;i++){
			if(sm>ss[s[i]]){
				sm=ss[s[i]];
				sn=i;
			}
		}
		for(int i=0,n=t.size();i<n;i++){
			if(tm<ss[t[i]]){
				tm=ss[t[i]];
				tn=i;
			}
		}
		
		if(sm<tm){
			cout<<"Yes";
			break;
		}
			
		else if(sm>tm){
			cout<<"No";
			break;
		}
		else{
		if(s.size()==1&&t.size()>1){
			cout<<"Yes";
			break;
		}
			
		if(s.size()>1&&t.size()==1){
			cout<<"No";
			break;
		}
			
			
		s.erase(s.begin()+sn);
		t.erase(t.begin()+tn);

			
			}
		}
		
	}
	
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int y, m, d, year[] = { 1989, 1926, 1912, 1868 };
string s, table[] = { "heisei", "showa", "taisho", "meiji", "pre-meiji" };

int main(){
	while (cin >> y >> m >> d){
		if (y > 1989){
			s = table[0];
		}
		else if (y == 1989){
			if (m > 1){
				s = table[0];
			}
			else{
				if (d >= 8){
					s = table[0];
				}
				else{
					s = table[1];
				}
			}
		}
		else if (y > 1926){
			s = table[1];
		}
		else if (y == 1926){
			if (m == 12){
				if (d >= 25){
					s = table[1];
				}
				else{
					s = table[2];
				}
			}
			else{
				s = table[2];
			}
		}
		else if (y > 1912){
			s = table[2];
		}
		else if (y == 1912){
			if (m > 7){
				s = table[2];
			}
			else if(m==7){
				if (d >= 30){
					s = table[2];
				}
				else s = table[3];
			}
			else s = table[3];
		}
		else if (y > 1868){
			s = table[3];
		}
		else if (y == 1868){
			if (m > 9){
				s = table[3];
			}
			else if (m == 9){
				if (d >= 8)s = table[3];
				else s = table[4];
			}
			else s = table[4];
		}
		else s = table[4];
		REP(i, 4){
			if (s == table[i]){
				y -= year[i];
				y++;
			}
		}
		if (s == table[4]) cout << s << endl;
		else cout << s << " " << y << " " << m << " " << d << endl;
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

vll ans;

void dfs(ll a) {
  if(a>=100000000000) return;
  ans.push_back(a);
  ll b = a%10;
  if(b-1>=0) dfs(10*a+(b-1));
  if(b+1<=9) dfs(10*a+(b+1));
  dfs(10*a+b);
}

int main() {
  ll k;
  cin >> k;
  for(ll i = 1; i <= 9; i++) {
    ll n = i;
    dfs(n);
  }
  sort(ans.begin(),ans.end());
  cout << ans[k-1] << endl;
  return 0;
}

Measured memory_bytes: 10476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else
		cout << "ARC" << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for( int i = 1; i <= n; ++i ) {
        if( i % 2 == 0 ) continue;
        int t = 0;
        for( int j = 1; j <= i; ++j ) 
            if( i % j == 0 ) ++t;
        if( t == 8 ) ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	char c; cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel";
	}
	else { cout << "consonant"; }
	return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    H, W, K = map(int, input().split())
    sh, sw, gh, gw = map(int, input().split())
    sh -= 1
    sw -= 1
    gh -= 1
    gw -= 1
    seen = [[1] * W for _ in range(H)]
    for h in range(H):
        line = input().rstrip('\n')
        for w in range(W):
            if line[w] == "@":
                seen[h][w] = 2

    #d = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    que = deque()
    que.append((sh, sw))
    seen_d = [[[0] * W for _ in range(H)] for _ in range(4)]
    seen[sh][sw] = 0
    while que:
        h, w = que.popleft()
        for id in range(4):
            dh, dw = d[id]
            h_new = h
            w_new = w
            for _ in range(K):
                flg = 1
                flggg = 0
                h_new += dh
                w_new += dw
                if 0 <= h_new < H and 0 <= w_new < W:
                    if seen[h_new][w_new] == 1:
                        seen[h_new][w_new] = seen[h][w] - 1
                        seen_d[id][h_new][w_new] = 1
                        que.append((h_new, w_new))
                        flg = 0
                    elif seen[h_new][w_new] <= 0:
                        if seen_d[id][h_new][w_new] == 0:
                            if seen[h_new][w_new] != seen[h][w]:
                                seen_d[id][h_new][w_new] = 1
                                flg = 0
                if flg:
                    break
    if seen[gh][gw] < 0:
        print(-seen[gh][gw])
    else:
        print(-1)
    #[print(seen[h]) for h in range(H)]


if __name__ == '__main__':
    main()


Measured memory_bytes: 127256
h, w, k = map(int, input().split())
cake = [[0 for _ in range(w)] for _ in range(h)]
cnt = 0
flg = True
for i in range(h):
  s = input()
  if '#' not in s:
    continue
  rowflg = True
  for j in range(w):
    if s[j] == '#':
      cnt += 1
      rowflg = False
    if rowflg:
      cake[i][j] = cnt+1
    else:
      cake[i][j] = cnt

for i in range(1, h):
  if cake[i][0] == 0:
    for j in range(w):
      cake[i][j] = cake[i-1][j]

for i in range(h-1)[::-1]:
  if cake[i][0] == 0:
    for j in range(w):
      cake[i][j] = cake[i+1][j]

      
for row in cake:
  print(' '.join(map(str, row)))


Measured memory_bytes: 7156
s = input()
t = input()

dp = [[0]*(1+len(s)) for i in range(1+len(t))]

for i in range(1, 1+len(t)):
    for j in range(1, 1+len(s)):
        if s[j-1] == t[i-1]:
            dp[i][j] = 1+dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i = len(t)
j = len(s)
st = ""

while dp[i][j] != 0:
    if s[j-1] == t[i-1]:
        st += s[j-1]
        i -= 1
        j -= 1
    else:
        if dp[i][j-1] > dp[i-1][j]:
            j -= 1
        else:
            i -= 1
            
print(st[::-1])

Measured memory_bytes: 112220
#include <cstdio>
char s[10000];

int main()
{
	int n, k; scanf("%d%d%s", &n, &k, s);
	// reverse & concat
	for (int i = 0; i < n; ++i)
		s[n + i] = s[n - i - 1];
	// find min suffix
	int min = 0;
	for (int tmp = 1; tmp < n; ++tmp)
		for (int i = 0; i < n; ++i)
			if (s[min + i] != s[tmp + i])
			{
				if (s[min + i] > s[tmp + i])
					min = tmp;
				break;
			}
	char *str = &s[min];
	// find prefix length of <str[0]>
	int len = 1;
	while (len < n)
		if (str[len] == str[0])
			++len;
		else 
			break;
	// double the length for each k
	int max = len;
	while (--k)
	{
		max *= 2;
		if (max > n)
		{
			max = n;
			break;
		}
	}
	// print answer
	for (int i = 0; i < max; ++i)
		printf("%c", str[0]);
	for (int i = max; i < n; ++i)
		printf("%c", str[len + i - max]);
	printf("\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 1000001
using namespace std;
int f[N],G[N],n,m,sum;
int find(int k)
{
    if(k!=f[k]) f[k]=find(f[k]);
    return f[k];
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) f[i]=i;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        x=find(x);
        y=find(y);
        if(x!=y) f[x]=y;
    }
    for(int i=1;i<=n;i++){
    	G[find(i)]=1;
	}
	for(int i=1;i<=n;i++){
		sum+=G[i];
	}
	cout<<sum-1;
    return 0;
}

Measured memory_bytes: 4404