akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define inc(i, n)  incID(i, 0, n)
#define FI first
#define SE second

// ---- ----

const int MOD = 998244353;

int n, BIT[200001];
pair<int, int> p[200000];
LL e2[200001];

int  sum(int i) { int s = 0; for(i++; i     ; i -= i & -i) { s += BIT[i]; } return s; }
void add(int i) {            for(i++; i <= n; i += i & -i) { BIT[i]++; } }

int main() {
	cin >> n;
	inc(i, n) { scanf("%d %d\n", &p[i].FI, &p[i].SE); }
	sort(p, p + n);
	inc(i, n) {
		p[i].FI = p[i].SE;
		p[i].SE = i;
	}
	sort(p, p + n);
	
	e2[0] = 1;
	inc(i, n) {
		e2[i + 1] = e2[i] << 1;
		if(e2[i + 1] >= MOD) { e2[i + 1] -= MOD; }
	}
	
	LL s = 0;
	inc(i, n) {
		int j = p[i].SE;
		
		int v = sum(j);
		add(j);
		LL a = e2[v];
		LL b = e2[i - v];
		LL c = e2[j - v];
		LL d = e2[n - 1 - (i + j - v)];
		s += (a + d - 1) * (b + c - 1) % MOD;
	}
	LL ans = (n * e2[n] - s) % MOD;
	if(ans < 0) { ans += MOD; }
	
	printf("%lld\n", ans);
	
	return 0;
}


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

#define MAXN 200005

using namespace std;

int n, s, t, ans;

struct graph {
    vector<int> g[MAXN];
    int fa[MAXN][19], dep[MAXN];
    
    void connect(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    void build(int u = s, int pre = 0) {
        fa[u][0] = pre;
        dep[u] = dep[pre] + 1;
        for (int i = 1; i <= 18; ++i)
            fa[u][i] = fa[fa[u][i - 1]][i - 1];
        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (v == pre)
                continue;
            build(v, u);
        }
    }
    
    int query(int u, int v) {
        if (dep[u] < dep[v])
            swap(u, v);
        for (int i = 18; i >= 0; --i)
            if (dep[fa[u][i]] >= dep[v])
                u = fa[u][i];
        if (u == v)
            return u;
        for (int i = 18; i >= 0; --i)
            if (fa[u][i] != fa[v][i]) {
                u = fa[u][i];
                v = fa[v][i];
            }
        return fa[u][0];
    }
    
    int calc(int u, int v) {
        return dep[u] + dep[v] - dep[query(u, v)] * 2;
    }
}A, B;


int read() {
    char c = getchar();
    int x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

bool DFS(int u, int pre) {
    if (A.dep[u] - 1 >= B.calc(t, u))
        return false;
    for (int i = 0; i < (int)A.g[u].size(); ++i) {
        int v = A.g[u][i];
        if (v == pre)
            continue;
        if (B.calc(u, v) > 2 || DFS(v, u))
            return true;
    }
    return false;
}

void find(int u, int pre) {
    if (A.dep[u] - 1 > B.calc(t, u))
        return ;
    ans = max(ans, B.calc(t, u) * 2);
    for (int i = 0; i < (int)A.g[u].size(); ++i) {
        int v = A.g[u][i];
        if (v == pre)
            continue;
        find(v, u);
    }
}

int main() {
//    freopen("giri4.in", "r", stdin);
    n = read();
    s = read();
    t = read();
    for (int i = 1; i < n; ++i)
        A.connect(read(), read());
    for (int i = 1; i < n; ++i)
        B.connect(read(), read());
    A.build();
    B.build();
    bool isinfinity = DFS(s, 0);
    if (isinfinity)
        puts("-1");
    else {
        find(s, 0);
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 61180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, check = 0; 
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < (N - 1); i++) {
	if (a.at(i) == a.at(i + 1)) {
        cout << "NO" << endl;
        check = 1;
        break;
    }
  }
  if (check == 0) {
	cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define ll long long 
#define pii pair<int,int>
#define fi first
#define se second
#define bg begin
cs int RLEN=(1<<20)|3;
inline char gc(){
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;
}
inline ll readll(){
	char ch=gc();
	ll res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;	
}
inline int readstring(char *s){
	char ch=gc();int l=0;
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++l]=ch,ch=gc();
	return l;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();return ch;
}
template<typename tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<typename tp>inline void chemn(tp &a,tp b){a<b?a=b:0;}
cs int N=200005;
struct node{
	int a,b,id;
	node(int x=0,int y=0,int z=0):a(x),b(y),id(z){}
	friend inline node operator +(cs node &a,cs node &b){return node(a.a+b.a,a.b+b.b,a.id);}
	friend inline bool operator <(cs node &a,cs node &b){
		if((ll)a.a*b.b==(ll)a.b*b.a)return (a.id==b.id?(a.a==b.a?a.b<b.b:a.a<b.a):a.id<b.id);
		return ((ll)a.b*b.a<(ll)a.a*b.b);
	}
//	friend inline bool operator >(cs node &a,cs node &b){
//		return ((ll)a.a*b.b==(ll)a.b*b.a)?(a.id>b.id):((ll)a.a*b.b>(ll)a.b*b.a);
//	}
	friend inline bool operator ==(cs node &a,cs node &b){
		return a.a==b.a&&a.b==b.b&&a.id==b.id;
	}
}a[N];
struct heap{
	priority_queue<node>a,b;
	void push(node x){a.push(x);}
	void erase(node x){b.push(x);}
	node top(){while(b.size()&&a.top()==b.top())a.pop(),b.pop();return a.top();}
}q;
int fa[N],p[N],n;
inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read();fa[1]=1;
	for(int i=2;i<=n;i++)p[i]=read(),fa[i]=i;
	for(int i=1;i<=n;i++){
		int t=read();
		if(t==1)a[i].a=1;
		else a[i].b=1;a[i].id=i;
		if(i>1)q.push(a[i]);
	}ll res=0;
	for(int i=2;i<=n;i++){
		node x=q.top(),y=a[find(p[x.id])];
		if(y.id>1)q.erase(y);
		q.erase(x),res+=(ll)y.a*x.b;
		fa[x.id]=fa[y.id],y=y+x;
		a[y.id]=y,a[x.id]=x;
		if(y.id>1)q.push(y);
	}cout<<res<<'\n';
}

Measured memory_bytes: 13552
n,m = map(int,input().split())
h = list(map(int,input().split()))

a = [list(map(int,input().split())) for i in range(m)]

ans = []

for i in range(m):
    if h[a[i][0]-1] > h[a[i][1]-1]:
        ans.append(a[i][1])
    elif h[a[i][0]-1] < h[a[i][1]-1]:
        ans.append(a[i][0])
    if h[a[i][0]-1] == h[a[i][1]-1]:
        ans.append(a[i][0])
        ans.append(a[i][1])
        

ans = set(ans)

print(int(len(h)) - int(len(ans)))
#2,3,5

1,4,4

Measured memory_bytes: 34480
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007
 
using namespace std;
 
typedef long long ll;
 
ll pow_mod(ll x,int k) {
  ll ans=1;
  while (k) {
    if (k&1) ans=ans*x%MOD;
    x=x*x%MOD;
    k>>=1;
  }
  return ans;
}
 
ll facd[4000005],facv[4000005];
 
void pre(int n) {
  facd[0]=1;
  for(int i=1;i<=n;i++) facd[i]=facd[i-1]*i%MOD;
  facv[n]=pow_mod(facd[n],MOD-2);
  for(int i=n-1;i>=0;i--) facv[i]=facv[i+1]*(i+1)%MOD;
}
 
inline ll C(int n,int m) {
  return facd[n]*facv[m]%MOD*facv[n-m]%MOD;
}
 
ll f[2005][2005],sum[2005][2005];
 
int main() {
  int n,k;
  scanf("%d%d",&n,&k);
  if (k==1) {
    puts("1");
    return 0;
  }
  pre(n*k);
  f[0][0]=sum[0][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=i;j++) {
        f[i][j]=sum[i-1][i-1];
        if (j>1) f[i][j]=(f[i][j]-sum[i-1][j-2]+MOD)%MOD;
        f[i][j]=C(i*k-j-1,k-2)*f[i][j]%MOD;
        sum[i][j]=(sum[i][j-1]+f[i][j])%MOD;
    }
  printf("%lld\n",sum[n][n]*facd[n]%MOD);
  return 0;
}


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

#define doubled( x ) (x * x)

//?????°?????°?????? (in:??´??° out:?????°)
int digit_count(int num);

using namespace std;

int main()
{
	int N; cin >> N;
	vector<int> data(3);
	
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> data[j];
		}
		sort(data.begin(), data.end());
		
		if( ( doubled(data[0]) + doubled(data[1]) ) == doubled(data[2]) )cout << "YES";
		else cout << "NO";
		
		cout << endl;
	}
	return 0;
}

int digit_count(int num)
{
	if( num < 0 )num *= (-1);
	
	int count = 0;
	
	for(int i = 10; num != 0; i *= 10)
	{
		int diff = num % i;
		num -= diff;
		count++;
	}
		
	return count;
}

Measured memory_bytes: 1204
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int[] a = ReadLine().Split(' ').Select(int.Parse).ToArray();
         int[] takahasi = new int[]{a[0], a[1]};
         int[] aoki = new int[]{a[2], a[3]};

         int taka = takahasi[0] / aoki[1];
         if(takahasi[0] % aoki[1] != 0) taka++;

         int ao = aoki[0] / takahasi[1];
         if(aoki[0] % takahasi[1] != 0) ao++;

         if(taka >= ao)WriteLine("Yes");
         else WriteLine("No");
      }
   }
}

Measured memory_bytes: 28304
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (100010)

int main()
{
	int H, W, K;
	scanf("%d%d%d", &H, &W, &K);

	ll dp[110][10];

	memset(dp, 0, sizeof(dp));
	dp[0][1] = 1;
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			for (int i = 0; i < (1 << (W - 1)); i++) {
				bool prevIsOn = false;
				bool valid = true;
				for (int j = 0; j < (W - 1); j++) {
					if (i & (1 << j)) {
						if (prevIsOn) {
							valid = false;
							break;
						}
						prevIsOn = true;
					} else {
						prevIsOn = false;
					}
				}
				if (!valid)
					continue;

				if (w - 2 >= 0 && (i & (1 << (w - 2)))) {
					dp[h][w] += dp[h - 1][w - 1];
				}
				if (w - 1 <= W - 2 && i & (1 << (w - 1))) {
					dp[h][w] += dp[h - 1][w + 1];
				}
				if ((w == 1 && (i & (1 << 0)) == 0) ||
					(w == W && (i & (1 << (w - 2))) == 0) ||
					((w - 2 >= 0 && (i & (1 << (w - 2))) == 0) && (w - 1 <= W - 2 && (i & (1 << (w - 1))) == 0))) {
					dp[h][w] += dp[h - 1][w];
				}
				while (dp[h][w] >= MOD)
					dp[h][w] -= MOD;
			}
		}
	}

	printf("%lld\n", dp[H][K]);

	return 0;
}


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

using namespace std;

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

	vector<vector<int> > arr(n, vector<int> (3));


	for(int i = 0; i<n;i++)
	{
		for(int j=0 ; j<3 ; j++)
		{
			cin>>arr[i][j];
		}
	}


	int dp[3][n];

	dp[0][0] = arr[0][0];
	dp[1][0] = arr[0][1];
	dp[2][0] = arr[0][2];

for(int i=1 ; i<n; i++)
{
	for(int j=0 ; j < 3 ; j++)
	{
		if(j==0)
		{
			dp[0][i] = max(dp[1][i-1]+ arr[i][0] , dp[2][i-1] + arr[i][0]);
		}


		if(j==1)
		{
			dp[1][i] = max(dp[0][i-1] + arr[i][1] , dp[2][i-1] + arr[i][1]);

		}

		if(j==2)
		{
			dp[2][i] = max(dp[0][i-1] + arr[i][2] , dp[1][i-1] + arr[i][2]);

		}


	}
}



cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<"\n";


}

Measured memory_bytes: 6912
from math import factorial
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

S = [0]

for i in A:
    S.append(S[-1] + i)

count = 0
count_dict = Counter(S)
for i in count_dict.values():
    if i == 1:
        continue
    count += factorial(i) // (factorial(i - 2) * factorial(2))
print(count)

Measured memory_bytes: 41728
N,K = map(int, input().split())
hs = []
for _ in range(N):
    hs.append(int(input()))

hs_sorted = sorted(hs)

min_diff = float("inf")
#print(hs_sorted)
for i in range(N-K+1):
    diff = hs_sorted[i+K-1] - hs_sorted[i]
    #print(diff)
    if diff < min_diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 8280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Int ans = 0;
	Int temp = 0;
	for (Int i = 0; i < N; i++) {
		cin >> temp;
		ans += temp;
	}

	ans -= N;
	
	cout << ans << endl;

}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];

    int ans = 0;
    int maxv = 0;

    rep(i, n - 1) {
        if (h[i] >= h[i+1]) {
            ans++;
        } else {
            maxv = max(ans, maxv);
            ans = 0;
        }
    }
    maxv = max(ans, maxv);

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
/*
alias p='g++ -std=c++17 -O2 pra.cpp'
alias pg='g++ -std=c++17 -O2 -g pra.cpp'
alias s='g++ -std=c++17 -O2 -g subpra.cpp'
alias ss='g++ -std=c++17 -O2 -g sspra.cpp'
ulimit -c unlimited
alias a='./a.out'
cd programming
cd cpp
cd practice

*/
using ll = long long;
#define rep(i, n) for(int i=0; i<(n); i++)
//if (i) cout << " "; で最初のみ空白文字を出力することができる
#define Sort(v) sort((v).begin(), (v).end())
#define pb push_back
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using vecb = vector<bool>;
using G = vector<vector<int>>;
using P = pair<int, int>;
double PI = acos(-1);
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
//const ll mod = 1000000007;
int main() {
    cout.precision(10);
    cin.tie(0);//cin高速化
    int d, g; cin >> d >> g;
    g /= 100; 
    veci p(d), c(d);
    for(int i=0; i<d; i++){
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    vecb seen(d, false);//見たかどうかの配列は初期値falseが都合がよい
    int ans = 1e9;
    int cnt;
    int goal;
    for(int bit = 0; bit<(1 << d); ++bit){
        for(int i=0; i<d; i++) seen[i] = false;
        cnt = 0;
        goal = 0;
        for(int j=0; j<d; j++){//jは0オリジンでbitを探索する
            if (bit&(1<<j)){//これで選ばれれば全部解く
                goal += ((j+1)*p[j] + c[j]);
                cnt += p[j];
                seen[j] = true;
            }
        }
        if (goal < g){
            for(int i=d; i>=0; --i){
                if (!seen[i]){//まだ残っているなら
                    for(int j=p[i]; j>0; --j){
                    cnt++;
                    goal += i+1;
                    if (goal>=g) break;
                    if (j ==1) break;
                }
            }
            if (goal>=g) break;
        }
        }
        if (goal >= g) ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int num[n];
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }
    
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        sum += b;
    }

    int c[n-1];
    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i];
    }

    for (int i = 0; i < n-1; i++)
    {
        if (num[i] + 1 == num[i+1])
        {
            sum += c[num[i]-1];
        }
    }
    
    cout << sum << endl;
}

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

using namespace std;

//#define FILE_IO

int N, L;
int v[100005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &L);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);

    for(int i = 1; i < N; i++)
        if(v[i] + v[i + 1] >= L)
        {
            printf("Possible\n");
            for(int j = 1; j < i; j++)
                printf("%d\n", j);
            for(int j = N - 1; j > i; j--)
                printf("%d\n", j);
            printf("%d\n", i);
            return 0;
        }

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


Measured memory_bytes: 1152
n,m = map(int,input().split())
stud = []
for i in range(n):
    a,b = map(int,input().split())
    stud.append([a,b])
dist = [ 1e9 for i in range(n) ]
at = [ 0 for i in range(n) ]
for j in range(m):
    a,b = map(int,input().split())
    for i in range(n):
        d = abs(a - stud[i][0]) + abs(b - stud[i][1])
        if d < dist[i]:
            dist[i] = d
            at[i] = j+1

for i in at:
    print(i)


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


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,j,k;
    cin>>n;
    ll a[n],s=0;
    for(i=0;i<n;++i)
    cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;++i)
    {
        for(j=i+1;j<n;++j)
        {
            for(k=j+1;k<n;++k)
            {
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]<a[i]+a[j])
                s++;
            }
        }
    }
    cout<<s;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int a[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n) scanf("%d",&a[i]),a[i]--;
    int ans = 0;
    REP (i,n) {
        if (a[a[i]] == i)
            ans++;
    }
    ans /= 2;
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main(){
  string s,f,p,t;
  cin >> s;
  int q,i,a,b;
  cin >> q;
  for (i=0;i<q;i++) {
    cin >> f >> a >> b;
    if (f=="print") {
      cout << s.substr(a, b-a+1) << endl;
    } else if (f=="reverse") {
      t=s.substr(a, b-a+1);
      reverse(t.begin(), t.end());
      s= s.substr(0, a) + t + s.substr(b+1,s.length() -b-1);
    } else {
      cin >> p;
      s= s.substr(0, a) + p + s.substr(b+1,s.length() -b-1);
    }
  }
  return 0;
}



Measured memory_bytes: 3204
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2)%MOD;
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a % MOD * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        int r,d,x;
        cin>>r>>d>>x;
        int l=x;
        int cou=10;
        while(cou--){
            l=r*l-d;
            cout<<l<<endl;
        }
    }
    RETURN;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int h,w;cin>>h>>w;
  vector<int> num(26,0);
  vector<string> a(h);
  bool judge=true;
  rep(i,h)cin>>a[i];
  rep(i,h){
    rep(j,w){
      int buf=a[i][j]-'a';
      num[buf]++;
    }
  }
  if(h%2==0&&w%2==0){
    rep(i,26){
      if(num[i]%4!=0)judge=false;
    }
  }
  else if(h%2!=0&&w%2!=0){
    int margin1=1;
    int margin2=h+w-2;
    margin2/=2;
    rep(i,26){
      if(num[i]%4!=0){
        if(num[i]%2==0){
          if(margin2>0)margin2--;
          else judge=false;
        }
        else{
          if(margin1>0)margin1--;
          else judge=false;
        }
      }
    }
  }
  else{
    rep(i,26){
      if(num[i]%2!=0)judge=false;
      num[i]/=2;
    }
    if(h%2!=0){
      int margin=w/2;
      rep(i,26){
        if(num[i]%2!=0){
          if(margin>0)margin--;
          else judge=false;
        }
      }
    }
    if(w%2!=0){
      int margin=h/2;
      rep(i,26){
        if(num[i]%2!=0){
          if(margin>0)margin--;
          else judge=false;
        }
      }
    }
  }
  if(judge)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////

int main(){fastio
    ll x,y;cin>>x>>y;
    rep(i,0,100){
        rep(j,0,100){
            if(i*2+j*4==y){
                if(i+j==x){
                    cout<<"Yes";exit(0);
                }
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3648
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
  # i は開始位置
  curr = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      curr+=1
  ans = min(curr, ans)
  
print(ans)

Measured memory_bytes: 9116
n=int(input())
s=[]
for i in range(n):
  a=list(map(int,input().split()))
  s.append(a)
ans=0
for i in range(n):
    for j in range(i+1, n):
        ans+=((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2)**0.5
print(ans*2/n)

Measured memory_bytes: 3060
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
cnt = [1] * n

for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        cnt[b-1] = 0
    elif h[a-1] < h[b-1]:
        cnt[a-1] = 0
    else:
        cnt[a-1] = 0
        cnt[b-1] = 0

print(cnt.count(1))

Measured memory_bytes: 20104
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
  int n,p; string s; cin >>n >>p >>s; ll ans=0;
  for(int i=0; i<n; i++) s[i]-='0';
  if(p==2||p==5){
    for(int i=0; i<n; i++) if(s[i]%p==0) ans+=i+1;
    cout <<ans;
  }
  else{
    int x=1,v=0; vector<ll>r(p,0);
    for(int i=1; i<=n; i++){
      v=(v+x*s[n-i])%p;
      r[v]++; x=(x*10)%p;
    }
    for(int i=0; i<p; i++) ans+=r[i]*(r[i]-1)/2;
    cout <<ans+r[0];
  }
return 0;}

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

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        int maxi=0,mini=501,s,t,i=0,j;
        for(;i<n;++i){
            s=0;
            for(j=0;j<5;++j){
                cin >> t;
                s += t;
            }
            maxi = max(maxi, s);
            mini = min(mini, s);
        }
        cout << maxi << " " << mini << endl;
    }
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	cout << a.back() - a.front() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int K, X;
    cin >> K >> X;
    if(K*500>=X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define INF 1e18
vvi adj;
vi vis;
stack<int> tmp;
vi tpsort;
int n,m;

void dfs(int root){
    vis[root] = 1;
    for(auto x : adj[root]){
        if(!vis[x])
        dfs(x);
    }
    tmp.push(root);
}   

void toposort(){
    for(int i = 0;i < n; ++i){
        if(vis[i] == 0) dfs(i);
    }

    while(!tmp.empty()){
        tpsort.push_back(tmp.top());
        tmp.pop();
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
    cin >> n >> m;
    adj.resize(n);
    vis.resize(n);
    ffor(i,m){
        int x,y;
        cin >> x >> y;
        --x,--y;
        adj[x].push_back(y);
    }
    toposort();

    int len = 0;
    vi dist(n);
    for(int i = 0;i < n; ++i){
        // cout << tpsort[i] << ' ';
        for(auto x : adj[tpsort[i]]){
            dist[x] = max(dist[x],dist[tpsort[i]] + 1LL);
        }
    }
    ffor(i,n){
        len = max(len,dist[i]);
    }
    cout << len;
}

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

typedef long long ll;

string s, t;
bool ok;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s >> t;
    int n = s.length();
    for (int i = 0; i < n; ++i) {
        int idx = i;
        ok = true;
        for (int j = 0; j < n; ++j) {
            if (s[idx] != t[j]) {
                ok = false;
                break;
            }
            idx = (idx + 1) % n;
        }
        if (ok)
            break;
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main(){
    int n; cin >> n;
    int candidate[10] = {111, 222, 333, 444, 555, 666, 777, 888, 999, 1111};
    rep(i, 10){
        if(candidate[i] >= n){
            cout << candidate[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define M 36

typedef struct {
  char suit;
  int value;
} Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void disply(Card *, int);
int isStable(Card *, Card *, int);

int main()
{
  Card A[M+1], B[M+1];
  int i, N;

  scanf("%d", &N);
  for( i = 0 ; i < N ; i++ ){
    scanf(" %c%d", &A[i].suit, &A[i].value);
  }
  for( i = 0 ; i < N ; i++ ) B[i] = A[i];

  BubbleSort(A, N);
  disply(A, N);
  printf("Stable\n");
  SelectionSort(B, N);
  disply(B, N);

  if( isStable(A, B, N) == 0 ) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

void BubbleSort(Card A[], int N)
{
  int i, j;
  Card t;

  for( i = 0 ; i < N ; i++ ){
    for( j = N-1 ; j > i ; j-- ){
      if( A[j].value < A[j-1].value ){
        t = A[j];
        A[j] = A[j-1];
        A[j-1] = t;
      }
    }
  }
}

void SelectionSort(Card B[], int N)
{
  int i, j, minj;
  Card t;

  for( i = 0 ; i < N ; i++ ){
    minj = i;
    for( j = i ; j < N ; j++ ){
      if( B[j].value < B[minj].value ) minj = j;
    }
    t = B[i];
    B[i] = B[minj];
    B[minj] = t;
  }
}

void disply(Card c[], int N)
{
  int i;

  for( i = 0 ; i < N ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%c%d", c[i].suit, c[i].value);
  }
  printf("\n");
}

int isStable(Card A[], Card B[], int N)
{
  int i;

  for( i = 0 ; i < N ; i++ )
  if( A[i].suit != B[i].suit ) return 1;

  return 0;
}


Measured memory_bytes: 2036
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 400+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

LL dp[nmax][nmax];

LL sum(int l,int r,const vector<LL> &v)
{
    LL s=0;
    for(int i=l;i<=r;i++)
        s += v[i];
    return s;
}

LL solve(int l ,int r,const vector<LL> &v)
{
    LL &ret = dp[l][r];

    if(ret!=-1) return ret;

    if(l==r) return ret = 0;

    ret = LLONG_MAX;
    LL cost = sum(l,r,v);
    for(int i=l;i<r;i++)
        ret = min(ret, solve(l,i,v) + solve(i+1,r,v) + cost);

    return ret;

}

int main()
{
    optimizeIO();

    int tc = 1;

    while(tc--)
    {
        int n;
        cin>>n;

        vector<LL>v(n);

        for(int i=0;i<n;i++)
            cin>>v[i];

        memset(dp,-1,sizeof dp);
        cout<<solve(0,n-1,v)<<endl;
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




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



int main()
{   
    int x,y;
    
    while (true)
    {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x > y)
        {
            cout << y << " " << x << endl;
        }
        else
        {
            cout << x << " " << y << endl;
        }
        
        
        
    }
    
    
    
    


}



Measured memory_bytes: 3072
#include<stdio.h>
int main(void){
int a,b,c,d,as,ad;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
if(a>b)
as=b;
else as=a;
if(c>d)
ad=d;
else ad=c;

printf("%d\n",as+ad);

return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int d;
    cin >> d;
    cout << "Christmas";
    for (int i = 0; i < 25-d; ++i) {
        cout << " Eve";
    }
    cout << "\n";
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,MM;
int A[101010];
template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;
multiset<int> M[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>MM;
	FOR(i,N) cin>>A[i];
	if(N==1) return _P("0\n");
	
	FOR(i,MM) {
		cin>>x>>y;
		uf(x,y);
	}
	FOR(i,N) M[uf[i]].insert(A[i]);
	
	int comp=0;
	ll tot=0;
	vector<int> V;
	
	FOR(i,N) if(uf[i]==i) {
		comp++;
		tot+=*M[i].begin();
		M[i].erase(M[i].begin());
		FORR(r,M[i]) V.push_back(r);
	}
	
	if(comp==1) {
		return _P("0\n");
	}
	
	if(comp+V.size()<2*(comp-1)) return _P("Impossible\n");
	sort(ALL(V));
	FOR(i,V.size()) {
		if(comp+(i+1)<=2*(comp-1)) tot+=V[i];
	}
	
	/*
	ll tot=0;
	while(S.size()>1) {
		auto L=*S.begin();
		S.erase(S.begin());
		auto R=*S.begin();
		S.erase(S.begin());
		x=L.second;
		y=R.second;
		tot += L.first+R.first;
		M[x].erase(M[x].begin());
		M[y].erase(M[y].begin());
		if(M[x].size()<M[y].size()) swap(M[x],M[y]);
		FORR(r,M[y]) M[x].insert(r);
		M[y].clear();
		uf(x,y);
		if(uf[x]==y) {
			swap(M[x],M[y]);
			x=y;
		}
		S.insert({*M[x].begin(),x});
	}
	
	if(E.size()) {
		if(S.empty()) {
			if(E.size()==2) {
				cout<<A[E[0]]+A[E[1]]<<endl;
				return;
			}
			else {
				return _P("Impossible\n");
			}
		}
		else {
			x=S.begin()->second;
			FORR(e,E) {
				if(M[x].empty()) _P("Impossible\n");
				tot+=*M[x].begin()+e;
				M[x].erase(M[x].begin());
			}
		}
	}
	*/
	
	cout<<tot<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 16624
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int S;
	int h, m, s;

	scanf("%d", &S);

	h = S / 3600;
	m = (S % 3600) / 60;
	s = S % 60;

	printf("%d:%d:%d\n", h, m, s);	

	return (0);
}

Measured memory_bytes: 1184
/**
 * Created by hiroqn on 13/10/06.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main() {
  var temp = input.shift().split(' '),
      n = +temp[0],
      m = +temp[1],
      graph = [],
      edges = [],
      d = [],
      i, j;
  for (i = 0; i < n; i++) {
    graph[i] = [];
    d[i] = 0;
  }
  for (i = 0; i < m; i++) {
    temp = input[i].split(' ');
//    edges[i] = [temp[0] - 0, temp[1] - 0, temp[2] - 0];
    graph[temp[0] - 0].push([temp[1] - 0, temp[2] - 0]);
//    console.log(temp);

  }
//  for(i = 0; i < n; i++){
//    for (j = 0; j < m; j++){
//      if(d[edges[j][1]]< d[edges[j][0]] + edges[j][2]){
//        d[edges[j][1]] = d[edges[j][0]] + edges[j][2];
//      }
//    }
//  }


  var vlist = [0], v, v2;
  while (vlist.length) {
    v = vlist.pop();
    for (i = 0; i < graph[v].length; i++) {
      v2 = graph[v][i][0];
//      console.log(d[v2]);

      if (d[v2] < d[v] + graph[v][i][1]) {
        d[v2] = d[v] + graph[v][i][1];
        vlist.push(v2);
      }
//      d[graph[v][i][0]] = Math.min(d[graph[v][i][0]],d[v]+graph[v][i][1]);
    }
  }
  console.log(d[n-1]);
}

Measured memory_bytes: 9704
def smaller(x, y):
	if x < y: return x
	else: return y

def judge(a, posneg):
	cnt = 0
	cur = posneg
	sum = 0
	for i in range(0, len(a)):
		sum = sum + a[i]
		sumt = sum * cur
		if sumt < 1:
			cnt = cnt + abs(cur - sum)
			sum = cur
		cur = -1 * cur
	return cnt

n = int(raw_input())
a = map(int, raw_input().split())
print smaller(judge(a, 1), judge(a, -1))

Measured memory_bytes: 11272
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


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

  cout << ((a*b)%2 == 0?"Even":"Odd") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n+2, 0);
  rep(i, n){
    int a;
    cin >> a;
    v.at(i+1) = a;
  }
  int sum = 0;
  rep2(i, 1, n+2){
    sum += abs(v.at(i-1) - v.at(i));
  }
  
  rep2(i, 1, n+1){
    bool b1 = v.at(i-1) < v.at(i);
    bool b2 = v.at(i) < v.at(i+1);
    if((b1 ^ b2) == false){
      cout << sum << endl;
    }else{
      int ans = sum;
      int mi = abs(v.at(i-1) - v.at(i)) + abs(v.at(i) - v.at(i+1)) - abs(v.at(i-1) - v.at(i+1));
      ans -= mi;
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int n,r;
vector<P> x[10002];
vector<P> xx[10002];
int main(void){
  while(cin >> n >> r && n){
    for(int i = 0; i < 10002; i++){
      x[i].clear();
      xx[i].clear();
    }

    for(int i = 0; i < n; i++){
      int x1,y1,x2,y2;
      cin >> x1 >> y1 >> x2 >> y2;
      for(int j = x1; j < x2; j++){
	bool f = true;
	for(int k = 0; k < (int)x[j].size(); k++){
	  if(x[j][k].F <= y2 && x[j][k].S >= y1){
	    x[j][k].F = min(x[j][k].F,y1);
	    x[j][k].S = max(x[j][k].S,y2);
	    f = false;
	    break;
	  }
	}
	if(f) x[j].push_back(P(y1,y2));
      }
    }

    for(int i = 0; i < 10000; i++){
      if(x[i].empty()) continue;
      sort(x[i].begin(),x[i].end());
      xx[i].push_back(x[i][0]);
      for(int j = 1,k = 0; j < (int)x[i].size(); j++){
	if(xx[i][k].S >= x[i][j].F){
	  xx[i][k].S = max(xx[i][k].S,x[i][j].S);
	}else{
	  xx[i].push_back(x[i][j]);
	  k++;
	}
      }
    }

    int res = 0;
    for(int i = 0; i < 10000; i++){
      for(int j = 0; j < (int)xx[i].size(); j++){
	res += xx[i][j].S - xx[i][j].F;
      }
    }
    cout << res << endl;

    if(r-1){
      res = 0;
      for(int i = 0; i < 10000; i++){
	res += 2 * (int)xx[i].size();
	for(int j = 0; j < (int)xx[i].size(); j++){
	  res += 2 * (xx[i][j].S - xx[i][j].F);
	  if(i){
	    for(int k = 0; k < (int)xx[i-1].size(); k++){
	      if(xx[i][j].F < xx[i-1][k].S && xx[i][j].S > xx[i-1][k].F){
		res -= min(xx[i][j].S,xx[i-1][k].S) - max(xx[i][j].F,xx[i-1][k].F);
	      }
	    }	
	  }  
	  if(i+1 < 10000){
	    for(int k = 0;k < (int)xx[i+1].size(); k++){
	      if(xx[i][j].F < xx[i+1][k].S && xx[i][j].S > xx[i+1][k].F){
		res -= min(xx[i][j].S,xx[i+1][k].S) - max(xx[i][j].F,xx[i+1][k].F);
	      }
	    }
	  }
	}
      }
      cout << res << endl;
    }
  }
}

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

int main(){

  int a, b, c, n;
  int p[1111], m[1111], k[1111], q[1111];
  int data[333];

  while(true){
    cin >> a >> b >> c;
    if(!a && !b && !c) break;

    for(int i=1;i<=a+b+c;i++) data[i] = 2;
    
    cin >> n;
    for(int i=0;i<n;i++) cin >> p[i] >> m[i] >> k[i] >> q[i];
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(q[j]) data[p[j]] = data[m[j]] = data[k[j]] = q[j];
	else{
	  if(data[p[j]] == 1 && data[m[j]] == 1) data[k[j]] = 0;
	  if(data[m[j]] == 1 && data[k[j]] == 1) data[p[j]] = 0;
	  if(data[p[j]] == 1 && data[k[j]] == 1) data[m[j]] = 0;
	}
      }
    }
    for(int i=1;i<=a+b+c;i++) cout << data[i] << endl;
  }
  
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=200005;
const ll inf=1e9+7;
int a,b,c;
int main()
{
    ll n,k;
    ll ans;
    while(cin>>n>>k)
    {
        ans=k;
        n--;
        while(n--) ans*=(k-1);
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 256
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0: break
    for j in range(H):
        for i in range(W):
            if j == 0 or j == H-1 or i == 0 or i == W-1:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print("")


Measured memory_bytes: 7000
while True:
	n, m, p = map(int, raw_input().split())
	if n == m == p == 0: break
	gambler = 0;
	for i in xrange(n):
		x = input()
		gambler += x;
		if i + 1 == m:
			hit = x
	if hit:
		pool = gambler * 100 - gambler * p
		print pool / hit
	else:
		print 0

Measured memory_bytes: 4224
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll sum = 0;
  ll x = n;
  while(x > 0) {
    sum += x % 10;
    x /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   char a, b;
   cin >> a >> b;

   if (a == b)
   {
      cout << "=" << endl;
   }
   else if (a < b)
   {
      cout << "<" << endl;
   }
   else
   {
      cout << ">" << endl;
   }
   return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<vector<int>> vec(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> vec[i][j];
		}
	}
	long cost = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			cost += min(vec[j][i], vec[i][j]);
		}
	}
	cout << cost << endl;



	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

Measured memory_bytes: 3196
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  int len = 1000001;
  map<ll, ll> c;
  vi sosu(len, 1);
  sosu[0] = sosu[1] = 0;
  for(ll i = 2; i < len; i++){
    if(sosu[i]){
      c[i]++;
      for(ll j = i + i; j < len; j += i) sosu[j] = 0;
    }
  }
  map<ll, ll> insu;
  for(auto a : c){
    ll num = a.first;
    while(n % num == 0){
      n /= num;
      insu[num]++;
    }
  }
  if(!insu.size()) cout << 1 << endl;
  else{
    ll ans = 0;
    for(auto a : insu){
      ans += int((double)(sqrt(1 + 8 * a.second) - (double)1) / 2);
    }
    if(n > 2) ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 12036