akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
from collections import Counter
def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")


for j in range(n):
    jj=s[j]
    for i in range(j):
        k=2*j-i
        if not j<=k<=n-1:
            continue
        ii=s[i]
        kk=s[k]
        if jj!=ii and jj!=kk and ii!=kk:
            ans-=1

print(ans)

Measured memory_bytes: 68628
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	set<char> st;
	rep(i,s.size()){
		if(s[i] == t[i]) st.insert(s[i]);
		else{
			if(st.find(s[i]) != st.end() || st.find(t[i]) != st.end()){
				cout << "No" << endl;
				return 0;
			}
			st.insert(t[i]);
			char u = s[i];
			char v = t[i];
			for(int j = i; j < s.size(); ++j){
				if(s[j] == u) s[j] = v;
				else if(s[j] == v) s[j] = u;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

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(long long int n, long long 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(){
	long long int n,k;
	COMinit();
	
	cin >> n >> k;
	
	vector<long long int> data(n);
	
	for(int i=0;i<n;++i){
		cin >> data[i];
	}
	
	sort(data.begin(),data.end());
	
	long long ma = 0;
	long long mi = 0;
	k--;
	for(int i=0;i<n;++i){
		int kk = n-i-1;
		
		mi += (data[i] * COM(kk,k))%MOD;
		ma += (data[i] * COM(i,k))%MOD;
		//cout << data[i] << " " << i << " " << COM(i,k) << " " << COM(kk,k) <<endl;
		ma %= MOD;
		mi %= MOD;
	}
	
	cout << (ma + MOD - mi)%MOD <<endl;
	
	
	return 0;
	
}


Measured memory_bytes: 120576
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int w;
		if(a<=b){
			w = a;
			a = b;
			b = w;
		}
		while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		}
		System.out.println(b);
	}

}

Measured memory_bytes: 17324
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <string.h>
using namespace std;

int main() {
	int K;
	string S;

	cin >> K >> S;

	if (S.length() <= K) {
		cout << S << endl;
	}
	else {
		for (int ii = 0; ii < K; ii++) {
			cout << S[ii];
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    while (~scanf("%d",&n)){
        int x = 0 , a = 1 , b = 1;
        for (int i=0; i<n; i++)  {
            int t;
            scanf("%d",&t);
            if (t%2 == 0)  x++;
            a *= 3;
        }

        for (int i=0; i<x; i++)  b *= 2;
        printf("%d\n",a-b);
    }
    return 0;
}


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

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

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

int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};

const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  P c, d;
  cin >> c.first >> c.second;
  cin >> d.first >> d.second;
  --c.first, --c.second, --d.first, --d.second;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  priority_queue<pair<int, P>> pq;
  pq.push({0, c});
  vector<vector<int>> dist(h, vector<int>(w, INF));
  dist[c.first][c.second] = 0;
  while (!pq.empty()) {
    auto u = pq.top();
    pq.pop();
    int i = u.second.first;
    int j = u.second.second;
    int cost = u.first;
    if (dist[i][j] < -cost) continue;

    auto ok = [&](int a, int b) {
      if (a < 0 || a >= h || b < 0 || b >= w) return false;
      if (s[a][b] == '#') return false;
      // if (dist[a][b] != INF) return false;
      return true;
    };

    rep(dir, 4) {
      int ni = i + di[dir];
      int nj = j + dj[dir];
      if (!ok(ni, nj)) continue;
      if (dist[ni][nj] > -cost) {
        dist[ni][nj] = -cost;
        pq.push({-dist[ni][nj], {ni, nj}});
      }
    }

    for (int di = -2; di <= 2; ++di) {
      for (int dj = -2; dj <= 2; ++dj) {
        int ni = i + di;
        int nj = j + dj;
        if (!ok(ni, nj)) continue;
        if (dist[ni][nj] > -cost + 1) {
          dist[ni][nj] = -cost + 1;
          pq.push({-dist[ni][nj], {ni, nj}});
        }
      }
    }
  }

  int ans = dist[d.first][d.second];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9548
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  ll x,y;
  cin >> x >> y;

  if(x < y){
    if((x >= 0 && y >= 0) || (y <= 0 && x <= 0))cout << y - x << endl; 
    else{
      cout << abs(abs(y)-abs(x)) + 1 << endl;
    }
  }//ok
  else{
    if(x <= 0 && y <= 0){
      if(x == 0)cout << x - y + 1 << endl;
      else{
	cout << x - y + 2 << endl;
      }
    }//ok
    else if(x >= 0 && y >= 0){
      if(y == 0)cout << 1 + x << endl;
      else cout << 2 + x - y << endl;
    }
    else{
      cout << abs(abs(x)-abs(y)) + 1 << endl;
    }
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main() {

    ll N;
    cin >> N;
    string S[N];
    rep(i,N) cin >> S[i];
    sort(S,S+N);
    string T[N];
    int A[N];
    rep(i,N) A[i] = 0;
    int count = -1;
    bool isExist = false;
    rep(i,N){
        if(i==0 || S[i]!=S[i-1]){
            count++;
            T[count] = S[i];
            isExist = true;
        }else{
            A[count]++;
        }
    } ll max = -1;
    rep(i,N){
        if(A[i]>max) max = A[i];
    }
    rep(i,N){
        if(A[i] == max) cout << T[i] << endl;
    }
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> v(n);
    for (auto&& vv : v) {
        cin >> vv;
    }

    vector<pair<int64_t, int64_t>> dp(n + 1);
    dp[0] = {0L, 1L};
    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, n) | reversed) {
            if (dp[j].second == 0L) {
                continue;
            }
            if (dp[j + 1].first < dp[j].first + v[i]) {
                dp[j + 1].first = dp[j].first + v[i];
                dp[j + 1].second = dp[j].second;
            } else if (dp[j + 1].first == dp[j].first + v[i]) {
                dp[j + 1].second += dp[j].second;
            }
        }
    }

    int64_t af = 0, as = 1;
    int64_t w = 0;
    for (auto i : irange(a, b + 1)) {
        if (af * i < as * dp[i].first) {
            af = dp[i].first;
            as = i;
            w = dp[i].second;
        } else if (af * i == as * dp[i].first) {
            w += dp[i].second;
        }
    }

    cout << setprecision(20) << af / (double)as << endl;
    cout << w << endl;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))

n4,n2=0,0
for i in range(N):
  if a[i] % 4 == 0:n4 += 1
  elif a[i] % 2 == 0:n2 += 1
    
if n4 >= N//2:print('Yes')
elif n4*2 + n2 >= N:print('Yes')
else:print('No')

Measured memory_bytes: 20068
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

const int MOD = 1'000'000'007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll h, w;
    cin >> h >> w;
    char ch;
    vector<int> v(w + 1);
    for (int i = 1; i <= h; i++)
    {
        v[0] = i == 1;
        for (int j = 1; j <= w; j++)
        {
            cin >> ch;
            if (ch == '.')
            {
                v[j] += v[j - 1];
                v[j] %= MOD;
            }
            else
            {
                v[j] = 0;
            }
        }
    }
    cout << v[w];
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int h,w,i;
  int a[101][101];

  scanf("%d %d", &h, &w);

  for(i=0;i<h;i++)
    scanf("%s", a[i]);

  for(i=0;i<w+2;i++)
    putchar('#');

    putchar('\n');

  for(i=0;i<h;i++){
    putchar('#');
    printf("%s", a[i]);
    putchar('#'); putchar('\n');
  }

  for(i=0;i<w+2;i++)
    putchar('#');

    return 0;


}


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 = 1; i <= (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;


int main() {
    int n; cin >> n;
    if(n / 100 == 7) {
        COUT("Yes");
        return 0;
    } else if((n % 100) / 10 == 7) {
        COUT("Yes");
        return 0;
    } else if((n %10) == 7) {
        COUT("Yes");
        return 0;
    } else {
        COUT("No");
        return 0;
    }

    
    return 0;
}

Measured memory_bytes: 3632
#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 ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int dp[3001][6001];

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> AB;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    AB.push_back({a, b});
  }
  sort(ALL(AB));
  int ans = 0;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++){
    for (int j = 0; j <= t - 1; j++){
      dp[i][j] = dp[i - 1][j];
      ans = max(ans, dp[i][j] + AB[i - 1].second);
      if(j - AB[i-1].first >= 0){
        dp[i][j] = max(dp[i][j], dp[i - 1][j - AB[i-1].first] + AB[i - 1].second);
      }
    }
  }
  cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  
  ll n,n1,n2; cin >> n;
  
  if(n == 1){cin >> n;cout << n << endl;return 0;}
  
  n1 = (n+1)/2; n2 = n/2;
  
  vector<ll> a1(n1);vector<ll> a2(n2);
  
  REP(i,n){
    
    if(i%2 == 0) cin >> a1[(i+1)/2];
    
    else cin >> a2[i/2];
    
  }
  
  if(n%2 == 0){
    
    reverse(ALL(a2));
    
    REP(i,n2) cout << a2[i] << " ";
    
    REP(i,n1-1) cout << a1[i] << " ";
    
    cout << a1[n1-1] << endl;
    
  }
  
  else if(n%2 == 1){
    
    reverse(ALL(a1));
    
    REP(i,n1) cout << a1[i] << " ";
    
    REP(i,n2-1) cout << a2[i] << " ";
    
    cout << a2[n2-1] << endl;
    
  }
}

Measured memory_bytes: 3712
//(5)6565656ってくりかえす

#include <stdio.h>
int main(void){
    unsigned long long int x,ans,rui;
    scanf("%lld",&x);
    ans=0;
    ans=x/11;
    ans*=2;
    rui=(ans/2)*11;
    if(x-rui>=1 && x-rui<=6){
        ans+=1;
    }else if(x-rui>=7){
        ans+=2;
    }
    printf("%lld\n",ans);
    
    return 0;
    
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

typedef struct _n {
  int deg;
  int right;
  int left;
  int r;
  int parent;
  int sib;
  int depth;
  int height;
} node;

//接点を格納する配列
node tree[100000];
int n;
//関数のプロトタイプ宣言
void setDepth(int);
int setHeight(int);
int main() {
  int i, j, k, l, r;
  //nを受け取る
  scanf("%d", &n);
  //木構造の各接点の情報を初期化
  for(i = 0; i < n; i++) {
    tree[i].parent = -1;
    tree[i].sib = -1;
    tree[i].depth = 0;
    tree[i].height = 0;
    tree[i].deg = 0;
  }
  //n行の入力を処理する（kでループしているがkは使わない）
  for(k = 0; k < n; k++) {
    //何番めの接点かをiに格納
    scanf("%d", &i);
    //接点の配列に、子を格納
    scanf("%d %d", &tree[i].left, &tree[i].right);
    //子の兄弟を設定
    if(tree[i].left != -1) tree[tree[i].left].sib = tree[i].right;
    if(tree[i].right != -1) tree[tree[i].right].sib = tree[i].left;
    //子に親を設定
    if(tree[i].left != -1)tree[tree[i].left].parent = i;
    if(tree[i].right != -1) tree[tree[i].right].parent = i;
    //子の数を設定
    if(tree[i].left != -1) tree[i].deg++;
    if(tree[i].right != -1) tree[i].deg++;
  }
  //kにrootとなる接点が配列の何番目にあるかを代入
  for(i = 0; i < n; i++) {
    if(tree[i].parent == -1) k = i;
  }
  //再帰関数を呼び出す（この関数で全てのtree[x].depthを設定）
  setDepth(k);
  //heightを設定する関数を呼び出す
  setHeight(k);
  //出力
  for(i = 0; i < n; i++) {
    //共通部分
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i, tree[i].parent, tree[i].sib, tree[i].deg, tree[i].depth, tree[i].height);
    
    //ここから接点の種類により分岐
    
    //接点の親が最初の-1から変わっていない場合それがrootとなる
    if(tree[i].parent == -1) {
      printf("root\n");
    }
    //子の数が0のときはleaf
    else if(tree[i].deg == 0) {
      printf("leaf\n");
    }
    /* leafでない場合internal nodeかrootになるが、
       rootの分岐は先に済ませたのでその他の場合　つまりinternal nodeの場合 
    */
    else {
      printf("internal node\n");
    }
  }
  return 0;
}

void setDepth(int r) {
  //引数は木構造のさくらんぼの繋がってる部分のイメージ（？）
  //tree[r]のそれぞれの子に、tree[r]の深さ+1をセット;
  if(tree[r].right != -1 )tree[tree[r].right].depth += 1 + tree[r].depth;
  if(tree[r].left != -1) tree[tree[r].left].depth += 1 + tree[r].depth;
  /* tree[r]のそれぞれの子から先の深さを決めるため、
     再帰的に関数を呼び出す
  */
  if(tree[r].left != -1) setDepth(tree[r].left);
  if(tree[r].right != -1) setDepth(tree[r].right);
}
int setHeight(int r) {
  int i, h=0, hl, hr, n;
  if(tree[r].deg == 0) {
    tree[r].height = 0;
    return 0;
  }
  if(tree[r].left != -1) hl = setHeight(tree[r].left);
  else hl = 0;
  if(tree[r].right != -1) hr = setHeight(tree[r].right);
  else hr = 0;
  h = (hl < hr)? hr: hl;
  h++;
  tree[r].height = h;
  return h;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <string>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, s, n) for(ll i = s; i < n; i++)
using namespace std;

const ll MOD = 1000000007;
int dp[110][5][5][5][5];
int main(){
  ll n;
  cin >> n;
  dp[0][0][0][0][0] = 1;
  rep(i, n)rep(c1, 5)rep(c2, 5)rep(c3, 5)rep(c4, 5)rep2(c5, 1, 5){
    dp[i+1][c2][c3][c4][c5] += dp[i][c1][c2][c3][c4];
    dp[i+1][c2][c3][c4][c5] %= MOD;
    if(c3==1 && c4==3 && c5==2) dp[i+1][c2][c3][c4][c5] = 0;
    if(c2==1 && c4==3 && c5==2) dp[i+1][c2][c3][c4][c5] = 0;
    if(c3==3 && c4==1 && c5==2) dp[i+1][c2][c3][c4][c5] = 0;
    if(c3==1 && c4==2 && c5==3) dp[i+1][c2][c3][c4][c5] = 0;
    if(c2==1 && c3==3 && c5==2) dp[i+1][c2][c3][c4][c5] = 0;
  }
  ll ans = 0;
  rep(c1, 5)rep(c2, 5)rep(c3, 5)rep(c4, 5){
    ans += dp[n][c1][c2][c3][c4];
    ans %= MOD;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double a,b,h,m,H,M;
    constexpr double pi=3.14159265358979;
    cin>>a>>b>>h>>m;
    H=h*pi/6+m*pi/360;
    M=m*pi/30;
    cout<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(H-M))<<'\n';
}


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

ll dp[2222][2222];


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

    ll mod = 1e9+7;
    ll n,m;
    cin>>n>>m;
    int s[n],t[m];
    for(int i=0;i<n;i++) cin>>s[i];
    for(int j=0;j<m;j++) cin>>t[j];
    for(int i=0;i<=n;i++) dp[i][0] = 1;
    for(int i=0;i<=m;i++) dp[0][i] = 1;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            dp[i+1][j+1] += dp[i+1][j] + dp[i][j+1] + mod - dp[i][j]; 
            if(s[i] == t[j]){
                dp[i+1][j+1] += dp[i][j];
            }
            dp[i+1][j+1] %= mod;
            //cerr << i << " " << j << " " << dp[i+1][j+1] << endl;
        }
    }
    cout << dp[n][m] << endl;

}

Measured memory_bytes: 35072
A,B=map(int,input().split())

L=[]
for i in range(100):
    if i<50:
        L.append(["."]*100)
    else:
        L.append(["#"]*100)
#print(L)


B-=1
for i in range(1,50):
    for j in range(99):
        if i%2==0 and j%2==1 and B>0:
            L[i][j]="#"
            B-=1
            
A-=1
for i in range(51,100):
    for j in range(99):
        if i%2==0 and j%2==1 and A>0:
            L[i][j]="."
            A-=1
print(100,100)
for i in range(100):
    print("".join(L[i]))

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

int main() {
  int n,d,x,j;
  cin>>n>>d>>x;
  std::vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++){
    for(j=0;v[i]*j+1<=d;j++){}
    x+=j;
  }
  cout<<x<<endl;
}


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

int main(){
  int x,y,z,w;
  cin >> x >> y >> z >> w;
  cout << z - (w - y) << " " << w + (z - x) << " ";
  cout << z - (w - y) - (z - x) << " " << w + (z - x) - (w - y) << endl;
}

Measured memory_bytes: 256
/**
 * ???????????±???????????????

????????????????????£????????§?????????????????????????????°??????????????°?????\??????????????????????????????????????£????????????????????£??????????????????????????????????????????????????\????????????????????????????????°???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????´???????????§??????

???????????´??° x ???????????????????????????????????????????????????????????°?????????????????????????????????

?????????????????????????????\?????????????????????????????????????????????????????????????????????????????¨?????¨?????????????????????

Input
??\???????????°????????????????????????????§????????????????????????????????????????????????????????????´??° x
??????????????????????§?????????????????????????

x ??? 0
?????¨?????\?????????????????????????????????????????????????????????????????????????????£????????????????????????

Output
??????????????????????????¨????????\????????¢?????§ x ???????????????????????????

Case i: x
????????§???i ?????????????§????????????????????????????????????????????????????Case??¨??????
i?????????????????????????????\???????????????????????????:?????????????????¨??´??° x
?????????????????????????????\????????????????????????????????\????????????????????????????????????

Constraints
1 ??? x ??? 10,000
???????????????????????°??? 10,000 ????¶?????????????
Sample Input
3
5
11
7
8
19
0
Sample Output
Case 1: 3
Case 2: 5
Case 3: 11
Case 4: 7
Case 5: 8
Case 6: 19

 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int x = 0, i = 1;

  while (true) {
    std::string param;

    getline(std::cin, param);
    std::istringstream iss(param);
    iss >> x;

    if (x > 10000) {
      std::cout << "Error: 1 <= x <= 10000" << std::endl;
    } else if (x == 0) {
      break;
    } else {
      std::cout << "Case " << i << ": " << x << std::endl;
      i++;
    }
  }

  return 0;
}

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

int main() {
	
	long long n,i,W;
	cin>>n>>W;
	long long wgt[n],val[n];
	
	for(i=0;i<n;i++)
    	cin>>wgt[i]>>val[i];
	
	long long dp[n+1][W+1];
	
	for(i=0;i<=n;i++)
	{
	    for(int j=0;j<=W;j++)
	    {
	        if(i==0||j==0)
    	        dp[i][j]=0;
	        else if(j>=wgt[i-1])
    	        dp[i][j]=max(dp[i-1][j], dp[i-1][j-wgt[i-1]] + val[i-1]);
	        else
    	        dp[i][j]=dp[i-1][j];
	    }
	   // cout<<dp[i][W]<<endl;
	}
	cout<<dp[n][W]<<endl;
	
	
	return 0;
}

Measured memory_bytes: 82432
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    ll a = (n-1)*(n-2)/2;
    if(a < k)cout << -1 << endl;
    else{
        cout << n-1+a-k << endl;
        REP(i, n-1){
            cout << 1 << " " << i+1 << endl;
        }
        ll cnt = 3, now = 2;
        rep(i, a-k){
            if(cnt > n){now++; cnt = now+1;}
            cout << now << " " << cnt << endl;
            cnt++;
        }
    }
}

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

using edge = pair<int, ll>;
using Graph = vector<vector<edge> >;

void dfs(const Graph &G, int v, int p, long long sum, vector<long long> &d) {
    d[v] = sum;
    for (auto a : G[v]) {
        if (a.first == p) continue;
        dfs(G, a.first, v, sum+a.second, d);
    }
}

int main() {
    int N; cin >> N;
    Graph G(N);

    for (int i = 0; i < N-1; ++i) {
        int a, b; 
        ll c; 
        cin >> a >> b >> c;
        --a, --b;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    
    int Q, K; 
    cin >> Q >> K; --K;
    vector<ll> d(N, 0);
    dfs(G, K, -1, 0, d);

    for (int i=0; i<Q; i++) {
        int x, y; 
        cin >> x >> y; 
        --x, --y;
        cout << d[x] + d[y] << endl;
    }
}   


Measured memory_bytes: 17408
#include <cstdio>

using namespace std;
int n,t,i,a[200004];
long long nr;
int main()
{
    scanf ("%d %d", &n, &t);
    for (i=1;i<=n;i++)
        scanf ("%d", &a[i]);
    nr=0LL;
    for (i=1;i<=(n-1);i++)
    {
        if (a[i+1]>(a[i]+t-1))
            nr=(0LL)+nr+t;
        else
            nr=(0LL)+nr+(a[i+1]-a[i]);
    }
    nr=(0LL)+nr+t;
    printf ("%lld", nr);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int num=(int)1e6+1;
vector<vector<long long int> > a;
vector<long long int> c;
long long int n,m,x;
long long int ans=INT_MAX;

void func(int r,vector<long long int> col_sum,long long int curr_cost)
{
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if(col_sum[i] >= x)
            cnt++;
    }
    if(cnt==m)
    {
        ans=min(ans,curr_cost);
        return;
    }
    if(r>n-1)
        return;
    for(int i=r;i<n;i++)
    {
        for(int j=0;j<m;j++)
            col_sum[j]+=a[i][j];
        func(i+1,col_sum,curr_cost+c[i]);
        for(int j=0;j<m;j++)
            col_sum[j]-=a[i][j];
    }
}
void go()
{
    cin>>n>>m>>x;
    c.resize(n);
    a.resize(n,vector<long long int>(m));
    for(int i=0;i<n;i++)
    {
        long long int z;
        cin>>z;
        c[i]=z;
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    long long int min_sum=INT_MAX;
    for(int i=0;i<m;i++)
    {
        long long int temp_sum=0;
        for(int j=0;j<n;j++)
        {
            temp_sum+=a[j][i];
        }
        min_sum=min(min_sum,temp_sum);
    }
    if(min_sum < x)
    {
        cout<<-1;
        return;
    }
    vector<long long int> temp(m,0);
    func(0,temp,0);
    cout<<ans;
}
int main()
{
    FIO;
    go();
    return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,odd,even;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if (x&1) odd++;else even++;
	}
	even+=odd/2;odd%=2;
	if (even) even=1;
	puts(odd+even==1?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
str = input()

result = "AC"

if str[0:1] != "A":
    result = "WA"
    
if "C" not in str[2:-1]:
    result = "WA"

if str.count("C") != 1:
    result = "WA"
    

str = str.replace("A", "")
str = str.replace("C", "")
if not str.islower():
    result = "WA"

print(result)

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == 1 && b == 1 && c == 1){
        cout << 0 << endl;
        return 0;
    }
    if(a == b && b == c && c == a){
        cout << -1 << endl;
        return 0;
    }
    int count = 0;
    while(a%2 == 0 && b%2 == 0 && c%2== 0){
        count++;
        int p,q,r;
        p = a/2;
        q = b/2;
        r = c/2;
        a = q+r;
        b = r+p;
        c = p+q;
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

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

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;
const int MOD = 1e9+7;

int mul(int a, int b) {
	return (ll)a * b % MOD;
}

int n, p[MAXN], dp[MAXN], cnt[MAXN];

set <pii> s;
map <int, int> mapa;

int main() {
	scanf("%d",&n);
	REP(i, n) scanf("%d",&p[i]);
	s.insert(mp(-1, 0));
	REP(i, n) {
		pii t = *s.rbegin();
		dp[i] = t.sec;
		if (mapa[t.fi - 1]) {
			mapa[t.fi]--;
			s.erase(--s.end());
			dp[i]++;
			t = *s.rbegin();
		}
		s.insert(mp(min(p[i], t.fi + 2), dp[i]));
		mapa[min(p[i], t.fi + 2)]++;
		cnt[dp[i]]++;
	}

	int uk = 0, sol = 1;
	REP(i, n) {
		uk += cnt[i];
		sol = mul(sol, uk - i);
		int t = uk-i;
	}
	printf("%d\n",sol);
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;


int dx[13]={0,1,1,0,1,1,1,0,1,1,1,0,1};
int dy[13]={0,1,0,1,-1,1,0,1,-1,1,0,1,-1};
int dz[13]={1,0,0,0,0,1,1,1,1,-1,-1,-1,-1};



int main(){
	int n,m,p;
	while(cin>>n>>m>>p,n){
		int mp[9][9][9],num[9][9]={0};
		memset(mp,-1,sizeof(mp));
		int draw=1;
		int P=p;
		int once=1;
		for(int i=1;i<=p;i++,P--){
			int x,y,z;
			cin>>x>>y;
			if(once){
				if(num[x][y]>=n)break;
				num[x][y]++;
				z=num[x][y];
				mp[x][y][z]=i%2;
				
				int win=0;
				
				for(int j=0;j<13;j++){
					
					int a=0;
					
					for(int k=1;mp[x+dx[j]*k][y+dy[j]*k][z+dz[j]*k]==i%2;k++,a++);
					for(int k=1;mp[x-dx[j]*k][y-dy[j]*k][z-dz[j]*k]==i%2;k++,a++);
					
					
					if(a+1>=m)win=1;
				}
				
				if(win==1&&i%2==1&&once){
					once=0;
					cout<<"Black "<<i<<endl;
					draw=0;
				}
				if(win==1&&i%2==0&&once){
					once=0;
					cout<<"White "<<i<<endl;
					draw=0;
				}
			}
		}
		
		if(draw)cout<<"Draw\n";
		
		/*
		for(int z=1;z<=n;z++){
			for(int y=1;y<=n;y++){
				for(int x=1;x<=n;x++){
					if(mp[x][y][z]>=0)cout<<mp[x][y][z];
					else cout<<"*";
				}
				cout<<endl;
			}
			cout<<endl;
		}
		*/
	}
	
	return 0;
}


Measured memory_bytes: 1160
from collections import deque
N = int(input())
b = [int(x) - 1 for x in input().split()]
d = deque()
while b:
  popped = -1
  for i in range(len(b))[::-1]:
    if b[i] == i:
      d.appendleft(i + 1)
      popped = b.pop(i)
      break
  if popped == -1:
    print(-1)
    exit()
print(*d, sep="\n")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int x;
    cin >> x;
    
    x>=30 ? cyes : cno;
    
    

    return 0;
}


Measured memory_bytes: 3648
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d,y(5)
    integer(8),allocatable::x(:)
  
    read(*,*) n
    do i=1,5
        read(*,*)y(i)
    end do
    a=minval(y)
    if(mod(n,a)==0)then
        b=n/a
    else
        b=n/a+1
    endif
    write(*,*)b+4
    stop
end program sample
  



Measured memory_bytes: 2856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n,k;
 cin >> n >> k;
 double ans=0;
 for(int i=1;i<=n;i++){
  int exp=ceil(log2(k*1.00/i));
  exp=max(exp,0);
  ans+=1.00/n*pow(0.5,exp);
 }
 cout.precision(12);
 cout<<fixed;
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0] - 1]
for i in range(1, n):
    a = A[i] - 1
    ans += B[a]
    aa = A[i - 1] - 1
    if a - 1 == aa:
        ans += C[aa]
        
print(ans)
    

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<list>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int n;
    cin >> n;
    int v[n];
    int c[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n) {
        if (v[i] > c[i]) ans += v[i] - c[i];
    }
    cout << ans << endl;
}


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

int main(){
int n;
scanf("%d",&n);
vector<int> v;
for (int x = 0; x<2*n; x++){
    int t;
    scanf("%d",&t);
    v.push_back(t);
}
sort(v.begin(),v.end());
int ans = 0;
for (int x = 0; x<2*n; x++){
    if (x%2==0) ans += v[x];
}
printf("%d",ans);
}


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

const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V,E; cin >> V >> E;
    struct edge{int to,cost;};
    vector<vector<edge>> G(V);
    for (int i=0;i<E;++i){
        int s,t,d; cin >> s >> t >> d;
        G[s].emplace_back(edge{t,d});
    }
    vector<vector<int>> dp(1<<V,vector<int>(V,INF));
    dp[0][0]=0;
    for (int bit=0;bit<(1<<V);++bit){
        for (int i=0;i<V;++i){
            for (auto e:G[i]){
                int j=e.to;
                if (!(bit&1<<j)){
                    dp[bit|1<<j][j]=min(dp[bit|1<<j][j],dp[bit][i]+e.cost);
                }
            }
        }
    }
    cout << (dp[(1<<V)-1][0]==INF?-1:dp[(1<<V)-1][0]) << endl;
}


Measured memory_bytes: 6160
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int w,s;
void solve(){
	if(w >= s) cout << "unsafe" << endl;
	else puts("safe");
	return;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> w;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define N 100005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, ans;
int a[N], b[N];
int tmpa[N], tmpb[N];
int date[N << 1], tot;

bool vis[N << 1];
int fa[N << 1];
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline void merge(int x, int y) { fa[find(x)] = find(y); }

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]), a[n + 1] ^= a[i];
	for (int i = 1; i <= n; ++i) read(b[i]), b[n + 1] ^= b[i];

	memcpy(tmpa, a, sizeof a);
	memcpy(tmpb, b, sizeof b);
	sort(tmpa + 1, tmpa + n + 2);
	sort(tmpb + 1, tmpb + n + 2);
	for (int i = 1; i <= n + 1; ++i)
		if (tmpa[i] != tmpb[i]) return puts("-1"), 0;

	++n;
	for (int i = 1; i <= n; ++i)
		date[++tot] = a[i], date[++tot] = b[i];
	sort(date + 1, date + tot + 1);
	for (int i = 1; i <= n; ++i) {
		a[i] = lower_bound(date + 1, date + tot + 1, a[i]) - date;
		b[i] = lower_bound(date + 1, date + tot + 1, b[i]) - date;
	}

	for (int i = 1; i <= n << 1; ++i) fa[i] = i;
	for (int i = 1; i <= n; ++i)
		if (a[i] != b[i]) {
			merge(a[i], b[i]);
			vis[a[i]] = true;
			vis[b[i]] = true;
			if (i < n) ++ans;
		}
	vis[a[n]] = true;

	if (!ans) return puts("0"), 0;
	for (int i = 1; i <= n << 1; ++i)
		if (vis[i] && fa[i] == i) ++ans;
	printf("%d\n", ans - 1);
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int main ()
{
  	int H,W; cin >> H >> W;
 	vector < string > M(H);
    for (int i = 0; i < H; i++) {
        cin >> M[i]; 
    }
  
  	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
        	if (M[i][j] == '#') {
            	int cnt = 0;
                for (int k = 0; k < 4; k++) {
                	int nx = i + dx[k];
                    int ny = j + dy[k];
                    if (nx < 0 || ny < 0 || nx >= H || ny >= W) {
                  		continue;
                    }
                    if (M[nx][ny] == '#') {
						cnt++;
                    }
                }
                if (cnt < 1) {
                	cout << "No" << endl;
                  	return 0;
                }
            }
        }
    }
  
  	cout << "Yes" << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

using namespace std;


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << endl;
    } else {
        int d = k - a;
        int dd = d - b;
        if(dd <= 0){
            cout << a << endl;
        } else {
            cout << a - dd << endl;
        }
    }
}

Measured memory_bytes: 3636
N = int(input())
P = ''.join(map(str, list(map(int, input().split()))))
Q = ''.join(map(str, list(map(int, input().split()))))
import itertools

T = [''.join(map(str, a)) for a in sorted(list(itertools.permutations(range(1, N + 1))))]

P_i = 0
Q_i = 0
for i, t in enumerate(T):
    if t == P:
        P_i = i
    if t == Q:
        Q_i = i
ans = abs(P_i - Q_i)
print(ans)


Measured memory_bytes: 16620
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  ll ans = 0;
  REP(i,n) ans += i;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let xy = (0..n)
        .map(|_| (read::<i64>(), read::<i64>()))
        .collect::<Vec<_>>();
    let mut t = vec![vec![0.0; n]; n];
    for i in 0..n {
        let (xi, yi) = xy[i];
        for j in i + 1..n {
            let (xj, yj) = xy[j];
            let dx = (xi - xj);
            let dy = (yi - yj);
            let d = ((dx * dx + dy * dy) as f64).sqrt();
            t[i][j] = d;
            t[j][i] = d;
        }
    }

    let mut visited = vec![false; n];
    let mut ans = 0.0;
    for i in 0..n {
        let (c, x) = f(&t, &mut visited, i);
        ans += x
    }

    let mut div = 1.0;
    for i in 1..n + 1 {
        div *= i as f64
    }
    println!("{}", ans / div);

    fn f(d: &Vec<Vec<f64>>, visited: &mut Vec<bool>, next: usize) -> (usize, f64) {
        let mut ans = 0.0;
        visited[next] = true;
        let mut cc = 0;

        for i in 0..visited.len() {
            if !visited[i] {
                let (c, x) = f(d, visited, i);
                cc += c;
                ans += d[i][next] * (c as f64) + x
            }
        }
        visited[next] = false;
        (std::cmp::max(1, cc), ans)
    }
}


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

ll q, h, s, d, n, ans;

int main() {
    cin >> q >> h >> s >> d >> n;
    s = min(min(4 * q, 2 * h), s);
    d = min(2 * s, d);
    ans = (n / 2) * d + (n % 2) * s;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
z=-1e8;
n,i;main(a,s){
  for(;scanf("%d",
             !n?
             s=s>=0&&!printf("%d\n",a),i=a=z,&n:&i),
      (i==z?n:((a=a<(s+=i)?s:a),n--))
      ;s*=s>0);
}

/*
//109B
s;main(i,n,m){
  for(;scanf("%d",&i),i;s=!printf("%d\n",m))
    for(m=-1e8;i--;m=m<(s+=n)?s:m,s*=s>0)
      scanf("%d",&n);
}
  */

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

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

using namespace std;

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

  queue<string> que;
  for (int i = 1; i <= 9; ++i) {
    string s = "0";
    s[0] += i;
    que.push(s);
  }
  for (int i = 0; i < K; ++i) {
    string here = que.front();
    if (i == K - 1) {
      cout << here << endl;
      break;
    }
    que.pop();
    int x = here.back() - '0';
    for (int i = x - 1; i <= x + 1; ++i) {
      if (i < 0 || 10 <= i) {
        continue;
      }
      que.push(here + (char)('0' + i));
    }
  }
}


Measured memory_bytes: 9636
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a = list(input())

count = 0

if len(a) % 2 == 0:
    kkk = len(a)//2
    for i in range(len(a)//2):
        if a[kkk+i] != a[kkk-(i+1)]:
            count += 1
else:
    kkk = len(a)//2+1
    for i in range(len(a)//2):
        if a[kkk+i] != a[kkk-(i+2)]:
            count += 1

print(count)



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
int k;
vector<ll> a;
ll n=50000000000;
int P(int i) {
    int ten = 1;
    rep(d, i) {
        ten *= 10;
    }
	return ten;
}
void lun(ll nm){
	for(int i=0;i<10;i++){
		if(abs(nm%10-i)>1) continue;
		ll number = nm*10 + i;
		if(number>n) continue;
		//cout<<"number=="<<number<<endl;
		a.push_back(number);
		lun(number);
}}


int main(){
 cin>>k;
for(int i=1;i<10;i++){
	lun(i);
	a.push_back(i);
}
sort(a.begin(),a.end());
cout<<a[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 7440
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
double n,d,x;
double solve(double T,double d,double x)
{
	if(T==1)return (2*d+x)/2;
	double sum=(d+(2*T-1)*x+d)/2;
	double nxd=d+(5*x+2*d)/(2*T);
	double nxx=x+2*x/T;
	return sum+solve(T-1,nxd,nxx);
}
int main()
{
	n=read();d=read();x=read();
	printf("%.9lf\n",solve(n,d,x));
	return 0;
}


Measured memory_bytes: 9472
fn main() {
    let s = read::<String>();
    let mut ret: Vec<char> = Vec::new();
    for (i, c) in s.char_indices() {
        if (i+1) % 2 != 0 {
            ret.push(c);
        }
    }
    println!("{}", ret.into_iter().collect::<String>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner068
{
    public class ABC089C
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            long[] count = new long[5];

            HashSet<string> names = new HashSet<string>();
            for(int i=0; i<n; i++)
            {
                string s = Console.ReadLine();
                switch( s.Substring(0,1) )
                {
                    case "M":
                        count[0]++;
                        break;
                    case "A":
                        count[1]++;
                        break;
                    case "R":
                        count[2]++;
                        break;
                    case "C":
                        count[3]++;
                        break;
                    case "H":
                        count[4]++;
                        break;
                }
            }

            long allcount = 0;
            for(int i=0; i<5; i++)
            {
                for(int j = i+1; j<5; j++)
                {
                    for(int k = j+1; k<5; k++)
                    {
                        allcount += count[i] * count[j] * count[k];
                    }
                }
            }

            Console.WriteLine(allcount);
        }
    }
}

Measured memory_bytes: 15440
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll a,b;
    cin>>a>>b;
    ll d=b*15;
    for(ll i=1;i<=d;i++){
        if(floor(i*0.08)==a && floor(i*0.1)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
S=list(map(int,"1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")))
k=int(input())
print(S[k-1])



Measured memory_bytes: 2940