akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
vector<char> c;
int main()
{
   ll a,b,k;
   cin>>a>>b>>k;
   for(int i=0;i<k;i++)
   {
        if(i%2==0)
        {
            if(a%2!=0)a--;
            int x=a/2;
            b=b+x;
            a=a-x;

        }else
        {
            if(b%2!=0)b--;
            int x=b/2;
            a=a+x;
            b=b-x;
        }

   }
   cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
x,n = map(int,input().split())
ls = list(map(int,input().split()))
p = float("inf")
s = 0
if n == 0:
    print(x)
    sys.exit()
for i in range(102):
    if i in ls:
        continue
    k = abs(x-i)
    if k < p:
        p = k
        s = i
print(s)


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

int main()
{
    int n, k;
    cin >> n >> k;
    ll ans = k;
    repl(i, 1, n) ans *= k - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;
struct edge{ int u, v, cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
};

void displayVector(vector<lli> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

vector<lli> argsort(vector<lli> v)
{
	lli n = v.size();
	vector<lli> indices(n);
	REP(i,n){ indices[i] = i; }

	sort(indices.begin(), indices.end(), [&v](lli i1, lli i2) {
        return v[i1] > v[i2];
  });

	return indices;
}


int main(){
	lli n; cin >> n;
	lli out = 1;
	while(1){
		if(n < out*out ){
			cout << (out-1)*(out-1) << endl;
			break;
		}
		out += 1;
	}
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll i,j,k,n,m,l;
    cin>>n;
    string s,p;
    cin>>s;
    p=s;
    ll cnt=0;
    sort(s.begin(),s.end());
    for(i=0;i<n;i++)
    {
        if(p[i]!=s[i])
            cnt++;
    }
    cnt=cnt/2;
    ll r=0,w=0,ans=INT_MAX;
   i=0;
    while(p[i]=='R')
        i++;
    for(j=i;j<n;j++)
        if(p[j]=='R') r++;
    string q=p;
    reverse(q.begin(),q.end());
    i=0;
    while(q[i]=='W')
        i++;
    for(j=i;j<n;j++)
     if(q[j]=='W')
        w++;
     ans=min(ans,cnt);
     ans=min(ans,r);
     ans=min(ans,w);
     cout<<ans<<endl;
}


Measured memory_bytes: 3936
#include <iostream>
#include <vector>
using namespace std;
typedef long long int LLI;

void formula(int arr[], int step, string st_ans, int ans, vector <string> & all)
{
	string tmp1 = st_ans, tmp2 = st_ans;
	if( step < 4 )
	{
		tmp1 += "+";
		tmp1 += (char)(arr[step]+'0');
		formula(arr, step+1, tmp1, ans+arr[step], all);
		
		tmp2 += "-";
		tmp2 += (char)(arr[step]+'0');
		formula(arr, step+1, tmp2, ans-arr[step], all);
	}else{
		if( ans == 7 )
			all.push_back(st_ans+"=7");
	}
}
int main()
{
	vector <string> ans;
	char take;
	int arr[4];
	for(int i = 0; i < 4; i++)
	{
		cin >> take;
		arr[i] = take - '0';
	}
		
	string start = "";
	start += (char)(arr[0]+'0');
	
	formula(arr,1,start,arr[0], ans);
	
	cout << ans[0];
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll K;
    cin >> K;
    auto check = [&](ll X){
        string S = to_string(X);
        int N = S.size();
        //i桁目までで未満フラグj,最後の数字l
        ll dp[N+1][2][10];
        rep(i,N+1)rep(j,2)rep(k,10)
            dp[i][j][k] = 0;
        dp[1][0][S[0]-'0'] = 1;
        rep1(i, S[0]-'0')dp[1][1][i] = 1;
        for(int i = 1; i < N;i++){
            rep1(l, 10)dp[i+1][1][l] += 1;
            rep(j,2)rep(k,10){
                int minn = max(0,k - 1);
                int maxx = min({k+1, (j ? 9:S[i]-'0')});
                for(int x = minn; x <= maxx;x++){
                    dp[i+1][j || x < S[i]-'0'][x] += dp[i][j][k];
                }
            }
        }
        ll cnt = 0;
        rep(j,2)rep(k,10){
            cnt += dp[N][j][k];
        }
        return cnt < K;
    };
    ll ok = 0;
    ll ng = 1e11;
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ng << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	int n,a,b,ans=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		int e=0,c=i;
		while(c>0){	
			e+=c%10;
			c/=10;
		}
		if(e>=a && e<=b){
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	string a;
	cin>>a;
	a[5]=' ';
	a[13]=' ';
	cout<<a;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    int x;
    cin >> x;
    if(x>=30) yes();
    else no();

    
    return 0;
}



Measured memory_bytes: 3636
#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 a,b;
	cin >> a >>b;
	if(a<=5) cout << 0 << endl;
	else if(a >= 13) cout << b << endl;
	else cout << b/2 << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3600
X = int(input())
rate = 0
if X >= 400 and X <= 599:
    rate = 8
elif X >= 600 and X <= 799:
    rate = 7
elif X >= 800 and X <= 999:
    rate = 6
elif X >= 1000 and X <= 1199:
    rate = 5
elif X >= 1200 and X <= 1399:
    rate = 4
elif X >= 1400 and X <= 1599:
    rate = 3
elif X >= 1600 and X <= 1799:
    rate = 2
else:
    rate = 1
    
print(rate)
    

Measured memory_bytes: 61872
#include<stdio.h>

int main(){
    while(1){
        int m,f,r;
        scanf(" %d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        
        if(m==-1||f==-1||m+f<30) printf("F\n");
        else if(m+f>=80) printf("A\n");
        else if(m+f>=65) printf("B\n");
        else if(m+f>=50 || (m+f>=30&&r>=50)) printf("C\n");
        else printf("D\n");
    }
    
    return 0;
}



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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
int main(){
  for(;;){
    int n;
    cin >> n;
    if(!n) { break; }
    string str;
    cin >> str;
    REP(i,n){
      stringstream s;
      int iter = 1;
      char num = str[0];
      for(int j = 1; j < (int)str.size(); j++){
	if(num == str[j]){
	  iter++;
	} else {
	  stringstream tmp;
	  tmp << iter;
	  s << tmp.str() << num;
	  num = str[j];
	  iter = 1;
	}
      }
      stringstream tmp;
      tmp << iter;
      s << tmp.str() << num;
      str = s.str();
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 1380
# 1000000000000001 15
# 素因数分解的な感じで解く 26で解く
n = int(input())
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
            'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']


def base10to(n, b):

    n -= 1
    if (int(n//b)):
        return base10to(int(n//b), b) + alphabet[n % b]
    return alphabet[n % b]


print(base10to(n, 26))


Measured memory_bytes: 9104
import bisect
A, B, Q = map(int,input().split())
s = [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20]
t = [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20]

for _ in range(Q):
    x = int(input())
    S = bisect.bisect_left(s,x)
    T = bisect.bisect_left(t,x)
    print(min(
        max(s[S],t[T])-x,
        x-min(s[S-1],t[T-1]),
        s[S]-x + s[S]-t[T-1],
        t[T]-x + t[T]-s[S-1],
        x-s[S-1] + t[T]-s[S-1],
        x-t[T-1] + s[S]-t[T-1]))


Measured memory_bytes: 12800
#include <cstdio>
using namespace std;

using namespace std;

int main()
{
    char g[7];
    for(int i= 0; i<7; i++){
        scanf("%c", &g[i]);
    }
    
    if(g[0]==g[6] && g[4]==g[2] && g[1]==g[5]){
        printf("YES");
    }
    else{
        printf("NO");
    }
    
    return 0;
}

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


int cmp(const void *p, const void *q) {
  return *(long *)p - *(long *)q;
}

long Abs(long);

int main (void){
	long N,i,j,tmp;
	long b=0;
	long ans=0;
	scanf("%ld",&N);
	long A[N];
	for(i=0;i<N;i++){
		scanf("%ld",&tmp);
		tmp -= (i+1);
		A[i] = tmp;
	}
	qsort(A,N,sizeof(long),cmp);
	b = A[N/2];
	//printf("X = %d\n",X);
	for(i=0;i<N;i++){
		ans += abs( A[i] - b );
	}
	printf("%ld",ans);
	return 0;
}

long Abs(long a) {
  if (a < 0) a *= -1;
  return a;
}

Measured memory_bytes: 3324
package main

import (
	"fmt"
)

func main() {
	var n, k, q int
	fmt.Scan(&n, &k, &q)
	
	parti := make([]int, n)
	
	tmp := 0
	for i := 0; i < q; i++ {
		fmt.Scan(&tmp)
		tmp--
		parti[tmp]++
	}

	for i  := range parti {
      point := k- (q - parti[i])
		if point > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


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

int main(void) {
	int N;
	const int r_val[] = { 1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 5000 };
	const int r_num = 9;
	int rank[r_num];

	for (int i = 0; i < r_num; ++i)
		rank[i] = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		for (int i = 0; i < r_num; ++i) {
			if (r_val[i] <= a && a < r_val[i + 1]) {
				++rank[i];
				break;
			}
		}
	}
	int min_ans = 0;
	for (int i = 0; i < r_num - 1; ++i) {
		if (rank[i] != 0)
			++min_ans;
	}
	int max_ans = min_ans + rank[r_num - 1];
	if (min_ans == 0)
		min_ans = 1;

	cout << min_ans << ' ' << max_ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int X=sc.nextInt();
        int Y=sc.nextInt();
        int[] x=new int[n+1];
        for (int i = 0; i < n; i++) {
            x[i]=sc.nextInt();
        }
        x[n]=X;
        int[] y=new int[m+1];
        for (int i = 0; i < m; i++) {
            y[i]=sc.nextInt();
        }
        y[m]=Y;
        Arrays.sort(x);
        Arrays.sort(y);
        if(x[n]<y[0]){
            out.println("No War");
        }else{
            out.println("War");
        }
    }
    //階乗
static long fact(long a){
    long b=1;
    for (long i = 1; i <= a; i++) {
        b*=i;
    }
    return b;
}
//最大公約数
static int gcd (int a, int b) {
    int temp;
    while((temp = a%b)!=0) {
        a = b;
        b = temp;
    }
    return b;
}
//※最小公倍数はa*b/gcd(a,b)である
//二項係数
static long combi (long a, long b) {
    b=min(a-b,b);
    return permu(a,b)/fact(b);
}
//順列
static long permu(long a,long b){
    long temp=1;
    for (long i =a ; i > a-b; i--) {
        temp*=i;
    }
    return temp;
}
}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ls p<<1
#define rs p<<1|1
const int N=200000+5,mod=998244353;
int tag[N<<2],sum[N<<2],v[N<<2];
int d[N][10];
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=1ll*res*b%mod;
		b=1ll*b*b%mod; n>>=1;
	}
	return res;
}
void pushtag(int p,int l,int r,int val){
	v[p]=val; tag[p]=val; sum[p]=d[r-l+1][val];
}
void pushdown(int p,int l,int r){
	if(tag[p]!=-1){
		int mid=(l+r)>>1;
		pushtag(ls,l,mid,tag[p]);
		pushtag(rs,mid+1,r,tag[p]);
		tag[p]=-1;
	}
}
void pushup(int p,int l,int r){
	int mid=(l+r)>>1;
	sum[p]=sum[ls]*ksm(10,r-mid)%mod+sum[rs];
	sum[p]%=mod;	
}
void build(int p,int l,int r){
	if(l==r) return v[p]=1,sum[p]=1,(void)0;
	int mid=(l+r)>>1;
	tag[p]=-1;
	build(ls,l,mid);
	build(rs,mid+1,r);
	pushup(p,l,r);
}
void upt(int p,int l,int r,int ql,int qr,int val){
//	cout<<l<<" "<<r<<" "<<sum[p]<<" tgr5yrhbe"<<endl;
	if(ql<=l&&r<=qr) return pushtag(p,l,r,val);
	int mid=(l+r)>>1;
	pushdown(p,l,r);
	if(ql<=mid) upt(ls,l,mid,ql,qr,val);
	if(mid+1<=qr) upt(rs,mid+1,r,ql,qr,val);
	pushup(p,l,r);
//	cout<<l<<" "<<r<<" "<<sum[p]<<" "<<sum[ls]<<" "<<sum[rs]<<endl;
}
int query(int p,int l,int r,int pos){
	if(l==r) return v[p];
	pushdown(p,l,r);
	int mid=(l+r)>>1;
	if(pos<=mid) return query(ls,l,mid,pos);
	else return query(rs,mid+1,r,pos);
	pushup(p,l,r);
}
signed main(){
	int n,q,l,r,D;
	memset(v,1,sizeof(v));
	cin>>n>>q;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=9;++j)
			d[i][j]=d[i-1][j]*10ll%mod+j,
			d[i][j]%=mod;
	build(1,1,n);
//	cout<<sum[1]<<endl;
	for(int i=1;i<=q;++i){
		cin>>l>>r>>D;
		upt(1,1,n,l,r,D);
		cout<<sum[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 33696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 100001;
int n, k, q, sc[N];

int main(){
    scanf("%d%d%d", &n,&k,&q);
    while(q--){
        int x; 
        scanf("%d", &x);
        sc[x+1] += -1; // add -1 to playyers form x+1 -> n 
        sc[0] += -1;
        sc[x]++;
    }
    for(int i = 1; i<=n; ++i){
        sc[i] += sc[i-1];
        if(sc[i]+k <= 0)puts("No");
        else puts("Yes");
    }
} 


Measured memory_bytes: 1024
import itertools
import functools
import math
from collections import Counter
from itertools import combinations

def CHK():
    S=list(input())
    Q=int(input())
    H=""
    B=""
    rflg = 0
    for i in range(Q):
        Que = input()
        if Que == '1':
            if rflg == 0:
                rflg = 1
            else:
                rflg = 0
            #S= list(reversed(S))
        else:
            T,F,C=map(str,Que.split())
            if F == '1' and rflg == 0 or (F != '1' and rflg == 1):
                #S=list(C)+S
                H = C + H
            else:
                #S.append(C)
                B = B + C

    S = list(H) + S + list(B)
    if rflg == 1:
        S = list(reversed(S))
    print("".join(S))

CHK()

Measured memory_bytes: 15144
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[365];
set<int>st[26];
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[i]]=i;
		res+=A[i][con[i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[x]];
	auto pre_old=--st[con[x]].lower_bound(x);
	auto next_old=st[con[x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
double rand_double(){
	return (double)rand()/RAND_MAX;
}
signed main(){
	cin>>D;
	rep(i,26){
		cin>>C[i];
		st[i].insert(-1);st[i].insert(D);
	}
	vector<int>last(26,-1);
	rep(i,D){
		int mx=-mod,idx;
		rep(j,26){
			cin>>A[i][j];
			if(chmax(mx,A[i][j]+C[j]*(i-last[j])*4))idx=j;
		}
		con[i]=idx;st[idx].insert(i);
       last[idx]=i;
	}
	int score_=score();
	cerr<<score_<<endl;
	double C=1970*100;
	int cnt=0;
	while(1000.*clock()/CLOCKS_PER_SEC<=1970){
		int x=rand()%D,y;
		do{
			y=rand()%26;
		}while(con[x]==y);
		int diff=change(x,y);
		double ti=1970-1000.*clock()/CLOCKS_PER_SEC;
		double rem=ti/1970.;
		if(diff>=0||ti/C>rand_double()&&diff>=-10000.*rem){
			score_+=diff;
			st[con[x]].erase(x);
			con[x]=y;
			st[y].insert(x);
		}
		cnt++;
		if(cnt%100000==0)cerr<<score_<<endl;
	}
	rep(i,D)cout<<con[i]+1<<"\n";
	cerr<<score_<<endl;
}


Measured memory_bytes: 3724
diff :: Integral a => a -> a -> a
diff n x = (n - x `mod` n) `mod` n

solve :: [(Int,Int)] -> Int
solve = foldr f 0
  where
     f (a,b) acc = acc + diff b (acc + a)

main :: IO ()
main = do
    _ <- getLine
    a <- map ((\[a,b] -> (a,b)) . (map read . words))
        . lines <$> getContents :: IO [(Int,Int)]
    print $ solve a

Measured memory_bytes: 68988
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<vector<int>> v;

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

    vector<vector<int>> v(N, vector<int>());
    vector<int> input(N, 0);
    vector<int> ans(N, 0);

    rep(i, N - 1 + M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        input[b]++;
    }

    stack<int> st;
    rep(i, N) {
        if (input[i] == 0)
            st.push(i);
    }

    while (!st.empty()) {
        int i = st.top();
        st.pop();
        for (int& j : v[i]) {
            input[j]--;
            if (input[j] == 0) {
                st.push(j);
                // printf("ans[%d]=%d\n", j, i + 1);
                ans[j] = i + 1; // node number is index + 1
            }
        }
    }
    rep(i, N) { cout << ans[i] << endl; }

    // rep(i, E) {
    //     printf("%d: [in] %d, [out] ", i, input[i]);
    //     for (auto& j : v[i]) {
    //         printf("->%d,", j);
    //     }
    //     printf("\n");
    // }
    return 0;
}


Measured memory_bytes: 7040
#include<iostream>

using namespace std;

int main (){

  	int a,b,c,d,i;

    cin>>a>>b>>c;

  	for(i=1; i<=10; i++){

    	d=(a*c)-b;
     	cout<<d<<endl;

     	c=d;

    }

 	return 0;

}


Measured memory_bytes: 256
using System;
class Prpgram
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        string[] inputlist = input.Split(' ');
        int N = int.Parse(inputlist[0]);
        int M = int.Parse(inputlist[1]);

        if (N == M)
        {
            Console.Write("Yes");
        }
        else
        {
            Console.Write("No");
        }
    
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <ctype.h>

int main(void){
char s[100];
 int flag=0; 
 int i; 
  scanf("%s",s);
  
  if(s[0]=='A'){
  flag=1;
  }
  for(i=2;i<=8;i++){
  if(s[i]=='C'){
  flag++;
  }
  }
  
  for(i=0;i<=10;i++){
  if(s[i]=='\0'){
  if(s[i-1]=='C'){
  flag=10;
  }
  }
  }
  
  for(i=0;i<=10;i++){
  if(s[i] != 'A'){
    if(s[i]!='C'){
   if( isupper( s[i] ) != 0 ){
   flag=3;
  }
  }
  }
  }
  
  
  
  if(flag==2){
    printf("AC");
  }
  else{
  printf("WA");
  }
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
#define KMAX 30
#define VMAX 1000000
int main( void )
{
	vector <bool> prime(VMAX+1, false);
	for ( int i = 3; i <= VMAX; i += 2 )
	{
		prime[i] = true;
	}
	prime[2] = true;
	for ( int i = 3; i * i <= VMAX; i += 2 )
	{
		if ( prime[i] )
		{
			for ( int j = i + i; j <= VMAX; j += i )
				prime[j] = false;
		}
	}

	while ( 1 )
	{
		int n, x;
		cin >> n >> x;
		if ( n == 0 && x == 0 )
			break;

		vector <int> K( KMAX );
		for ( int i = 0; i < n; i++ )
			cin >> K[i];

		vector < vector <bool> > T( KMAX, vector <bool>(VMAX, false) );

		for ( int i = 0; i < n; i++ )
			T[i][0] = true;
		for ( int i = K[0]; i <= x; i += K[0] )
			T[0][i] = true;

		for ( int i = 1; i < n; i++ )
		{
			for ( int j = 1; j < K[i]; j++ )
			{
				T[i][j] = T[i-1][j];
			}

			for ( int j = K[i]; j <= x; j++ )
			{
				T[i][j] = ( T[i-1][j] || T[i][j-K[i]] );
			}
		}

		int kotae = -1;
		for ( int i = x; i >= 2; i-- )
		{
			if ( prime[i] && T[n-1][i] )
			{
				kotae = i;
				break;
			}
		}

		if ( kotae == -1 )
			cout << "NA" << endl;
		else
			cout << kotae << endl;

	}

	return 0;
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 256
n, a, b, c = gets.chomp.split(' ').map(&:to_i)
list = n.times.map { gets.chomp.to_i }

res = [a, b, c]
if res.all? { |x| list.find { |y| y == x } }
  puts 0
  exit 0
end

min_sum = 10_0000
0.upto(4 ** n - 1).each do |s|
  lens = [0, 0, 0, 0]
  sums = [0, 0, 0, 0]
  cs = s.to_s(4).rjust(n, '0').chars
  next if cs.count('1') == 0 || cs.count('2') == 0 || cs.count('3') == 0
  cs.map(&:to_i).each.with_index(0) do |d, i|
    lens[d] += list[i]
  end
  [1, 2, 3].each do |i|
    x = cs.count(i.to_s) - 1
    next if x <= 0
    sums[i] += x * 10
  end

  res.each.with_index(1) do |x, i|
    sums[i] += (x - lens[i]).abs
  end
  sum = sums[1] + sums[2] + sums[3]
  min_sum = sum if sum < min_sum
end
puts min_sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin>>n;
  int ans=0;
  for (int i = 1; i <=n; i+=2) {
      int count=0;
 for (int j = 1; j <= n; j++) {
    if(i%j ==0){
      count++;
}
       }
    if(count==8){
      ans++;
    }
  }
cout<<ans<<endl;

}

Measured memory_bytes: 256
box = [
		[1,2,3,4,5,6,7,8,9,10,11,12,13],	#S
		[1,2,3,4,5,6,7,8,9,10,11,12,13],	#H
		[1,2,3,4,5,6,7,8,9,10,11,12,13],	#C
		[1,2,3,4,5,6,7,8,9,10,11,12,13]	#D
	]
gara = ["S", "H", "C", "D"]
num = int(input())

def popper(suit, num):
	if   suit == "S":box[0].remove(int(num))
	elif suit == "H":box[1].remove(int(num))
	elif suit == "C":box[2].remove(int(num))
	elif suit == "D":box[3].remove(int(num))
	
for i in range(num):
	suit, card_num = input().split()
	popper(suit, card_num)

for i in range(4):
	for j in range(len(box[i])):
		print("{} {}".format(gara[i], box[i][j]))

Measured memory_bytes: 7656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


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

Measured memory_bytes: 256
K, N = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
behind_range = 0
max_distance = 0
a_list.append(K + a_list[0])
for a in a_list:
    distance = a - behind_range
    behind_range += distance
    if max_distance < distance:
        max_distance = distance

print(K - max_distance)


Measured memory_bytes: 24564
n,x = (int(i) for i in input().split())
lenb = [[1,1,0]]
for i in range(n):
    p = lenb[i][1]*2 + 1
    b = lenb[i][2]*2 + 2
    lenb.append([p+b,p,b])

def count(n,x):
    if n >= 1:
        if x <= 1 + lenb[n-1][0]:
            return count(n-1,x-1)
        elif x ==  1 + lenb[n-1][0] + 1:
            return lenb[n-1][1]+1
        else:
            return lenb[n-1][1]+1 + count(n-1,x-lenb[n-1][0]-2)
    else:
        if x > 0:
            return 1
        else:
            return 0
print(count(n,x))

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void Init();
void printList();
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
void delete(int);
void insert(int);

int main(){

  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d",&n);
  Init();

  for(i = 0; i < n; i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i') {
      insert(key);
      np++;
      size++;
    }else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();  
      }else{
	delete(key);
	nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key) cur = cur->next;

  return cur;
}

void Init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil) break;
    if(isf == 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if(t == nil) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x;

  x = (NodePointer)malloc(sizeof(struct node));

  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}





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

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll x, t;
    cin >> x >> t;
    if (x - t >= 0) {
        cout << x - t << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <random>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <iostream>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <map>

#define ll long long
#define mod 1000000007
#define max_limit 1000005
using namespace std;




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

    vector<string> voting_papers(n, "");
    unordered_map<string, int> stringOcc;
    int max_count = 0;
    for(int i = 0; i < n; i++) {
        cin>>voting_papers[i];

        stringOcc[voting_papers[i]]++;
        max_count = max(max_count, stringOcc[voting_papers[i]]);
    }


    std::unordered_map<string, int>::iterator it = stringOcc.begin();
    vector<string> answers;
    while(it != stringOcc.end()) {
        if(max_count == it->second) {
            answers.push_back(it->first);
        }
        it++;
    }

    sort(answers.begin(), answers.end());
    for(unsigned int i = 0; i < answers.size(); i++) {
        cout<<answers[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 28228
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    int N, M, x, y;
    std::cin >> N >> M >> x >> y;
    std::vector<int> emp_a(N);
    for (size_t i = 0; i != N; ++i) {
        std::cin >> emp_a[i];
    }
    std::vector<int> emp_b(M);
    for (size_t i = 0; i != M; ++i) {
        std::cin >> emp_b[i];
    }
    bool is_war = false;
    for (int i = x + 1; i != y + 1; ++i) {
        is_war = false;
        for(size_t j = 0; j != N; ++j) {
            if (i <= emp_a[j])
                is_war = true;
        }
        for(size_t j = 0; j != M; ++j) {
            if (i > emp_b[j])
                is_war = true;
        }
        if (!is_war)
            break;
    }
    if (is_war)
        std::cout << "War\n";
    else
        std::cout << "No War\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>

int main()
{
    std::string s;
    std::cin >> s;

    int K;
    std::cin >> K;

    std::vector<std::string> subs;
    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 1; j < s.length() - i + 1; j++)
        {
            if (j > K) break;
            subs.emplace_back(s.substr(i, j));
        }
    }

    std::sort(subs.begin(), subs.end());
    subs.erase(std::unique(subs.begin(), subs.end()), subs.end());

    std::cout << subs[K - 1] << std::endl;
    return 0;
}

Measured memory_bytes: 1660
/**
 *    author:  math2do
 *    created: 18.01.2020 02:52:32
**/

#include <bits/stdc++.h>

using namespace std;

const int pinf = (1U << 31) - 1;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (n == 1) {
    cout << 0 << '\n';
    return 0;
  } 
  vector <int> dp(n, pinf); 
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  for (int i = 2; i < n; i++) { 
    int jump = pinf;
    for (int j = max(0, i - k); j < i; j++) {
      jump = min(jump, dp[j] + abs(arr[i] - arr[j]));
    }
    dp[i] = jump; 
  } 

  cout << dp[n - 1] << '\n';
  return 0;
}


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

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);
  /*


  C=n*(n+1)/2とおく．

  n頂点からなる完全グラフを考えると，
  頂点iにおける隣接頂点の和は(C-i)である．
  ここで次の補題を考える．

  Lemma:頂点s,t(1<=s,t<=n,s!=t)をつなぐ辺を取り除いたとき，
  それぞれの隣接頂点の和は等しくなる．

  Proof:s,t,の隣接頂点の和はそれぞれ(C-s),(C-t)である．
  ここで，辺を取り除くとそれぞれの隣接頂点の和は(C-s-t),(C-t-s)となり等しい．

  まずnが偶数の時の考察をする．
  (s,t)=(1,n),(2,n-1),(3,n-2)...(n/2,n/2+1)というn/2個のペアを考える．
  このようにペアをとると，各ペアの隣接頂点の和は(C-(n+1))で等しくなる．
  よって，nが偶数の時は完全グラフからこれらの辺を除いたものを構成すればよい．

  次にnが奇数の時の考察をする．
  いま1~nがそれぞれ書かれたn頂点のグラフGを考えているが，これに頂点0を追加した
  (n+1)頂点からなるグラフG'を考える．するとグラフG'の各頂点における隣接頂点の和は
  変化しないことがわかる．そこで，先ほど同様(s,t)=(0,n),(1,n-1),...((n-1)/2,(n+1)/2)
  というペアを考えると，各ペアの隣接頂点の和は(C-n)で等しくなる．
  よってnが奇数の時は完全グラフG'からこれらの辺と頂点0から出る辺を除いたものを構成すればよい．

  最後に
  ・完全グラフの辺の本数=n*(n+1)/2
  ・取り除く本数はn/2の切り捨て
  ということがわかるので，構成するために必要な辺の本数は
  n*(n+1)/2-n/2であることがわかる．
  (下の実装では完全グラフの辺の数=(n角形の対角線の数)+(n角形の辺の数)という形で実装しています)


  実際の構成方法は以下のコードの通りで，計算量はO(n^2)で十分高速である．


  */
  int ans=(n-3)*n/2+n;
  ans-=n/2;
  printf("%d\n",ans);
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j==n+1 && n%2==0){
        continue;
      }
      if(i+j==n && n%2==1){
        continue;
      }

      printf("%d %d\n",i,j);
    }
  }
}

Measured memory_bytes: 1716
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll sum = 0;

int main(){
    ll N, M;
    ll waru = 1000000007;
    cin >> N >> M;
    vector <ll > a(N + 2, 0);

    ll m = 0;
    for(ll i = 0; i < M; i++){
        cin >> m;
        a[m] = -1;
    }

    //vector<vector<ll > > dp(N, vector<ll >(N + 1, -1));
    a[0] = 1;

    for(ll i = 0; i < N; i++){
        if(a[i] == -1){
            continue;
        }
        if(a[i + 1] != -1){
            a[i + 1] += a[i];
            a[i + 1] %= waru;
        }
        if(a[i + 2] != -1){
            a[i + 2] += a[i];
            a[i + 2] %= waru;
        }
    }

    cout << a[N] << endl;

} 

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%s", $ss);
$s = str_split($ss);
$len = count($s);
if ($s[0] == $s[1]) {
    echo '1 2';
    return;
}
if ($len == 2) {
    echo '-1 -1';
    return;
}
$list = [$s[0] => 1, $s[1] => 1];
for ($i = 2; $i < $len; $i++) {
    if (!isset($list[$s[$i]]) || $list[$s[$i]] == 0) {
        $list[$s[$i]] = 1;
    } elseif ($list[$s[$i]] == 1) {
        echo ($i - 1) . ' ' . ($i + 1);
        return;
    }
    $list[$s[$i - 2]]--;
}
echo '-1 -1';


Measured memory_bytes: 21132
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include<bitset>
#include <utility>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
//const ll M=1e9+7;
//const ll maxn=2e5+7;
//const int MAXN=1005;
const int MAX=2e5+5;
const int MAX_N=MAX;
//const int N=55;
const ll MOD=1000000007;
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
    freopen("1004.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int H,w;
char a[2005][2005];
int l[2005][2005],r[2005][2005],dp[2005][2005],le[2005][2005],ri[2005][2005],h[2005][2005];//某个点左侧、右侧下一个（不含本身）障碍点的位置
int dx[4]={0,0,1,1};
int dy[4]={0,1,0,1};
int an=0;
inline bool check(int x,int y)
{
    int cnt=0;
    for(int i=0;i<4;i++)
        if(a[x+dx[i]][y+dy[i]]=='#')
            ++cnt;
    return cnt%2==0;
}
int main()
{
    scanf("%d%d",&H,&w);
    for(int i=1;i<=H;i++)
        scanf("%s",a[i]+1);
    for(int i=1;i<=H-1;i++)
        for(int j=1;j<=w-1;j++)
            if(!check(i,j))
                dp[i][j]=1;
    //处理l
    for(int i=1;i<=H;i++)
        for(int j=1;j<=w;j++)
            l[i][j]=dp[i][j-1]?j-1:l[i][j-1];
    for(int i=1;i<=H;i++)
        r[i][w]=w;
    for(int i=1;i<=H;i++)
        for(int j=w-1;j>=0;j--)
            r[i][j]=dp[i][j+1]?j+1:r[i][j+1];
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(dp[i-1][j]||i==1)
            {
                h[i][j]=1;
                le[i][j]=0;ri[i][j]=w;
            }
            else
            {
                h[i][j]=h[i-1][j]+1;
                le[i][j]=max(l[i-1][j],le[i-1][j]);
                ri[i][j]=min(r[i-1][j],ri[i-1][j]);
//                printf("i=%d j=%d le=%d ri=%d\n",i,j,le[i][j],ri[i][j]);
            }
            an=max(an,h[i][j]*(ri[i][j]-le[i][j]));
        }
    }
    printf("%d\n",an);

    return 0;
}


Measured memory_bytes: 98432
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll=long long;
const double PI=acos(-1);
int main(){
  int a, b, h, m;
   cin >> a >> b >> h >> m;
  double M=m/2.0;
  double Min=min(abs(30*h+M-6*m),360-abs(30*h+M-6*m));
  double x=Min/180.0;
  
  double ans=sqrt(a*a+b*b-2*a*b*cos(x*PI));
  
  printf("%.12f\n",ans);
  
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MIN(a,b) (((a)<=(b))?(a):(b))
#define MAX(a,b) (((a)>=(b))?(a):(b))
#define ll long long int
using namespace std;

int main(){
    int n, p, q;
    cin >> n >> p >> q;
    int qq[q];
    rep(i, q) cin >> qq[i];
    rep(i, q) qq[i]--;
    int a[n];
    rep(i, n) a[i] = p;
    rep(i, q)
        a[qq[i]]++;
    rep(i, n)
        a[i] -= q;
    rep(i, n){
        if(a[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;


int main(void) {

    int r, d, x; cin >> r >> d >> x;
    for(int i=0; i<10; i++) {
      x = x * r - d;
      cout << x << endl;
    }

    return 0;
}



// EOF


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;
    string ans;
    if(a+b > c+d) ans = "Left";
    else if(a+b == c+d) ans = "Balanced";
    else ans = "Right";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8
a, b, c = map(int, input().split())

#パターンを列挙 10の桁をどこにするかで3通り
x = a * 10 + b + c
y = a + b * 10 + c
z = a + b + c * 10

print(max(x, y, z))

Measured memory_bytes: 2940
while True:
    n,k=map(int,input().split())
    if (n,k)==(0,0):
        break
    list=[int(input()) for i in range(n)]
    a=[]
    c=0
    for i in range(k):
        c+=list[i]
    a.append(c)
    for j in range(n-k):
        c+=list[k+j]
        c-=list[j]
        a.append(c)
    print(max(a))


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

int main(){

	int N, H, x;
  	x = 0;
  
  	cin >> N >> H; 
  
  	vector<vector<int>> vec (H, vector<int>(2));
  
  	for(int i = 0; i < H; i++){
    	for(int j = 0; j < 2; j++){
        	cin >> vec.at(i).at(j);
        }
    }
  
  	for(int k = 1; k < N + 1; k++){
    	for(int i = 0; i < H; i++){
        	for(int j = 0; j < 2; j++){
            	if(vec.at(i).at(j) == k){
               		x++; 	
                }           
            }
        }
    cout << x << endl;
    x = 0;
    }

  	
  
}

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

signed main() {
	int h,w,m=1e9+7;
	cin>>h>>w;
	char g[h+1][w+1];
	int dp[h+1][w+1];
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin>>g[i][j];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			if(g[i][j]=='#') continue;;;;;
			if(i==1 and j==1) dp[i][j]=1;
			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%m;
		}
	cout<<dp[h][w];
	
}

Measured memory_bytes: 9088
using System;

namespace B___e_e_ee_e
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var s = Console.ReadLine ();
            var k = int.Parse (Console.ReadLine ());
            var ans = "";
            for (var i = 0; i < n; i++)
            {
                if (s[i] != s[k-1])
                {
                    ans += '*';
                }
                else
                {
                    ans += s[i];
                }
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V deque<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
const int   N=                   2e5+5;
 
const int MAXR = 1000005;
ll         tests=          1;
 
using namespace std;
ll binarySearch(ll l, ll r,ll k)
{
  if (r >= l) {
    ll mid = l + (r - l) / 2;
    if (mid*(mid+1)==k)
      return 1;
    if (mid*(mid+1)>k)
      return binarySearch( l, mid - 1,k);
    return binarySearch(mid + 1, r, k);
  }
  return 0;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
int MaxSubArraySumReturn(int a[], int  n) //negative thakle o kaaj korbe in O(n)
{
 
    int sum = 0, best = 0;
   for(ll i=0;i<n;i++)
    {
        sum = max(a[i], a[i] + sum);
        best = max(best, sum);
    }
    return best;
 
}
ll totalDigits(ll n) 
{ 
 
    ll number_of_digits = 0; 
    for (ll i = 1; i <= n; i *= 10) 
        number_of_digits += (n - i + 1); 
  
    return number_of_digits; 
}
ll paa[N]={0},pbb[N]={0};
int main()
{
  #ifndef ONLINE_JUDGE
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    }
#endif
  ll n,m,k,sum=0,ctr=0;
  cin>>n>>m>>k;
  ll a[n];
  ll b[m];
  for(ll i=0;i<n;i++)
    {cin>>a[i];
        paa[i+1]=paa[i]+a[i];}
  for(ll i=0;i<m;i++)
    {cin>>b[i];
        pbb[i+1]=pbb[i]+b[i];}
  for(ll i=0;i<n+1;i++)
  {
        if (paa[i] <= k)
         ctr = max(ctr, i+(ll)(upper_bound(pbb, pbb+m+1, k-paa[i])-pbb-1));
      else
        break;
  }
  cout<<ctr<<Endl;
 }


Measured memory_bytes: 9860
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    int res = 0;
    int right = 0;
    for (int left = 0; left < n; left++) {
        
        while (right < n && a[right] - a[left] <= 2) {
            right++;
        }

        //区間を広げるとfeasibleでなくなる問題なので不当なres更新が起きない
        res = max(res, right - left);
        
        if (left == right) {
            right++;
        }
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 640
str=input()
if(str=='SAT'):
	print('1')
elif(str=='SUN'):
	print('7')
elif(str=='MON'):
	print('6')
elif(str=='TUE'):
	print('5')
elif(str=='WED'):
	print('4')
elif(str=='THU'):
	print('3')
else:
	print('2')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
long long G[N][N],n,ans=0;
signed main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
		cin>>G[i][j];
	for(int i=0;i<n;i++)
	for(int j=0;j<i;j++)
		ans+=min(G[i][j],G[j][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1272
#include <stdio.h>
    #include <string.h>
     
    int main(void)
    {
     
      char a[100];
      scanf("%s",a);
      if(strcmp(a,"2019/04/30")<=0)
            printf("Heisei\n");
      else
            printf("TBD\n");
      return 0;
    }

Measured memory_bytes: 128
from sys import stdin
input = stdin.readline

x, n  = map(int, input().split())
p_list = list(map(int, input().split()))

if n == 0:
    print (x)
    exit()

li = []
# res = float('inf')
# for i in n:
#      std = abs(x - p_list[i])
#      if std <= res:
#          res = std    
def dfslower(std) :
    """
    argument x : 基準となる数字
    y 結果となりうる数字？
    return : 結果
    """
    if std  in p_list:
        return dfslower(std-1)
        #print(std)
    else:
        return std
        

def dfsupper(std) :
    """
    argument x : 基準となる数字
    y 結果となりうる数字？
    return : 結果
    """
    if std  in p_list:
        return dfsupper(std+1)
        #print(std)
    else:
        return(std)

mininte = dfslower(x)
maxinte =  dfsupper(x)

if abs(mininte-x)> abs(maxinte -x):
    print(maxinte)
elif abs(mininte-x) <= abs(maxinte -x):
    print(mininte)




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

int main(){
    int W, H , x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if(x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n)cin >> a[i];
	if (a[0] != 0)
	{
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i < n; ++i)
	{
		if (a[i] > a[i - 1] + 1)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	ll res = 0;
	for (int i = 1; i < n; ++i)
	{
		if (a[i] == a[i - 1] + 1)++res;
		else res += a[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 1024