akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=2e8+5;
char s[N],t[N];
int n,m,xx,yy,nex[N];
void kmp_init()
{
    int i=1,k=0;
    while(i<=xx*m)
        if(k==0||t[i]==t[k]) nex[++i]=++k;
    else k=nex[k];
}
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);m=strlen(t+1);
    xx=100000000/m;
    for(int j=1;j<xx;j++)
    for(int i=1;i<=m;i++)
        t[i+m*j]=t[i];
    kmp_init();
    int ans=0,p=m*xx/n;
    int now=0,pos=0;
    m*=xx;
    for(int l=1;l<=p;l++)
    {
        for(int i=1;i<=n;i++)
        {
            pos++;
            now++;
            while(pos&&t[pos]!=s[i])
            {
                now-=pos-nex[pos];
                pos=nex[pos];
            }
            if(pos==0) now=0;
            if(pos==m)
                pos=0;
            ans=max(ans,now);
        }
    }
    m/=xx;
    if(ans==n*p||ans>=n*(p-1)) printf("-1\n");
    else printf("%d\n",ans/m);
}


Measured memory_bytes: 495872
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)


typedef long long LL;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	int n, m;
	string s;
	
	cin >> n >> m;
	rep(i, 0, m+2)
		putchar('#');
	putchar('\n');
	rep(i, 0, n) {
		cin >> s;
		putchar('#');
		printf("%s", s.c_str());
		putchar('#');
		putchar('\n');
	}
	rep(i, 0, m+2)
		putchar('#');
	putchar('\n');

	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    ll ans = 0;
    ans += ((h + 1LL) / 2LL) * ((w + 1LL) / 2LL);
    ans += (h / 2LL) * (w / 2LL);
    if (h > 1 && w > 1) cout << ans << "\n";
    else cout << 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
v, e, r = map(int, input().split())
g = [[] for _ in range(v)]
for i in range(e):
    s, t, d = map(int, input().split())
    g[s].append((d, t))#(重み, 次の頂点)

dist = [float("inf")] * v
dist[r] = 0
updated = False

for k in range(v-1):
    updated = False

    for i in range(v):
        for j in g[i]:
            if dist[i] != float("inf") and dist[i] + j[0] < dist[j[1]]:
                dist[j[1]] = dist[i] + j[0]
                updated = True
    if not updated:
        break
if updated:
    print("NEGATIVE CYCLE")
    exit()

for i in dist:
    if i == float("inf"):
        print("INF")
    else:
        print(i)



Measured memory_bytes: 6036
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d; cin >> a>>b>>c>>d;
  	bool A=false,B=false;
  	int ans=0;
  	for(int i=0;i<101;i++){
      if(i==a) A=true;
  	  if(i==b) A=false;
  	  if(i==c) B=true;
      if(i==d) B=false;
      if(A==true and B==true) ans++;
    }
  	cout<< ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,ans,maxx,A[200005],minn;
int main() {
           cin>>n;
           for(long long i=1;i<=n;i++) {
                      cin>>A[i];
           }
           minn=99999999999;
           for(long long i=1;i<=100;i++) {
                      ans=0;
                      for(long long j=1;j<=n;j++) {
                                 ans+=abs(A[j]-i)*abs(A[j]-i);
                      }
                      minn=min(minn,ans);
           }
           cout<<minn;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll p=998244353ll;
const int N=200005;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
int a[N];
int main(){
	int n,i,j,m;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	for(i=n;i>=1;--i){
		for(j=i<<1;j<=n;j+=i)a[i]^=a[j];
		if(a[i])++m;
	}
	printf("%d\n",m);
	for(i=1;i<=n;++i)if(a[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 1792
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = INF * 2;
	for (int i = k; i <= n; i++)
	{
		if (a[i - k + 1] >= 0) ans = min(ans, a[i]);
		else if (a[i] <= 0) ans = min(ans, -a[i - k + 1]);
		else ans = min({ ans,a[i] - a[i - k + 1] + min(abs(a[i]),abs(a[i - k + 1])) });
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int n;

int parent(i){
  return i/2;
}

int left(i){
  return 2*i;
}

int right(i){
  return 2*i+1;
}

void maxHeapify(int H[],int i){
  int l,r,largest;
  int x;
  l = left(i);
  r = right(i);

  if(l<=n && H[l]>H[i]) largest = l;
  else largest = i;
  if(r<=n && H[r]>H[largest]) largest = r;

  if(largest!=i){
    x = H[i];
    H[i] = H[largest];
    H[largest] = x;

    maxHeapify(H,largest);
  }
		      
}

void buildMaxHeap(int H[]){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(H,i);
  }
}
	       

int main(){

  int i;
  scanf("%d",&n);

  int H[n+1];

  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }

  buildMaxHeap(H);

  for(i=1;i<=n;i++){
    printf(" %d",H[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3696
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int min =1000;
        int max =0;
        for(int i=0; i<N; i++){
            int a = sc.nextInt();
            if(min > a){
                min = a;
            }
            if(max < a){
                max = a;
            }
        }
        
        System.out.println(max - min);
    }
}

Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import deque

n,m = getList()
vtxs = [[] for i in range(n)]
included = [0 for i in range(n)]

for i in range(m):
    a,b = getList()
    vtxs[a-1].append(b-1)
    vtxs[b-1].append(a-1)

q = deque()
q.append(0)
included[0] = 1
# print(vtxs)
tgt = 0
flag = True
while(flag):
    flag = False
    for vx in vtxs[tgt]:
        if included[vx] == 0:
            tgt = vx
            q.append(tgt)
            included[tgt] = 1
            flag = True
            break
    # print(q)

tgt = 0
flag = True
while (flag):
    flag = False
    for vx in vtxs[tgt]:
        if included[vx] == 0:
            tgt = vx
            q.appendleft(tgt)
            included[tgt] = 1
            flag = True
            break

# print(q)
print(len(list(q)))
print(*[i + 1 for i in list(q)])



Measured memory_bytes: 69936
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if ((s.at(0) == s.at(1)) &&(s.at(1) == s.at(2))){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
## 01BFSで解く
from collections import deque

H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh_, dw_ = map(int, input().split())
fs = [input() for i in range(H)]

INF = float("inf")
N = 10**4
dps = [[INF]*W for i in range(H)]
dps[ch-1][cw-1] = 0
q = deque([])
q.append((0, (ch-1)*N+(cw-1)))
while q:
    cnt, n  = q.popleft()
    h,w = divmod(n, N)
    if cnt > dps[h][w]:continue
    dps[h][w] = cnt
    # 歩いた
    for dh in range(-2,3):
        for dw in range(-2,3):            
            hn = h + dh
            wn = w + dw
            if not 0 <= wn < W: continue
            if not 0 <= hn < H: continue
            if fs[hn][wn] == "#": continue
            if dps[hn][wn] < INF:continue
            if abs(dh) + abs(dw) <= 1:
                q.appendleft((cnt, hn*N+wn))
            else:
                q.append((cnt+1, hn*N+wn))
# for r in dps:
#     print(*r)
ans = dps[dh_-1][dw_-1]
print(ans if ans != INF else -1)


Measured memory_bytes: 154724
#include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;


bool judge(int n){
	for(int i=2;i*i<=n;i++)
		if(n%i==0)return false;
	return true;
}

int main(){
	int n;
	while(cin >> n, n != 0){
		for(int i=n;i>0;i--){
			if(judge(i)&&judge(i-2)){
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
	}
	return 0;
}













/*#include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int so[10010];
int set[10010];//入力

int main(){
	int x=0;
	while(1){
	cin>>set[x];
			if(set[x]==0)break;
		x++;
	}
	
	for(int y=0;y<x;y++){
	
	
	int num[10000];
	for(int i=0;i<set[y];i++){
	num[i]=1;
	}
	
	
	for(int i=2;i<set[y];i++){
		if(num[i]==1){
			for(int j=0;i*(j+2)<set[y];j++){
			num[i*(j+2)]=0;
			}
		}
	}
	for(int i=2;i<set[y];i++){
		if(num[i]){
		so[i]=i;
		}
	}
	
	sort(so, so+set[y],greater<int>() );

	for(int i=0;i<set[y];i++){
		if(so[i]-so[i+1]==2){
		cout<<so[i+1]<<" "<<so[i]<<endl;
			break;
		}
	}
	
	}


}*/
/*
#include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int so[10010];
int set[10010];

int main(){
	
	while(1){
	int n;
		cin>>n;
		if(n==0)break;
		
	
	

	int num[10000];
	for(int i=0;i<n;i++){
	num[i]=1;
	}
	
	
	for(int i=2;i<n;i++){
		if(num[i]==1){
			for(int j=0;i*(j+2)<n;j++){
			num[i*(j+2)]=0;
			}
		}
	}
	for(int i=2;i<n;i++){
		if(num[i]){
		so[i]=i;
		}
	}
	
	sort(so, so+n,greater<int>() );

	for(int i=0;i<n;i++){
		if(so[i]-so[i+1]==2){
		cout<<so[i+1]<<" "<<so[i]<<endl;
			break;
		}
	}
	
}


}*/


Measured memory_bytes: 3092
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 998244353;
const int INF = 1LL << 55;

/*
 * 全体集合は3のN乗. 補集合(三角形にならないような満たしかた)を求めて全体から引くことを考える.
 * Rの和が大きいとして一般性を失わない.
 * 三角形の成立条件は, (RがS/2未満) and (R > 0) and (G > 0) and (B > 0).
 * その補集合の条件は, (RがS/2以上) or (G == 0) or (B == 0)
 * 場合分けしてかぞえあげる.
 * (i) Rが(S/2 + 1)以上のとき
 *      dp2[i+1][j] = 数列のi番目までで, Rの和がjになるように選ぶ場合の数.
 *      求める場合の数: dp2[N][S/2 + 1 以上]
 *      Rが最大の制約を外した場合の数: 3 * dp2[N][S/2 + 1 以上]
 *      dp2[i+1][j] = 2 * dp2[i][j] + dp2[i][j - A[i]]
 * (ii) Rが(S/2)のとき. ただしSが偶数の場合に限る.
 *      (a) GかBが(S/2)で, もう一方がゼロ
 *          dp[i+1][j] = 数列のi番目までで, 和がjになるように選ぶ場合の数.
 *          求める場合の数: dp[N][S/2]
 *          Rが最大の制約を外した場合の数: 3 * dp[N][S/2]
 *          dp[i+1][j] = dp[i][j] + dp[i][j - A[i]]
 *      (b) G > 0 and B > 0
 *          dp2[N][S/2]から, R=S/2,G=S/2となる場合とR=S/2,B=S/2となる場合を引く.
 *          求める場合の数: dp2[N][S/2] - 2 * dp[N][S/2]
 *          Rが最大の制約を外した場合の数: 3 * (dp2[N][S/2] - 2 * dp[N][S/2])
 *
 *  complement = 3 * (dp2[N][S/2 + 1 以上] + dp[N][S/2] + dp2[N][S/2] - 2 * dp[N][S/2])
 *  ただし第二項と第三項はSが偶数のときのみ足される
 *  ans = pow(3, N) - complement
 */

int dp[301][90001];
int dp2[301][90001];

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int S = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        S += A[i];
    }

    dp[0][0] = 1;
    dp2[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 90001; j++) {
            dp[i+1][j] = dp[i][j];
            if (j - A[i] >= 0) {
                dp[i+1][j] += dp[i][j - A[i]];
                dp[i+1][j] %= MOD;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 90001; j++) {
            dp2[i+1][j] = (2 * dp2[i][j]) % MOD;
            if (j - A[i] >= 0) {
                dp2[i+1][j] += dp2[i][j - A[i]];
                dp2[i+1][j] %= MOD;
            }
        }
    }

    int comp = 0;
    for (int j = S/2 + 1; j <= 90000; j++) (comp += dp2[N][j]) %= MOD;
    if (S % 2 == 0) {
        (comp += dp[N][S/2]) %= MOD;
        (comp += dp2[N][S/2]) %= MOD;
        for (int i = 0; i < 2; i++) {
            comp += MOD;
            comp -= dp[N][S/2];
            comp %= MOD;
        }
    }
    (comp *= 3) %= MOD;

    int all = 1;
    for (int i = 0; i < N; i++) (all *= 3) %= MOD;

    cout << (all + MOD - comp) % MOD << endl;

    return 0;
}

Measured memory_bytes: 422784
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string s;
	cin >> s;
	long long ans = 0;

	int n = s.size();
	int c = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i]=='W') {
			c++;
		}
		else {
			ans += c;
		}
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 848
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    ll N;
    cin >> N;
    ll N2 = N;
    int temp=0;
    while(1){
       
        temp += N2 % 10;
        N2 /= 10;
        if(N2 == 0) break;
    }
    if(N %temp ==0)cout << "Yes" << endl; else cout << "No" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

MAX = 60000
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

N = list(get_input())
for l in range(len(N)):
    n = int(N[l])
    d = 1
    while True:
        if primes[n-d]:
            print(n-d, end=" ")
            break
        d += 1

    d = 1
    while True:
        if primes[n+d]:
            print(n+d)
            break
        d += 1




Measured memory_bytes: 6168
#include<bits/stdc++.h>
using namespace std;
int a, b, d[12][12], f[107][107];
int read()
{
	int num = 0;
	char c = getchar();
	while (c<'0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int main()
{
	a = read();
	b = read();
	for (int i = 1; i <= a; i++)
		for (int j = 1; j <= b; j++)
			d[i][j] = read();
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
			for (int k = 1; k <= a; k++)
				for (int l = 1; l <= b; l++)
					f[i][j] = max(f[i][j], d[k][l] - i * k - j * l);
	for (int i = 1; i <= a; i++)
		for (int j = 1; j <= b; j++)
		{
			int mn = 1e9;
			for (int p = 0; p <= 100; p++)
				for (int q = 0; q <= 100; q++)
					mn = min(mn, f[p][q] + p * i + q * j);
			if (mn != d[i][j])
			{
				printf("Impossible\n");
				return 0;
			}
		}
	printf("Possible\n");
	printf("202 10401\n");
	for (int i = 1; i <= 100; i++)
		printf("%d %d X\n", i, i + 1);
	for (int i = 102; i < 202; i++)
		printf("%d %d Y\n", i, i + 1);
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
			printf("%d %d %d\n", i + 1, 202 - j, f[i][j]);
	printf("1 202\n");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (2000)
#define MOD (1000000007)

char map[MAXN][MAXN+1];

int s1[MAXN][MAXN];
int s2[MAXN][MAXN];

int main(void)
{
    ll h,w;
    scanf("%ld %ld",&h, &w);
    for(int i=0;i<h;i++) scanf("%s",map[i]);

    for(int i=0;i<h;i++)
    {
        int c = 0;
        for(int j=0;j<w;j++)
        {
            if(map[i][j]=='#')
            {
                s1[i][j] = 0;
                c = 0;
            }
            else
            {  
                c++;
                s1[i][j] = c;
            }
        }
        for(int j=w-2;j>=0;j--)
        {
            if(s1[i][j]==0) continue;
            if(s1[i][j+1]==0) continue;
            s1[i][j] = s1[i][j+1];
        }
    }
    
    for(int j=0;j<w;j++)
    {
        int c = 0;
        for(int i=0;i<h;i++)
        {
            if(map[i][j]=='#')
            {
                s2[i][j] = 0;
                c = 0;
            }
            else
            {  
                c++;
                s2[i][j] = c;
            }
        }
        for(int i=h-2;i>=0;i--)
        {
            if(s1[i][j]==0) continue;
            if(s1[i+1][j]==0) continue;
            s2[i][j] = s2[i+1][j];
        }
    }
    ll ans = 0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++)
    {
        ans = max(ans,s1[i][j]+s2[i][j]);
    }
    ans--;

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


Measured memory_bytes: 35328
N, X, Y = map(int, input().split())

d = [0] * N
for i in range(1, N):
    for j in range(i + 1, N + 1):
        if j <= X:
            a = j - i
        elif i <= X and j >= Y:
            a = (X - i) + (j - Y) + 1
        else:
            a = min(j - i, abs(X - i) + 1 + abs(Y - j))

        d[a] += 1
for ans in d[1:]:
    print(ans)


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

int main() {
    int t = 0;
    int w;
    int d = 10;
    for(int i = 0; i < 5; i++) {
        cin >> w;
        if (w % 10 == 0) {
            t += w;
        } else {
            t += w + (10 - (w % 10));
            d = min(d, (w % 10));
        }
    }

    cout << t - (10 - d) << endl;
}


Measured memory_bytes: 256
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int INF = 1e9;
int fast_pow(int x, int y, int p);

string s;
int d;
int dp[10001][2][101][2];
int rec(int pos,int br,int md,int started=0){
    if(pos==s.size()){
        return md==0 && started ;
    }
    int& ans =dp[pos][br][md][started];
    if(ans!=-1)return ans;
    ans=0;
    int en = 9;
    if(br)
        en = s[pos]-'0';
    for(int i=0;i<=en;i++){
        ans+=rec(pos+1,br&(i==(s[pos]-'0')),(md+i)%d,started|(i!=0));
        ans%=MOD;
    }
    return ans;
}
void solve() {
    cin>>s>>d;
    memset(dp,-1,sizeof dp);
	int ans = rec(0,1,0);
	cout<<ans;

}


int32_t main() {

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

Measured memory_bytes: 35992
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,d;
  cin>>a;
  if(a<1200)
  {
    cout<<"ABC";
  }
  else
  {
    cout<<"ARC";
  }
  cout<<endl;

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
#define pi 3.14159265358979323846
 
int main(){
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  double ans = 2*pi*n;
  cout<<setprecision(5);
  cout<<fixed;
  cout<<ans<<endl;
  
 
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	char l;
	cin>>l;

	if(l == 'A') cout<<"T";
	if(l == 'T') cout<<"A";
	if(l == 'C') cout<<"G";
	if(l == 'G') cout<<"C";
	cn;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    int x;
    rep(i,n-1){
        cin>>x;
        a[x-1]++;
    }
    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int cnt = 0; int now = 0;
    rep(i,n+3){
        if(now == 1) break;
        now = a[now];
        cnt++;
    }

    if(cnt >= n+1) cout << -1 << endl;
    else cout << cnt << endl;

}

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define br cout<<endl;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 100005;
const int INF = 1e9+7;
const ll LINF = 1e18 + 7;

/***************************************************************************/

int main()
{
    ios::sync_with_stdio(0);
    string s;
    cin>>s;
    ll n=s.size(),cnt=0,pos=0,ans=0;
    for(ll i=0;i<n;i++)
    {
       if(s[i]=='W')
       {
           ans+=(pos-cnt);
           //debug2(pos, cnt);
           cnt++;
       }
       pos++;

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



Measured memory_bytes: 720
#include<iostream>
using namespace std;
int main(){
int n;cin>>n;
long long x,y;cin>>x>>y;
n--;
while(n--){
    long long a,b;
    cin>>a>>b;
    long long lo=0,hi=1e18/max(a,b)+1;
    while(lo<hi){
        long long md=lo+(hi-lo)/2;
        a*md>=x&&b*md>=y?hi=md:lo=md+1;
    }x=a*lo;
    y=b*lo;
}cout<<x+y<<'\n';




return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9)

int main(){
	int N, i, mina = inf, maxa = -inf, min_num, max_num;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
		if(a[i] < mina){
			mina = a[i];
			min_num = i;
		}
		if(a[i] > maxa){
			maxa = a[i];
			max_num = i;
		}
	}
	if(mina >= 0){
		printf("%d\n", N - 1);
		for(i = 1; i < N; i++){
			printf("%d %d\n", i, i + 1);
		}
	}
	else if(maxa <= 0){
		printf("%d\n", N - 1);
		for(i = N; i > 1; i--){
			printf("%d %d\n", i, i - 1);
		}
	}
	else if(maxa + mina >= 0){
		printf("%d\n", 2 * N - 1);
		for(i = 1; i <= N; i++){
			printf("%d %d\n", max_num + 1, i);
		}
		for(i = 1; i < N; i++){
			printf("%d %d\n", i, i + 1);
		}
	}
	else{
		printf("%d\n", 2 * N - 1);
		for(i = 1; i <= N; i++){
			printf("%d %d\n", min_num + 1, i);
		}
		for(i = N; i > 1; i--){
			printf("%d %d\n", i, i - 1);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;
    int n, i, j;
    int C[VMAX];
    scanf("%d", &n);
    A = (unsigned short *)malloc(sizeof(short) * n + 1);
    B = (unsigned short *)malloc(sizeof(short) * n + 1);

    for (int i=0; i<VMAX; i++) C[i] = 0;

    for (int i=0; i<n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }

    for (i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];

    for (j=1; j<=n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for (int i=1; i<=n; i++) {
        printf("%d", B[i]);
        if (i == n) printf("\n");
        else printf(" ");
    }
    return 0;
}

Measured memory_bytes: 8888
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int n,count,h;
	while(1){
		count=0;
		cin >> n;
		if(n==0)break;
		for(int i=4;i<=n;i++){
			h=i;
			while(h%5==0){
				h /= 5;
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>

int main()
{
    int n,k,i,j=1;
    scanf("%d %d",&n,&k);
    for(i=1; i<=n ; i++)
    {
        if(j<=k)
        {
            j*=2;
        }
        else
        {
            j+=k;
        }
    }
    printf("%d\n",j);


    return 0;
}


Measured memory_bytes: 1680
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
h = iln()

dp = [INF for _ in range(N)]
dp[0] = 0

for i in range(N-1):
    if i+1 < N:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[N-1])

Measured memory_bytes: 83100
fun main(args: Array<String>) {
  val N = readInt()
  val A = readLongs().toMutableList()

  for (i in 0 until N) {
    A[i] -= (i.toLong() + 1)
  }

//  A.sortBy { Math.abs(it) }
  A.sort()
  val mid = A[A.size / 2]

//  println(mid)
  println(A.map { Math.abs(it - mid) }.sum())
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 80368
from itertools import accumulate as ac
t = 3099044504245996706400 # LCM(1..50)
N, A, B = map(int, input().split())
V = sorted([int(a) * t for a in input().split()])[::-1]
l, r = 0, 1<<200
while r - l > 1:
    m = (l+r) // 2
    if list(ac([v-m for v in V]))[A-1] >= 0:
        l = m
    else:
        r = m

fa = [1]
for i in range(1, 60):
    fa.append(fa[-1] * i)
C = lambda a, b: fa[a] // (fa[a-b] * fa[b])

print(l/t)
print(sum([C(V.count(V[i-1]), V[:i].count(V[i-1])) for i in range(A, B+1) if sum(V[:i]) == l * i]))

Measured memory_bytes: 3064
#include<iostream>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int N, T, A;
    cin >> N >> T >> A;
    double mn = 1e10;
    vector<int> vec(N);
    vector<double> GAP(N);
    rep(i, N){
        cin >> vec[i];
        GAP[i] = abs(T - A - 0.006*vec[i]);
        mn = min(mn,GAP[i]);
    }
    rep(i, N){
        if(mn == GAP[i]) cout << i+1;
    }

}


Measured memory_bytes: 256
def count(x1,x2):
    if x1<=4 or (x1==5 and x2 <=4):
        return x1,0 
    else:
        return 10-x1,1

n='0'+input()
count_sum = 0
digit_plus = 0
for c1,c2 in zip(n[::-1],n[-2::-1]):
    count_add, digit_plus = count(int(c1)+digit_plus,int(c2))
    count_sum += count_add
if digit_plus: count_sum += 1
print(count_sum)


Measured memory_bytes: 7908
N = int(input())
block_list = list(map(int,input().split()))
blocked_list = []

cnt = 1
break_cnt = 0

for i in range(N):
    if block_list[i] == cnt:
        blocked_list.append(cnt)
        cnt += 1

    else:
        break_cnt += 1


if blocked_list == []:
    print(-1)

else:
    print(break_cnt)

Measured memory_bytes: 24744
/**
 *    Author: Sutlan Ahmed
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    scanf("%d",&d);
    if(d==25)printf("Christmas\n");
    else if(d==24)printf("Christmas Eve\n");
    else if(d==23)printf("Christmas Eve Eve\n");
    else if(d==22)printf("Christmas Eve Eve Eve\n");
    return 0;
}


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

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  
  vector<char> ini = {'M','A','R','C','H'};
  vector<ll> d(5);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 5; j++) {
      if (S.at(i).at(0) == ini.at(j)) d.at(j)++;
    }
  }
  
  ll ans = d.at(0)*d.at(1)*d.at(2) + d.at(0)*d.at(1)*d.at(3) + d.at(0)*d.at(1)*d.at(4) + d.at(0)*d.at(2)*d.at(3) + d.at(0)*d.at(2)*d.at(4) + d.at(0)*d.at(3)*d.at(4) + d.at(1)*d.at(2)*d.at(3) + d.at(1)*d.at(2)*d.at(4) + d.at(1)*d.at(3)*d.at(4) + d.at(2)*d.at(3)*d.at(4);
  cout << ans << endl;
}

Measured memory_bytes: 6144
d,g = map(int,input().split())
p = [list(map(int,input().split())) for _ in range(d)]
ans = 9999

for i in range(1 << d):
    score = 0
    haredst_rest_p = -1
    solves = 0
    for j in range(d):
        if i >> j & 1:
            score += (j+1) * 100 * p[j][0] + p[j][1]
            solves += p[j][0]
        else:
            hardest_rest_p = j
    
    if score < g and hardest_rest_p != -1:
        rest = (g - score + (hardest_rest_p+1) * 100 - 1) // ((hardest_rest_p+1) * 100)
        if rest >= p[hardest_rest_p][0]:
            continue
        else:
            solves += rest
    
    ans = min(ans, solves)
print(ans)

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

int main(){
    string N;
    int k;
    cin >> N;
    cin >> k;
    vector<vector<int>> data(k+1, vector<int>(2));

    for (int i=0; i < N.size(); i++){
        int n = (int)(N[i] - '0');
        if (i==0){
            data.at(1).at(0) = 1;
            data.at(0).at(1) = 1;
            data.at(1).at(1) = n - 1;

            continue;
        }
        
        for (int j=k; j > 0; j--){
            data.at(j).at(1) += data.at(j-1).at(1)*9;
            if (n != 0){
                data.at(j).at(1) += (n - 1) * data.at(j-1).at(0) + data.at(j).at(0);
                data.at(j).at(0) = data.at(j-1).at(0);
            }
        }

    }
    cout << data.at(k).at(0) + data.at(k).at(1) << endl;

}

Measured memory_bytes: 256
from math import gcd


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    m = max(a)
    p = [i for i in range(m + 1)]
    for i in range(3, m + 1):
        for j in range(2, int(i**.5 + 1) + 1):
            if i % j == 0:
                p[i] = j
                break
    factors = set()
    for ai in a:
        if ai == 1:
            continue
        f = set()
        while ai > p[ai]:
            f.add(p[ai])
            ai //= p[ai]
        f.add(ai)
        if factors & f:
            break
        factors |= f
    else:
        print("pairwise coprime")
        return
    g = a[0]
    for ai in a[1:]:
        g = gcd(ai, g)
        if g == 1:
            print("setwise coprime")
            return
    print("not coprime")


if __name__ == '__main__':
    main()


Measured memory_bytes: 220604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int n, k;


vector<int> solve() {
    int m = pow(2, n) - 1;
    
    vector<int> v;
    if (k == 0) {
        rep(i, m + 1) {
            v.eb(i);
            v.eb(i);
        }
        
        return v;
    }
    

    
    if (m < k) { v.eb(-1); return v; }
    
    int tmp = 0;
    rep(i, m + 1) { if (i == k) continue; tmp ^= i; }
    if (tmp != k) { v.eb(-1); return v; }
    
    
    rep(i, m + 1) { if (i == k) continue; v.eb(i); }
    v.eb(k);
    for (int i = m; i >= 0; --i) {
        if (i == k) continue;
        v.eb(i);
    }
    v.eb(k);
    
    return v;
    
}


vector<int> ac(int M, int K) {
    vector<int> v;
    if(M==0){
        if(K==0){
            v.eb(0);
            v.eb(0);
            return v;
        }else{
            v.eb(-1);
            return v;
        }
    }else if(M==1){
        if(K==0){
            v.eb(0);
            v.eb(1);
            v.eb(1);
            v.eb(0);
            return v;
        }else{
            v.eb(-1);
            return v;
        }
    }else{
        if(K<(1<<M)){
            rep(i,(1<<M)){
                if(i==K)continue;
                v.eb(i);
            }
            v.eb(K);
            
            rep(i,(1<<M)){
                if((1<<M)-i-1==K)continue;
                v.eb((1<<M)-i-1);
            }
            v.eb(K);
            return v;
        }else{
            v.eb(-1);
            return v;
        }
    }
}

random_device rnd;
mt19937 mt(rnd());
uniform_int_distribution<> rand100(1, 17);
#define rm rand100(mt);


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    /*
    while (1) {
        n = rm;
        k = rm;
        auto aa = solve();
        auto bb = ac(n, k);
        if (aa != bb) {
            out(n << " " << k);
            outa(aa, SZ(aa));
            outa(bb, SZ(bb));
            break;
        }
    }
     */
    
    cin >> n >> k;
    auto aa = solve();
    outa(aa, SZ(aa));
}



Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
    }
    int l = 0, r = (int) 1e9 + 7;
    while (r - l > 1)
    {
        int mid = (l + r) / 2;
        int count = 0;
        for (int i = 0; i < n; ++i)
        {
            count += (a[i] + mid - 1) / mid - 1;
        }
        if (count <= k)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    std::cout << r << '\n';
    return 0;
}

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

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

int main(){
  int n;
  cin >> n;
  double N;
  N=(double)n;
  if(n%2 == 0){
    cout << 1.0/2.0 << endl;
  }
  else cout << (N+1)/(2*N) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

long solve(const std::string& s, const std::string& t)
{
  long result = -1;
  const long size = static_cast<long>(s.size());
  long old_index = -1;
  for (const auto c : t) {
    long index = s.find(c, old_index + 1);
    if (index == std::string::npos) {
      index = s.find(c);
    }
    if (index == std::string::npos) return -1;
    if (result < index) {
      result = index;
    } else {
      const auto r = result % size;
      if (r < index) {
        result += index - r;
      } else {
        result = (result / size + 1) * size + index;
      }
    }
    old_index = index;
  }

  return result + 1;
}

int main()
{
  std::string s, t;
  std::cin >> s >> t;

  std::cout << solve(s, t) << std::endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;


int ss[ms]={0};


int main()
{
    idfc;

    string s;
    cin>>s;
    int l=0;
    int r=s.length()-1;

    int a=0;

    while(l<r)
    {
        if(s[l]!=s[r])
        {
            if(s[l]=='x')
            {
                a++; l++;
            }
            else if(s[r]=='x')
            {
                a++; r--;
            }
            else{
                cout<<-1;
                return 0;
            }
        }
        else {l++;r--;}
    }
    cout<<a;

    return 0;
}

Measured memory_bytes: 3744
using System;
using System.Collections.Generic;
using System.Text;
class Program {
    static void Main(string[] args) {
        string N = Console.ReadLine();

        string[] S = new string[10];
        int i = 0;
        foreach(char s in N) {
            S[i] = s.ToString();
            ++i;
        }
        int startNum = 0;
        int ans = 0;
        while (true) {

            int len = 0;
            for(int k = startNum; k < S.Length; ++k) {
                if(S[k] == "A" || S[k] == "C" || S[k] == "G" || S[k] == "T") {
                    ++len;
                }
                else {
                    break;
                }

            }
            if(ans < len) {
                ans = len;
            }
            ++startNum;
            if (startNum >= 11) break;
        }
        Console.WriteLine(ans);

    }


    }



Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class UnionFind {
public:
    vector<int> m_parent;
    vector<int> m_rank;

public:
    UnionFind( int n ) {
	Init( n );
    }
    ~UnionFind( ) { 
	m_parent.clear( );
	m_rank.clear( );
    }

    void Init( int n ) {

	m_parent.resize( n );
	m_rank.resize( n );

	for ( int i=0; i<n; ++i ) {
	    m_parent[i] = i;
	    m_rank[i] = 0;
	}
    }

    int Find( int i ) {
	if ( m_parent[i] == i ) return i;
	return m_parent[i] = Find( m_parent[i] );
    }

    void Unite( int i, int j ) {

	i = Find( i );
	j = Find( j );
	if ( i == j ) return;

	if ( m_rank[i] < m_rank[j] ) m_parent[i] = j;
	else {
	    m_parent[j] = i;
	    if ( m_rank[i] == m_rank[j] ) ++m_rank[i];
	}
    }

    bool Same( int i, int j ) { return Find( i ) == Find( j ); }

};

template <typename T>
class Edge {
public:
    int m_b, m_e;
    T m_c;
public:
    Edge() {}
    Edge(int b, int e, const T& c) : m_b(b), m_e(e), m_c(c) {  }
    void Set(int b, int e, const T& c) { m_b = b; m_e = e; m_c = c; }

    bool operator > (const Edge& edge) const { return m_c > edge.m_c; }
    bool operator < (const Edge& edge) const { return m_c < edge.m_c; }
};

//無向グラフ
int Kruskal( int nNode, int nEdge, const vector< Edge<int> >& aEdge ) {

    UnionFind uni( nNode );

    int res = 0;
    for ( int i=0; i<nEdge; ++i ) {

	const Edge< int >& e = aEdge[i];

	if ( !uni.Same( e.m_b, e.m_e ) ) {
	    uni.Unite( e.m_b, e.m_e );
	    res += e.m_c;
	}

    }

    return res;
}

int main() {

    int nNode, nEdge;
    vector< Edge< int > > aEdge;

    cin >> nNode >> nEdge;

    int s, t, w;
    for ( int i=0; i<nEdge; ++i ) {
	cin >> s >> t >> w;
	aEdge.push_back( Edge<int>( s, t, w ) );
    }

    sort( aEdge.begin(), aEdge.end() );

    cout << Kruskal( nNode, nEdge, aEdge ) << endl;

    return 0;
}



Measured memory_bytes: 4532