akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    Int(l);

    vvi g(n, vi(n, INF));
    rep(i, n) g[i][i] = 0;
    rep(i, m) {
        int3(a, b, c);
        a--; b--;
        g[a][b] = g[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    }

    rep(i, n) {
        rep(j, n) {
            g[i][j] = (g[i][j] <= l ? 1 : INF);
        }
    }

    rep(k, n) rep(i, n) rep(j, n) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    }

    Int(q);
    while (q--) {
        int2(a, b);
        a--; b--;
        
        cout << (g[a][b] != INF ? g[a][b] -1 : -1) << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
H, W = map(int, input().split())
a = [input() for _ in range(H)]
MOD = 10**9 + 7

dp = [[0]*1100 for _ in range(1100)]
dp[1][1] = 1
for h in range(1, H+1):
    for w in range(1, W+1):
        if h == 1 and w == 1:
            continue
        if a[h-1][w-1] == '#':
            dp[h][w] = 0
        else:
            dp[h][w] += (dp[h-1][w] + dp[h][w-1]) % MOD
print(dp[H][W] % MOD)

Measured memory_bytes: 51216
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    String S=sc.next();
    String T=sc.next();
    char s,t;
    StringBuilder buf=new StringBuilder();
    
    for(int i=0;i<N;i++){
      s=S.charAt(i);
      t=T.charAt(i);
      buf.append(s);
      buf.append(t);
    }
    System.out.println(new String(buf));
  }
}

Measured memory_bytes: 21588
#include<cstdio>
using namespace std;

int main() {
  int n;
  char s[1000][1060];
  int counter[1000];
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    for (int i = 0; i < n; i++)
      for (counter[i] = 0; s[i][counter[i]] == '.'; counter[i]++) s[i][counter[i]] = ' ';
    for (int i = 0; i < n; i++) counter[i]--;
    printf("%s\n", s[0]);
    for (int i = 1; i < n; i++) {
      s[i][counter[i]] = '+';
      if (counter[i - 1] > counter[i]) {
        for (int j = i - 1; counter[j] > counter[i]; j--) s[j][counter[i]] = '|';
      }
    }
    for (int i = 1; i < n; i++) printf("%s\n", s[i]);
  }
}



Measured memory_bytes: 3556
n = int(input())

adj_mat = [[0 for i in range(n + 1)] for j in range(n)]

for i in range(n):
    adj_list_i = list(map(int, input().split()[2:]))
    for j in adj_list_i:
        adj_mat[i][j] = 1

for r in adj_mat:
    print(*r[1:])

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

int main(){
  string s; cin >> s;
  int N=-1;
  int E=-1;
  int W=-1;
  int S=-1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='N') N=1;
    if(s[i]=='E') E=1;
    if(s[i]=='W') W=1;
    if(s[i]=='S') S=1;
  }
  if(N*S<0 || E*W<0){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
}
    
  

Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int w, h, n;
  cin >> w >> h >> n;

  int x[n];
  int y[n];
  int a[n];
  int l,r,u,d;
  l = 0;
  r = w;
  d = 0;
  u = h;

  REP(i, n){
    cin >> x[i] >> y[i] >> a[i];
    if(a[i]==1){
      l = max(l, x[i]);
    }
    else if(a[i]==2){
      r = min(r, x[i]);
    }
    else if(a[i]==3){
      d = max(d, y[i]);
    }
    else{
      u = min(u, y[i]);
    }
  }

  cout << max(0, r-l)*max(0, u-d) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import heapq

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    V = list(map(int, input().split()))

    res = 0
    for i in range(1, k + 1):
        # i回取り出す
        for j in range(i + 1):
            que = deque(V)
            get = []
            heapq.heapify(get)
            # j回前から取り出す
            for x in range(j):
                if que:
                    v = que.popleft()
                    heapq.heappush(get, v)

            # i - j回前から取り出す
            for _ in range(i - j):
                if que:
                    v = que.pop()
                    heapq.heappush(get, v)

            score = sum(get)
            res = max(res, score)

            # 宝石の価値が低い順にk - i回戻す
            for _ in range(k - i):
                if get:
                    heapq.heappop(get)

                score = sum(get)
                res = max(res, score)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
int n;ll m,L,R,ans,a[N];
bool chk(ll x)
{
	ll cnt=0,t1,t2;
	for(int i=1;i<=n;++i)
		if(a[i])
		{
			t1=t2=x/a[i];
			if(x%a[i])
			{
				if((x<0 && a[i]>0) || (x>0 && a[i]<0)) --t1;
				else ++t2;
			}
			if(a[i]<0) cnt+=n+1-(upper_bound(a+1,a+n+1,t1)-a);
			if(a[i]>0) cnt+=lower_bound(a+1,a+n+1,t2)-a-1;
			if(a[i]*a[i]<x) --cnt;
		}else if(x>0) cnt+=n-1;cnt>>=1;return cnt<m;
}
int main()
{
	scanf("%d %lld",&n,&m);L=-1e18;R=1e18;
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);sort(a+1,a+n+1);
	while(L<=R) {ll mid=L+R>>1;if(chk(mid)) L=mid+1,ans=mid;else R=mid-1;}
	printf("%lld\n",ans);return 0;
}

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

int main() {
  long long N;
  cin >> N;
 
  vector<long long> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  long long sum=0;
  long long ans=0;
  for(int i=0;i<N-1;i++){
    long long neko=0;
    sum = sum + a.at(i);
    sum = sum %1000000007;
    neko = (sum * a.at(i+1))%1000000007;
    ans = ans + neko;
    ans = ans%1000000007;
  }
  
  cout << ans << endl;
  
  
}

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

typedef long long ll;

ll pre[200005];

ll getsum(int l, int r){
    return pre[r] - pre[l-1];
}

ll uradi(ll i, ll j, ll k, ll l){
    ll a = pre[i];
    ll b = pre[j] - pre[i];
    ll c = pre[k] - pre[j];
    ll d = pre[l] - pre[k];
    ll mn = min(min(min(a, b), c), d);
    ll mx = max(max(max(a, b), c), d);
    return mx - mn;
}

int main(){

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        pre[i] = pre[i-1] + x;
    }
    int l=1, r=3;
    ll res = pre[n];
    for(int middle=2; middle<=n-2; middle++){
        while(l+1 < middle && abs(getsum(1, l+1) - getsum(l+2, middle)) < abs(getsum(1, l) - getsum(l+1, middle))) l++;
        r = max(r, middle+1);
        while(r+1 < n && abs(getsum(middle+1, r+1) - getsum(r+2, n)) < abs(getsum(middle+1, r) - getsum(r+1, n))) r++;
        res = min(res, uradi(l, middle, r, n));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let a: usize = read();
    let b: usize = read();

    if a > 9 || b > 9 {
        println!("{}", -1)
    } else {
        println!("{}", a * b);
    }
}


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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define mod 1000000007

int main()
{
	Coming 
	
	ll n,a;
	ll sum = 0;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		sum = __gcd(a,sum);
	}
	
	cout << sum << endl;
	
	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 14; j++) {
			if(4*i + 7*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    int a[n];
    int i;
    for (i = 0; i < n; i++) {
    	cin >> a[i];
    }
    for (i = n-1; i >= 1; i=i-1) {
    	cout << a[i] << " ";
    }
    cout << a[0]<<endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
#define mp make_pair

typedef pair<int,pair<int,int> > P;

int main(){
	while(true){
		int N,ql;
		cin >> N >> ql;			if(!N) return 0;
		set<P> ps;
		REP(qi,ql){
			string c; int a,b;
			cin>>c>>a>>b; a--;b--;
			if(c=="xy") REP(z,N) ps.insert(mp(a,mp(b,z)));
			if(c=="xz") REP(y,N) ps.insert(mp(a,mp(y,b)));
			if(c=="yz") REP(x,N) ps.insert(mp(x,mp(a,b)));
		}
		cout<< N*N*N - ps.size() <<endl;
	}
}

Measured memory_bytes: 4332
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    if(N%2==0) cout<<(N-1)/2<<endl;
    else cout<<N/2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int N, M, V, P;

int bin_search(int l, int r, vector<int> &A){
    int mid=(l+r)/2;
    if(mid==l){
        return l;
    }

    long long value = A[mid]+M;

    if(value<A[P-1]){
        return bin_search(l, mid, A);
    }
    if(V<=P){
        return bin_search(mid, r, A);
    }else if(V>P && mid<N-V+P){
        return bin_search(mid, r, A);
    }else{
        long long diff=(V-P-(N-mid-1));
        long long cnt=(long long) diff*M;
        for(int i=P-1; i<mid; i++){
            //cout << cnt << endl;
            cnt-=min((long long) M, value-A[i]);
        }
        //cout << cnt << endl;
        if(cnt<=0){
            return bin_search(mid, r, A);
        }else{
            return bin_search(l, mid, A);
        }
    }
}

int main(){
    cin >> N >> M >> V >> P;
    vector<int> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    sort(A.rbegin(), A.rend());

    cout << bin_search(P-1, N, A)+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
int n,m;
int num[10];
double dist[40][40];
double memo[40][1<<8];
const int INF = 1<<28;

struct V{
  int v,tic;
  V(int v,int tic):v(v),tic(tic){}
};

bool operator < (const V& a,const V& b){
  return memo[a.v][a.tic] > memo[b.v][b.tic];
}

double solve(int a,int b){
  for(int i=0;i<n;++i)
    for(int j=0;j<1<<m;++j)
      memo[i][j]=INF;
  memo[a][(1<<m)-1]=0;

  priority_queue<V> Q;
  Q.push(V(a,(1<<m)-1));
  while(!Q.empty()){
    V x = Q.top(); Q.pop();
    int v = x.v;
    int tck = x.tic;
    double cst = memo[v][tck];
    for(int i=0;i<n;++i){
      if(dist[v][i]){
	for(int j=0;j<m;++j){
	  if((tck>>j)&1){
	    int nxttck = tck-(1<<j);
	    double nxtcst = cst+1.0*dist[v][i]/num[j];
	    if(memo[i][nxttck] <= nxtcst) continue;
	    memo[i][nxttck] = nxtcst;
	    Q.push(V(i,nxttck));
	  }
	}
      }
    }
  }

  double ret = INF;
  for(int i=0;i<1<<m;++i) ret = min(ret,memo[b][i]);
  if(ret==INF) ret=-1;
  return ret;
}

int main(){
  int p,a,b;
  while(cin>>m>>n>>p>>a>>b,n||m||p||a||b){
    memset(dist,0,sizeof(dist));
    for(int i=0;i<m;++i) cin>>num[i];
    a--;b--;
    while(p--){
      int s,t,d;
      cin>>s>>t>>d;
      s--;t--;
      dist[s][t]=dist[t][s]=d;
    }
    double ans = solve(a,b);
    if(ans<0) cout << "Impossible" << endl;
    else cout << ans << endl;
  }
  return 0;
}
  

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30

using namespace std;

int main()
{
    int n,m;
    while(cin >> n >> m)
    {
       if(n == 0 && m == 0) break;
       
       vector<int> a(n),b(m);
       int as = 0,bs = 0;
       rep(i,n)  {
           cin >> a[i];
           as += a[i];
       }
       rep(i,m) {
           cin >> b[i];
           bs += b[i];
       }

       int ans = INF,A = 0,B = 0;
       rep(i,n) {
           rep(j,m) {
               int res = as - a[i] + b[j];
               int res2 = bs - b[j] + a[i];
               if(res == res2) {
                   if(res < ans) {
                       ans = res;
                       A = i;
                       B = j;
                   }
               }
           }
       }

       if(ans == INF) cout << -1 << endl;
       else cout << a[A] << " " << b[B] << endl;
    }

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
long long a[305][305];
long long sum;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			long long t=a[i][j]+1;
			for(int k=0;k<n;k++)
			{
				if(i==k||j==k)
					continue;
				t=min(t,a[i][k]+a[k][j]);
			}
			if(t<a[i][j])
			{
				cout<<"-1";
				return 0;
			}
			if(t>a[i][j])
				sum+=a[i][j];
		}
	}
	cout<<sum; 

	return 0;
}

Measured memory_bytes: 896
import math

MOD = 10**9+7
fact = [1]
for i in range(1, 2*10**5+10):
    fact.append((fact[i-1]*i)%MOD)

def comb(n, k):
    ans = 1
    for i in range(k):
        ans = (ans*(n-i))%MOD
    return (ans*pow(fact[k], MOD-2, MOD))%MOD

n, a, b = map(int, input().split())
ans = 1
x = 2
y = n
while y != 0:
    if y%2 != 0:
        ans = (ans*x)%MOD
    x = (x*x)%MOD
    y >>= 1
ans = (ans - comb(n, a) - comb(n, b) -1)%MOD
print(ans)

Measured memory_bytes: 52592
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h, w = LI()
maze = SRL(h)


def solve(sy, sx):
    min_cost = deepcopy(maze)
    min_cost[sy][sx] = 0
    que = deque([(sy, sx)])
    max_c = 0
    while que:
        cy, cx = que.popleft()
        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            ny = cy + i
            nx = cx + j
            if 0 <= ny < h and 0 <= nx < w:
                if min_cost[ny][nx] == '.':
                    min_cost[ny][nx] = min_cost[cy][cx] + 1
                    que += [(ny, nx)]
                    max_c = max(max_c, min_cost[ny][nx])
    return max_c



ans = 0
for y in range(h):
    for x in range(w):
        if maze[y][x] == '#':
            continue
        else:
            max_c = solve(y, x)
            ans = max(max_c, ans)


print(ans)

Measured memory_bytes: 54364
import sys
for line in sys.stdin:
    hit = 0
    blow = 0
    if line == "\n":
        break
    A = line.split()
    B = [n for n in input().split()]
    for i in B:
        if i in A:
            if A.index(i) == B.index(i):
                hit += 1
            else:
                blow += 1
    print(hit, blow)

Measured memory_bytes: 7540
def main():
    from itertools import takewhile

    N, X = map(int, input().split())
    *L, = map(int, input().split())

    def accumulate(a):
        s = 0
        yield s
        for x in L:
            s += x
            yield s

    ans = len(tuple(takewhile(lambda s: s <= X, accumulate(L))))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# import sys
# input = sys.stdin.readline
import itertools

# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, m, x = input_list()
    books = {}
    contents = {}
    for i in range(n):
        c = input_list()
        books[i] = c[0]
        contents[i] = c[1:m+1]

    if n == 1:
        if sum(contents[0]) >= x:
            print(books[0])
        else:
            print(-1)
        exit()

    ans = []
    for v in itertools.product([0, 1], repeat=n):
        understands = [0] * m
        ok = [False] * m
        a = 0
        for i, vi in enumerate(v):
            if vi == 0:
                continue
            for index, val in enumerate(contents[i]):
                understands[index] += val
                if understands[index] >= x:
                    ok[index] = True
            a += books[i]
        if all(ok):
            ans.append(a)

    if len(ans) > 0:
        print(min(ans))
    else:
        print(-1)
        # a = 0
        # for vi in v:
        #     for index, val in enumerate(contents[vi]):
        #         understands[index] += val
        #         if understands[index] >= x:
        #             ok[index] = True
        #     a += books[vi]
        # if all(ok):
        #     ans.append(a)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 74180
#include <bits/stdc++.h>
#pragma GCC optimize ("O3,unroll-loops")
#define f first
#define s second
#define ri register int
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int **dp = new int*[n];
	for(ri k = 0; k < n; ++k) {
		dp[k] = new int[m];
		for(ri i = 0; i < m; ++i)
			dp[k][i] = 0;
	}
	for(ri k = 0; k < n; ++k) dp[k][0] = s[k] == t[0];
	for(ri k = 0; k < m; ++k) dp[0][k] = s[0] == t[k];
	for(ri k = 1; k < n; ++k) dp[k][0] |= dp[k - 1][0];
	for(ri k = 1; k < m; ++k) dp[0][k] |= dp[0][k - 1];
	for(ri k = 1; k < n; ++k) {
		for(ri i = 1; i < m; ++i) {
			if(s[k] == t[i]) dp[k][i] = 1 + dp[k - 1][i - 1];
			else dp[k][i] = dp[k - 1][i - 1];
			dp[k][i] = max(dp[k][i], max(dp[k - 1][i], dp[k][i - 1]));
		}
	}
	string ans;
	int lcs = dp[n - 1][m - 1];
	for(ri k = n - 1; k >= 0; --k) {
		for(ri i = m - 1; i >= 0; --i) {
			if(s[k] == t[i] && dp[k][i] == lcs) {
				ans.push_back(s[k]);
				--lcs;
				m = i;
				break;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
    return 0;
}

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

typedef int32_t i32;
typedef int64_t i64;

typedef struct line {
  i64 a, b;
} line;

i64 eval (line l, i64 x) {
  return l.a * x + l.b;
}

int cond (line p, line q, line r) {
  return -(p.b - q.b) * (q.a - r.a) < -(q.b - r.b) * (p.a - q.a);
}

#define ALLOC(size,type) ((type*) calloc ((size), sizeof (type)))

void run (void) {
  i32 n;
  i64 c;
  scanf ("%" SCNi32 "%" SCNi64, &n, &c);
  i32 h;
  scanf ("%" SCNi32, &h);
  line *d = ALLOC (n, line);
  i32 front = 0;
  i32 last = 0;
  d[last++] = (line) {-2 * h, (i64)h * h + c};
  i64 cur = 0;
  for (i32 i = 1; i < n; ++i) {
    i32 x;
    scanf ("%" SCNi32, &x);
    for (; front < last - 1 && eval (d[front], x) >= eval (d[front + 1], x); ++front);
    cur = eval (d[front], x) + (i64) x * x;
    line l = {-2 * x, cur + (i64) x * x + c};
    for (; front + 1 < last && !cond (d[last - 2], d[last - 1], l); --last);
    d[last++] = l;
  }
  printf ("%" PRIi64 "\n", cur);
}

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


Measured memory_bytes: 3328
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n, c, k;
  cin >> n >> c >> k;
  int t[n];
  for(int i = 0; i < n; i++){
    cin >> t[i];
  }

  sort(t, t + n);
  int i = 0;
  int count = 0;
  while(i < n){
    int j = distance(t + i, upper_bound(t, t + n, t[i] + k));
    i += min(c, j);
    ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  map<int,int> ans;
  ans[a]++;
  ans[b]++;
  ans[c]++;
  if(ans[5]==2&&ans[7]==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  int ans;
  if (a == 2) ans = 1;
  if (a == 1 && b == 3) ans = 2;
  if (a == 1 && b == 2) ans = 3;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<math.h>

using namespace std;
int main(){
    
    long long a,b=1000000000000;
    cin >> a;
    for(int i=1;i<=sqrt(a);i++){
        if(a%i==0){
            if((i+(a/i))<=b){
                b=i+(a/i);
            }
        }
    }
    

    cout << b-2 << endl;

}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 4");
            WillReturn.Add("1 2");
            WillReturn.Add("2 3");
            WillReturn.Add("3 4");
            WillReturn.Add("4 2");
            //Yes
            //1
            //2
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("6 9");
            WillReturn.Add("3 4");
            WillReturn.Add("6 1");
            WillReturn.Add("2 4");
            WillReturn.Add("5 3");
            WillReturn.Add("4 6");
            WillReturn.Add("1 5");
            WillReturn.Add("6 2");
            WillReturn.Add("4 5");
            WillReturn.Add("5 6");
            //Yes
            //6
            //5
            //5
            //1
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];

        // 移動可能な座標のSetのDict
        var LinkListDict = new Dictionary<int, HashSet<int>>();

        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            int A = wkArr[0];
            int B = wkArr[1];

            Action<int, int> AddAct = (pFrom, pTo) =>
            {
                if (LinkListDict.ContainsKey(pFrom) == false) {
                    LinkListDict[pFrom] = new HashSet<int>();
                }
                LinkListDict[pFrom].Add(pTo);
            };
            AddAct(A, B);
            AddAct(B, A);
        }

        var Que = new Queue<int>();
        Que.Enqueue(1);

        var AnswerDict = new Dictionary<int, int>();
        var Visited = new HashSet<int>();
        Visited.Add(1);

        while (Que.Count > 0) {
            int Dequeued = Que.Dequeue();

            foreach(int EachInt in LinkListDict[Dequeued]){
                //再訪禁止
                if (Visited.Add(EachInt) == false) {
                    continue;
                }
                Que.Enqueue(EachInt);
                AnswerDict[EachInt] = Dequeued;
            }
        }
        Console.WriteLine("Yes");
        for (int I = 2; I <= N; I++) {
            Console.WriteLine(AnswerDict[I]);
        }
    }
}


Measured memory_bytes: 77540
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {
    var n = parseInt(input[0], 10);
    var a = parseInt(input[1], 10);

    var black = n * n - a;
    console.log(black);

    return 0;
}



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

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	int ans = -1;

	for (int i = 0;i < 60;i++) {
		if (n % (a + b) <= a) {
			ans = n;
			break;
		}
		n += 60;
	}
	cout << ans << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N,Q;
    cin >> N >> Q;
    fenwick_tree<int> ft(N);
    REP(i,N) {
        int a;
        cin >> a;
        ft.add(i, a);
    }
    REP(i,Q) {
        int a,b,c;
        cin >> a >> b >> c;
        if (a == 0) {
            ft.add(b, c);
        }
        else {
            cout << ft.sum(b,c) << endl;
        }
    }

    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 8264
def buble(a):
    c = 0
    for i in range(n):
        for j in range(n-1,i,-1):
            if int(a[j]) < int(a[j-1]):
                a[j],a[j-1] = a[j-1],a[j]
                c += 1
    return c
    
while True:
	n = int(raw_input())
	if n == 0: break
	a = [int(raw_input()) for i in range(n)]
	print buble(a)

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    int answer = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x.at(i);
        answer += min(2 * x.at(i), 2 * (k - x.at(i)));
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, a; cin >> n >> k;
    rep(i, n) cin >> a;
    ll res = 1; n -= k;
    while(n > 0){
        n -= (k-1);
        ++res;
    }
    cout << res;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

vector<int> s(30);
int n, mi = 100;
ll gcd(ll a, ll b) {
	return (b == 0 ? a : gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
unordered_set<ll> se;
void dfs(int a, ll b) {
	if (a == n) {
		se.insert(b);
		return;
	}
	dfs(a + 1, b);
	dfs(a + 1, lcm(b, s[a]));
}
int main() {
	cin >> n;
	REP(i, n) {
		cin >> s[i];
		mi = min(mi, s[i]);
	}
	dfs(0, 1);
	if(mi == 1) cout << se.size() << endl;
	else cout << se.size() - 1 << endl;
}


Measured memory_bytes: 3736
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if (a+b==c || b+c==a || c+a==b){
		printf("Yes");
	} else {
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s1(c, s, last_date, di, i):
    score = s[di - 1][i]
    score -= 20 * c[i - 1] * (di - last_date[i - 1])
    return score


def f(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        score_list = []
        for i in range(26):
            score_list.append(s1(c, s, last_date, di, i))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f(D, c, s):
    print(ti + 1)

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

int main()
{
  int m, f, r;
  cin >> m >> f >> r;
  while (m != -1 || f != -1 || r != -1)
  {
    if (m == -1 || f == -1)
    {
      cout << "F" << endl;
    }
    else if (m + f >= 80)
    {
      cout << "A" << endl;
    }
    else if (m + f >= 65 && m + f < 80)
    {
      cout << "B" << endl;
    }
    else if (m + f >= 50 && m + f < 65)
    {
      cout << "C" << endl;
    }
    else if (m + f >= 30 && m + f < 50)
    {
      if (r >= 50)
      {
        cout << "C" << endl;
      }
      else
      {
        cout << "D" << endl;
      }
    }
    else if (m + f < 30)
    {
      cout << "F" << endl;
    }
    cin >> m >> f >> r;
  }
}


Measured memory_bytes: 3088
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let mut ans = "No";
    'o: for i in 1..10 {
        for j in 1..10 {
            if n == i * j {
                ans = "Yes";
                break 'o;
            }
        }
    }
    println!("{}", ans);
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int ans = (int) 1e4;
  int len = 0;
  if ((int) t.size() == (int) s.size()) {
    for (int i = 0; i < (int) t.size(); i++) {
      if (s[i] == t[i]) {
        len++;
      }
    }
    cout << (int) t.size() - len << '\n';
    return 0;
  }
  for (int i = 0; i + (int) t.size() < (int) s.size(); i++) {
    len = 0;
    for (int j = 0; j < (int) t.size(); j++) {
      if (s[i + j] == t[j]) {
        len++;
      }
    }
    ans = min(ans, (int) t.size() - len);
  }
  cout << ans << '\n';
  return 0;
}


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

vector<int> primes={2,3,5,7};
int primes_extend(int calc_from, int calc_to);
int factoring(int n, map<int,int> &factors);


int main()
{

	primes_extend(10,100);
	primes_extend(100,10000);
	primes_extend(10000,1000000);

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

	map<int,int> primescount;
	for (int i=0;i<n;++i)
	{
		if (a[i]==1)
		{
			continue;
		}

		map<int,int> factors;
		factoring(a[i],factors);
		for (pair<int,int> p:factors)
		{
			++primescount[p.first];
		}
	}

	bool factor_in_2plus=false;
	bool factor_in_n=false;
	for (pair<int,int> p: primescount)
	{
		if (p.second>=2)
		{
			factor_in_2plus=true;
			if (p.second==n)
			{
				factor_in_n=true;
			}
		}
	}

	if (factor_in_n!=false)
	{
		cout << "not coprime" << endl;
	}
	else if (factor_in_2plus!=false)
	{
		cout << "setwise coprime" << endl;
	}
	else
	{
		cout << "pairwise coprime" << endl;
	}
}


int primes_extend(int calc_from, int calc_to)
{

	for (int i=calc_from;i<=calc_to;++i)
	{
		int j;
		int loop_max=sqrt(i);
		for (j=0;(primes[j]<=loop_max)&&(j<primes.size());++j)
		{
			if ((i%primes[j])==0)
			{
				// not prime...
				break;
			}
		}
		if ((j>=primes.size())||(primes[j]>loop_max))
		{
			primes.push_back(i);
		}
	}
	//fprintf(stderr,"count: %d\n",primes.size());
	return 0;
}

int factoring(int n, map<int,int> &factors)
{
	int maxfactor=sqrt(n);
	for (int i=0;(n>1)&&(primes[i]<=maxfactor);++i)
	{
		while ((n%primes[i])==0)
		{
			n/=primes[i];
			factors[primes[i]]++;
		}
	}
	if (n!=1)
	{
		factors[n]++;
	}

	return 0;
}






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

int main() {
	string str;
	cin >> str;
	int value = 700;
	for (int i = 0; i < 3; i++) {
		if (str[i] == 'o') value += 100;
	}
	cout << value << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

/////////////////////////////////////////
///////////////// Input /////////////////
/////////////////////////////////////////

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

func main() {
	inputs := scanIntNums()
	N := inputs[0]
	M := inputs[1]

	H := scanIntNums()
	outMap := make(map[int]int, N)

	for i := 0; i < M; i++ {
		inputs = scanIntNums() // A : 1~N -> H:0~N-1
		if H[inputs[0]-1] > H[inputs[1]-1] {
			outMap[inputs[1]-1]++
		} else if H[inputs[0]-1] < H[inputs[1]-1] {
			outMap[inputs[0]-1]++
		} else {
			outMap[inputs[0]-1]++
			outMap[inputs[1]-1]++
		}
	}
	fmt.Println(N - len(outMap))
}


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

int main(void){
  string s;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i] == '1') s[i]='9';
    else s[i] = '1';
  }
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,k,a,ans=0;
  std::cin >> n>>k;
  for (int i = 0; i < n; i++) {
    std::cin >> a;
    if(a>=k)ans++;
  }
  std::cout << ans << '\n';


return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < 10 && b < 10){
            System.out.println(a*b);
        }else{
            System.out.println("-1");
        }
        sc.close();
    }
}

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

int main(){
	/*input*/
	vector<vector<char> >c(3, vector<char>(3));
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}
	/*calculation*/
	/*output*/
	cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


Measured memory_bytes: 256
N, C = map(int, input().split())
xy = [[int(i) for i in input().split()] for _ in range(N)]
c = [0]
rc = [0]
uc = [0]
ruc = [0]
sum = 0
out = 0
for x, cal in xy:
    sum += cal
    c.append(max(c[-1], sum-x))
    rc.append(max(rc[-1], sum-2*x))
sum = 0
for x, cal in xy[::-1]:
    sum += cal
    uc.append(max(uc[-1], sum-C+x))
    ruc.append(max(ruc[-1], sum-2*(C-x)))
for w, wr in zip(c, ruc[::-1]):
    out = max(out, w+wr)
for w, wr in zip(rc, uc[::-1]):
    out = max(out, w+wr)
print(out)

Measured memory_bytes: 35072
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long int flag = -1;
void yutongzhou(long long int s[3])
{
	sort(s,s+3);
	long long int r=s[2]-s[0];
	if(flag==-1)	flag=r;
	else
    {
        if(r<flag)
           flag=r;
    }
}
int main()
{
    long long int a[6],b[6];
	long long int h,w,i,j;
	long long int s[3];
	scanf("%lld%lld",&h,&w);
		a[0]=h/3;
		b[0]=w/3;
        a[2]=a[0]+2;
		b[2]=b[0]+2;
		a[1]=a[0]+1;
		b[1]=b[0]+1;
        a[4]=a[0]-1;
		b[4]=b[0]-1;
		a[5]=a[0]-2;
		b[5]=b[0]-2;
		a[3]=h>>1;
		b[3]=w>>1;
        for(i=0;i<=5;i++)
		{
			for(j=i; j<=5;j++)
			{
				if(b[i]>=0&&b[j]>=0&&b[i]+b[j]<=w)
				{
                    s[1]=b[j]*h;
					s[0]= b[i]*h;
					s[2] =(w-b[i]-b[j])*h;
					yutongzhou(s);
				}
			}
		}
		for(i=0; i<=5; i++)
        {
			for(j=0; j<=5; j++)
			{
				if(a[i]>=0&&b[j]>=0&&a[i]<=h&&b[j]<=w)
                {
					s[0]= a[i]*w;
					s[1]=(h-a[i])*b[j];
					s[2] =(h-a[i])*(w-b[j]);
					yutongzhou(s);
					s[0]= b[j]*h;
					s[1]=(w-b[j])*a[i];
					s[2] =(w-b[j])*(h-a[i]);
					yutongzhou(s);\
					s[1]=(a[i])*b[j];
					s[0]= (h-a[i])*w;
					s[2] =(a[i])*(w-b[j]);
					yutongzhou(s);
					s[0]= (w-b[j])*h;
					s[1]=(b[j])*a[i];
					s[2] =(b[j])*(h-a[i]);
					yutongzhou(s);
				}
			}
		}
		for(i=0;i<=5;i++)
		{
			for(j=i;j<=5;j++)
			{
				if(a[i]>=0&&a[j]>=0&&a[i]+a[j]<=h)
                {
                    s[1]=a[j]*w;
					s[0]= a[i]*w;
					s[2] =(h-a[i]-a[j])*w;
					yutongzhou(s);
				}
			}
		}
	printf("%lld",flag);
	return 0;
}


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

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

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>; 

int main(){
    int n,k,r,p,s;
    cin>>n>>k>>r>>s>>p;
    string t; cin>>t;
    vector<int>win(n);
    int ans = 0;
    rep(i,n){
        if(t[i] == 'r'){
            if(i>=k&&t[i]==t[i-k]&&win[i-k] == 1){
              continue;  
            }else{
                ans += p;
                win[i] = 1;
            }
        }else if(t[i] == 's'){
             if(i>=k&&t[i]==t[i-k]&&win[i-k] == 1){
                  continue;  
            }else{
                ans += r;
                win[i] = 1;
            }
        }else{
             if(i>=k&&t[i]==t[i-k]&&win[i-k] == 1){
              continue;  
            }else{
                ans += s;
                win[i] = 1;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 896