akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define X 19
#define N (1<<19)
ll n,a[N];
ll m1[N],m2[N];

void Update(int p,int x){
    if(x==m1[p]||x==m2[p])return;
    if(a[m1[p]]<a[x]){
	m2[p]=m1[p];
	m1[p]=x;
	return;
    }
    if(a[m2[p]]<a[x]){
	m2[p]=x;
    }
    return;
}

int main(){
    cin>>n;
    n=(1<<n);
    lol(i,n){
	cin>>a[i];
	m1[i]=i;
	m2[i]=-1;
    }
    m1[n]=m2[n]=-1;
    lol(k,n){
	bool t[X];
	ll cop=k;
	lol(i,X){
	    t[i]=cop%2;
	    cop/=2;
	}
	lol(i,X){
	    if(t[i])continue;
	    ll to=k+(1<<i);
	    if(m1[k]>=0)Update(to,m1[k]);
	    if(m2[k]>=0)Update(to,m2[k]);
	}
    }
    ll maxi=-1;
    for(int i=1;i<n;i++){
	ll gre=a[m1[i]]+a[m2[i]];
	maxi=max(maxi,gre);
	cout<<maxi<<endl;
    }
    return 0;
}


Measured memory_bytes: 15360
from collections import deque
H, W = map(int, input().split())
field = ''
for i in range(H):
    field += input()

def bfs(start):
    dist = [0] * (H * W)
    q = deque([start])
    while q:
        p = q.popleft()
        c = dist[p] + 1
        if p - W != start and p - W >= 0 and field[p - W] == '.' and dist[p - W] == 0:
            dist[p - W] = c
            q.append(p - W)
        if p + W != start and p + W < H * W and field[p + W] == '.' and dist[p + W] == 0:
            dist[p + W] = c
            q.append(p + W)
        if p - 1 != start and p - 1 >= 0 and field[p - 1] == '.' and dist[p - 1] == 0 and p % W != 0:
            dist[p - 1] = c
            q.append(p - 1)
        if p + 1 != start and p + 1 < H * W and field[p + 1] == '.' and dist[p + 1] == 0 and p % W != W - 1:
            dist[p + 1] = c
            q.append(p + 1)
    return dist[p]

ans = 0
for s in range(H * W):
    if field[s] == '.':
        ans = max(ans, bfs(s))
print(ans)


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int keta(int num) {
  int ans = 1;
  while (true) {
    if (num <= 9) {
      return ans;
    } else {
      num /= 10;
      ans++;
    }
  }
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (keta(i) % 2 == 1) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

const long mod = 1e9 + 7;

long powmod(long x, long n){
  long ret = 1;
  while(n > 0){
    if(n&1) ret *= x, ret %= mod, n -= 1;
    else x *= x, x %= mod, n >>= 1;
  }
  return ret;
}

vector<long> fact;
vector<long> revfact;

void setfact(int n){
  fact.resize(n+1); revfact.resize(n+1);
  fact[0] = 1;
  rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;
  
  revfact[n] = powmod(fact[n], mod-2);
  for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

long getC(int n, int r){
  return fact[n] * revfact[r] % mod * revfact[n-r] % mod;
}

int main(){
    int h, w, a, b; cin >> h >> w >> a >> b;
    setfact(h+w);
    long ans = 0;
    For(i, b, w) ans = (ans + getC(h-1-a+i, i) * getC(w+a-i-2, a-1)) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// n枚のコイントスで表の数が裏の数を上回る確率
double CoinToss(const vector<double> &p){
    long long n = p.size();
    // i枚投げた時、j枚表になる確率
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1.0;
    for(long long i=1; i<=n; i++){
        for(long long j=0; j<=n; j++){
            if(j == 0) dp[i][j] = dp[i-1][j]*(1.0-p[i-1]);
            else dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1.0-p[i-1]);
        }
    }
    // 表が裏の数を上回る確率を計算
    double total = 0.0;
    for(long long i=n; i>=n/2+1; i--) total += dp[n][i];
    return total;
}

int main(){
    Init();
    ll n; cin >> n;
    vector<double> p(n, 0);
    rep(i, n) cin >> p[i];
    cout << CoinToss(p) << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int n, x;
int v[30], dp[1000001];
bool sosu[1000001];
int main()
{
	for(int i = 2; i < 1000000; i++)
	{
		if(!sosu[i])
		{
			for(int j = 2; j * i <= 1000000; j++)
			{
				sosu[i * j] = 1;
			}
		}
	}
	while(1)
	{
		cin >> n >> x;
		if(n == 0 && x == 0)
			break;
		for(int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		memset(dp, 0, sizeof(dp));
		dp[0]= 1;

		for(int i = 0; i < n; i++)
			for(int j  = 0; j <= x - v[i]; j++)
				if(dp[j])
						dp[j + v[i]] = dp[j];
					for(int i = x; i >= 0; i--)
					{
						if(!sosu[i] && dp[i])
						{
							if(i)
								cout << i << endl;
							else
								cout << "NA" << endl;
							break;
						}
					}
				}
				return 0;
			}

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


signed main(){
  Int n;
  cin>>n;
  Int f[n][10];
  for(Int i=0;i<n;i++)
    for(Int j=0;j<10;j++)
      cin>>f[i][j];
  Int p[n][11];
  for(Int i=0;i<n;i++)
    for(Int j=0;j<11;j++)
      cin>>p[i][j];

//入力終わり　

  Int ans=-(1LL<<55);//適当な小さい数

  for(Int b=1;b<(1<<10);b++){
    Int tmp=0;
    for(Int i=0;i<n;i++){
      Int k=0;
      for(Int j=0;j<10;j++)
	if((b>>j)&1) if(f[i][j]) k++;
      tmp+=p[i][k];
    }
    ans=max(ans,tmp);
  }

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

Measured memory_bytes: 256
import itertools
n=int(input())
numbers1k=[]
numbers2k=[]
s=[]
for i in range(n):
    s.append(i+1)
p=itertools.permutations(s,n)
u=list(p)
#print(u)
numbers1=input().rstrip().split(" ")
for num1 in numbers1:
    numbers1k.append(int(num1))
numbers2=input().rstrip().split(" ")
for num2 in numbers2:
    numbers2k.append(int(num2))
com1=tuple(numbers1k)
com2=tuple(numbers2k)
for i in range(len(u)):
    if u[i]==com1:
        a=i+1
for j in range(len(u)):
    if u[j]==com2:
        b=j+1
#print(a)
#print(b)
print(abs(b-a))

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

void trace(int A[], int n){
    for (int i = 0; i < n-1; i++) cout << A[i] << " ";
    cout << A[n-1] << "\n";
}

int main() {
    int N, temp, count = 0, minj;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    for (int i = 0; i < N; i++){
        minj = i;
        for (int j = i; j < N; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        temp = A[i];
        A[i] = A[minj];
        A[minj] = temp;
        if (i != minj) count++;
    }

    trace(A,N);
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3084
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

int n, m;

void run() {
	scanf("%d%d", &n, &m);
	// pok=1/2**m
	// x=(1900*m+100*(n-m))*2**m
	printf("%d\n", (1900 * m + 100 * (n - m)) << m);

}

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


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

long long n, a, b;
vector<int> res;

bool solve();

int main() {
  cin >> n >> a >> b;
  if (solve())
    for (int i = 0; i < n; ++i) cout << res[i] << " \n"[i == n - 1];
  else
    cout << -1 << endl;
  return 0;
}

bool solve() {
  if (n < a || n < b || a + b - 1 > n || b < (n + a - 1) / a) return 0;
  for (int i = 0; i < a; ++i) res.push_back(n - a + 1 + i);
  --b;
  for (int i = n - a; i > 0;) {
    if (b == i) {
      while (i) res.push_back(i--);
    } else {
      --b;
      long long num = min(i - b, a);
      for (int j = 0; j < num; ++j) res.push_back(i - num + 1 + j);
      i -= num;
    }
  }
  return 1;
}

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

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

int main(void) {
	int n;
	map<string, int> m;
	string s;
	cin >> n;
	rep(i, n) {
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
	return 0;
}

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

int main() {
  long long H;
  int N;
  cin >> H >> N;
  vector<long long> V(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
   
  long long sum = 0;
  for (int j = 0; j < N; j++)
    sum += V.at(j);
  
  if (sum >= H)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 1024
import sys
s = input()
l = len(s)
del_len_max = l-2
del_len_min = 1 if l%2 == 1 else 2
if del_len_min == del_len_max:
    print(del_len_max)
    sys.exit()
for i in range(del_len_min, del_len_max+2, 2):
    before = s[0:(l-i)//2]
    after = s[(l-i)//2:l-i]
    if before == after:
        print(l-i)
        sys.exit()

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    lint l = min(X / D, K);

    X -= D * l;
    K -= l;
    dd(X, K);

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << abs(X - D) << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n2 = n;
        int sum = 0;
        while(n2 >= 1){
            sum = sum + n2%10;
            n2 = n2 / 10;
        }
        if(n%sum == 0){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 25172
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

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

long long lcm(long long a, long long b) {
	long long  g = gcd(a, b);
	return a / g * b;
}

int main() {
	long long a, b;
	cin >> a >> b;
	cout << (a - gcd(a, b)) * 3 << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    while (N) {
        if (N%10 == 7) {
            cout << "Yes" << endl;
            return;
        }
        N /= 10;
    }
    cout << "No" << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

//困ったら全探索
//全探索をしろ
//範囲を絞ればACするはずだ

int main(){
    int n;
    cin >> n;
    int x = 800*n;
    int y = 200*(n / 15);
    cout << x - y << endl;
}

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

using ll = long long int;

const int MAX_N = (int)(2e5 + 5);

int n, k;

ll cnt[MAX_N];
map<int, pair<int, int>> mp;

ll ans;

int main(void){
  scanf("%d %d", &n, &k);

  for (int i = 1; i <= n; ++i) cnt[i % k] += 1;

  for (int i = 1; i <= n; ++i) {
    int amodk = i % k;
    if (mp.find(amodk) != mp.end()) continue;
    int bmodk = (k - amodk) % k;
    int cmodk = (k - bmodk) % k;
    int amodk_re = (k - cmodk) % k;
    if (amodk == amodk_re) mp[amodk] = make_pair(bmodk, cmodk);
  }

  for (const auto e : mp) {
    ans += cnt[e.first] * cnt[e.second.first] * cnt[e.second.second];
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1024
class Fenwick:
    def __init__(self, n):
        self.n = n
        self.BIT = [0] * (n + 1)
    
    def getsum(self, i):
        ret = 0
        i += 1
        while(i > 0):
            ret += self.BIT[i]
            i -= i & -i
        return ret
    
    def add(self, i, x):
        i += 1
        while(i <= self.n):
            self.BIT[i] += x
            i += i & -i

N, Q = map(int, input().split())
A = list(map(int, input().split()))
bit = Fenwick(N)
for i in range(N):
    bit.add(i, A[i])

for q in range(Q):
    t, a, b = map(int, input().split())
    if t == 0:
        bit.add(a, b)
    else:
        print(bit.getsum(b - 1) - bit.getsum(a - 1))

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

int main() {
  int N, M;
  cin >> N;
  M = N;

  int x = 100000000;
  int sum = 0;
  for (int i = 0; i < 9; i++) {
    sum += M / x;
    M = M - (M / x) * x;
    x /= 10;
  }
  if ((N % sum) ==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import numpy as np

def main():
  N, M, X = map(int, input().split())
  C = []
  A = []
  for i in range(N):
    l = (list(map(int, input().split())))
    C.append(l[0])
    A.append(l[1:])

  cost = np.inf

  for i in range(2**N):
    tmp_cost = 0
    skills = np.zeros(M)
    for j in range(N):
      if bin(i >> j)[-1] == '0':
        continue
      tmp_cost += C[j]
      skills = np.add(skills, np.array(A[j]))

    if (skills >= X).all() and tmp_cost<cost:
      cost = tmp_cost

  if cost == np.inf:
    print(-1)
  else:
    print(cost)







if __name__ == "__main__":
  main()

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

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;

int main(){
  long long a,b;
  cin >> n >> a >> b;
  int x[n]; rep(i,n) cin >> x[i];
  ans = 0;
  rep(i,n-1){
    int tmp = x[i+1]-x[i];
    ans += min(a*tmp, b);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long n = Long.parseLong(br.readLine());

		long ans = 0;

		for (int a = 1; a < n; a++) {
			for (int b = 1; b < n; b++) {
				if (a * b >= n)
					break;
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main (){
    int N;
    cin >> N;
    vector<int> del(N);

    for (int i=0;i<N;i++)cin >> del[i];
    int ans =0;
    for (int i=0;i<N;i++){
        for(int j = i+1;j<N;j++){
            ans += del[i]*del[j];
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,n;
  scanf("%d %d",&x,&y);
  if(x<y){
    n=y;
    y=x;
    x=n;
  }
  while(y != 0){
    n=y;
      y=x%n;
      x=n;
    }
  printf("%d\n",x);
  return 0;
}



Measured memory_bytes: 2128
import Data.List
import Control.Monad

solve :: [Int] -> Int -> Int -> Int -> Int -> Int
solve [] _ _ _ _ = 1
solve (t:rs) ti 0 c k = 1 + solve rs (t + k) (c - 1)c k
solve (t:rs) ti count c k
  | t <= ti = solve rs ti next_c c k
  | True = 1 + solve rs (t + k) (c - 1) c k
    where
      next_c = count - 1

main :: IO ()
main = do
  n:c:k:_ <- fmap (\x -> read x :: Int) <$> words <$> getLine
  h:ts <- sort <$> fmap (\x -> read x :: Int) <$> replicateM n getLine
  print $ solve ts (h + k) (c - 1) c k


Measured memory_bytes: 62204
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n;
  cin >> n;
  vector< pair<int,int> > p(n);
  for(int i=0; i<n; i++) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  cout << p[n-1].first + p[n-1].second << endl;
  return 0;
}

// EOF


Measured memory_bytes: 1024
def calc(nums):
    ret = 0
    for a, b, c, d in req:
        if nums[b - 1] - nums[a - 1] == c:
            ret += d
 
    return ret
 
 
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
 
ans = 0
 
stack = []
 
# [1]～[m]までキューに追加します。実は[1]だけでもいいです。考えてみてください。
for i in range(1, m + 1):
    stack.append([i])
 
while stack:
    seq = stack.pop()
 
    if len(seq) == n:
        score = calc(seq)
        ans = max(ans, score)
    else:
        for i in range(seq[-1], m + 1):
            seq_next = seq + [i]
            stack.append(seq_next)
 
print(ans)

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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


int main(void) {
	int x;
	int maxi = 0;

	cin >> x;
	FOR(i, 2, 1000) {
		FOR(t, 1,1000) {
			if (pow(t, i) > x) {
				break;
			}
			if (pow(t, i) > maxi) {
				maxi = pow(t, i);
			}
		}
	}
	cout << maxi << endl;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

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

  int32_t N;
  int32_t result;
  cin >> N;
  vector<int32_t> d(N);
  if (N % 2 == 1) {
    result = 0;
  } else {
    for (int32_t i = 0; i < N; ++i) {
      cin >> d[i];
    }
    sort(d.begin(), d.end());

    const int32_t upper_1st = N / 2 - 1;
    const int32_t lower_2nd = N / 2;

    result = d[lower_2nd] - d[upper_1st];
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 768
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B, C = mapint()
costs = {'A': A, 'B': B, 'C': C}
old_a, old_b = list(input())

if costs[old_a]==0 and costs[old_b]==0:
    print('No')
    exit()

commands = []
for _ in range(N-1):
    nx_a, nx_b = list(input())
    if costs[old_a]==0 and costs[old_b]==0:
        print('No')
        exit()
    elif costs[old_a]==0:
        costs[old_a] += 1
        costs[old_b] -= 1
        commands.append(old_a)
        
    elif costs[old_b]==0:
        costs[old_b] += 1
        costs[old_a] -= 1
        commands.append(old_b)

    else:
        if old_a==nx_a or old_a==nx_b:
            commands.append(old_a)
            costs[old_a] += 1
            costs[old_b] -= 1
        else:
            commands.append(old_b)
            costs[old_b] += 1
            costs[old_a] -= 1
    old_a, old_b = nx_a, nx_b

if costs[old_a]==0 and costs[old_b]==0:
    print('No')
    exit()
elif costs[old_a]==0:
    costs[old_a] += 1
    costs[old_b] -= 1
    commands.append(old_a)
    
else:
    costs[old_b] += 1
    costs[old_a] -= 1
    commands.append(old_b)

print('Yes')
print('\n'.join(commands))

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn gcd(a:i128, b:i128) -> i128 {

    let mut a = a;
    let mut b = b;
    let mut tmp = 0;
    if a < b {
        tmp = a;
        a = b;
        b = tmp;
    }

    let mut r = a % b;
    while r !=0 {
        a = b;
        b = r;
        r = a % b;
    }

    b
}

fn canti() {

    let data: Vec<i128> = read_vec();

    let lcm = (data[2]/gcd(data[2],data[3])) * data[3];
    //println!("lcm {}", lcm);
    let b =  data[1]/data[2] + data[1]/data[3] - data[1]/lcm ;
    //println!("a {}", b);
    let a =(data[0]-1)/data[2] + (data[0]-1)/data[3] - (data[0]-1)/lcm;
    //println!("b {}", a);


    println!("{}", (data[1] - data[0] + 1) - (b-a));
}

fn main() {
    canti();
}

Measured memory_bytes: 2168
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(string, s, t);
    var(int, a, b);
    var(string, u);
    if (s == u) --a;
    if (t == u) --b;
    print(a, b);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
    if i==0:
        if h[i]>h[i+1]+1:
            print("No")
            exit(0)
        else:
          	h[i]-=1
    elif h[i]<=h[i+1]:
        if h[i]-1>=h[i-1]:
            h[i]-=1
    elif h[i]==h[i+1]+1:
        if h[i]-1>=h[i-1]:
            h[i]-=1
        else:
            print("No")
            exit(0)
    else:
        print("No")
        exit(0)

print("Yes")

Measured memory_bytes: 14708
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct UFTree2 {
private:
	vector<int> mNode;
	vector<int> mRank;
	vector<int> mNodeNum;

public:
	UFTree2(int n) : mNode(n), mRank(n), mNodeNum(n)
	{
		for (int i = 0; i < n; i++) {
			mNode[i] = i;
			mNodeNum[i] = 1;
		}
	}

	int find(int x)
	{
		if (mNode[x] == x) {
			return x;
		}
		else {
			mNode[x] = find(mNode[x]);
			return mNode[x];
		}
	}

	void unite(int x, int y)
	{
		int idxX = find(x);
		int idxY = find(y);

		if (idxX == idxY) {
			return;
		}

		if (mRank[idxX] > mRank[idxY]) {
			mNode[idxY] = idxX;
			mNodeNum[idxX] += mNodeNum[idxY];
		}
		else {
			mNode[idxX] = idxY;
			mNodeNum[idxY] += mNodeNum[idxX];
			if (mRank[idxX] == mRank[idxY]) {
				mRank[idxY]++;
			}
		}
	}

	bool isSameSet(int x, int y)
	{
		return find(x) == find(y);
	}

	int getNodeNum(int x)
	{
		auto node = find(x);
		return mNodeNum[node];
	}
};


int main()
{
	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> bridge;
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		bridge.push_back({ A, B });
	}

	reverse(bridge.begin(), bridge.end());

	UFTree2 t(N);
	auto res = (ll)N * (N - 1) / 2;
	vector<ll> ans;
	ans.push_back(res);
	for (auto i = 0; i < M - 1; ++i)
	{
		auto& p = bridge[i];
		auto A = p.first;
		auto B = p.second;
		if (t.isSameSet(A, B))
		{
			ans.push_back(res);
			continue;
		}

		ll numA = t.getNodeNum(A);
		ll numB = t.getNodeNum(B);
		ll num = numA + numB;
		res += numA * (numA - 1) / 2;
		res += numB * (numB - 1) / 2;
		res -= num * (num - 1) / 2;
		t.unite(A, B);
		ans.push_back(res);
	}

	reverse(ans.begin(), ans.end());
	for (auto a : ans)
	{
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 4212
#include <stdio.h>

using namespace std;

void Output(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n", mark, i);
    }
}

int main(int argc, const char * argv[]){
    char mark[2];
    int n, S[14], H[14], C[14], D[14], tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);

    for(int i = 0; i < n; i++){
        scanf("%s %d", mark, &tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    Output(S, 'S');
    Output(H, 'H');
    Output(C, 'C');
    Output(D, 'D');
    
    return 0;
}



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

using namespace std;

int dfs(int curr, const vector<vector<int> >& c, bitset<10> passed) {
    passed.set(curr);
    int ret = c[curr][1];
    for (int i = 0; i < 10; ++i) {
        if (!passed[i] && i != curr && i != 1) {
            ret = min(ret, dfs(i, c, passed) + c[curr][i]);
        }
    }
    return ret;
}

void Main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > c(10, vector<int>(10, 0));
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> c[i][j];
        }
    }
    map<int, int> A;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int a;
            cin >> a;
            if (a >= 0) {
                if (A.count(a) == 0) {
                    A.insert(make_pair(a, 0));
                }
                ++A[a];
            }
        }
    }

    vector<int> power(10, 0);
    power[1] = 0;
    for (int i = 0; i <= 9; ++i) {
        bitset<10> passed(0);
        power[i] = dfs(i, c, passed);
    }

    int ans = 0;
    for (auto e : A) {
        ans += power[e.first] * e.second;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3656
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
if sum(a) < sum(b):
    print(-1)
    exit()
s = 0
num = []
ok = True
for i in range(n):
    if a[i] < b[i]:
        s += b[i] - a[i]
        ans += 1
        ok = False
    else:
        num.append(a[i]-b[i])
if ok:
    print(0)
    exit()
num.sort()
t = 0
while s > t:
    t += num.pop()
    ans += 1

print(ans)


Measured memory_bytes: 18292
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        k: usize,
        n: usize,
        mut a: [usize; n],
    }
    let mut b = a.iter().map(|ai| ai + k).collect::<Vec<_>>();
    a.append(&mut b);
    let mut ans = k;
    for i in 0..n {
        ans = ans.min(a[n - 1 + i] - a[i]);
    }
    println!("{}", ans);
}


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

using namespace std;

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

	int N, Y;
	cin >> N >> Y;

	int ans1 = -1, ans2 = -1, ans3 = -1;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; i + j <= N; j++) {
			int k = N - i - j;
			int total = 10000 * i + 5000 * j + 1000 * k;
			if (total == Y) {
				ans1 = i;
				ans2 = j;
				ans3 = k;
			}
		}
	}

	cout << ans1 << " " << ans2 << " " << ans3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    ll x, a, b;
    cin >> x >> a >> b;
    if (b - a > x) cout << "dangerous" << endl;
    else if(b-a<=0)
        cout << "delicious" << endl;
    else
        cout << "safe" << endl;
}


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

list_cards = [0 for i in range(53)]

for i in range(1, n + 1):
    Type, Number = raw_input().split()
    Number = int(Number)
    if Type == "S":
        x = 0
    elif Type == "H":
        x = 1
    elif Type == "C":
        x = 2
    elif Type == "D":
        x = 3
    list_cards[x * 13 + Number] = 1
    
for i in range(1, 53):
    if list_cards[i] == 0:
        if 0 < i and i < 14:
            Type = "S"
        elif 13 < i and i < 27:
            Type = "H"
        elif 26 < i and i < 40:
            Type = "C"
        elif 39 < i and i < 53:
            Type = "D"
    
        d = i % 13
        if d == 0:
            d = 13
        if Type == "S":
            print "S %d" %(d)
        elif Type == "H":
            print "H %d" %(d)
        elif Type == "C":
            print "C %d" %(d)
        elif Type == "D":
            print "D %d" %(d)

Measured memory_bytes: 6412
#include <stdio.h>

int main(void)
{
	int N;
	int i;
	int a, b, c;
	
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d %d %d", &a, &b, &c);
		if((a * a + b * b == c * c) || (b * b + c * c == a * a) || (c * c + a * a == b * b)){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	
	return (0);
}

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

int main()
{
    cin>>n;
    long double p[n],dp[n+1][n+1];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j)
                dp[i][j]+=dp[i-1][j-1]*(p[i-1]);
            dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
        }
    }
    long double ans=0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans;
    return 0;
}


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

template<class T>
T lcm(T a,T b){
    return a*b/__gcd(a,b);
}

int main(){
    ll n,y;cin >> n >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i+j<=n && i*10000+j*5000+(n-i-j)*1000==y){
                cout << i << " " << j << " " << n-i-j; 
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1;
    return 0;
}

Measured memory_bytes: 256
inputs = gets
inputs.slice!("\n")
tiles = ( inputs.chars ).map { |s| s=='1' ? 1 : 0 }

# 最終状態は101...か010...にしかならない
# 最終状態を作成する
e1 = Array.new(tiles.length) { |i| i.modulo(2)==0 ? 1 : 0 }
e2 = Array.new(tiles.length) { |i| i.modulo(2)==1 ? 1 : 0 }

c1 = 0
c2 = 0
tiles.each_with_index do |t,i|
    c1 = c1 + 1 if e1[i] != t
    c2 = c2 + 1 if e2[i] != t
end

puts [c1,c2].min

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(a) "(" << #a << ": " << (a) << ")"

template<typename T>
void chmin(T &x, T y) { x = min(x, y); }

template<typename T>
void chmax(T &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef tuple<int,int> P;

const int INF = INT_MAX/2 - 1;
const ld EPS = 1e-14;
const int dx[4] = {0, 1, 0, -1}; // {-1,  0,  1, -1, 1, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0}; // {-1, -1, -1,  0, 0,  1, 1, 1};
const int M = 256;

ld entropy(const vector<int> &v) {
  ld H = 0;
  for (int x : v) {
    if (x) { H -= x * log((ld)x); }
  }
  return H;
}

ld calc(int S, int A, int C, const vector<int> &I) {
  vector<int> table(M);
  for (int i = 0, len = I.size(), R = S; i < len; ++i) {
    R = (A * R + C) % M;
    table[(I[i] + R) % M]++;
  }
  return entropy(table);
}

int main() {
  cout << fixed << setprecision(10);
  int N;
  while (cin >> N and N) {
    vector<int> I(N);
    REP(i, N) cin >> I[i];
    ld ans = INF;
    int S = -1, A = -1, C = -1;
    REP(s, 16) REP(a, 16) REP(c, 16) {
      ld H = calc(s, a, c, I);
      if (ans > H + EPS) {
        ans = H;
        S = s, A = a, C = c;
      }
    }
    cout << S << " " << A << " " << C << endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>
#include <algorithm>


struct Stone
{
	int val, num;
	bool operator<(const Stone& o) const
	{
		if (num == o.num) {
			return val < o.val;
		} else {
			return num > o.num;
		}
		
	}
};

Stone stone[100000];
long long res[100000];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		Stone s;
		s.val = i;
		scanf("%d", &s.num);
		stone[i] = s;
	}
	std::sort(stone, stone + n);
	std::fill(res, res + n, 0);
	long long stock = 0;
	int minval = 0;
	int maxnum = 0;
	for (int i = 0; i < n; i++) {
		Stone s = stone[i];
		stock += s.num;
		if (i == 0) {
			minval = s.val;
			continue;
		}
		if (minval < s.val) {
			continue;
		}
		res[minval] = stock - (long long)(i + 1) * s.num;
		stock = (long long)(i + 1)*s.num;
		minval = s.val;
	}
	res[minval] = stock;
	for (int i = 0; i < n; i++) {
		printf("%lld\n", res[i]);
	}
	return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <string>

using namespace std;

int main() {
	int64_t A,B;
	cin>>A>>B;
	if(B%A==0){
		cout<<A+B<<endl;
	}else{
		cout<<B-A<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=100010;
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
int main(){
	int k;
	int b[5];
	cin>>b[0]>>b[1]>>b[2]>>b[3]>>b[4]>>k;
//	for(int i=0;i<5;i++){
//		cin>>b[i];
//	}
	qsort(b, 5, sizeof(int), compare_int);
	if(b[4]-b[0]>k){
		printf(":(\n");
	}
	else{
		printf("Yay!\n");
	}
	/*	rep(i, n){
		ans=c;
		rep(j, m){
			cin>>imp;
			ans=ans+imp*b[j];
		}
		if(ans>0){
			anss++;
		}
	}
	cout<<anss<<endl;
}*/
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	int n,m,l,r,ml=0,mr=inf,ans=0;
	cin>>n>>m;
	rep(i,0,m){
		cin>>l>>r;
		ml=max(l,ml);
		mr=min(mr,r);
	}
	if(mr-ml<0)cout<<0;
	else cout<<mr-ml+1;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a;
	string s="";
	cin>>a>>s;
	if(a>=3200){
		cout<<s<<endl;
	}else{
		cout<<"red"<<endl;
	}

	return 0;
}



Measured memory_bytes: 256
program main
	implicit none
    character(len=100)::s
    integer::le,i,j,t
    read(*,*)s
    le=len_trim(s)
    t=1
    if (le==7)then
    	if(s=="keyence")then
        	t=0
        end if
        
    else
    	do i=1,6
    		if(s(1:i)//s(le-(7-i)+1:le)=='keyence')then
        		t=0
            end if
        end do
        
        if (s(le-6:le)=='keyence')then
        	t=0
        end if
    end if
    
    if(t==0)then
    	write(*,*) 'YES'
    else
    	write(*,*)'NO'
    end if
    
    stop
end program main

            

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int a[][] = new int[3][3];
		for(int i=0;i<3;i++) {
			a[i] = fs.nextIntArray(3);
		}
		int n= fs.nextInt();
		for(int i=0;i<n;i++) {
			int b = fs.nextInt();
			for(int j=0;j<3;j++) {
				for(int k=0;k<3;k++) {
					if(a[j][k]==b)a[j][k] = -1;
				}
			}
		}
		
		String ans = "No";
		//横
		for(int i=0;i<3;i++) {	
			if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1)ans = "Yes";
		}
		//縦
		for(int i=0;i<3;i++) {	
			if(a[0][i]==-1&&a[1][i]==-1&&a[2][i]==-1)ans = "Yes";
		}
		//斜め
		if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)ans = "Yes";
		if(a[2][0]==-1&&a[1][1]==-1&&a[0][2]==-1)ans = "Yes";
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 23508
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

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

  FOR(h, 1, 3501) FOR(n, 1, 3501) {
    ll a = N * h * n;
    ll b = (4 * h * n) - (N * n) - (N * h);
    if (b > 0 && a % b == 0) {
      cout << h << " " << n << " " << (a / b) << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3676
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 1000;
    public static int VMAX = 10000;

    public static int[] A = new int[MAX];
    public static int n, s;
    public static int[] B = new int[MAX];
    public static int[] T = new int[VMAX + 1];

    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        s = VMAX;
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
            s = Math.min(s, A[i]);
        }

        // ??????
        System.out.println(solve());
    }

    public static int solve() {
        int ans = 0;
        boolean[] V = new boolean[MAX];

        for(int i = 0; i < n; i++){
            B[i] = A[i];
            V[i] = false;
        }
        Arrays.sort(B, 0, n );
        for(int i = 0; i < n; i++) T[B[i]] = i;
        for(int i = 0; i < n; i++) {
            if(V[i]) continue;
            int S = 0;
            int an = 0;
            int m = VMAX;
            int cur = i;
            while(true) {
                V[cur] = true;
                an++;
                int v = A[cur];
                m = Math.min(m, v);
                S += v;
                cur = T[v];
                if(V[cur]) break;
            }
            ans += Math.min(S + (an - 2) * m, m + S + (an + 1) * s);
        }
        return ans;
    }
}

Measured memory_bytes: 30628
#include <stdio.h>
#define STOI(a) ((a-'1')+1)
#define SUM(a,b) (a+b)
int main(void){
    char x[1001];
    int res[1000]={0},su=0,n=0,i=0,j;
    while(1){
        n=0, su=0;
        scanf("%s",x);
        if(x[0]=='0' && x[1]==NULL) break;
        while(1){
            if (x[n] == NULL) break;
            su=SUM(su,STOI(x[n]));
            n++;
        }
        res[i]=su, i++;
    }
    for(j=0;j<i;j++) printf("%d\n",res[j]);
    return 0;
}


Measured memory_bytes: 2092
#include <cstdio>
#include <cstring> 
using namespace std;
const int maxn=200001;
typedef long long LL;

int n;
LL ans;
char a[maxn];
LL alp[26];

int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=n;i++) 
		alp[a[i]-'a']++;
	
	ans=(LL)n*(LL)(n-1)/2ll;
	for(int i=0;i<26;i++)
		ans-=alp[i]*(alp[i]-1ll)/2ll;
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
    int n, x, y;
    cin >> n >> x >> y;

    vector<int> ans(n-1, 0);
    
    rep (i, 1, n+1) {
        rep (j, i+1, n+1) {
            int cost_normal = j - i;
            int cost_shortcut = min(abs(i - x), abs(i - y)) + 1 + min(abs(j - x), abs(j - y));
            int cost = min(cost_normal, cost_shortcut);
            ans[cost-1]++;
        }
    } 

    rep (i, n-1) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256