akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
char S[12];
char out[2<<20];
int outsz,Slen;
main()
{
	int N,K;
	scanf("%d%d ",&N,&K);
	gets(S);
	Slen=strlen(S);
	S[Slen++]='\n';
	for(int i=0;i<K;i++)
	{
		memcpy(out+i*Slen,S,Slen);
	}
	outsz=K*Slen;
	N-=K;
	for(int i=0;i<N;i++)
	{
		out[outsz+i*2]='7';
		out[outsz+i*2+1]='\n';
	}
	write(1,out,outsz+N*2);
}

Measured memory_bytes: 2304
fun main(args: Array<String>) {
    val (w,h,x,y) = readLine()!!.split(" ").map { it.toLong() }
    val ans = w*h/2.0
    val ans2 = if(w==x*2 && h == y*2) 1 else 0
    println("$ans $ans2")

}

Measured memory_bytes: 37940
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

int main(){
  string s; cin >> s;
  reverse(all(s));
  int n = s.size();
  int dp[n+1][13] = {};
  dp[0][0] = 1;

  int mul = 1;
  rep(i, n){
    int c;
    if(s[i] == '?') c = -1;
    else c = s[i] - '0';

    rep(j, 10){
      if(c != -1 && j != c) continue;
      rep(k, 13){
        dp[i+1][(j*mul + k)%13] += dp[i][k];
        dp[i+1][(j*mul + k)%13] %= MOD;
      }
    }
    mul *= 10;
    mul %= 13;
  }
  std::cout << dp[n][5] << '\n';
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
 
int isBeautiful(string str){
  int arr[26] = {0};
  for (int i = 0; i < str.length(); i ++){
    arr[str[i] - 'a'] ++;
  }
  for (int i = 0; i < 26; i ++){
    if (arr[i] % 2 != 0){
      return false;
    }
  }
  return true;
}
int main (){
  string str;
  cin >> str;
  if (isBeautiful(str)){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

Measured memory_bytes: 3076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	int x = 1;
	int a;
	Rep(n){
		cin >> a;
		if(a == x){
			x++;
		}
	}
	cout << ((x==1) ? -1 : n-x+1) << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
     
    int main(){
    	int x,y;
    	scanf("%d %d",&x,&y);
    	int a,f=0;
    	for(a=0;a<=x;a++){
    		int z=x+a;
    		if(y==2*z){
    			f++;
    			break;
    		}
    	}
    	if(f>0) printf("Yes\n");
    	else       printf("No\n");
    	return 0;
    }

Measured memory_bytes: 2064
#include<iostream>
#include<algorithm>
using namespace std;int main(){int n,k[100];while(cin>>n){int ans=0;for(int i=0;i<n;i++)cin>>k[i];sort(k,k+n);for(int i=0;i<n;i++)ans+=k[i]*(n-i);cout<<ans<<endl;}return 0;}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	double s = 0;
	for (int i = 0; i < n; i++) {
		double a; cin >> a;
		s += 1. / a;
	}
	printf("%.10f\n", 1./s);
	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    if (d == 0) {
        printf("%.10lf\n", (1.0)/n*(m-1));
    }
    else {
        printf("%.10lf\n", (2.0 * (n - d) * (m - 1) / (n * n)));
    }
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
A = tuple(tuple(map(int, input().split())) for _ in range(H))
B = tuple(tuple(map(int, input().split())) for _ in range(H))
table = [0] * W
table[0] = 1 << 6400
for i in range(H):
    for j in range(W):
        shamt = abs(A[i][j] - B[i][j])
        if j > 0:
            table[j] |= table[j - 1]
        table[j] = (table[j] << shamt) | (table[j] >> shamt)
dl = dr = 1 << 6400
for i in range(6401):
    if table[W - 1] & (dl | dr):
        print(i)
        break
    dl <<= 1
    dr >>= 1

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

int main(void){
    long long int i, j, n, k, ans=0, po=7;
    scanf("%lld", &k);
    for(i=1; i<=k; i++){
        po = po%k;
        if(po==0){
            ans = i;
            break;
        }
        po = po*10+7;
    }
    if(ans==0) printf("-1");
    else printf("%lld", ans);
    
    
    
}

Measured memory_bytes: 1696
#include <iostream>
#include <stack>
#include <functional>
#include <climits>
using namespace std;

int main() {
    int n;
    cin >> n;
    string graph[n];
    for (int i = 0; cin >> graph[i]; i++) {
    }
    auto bipartite = [&]() {
        int color[n] = {};
        color[0] = 1;
        stack<int> stack;
        stack.emplace(0);
        do {
            auto top = stack.top();
            stack.pop();
            for (int i = 0; i < n; i++) {
                if (graph[top][i] == '1') {
                    if (color[i] == 0) {
                        color[i] = 3 - color[top];
                        stack.emplace(i);
                    } else if (color[i] == color[top]) {
                        return false;
                    }
                }
            }
        } while (!stack.empty());
        return true;
    };
    if (!bipartite()) {
        cout << -1;
    } else {
        int diameter = 0, dist[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (graph[i][j] == '1') {
                    dist[i][j] = 1;
                } else {
                    dist[i][j] = INT_MAX;
                }
            }
            dist[i][i] = 0;
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (dist[i][j] - dist[i][k] > dist[k][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }
        for (int i = 0; i <  n; i++) {
            for (int j = 0; j < n; j++) {
                diameter = max(diameter, dist[i][j]);
            }
        }
        cout << diameter + 1;
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define N 200100
#define M 1000000007
using namespace std;

ll n,m,mx,ans,dp[N],qz[N];
char str[N];

inline void Add(ll &u,ll v){u=(u+v)%M;}
int main()
{
	ll i,j,t;
	cin>>n>>m;
	scanf("%s",str+1);
	for(i=1;i<=m;i++) if(str[i]!=str[1]) break;
	mx=i-1;
	if(mx==m)
	{
		dp[0]=qz[0]=ans=1;
		for(i=0;i<=n;i++)
		{
			if(i>=2) dp[i]=qz[i-2];
			qz[i]=(qz[i-1]+dp[i])%M;
			if(n-i>=2) Add(ans,dp[i]*(n-i)%M);
		}
		cout<<ans;
		return 0;
	}
	if(n&1)
	{
		puts("0");
		return 0;
	}
	if(mx%2==0) mx++;
	for(t=0;i<=m;i++)
	{
		if(str[i]==str[1]) t++;
		else
		{
			if(t&1) mx=min(mx,t);
			t=0;
		}
	}
	n/=2,mx=(mx+1)/2;
	dp[0]=qz[0]=1;
	for(i=0;i<=n;i++)
	{
		if(i)
		{
			dp[i]=(M+qz[i-1]-(i-mx-1>=0?qz[i-mx-1]:0))%M;
			qz[i]=(qz[i-1]+dp[i])%M;
		}
		if(n-i<=mx) Add(ans,(n-i)*dp[i]*2%M);
	}
	cout<<ans;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,m,a[N],tot,head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);add(u,v);add(v,u);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        bool flag=true;
        for(int j=head[i];j;j=nex[j])
        {
            if(a[to[j]]>=a[i]) flag=false;
        }
        ans+=flag;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 6172
#include<bits/stdc++.h>
using namespace std;
int bord[101][101]={},playx[2],playy[2];
int movex[]={1,0,-1,0},movey[]={0,1,0,-1};
int serch(int x,int y,int color)
{
    if(color==0)return 0;
    int now=0;
    bord[y][x]=0;
    if(x==playx[1]&&y==playy[1])return 1;
    for(int i=0;i<4&&now==0;i++){
        if(bord[movey[i]+y][movex[i]+x]==color)now=serch(movex[i]+x,movey[i]+y,color);
    }
    return now;
}
int main()
{
    int  h,w;
    while(cin>>h>>w,h,w){
        for(int i=0;i<=h+1;i++){
                for(int j=0;j<=w+1;j++){
                        bord[i][j]=0;
                }
        }
        for(int i=0;i<2;i++)cin>>playx[i]>>playy[i];
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            int co,mu,x,y;
            cin>>co>>mu>>x>>y;
            for(int j=0;j<4;j++){
                if(mu==1){
                    bord[y+j][x]=co;
                    bord[y+j][x+1]=co;
                }
                else{
                    bord[y][x+j]=co;
                    bord[y+1][x+j]=co;
                }
            }
        }
        if(serch(playx[0],playy[0],bord[playy[0]][playx[0]]))cout<<"OK\n";
        else cout<<"NG\n";
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

ll mod = 1e9 + 7;

ll modpow(ll a ,ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n = n >> 1;
    }
    return res;
}

//aのmod mにおける逆元を求める
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll nCa = 1, nCb = 1;
    for(int i=0;i<a;i++){
        nCa *= n-i;
        nCa %= mod;
    }
    for(int i=1;i<=a;i++){
        nCa *= modinv(i, mod);
        nCa %= mod; 
    }
    for(int i=0;i<b;i++){
        nCb *= n-i;
        nCb %= mod;
    }
    for(int i=1;i<=b;i++){
        nCb *= modinv(i, mod);
        nCb %= mod; 
    }

    //cout << modpow(2, n) << " " << nCa << " " << nCb << endl;
    cout << (modpow(2, n) - 1 - nCa - nCb + 2*mod)%mod << endl;

}

Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }


ll N, M, L, A[112345], B[112345], C[112345], Q, s[112345], t[112345];
vector<vector<pair<ll, ll>>> Edge;

int main() {

	scanf("%lld%lld%lld", &N, &M, &L);
	rep(i, M) scanf("%lld%lld%lld", &A[i], &B[i], &C[i]);
	scanf("%lld", &Q);
	rep(i, Q) scanf("%lld%lld", &s[i], &t[i]);

	Edge.resize(N);
	rep(i, M) {
		Edge[A[i] - 1].push_back({ B[i] - 1, C[i] });
		Edge[B[i] - 1].push_back({ A[i] - 1, C[i] });
	}

	vector<vector<pair<ll, ll>>> costs(N, vector<pair<ll, ll>>(N, { 9223372036854775807, -L })); //times, l
	rep(i, N) {
		priority_queue<pair<pair<ll, ll>, ll>, vector<pair<pair<ll, ll>, ll>>, greater<>> pq;
		pq.push({ {0, -L}, i });
		costs[i][i] = { 0, -L };
		while (!pq.empty()) {
			auto cur = pq.top().second;
			pq.pop();

			for (auto e : Edge[cur]) {
				auto n = costs[i][cur];
				if (n.second + e.second > 0) {
					++n.first;
					n.second = -L + e.second;
					if (n.second > 0) continue;
				}
				else {
					n.second += e.second;
				}
				if (costs[i][e.first] > n) {
					costs[i][e.first] = n;
					pq.push({ n, e.first });
				}
			}
		}
	}

	rep(q, Q) {
		if (costs[s[q] - 1][t[q] - 1].first != 9223372036854775807)
			printf("%lld\n", costs[s[q] - 1][t[q] - 1].first);
		else
			printf("-1\n");
	}

	return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll comb[55][55];

ll get_comb(ll a, ll b){
  if(comb[a][b]>0) return comb[a][b];
  if(a==b || b==0) return comb[a][b] = 1;
  return comb[a][b] = get_comb(a-1, b-1) + get_comb(a-1, b);
}

int main() {
  for(int i=0;i<55;++i){
    for(int j=0;j<=i;++j){
      get_comb(i, j);
    }
  }
  int N, P;
  cin>>N>>P;
  ll even=0, odd=0;
  int A;
  for(int i=0;i<N;++i){
    cin>>A;
    if(A%2==0) even++;
    else odd++;
  }
  ll ans = 1;
  ll tmpans = 0;
  for(int i=0;i<even;++i) ans *= 2;
  if(P==0){
    for(int i=0;i<=odd;i+=2){
      tmpans += comb[odd][i];
    }
  }
  else{
    for(int i=1;i<=odd;i+=2){
      tmpans += comb[odd][i];
    }
  }
  cout<<ans*tmpans<<endl;
}



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

string st;


vector<vector<int>>make(int pr) {
	vector<vector<int>>ans(pr*(pr + 1)+1, vector<int>(pr+1));
	for (int i = 0; i <= pr; ++i) {
		ans[i][0] = 1;
		for (int j = 0; j < pr; ++j) {
			int num = pr*i+j + 2;
			ans[i][j + 1] = num;
		}
	}
	for (int team = 2; team <= 1 + pr; ++team) {
		for (int i = 0; i < pr; ++i) {
			int id = (team-1)*pr + 1+i;
			ans[id][0] = team;
			int now = i;
			for (int j = 0; j < pr; ++j) {
				now += (team - 2);
				now %= pr;
				int num = (j + 1)*pr + 2 + now;
				ans[id][j + 1] = num;
			}
		}
	}
	return ans;
}
bool  check(vector<vector<int>>v) {
	for (int i = 0; i < v.size(); ++i) {
		for (int j = i + 1; j < v.size(); ++j) {
			auto aa(v[i]);
			auto bb(v[j]);
			int num = 0;
			for (int k = 0; k < aa.size(); ++k) {
				for (int l = 0; l < bb.size(); ++l) {
					if (aa[k] == bb[l])num++;
				}
			}
			if (num != 1) {
				return false;
			}
		}
	}
	return true;
}
int main() {  
	int pr = 37;
	auto vs(make(pr));
	auto aaa(check(vs));
	cout << vs.size() << " " << vs[0].size() << endl;
	for (int i = 0; i < vs.size(); ++i) {
		for (int j = 0; j < vs[i].size(); ++j) {

			cout << vs[i][j];
			if (j == vs[i].size() - 1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <cstdint>
#include <array>

using namespace std;


typedef std::array<uint32_t, 2> Idx;

uint32_t checkAndSetIdx(vector<string>& mp, vector<Idx>& stack, uint32_t i, uint32_t j)
{
    if(i > mp.size()-1 || j > mp.at(0).size()-1)
        return 0;

    if(mp[i][j] == '.'){
        mp[i][j] = 'x';
        Idx e = {i, j};
        stack.push_back(e);
        return 1;
    }

    return 0;
}


int main()
{
    while(1)
    {
        uint32_t h, w;
        cin >> w >> h;

        if(w == 0 && h == 0)
            break;


        Idx iniPos;

        vector<string> mp;
        for(uint32_t i = 0; i < h; ++i){
            mp.push_back([](){string str; cin >> str; return str;}());

            for(uint32_t j = 0; j < w; ++j){
                if(mp[i][j] == '@'){
                    Idx e = {i, j};
                    iniPos = e;
                    mp[i][j] = 'x';
                }
            }
        }


        vector<Idx> stack;
        stack.push_back(iniPos);
        uint32_t cnt = 1;


        while(stack.size() != 0){
            auto nowPos = stack.at(stack.size() - 1);
            stack.pop_back();
            const auto i = nowPos[0],
                       j = nowPos[1];

            cnt += checkAndSetIdx(mp, stack, i+1, j);
            cnt += checkAndSetIdx(mp, stack, i-1, j);
            cnt += checkAndSetIdx(mp, stack, i, j+1);
            cnt += checkAndSetIdx(mp, stack, i, j-1);
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
        }
    }
    vector<bool> col(W, false), row(H, false);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (a[i][j] == '#') col[j] = true, row[i] = true;
        }
    }
    for (int i = 0; i < H; ++i) {
        if (row[i]) {
            for (int j = 0; j < W; ++j) {
                if (col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll P;
//累乗(aのk乗)
ll matpow(ll a,ll k){
    ll dp=1,mt=a;
    while(k>0){
        if(k & 1)dp=(dp*mt)%P;
        mt=(mt*mt)%P;
        k/=2;
    }
    return dp;
}

int main(){
    int N;cin>>N>>P;
    string S;cin>>S;
    if(P==2 || P==5){
        ll ans=0;
        for(int i=0;i<N;i++){
            int a=S[i]-'0';
            if(a%P==0) ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    vec A(200010);A[0]=0;
    map<int,ll> mp;mp[0]++;
    for(int i=0;i<N;i++){
        ll a=S[i]-'0';
        A[i+1]=(10*A[i])%P;
        A[i+1]=(A[i+1]+a)%P;
        ll k=(ll)300000*(P-1)-1-i;
        ll X=(A[i+1]*matpow(10,k))%P;
        mp[X]++;
    }
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ans+=(itr->second*(itr->second-1))/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2564
n = int(raw_input())

matrix = [[100001 for i in range(n)] for j in range(n)]

for i in range(n):
    line = raw_input()
    splited = line.split()
    splited = map(lambda x: int(x), splited)
    u = splited[0]
    k = splited[1]
    for j in range(k):
        matrix[u][splited[2 + j * 2]] = splited[2 + j * 2 + 1]

cost = [10000000000 for i in range(n)]
selected = []
now_node = 0
cost[now_node] = 0
while len(selected) != n + 1:
    selected.append(now_node)

    for (i, item) in enumerate(matrix[now_node]):
        if item < 100001 and cost[i] > item + cost[now_node] and cost[i] != -1:
            cost[i] = item + cost[now_node]
    now_node = -1
    for (i, item) in enumerate(cost):
        if i not in selected and now_node == -1:
            now_node = i
        elif i not in selected and item < cost[now_node]:
            now_node = i

for (i, item) in enumerate(cost):
    print i, item

Measured memory_bytes: 6476
#include<stdio.h>

int main (void)

{
	int i;
	int j;
	
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return(0);
}

Measured memory_bytes: 524
n = int(input())
t = list(map(int,input().split()))
a = list(map(int,input().split()))
if n == 1:
    if t[0] == a[0]:
        print(1)
    else:
        print(0)
elif n == 2:
    if t[0] >= a[1]:
        if t[0] == t[1] and a[0] >= a[1]:
            if t[0] == a[0]:
                print(1)
            else:
                print(0)
        else:
            print(0)
    else:
        if t[0] < t[1] and a[0] == a[1] and a[1] == t[1]:
            print(1)
        else:
            print(0)
else:
    mod = 10**9 + 7
    ans = 1
    for i in range(1,n-1):
        if t[i-1] == t[i]:
            if a[i+1] == a[i]:
                ans = (ans*(min((a[i],t[i]))%mod)) % mod
            else:
                if a[i] > t[i]:
                    ans = 0
                    break
        else:
            if a[i] < t[i]:
                ans = 0
                break
    if t[0] > a[0] or t[n-1] < a[n-1]:
        ans = 0
    print(ans)

Measured memory_bytes: 18752
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s[n];
    int left[n], right[n];
    int suml = 0, sumr = 0;
    rep(i,n){
        cin >> s[i];
        int m = s[i].size();
        int l = 0, r = 0;
        drep(j,m){
            if(s[i][j] == ')') l++;
            else l = max(0, l-1);
        }
        rep(j,m){
            if(s[i][j] == '(') r++;
            else r = max(0, r-1);
        }
        left[i] = l;
        right[i] = r;
        suml += l;
        sumr += r;
        // cout << left[i] << ' ' << right[i] << endl;
    }
    if(suml != sumr){
        cout << "No" << endl;
        return 0;
    }

    vector<P> u,v;
    int max_equal = 0;
    rep(i,n){
        
        if(left[i] < right[i]) u.push_back(P(left[i], right[i]));
        if(right[i] < left[i]) v.push_back(P(right[i], left[i]));
        if(left[i] == right[i]) max_equal = max(max_equal, left[i]);
    }
    sort(v.begin(), v.end());
    sort(u.begin(), u.end());

    int now = 0;
    rep(i,u.size()){
        if(u[i].first > now){
            cout << "No" << endl;
            return 0;
        }
        now += u[i].second - u[i].first;
    }
    if(now < max_equal){
        cout << "No" << endl;
        return 0;
    }
    now = 0;
    rep(i,v.size()){
        if(v[i].first > now){
            cout << "No" << endl;
            return 0;
        }
        now += v[i].second - v[i].first;
    }
    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 50188
import Text.Printf

main :: IO ()
main = getContents >>= mapM_ (printf "%.8f\n" . sd . map read . words) . pick . init . lines
    where pick ss = [s | (i,s) <- zip [1..] ss, even i]

sd :: [Double] -> Double
sd xs = sqrt v
    where v = sum (map ((^2) . subtract m) xs) / n
          m = sum xs / n
          n = fromIntegral (length xs)


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	s[5] = ' ';
	s[13]= ' ';
	cout<<s;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    //freopen("d:\\input.txt","r",stdin);
    int n,arr[11000];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++) cin>>arr[i];
        sort(arr+1,arr+n+1);
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=i;j++)
                sum+=arr[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int d, t, s;
    cin >> d >> t >> s;
    if ( (d+s-1)/ s > t ) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0;i<n;i++) {
    int a;
    cin >> a;
    int times = 0;
    while(a % 2 == 0) {
      a /= 2;
      times++;
    }
    ans += times;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STR(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define ENDFOR(i) goto i##_3;i##_1:0

int main(){
	int m, n;
	scanf("%d%d", &n, &m);
	printf("%d\n", (1 << m) * (m * 1800 + n * 100));
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100200][3], dp[100200][3];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				dp[i+1][k] = max(dp[i][j] + a[i][k], dp[i+1][k]);
			}
		}
	}
	printf("%d\n", *max_element(dp[n], dp[n] + 3));
	return 0;
}


Measured memory_bytes: 2560
def otoshidama(nos, amt):
    
    for x in range(0, amt//10000+1):
        for y in range(0, (amt-(10000*x))//5000+1):
            if 10000*x + 5000*y + 1000*(nos-x-y) == amt:
                return (x, y, nos-x-y)
    
    return (-1, -1, -1)

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

print(*otoshidama(n, y))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt().ToString();

            Console.WriteLine(N[0] == N[2] ? "Yes" : "No");
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
long long N;

void func(long long result, int bit, long long& count) {
    // 全探索のキモ
    // ベースケースの設定(Nより大きくないとか),参照渡し(countし続ける),
    // 樹形図を書くときの分岐条件を雑に置いておく(7, 5, 3を足すとか)

    if (result > N) {
        return;
    }

    if (bit == 0b111) {
        ++count;
    }
    // bit | 0b001はbit演算のORである
    // 数字の中に7, 5 ,3が含まれているか確認がしやすい
    // 別に配列で数字を使ったかを確認できるけど

    // add 3
    func(result * 10 + 3, bit | 0b001, count);

    // add 5
    func(result * 10 + 5, bit | 0b010, count);

    // add 7
    func(result * 10 + 7, bit | 0b100, count);

}

int main() {
    cin >> N;
    long long count = 0;
    func(0, 0, count);
    cout << count << endl;
}


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

int main() {
    ll h,w;
    std::cin >> h>>w;
    
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    
    vector<vector<vector<ll>>> dp(h,vector<vector<ll>>(w,vector<ll>(2,1e18)));
    if(s[0][0]=='.'){
        dp[0][0][0] = 0;
    }else{
        dp[0][0][1] = 1;
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(i==0&&j==0)continue;
            if(s[i][j]=='.'){
                auto &d = dp[i][j][0];
                if(i>0) d = min(dp[i-1][j][0],dp[i-1][j][1]);
                if(j>0) d = min(d,min(dp[i][j-1][0],dp[i][j-1][1]));
            }else{
                auto &d = dp[i][j][1];
                if(i>0) d = min(dp[i-1][j][0]+1,dp[i-1][j][1]);
                if(j>0) d = min(d,min(dp[i][j-1][0]+1,dp[i][j-1][1]));
            }

        }
    }
    std::cout << dp[h-1][w-1][s[h-1][w-1]!='.'] << std::endl;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M = 0, L, K, P = 0, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

ll count(int n, vector<ll> &a) {
    ll cnt = 0;
    if (n >= 0) {
        REP(i, a.size()) {
            ll tmp = 0;
            if (a[i] == 0) {
                continue;
            }
            if (a[i] > 0) {
                tmp = n / a[i];
                ll hoge = upper_bound(a.begin(), a.end(), tmp) - a.begin();
                cnt += P - (a.size() - hoge);
                if (i < hoge) {
                    cnt--;
                }
                dump(i, a[i], hoge, P - (a.size() - hoge));
            } else {
                tmp = n / a[i];
                ll hoge = lower_bound(a.begin(), a.end(), tmp) - a.begin();
                dump(i, a[i], hoge, M - hoge);
                cnt += M - hoge;
                if (hoge <= i) {
                    cnt--;
                }
            }
        }
        cnt = cnt / 2 + M * P;
        ll zeroN = a.size() - M - P;
        cnt += zeroN * (zeroN - 1) / 2 + zeroN * (M + P);
    } else {
        REP(i, a.size()) {
            if (a[i] < 0) {
                ll tmp = intceil(-n, -a[i]);
                ll hoge = lower_bound(a.begin(), a.end(), tmp) - a.begin();
                cnt += a.size() - hoge;
            }
        }
    }
    dump(n, cnt, a);
    return cnt;
}

bool isOK(int n, int key, vector<ll> &a) {
    ll c = count(n, a);
    if (c >= key)
        return true;
    else
        return false;
}
int binary_search(int key, vector<ll> &a) {
    int ng = -LLINF; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = LLINF;  // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOK(mid, key, a))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

signed main() {
    cin >> N >> K;
    vector<ll> a(N);
    cin >> a;
    sort(ALL(a));
    REP(i, a.size()) {
        if (a[i] < 0) {
            M++;
        } else if (a[i] > 0) {
            P++;
        }
    }
    //count(7, a);
    cout << binary_search(K, a) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct RollingHash{
  const int base1 = 1e3+7, base2 = 1e3+9;
  const int mod1 = 1e9+7, mod2 = 1e9+9;
  vector<int> hash1, hash2, pow1, pow2;

  RollingHash(string s){
    int n = s.size();
    hash1.assign(n+1, 0); hash2.assign(n+1, 0); pow1.assign(n+1, 1); pow2.assign(n+1, 1);
    for(int i = 0; i < n; ++i){
      hash1[i+1] = (hash1[i] * base1 + s[i]) % mod1;
      hash2[i+1] = (hash2[i] * base2 + s[i]) % mod2;
      pow1[i+1] = (pow1[i] * base1) % mod1;
      pow2[i+1] = (pow2[i] * base2) % mod2;
    }
  }

  pair<int, int> getval(int l, int r){
    int res1 = (hash1[r] - hash1[l] * pow1[r-l] % mod1 + mod1) % mod1;
    int res2 = (hash2[r] - hash2[l] * pow2[r-l] % mod2 + mod2) % mod2;
    return {res1, res2};
  }

  int getlcp(int a, int b){
    int left = 0, right = hash1.size() - max(a, b);
    while(right - left > 1){
      int mid = (left + right) / 2;
      (getval(a, a + mid) != getval(b, b + mid) ? right : left) = mid;
    }
    return left;
  }
};

signed main(){

  int n; cin >> n;
  string s; cin >> s;

  RollingHash rh(s);
  auto f = [&](int mid){
    map<pair<int ,int>, int> mp;
    for(int i = 0; i + mid <= n; i++){
      auto p = rh.getval(i, i + mid);
      if(mp.count(p)){
        if(i - mp[p] >= mid) return true;
      }else {
        mp[p] = i;
      }
    }
    return false;
  };

  int left = -1, right = n;
  while(right - left > 1){
    int mid = (left + right) / 2;
    (!f(mid) ? right : left) = mid;
  }
  cout << left << endl;

  return 0;
}


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

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

long long n, h, w;
vector<P> v;

long long solve();

int main() {
  cin >> h >> w >> n;
  v.resize(n);
  for (auto &p : v) {
    cin >> p.second >> p.first;
    --p.first, --p.second;
  }
  for (int i = 0; i < w; ++i) v.emplace_back(i, h);
  n = v.size();
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 1e10, x = 0;
  for (int i = 0, id = 0; i < w && x < h; ++i) {
    while (id < n && v[id].first == i) res = min(res, v[id++].second);
    while (id < n && v[id].first == i + 1 && x + 1 >= v[id].second)
      if (x + 1 == v[id++].second) ++x;
    ++x;
  }
  return res;
}

Measured memory_bytes: 12088
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int tmpH;
        int ans=0;
        int maxH=0;
        for(int i=0;i<n;i++){
            tmpH=sc.nextInt();
            if(tmpH>=maxH){
                ans++;
            }
            if(tmpH>maxH){
                maxH=tmpH;
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int n,m,tmp;
char bo[110][110];
int boo[110][110];
int nx[]={1,1,1,0,0,-1,-1,-1},ny[]={1,0,-1,1,-1,1,0,-1};
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            cin>>bo[i][j];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(bo[i][j]=='#'){
                continue;
            }
            int tmp=0;
            for(int k=0;k<8;++k){
                if(bo[i+nx[k]][j+ny[k]]=='#'){
                    ++tmp;
                }
            }
            boo[i][j]=tmp;
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(bo[i][j]=='#'){
                cout<<'#';
            }else{
                cout<<boo[i][j];
            }
        }
        cout<<endl;
    }
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

int main() {
	fastio;
	ll n, k; cin >> n >> k;
	
	ll q1, q2;
	q1 = (n/k), q2 = (n/k) + 1;
	
	ll ans1 = abs(n - (q1 * k)), ans2 = abs(n - (q2 * k));

	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    ll r,d,x;
    ll pre;
    cin >> r>>d>>x;
    pre=x;
    
    rep(i,10){
        cout <<r*pre-d<<endl;
        pre=r*pre-d;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout <<a[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}
/*bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}*/
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first>y.first;
}*/
int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    while(T--)
    {
        sieve();
        int n,i,j;
        cin>>n;
        int a[n],b[n];
        set<int> s;
        bool f=true;
        for(i=0;i<n;i++)
        {
            cin>>a[i];b[i]=a[i];
        }
        map<int,int> m;
        for(i=0;i<n;i++)
        {
            for(j=2;j*j<=a[i];j++)
            {
                if(a[i]%j==0)
                {
                    if(m[j])
                    {
                        f=false;break;
                    }
                    while(a[i]%j==0)
                    {
                        a[i]/=j;
                        m[j]++;
                    }
                }
            }
            if(a[i]>1)
            {
                if(m[a[i]])
                {
                    f=false;
                }
                else
                {
                    m[a[i]]++;
                }
            }
            if(!f)break;
        }
        int p=__gcd(b[0],b[1]);
        for(i=2;i<n;i++)
        {
            p=__gcd(p,b[i]);
        }
        if(f)
        {
            cout<<"pairwise coprime\n";
        }
        else if(p==1)
        {
            cout<<"setwise coprime\n";
        }
        else cout<<"not coprime\n";
    }
    return 0;
}


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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    #define fast   ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
    using namespace std;
    ll graph[22][22];
    ll dp[22][1<<22];
    ll dfs(int i, int n, int mask)
    {
        if(i>n)
            return 0;
        if(mask == (1<<n)-1)
            return 1;

        if(dp[i][mask]!=-1)
            return dp[i][mask];
        ll ans =0;
        for(int j=0; j<n; j++)
        {
            if(graph[i][j]==1 && !(mask & (1<<j)))
            {
                ans = (ans + dfs(i+1, n, (mask | 1<<j)))%M;
            }
        }
        //cout<<i<<" "<<mask<<" "<<ans<<"\n";
        return dp[i][mask] = ans%M;
    }
    int main()
    {
            fast
         int n;
         cin>>n;
         for(int i=0; i<n; i++)
         {
             for(int j=0; j<n; j++)
             {
                 cin>>graph[i][j];
             }
         }
         int mask=0;
         memset(dp,-1,sizeof(dp));
         cout<<dfs(0,n,mask);

        return 0;

    }



Measured memory_bytes: 724504
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;

ll gcd(ll a, ll b){
	if(a==0) return b;
	return gcd(b%a, a);
}

int main(){
	IOS
	ll k, sums=0;
	cin >> k;
	for(ll i=1;i<=k;i++){
		for(ll j=1;j<=k;j++){
			for(ll l=1;l<=k;l++){
				sums+=gcd(i, gcd(j, l));
			}
		}
	}
	cout << sums << '\n';
}

Measured memory_bytes: 3616
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import statistics

# qsort(array[])
def qsort(seq):
	if len(seq) < 1:
		return seq
	pivot = seq[0]
	left = []
	right = []
	for x in range(1, len(seq)):
		if seq[x] <= pivot:
			left.append(seq[x])
		else:
			right.append(seq[x])
	left = qsort(left)
	right = qsort(right)
	foo = [pivot]
	return (left + foo + right)

# , = map(int, input.split())
n = int(input())
#  = raw_input().split()
#  = list(int(i) for i in input().split())  
a = []

for i in range(n):
  num = int(input())
  a.append(num)

sla = sorted(a)
for i in range(n):
	if a[i] == sla[-1]:
		print(sla[-2])
	else:
		print(sla[-1])

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  string s; cin >> s;
  int a = 0;
  REP(i,s.size()) {
    if(i%2) {
      if(s[i] == '1') ++a;
    } else {
      if(s[i] == '0') ++a;
    }
  }
  int b = 0;
  REP(i,s.size()) {
    if(i%2) {
      if(s[i] == '0') ++b;
    } else {
      if(s[i] == '1') ++b;
    }
  }
  cout << min(a,b);
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512