akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 5100000;
const int MOD = 1000000007;

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

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

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

int main() {
	ll r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;
	ll sum1=0;  
	COMinit();
	for(ll i=c1+1;i<=c2+1;i++){
		ll now=COM(r1+i-1,i);
		//cout <<now<<endl;
		sum1+=now;
		sum1%=inf;
	    //cout<<sum1<<endl;			
	}
	ll  sum2=0;
	for(ll i=c1+1;i<=c2+1;i++){
		ll now=COM(r2+i,i);
		sum2+=now;
		sum2%=inf;
	}	
	if(sum2<sum1){
		sum2+=inf;
	}
	cout << sum2-sum1;
	// your code goes here
	return 0;
}

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

int32_t main(){
	int n;
	cin>>n;
	int flag = false;
	for(int i=1;i<=n;i++){
		if((108*i)/100 == n){
			cout<<i<<endl;
			flag = true;
			break;
		}
	}
	if(!flag)cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#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
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    string X; cin >> X;
    stack<char> st;
    int N = X.size();

    for (int i = 0; i < N; i++) {
        if (st.empty()) {
            st.push(X[i]);
        }
        else {
            char lhs = st.top();
            if (lhs == 'S' && X[i] == 'T') {
                st.pop();
            }
            else {
                st.push(X[i]);
            }
        }
    }
    
    string ans;
    while (!st.empty()) {
        ans += st.top();
        st.pop();
    }
    reverse(ALL(ans));
    cout << ans.size() << endl;
    sysp;
}

Measured memory_bytes: 3912
from math import pi, cos, sin
def solve():
    def rotate(x, y, theta):
        cv = cos(theta); sv = sin(theta)
        return x*cv - y*sv, x*sv + y*cv
    N, D = map(int, input().split())
    if N == D == 0:
        return False
    x0 = -D; x1 = D
    y0 = y1 = 0
    for i in range(N):
        dl, dr, t = map(int, input().split())
        if dl ^ dr >= 0:
            if dl == dr:
                dx = x1 - x0; dy = y1 - y0
                a = pi * dl * t / 180
                dx1 = -dy * a / (2*D); dy1 = dx * a / (2*D)
                x0 += dx1; x1 += dx1
                y0 += dy1; y1 += dy1
            elif dl > dr:
                x2 = (dl * x1 - dr * x0) / (dl - dr)
                y2 = (dl * y1 - dr * y0) / (dl - dr)
                theta = pi * (dl - dr) * t / (360 * D)
                dx, dy = rotate(x0 - x2, y0 - y2, -theta)
                x0 = x2 + dx; y0 = y2 + dy
                dx, dy = rotate(x1 - x2, y1 - y2, -theta)
                x1 = x2 + dx; y1 = y2 + dy
            else:
                x2 = (dr * x0 - dl * x1) / (dr - dl)
                y2 = (dr * y0 - dl * y1) / (dr - dl)
                theta = pi * (dr - dl) * t / (360 * D)
                dx, dy = rotate(x0 - x2, y0 - y2, theta)
                x0 = x2 + dx; y0 = y2 + dy
                dx, dy = rotate(x1 - x2, y1 - y2, theta)
                x1 = x2 + dx; y1 = y2 + dy
        else:
            if dl > dr:
                x2 = (- dr * x0 + dl * x1) / (dl - dr)
                y2 = (- dr * y0 + dl * y1) / (dl - dr)
                theta = pi * (dl - dr) * t / (360 * D)
                dx, dy = rotate(x0 - x2, y0 - y2, -theta)
                x0 = x2 + dx; y0 = y2 + dy
                dx, dy = rotate(x1 - x2, y1 - y2, -theta)
                x1 = x2 + dx; y1 = y2 + dy
            else:
                x2 = (dr * x0 - dl * x1) / (- dl + dr)
                y2 = (dr * y0 - dl * y1) / (- dl + dr)
                theta = pi * (- dl + dr) * t / (360 * D)
                dx, dy = rotate(x0 - x2, y0 - y2, theta)
                x0 = x2 + dx; y0 = y2 + dy
                dx, dy = rotate(x1 - x2, y1 - y2, theta)
                x1 = x2 + dx; y1 = y2 + dy
    print("%.16f" % ((x0 + x1) / 2))
    print("%.16f" % ((y0 + y1) / 2))
    return True
while solve():
    ...


Measured memory_bytes: 5760
S = list(input())
K = int(input())

tmp = S[0]
count = 1
S_num = list()
for i in range(1,len(S)):
	if S[i] == tmp:
		count += 1
	else:
		S_num.append(count)
		tmp = S[i]
		count = 1
S_num.append(count)

if len(S_num) == 1:
	print(len(S)*K//2)
else:
	if S[0] != S[-1]:
		S_num = list(map(lambda x: x//2, S_num))
		print(sum(S_num)*K)
	else:
		a = S_num[0]
		b = S_num[-1]
		S_num = list(map(lambda x: x//2, S_num))
		print(sum(S_num)*K - (a//2 + b//2 - (a+b)//2)*(K-1))

Measured memory_bytes: 3064
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();
    int ans = 0;

    if (n % k != 0) {
      ans = 1;
    }

    System.out.println(ans);
  }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

int is_pow2(int N) {
    while (N%2 == 0) N/=2;
    if(N==1) return true;
    return false;
}

int get_r(int N){
    int r = 1;
    while (N%(2*r) == 0) r*=2;
    return r;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;

    if (is_pow2(N)) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    
    int K = (N-1) / 2;
    for(int i=1;i<=K;i++) {
        cout << 1 << " " << 2*i << endl;
        cout << 2*i << " " << 2*i + 1 << endl;
        cout << 1 << " " << N + 2*i + 1 << endl;
        cout << N + 2*i + 1 << " " << N + 2*i << endl;
    }

    cout << N+1 << " " << 3 << endl;

    if (N % 2 == 0) {
        int r = get_r(N);
        int s = N - r;
        cout << N << " " << r << endl;
        cout << N + N << " " << N + s + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    ll n;cin >> n;
    ll mx = -1;
    ll ind = -1;
    vll a(n);
    forn(i,n){
        cin >> a[i];
        if(a[i] > mx){
            mx = a[i];
            ind = i;
        }
    }
    ll sum = 0;
    forn(i,n){
        if(i == ind){
            continue;
        }
        sum += a[i];
    }
    (mx < sum)?cout<<"Yes\n":cout<<"No\n";

}

Measured memory_bytes: 256
S = input()
T = input()

ind = 0
def search(ind, target, source, target_pos):
    if target_pos + ind >= len(target) and ind < len(source):
        return ""
    if ind == len(source):
        if target_pos + len(source) <= len(target):
            return target[:target_pos] + source + target[target_pos+len(source):].replace("?","a")
        else:
            return target[:target_pos] + source
    if target[target_pos + ind] == source[ind] or target[target_pos + ind] == "?":
        result = search(ind+1, target, source, target_pos)
    else:
        target = target[:target_pos].replace("?","a")+target[target_pos:]
        result = search(0, target, source, target_pos+1)
    return result

best = ""
for i in range(len(T)):
    result = search(0, S[::-1], T[::-1], i)[::-1].replace("?","a")
    if result != "" and (best == "" or best > result):
        best = result
if best == "":
    print("UNRESTORABLE")
else:
    print(best)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define maxn 315
#define ll long long int
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
using namespace std;

int n, _k;
char s[maxn];

int dp[maxn][maxn][maxn];
bool vis[maxn][maxn][maxn];
int DP(int a, int b, int k){
    if (a == n + 1 || !b) return 0;
    if (a >= b) return (a == b);
    if (vis[a][b][k]) return dp[a][b][k];
    vis[a][b][k] = 1;
    int& ans = dp[a][b][k];
    if (s[a] == s[b]) ans = max(ans, DP(a + 1, b - 1, k) + 2);
    if (k) ans = max(ans, DP(a + 1, b - 1, k - 1) + 2);
    ans = max(ans, DP(a + 1, b, k));
    ans = max(ans, DP(a, b - 1, k));
    return ans;
}

int main(){
    scanf("%s%d", s + 1, &_k);
    n = strlen(s + 1);
    printf("%d", DP(1, n, _k));
    return 0;
}

Measured memory_bytes: 147456
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N[4];
  REP(i, 0, 4) cin >> N[i];
  sort(N, N + 4);

  cout << (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
int main(){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a>b){
        printf("a > b\n");
    } else if (a<b) {
        printf("a < b\n");
    }   else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 3144
n,x=map(int,input().split())
a=list(map(int,input().split()))
if a[0]>x:
    ans=a[0]-x
    a[0]=x
else:
    ans=0
for i in range(1,n):
    if a[i-1]+a[i]>x:
        ans+=(a[i-1]+a[i]-x)
        a[i]=x-a[i-1]
print(ans)

Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

const double eps = 1e-9;

bool inside(double r, double cx, double cy, double x, double y){
  return (hypot(x-cx, y-cy) <= r+eps);
}

vector<double> circle(double x1, double y1, double x2, double y2, double x3, double y3){
  double a = x1 - x2;
  double b = y1 - y2;
  double c = x2 - x3;
  double d = y2 - y3;
  double q = 2*(a*d - b*c);
  if(abs(q) < eps) return {};
  double D1 = x1*x1 + y1*y1;  //https://mathwords.net/suityokunitobun
  double D2 = x2*x2 + y2*y2;
  double D3 = x3*x3 + y3*y3;
  double v1 = D1 - D2;
  double v2 = D2 - D3;
  double cx = (d*v1 - b*v2)/q;
  double cy = (-c*v1 + a*v2)/q;
  double r = hypot(cx-x1, cy-y1);
  return {cx, cy, r};
}
  

int main(){  
  int n;
  cin >> n;
  vector<double> x(55,0),y(55,0);  
  rep(i,n){
    cin>>x[i]>>y[i];
  }
  if(n==2){ 
    double ans = hypot(x[1]-x[0], y[1]-y[0])/2;
    cout << fixed << setprecision(10) << ans << endl; return 0; 
  }
  
  vector<vector<double>> ctmp;
  for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ 
    double cx = (x[i]+x[j])/2;
    double cy = (y[i]+y[j])/2;
    double r = hypot(cx-x[i], cy-y[i]);
    ctmp.push_back({cx,cy,r});
  } } 
  
  for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ for(int k=j+1; k<n; k++){
    auto ret = circle(x[i], y[i], x[j], y[j], x[k], y[k]);
    if(ret.size()){ ctmp.emplace_back(ret);}
  } } }
  
  double ans = inf;
  for(auto& to:ctmp){
    double cx=to[0], cy=to[1], r=to[2];
    bool flag=true;
    for(int i=0; i<n; i++){
      if(!inside(r, cx, cy, x[i], y[i])){ flag=false; break;}
    }
    if(flag){ ans = min(ans, r); }
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 1468
#include <cstdio>
#include <cmath>

int main(void){
    while (true) {
        int n, sum = 0, ss = 0;
        scanf("%d", &n);
        if (n == 0) break;

        for (int i = 0; i < n; i++) {
            int data;
            scanf("%d", &data);
            sum += data;
            ss += data * data;
        }
        double mean = (double)sum / n;
        double sd = sqrt((double)ss / n - mean * mean);
        printf("%lf\n", sd);
    }

    return 0;
}

Measured memory_bytes: 1060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vi ps(n);
		rep(i,n) cin>>ps[i];
		sort(all(ps));
		
		int sum=accumulate(all(ps),0);
		for(int i=n-m;i>=0;i-=m)
			sum-=ps[i];
		cout<<sum<<endl;
	}
	
	return 0;
}

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

int main(){
  int N,j,k=0,tmp=1;
  cin >> N;
  vector <int>lamp(N);
  for (int i=0;i<N;i++)
    cin >> lamp.at(i);
  
  while(!(tmp==-1||tmp==2)){
    j=tmp;
    tmp=lamp.at(tmp-1);
    lamp.at(j-1)=-1;
    k++;
  }
  if(tmp==-1)
  cout << tmp<<endl;
  else
  cout << k<<endl;
}

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

int main() {
    int n,a = 1,c;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i ++){
        cin >> b.at(i);
    }
    for(int i = 1;;i ++){
        c = a;
        a = b.at(a-1);
        b.at(c-1) = 0;

        if(a == 2){
            cout << i << endl;
            return 0;
        }
        if(a == 0){
            cout << -1 << endl;
            return 0;
        }
    }
}
    

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#define ri register int
namespace io {
    const int SIZE = (1 << 21) + 1;
    char ibuf[SIZE], *iS, *iT, c; int f;
    // getchar
    #define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
    // input a signed integer
    template <class I>
    inline void gi (I &x) {
        for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
        for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
    }
}
using io :: gi;
const int N=500005,inf=1<<30,mod=1000000007;
int mn[N],mx[N],f[N],sum[N];
struct node{
	int k,b,l,r;
}a[N];
inline bool cmp(node p,node q){
	return p.b>q.b;
}
inline bool cmp2(node p,node q){
	return p.l<q.l||(p.l==q.l&&p.r<q.r);
}
inline int min(ri x,ri y){
	return x<y ? x:y;
}
inline int max(ri x,ri y){
	return x>y ? x:y;
}
int main(){
    ri n,i,pos,l,r,mid,j,ans=0;
    gi(n);
    for(i=1;i<=n;++i) gi(a[i].k),gi(a[i].b);
    std::sort(a+1,a+1+n,cmp);
    mn[0]=inf;
    for(i=1;i<=n;++i){
    	mn[i]=min(mn[i-1],a[i].k);
    	l=0;r=i-1;pos=i;
    	while(l<=r){
    		mid=l+r>>1;
    		if(mn[mid]<a[i].k) pos=mid,r=mid-1;
    		else l=mid+1;
		} 
		a[i].l=pos;
	}
	mx[n+1]=-inf; 
	for(i=n;i;--i){
		mx[i]=max(mx[i+1],a[i].k);
		l=i+1;r=n;pos=i;
		while(l<=r){
			mid=l+r>>1;
			if(mx[mid]>a[i].k) pos=mid,l=mid+1;
			else r=mid-1;
		} 
		a[i].r=pos;
	}
	std::sort(a+1,a+1+n,cmp2);
	j=1;
	for(i=1;i<=n;++i){
		while(a[j].r+1<a[i].l) ++j;
		f[i]=(sum[i-1]-sum[j-1]+mod)%mod;
		if(a[i].l==1) f[i]=(f[i]+1)%mod;
		//可以只选i这个区间就覆盖1~i这么多区间的范围 
		sum[i]=(sum[i-1]+f[i])%mod;
		if(a[i].r==n) ans=(ans+f[i])%mod;//第i个区间可以作为最后一个选的区间 
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 15744
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()
	N := len(s)
	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, 13)
	}
	dp[0][0] = 1

	for i := 0; i < N; i++ {
		if s[i] == '?' {
			for j := 0; j < 13; j++ {
				for x := 0; x < 10; x++ {
					dp[i+1][(10*j+x)%13] += dp[i][j]
					dp[i+1][(10*j+x)%13] %= mod
				}
			}
		} else {
			for j := 0; j < 13; j++ {
				x := int(s[i] - '0')
				dp[i+1][(10*j+x)%13] += dp[i][j]
				dp[i+1][(10*j+x)%13] %= mod
			}
		}
	}
	// for i := 0; i <= N; i++ {
	// 	out(dp[i])
	// }

	out(dp[N][5])
}


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

int n,m;
int g[500][500];

int main(){
	while(scanf("%d%d",&n,&m),n){
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++) g[i][j]=100000;
		for(int i=0;i<m;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			g[a-1][b-1]=1;g[b-1][a-1]=1;
		}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				for(int k=0;k<n;k++) g[j][k]=min(g[j][k],g[j][i]+g[i][k]);
		int res=0;
		for(int i=1;i<n;i++) if(g[0][i]<=2)res++;
		printf("%d\n",res);
	}
}

Measured memory_bytes: 2164
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  ll s[N]; rep(i, N) cin >> s[i];

  ll result = 0;
  for (int i=1; i<N; i++) {
    ll tmp=0, j=1;
    while (i*(j+1)<N-1) {
      if (i*j==(N-1)-i*j || i*j-((N-1)-i*j)==i) break;
      tmp += s[i*j] + s[(N-1)-i*j];
      result = max(result, tmp);
      j++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.io.*;class Main{public static void main(String[]_)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));double x=0,y=0,a=0;for(Integer n=1,m=1;n>0||m!=0;){_=B.readLine().split(",");n=m.valueOf(_[0]);x+=n*Math.cos(Math.toRadians(a));y+=n*Math.sin(Math.toRadians(a));a+=m=n.valueOf(_[1]);}System.out.println((int)y+"\n"+(int)x);}}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define debug(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> ii;
typedef pair <ii, int> iii;

void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const ll mod = 1000000007;
ll dp[3000];
int n;

ll solve(int sum){
  if(sum > n)
    return 0;
  if(sum == n)
    return 1;
  ll &ans = dp[sum];
  if(ans != -1)
    return ans;
  ans = 0;
  for(int j = 3; j <= n; j++)
    ans = (ans%mod+solve(sum+j)%mod)%mod;
  return ans%mod;
}

int main(){
  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << solve(0)%mod << endl;
  return 0;
}

Measured memory_bytes: 3672
program prob5
    implicit none
    integer(16) :: W, H, x, y
    character(len=100) :: S
    read(*,*) W, H, x, y

    write(S,'(f44.20)') real(W, kind=16)*real(H, kind=16)/2.0_8

    write(*,'(a)',advance='no') trim(adjustl(S))


    if(2*x == W .and. 2*y == H) then
        write(*,*) ' 1'
    else
        write(*,*) ' 0'
    end if

    stop
contains
end program prob5

Measured memory_bytes: 2892
#include <bits/stdc++.h>
using namespace std;
long long sum[1000000],kq,tmp,n,a[1000000];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];

    }
    kq=1e12;
    for (int i=1;i<=n-1;i++){
        kq=min(kq,abs(sum[n]-2*sum[i]));
    }
    cout<<kq;
}


Measured memory_bytes: 5888
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=4*1e3+5,Mo=1e9+7;

int n,m,k,f[N][N][2],ans;

void inc(int &x,int y) {
	x=x+y;
	if (x>=Mo) x=x-Mo;
}

int main() {
	scanf("%d%d%d",&n,&m,&k);
	m--;k--;
	f[0][0][0]=1;
	fo(i,0,(n+m)/k) {
		fo(j,0,n)
			fo(z,0,1)
				if (f[i][j][z]) {
					inc(f[i+1][j+1][1],f[i][j][z]);inc(f[i+1][min(n+1,j+k+1)][1],Mo-f[i][j][z]);
					inc(f[i+1][j][0],f[i][j][z]);inc(f[i+1][j+1][0],Mo-f[i][j][z]);
				}
		fo(j,1,n) fo(z,0,1) inc(f[i+1][j][z],f[i+1][j-1][z]);
	}
	fo(i,1,(n+m)/k) 
		fo(j,0,n)
			if (j%k==n%k&&(i*k-j)%k==m%k&&i*k-j<=m)
				inc(ans,f[i][j][1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 124416
#include <iostream>

using namespace std;

int main(){
    int D;
    cin >> D;
    if(D == 25){
        cout << "Christmas" << endl;
    }else if(D == 24){
        cout << "Christmas Eve" << endl;
    }else if(D == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int debt = 100000;
		for (int i = 0; i < n; ++i) {
			debt += debt / 20;
			int up = 1000 - debt % 1000;
			if (up != 1000) debt += up;
		}
		System.out.println(debt);
		sc.close();
	}
}


Measured memory_bytes: 26004
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> w(n);
    int sum = 0;
    REP(i, 0, n) {
        cin >> w[i];
        sum += w[i];
    }
    int ans = 1 << 30;
    REP(i, 0, n) {
        int s1 = 0;
        REP(j, 0, i) {
            s1 += w[j];
        }
        int s2 = sum - s1;
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans << endl;
    return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector<bool> vec(10);
  for (ll i = 0; i < K; i++) {
    ll d; cin >> d;
    vec.at(d) = true;
  }

  auto suit = [&](const auto& recF, ll x) -> ll {
    if (x < 10) {
      ll i = x;
      for ( ; i < 10 && vec.at(i); i++);
      if (i < 10) return i;
      for (i = 1; vec.at(i); i++);
      return i * 10 + (vec.at(0) ? i : 0);
    }
    ll y = recF(recF, x / 10);
    if (y > x / 10) return y * 10 + recF(recF, 0);
    ll z = recF(recF, x % 10);
    if (z < 10) return y * 10 + z;
    y = recF(recF, 1 + x / 10);
    return y * 10 + recF(recF, 0);
  };
  cout << suit(suit, N) << endl;

  return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class EStringsOfImpurity {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s, t; cin >> s >> t;
      vector<vector<int>> a(26, vector<int>());
      rep(i, s.size()) {
        a[s[i]-'a'].push_back(i+1);
      }
      ll pos = 0;
      ll loop = 0;
      for(auto c: t) {
        int p = c-'a';
        if (a[p].empty()) {
          cout << -1 << endl;
          return;
        }
        auto it = upper_bound(a[p].begin(), a[p].end(), pos);
        if (it != a[p].end()) {
          pos = *it;
        } else {
          loop++;
          it = upper_bound(a[p].begin(), a[p].end(), 0);
          pos = *it;
        }
      }
      cout << loop*s.size()+pos << endl;
    }
};

signed main() {
  EStringsOfImpurity solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1228
#include<iostream>

using namespace std;

int main()
{
	int i, j;
	int a, b;

	while (true)
	{
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		for (i = 0; i < a; i++)
		{
			for (j = 0; j < b; j++)
			{
				if ((i + j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
 
using namespace std;
 
int C, D, W, X;
int E[16][31], F[16][31];
int memo[31][51][6];
const int dx[] = {-1, 1};
 
int solve(int d, int w, int x)
{
    if (d == D) return 0;
 
    int &res = memo[d][w][x];
    if (res != -1) return res;
   
    res = solve(d+1, w, x);
 
    for (int i = 0; i < C; i++) {
        if (E[i][d] == 0) continue;
        if (w + F[i][d] <= W) {
            res = max(res, solve(d+1, w + F[i][d], x) + E[i][d]);      
        }    
        if (x + 1 > X) continue;
        for (int j = 0; j < 2; j++) {
            int nx = i, cost = 0, f = 0;
            while (1) {
                if (nx < 0 || nx >= C || E[nx][d] == 0) break;
                f += F[nx][d];
                cost += E[nx][d];
                if (w + f <= W) {
                    res = max(res, solve(d+1, w + f, x+1) + cost);
                }
                nx += dx[j];
            }
        }   
    }
    return res;
}
 
int main()
{
    while (cin >> C >> D >> W >> X, C) {
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < D; j++) {
                cin >> E[i][j];
            }
        }
 
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < D; j++) {
                cin >> F[i][j];
            }
        }
 
        memset(memo, -1, sizeof(memo));
     
        int res = solve(0, 0, 0);
        cout << res << endl;
    }
    return 0;
}

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

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

    int k, x;
    cin >> k >> x;

    if(500 * k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = input().split()
W, H, x, y, r = map(int, n)

x1 = x - r
y1 = y - r
x2 = x + r
y2 = y + r

if x1 < 0 or y1 < 0:
    print('No')
elif x2 > W or y2 > H:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5596
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> line(N, 0);

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

	int result = 0;

	for (int i = 0; i < N - 2; i++)
	{
		for (int j = i + 1; j < N - 1; j++)
		{
			for (int k = j + 1; k < N; k++)
			{
				if (line[i] != line[j] && line[j] != line[k] && line[i] != line[k])
				{
					vector<int> check = { line[i], line[j], line[k] };
					sort(check.begin(), check.end());

					if (check[0] + check[1] > check[2])
					{
						result++;
					}
				}
			}
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

typedef struct RMQandRAQ {
  i64 *add;
  i64 *max;
  i32 bit;
  i32 size;
} RMQandRAQ;

RMQandRAQ* new_RMQandRAQ (const i32 n) {
  i32 k = 0;
  while ((1 << k) < n) ++k;
  RMQandRAQ *s = (RMQandRAQ *) calloc (1, sizeof (RMQandRAQ));
  s->add = (i64 *) calloc (2 << k, sizeof (i64));
  s->max = (i64 *) calloc (2 << k, sizeof (i64));
  s->bit = k;
  s->size = 1 << k;
  return s;
}

static inline i64 max (i64 a, i64 b) {
  return a > b ? a : b;
}

static inline i64 eval (RMQandRAQ *s, i32 k) {
  return s->add[k] + s->max[k];
}

void propagate (RMQandRAQ *s, i32 x) {
  x += s->size;
  for (i32 bit = s->bit; bit > 0; bit--) {
    i32 k = x >> bit;
    s->add[2 * k] += s->add[k];
    s->add[2 * k + 1] += s->add[k];
    s->add[k] = 0;
    s->max[k] = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void save (RMQandRAQ *s, i32 x) {
  for (i32 k = (x + s->size) >> 1; k >= 1; k >>= 1) {
    s->max[k] = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void add (RMQandRAQ *s, i32 l, i32 r, i64 v) {
  for (i32 x = l + s->size, y = r + s->size; x < y; x >>= 1, y >>= 1) {
    if (x & 1) s->add[x++] += v;
    if (y & 1) s->add[--y] += v;
  }
  save (s, l);
  save (s, r - 1);
}

i64 find (RMQandRAQ *s, i32 l, i32 r) {
  propagate (s, l);
  propagate (s, r - 1);
  i64 ans = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = max (ans, eval (s, l++));
    if (r & 1) ans = max (ans, eval (s, --r));
  }
  return ans;
}

typedef struct range {
  i32 l, r, v;
} range;

int cmp (const void *a, const void *b) {
  i32 d = ((range *)a)->r - ((range *)b)->r;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  range *p = (range *) calloc (m, sizeof (range));
  for (i32 i = 0; i < m; ++i) {
    i32 l, r, v;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &l, &r, &v);
    p[i] = (range) {l, r, v};
  }
  qsort (p, m, sizeof (range), cmp);
  RMQandRAQ *s = new_RMQandRAQ (n + 1);
  for (i32 i = 1, j = 0; i <= n; ++i) {
    i64 v = find (s, 0, i);
    add (s, i, i + 1, v);
    for (; j < m && p[j].r <= i; ++j) {
      add (s, p[j].l, p[j].r + 1, p[j].v);
    }
  }
  printf ("%" PRIi64 "\n", find (s, 0, n + 1));
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 9448
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int[] d = new int[n];
    for(int i = 0; i < n; i++) {
      d[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
    }
    long ans = 0;
    for(int i = 0; i < (int)Math.pow(2, n - 1); i++) {
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < (n - 1); j++) {
        if((i & (1 << j)) != 0) list.add(j);
      }
      for(int j = 0; j < list.size(); j++) {
        if(j == 0) {
          int c = list.get(j);
          for(int k = c; k >= 0; k--) {
            ans += ((long)d[k] * (long)Math.pow(10, c - k));
          }
        } else {
          int c1 = list.get(j - 1);
          int c2 = list.get(j);
          for(int k = c2; k > c1; k--) {
            ans += ((long)d[k] * (long)Math.pow(10, c2 - k));
          }
        }

        if(j == (list.size() - 1)) {
          int c = list.get(j);
          for(int k = n - 1; k > c; k--) {
            ans += ((long)d[k] * (long)Math.pow(10, n - 1 - k));
          }
        }
      }
    }
    for(int i = n - 1; i >= 0; i--) {
      ans += ((long)d[i] * (long)Math.pow(10, n - 1 - i));
    }
    System.out.println(ans);
  }
}


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

using namespace std;
int main(){
    int n,t=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        {cin>>a[i];
        t=t+a[i];
        }
    sort(a,a+n);
    t=t-(a[n-1]/2);
    cout<<t<<endl;
return 0;
}



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

constexpr int MAX_N = 1e5+9;
constexpr int TOTAL = 1e9+7;

bool broken[MAX_N+1];
int dp[MAX_N+1];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i{}; i < M; ++i) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  dp[0] = 1;
  if (!broken[1]) dp[1] = 1;
  for (int i{2}; i <= N; ++i) {
    if (!broken[i]) dp[i] = (dp[i-1] + dp[i-2]) % TOTAL;
  }

  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 768
#include<stdio.h>


int main(){
	char b;
	scanf("%c",&b);
	if(b == 'A') printf("T\n");
	else if(b == 'T') printf("A\n");
	else if (b == 'C') printf("G\n");
	else printf("C\n");
	
	
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, H := ReadInt(), ReadInt()
	a := make([]int, N)
	b := make([]int, N)
	for i := 0; i < N; i++ {
		a[i], b[i] = ReadInt(), ReadInt()
	}

	e := Max(a...)
	c := make([]int, 0)
	for i := 0; i < N; i++ {
		if b[i] > e {
			c = append(c, b[i])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(c)))

	cnt := 0
	for _, ci := range c {
		if H <= 0 {
			fmt.Println(cnt)
			return
		}
		H -= ci
		cnt++
	}
	if H <= 0 {
		fmt.Println(cnt)
		return
	}
	fmt.Println(cnt + (H+e-1)/e)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    int a, b;
    cin >> a >> b;
    if (a+b == 15)cout << "+" << endl;
    else if (a * b ==15)cout << "*" << endl;
    else cout << "x" << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	int R = 0;
  if(N % 1000 == 0){
  	cout << R << endl;
	}
  else if(N > 1000){
	int x = N % 1000;
    R = 1000 - x;
    cout << R << endl; 
    }
  
  else if(N < 1000){
  R = 1000 - N;
    cout << R << endl;
  }
  }



Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const long long llinf=1e18;
const int A=100005,B=200005,C=305,D=105,E=1005;
int a,b;
int main(){
	cin>>a>>b;
	if((a*b)%2==0)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define N 50001
using namespace std;

int main() {
	vector<bool>sosuu(N, true);
	for (int b = 2; b < N; b++) {
		if (sosuu[b]) {
			for (int c = b * 2; c < N; c += b)sosuu[c] = false;
		}
	}
	int d;
	while (cin >> d, d) {
		int s = 0;
		for (int e = 2; e <= d / 2; e++) {
			if (sosuu[e] && sosuu[d - e])s++;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3080
n=int(input())
li=[list(map(int,input().split())) for i in range(n)]
dp=[li[0]]
#print(li)
for i in range(1,n):
  temp=[]
  temp.append(li[i][0]+max(dp[i-1][1],dp[i-1][2]))
  temp.append(li[i][1]+max(dp[i-1][0],dp[i-1][2]))
  temp.append(li[i][2]+max(dp[i-1][0],dp[i-1][1]))
  dp.append(temp)
#print(dp)
print(max(dp[n-1]))

Measured memory_bytes: 47380
n=int(input())
l=[]
for i in range(n):
    s,p=input().split()
    pp=int(p)
    l.append([s,pp,i])
l.sort(key=lambda x:x[0])
buf=l[0][0]
b=n
m=[]
for i in range(n):
    [s,p,index]=l[i]
    if (buf!=s):
        b-=1
        buf=s
    m.append([b*100+p,index,s])
m.sort(key=lambda x:x[0],reverse=True)
for i in range(n):
    print(m[i][1]+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string ans = "Yes\n";
void p(int & a, int & b, char A, char B)
{
    if (a == 0 && b == 0) {
        cout << "No\n";
        exit(0);
    }
    if (a > b) {
        --a;
        ++b;
        ans += B;
    } else {
        --b;
        ++a;
        ans += A;
    }
    ans += '\n';
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> vs(n);
    for (auto & s : vs)
        cin >> s;
    for (int i = 0; i < n; ++i) {
        string s = vs[i];
        if (s == "AB") {
            if (a == 1 && b == 1 && c == 0 && i + 1 < n && vs[i + 1] == "BC") {
                p(b, a, 'B', 'A');
            } else {
                p(a, b, 'A', 'B');
            }
        } else if (s == "AC") {
            if (a == 1 && c == 1 && b == 0 && i + 1 < n && vs[i + 1] == "BC") {
                p(c, a, 'C', 'A');
            } else {
                p(a, c, 'A', 'C');
            }
        } else if (s == "BC") {
            if (b == 1 && c == 1 && a == 0 && i + 1 < n && vs[i + 1] == "AC") {
                p(c, b, 'C', 'B'); 
            } else {
                p(b, c, 'B', 'C'); 
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 6760
N = int(input())

k = {i: 0 for i in range(1, 100) if str(i)[-1] != '0'}

for i in range(1, N+1):
    if i < 10:
        k[i] += 1
        zoro = int(str(i)*2)
        if zoro <= N:
            k[zoro] += 1
    else:
        _i = str(i)
        first = int(_i[0])
        last  = int(_i[-1])
        if last != 0:
            handstand = int(str(last)+str(first))
            if first == last:
                k[first] += 1
                k[int(str(first)*2)] += 1
            elif handstand <= N:
                k[handstand] += 1

ans = 0
for i in range(1, N+1):
    _i = str(i)
    first = int(_i[0])
    last  = int(_i[-1])
    if i < 10:
        ans += k[i]
    elif last != 0:
        ans += k[int(str(first)+str(last))]

print(ans)

Measured memory_bytes: 42204
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	long long k,flag=1;
	long long sum;
	cin>>s;
	scanf("%lld",&k);
	char f=s[0];
	long long p=0,cnt=0,q=0,sz=s.size();
	for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            p++;
            if(p%2){
                cnt++;
            }
        }
        else {
            p=0;
        }
	}
	//cout<<cnt<<endl;
	if(p==sz-1) flag=0;
	else{
        if(s[sz-1]!=f){
            q=1;
        }
        else{
            for(int i=0;i<s.size();i++) {
                if(s[i]==f) q++;
                else break;
            }
            for(int i=s.size()-1;i>=0;i--){
                if(s[i]==f) q++;
                else break;
            }
        }

	}
	if(flag){
        if(q%2){
            sum=k*cnt;
        }
        else{
            sum=cnt*k+k-1;
        }
	}
	else{
        sum=sz*k/2;
	}
	cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;


int main()
{
	string str;
	cin >> str;
	ll turn = 1;
	while (str.size()>2)
	{
		bool flag = false;
		for (size_t i = 1; i < str.size()-1; i++)
		{
			if (str[i - 1] != str[i + 1]) { 
				flag = true;
				str.erase(i,1);
				break;
			}
		}
		if (!flag)break;
		turn++;
	}
	string out = turn % 2 == 1 ? "Second" : "First";
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	int N,ans=0,k=1000;
	cin>>N;
	vector<int>s(N);
	for(int i=0;i<N;++i)
	{
		cin>>s[i];
		ans+=s[i];
		if(s[i]%10!=0)k=min(k,s[i]);
	}
	if(ans%10==0){
	if(k==1000)ans=0;
	else ans-=k;
		}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.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 rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi h(n);
    cin >> h;
    sort(all(h));
    int ans = inf;
    rep(i,n-k+1) chmin(ans,h[i+k-1]-h[i]);
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define NN 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1) // 3.141592654
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mem(a,n) memset(a,n,sizeof(a))
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n!=1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll rem(int x, int N){
	return (x % N + N) % N;
}
vector<int>fre(100007);
vector<vector<int> >v(100007);
void dfs(int x){
	fre[x] = 1;
	for(int i = 0;i<v[x].size();i++){
		int cnt = v[x][i];
		if(!fre[cnt]){
			dfs(cnt);
		}
	}
}
int main()
{
	//cout<<fixed<<setprecision(9);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int c = 0;
	for(int i = 1;i<=n;i++){
		if(!fre[i]){
			c++;
			dfs(i);
		}
	}
	cout << c - 1;
	return 0;
}


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

using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
	while(u != NIL && k != u->key) {
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
find 12
insert 17
insert 25
find 16
print
*/


Measured memory_bytes: 22072