akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 1e5 + 100;
int a[N];
    
int n;
/*
map <pair <int, int>, int> dp;

// 1 - Win, 0 - Lose
int solve(int x, int y)
{
    if (a[x] <= y)
        return 1;
    if (dp.count(make_pair(x, y)))
        return 1;
    int ans = 0;
    if (abs(x - y) == 0)
    {
        if (!solve(x + 1, y) || !solve(x, y + 1))
            ans = 1;
    }
    else if (y == x + 1)
    {
        if (!solve(x + 1, y))
            ans = 1;
        else if (a[x + 1] <= y + 1 && (a[x] - y) % 2 == 0)
            ans = 1;
    }
    else if (y + 1 == x)
    {
        if (!solve(x, y + 1))
            ans = 1;
        else if (a[x + 1] <= y + 1)
        {
            int ptr = x;
            while (a[ptr] > y)
                ptr++;
            if ((ptr - x) % 2 == 0)
                ans = 1;
        }
    }
    dp[make_pair(x, y)] = ans;
    return ans;
}
*/


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    reverse(a, a + n);

//    int ans = solve(0, 0);

    int ans = 0;
    
    for (int t = 0; t < 2; t++)
    {
        int x = t;
        int y = t ^ 1;

        while (a[x] > y)
        {
            x++;
            y++;
        }
        x--;
        y--;
        if (x >= 0 && y >= 0)
        {
            ans = 1;
            if ((a[x] - y) % 2 == 0)
                ans = 0;
            int ptr = x;
            while (a[ptr] > y)
                ptr++;
            if ((ptr - x) % 2 == 0)
                ans = 0;
        }

        if (ans)
            break;
    }
    
    
    printf(ans ? "First\n" : "Second\n");



	return 0;
}




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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,n,s1=0,s2=0,t;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>t;
		if (t%4==0){
			s1++;
		}
		else if (t%2==0){
			s2++;
		}
	}
	if (s2>0){
		if (s1>=n-s1-s2){
			cout<<"Yes";
		}
		else {
			cout<<"No";
		}
	}
	else {
		if (2*s1>=n-1){
			cout<<"Yes";
		}
		else {
			cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ds = [int(input()) for i in range(N)]

max_d = 101
c = 0
answer = []

while len(ds) > 0:
  max_ds = max(ds)
  max_d = max_ds
  c+=1
  ds = [d for d in ds if d != max_ds]

print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  set<int> kind;
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c) cout << "Yes" << endl;
  else if(a+c==b) cout << "Yes" << endl;
  else if(c+b==a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
int a[maxn] , n;
ll b[maxn];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen(taskname".INP", "r",stdin);
	//freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    for(int i = 1 ; i <= n ; ++i)a[i] -= i;
    sort(a + 1 , a + n + 1);
    for(int i = 1 ; i <= n ; ++i)
        b[i] = b[i - 1] + a[i];
    ll res = LLONG_MAX;
    for(int i = 1 ; i <= n ; ++i)
    {
        ll cal = -b[i] + 1ll * i * a[i] + (b[n] - b[i]) - 1ll * a[i] * (n - i);
        res = min(res , cal);
    }
    cout << res;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

void insertion (vector<int> &a, int n) {
    for (int i = 1; i < n; i++) {
        int v = a[i], j = i - 1;
        while (a[j] > v && j >= 0) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        rep (k, n) {
            if (k) cout << " ";
            cout << a[k];
        }
        cout << "\n";
    }
    return;
}

int main() {
    int n;
    cin >> n;
    vector<int> vec (n);
    rep (i, n) cin >> vec[i];
    rep (k, n) {
        if (k) cout << " ";
        cout << vec[k];
    }
    cout << "\n";
    insertion (vec, n);
}


Measured memory_bytes: 3100
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n = int(input())
a = list(map(int, input().split()))

d = {}
for i in range(n):
    if a[i] not in d:
        d[a[i]] = 1
    else:
        d[a[i]] += 1

m = sum([k*v for (k,v) in d.items()])

q = int(input())

for i in range(q):
    b, c = list(map(int, input().split()))

    if b in d:
        m += (c - b)*d[b]

        if c not in d:
            d[c] = d[b]
        else:
            d[c] += d[b]

        d[b] = 0

    print(m)




Measured memory_bytes: 21148
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	bool prime[1000001];
	prime[1] = true;
	for(int i = 2; i * i <= 1000000; i++){
		if(!prime[i]){
			for(int j = i * i; j <= 1000000; j += i){
				prime[j] = true;
			}
		}
	}
	int n,w;
	while(cin >> n >> w){
		if(n == 0 && w == 0) break;
		bool dp[1000001] = {0};
		int data[31];
		for(int i = 0; i < n; i++){
			cin >> data[i];
		}
		dp[0] = true;
		for(int i = 0; i < n; i++){
			for(int j = data[i]; j <= w; j++){
				if(dp[j - data[i]]){
					dp[j] = true;
				}
			}
		}
		int ans = -1;
		for(int i = w; i >= 2; i--){
			if(!prime[i] && dp[i]){
				ans = i;
				break;
			}
		}
		if(ans == -1)puts("NA");
		else printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
  int N;
  int counter = 0;
  cin >> N;
  
  for(int i=0; i<N; i++){
    int l,r;
    cin >> l >> r;
    
    if(l == r){
      counter++;
    }else{
      counter += (r - l + 1);
    }
  }
  
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 13

long long modpow(long long a, long long b){ 
  long long r = 1LL;
  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r%MOD;
}

ll dp[100100][14];

int main(){
  string s;
  cin>>s;
  ll l = s.sz;
  clr(dp,0);
  dp[0][0] = 1;
  rep(i,0,s.sz){
    rep(j,0,13){
      if(s[i]=='?'){
        rep(k,0,10){
          ll n1 = k;
          ll n2 = n1 * modpow(10,l-i-1);
          dp[i+1][(j+n2)%MOD]+=dp[i][j];
          dp[i+1][(j+n2)%MOD]%=1000000007;
        }
      }
      else{
        ll n1 = s[i]-'0';
        ll n2 = n1 * modpow(10,l-i-1);
        dp[i+1][(j+n2)%MOD]+=dp[i][j];
        dp[i+1][(j+n2)%MOD]%=1000000007;
      }
    }
  }
  cout << dp[l][5] << endl;
  return 0;
}

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

int main() {
	long long X, K, D;
	cin >> X >> K >> D;
	if (X < 0) X *= -1;

	long long cnt = X/D;
	if (cnt >= K) {
		cout << X-K*D << endl;
	} else { // cnt < K
		if ((K-cnt)%2 == 0) {
			cout << X-cnt*D << endl;
		} else { // (K-cnt)%2 == 1
			cout << -(X-(cnt+1)*D) << endl;
		}
	}
}

Measured memory_bytes: 3624
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

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

bool solve() {
  int n, k;
  if (scanf("%d%d", &n, &k) != 2) { return false; }

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

  set<int> items;
  int incrs = 0;
  for (int i = 0; i < k; ++i) {
    items.insert(a[i]);
    if (i && a[i - 1] < a[i]) {
      incrs++;
    }
  }
  dbg("0..%d\n", k - 1);
  int ans = 1;
  bool was_sorted = false;
  for (int i = k; i < n; ++i) {
    was_sorted |= (incrs == k - 1);
    items.erase(a[i - k]);
    if (a[i - k] < a[i - k + 1]) {
      --incrs;
    }

    bool good = (!(a[i - k] < *items.begin() && *items.rbegin() < a[i]));
    items.insert(a[i]);
    if (a[i - 1] < a[i]) {
      incrs++;
    }
  
    if (good && !(was_sorted && incrs == k - 1)) {
      dbg("%d..%d\n", i - k + 1, i);
      ++ans;
    }
}
  printf("%d\n", ans);

  return true;
}

int main() {
  int tt = -1;
  //scanf("%d", &tt);
  while (tt-- && solve());
  return 0;
}


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

int main() {
	int	N;
	cin >> N;
	vector<P> vec(N);
	rep(i, N)
		cin >> vec.at(i).first >> vec.at(i).second;
	sort(vec.begin(), vec.end());
	rep(i, N)
		cout << vec.at(i).first << ' ' << vec.at(i).second << endl;
}



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

using namespace std;

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

    int T = 0, X = 0, Y = 0;
    for (int i = 0; i < n; ++i) {
        int t, x, y;
        cin >> t >> x >> y;

        int tt = t - T, xx = x - X, yy = y - Y;
        if ((abs(xx) + abs(yy) > tt) ||
            ((abs(xx) + abs(yy) + tt) % 2 != 0)) {
            cout << "No" << endl;
            return 0;
        }
        T = t, X = x, Y = y;
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for _ in range(M):
    x,y,c=map(int,input().split())
    ans=min(ans, a[x-1]+b[y-1]-c)

print(ans)

Measured memory_bytes: 18736
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    static Set<String> ODD = new HashSet<>();
    static Set<String> EVE = new HashSet<>();
    static {
        ODD.add("R");
        ODD.add("U");
        ODD.add("D");
        EVE.add("L");
        EVE.add("U");
        EVE.add("D");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        char[] tap = N.toCharArray();

        boolean isGood = true;
        for (int i = 0; i < N.length(); i++) {
            if ((i + 1) % 2 == 0) {
                if (!isMatch(EVE, tap[i])) {
                    isGood = false;
                    break;
                }
            } else {
                if (!isMatch(ODD, tap[i])) {
                    isGood = false;
                    break;
                }
            }
        }

        System.out.println(isGood ? "Yes" : "No");
    }

    private static boolean isMatch(Set<String> set, char c) {
        return set.contains(String.valueOf(c));
    }
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    string N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < 4; i++) {
        if(N[i] == '2') ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	char s[4];
	scanf("%s", s);
	if (*(unsigned int*)s == *(unsigned int*)"AAA" || *(unsigned int*)s == *(unsigned int*)"BBB")
	{
		puts("No");
	}
	else
	{
		puts("Yes");
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin,(x).end()
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define fastCin ios::sync_with_stdio(false)
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const db pi=acos(-1);
const int mod=1e9+7;
const int maxn=100+10;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll quickpow(ll x,ll k) //x^k
{
	ll ans=1;
	while (k)
	{
		if (k&1) ans=ans*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return ans;
}

int x,n;
int a[maxn];
bool bo[maxn];
int ans=500,ansi=500;
int main()
{
	fastCin;
	cin>>x>>n;
	rep(i,1,n) cin>>a[i],bo[a[i]]=1;
	rep(i,0,101)
		if (!bo[i])
			if (abs(x-i)<ansi) ans=i,ansi=abs(x-i);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
    int h,w,i,j,k;
    char s[110][110];
    int flag,count;

    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++){
	scanf("%s",s[i]);
    }

    for(i=0;i<h;i++){
	flag=0;
	for(j=0;j<w;j++){
	    if(j) printf(" ");

	    if(s[i][j]=='c'){
		flag=1;
		count=0;
	    }
	    if(!flag) printf("-1");
	    else{
	        printf("%d",count);
		count++;
	    }
	}
	printf("\n");
    }
	    

    return 0;
}

Measured memory_bytes: 616
s=input()
i=1
new=[s[0]]
while i<len(s):
    if s[i]=="C" and s[i-1] == "B":
        new.pop()
        new.append("K")
    else:
        new.append(s[i])
    i+=1

cnt=0
ans=0
for i in range(len(new)-1,-1,-1):
    if new[i]=="A" and cnt > 0:
        ans+=cnt
    elif new[i]=="K":
        cnt+=1
    else:
        cnt=0
    
print(ans)

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

int main(){
  int N; string S; cin >> N >> S;
  int m=0, result=0;
  for(int i=0; i<N; i++){
    if(S[i]=='I'){
      result++;
    }else{
      result--;
    }
    m=max(m,result);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
S = input()
s = list(S)
p = []
q = []
for i in range(int((len(s)-1)/2)):
    p.append(s[i])
for i in range(int((len(s)-1)/2)):
    q.append(s[len(s)-1-i])
def abc(k):
    x = 1
    for i in range(int((len(s)-1)/2)):
        if k[i] == k[len(k)-i-1]:
            x = x*1
        else:
            x = x*0
    if x == 1:
        return 1
    else:
        return 0
if abc(p) == 1 and abc(q) ==1 and abc(s) == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    std::deque<int> deq;
    for (int i=1;i<=100;i++) {
        if (a%i==0&&b%i==0) {
            deq.emplace_back(i);
        }
    }
    sort(deq.begin(),deq.end(),greater<int>());
    cout<<deq[k-1]<<endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush, heapify
k = int(input())
def next_num(n):
  if n == 0:
    return [0, 1]
  elif n == 9:
    return [8, 9]
  else:
    return [n-1, n, n+1]
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9]
heapify(queue)
for _ in range(k-1):
  now = heappop(queue)
  for next_i in next_num(now%10):
    heappush(queue, now*10 + next_i)
    
print(heappop(queue))

Measured memory_bytes: 19428
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const double EPS=1e-10;
const ll INF=1000000000;
const ll MAX=100010;
int prime[300010];
int main(){
        for(int i=0;i<300001;i++){
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(int i=2;i<=200000;i++){
        if(prime[i]==1){
            for(int j=i+i;j<=300000;j+=i){
                prime[j]=0;
            }
        }
    }
    vector<int> v;
    for(int i=0;i<=300000;i++){
        if(prime[i]){
            v.push_back(i);
        }
    }
    int n,p;
    while(cin>>n>>p,n+p>=0){
        int f=upper_bound(all(v),n)-v.begin();
        vector<int> ans;
        for(int i=0;i<=p;i++){
            for(int j=i;j<=p;j++){
                ans.push_back(v[f+i]+v[f+j]);
            }
        }
        sort(all(ans));
        cout<<ans[p-1]<<endl;
    }
}



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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    double P,A,Q,B,R;
    cin >> A >> B >> P >> Q >> R;
    cout << fixed << setprecision(10) << (R*B+Q*A+P*B)/(R+Q) << endl;
    //cin >> P;
}


Measured memory_bytes: 3276
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*d,a*c),max(b*c,b*d))<<endl;

    return 0;
}



Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>=13){
		printf("%d\n",b);
	}
	else if(6<=a && a<=12){
		printf("%d\n",b/2);
	}
	else{
		printf("%d\n",0);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
   	int num = sc.nextInt();
    int ans = 0;
    
    ans = 1000*(num/500);
    num %= 500;
    ans += num - num%5;
    
    System.out.println(ans);

  }
}


Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
 
int main(){
	string s;
	ll k;
	cin >> s >> k;

	ll len = 0;

	while(1){
		ll num = s[len] - '0';
		if(num > 1){
			k -= pow(num, 5000000000000000);
		}else{
			k -= 1;
		}

		if(k <= 0){
			cout << s[len] << endl;
			return 0;
		}
		len++;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define mod 1000000007LL
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res + m) * ( a + m) % m;
        a = a * a % m;
        b >>= 1;
    }
    return (res + m) % m;
}

long long mul(long long a, long long b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return ((a + mod) * (b + mod))%mod;
}
long long add(long long a, long long b){
    a += mod;
    b += mod;
    return (a + b)%mod;
}
ll inv(ll x){
    return binpow(x, mod - 2, mod);
}
#define int ll
ll cnt(string &a, string & b)
{
    ll ans = 0;
    for (ll i = 0; i < a.length();i++)
        ans += (a[i] != b[i]);
    return ans;
}
signed main()
{
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n;i++)
        cin >> a[i];
    ll b[n];
    b[n - 1] = a[n - 1];
    for (ll i = n - 2; i >= 0;i--)
    {
        b[i] = add(b[i + 1], a[i]);
    }
    ll sum = 0;
    for (ll i = 0; i < n - 1;i++)
    {
        sum += mul(a[i], b[i + 1]);
        sum %= mod;
    }
    cout<<sum;
}

Measured memory_bytes: 6740
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
#define Rep(i,s,n) for(int i=(s);i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int n;
    cin >>n;
    string s;
    cin >>s;
    int ans=0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3620
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    xy = [list(map(int, input().split())) for _ in range(n)]

    sum = 0

    for i in range(n - 1):
        for j in range(i + 1, n):
            xi, yi = xy[i]
            xj, yj = xy[j]
            sum += ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5

    print(2 * sum / (n * (n - 1)) * (n - 1))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

template<class T> struct Fenwick {
    vector<T> bit; int N;
    Fenwick(int n) : N(n) { bit.assign(n+1, 0); }
    // add w to a
    void add(int a, T w) {
        for (int x = ++a; x <= N; x += x & -x) bit[x] += w;
    }
    // sum [0, a)
    T sum(int a) {
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
    // sum [a, b)
    T sum(int a, int b) { return sum(b) - sum(a); }
};

long long solve(vector<pair<long long, long long>> &v, int n, int d, int a) {
    set<long long> st; map<long long, int> compress;
    for (int i = 0; i < n; i++) {
        long long x = v[i].first;
        st.insert(x); st.insert(x+2*d+1);
    }
    for (auto &x: st) {
        int t = compress.size();
        compress[x] = t;
    }
    int sz = compress.size();
    Fenwick<long long> f(sz);
    sort(v.begin(), v.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long diff = f.sum(compress[v[i].first]+1);
        long long remain = v[i].second - diff;
        if (remain <= 0) continue;
        long long req = (remain + a - 1) / a;
        ans += req;
        f.add(compress[v[i].first], req * a);
        f.add(compress[v[i].first+2*d+1], -req * a);
    }
    return ans;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; long long d, a; cin >> n >> d >> a;
    vector<pair<long long, long long>> v, w;
    for (int i = 0; i < n; i++) {
        long long x, h; cin >> x >> h;
        v.emplace_back(x, h);
        w.emplace_back(-x, h);
    }
    long long ret = 1e17;
    ret = min(ret, solve(v, n, d, a));
    ret = min(ret, solve(w, n, d, a));
    cout << ret << "\n";
    return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool poor = false;
  if (A==B&&A!=C||B==C&&A!=B||C==A&&A!=B) poor = true;
  if (poor) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  string S, T;
  int s, count;
  
  cin >> S >> T;
  
  s = S.size();
  count = 0;
  
  for(int i = 0; i < s; i++){
    if(S.at(i) == T.at(i)){
      count++;
    }
  }
  
  //cout << count << endl;
  
  if(count == s){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
  
      
  
  
}

Measured memory_bytes: 3600
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N + 1);

    REP(i, N) { cin >> x[i]; }
    x[N] = X;
    sort(x.begin(), x.end());

    ll tmp = x[0];
    REP(i, N + 1) { x[i] -= tmp; }
    x.erase(x.begin());

    debug(x);
    if (x.size() == 1) {
        cout << x[0] << endl;
        return 0;
    } else {
        ll res = GCD(x[0], x[1]);
        FOR(i, 2, N) {
            res = GCD(res, x[i]);
            debug(i, x[i], res);
        }
        cout << res << endl;
        return 0;
    }
}


Measured memory_bytes: 1024
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
GCD= a[0]
dp = [set() for i in range(n)]
dp[1].add(a[0])
dp[1].add(a[1])
for i in range(1,n):
    x = a[i]
    for j in dp[i-1]:
            dp[i].add(gcd(j,x))
    if x % GCD != 0:
        dp[i].add(GCD)
        GCD = gcd(GCD,x)
print(max(dp[n-1]))

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

int main() {
  int n;
  cin >> n;
  if (1 <= n && n <= 9)
    cout << n << endl;
  else if (10 <= n && n <= 99)
    cout << 9 << endl;
  else if (100 <= n && n <= 999)
    cout << n - 90 << endl;
  else if (1000 <= n && n <= 9999)
    cout << 909 << endl;
  else if (10000 <= n && n <= 99999)
    cout << n - 9090 << endl;
  else
    cout << 90909 << endl;
  return 0;
}

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

using namespace std;

void Main() {
    long long N, A, B;
    cin >> N >> A >> B;
    vector<long long> h(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    long long lb = 0;
    long long ub = h.back() / B + 1;
    while (ub - lb > 1) {
        long long mid = (ub + lb) / 2;
        auto u = upper_bound(h.begin(), h.end(), mid * B);
        long long numDirect = 0;
        for (; u < h.end(); ++u) {
            numDirect += ((*u) - mid * B) / (A - B);
            if (((*u) - mid * B) % (A - B) > 0) {
                ++numDirect;
            }
        }
        if (numDirect <= mid) {
            ub = mid;
        }
        else {
            lb = mid;
        }
    }
    cout << ub << endl;
}

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


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
int n,a[100010],cnt,maxn=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)	
		cin>>a[i];
	for(int i=n-1;i>=1;i--){
		if(a[i]>=a[i+1])
			cnt++;
		else{
			maxn=max(maxn,cnt);
			cnt=0;
		}
	}
	if(maxn==0)
		maxn=cnt;
	cout<<maxn;
	return 0;
}
/*
模拟只会猜题意
贪心只能过样例
数学上来先打表
DP一般看规律
组合数学靠运气
计算几何瞎暴力
图论强行套模板
数论只会GCD
递归递推伤不起
搜索茫然TLE
分治做得像枚举
暴力枚举数第一
数据结构干瞪眼
怒刷水题找信心
涨姿势也不容易
考试一来全懵逼
*/

 

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

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
using ll = long long;
using namespace std;
const int INF = 1001001001;

int main(){
    int n; cin >> n;
    vector<int> a(n + 10, 0), b(n + 10, 0), c(n + 10, 0);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    vector<int> dpA(n +10, 0), dpB(n +10, 0), dpC(n +10, 0);
    rep(i, n){
        int ni = i + 1;
        dpA[ni] = max(dpB[i] + a[i], dpC[i] + a[i]);
        dpB[ni] = max(dpA[i] + b[i], dpC[i] + b[i]);
        dpC[ni] = max(dpA[i] + c[i], dpB[i] + c[i]);
    }
    cout << max(dpA[n], max(dpB[n], dpC[n])) << endl;
}


Measured memory_bytes: 2688
"""

https://atcoder.jp/contests/arc097/tasks/arc097_d

始点と終点関係ある？
→逆にしても問題はない

黒い葉は完全に無視できる(落とせる)
よって、葉はすべて白
葉以外は白黒どっちもあり得る

すべての葉をめぐる最短経路？
ある葉からスタートするのは自明っぽい？
ある白からスタートするのはそう

→自分を塗ってからdfsする
→全方位木dp?

行きのみで帰らない場所が1つ存在するはず
→始点と終点のパスとそこから生える木って感じのイメージ

足踏み(停止)の回数を極力少なくしたい
→始点でも終点でもない場合、 e本の辺がつながってたらe回訪問は確定
　e^colorが黒でない場合は+1
→つまり、各頂点で消費する回数は始点・終点でない限り常に一定？

終点はまず葉→始点も葉でおｋ
始点は足踏みなので1秒つかう　終点も1秒使う
パス上の点は、e-1回訪問(ここが根本的に違う！)

つまり、あるパスがあって　その長さがL(両端除く)の時、最大でL減る
ただし、パス上にあっても回数が減らない点もある

B=0 W=1とするか
(color^E) == 1 の点は、E-1回訪問になると足踏みがいらないから2減る
つまり、そのような点が最大数あるパスを求めればいい

"""

import sys
sys.setrecursionlimit(200000)
from collections import deque

MM = 0

def dfs(v,p):
    global MM

    if v != p and linknum[v] == 1:
        return 0

    cl = []
    for nex in lis[v]:
        if nex != p and exist[nex]:
            tmp = dfs(nex,v)
            cl.append(tmp)
    cl.sort()
    cl.reverse()

    if len(cl) == 1:
        MM = max(MM , cl[0])
    else:
        if (linknum[v]+c[v])%2 == 1:
            MM = max(MM , cl[0] + cl[1] + 2)
        else:
            MM = max(MM , cl[0] + cl[1])

    
    if (linknum[v]+c[v]) % 2 == 1:
        return cl[0]+ 2
    else:
        return cl[0]

N = int(input())

lis =  [ [] for i in range(N) ]
linknum = [0] * N
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1

    lis[u].append(v)
    lis[v].append(u)
    linknum[u] += 1
    linknum[v] += 1

ctmp = input()
c = []

for i in ctmp:
    if i == "B":
        c.append(0)
    else:
        c.append(1)

exist = [True] * N

q = deque([])
for i in range(N):
    if linknum[i] <= 1 and c[i] == 0:
        q.append(i)

while len(q) > 0:
    now = q.popleft()
    exist[now] = False
    linknum[now] = 0
    
    for nex in lis[now]:
        linknum[nex] -= 1

        if linknum[nex] == 1 and c[nex] == 0:
            q.append(nex)

#print (exist)
start = None
for i in range(N):
    if exist[i]:
        start = i
        break
else:
    print (0)
    sys.exit()

if linknum[start] == 0:
    print (1)
    sys.exit()

ans = 0
#print (linknum)
for i in range(N):
    if exist[i]:

        if (linknum[i] + c[i]) % 2 == 0:
            ans += linknum[i]
        else:
            ans += linknum[i] + 1

MM = 0
pick = dfs(start,start)
print (ans - MM)


Measured memory_bytes: 113284
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

map<string,bool> cnt;
int main(){
  IOS();
  int n;
  cin>>n;
  string pre,now;
  bool ok = true;
  REP(i,n){
    debug(ok);
    cin>>now;
    if( cnt[now] ) ok=false;
    cnt[now] = true;
    if( i==0 ){
      pre = now;
      continue;
    }
    debug(pre,now);
    if( pre[SZ(pre)-1]!=now[0] ) ok=false;
    pre = now;
  }
  cout<<(ok ?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K){
  cout<<min(N%K,abs(N%K-K))<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
  
using namespace std;
 
int main(){
  int h,a;
  cin >> h >> a;
  int t = 0;
  
   while(h > 0){
 
     h = h - a;
     t++;
  
   }
  
   cout << t << endl;
  
}

Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int k = fs.nextInt();
        final int[] arr = new int[n + k];
        for (int i = 0; i < n; i++) {
            arr[i] = fs.nextInt();
        }
        final int[] dp = new int[n + k];
        Arrays.fill(dp, (int) 1e9);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= k; j++) {
                final int arrIdx = Math.min(i + j, n - 1);
                dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(arr[arrIdx] - arr[i]));
            }
        }
        System.out.println(dp[n - 1]);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 44304
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int D = sc.nextInt();
    int i = sc.nextInt();
    int box = 0;
    
    for(int j= 0;j < 10;j++){
      box = (r * i) - D;
      System.out.println(box);
      i = box;
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<cstdio>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

double p(int n) {
	double re = 1;
	FOR(n)
		re /= 2;
	return re;
}

int c(int n, int k) {
	int co = 0;
	while (n < k) {
		co++;	n *= 2;
	}
	return co;
}

int main() {
	int n, k;
	double d = 0;
	cin >> n >> k;
	FORR(1,n+1) {
		d += (1.0/n) * p(c(i, k));
	}
	printf("%.9lf\n", d);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = int(input())
d = 0
k = 1
while k*k <= n-s:
  if (n-s)%k > 0:
    k += 1
    continue
  l = (n-s)//k
  if (l+1)*(l+1) > n:
    b = l+1
    if n//b + n%b == s:
      d = b
  b = k+1
  a = 0
  r = n
  while r > 0:
    a += r%b
    r = r//b
  if a == s:
    print(b)
    exit()
  k += 1
if n == s:
  print(n+1)
elif d>0:
  print(d)
else:
  print(-1)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        StringTokenizer st=new StringTokenizer(br.readLine());
        int[] a=new int[2*n];
        for(int i=0;i<2*n;i++){ a[i]=Integer.parseInt(st.nextToken()); }
        Arrays.parallelSort(a);
        int sum=0;
        for(int i=0;i<2*n;i+=2){ sum+=Math.min(a[i],a[i+1]); }
        System.out.println(sum);
    }
}

Measured memory_bytes: 8400
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	string S;
	cin >> S;
	vector< int > dp(N + 1, 0);
	dp[B] = 1;
	for (int i = 2; i <= N; i++) {
		if (S[i - 1] == '#')
			continue;
		dp[i] |= dp[i - 1] | dp[i - 2];
	}
	if (dp[D] == 0) {
		cout << "No" << endl;
		return 0;
	}
	if (C > D) {
		int tmp = 0;
		bool f = false;
		for (int i = B - 1; i <= D + 1; i++) {
			if (S[i - 1] == '.')
				++tmp;
			else
				tmp = 0;
			if (tmp >= 3)
				f = true;
		}
		if (!f) {
			cout << "No" << endl;
			return 0;
		}
	}
	dp.assign(N + 1, 0);
	dp[A] = 1;
	for (int i = 2; i <= N; i++) {
		if (S[i - 1] == '#')
			continue;
		dp[i] |= dp[i - 1] | dp[i - 2];
	}
	if (dp[C] == 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	//cout << dp;
	return 0;
}

Measured memory_bytes: 2052
// https://atcoder.jp/contests/abc126/tasks/abc126_a
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int N, K;
  string S;
  cin >> N >> K >> S;
  K = K - 1;

  if (S[K] == 'A')
    S[K] = 'a';
  else if (S[K] == 'B')
    S[K] = 'b';
  else if (S[K] == 'C')
    S[K] = 'c';

  cout << S << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;



int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);

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

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

    
    for (int i=0; i<N-M+1; i++) {
        for (int j=0; j<N-M+1; j++) {

            int flag=0;
            int breakflag=0;
            for (int k=0; k<M; k++) {
                for (int l=0; l<M; l++) {
                    if (B[k][l] != A[i+k][j+l]) {
                        flag=1;
                        breakflag=1;
                        break;
                    }
                }

                if (breakflag == 1) break;
            }

            if (flag==0) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

}

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

int main(void)
{
    long long int a,b,c,i,j,k,n;
    char s[4];
    cin >> s[0];
    for(i=1;i<4;i++){
        cin >> s[i];
        if(s[i]==s[i-1]) break;
    }

    if(i==4) cout << "Good";
    else cout << "Bad";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(int argc, char const *argv[])
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = k; i < n; ++i)
	{
		if (a[i] > a[i - k])
			cout << "Yes" << '\n';
		else
			cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
vector<vector<int>> arr(1000001);
vector<ll int> dp(1000000);
void build_sieve()
{
	for (int c = 2; c <= 1000000; c++)
	{
		if (arr[c].size() != 0)
			continue;
		for (int c1 = c; c1 <= 1000000; c1 += c)
			arr[c1].push_back(c);
	}
}
void solve()
{
	int n;
	cin >> n;
	ll ans = 0;
	for (int c = 1; c <= n - 1; c++)
	{
		ans += dp[n - c];
	}
	cout << ans << endl;
	return;
}
int main()
{
	build_sieve();
	for (int c = 2; c <= 1000000; c++)
	{
		ll ans = 1;
		int a = c;
		for (int c1 = 0; c1 < arr[c].size(); c1++)
		{
			int temp = 0;
			while (a % arr[c][c1] == 0)
				temp++, a /= arr[c][c1];
			ans *= (temp + 1);
		}
		if (a != 1)
			ans *= 2;
		dp[c] = ans;
	}
	dp[1] = 1;
	int t;
	t = 1;
	for (int c = 0; c < t; c++)
		solve();
}

Measured memory_bytes: 66208