akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 3005
using namespace std;
int n;
double p[M], dp[M][M];
int main()
{
    while (~scanf("%d",&n)) {
        REP(i,1,n) scanf("%lf", &p[i]);
        dp[0][0] = 1.0;
        REP(i,1,n) REP(j,0,i) {
            dp[i][j] = dp[i-1][j] * (1.0-p[i]);
            if (j) dp[i][j] += dp[i-1][j-1] * p[i];
        }

        double ans = 0.0;
        REP(i,(n+1)/2,n) ans += dp[n][i];
        printf("%.10f\n", ans);
    }
    
    return 0;
}




Measured memory_bytes: 68992
while 1:
	n = input()
	if n == 0: break
	ans = 0
	for i in range(96):
		tri = i*(i+1)*(i+2)/6
		if tri > n: break
		ans = max(ans,int((n-tri)**(1.0/3)+1e-8)**3 + tri)
	print ans

Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
int n;
const int N=100010,M=16;
int s[N],cnt[M],ans,f[1000010];
void chkmin(int &x,int y)
{
	if(y<x)x=y;
}
int main()
{
	scanf("%d",&n);
	int u,v,w;
	for(int i=1;i<n;i++)
		scanf("%d%d%d",&u,&v,&w),s[u]^=w,s[v]^=w;
	for(int i=0;i<n;i++)
		cnt[s[i]]++;
	int now=0;
	for(int i=1;i<16;i++)
		ans+=cnt[i]/2,now+=((cnt[i]&1)<<i-1);
	memset(f,127,sizeof(f)); f[now]=0;
	for(int i=(1<<15)-1;i;i--)
		if(f[i]<2000000000)
		{
			for(int j=1;j<=15;j++)
				if(i&(1<<j-1))
					for(int k=1;k<=15;k++)
						if(i&(1<<k-1) && j!=k)
						{
							int l=j^k;
							if(i&(1<<l-1))
								chkmin(f[i-(1<<j-1)-(1<<k-1)-(1<<l-1)],f[i]+2);
							else
								chkmin(f[i-(1<<j-1)-(1<<k-1)+(1<<l-1)],f[i]+1);
						}
		}
	printf("%d\n",f[0]+ans);
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
//mod = 1000000007;
int main() {
  long long n,k;
  cin >> n >> k;
  
  long long tmp;
  long double tmp_p;
  long double p = 0;
  for(int i = 1;i<n+1;i++){
    tmp = i;
    tmp_p = 1;
    while(tmp < k){
      tmp *= 2;
      tmp_p *= (0.5);
    }
    p += tmp_p;
  }
  
  cout << fixed << setprecision(10) << p/n;
  
    
  
}


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

/**
 *  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
 *  0 1 1 0 1 1 0 1 1 0 1 1 0 1 1
 *  1 1 0 1 1 0 1 1 0 1 1 0 1 1 0
 *  1 0 1 1 0 1 1 0 1 1 0 1 1 0 1
 **/

int main () {
	int N;
	int a[] = {-1, -1, -1};
	int c[] = {0, 0, 0};
	int idx = 0;
	cin >> N;
	for (int i=0; i<N; i++) {
		int tmp;
		bool flag = true;
		cin >> tmp;
		for (int j=0; j<idx && j<3; j++) {
			if (a[j] == tmp) {
				flag = false;
				c[j] ++;
			}
		}
		if (flag) {
			if (idx >= 3) {
				cout << "No" << endl;
				return 0;
			}
			a[idx] = tmp;
			c[idx] ++;
			idx ++;
		}
	}
	if (idx==1 && a[0]==0) {
		cout << "Yes" << endl;
	} else if (idx==2 && ((a[0]==0&&c[1]==2*c[0]) || (a[1]==0&&c[0]==2*c[1])) && N%3==0) {
		cout << "Yes" << endl;
	} else if (idx==3 && (a[0]^a[1]^a[2])==0 && c[0]==c[1] && c[1]==c[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	string s;cin>>s;int idx=1;int cnt=1;
	while(idx<n)
	{
		while(idx<n&&s[idx-1]==s[idx]) idx++;
		if(idx!=n&&s[idx-1]!=s[idx])
		{
			//cout<<idx<<endl;
			idx++;
			cnt++;
		}
	}
	cout<<cnt<<endl;
 } 

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

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


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

    int a;
    cin >> a;
    cout << a * a * a << endl;

    return 0;
}


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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

int main(){
	fast;
	int n,ans=0;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++)
				if(arr[i]+arr[j]>arr[k] and arr[i]!=arr[j] and arr[i]!=arr[k] and arr[j]!=arr[k])
					ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3652
inf = 10 ** 15
mod = 10 ** 9 + 7

s = input()
k = int(input())
count1 = 0
other = ''
for c in s:
    if c == '1':
        count1+=1
    else:
        other = c
        break
if other == '':
    print(1)
else:
    if k <= count1:
        print(1)
    else:
        print(other)

Measured memory_bytes: 38400
#include<bits/stdc++.h>
using namespace std;
const int M=20,N=50000;
int dp[N+5],a[M+5],n,m;
signed main(void){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",a+i);
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=m;i++)
		for(int j=0;j<=n;j++)
			if(j-a[i]>=0)
				dp[j]=min(dp[j],dp[j-a[i]]+1);
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1392
N = int(input())
d = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for _ in range(N):
    S = input()
    d[S] += 1
print('AC x ' + str(d['AC']))
print('WA x ' + str(d['WA']))
print('TLE x ' + str(d['TLE']))
print('RE x ' + str(d['RE']))

Measured memory_bytes: 9196
#include <iostream>

using namespace std;

void swap(int &x1, int &x2)
{
	int tmp = x1;
	x1 = x2;
	x2 = tmp;
}

int main()
{
	int h1, h2, h3;
	h1 = h2 = h3 = 0;

	for (int i = 0; i < 10; i++) {
		int x;
		cin >> x;
		if (x > h3) {
			swap(x, h3);
			if (h3 > h2) {
				swap(h3, h2);
				if (h2 > h1) {
					swap(h2, h1);
				}
			}
		}
	}
	cout << h1 << endl;
	cout << h2 << endl;
	cout << h3 << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll n, k, l;
ll p[200005];

class union_find {
	public:
	vector<int>par;
	vector<int>size;

	union_find(int n) : par(n), size(n, 1) {
		for (int i = 0; i < n; i++) {
			par[i] = i;//最初の親は自分自身
		}
	}
	void init(int n) {
		par.resize(n);
		size.assign(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;//最初の親は自分自身
		}
	}
	//木の根を求める
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = root(par[x]);
		}
	}
	//xとyが同じ集合に属すか否か
	bool same(int x, int y) {
		return(root(x) == root(y));
	}
	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return false;//根が同じならもう併合済み
		//併合するときは"小さい方"を"大きい方"に併合させる
		if (size[x] < size[y]) {
			swap(x, y);
		}
		size[x] += size[y];
		par[y] = x;
		return true;
	}

	int getSize(int x) {
		return size[root(x)];
	}
};

//union_find tree;
//tree.init(); //これで初期化
//tree.unite(a,b) //aとbのグループを併合
//tree.same(a,b) //aとbが同じグループか(trueかfalse)
int main(void) {
	cin >> n >> k >> l;
	union_find uf1(n), uf2(n);
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf1.unite(a, b);
	}

	for (int i = 0; i < l; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf2.unite(a, b);
	}


	map<P, int>ma;
	for (int v = 0; v < n; v++) {
		P p;
		p = (make_pair(uf1.root(v), uf2.root(v)));
		ma[p]++;
	}

	for (int v = 0; v < n; v++) {
		P p;
		p = (make_pair(uf1.root(v), uf2.root(v)));
		cout << ma[p] << " ";
	}
	return 0;
}

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

int main()
{
	int num[3];
	
	for (int i = 0;i < 3;i++)
	{
		cin >> num[i];
	}

	for (int i = 0; i < 2;i++)
	{
		for (int j = 1;j < 3;j++)
		{
			if (num[i] > num[j])
			{
				int tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
		}
	}

	cout << num[0] << " " << num[1] << " " << num[2] << '\n';
}


Measured memory_bytes: 3112
n = int(input())
s = list(map(int,input()))
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            a,b,c = -1,-1,-1
            for l in range(n):
                if s[l] == i:
                    a = l
                    break
            for l in range(a+1,n):
                if s[l] == j:
                    b = l
                    break
            for l in range(b+1,n):
                if s[l] == k:
                    c = l
                    break
            if a == -1 or b == -1 or c == -1: pass
            else: ans += 1
print(ans)

Measured memory_bytes: 45532
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

const int N = 3001;
int vis[N];
const int limit=3000;
bool isprime[limit+1];
vector<ll> prime;
 
void init(){
	REP(i, 0, limit+1) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(ll i=2;i*i<=limit;++i){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=i*i;j<=limit;j+=i)
				isprime[j]=false;
		}
	}
	return;
}
map<ll, int> cnt;
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    init();
    int m = prime.size();
    int n;
    scanf("%d", &n);
    REP(i, 0, n){
        ll cur;
        scanf("%lld", &cur);
        REP(j, 0, m){
            ll cube = 1ll * prime[j] * prime[j] * prime[j];
            while(cur % cube == 0) cur /= cube;
        }
        cnt[cur] ++;
    }
    ll ans = 0;
    for(auto &it : cnt){
        if(it.fi == 1)
            ans += min<ll>(1ll, it.se);
        else{
            ll tar = 1ll * it.fi * it.fi;
            REP(j, 0, m){
                ll cube = 1ll * prime[j] * prime[j] * prime[j];
                while(tar % cube == 0) tar /= cube;
            }
            ans += max<ll>(it.se, cnt[tar]);
            it.se = 0;
            cnt[tar] = 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 21376
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    string s;
    while(getline(cin,s)){
        for(int i=0;i<s.size();i++){
            if(s[i]>='a'&&s[i]<='z')    s[i]-=32;
        }
        cout << s << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

unordered_set<ll>S[300005];
int n,m;
char f[300005];
ll b[300005][2];
ll r[300005][2];
ll rui[300005][2];
ll mod[2] = {1000000007, 1000000009};
ll inv[2] ;
ll modpow(ll x,ll n,ll mod){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",&f);
	b[0][0] = b[0][1] = r[0][0] = r[0][1] = 1;
	inv[0] = modpow(32LL,mod[0]-2,mod[0]);
	inv[1] = modpow(32LL,mod[1]-2,mod[1]);
	for(int i=1;i<=n;i++){
		rep(k,2){
			b[i][k] = b[i-1][k] * 32LL % mod[k];
			r[i][k] = r[i-1][k] * inv[k] % mod[k];
			rui[i][k] = rui[i-1][k] + b[i][k]*(f[i-1]-'a'+1);
			rui[i][k] %= mod[k];
		}
	}
	int L = 1, R = 1;
	rep(i,m){
		char f[6]; scanf("%s",&f);
		if(f[0] == 'L'){
			if(f[1] == '+') L++;
			else L--;
		}
		else{
			if(f[1] == '+') R++;
			else R--;
		}
		if(L > R){
			S[0].insert(0LL);
		}
		else{
			ll RR[2];
			rep(k,2){
				RR[k] = rui[R][k] - rui[L-1][k];
				RR[k] *= r[L-1][k];
				RR[k] %= mod[k];
				if(RR[k] < 0) RR[k] += mod[k];
			}
			S[R-L+1].insert(RR[0] * 1000000100LL + RR[1]);
		}
	}
	int ans = 0;
	rep(i,300005) ans += S[i].size();
	cout<<ans<<endl;
}


Measured memory_bytes: 52728
#include <iostream>
using namespace std;
long long int gcm(long long int a,long long int b)
{
 
  long long int r, tmp;

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

bool solve(long long int a,long long int b,long long int c,long long int d){
    if(a<b)return false;
    if(b>d)return false;
    long long int x=a%b;
    long long int y=gcm(b,d);
    if(a%b>c)return false;
    if(x+y*(1+(c-x)/y)-b<0)return false;
    return true;
}
int main(void){
    // Your code here!
    long long int n,a,b,c,d;
    cin>>n;
    for(long long int i=0;i<n;i++){
        cin>>a>>b>>c>>d;
        if(solve(a,b,c,d))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  vector<int64_t> WA(N);
  WA.at(0)=p.at(0);
  for(int i=1;i<N;i++){
    WA.at(i)=p.at(i)+WA.at(i-1);
  }
  int A=1;
  for(int i=N-2;i>=0;i--){
    if(WA.at(i)*2>=p.at(i+1)){
      A++;
    }
    else{
      break;
    }
  }
  cout<<A<<endl;
  
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int n,x;
    cin >> n >> x;
    vi locs(n);
    rep(i, n) cin >> locs[i];
    rep(i, n) locs[i] = abs(x - locs[i]);
    sort(all(locs));
    int saidai = locs[0];
    for(int val = saidai; val >= 1; val--) {
        bool ok = true;
        for(int loc: locs) {
            if (loc % val != 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << val << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 640
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
    var ans;
	//文字列から10進数に変換するときはparseIntを使います
	//var a = parseInt(input[0], 10);
	
    for(i=0;i<5;i++){
      if(parseInt(tmp[i],10)!=(i+1)){
        ans = i + 1;
      }
    }
    
	//出力
	console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29196
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

A = inputIL()
K = inputI()

S = sum(A)
M = max(A)

print(S-M+M*2**K)

Measured memory_bytes: 38256
import java.awt.*;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    private static int[][] DXDY = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] s = new String[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next().split("");
        }
        int black = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ("#".equals(s[i][j])) {
                    black++;
                }
            }
        }
        Deque<Point> queue = new ArrayDeque<>();
        queue.add(new Point(0, 0));
        int dis = 1;
        boolean[][] visited = new boolean[h][w];
        visited[0][0] = true;
        while (!queue.isEmpty()) {
            int size = queue.size();
            dis++;
            for (int i = 0; i < size; i++) {
                Point p = queue.poll();
                int posx = p.x;
                int posy = p.y;
                for (int j = 0; j < DXDY.length; j++) {
                    int x = posx + DXDY[j][0];
                    int y = posy + DXDY[j][1];
                    if (x == h - 1 && y == w - 1) {
                        System.out.println(w * h - black - dis);
                        return;
                    }
                    if (x < 0 || x >= s.length || y < 0 || y >= s[0].length || "#".equals(s[x][y])
                            || visited[x][y]) {
                        continue;
                    }
                    visited[x][y] = true;
                    queue.add(new Point(x, y));
                }
            }
        }
        System.out.println(-1);
    }

}


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

const int MAXN = 500005;
int lr[MAXN], rl[MAXN], ud[MAXN], du[MAXN];
int mlr[MAXN], mrl[MAXN], mud[MAXN], mdu[MAXN];
int h, w, n, x, y;
string s, t;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w >> n;
	cin >> x >> y;
	cin >> s >> t;
	for(int i = 0; i < n; ++i) {
		lr[i * 2 + 1] = lr[i * 2];
		rl[i * 2 + 1] = rl[i * 2];
		ud[i * 2 + 1] = ud[i * 2];
		du[i * 2 + 1] = du[i * 2];
		if(s[i] == 'L')
			++lr[i * 2 + 1];
		if(s[i] == 'R')
			++rl[i * 2 + 1];
		if(s[i] == 'U')
			++ud[i * 2 + 1];
		if(s[i] == 'D')
			++du[i * 2 + 1];
		lr[i * 2 + 2] = lr[i * 2 + 1];
		rl[i * 2 + 2] = rl[i * 2 + 1];
		ud[i * 2 + 2] = ud[i * 2 + 1];
		du[i * 2 + 2] = du[i * 2 + 1];
		if(t[i] == 'L')
			--rl[i * 2 + 2];
		if(t[i] == 'R')
			--lr[i * 2 + 2];
		if(t[i] == 'U')
			--du[i * 2 + 2];
		if(t[i] == 'D')
			--ud[i * 2 + 2];
	}
	mrl[n + n] = rl[n + n];
	mlr[n + n] = lr[n + n];
	mud[n + n] = ud[n + n];
	mdu[n + n] = du[n + n];
	for(int i = 2 * n - 1; i >= 0; --i) {
		mrl[i] = max(mrl[i + 1], rl[i]);
		mlr[i] = max(mlr[i + 1], lr[i]);
		mud[i] = max(mud[i + 1], ud[i]);
		mdu[i] = max(mdu[i + 1], du[i]);
	}
	for(int i = 0; i < n; ++i) {
		if(s[i] == 'L' && y - (mlr[i * 2 + 1] - lr[i * 2]) < 1)
			--y;
		if(s[i] == 'R' && y + mrl[i * 2 + 1] - rl[i * 2] > w)
			++y;
		if(s[i] == 'U' && x - (mud[i * 2 + 1] - ud[i * 2]) < 1)
			--x;
		if(s[i] == 'D' && x + mdu[i * 2 + 1] - du[i * 2] > h)
			++x;
		if(x < 1 || y < 1 || x > h || y > w) {
			cout << "NO" << endl;
			return 0;
		}
		if(t[i] == 'L' && y - (mlr[i * 2 + 2] - lr[i * 2 + 2]) - 1 >= 1)
			--y;
		if(t[i] == 'R' && y + mrl[i * 2 + 2] - rl[i * 2 + 2] + 1 <= w)
			++y;
		if(t[i] == 'U' && x - (mud[i * 2 + 2] - ud[i * 2 + 2]) - 1 >= 1)
			--x;
		if(t[i] == 'D' && x + mdu[i * 2 + 2] - du[i * 2 + 2] + 1 <= h)
			++x;
	}
	cout << "YES" << endl;

}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int a,b,c;

void input(){
	cin>>a>>b>>c;
	return;
}

void solve(){
	if(a==b&&b==c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	int [] order;
	boolean [] used;
	int kind;
	boolean flg;
	int [][] pos;
	char [][] data;
	ArrayList<Character> kindchar;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		while(dataset-- > 0){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if((h|w) == 0) break;
			data = new char[h][w];
			for(int i = 0; i < h; i++){
				data[i] = sc.next().toCharArray();
			}
			
			int [] freq = new int[26];
			pos = new int[26][4]; //minx, miny, maxx, maxy
			for(int i = 0; i < 26; i++){
				Arrays.fill(pos[i], -1);
			}
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(data[i][j] == '.') continue;
					int ind = data[i][j] - 'A';
					freq[ind]++;
					if(pos[ind][0] == -1){
						pos[ind][0] = j;
						pos[ind][2] = j;
						pos[ind][1] = i;
						pos[ind][3] = i;
					}
					else{
						pos[ind][0] = Math.min(pos[ind][0], j);
						pos[ind][1] = Math.min(pos[ind][1], i);
						pos[ind][2] = Math.max(pos[ind][2], j);
						pos[ind][3] = Math.max(pos[ind][3], i);
					}
				}
			}
			kind = 0;
			kindchar = new ArrayList<Character>();
			for(int i = 0; i < 26; i++){
				if(freq[i] > 0){
					kindchar.add((char) (i + 'A'));
				}
			}
			kind = kindchar.size();
			order = new int[kind];
			used = new boolean[kind];
			flg = false;
			dfs(0);
			System.out.println(flg ? "SAFE" : "SUSPICIOUS");
		}
	}

	private void dfs(int deep) {
		if(deep == kind){
			if(check()) flg = true;
			return;
		}
		for(int i = 0; i < kind; i++){
			if(used[i]) continue;
			used[i] = true;
			order[deep] = i;
			dfs(deep + 1);
			used[i] = false;
		}
	}

	private boolean check() {
		boolean [] checked = new boolean[26];
		for(int orderi = 0; orderi < order.length; orderi++){
			int nowind = order[orderi];
			char nowchar = kindchar.get(nowind);
			int nowcharind = nowchar - 'A';
			checked[nowcharind] = true;
			
			for(int i = pos[nowcharind][1]; i <= pos[nowcharind][3]; i++){
				for(int j = pos[nowcharind][0]; j <= pos[nowcharind][2]; j++){
					if(data[i][j] == '.') return false;
					if(checked[data[i][j] - 'A'] == false) return false;
				}
			}
		}
		return true;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ld avg = accumulate(all(a), 0) / (ld)n;
    ll res = 1e18;
    for (ll mean = (ll)avg; mean <= 1 + (ll)avg; mean++) {
        ll sum = 0;
        rep(i, n) {
            sum += (a[i] - mean) * (a[i] - mean);
        }
        res = min(res, sum);
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort()
  for i in range(n-1):
    l[i+1]+=l[i]

  # print(l)
  
  ans=n
  c=1
  for i in range(n-1):
    if l[i+1]-l[i]>l[i]*2:
      ans-=c
      c=1
    else:
      c+=1

  return ans

# main()
print(main())


Measured memory_bytes: 17220
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	double X;
	string U;
	while(cin>>N) {
		double ans = 0;
		REP(i, N) {
			cin>>X>>U;
			if(U=="JPY") ans += X;
			else ans += X * 380000;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include "iostream"

using namespace std;

int N, M;
long long int ans1 = 1;
long long int ans2 = 1;

int main(){
	cin >> N >> M;
	if (abs(N - M) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	else {
		for (int i = N; i >= 1; i--) {
			ans1 *= i;
			ans1 %= 1000000007;
		}
		for (int i = M; i >= 1; i--) {
			ans2 *= i;
			ans2 %= 1000000007;
		}
		if (N == M) {
			cout << (ans1*ans2*2) % 1000000007 << endl;
		}
		else {
			cout << (ans1*ans2) % 1000000007 << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    int n, k;
    cin >> n >> k;
    VI v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(ALL(v));
    ll ans = 0;
    rep(i, n)
    {
        ans += v[i] * COM(i, k - 1);
        ans -= v[i] * COM(n - 1 - i, k - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12544
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] abString = sc.nextLine().split(" ");
        int a = Integer.parseInt(abString[0]);
        int b = Integer.parseInt(abString[1]);

        if((a*b) % 2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21332
Var N,i,Max,Min:Integer;
    A:Array[1..100] Of Integer;
Begin
        //Assign(Input,'A.INP'); Reset(Input);
        //Assign(Output,'A.OUT'); Rewrite(Output);
        Readln(N);
        Max:=-1;
        Min:=1001;
        For i:=1 to N Do
                Begin
                Read(A[i]);
                If A[i]>Max Then Max:=A[i];
                If A[i]<Min Then Min:=A[i];
                End;
        Write(Max-Min);
        //Close(Input);
        //Close(Output);
End.


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int q,n;
  cin >> q;
  int i,j,k,l;
  for(i=0;i<q;i++){
    cin >> n;
    int s=0;
    while(n>=10){
      int b = n;
      k=0;
      while(b>=10) {
	b/=10;
	k++;
      }
      b=n;
      n=0;
      for(j=0;j<k;j++){
	int d=10;
	for(l=0;l<j;l++) d*=10;
	if((b/d)*(b%d)>n) n= (b/d)*(b%d);
      }
      
      s++;
    }
    cout << s << endl;
  }
  return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  // static const ll MAX = 100010LL;
  ll N, M, Q, A[60], B[60], C[60], D[60], CUR[20], ans = 0;
  // ll A[MAX], B[MAX];

  void init() {
    scanf("%lld %lld %lld", &N, &M, &Q);
    rep(i, Q) {
      scanf("%lld %lld %lld %lld", A+i, B+i, C+i, D+i);
      A[i]--;
      B[i]--;
    }
  }

  void calc() {
    ll res = 0;
    rep(i, Q) {
      if(CUR[B[i]] - CUR[A[i]] == C[i]) res += D[i];
    }
    ans = max(ans, res);
  }

  void rec(ll cur) {
    if(cur == N) {
      calc();
      return;
    }
    if(cur == 0) {
      rep1c(i, M) {
        CUR[cur] = i;
        rec(cur+1);
      }
    } else {
      REP(i, CUR[cur-1], M+1) {
        CUR[cur] = i;
        rec(cur+1);
      }
    }
  }

  void solve() {
    rec(0);
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>

int main(void){

  int a,b,c,n;

  scanf("%d %d %d", &a,&b,&c);

  if(a>b){
    n=a;
    a=b;
    b=n;
  };

  if(b>c){
    n=b;
    b=c;
    c=n;
  };

  if(a>b){
    n=a;
    a=b;
    b=n;
  };

  printf("%d %d %d", a,b,c);

  printf("\n");
  
  return 0;
  
};

Measured memory_bytes: 600
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 4000 + 20 , inf = 1e9 + 20  ;
int n , a[N] , dp[N][N] , save[2][N][N] ;
bool mark[2][N] ;
char c[N] ;

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

	cin >> n ;

	for (int i = 0 ; i < 2 * n ; i ++)
		cin >> c[i] >> a[i] ;

	for (int i = 0 ; i < 2 * n ; i ++) {
		a[i] -- ;

		bool f ;
		if (c[i] == 'B') f = 1 ;
		else f = 0 ;
	
		mark[f][a[i]] = 1 ;
		
		for (int j = n ; j >= 0 ; j --) {
			save[f][a[i]][j] = save[f][a[i]][j + 1] ;
			if (mark[!f][j]) save[f][a[i]][j] ++ ;
		}
	}

	for (int i = 0 ; i <= n ; i ++)
		for (int j = 0 ; j <= n ; j ++) {
			dp[i][j] = inf ;
		}

	dp[0][0] = 0 ;

	for (int i = 0 ; i <= n ; i ++) {
		for (int j = 0 ; j <= n ; j ++) {
			if (i < n) dp[i + 1][j] = min(dp[i + 1][j] , dp[i][j] + save[0][i][j]) ;
			if (j < n) dp[i][j + 1] = min(dp[i][j + 1] , dp[i][j] + save[1][j][i]) ;
		}
	}

	int ans = dp[n][n] ;

	for (int i = 0 ; i < 2 * n ; i ++)
		for (int j = 0 ; j < i ; j ++)
			if (c[i] == c[j] && a[i] < a[j]) ans ++ ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 100224
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    X = int(input())

    now = 100
    res = 0

    while True:
        res += 1
        now *= 1.01
        now = int(now)
        if now >= X:
            break

    print(res)



main()


Measured memory_bytes: 9104
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        a = l[i]
        b = l[j]
        x = (a+1) - b
        y = (b+1) - a
        z = max(x,y)
        a = j+1
        b = n-1
        c = (a+b) // 2
        while a <= b:
            if l[c] == z:
                a += 1
            elif l[c] > z:
                a = c + 1
            elif l[c] < z:
                b = c - 1
            else:
                pass
            c = (a+b) // 2
        ans += c-j
print(ans)

Measured memory_bytes: 68160
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
A = sorted([(a, p) for p, a in enumerate(A)], reverse=True)


# dp[i][j] := i番目の幼児まで見て、左に詰める選択をj回行った場合のうれしさの最大値
dp = [[0] * (N + 1) for _ in range(N + 1)]
for i, (a, p) in enumerate(A):
    for j in range(i + 1):
        # 左に詰める場合
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (p - j) * a)

        # 右に詰める場合
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + ((N - (i - j) - 1) - p) * a)
#print(dp)
print(max(dp[-1]))


Measured memory_bytes: 99880
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=1;i<=10;i++){
			X = R * X - D;
			Console.WriteLine(X);
		}
		
	}
	long R, D, X;
	public Sol(){
		var d = rla();
		R = d[0]; D = d[1]; X = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int h,w;
  cin>>h>>w;
  string c[2*h];
  REP(i,h){
    cin>>c[2*i];
    c[2*i+1]=c[2*i];
  }
  REP(i,2*h){
    cout<<c[i]<<endl;
  }
  return 0;
}


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

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

using namespace std;

int main(){
	int a,b,c; scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",min(a+b+1,c)+b);
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<valarray>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  for(int d;cin>>d,d;){
    vector<valarray<double> > v;
    for(int i=0;i<d+3;i++){
      valarray<double> va(d+2);
      va[d]=1;
      for(int j=0;j<d;j++){
	va[d-1-j]=va[d-j]*i;
      }
      cin>>va[d+1];
      v.push_back(va);
    }
    double mx=1e9;
    int ans;
    for(int i=0;i<d+3;i++){
      vector<valarray<double> > m=v;
      m.erase(begin(m)+i);
      for(int j=0;j<d+1;j++){
	int x=j;
	for(int k=j;k<d+2;k++){
	  if(fabs(m[k][j])>fabs(m[x][j])){
	    x=k;
	  }
	}
	if(fabs(m[x][j])<1e-5)goto next;
	swap(m[x],m[j]);
	auto a=m[j][j];
	m[j]/=a;
	for(int k=0;k<d+2;k++){
	  if(k!=j){
	    auto a=m[k][j];
	    m[k]-=m[j]*a;
	  }
	}
      }
      if(mx>fabs(m[d+1][d+1])){
	mx=fabs(m[d+1][d+1]);
	ans=i;
      }
    next:
      ;
    }
    cout<<ans<<endl;
  }
}

      

Measured memory_bytes: 1260
import copy
import sys
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    S = read_func().strip()
    if len(S) >= 4 and S[0:4] == "YAKI":
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()

Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



int main()
{
    ll X;
    cin >> X;
    ll m = 100;
    int y = 0;

    while (m < X)
    {
        m += m / 100;
        ++y;
    }
    
    cout << y << endl;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (b - a == c - b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
use std::io::*;
 
fn read_spc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    palindromic_numbers();
}

fn palindromic_numbers() {
    let ab: Vec<i64> = read_spc();
    let a = ab[0];
    let b = ab[1];
    let mut m: i64 = 0;
    for i in a..(b + 1) {
        let mut istr = i.to_string().chars().collect::<Vec<char>>();
        if istr[0] == istr[4] && istr[1] == istr[3] {
            m += 1;
        }
    }
    println!("{}", m);
}

Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

void dfs(int i, int n, int mxChar, const string& s) {
  if (i == n) {
    cout << s << endl;
    return;
  }
  rep(j, mxChar + 1) {    
    string ss(s);
    ss.push_back((char)('a' + j));
    dfs(i + 1, n, j == mxChar ? (mxChar + 1) : mxChar, ss);
  }
}

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

  int n;
  cin >> n;
  dfs(0, n, 0, "");
}

Measured memory_bytes: 1536
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 2345
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 1e9 + 7;
int R, B;
ll c[N][N];
inline void init() {
	c[1][1] = 1;
	for (int i = 2; i <= max(R, B) + 10; ++i) {
		for (int j = 1; j <= i; ++j) {
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % P;
		}
	}
}
inline ll get_c(int n, int m) {
	if (n < 0 || m < 0 || n - m < 0)	return 0;
	return c[n + 1][m + 1];
}

ll f[N][N];
inline void work() {
	for (int s = 0; s <= max(R, B); ++s) {
		ll nw = 1; f[s][0] = 1;
		for (int t = 1; t <= max(R, B); ++t) {
			nw = (nw + get_c(s, t)) % P;
			f[s][t] = (f[s][t - 1] + nw) % P;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= R; ++i) {
		ll res = 1;
		for (int j = 1; j <= R - i; ++j) {
			ll rres = f[j - 1][R - i - j];
			res = (res + rres * get_c(B - 1, j)) % P;
		}
		ans = (ans + res) % P;
	}
	printf("%lld\n", (ans % P + P) % P);
}

int main() {
	read(R), read(B);
	init();
	work();
	return 0;
}



Measured memory_bytes: 63500
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define maxn 100+10
#define mod 1000000007
using namespace std;
long long a[maxn][10][10][10];
int main(){
	int k,m,n;
	scanf("%d",&n);
	if(n==1){printf("4\n");return 0;}
	if(n==2){printf("16\n");return 0;}
	if(n==3){printf("61\n");return 0;}
	for(register int i1=1;i1<=4;i1++)
		for(register int i2=1;i2<=4;i2++)
			for(register int i3=1;i3<=4;i3++)
				a[3][i1][i2][i3]=1;
	a[3][3][1][2]=0;
	a[3][1][3][2]=0;
	a[3][1][2][3]=0;
	for(register int i=4;i<=n;i++){
		for(register int i1=1;i1<=4;i1++){
			for(register int i2=1;i2<=4;i2++){
				for(register int i3=1;i3<=4;i3++){
					for(register int i4=1;i4<=4;i4++){
						if(i2==1 && i3==3 && i4==2)continue;
						if(i1==1 && i3==3 && i4==2)continue;
						if(i2==3 && i3==1 && i4==2)continue;
						if(i2==1 && i3==2 && i4==3)continue;
						if(i1==1 && i2==3 && i4==2)continue;
						(a[i][i2][i3][i4]+=a[i-1][i1][i2][i3])%=mod;
					}
				}
			}
		}
	}
	long long ans=0;
	for(register int i1=1;i1<=4;i1++)
		for(register int i2=1;i2<=4;i2++)
			for(register int i3=1;i3<=4;i3++){
				(ans+=a[n][i1][i2][i3])%=mod;
			}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int selectionSort(int a[],int n){
    int ct=0,i,j,min_index,tmp;
    for(i = 0;i<n-1;i++){
        min_index = i;
        for(j =i;j<n;j++){
            if(a[min_index]>a[j]){
                min_index = j;
            }
        }
        if(i != min_index){
        tmp = a[i];
        a[i] = a[min_index];
        a[min_index]=tmp;
        ct++;
        }
    }
    return ct;
}
int main(){
    int a[100];
    int n,ct,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    ct = selectionSort(a,n);
    for(i =0;i<n-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n%d\n",a[n-1],ct);
    return 0;
}


Measured memory_bytes: 2036