akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int h,w;cin>>h>>w;
	char a;
	int b;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			string s;cin>>s;
			if (s == "snuke"){
				a = 'A' + j;
				b = i + 1;

			}
		}
	}
	cout <<a << b<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,W,w[110],v[110];
long long dp[110][100010];
int main(){
    cin>>n>>W;
    for (int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for (int i=1;i<=100000;i++)
        dp[0][i]=1e12;
    dp[0][0]=0;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=100000;j++)
        {
            if (v[i]<=j)
            {
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    long long res=0;
    for (int i=100000;i>=1;i--)
        if (dp[n][i]<=W)
        {
            res=i;
            break;
        }
    cout<<res;
}



Measured memory_bytes: 80128
#include<iostream>

using namespace std;

int isPrime(int n) {
  for(int i=2;i*i<=n;i++){
    if(n%i==0) return 0;
  }
  return 1;
}

int main() {
  int a;
  int b[1000000];
  for(int i=2;i<=1000000;i++){
    if(isPrime(i)) b[i]=b[i-1]+1;
    else b[i]=b[i-1];
  }
  while(cin>>a){
    cout << b[a] << endl;
  }
  return 0;
}



Measured memory_bytes: 6976
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        if((a-b)%2 == 0) {
            System.out.println((a+b)/2);
        }else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21332
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int a,b,c;cin >> a >> b >> c;
  if (b-a==c-b){cout << "YES";}
  else {cout << "NO";}

  return 0;
}


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();
		long K = sc.nextLong();
		
		long[] a = new long[100001];
		
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			long y = sc.nextLong();
			a[x] += y;			
		}
		
		long sum = 0;
		
		for(int i = 0; i < a.length; i++) {
			sum += a[i];
			if(sum >= K) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 65376
import java.util.Scanner;

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

		X = N / 1.08;

		if (N == (int)(Math.ceil(X) * 1.08)) {
			System.out.println((int)Math.ceil(X));
		} else {
			System.out.println(":(");
		}
	}
}


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

using namespace std;

int solve(int x) {
	for (int i = 1; i < 100000; i++) {
		if (i * (i + 1) / 2 >= x)return i;
	}
}

int main() {
	int x;
	cin >> x;
	cout << solve(x) << endl;
}

Measured memory_bytes: 256
/*
https://atcoder.jp/contests/dp/tasks/dp_d
*/

#include <iostream>
#include <algorithm>

using namespace std;

long long int dp[100][100000];


long long int knapsack(long long int* w,long long int* v, int N ,long long int W){
	
	for(long long int j=1;j<=W;j++){
		if(w[0]<= j) dp[0][j] = v[0];
	}

	for(int i=1;i<N;i++){
		for(long long int j=1;j<=W;j++){
			if(w[i]<=j) 
				dp[i][j] = max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
			else 
				dp[i][j] = dp[i-1][j];
		}
	}

	return dp[N-1][W];
}


int main(){

	int N;
	long long int W;

	cin >> N >> W;

	long long int w[N];
	long long int v[N];

	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}
	
	//long long int k = knapsack(w,v,N,W);
	
	cout << knapsack(w,v,N,W) << endl;
/*
	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}
	*/
	return 0;
}	


Measured memory_bytes: 81644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<ll> x(n), y(n), p(n);
	rep(i, n) cin >> x[i] >> y[i] >> p[i];
	int s = 1 << n;
	vector<vector<ll>> a(s, vector<ll>(n, INF));
	vector<vector<ll>> b(s, vector<ll>(n, INF));
	rep(i, s) rep(j, n) {
		chmin(a[i][j], abs(x[j]));
		chmin(b[i][j], abs(y[j]));
	}
	rep(i, s) {
		rep(j, n) {
			if ((i >> j) & 1) {
				rep(k, n) {
					chmin(a[i][k], abs(x[j] - x[k]));
					chmin(b[i][k], abs(y[j] - y[k]));
				}
			}
		}
	}
	int sz = 1;
	rep(i, n) sz *= 3;
	vector<ll> ans(n + 1, INF);
	rep(i, sz) {
		int tmp = i;
		int xb = 0, yb = 0;
		int cnt = 0;
		rep(j, n) {
			if (tmp % 3 != 0) cnt++;
			if (tmp % 3 == 1) xb |= 1 << j;
			if (tmp % 3 == 2) yb |= 1 << j;
			tmp /= 3;
		}
		ll sum = 0;
		rep(j, n) {
			sum += min(a[xb][j], b[yb][j]) * p[j];
		}
		chmin(ans[cnt], sum);
	}
	rep(i, n) chmin(ans[i + 1], ans[i]);
	rep(i, n + 1) cout << ans[i] << '\n';
}

Measured memory_bytes: 12920
#include <bits/stdc++.h>
#define MAXN 100001

using namespace std;

int a[MAXN + 1];
int n, m;

long long smen[2 * MAXN + 1], aux[2 * MAXN + 1];
long long sol[2 * MAXN + 1];

inline int cost(int a, int b) {
    if(a > b)
        b += m;
    smen[b]--;
    smen[a]++;
    aux[b] += b - a;
    return b - a;
}

int main() {
   // fstream cin("A.in");
   // ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        cin >> a[i];
    long long ans = 0;
    for(i = 2; i <= n; i++)
        ans += cost(a[i - 1], a[i]);
    long long val = 0;
    for(i = 2 * m; i >= 1; i--) {
        smen[i] += smen[i + 1];
        val += aux[i] + smen[i];
        sol[i] = val;
     }
    for(i = 1; i <= 2 * m; i++)
        if(i > m)
            sol[i - m] += sol[i];
    long long mx = 0;
    for(i = 1; i <= m; i++)
        mx = max(mx, sol[i]);
    cout << ans - mx << endl;
    //cin.close();
    //cout.close();
    return 0;
}


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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector<P> v;
    for (int i = 0; i < n; i++) {
        int t;
        ll d;
        cin >> t >> d;
        t--;
        v.emplace_back(d, t);
    }
    sort(v.begin(), v.end(), greater<>());

    ll sum = 0, type = 0;
    vector<int> cnt(n, 0);
    for (int i = 0; i < K; i++) {
        sum += v[i].first;
        if (cnt[v[i].second] == 0) {
            type++;
        }
        cnt[v[i].second]++;
    }

    ll ans = sum + type * type;
    for (int i = K, j = K - 1; i < n; i++) {
        if (cnt[v[i].second] > 0) continue;
        cnt[v[i].second]++;
        sum += v[i].first;
        type++;
        while (j >= 0) {
            if (cnt[v[j].second] > 1) {
                cnt[v[j].second]--;
                sum -= v[j].first;
                ans = max(ans, sum + type * type);
                j--;
                break;
            }
            j--;
        }
        if (j < 0) break;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<string>

int n;
std::string s;
int cnt, pnt;
int rui;

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

	while( std::cin >> s )
	{
		if( s == "HIT" )
		{
			++rui;
			
			if( rui > 3 )
			{
				--rui;
				++pnt;
			}
		}
		else if( s == "HOMERUN" )
		{
			pnt += rui + 1;
			rui = 0;
		}
		else
			++cnt;

		if( cnt == 3 )
		{
			std::cout << pnt << std::endl;
			rui = cnt = pnt = 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=17;
int a[N][N], n, dem, luu[N];
long long dp[(1ll<<16)];
int get(int x, int i) {
    return (x>>i)&1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n;
    rep(i, 1, n) rep(j, 1, n) cin >> a[i][j];
    rep(i, 1, (1ll<<n)-1) {
        dem=0;
        rep(j, 1, n) {
            if(get(i, j-1)) luu[++dem]=j;
        }
        rep(j, 1, dem-1)
            rep(k, j+1, dem) {
                dp[i]+=a[luu[j]][luu[k]];
            }
    }

    dp[0]=0;
    rep(s, 1, (1ll<<n)-1) {
        for (int i = s; i > 0; i = (i - 1) & s) {
            dp[s]=max(dp[s], dp[i]+dp[s^i]);
        }
    }
    cout << dp[(1ll<<n)-1];
    return 0;
}


Measured memory_bytes: 768
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD2 1000000007
#define MOD 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
int fast_pow(int x, int y, int p);
const int MAX_SIZE = 200001;
int n;VI a;
int dp[3001][3001];
int rec(int i,int j,int cnt){
    if(i>j)return 0;
    int& ans=dp[i][j];
    if(ans!=-1)return ans;
    int op1=a[i]-rec(i+1,j,!cnt);
    int op2=a[j]-rec(i,j-1,!cnt);
    ans=max(op1,op2);
    return ans;
}
void solve() {
    cin>>n;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        a.EB(x);
    }
    memset(dp,-1, sizeof(dp));
    cout<<rec(0,n-1,1);
}

int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
//        cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
int N;
vector<int> v;
//=================================================
//=================================================
void input()
{
    cin>>N;
    v.resize(N);
    rep(i,N){
        cin>>v[i];
    }
}
//=================================================
void solve()
{
    sort(v.begin(),v.end());
    int ans = N;
    int prev = -1;
    for (auto x : v) {
        if (x == prev) --ans;
        prev = x;
    }
    cout<<ans<<endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;
  int N = S.length();
  string tmpS = S;
  reverse(tmpS.begin(), tmpS.end());

  if (S != tmpS) {
    cout << "No" << endl;
    return 0;
  }

  string beforeWord, tmpBeforeWord;
  beforeWord = tmpBeforeWord = S.substr(0, (N - 1) / 2);
  reverse(tmpBeforeWord.begin(), tmpBeforeWord.end());

  string afterWord, tmpAfterWord;
  afterWord = tmpAfterWord = S.substr((N + 1) / 2);
  reverse(tmpAfterWord.begin(), tmpAfterWord.end());

  if (beforeWord != tmpBeforeWord || afterWord != tmpAfterWord) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  string s;
  cin >> s;
  
  int ans = 1;
  
  if(c<d){
    for(int i=a;i<d-3;i++){
      if(s[i]=='#' && s[i+1]=='#')
        ans = 0;
    }
  }
  
  if(c>d){
    for(int i=b-2;i<d-1;i++){
      if(s[i]=='.' &&s[i+1]=='.'&& s[i+2]=='.')
        ans++;
    }
    if(ans==1)
      ans=0;
      
    for(int i=a;i<c-3;i++){
      if(s[i]=='#' && s[i+1]=='#')
        ans = 0;
    }
  }
  if(ans==0)
      cout << "No";
  else
      cout << "Yes";
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}


int main() {
  ll N; cin >> N;
  Vll A(N);
  rep(i, N) cin >> A[i];
  
  VVll dp(N+1, Vll(5));

  rep(i, N) {
    ll x = 0;
    rep(j, 5) {
      if (j == 0 || j == 4) x = A[i];
      if (j == 1 || j == 3) x = A[i]%2 + ((A[i] == 0) ? 2 : 0);
      if (j == 2) x = (A[i]+1)%2;

      dp[i+1][j] = dp[i][j];
      rep(k, j) chmin(dp[i+1][j], dp[i][k]);
      dp[i+1][j] += x;
    }
  }

  ll ans = *min_element(all(dp[N]));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n, h[120], ans=0, max=-1;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> h[i];
        if(max < h[i]){
            max = h[i];
        }
    }
    for(int i=1; i<=max; i++){
        for(int j=0; j<n; j++){
            if(j!=n-1){
                if(h[j+1]==0 && h[j]!=0){
                    ans++;
                }
            }
            if(j==n-1 && h[j]!=0){
                ans++;
            }
            if(h[j]>0){
                h[j]--;
            }
        }
    }
    cout << ans << endl;
}

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 Q;
int N;
string S;
int ptr,L;


pair<int,int> hoge() {
	if(ptr>=L) return {0,99};
	int x=ptr;
	if(S[x]=='0') {
		ptr++;
		return {0,0};
	}
	else if(S[x]>='1' && S[x]<='9') {
		ptr++;
		if(x==L-1) {
			return {S[x]-'0',(S[x]-'0')*10+9};
		}
		
		if(S[ptr]>='0' && S[ptr]<='9') {
			ptr++;
			return {(S[x]-'0')*10+(S[x+1]-'0'),(S[x]-'0')*10+(S[x+1]-'0')};
		}
		else {
			return {S[x]-'0',S[x]-'0'};
		}
	}
	else if(S[x]=='^' || S[x]=='_') {
		ptr++;
		ptr++;
		if(ptr>=L) return {0,99};
		auto lh=hoge(),rh=lh;
		ptr++;
		if(ptr>=L) rh={0,99};
		else rh=hoge();
		
		ptr++;
		if(S[x]=='^') return {max(lh.first,rh.first),max(lh.second,rh.second)};
		else return {min(lh.first,rh.first),min(lh.second,rh.second)};
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>Q;
	while(Q--) {
		cin>>S;
		N=S.size();
		for(i=1;i<=N;i++) {
			ptr=0;
			L=i;
			auto ret=hoge();
			if(ret.first==ret.second) {
				cout<<ret.first<<" "<<i<<endl;
				break;
			}
		}
	}
	
}


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);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int W, H, N,x,y,a;
	cin >> W >> H >> N;
	int top=H, bottom=0, left=0, right=W;
	for (size_t i = 0; i < N; i++)
	{
		cin >> x >> y >> a;
		if (a == 1)left = max(left, x);
		if (a == 2)right = min(right, x);
		if (a == 4)top = min(y, top);
		if (a == 3)bottom = max(bottom, y);
	}
	if (top > bottom&& right > left)cout << (top - bottom) * (right - left);
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char **argv)
{
    int N;
    std::string S;
    std::cin >> N >> S;

    for(int i = 0; i < S.size(); i++){
        char c = S.at(i);
        std::cout << (char)(((c - 'A' + N) % 26) + 'A');
    }
    std::cout << std::endl;
}

Measured memory_bytes: 256
#include <iostream>

namespace ABC179
{

  class B
  {
  public:
    B() = default;
    ~B() = default;


    void Run()
    {
      int N = {};
      std::cin >> N;

      int zoro_count = 0;
      for (int i = 0; i < N; ++i)
      {
        int D1, D2;
        std::cin >> D1;
        std::cin >> D2;

        if (zoro_count == 3) continue;

        if (D1 == D2)
        {
          zoro_count++;
        }
        else
        {
          zoro_count = 0;
        }
      }

      std::cout << ((zoro_count==3) ? "Yes" : "No") << std::endl;
    }
  };

}

int main()
{

  ABC179::B prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int a, b, n;
    string s;
    cin >> n >> a >> b;
    cin >> s;
    int cnt = 0, knt = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == 'a'){
            if(cnt < a + b){
                cnt++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }

        else if(s[i] == 'b'){
            knt++;
            if(cnt < a + b && knt <= b){
                    cnt++;
                    cout << "Yes" << endl;
                }
            else cout << "No" << endl;
        }

        else cout << "No" << endl;
    }

}   

Measured memory_bytes: 3752
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val s = readLine()!!.split(' ')
    val t = readLine()!!.split(' ')
    val pre = Array(m + 1) { 0L }
    val cum = Array(m + 1) { 0L }
    val po = 1000000007
    for (i in 1..n) {
        for (j in 1..m) {
            pre[j] = if (s[i - 1] == t[j - 1]) pre[j] + cum[j - 1] + 1 else pre[j]
        }
        for (j in 1..m) {
            cum[j] = (cum[j - 1] + pre[j]) % po
        }
    }
    println((cum[m] + 1) % po)
}


Measured memory_bytes: 80304
N = int(input())
S1 = input()
S2 = input()

MOD = 10**9 + 7

pre = [S1[0], S2[0]]
ans = 6 if pre[0] != pre[1] else 3
for i in range(1,N):
    current =[S1[i], S2[i]]
    if pre[0] == pre[1]:
        if current[0] == current[1]:
            ans *= 2
            ans %= MOD
        else:
            ans *= 2
            ans %= MOD
    else:
        if current[0] != current[1] and pre[0] != current[0]:
            ans *= 3
            ans %= MOD
    pre = current[:]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (1LL<<50LL)
#define MOD 1000000007LL

typedef long long ll;

using namespace std;

ll n,x;

int main() {
	cin >> n >> x;
	vector<ll> dp(100001);
	dp[x] = 1;
	vector<int> in(n);
	for(int i = 0; i < n; i++) {
		cin >> in[i];
	}
	sort(in.begin(),in.end());
	reverse(in.begin(),in.end());
	for(int i = 0; i < n; i++) {
		int a = in[i];
		//cout << "a=" << a << endl;
		vector<ll> dp2(100001);
		for(int j = 0; j <= 100000; j++) {
			int m = j%a;
			dp2[m] += dp[j];
			dp2[m] %= MOD;
			if(i!=(n-1)) {
				dp2[j] += (dp[j]*(ll)(n-i-1))%MOD;
				dp2[j] %=MOD;
			}
		}
		/*
		for(int i = 0; i <= x; i++) {
			if(dp2[i]>0) cout << i << "," << dp2[i] << endl;
		}
		cout << endl;
		*/
		dp.swap(dp2);
	}
	ll ans = 0;
	for(ll i = 0; i <= 100000; i++) {
		ll temp = i*dp[i];
		temp %= MOD;
		ans = (ans+temp)%MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
	int n; cin>>n;
	int a[200001]={};
	ll sum[200001]={};
	FOR(i,0,n){
		cin>>a[i];
		if(i) sum[i]=sum[i-1]+a[i];
		else sum[i]=a[i];
	}
	ll ans=10e17;
	FOR(i,0,n-2){
		ll bc=sum[i],de=sum[n-1]-sum[i];
		int x=upper_bound(sum,sum+n,bc/2)-sum;
		int y=upper_bound(sum,sum+n,sum[i]+de/2)-sum;
		ll b=sum[x],c=bc-b,e=sum[n-1]-sum[y],d=de-e;
		ll B=sum[x-1],C=bc-B,E=sum[n-1]-sum[y-1],D=de-E;
		ll M1=max({b,c,d,e});
		ll m1=min({b,c,d,e});
		ll M2=max({B,C,D,E});
		ll m2=min({B,C,D,E});
		ll M3=max({b,c,D,E});
		ll m3=min({b,c,D,E});
		ll M4=max({B,C,d,e});
		ll m4=min({B,C,d,e});
		ans=min({ans,M1-m1,M2-m2,M3-m3,M4-m4});
	}
	co(ans);
}

Measured memory_bytes: 2560
def solution(count,nums):
    for i in range(count):
        objNum = nums[i]
        j = i - 1
        while j >= 0 and nums[j] > objNum:
            nums[j+1] = nums[j]
            j -= 1
        nums[j+1] = objNum
        print(' '.join(map(str,nums)))



count = int(input())
tmp = input().split(" ")
nums = []
for i in tmp:
    nums.append(int(i))
solution(count,nums)



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

int main(){
  int N;
  string S;
  cin>>N>>S;
  bool finished=false;
  if(N%2!=0)
    cout<<"No"<<endl;
  else{
  	for(int i=0;i<N/2;i++){
      if(S.at(i)!=S.at(i+N/2)){
      	finished=true;
        break;
      }
    }
    if(finished==true)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
}

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  if (a % 2 == 1) ans ^= a++;
  if (b % 2 == 0) ans ^= b--;
  if ((b - a + 1) / 2 % 2 == 1) ans ^= 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
n,k=map(int,input().split())
r,s,p=map(int,input().split())
res_list = {'r':'p','s':'r','p':'s'}
t=input()
res = [0]*n
ans = 0
for i,rsp in enumerate(t):
    res_rsp = res_list[rsp]
    if i<k or res[i-k] != res_rsp:
        ans += eval(res_rsp)
        res[i] = res_rsp
print(ans)

Measured memory_bytes: 4084
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,a[1000002],m,k;
char s[2000002];
long long ans;
int main(){
	n=read();
	for(re int i=1;i<=n;++i){
		k=max(k,a[i]=read());
		ans+=k-a[i];
	}
	printf("%lld",ans);
}

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

using namespace std;
typedef long long ll;
ll s[100010];
ll t[100010];
ll n,m;
ll a[100001];
int main() {
  cin >> n >> m;

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

  for(int i = 1; i < n; i++) {
    ll l = a[i-1];
    ll r = a[i];
    if(l < r){
    s[1] += (r - l + m) % m;
    s[l+1] += -((r - l + m) % m);
    s[r+1] += (r - l + m) % m;
    s[l+1] += r + 1;
    s[r+1] += -(r + 1);
    t[l+1] += -1;
    t[r+1] += 1;
    }
    else {
      s[1] += r + 1;
      s[r+1] += -(r + 1);
      t[1] += -1;
      t[r+1] += 1;
      t[l+1] += -1;
      s[l+1] += r + 1 + m;
      s[r+1] += (r - l + m) % m;
      s[l+1] += -((r - l + m) % m);
    }
   
  }

  for(int i = 2; i <= m; i++) {
    s[i] += s[i-1];
    t[i] += t[i-1];
  }

  for(ll i = 1; i <= m; i++) t[i] *= i;

  ll ans = 1e13;

      for(int i = 1; i <= m; i++) {
	//  cout << "s["<<i<<"] = "<<s[i]<<"   t["<<i<<"] = "<<t[i]<<endl;
    ans = min(ans,s[i]+t[i]);
  }

 

  cout << ans << endl;
}


Measured memory_bytes: 2560
list_a = [1,3,5,7,8,10,12]
list_b = [4,6,9,11]
x,y=map(int,input().split())
print(["No","Yes"] [(x in list_a and y in list_a)or(x in list_b and y in list_b)or(x == 2 and y == 2)])

Measured memory_bytes: 3060
//code by parshuram_84
#include <bits/stdc++.h>
#define floop(i,a,n) for (int i=a;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvl vector<vector<long long> >
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin();it != container.end(); it++)
typedef std::numeric_limits< double > dbl;
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }

int32_t main() {
	IOS;
	ll t,i,j,k,n,x,y,z,a,b,c,d;
	string s;
	t=1;
	for(i=0;i<t;i++)
	{
		cin>>a>>b>>c>>d;
		z=1;
		z=max(max(b*d,a*c),max(b*c,a*d));
		cout<<z;
	}
	return 0;
}

Measured memory_bytes: 3612
H, W = tuple(map(int, input().split()))
func = (lambda x: 0 if x == "#" else -1)
func_in = (lambda h, w: 0 <= h < H and 0 <= w < W)
P = [[func(i) for i in input()] for i in range(H)]

queue_set = set()
zeros = set()
for h in range(H):
    for w in range(W):
        if P[h][w] == 0:
            zeros.add((h)*W+w)
            for dh, dw in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
                if func_in(h+dh, w+dw) and P[h+dh][w+dw] == -1:
                    queue_set.add((h+dh)*W+w+dw)
m = 0

queue = [[q // W, q % W, 0] for q in queue_set]
queue_set |= zeros
idx = 0
cnt = 0
while len(queue) > idx:
    h, w, cnt = queue[idx]
    idx += 1
    cnt += 1
    P[h][w] = cnt
    a = 0
    for dh, dw in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        if func_in(h+dh, w+dw) and (h+dh)*W+w+dw not in queue_set:
            queue += [[h + dh, w + dw, cnt]]
            queue_set.add((h+dh)*W+w+dw)
print(cnt)


Measured memory_bytes: 197136
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int wa = 0;
        for (int i=1; i <= N; i++) {
            if( ((int)i/10000 + ( (int)i/1000 % 10) + ( (int)i/100 % 10) + ( (int)i/10 % 10) + i%10) >= A && ((int)i/10000 + ( (int)i/1000 % 10) + ( (int)i/100 % 10) + ( (int)i/10 % 10) + i%10) <= B){
              wa = wa + i;
            }
        }
          System.out.print(wa);
		
	}
}

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

using namespace std;

#define N                   100000000
#define M                   5761455
#define ll                  long long
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define sqr(a)              ((a)*(a))
#define scan2(a,b)          scanf("%d %d", &a, &b)
#define pii                 pair <int, int>

//bool num[N];
//int prime[M];
//
//void sieve(){
//    for (int i = 4; i <= N; i += 2){
//        num [i] = 1;
//    }
//
//    for (int i = 3; i*i <= N; i += 2){
//        if ( !num[i] ){
//            for (int k = i*i; k <= N; k += 2*i){
//                num[k] = 1;
//            }
//        }
//    }
//
//    prime[0] = 2;
//    int j = 1;
//
//    for (int i = 3; i <= N; i += 2){
//        if (!num[i]){
//            prime[j++] = i;
//        }
//    }
//    return;
//}
//
//int factors (int n){
//    if (n < N){
//        if ( !num[n] ){
//            return 2;
//        }
//    }
//
//    int cnt = 1, s = 0, val = sqrt(n)+1;
//
//    for (int i = 0; prime[i] < val; i++){
//        if ( !(n%prime[i]) ){
//            s = 1;
//
//            while ( !(n%prime[i]) ){
//                n /= prime[i];
//                s++;
//            }
//
//            cnt *= s;
//        }
//    }
//
//    if ( n > 1 ){
//        cnt *= 2;
//    }
//
//    return cnt;
//}
//
//ll factor_sum (ll n){
//    ll sum = 1, p = 0, val = sqrt(n)+1, s = 0;
//
//    for (int i = 0; prime[i] < val; i++){
//        if ( !(n%prime[i]) ){
//            p = prime[i];
//
//            while ( !(n%prime[i]) ){
//                p *= prime[i];
//                n /= prime[i];
//            }
//
//            s = (p-1)/(prime[i]-1);
//            sum *= s;
//        }
//    }
//
//    if (n > 1){
//        sum *= (n*n-1)/(n-1);
//    }
//
//    return sum;
//}


int main(){
//    sieve();
    int n = 0, mx = 1;
    int digit[100005];

    memset(digit, 0, sizeof(digit));

    scanf("%d", &n);

    for (int i = 0; i < n; i++){
        int a = 0;

        scanf("%d", &a);

        digit[a]++;
    }

    for (int i = 1; i <= 100000; i++){
        int cnt = digit[i-1] + digit[i] + digit[i+1];

        mx = max(cnt,mx);
    }

    printf("%d", mx);
    return 0;
}


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

int main()
{
    int t,n,i;
    cin>>n;
    int dp[n+1],v[n+1],a=0,b=0,p;
    for(int i=0; i<n; i++) dp[i] = INT_MAX;
    for(int i=0; i<n; i++) cin>>v[i];
    if(n==2) cout<<abs(v[0]-v[1])<<endl;
    else
    {
        dp[1] = abs(v[0]-v[1]);
        dp[2] = abs(v[0]-v[2]);
        for(int i=3; i<n; i++)
        {
            p = dp[i-2]+abs(v[i] - v[i-2]);
           a = dp[i-1] + abs(v[i] - v[i-1]);
           dp[i] = min(p,a);
        }
        cout<<dp[n-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4344
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) {
      sb.append(s[i]).append(t[i]);
    }
    System.out.println(sb.toString());
  }
}


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

void dist(vector<vector<int>> &vec,int curr, vector<int> &vec1)
{
    int n=vec.size();
    vector<int> visited(n,0);
    queue<pair<int,int>> q;
    q.push(make_pair(curr,0));
    visited[curr]=1;
    while(!q.empty())
    {
        pair<int,int> p=q.front();
        int temp=p.first;
        int dis=p.second;
        vec1[temp]=dis;
        q.pop();
        for(int i=0;i<vec[temp].size();++i)
        {
            if(!visited[vec[temp][i]])
            {
                visited[vec[temp][i]]=1;
                q.push(make_pair(vec[temp][i],dis+1));
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,u,v;
    cin>>n>>u>>v;
    vector<vector<int>> vec(n);
    for(int i=0;i<n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        vec[a-1].push_back(b-1);
        vec[b-1].push_back(a-1);
    }
    
    vector<int> vec1(n),vec2(n);
    dist(vec,u-1,vec1);
    dist(vec,v-1,vec2);
    int max=INT_MIN;
    for(int i=0;i<n;++i)
    {
        if(vec1[i]<vec2[i])
        {
            if(vec2[i]>max)
            {
                max=vec2[i];
            }
        }
    }
    
    
    
    cout<<max-1<<"\n";

}


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

int main () {

  int n, m; cin >> n >> m;
  
  vector<int> a(n);
  double ans =0;
  int count = 0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  double sum = ans/(4*m);
  for (int i=0; i<n; i++) {
    
    if (a[i] >=sum) count++;
  }
    if (count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
  
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(scanner.nextLine());
            set.add(a);
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 23252
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	bit = bin(i)[2:].rjust(len(S) - 1, "0")
	start = 0
	tmp = 0
	for j in range(len(bit)):
		if bit[j] == "1":
			tmp += int(S[start: j + 1])
			start = j + 1
		if j == len(bit) - 1:
			tmp += int(S[start:])
	ans += tmp
print(ans)


Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace  std;
int N,a[100001],x;
long long sum = 0;
int main(){
	cin >> N >> x;
	for(int i=0;i<N;i++) cin >> a[i];
	if(a[0] > x){
		sum += a[0]-x;
		a[0] = x;
	}
	for(int i=1;i<N;i++){
		if(a[i]+a[i-1] > x){
			sum += a[i] -(x - a[i-1]);
			a[i] =x - a[i-1];
			
		}
	}
	
	cout << sum << endl;
}

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

vector<int> buf;

int main()
{
    int N, h[100], c = 0;
    vector<vector<int>> T(1000, vector<int>(100, 0));
    int ans = 0;
    cin >> N;
    for (int i = 0; i < 100; i++)
    {
        h[i] = 0;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (h[j] > i)
            {
                T[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < N; j++)
        {
            c = 0;
            while (T[i][j] == 1)
            {
                j++;
                c++;
            }
            if (c != 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int w[N];
    int a_b_s = 10000;
    
    
    for(int i = 0; i < N; i++){
        cin >> w[i];
        
    }
    for(int i = 0; i < N; i++){
        int s_1 = 0;
        int s_2 = 0;
        for (int k = 0; k <= i; k++) {
            s_1 += w[k];
        }
        for (int j = i+1; j < N; j++){
            s_2 += w[j];
        }
        a_b_s = min(a_b_s, abs(s_1 - s_2));
    }
    cout << a_b_s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc,char* argv[]){
  int comb[50001];
  int i,j;
  int n;
  
  for(i = 2;i <= 50000; i++){
    comb[i] = 1;
  }
  comb[0] = comb[1] = 0;
  
  for(i = 2; i < 224; i++){
    if(comb[i] == 0){continue;}
    for(j = 2; (i*j) <= 50000; j++){
      comb[i*j] = 0;
    }
  }

  for(;;){
    int sum = 0;
    scanf("%d",&n);
    if(n == 0){break;}
    
    for(i = 2; i <= (n/2); i++){
      if(comb[i] != 0){
	if(comb[n - i] != 0){
	  sum++;
	}
      }
    }

    printf("%d\n",sum);
  }
  
  
  return 0;
  
}

Measured memory_bytes: 600
MOD = 10**9 + 7

n,m = map(int,input().split())

C = [[0 for i in range(40)] for j in range(n+40)]

def genprime(nnn):
    prime = [2,3]
    for i in range(5,nnn):
        f = True
        for p in prime:
            if(p*p > i):break
            if i % p == 0 :
                f = False
                break
        if f :prime.append(i)
    return prime

C[1][0],C[1][1] = 1,1
for i in range(2,n+40):
    for j in range(min((i+1),40)):
        if(i == j):
            C[i][i] = 1
            continue
        if(j == 0):
            C[i][j] = 1
            continue
        C[i][j] = (C[i-1][j-1]+C[i-1][j]) % MOD

prime = genprime(100000)

cnt = [0 for i in range(len(prime))]

for k,pp in enumerate(prime):
    while(m % pp == 0):
        m //= pp
        cnt[k] += 1
if(m == 1): ans = 1
else: ans = n
for k,pp in enumerate(cnt):
    if pp == 0:continue
    ans = (ans *C[pp+n-1][pp]) % MOD

print(ans)

Measured memory_bytes: 92508
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC169E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            int[] A = new int[N];
            int[] B = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = RInt;
                B[i] = RInt;
            }


            int ans = 0;
            if (N % 2 == 1)
            {
                Array.Sort(A);
                Array.Sort(B);

                ans = B[N / 2] - A[N / 2] + 1;
            }
            else
            {
                Array.Sort(A);
                Array.Sort(B);

                ans = B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1;
            }
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 60424
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank;
    UnionFind(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; ++i)
            par[i] = i;
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x), ry = root(y);
        if (rx == ry)
            return;
        if (rank[ry] > rank[rx])
            par[rx] = ry;
        else
            par[ry] = rx;
        if (rank[rx] == rank[ry])
            rank[rx]++;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
};

vector<ll> fac, inv, finv;

void initcom()
{
    fac = inv = finv = vector<ll>(1e6);
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i < 1e6; ++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;
    }
}

ll com(int n, int k)
{
    if (n < 0 || k < 0)
        return 0;
    if (n < k)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}
ll mopow(ll a, ll x, ll mod)
{
    ll res = 1;
    while (x > 0)
    {
        if (x & 1)
            res = res * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return res;
}

int main(){
    ll n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin>>a[i],--a[i];
    vector<bool> used(n,false);
    int cur=0;
    while(!used[cur]){
        used[cur]=true;
        cur=a[cur];
    }
    vector<int> cycle;
    cycle.push_back(cur);
    int s=a[cur];
    while(s!=cur){
        cycle.push_back(s);
        s=a[s];
    }
    int t=0;
    while(t!=cur){
        if(k==0){
            cout<<t+1<<endl;
            return 0;
        }
        k--;
        t=a[t];
    }
    ll m=cycle.size();
    cout<<cycle[k%m]+1<<endl;
    return 0;
}

Measured memory_bytes: 4584
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	int cnt=0;
	vector<int> v={A,B,C};
	sort(v.begin(),v.end());
	v[2]-=v[0];
	v[1]-=v[0];
	v[0]-=v[0];

	cnt+=v[2]-v[1];
	if(v[1]%2==0){
		cnt+=v[1]/2;
	}else{
		cnt+=v[1]/2+2;
	}
	
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
mod = 1000000007

n = int(input())
a = list(map(int, input().split(' ')))
b = [0] * (n + 1)

for i, v in enumerate(a):
    b[i+1] = (b[i] + v) % mod

ans = 0
for i in range(n):
    ans = (((a[i] * (b[n] - b[i+1])) % mod) + ans) % mod

print(ans)


Measured memory_bytes: 31444
_, k = gets.split.map(&:to_i)
s = gets.chomp

# run length
ns = s.chars.chunk(&:itself).map { |(b, a)| [b.to_i, a.size] }
# /(10)*1/
ns.unshift [1, 0] if ns[0][0] == 0
ns << [1, 0] if ns[-1][0] == 0
# <len>
ns.map!(&:last)

# 累積和
sums = ns.inject([0]) { |a, n| a << a.last + n }

w = k * 2 + 1
# 1 only = every 2
ls = (0...sums.size).step(2).map do |l|
  sums.fetch(l + w, sums.last) - sums[l]
end
p ls.max


Measured memory_bytes: 17588
#include<stdio.h>
#define N 100000
#define Q 50000

int binary(int n,int A[],int key){
  int left,right,mid;

  left=0;

  right=n;

  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key)return 1;
    else if(key<A[mid]) right=mid;
    else left=mid+1;
  }

  return 0;
}

int main(){

  int i,n,q,key,S[N],T[Q],cnt=0;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&S[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++) scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    if(binary(n,S,T[i])==1)cnt++;
  }

  printf("%d\n",cnt);

  return 0;
}



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

int main(void){
		int a;
		scanf("%d",&a);
    int c[a];
    int b[a];



    for(int i = 0;i<a-1;i++){
      scanf("%d",&c[i]);
    }
    c[a-1] = 0;
    for(int i = 0;i<a;i++){
      b[i] = 0;
    }
    for(int i = 0;i<a-1;i++){
          b[c[i]-1]++;
    }
    b[a-1]=0;




    for(int i =  0;i<a;i++){
    printf("%d\n",b[i]);
  }

		return 0;
}


Measured memory_bytes: 3292
import math


def trial_division(target):
    dest = int(math.sqrt(target))

    for i in range(2, dest):
        if target % i == 0:
            return trial_division(target + 2)

    else:
        return target


def main():
    x = int(input())
    if x % 2 == 0 and x != 2:
        x += 1
    ans = trial_division(x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9080