akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_127A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, x;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            x = int.Parse(word[1]);

            if (a>=13)
            {
                x = b;
            }

            else if (a>=6 && 6<=12)
            {
                x = b / 2;
            }

            else if (a<=5)
            {
                x = 0;
            }

            Console.WriteLine(x);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long int ll;
typedef long double ld;
const int maxn=2E5+5;
ll n,k,l[maxn],r[maxn],f[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=k;++i)
		cin>>l[i]>>r[i];
	f[1]=1;
	ll s=0;
	for(int i=2;i<=n;++i)
	{
		for(int j=1;j<=k;++j)
		{
			if(i-l[j]>=1)
				s=(s+f[i-l[j]])%mod;
			if(i-r[j]-1>=1)
				s=(s-f[i-r[j]-1])%mod;
		}
		f[i]=s;
	}
	cout<<(f[n]%mod+mod)%mod<<endl;
	return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int X, A;
  cin >> X >> A;
  int ans = 0;
  if (X >= A) ans = 10;
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int maximam(int a,int b,int c){
  if(a>=b&&a>=c) return a;
  else if(b>=a&&b>=c) return b;
  else return c;
}
int main(){
  int A,B;
  cin>>A>>B;
  int x=maximam(A+B,A-B,A*B);
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int ans=0;
	if(n==0)ans=1;
	if(n==1)ans=2;
	if(n==2)ans=1;
	cout<<ans<<endl;
}


Measured memory_bytes: 3148
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n, l] <- readInts
  input <- getNLns n
  putStrLn $ solve input

solve :: [String] -> String
solve = concat . sort

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx


Measured memory_bytes: 1404
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
L = [-1] * (N+1)
L[1] = 0
idx = 1
for i in range(1, N+1):
    idx = A[idx]
    if L[idx] >= 0:
        t = i - L[idx]
        b = L[idx]
        break
    else:
        L[idx] = i

if K <= b:
    print(L.index(K))
else:
    print(L.index((K-b)%t+b))


Measured memory_bytes: 32376
#include<stdio.h>

int main(void) {
	int a=0, b=0, c=0,d=0;

	scanf("%d %d %d", &a, &b,&c);
	a--;
	for (;;) {
		a++;
		if (c%a == 0)
			d++;

		if (b - a <= 0)
			break;
	}
	printf("%d\n", d);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  map<string, ll> anaglam;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    anaglam[s[i]]++;
  }
  ll ans = 0;
  for (auto x : anaglam) {
    ll num = x.second;
    ans += num*(num-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 14068
#include<bits/stdc++.h>
using namespace std;
#define debug 1

const long MAXN=60;
long n;
string s[MAXN];
long t[MAXN];

int main() {
	cin>>n;
	register long i;
	for(i=1;i<=n;++i) {
		cin>>s[i]>>t[i];
	}
	
	string sleep;
	cin>>sleep;
	for(i=1;i<=n;++i)
		if(sleep == s[i]) {
			++i;
			break;
		}
	
	long ans=0;
	for(;i<=n;++i)
		ans+=t[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    REP(i,n){
        cin>>v[i];
    }
    if(v[0]!=1){
        v[0]--;
    }
    FOR(i,1,n){
        if(v[i-1]<v[i]){
            v[i]--;
        }
        if(v[i-1]>v[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long[] a = new long[N];
		for (int i=0;i<N;i++) {
			a[i] = Long.parseLong(sc.next());
		}
		Arrays.sort(a);
		long tmp = 0;
		int flag = 0;
		if (N%3 != 0) {
			flag=1;
		} else {
			for (int i=0;i<N;i++) {
				if (i==0) {
					tmp = a[0];
				} else if (0<i && i<N/3) {
					if (tmp != a[i]) {
						flag=1;
						break;
					}
				} else if (i==N/3) {
					tmp = a[N/3];
				} else if (N/3<i && i<N/3*2) {
					if (tmp != a[i]) {
						flag=1;
						break;
					}
				} else if (i==N/3*2) {
					if (a[N/3*2]!=(a[0]^a[N/3])) {
						flag=1;
						break;
					}
					tmp = a[N/3*2];
				} else if (N/3*2<i && i<N) {
					if (tmp != a[i]) {
						flag=1;
						break;
					}
				}
			}
		}
		int flag_zero = 0;
		for (int i=0;i<N;i++) {
			if (a[i]!=0) {
				flag_zero = 1;
			}
		}
		if (flag==0 || flag_zero==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 48880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> x(N),y(N),h(N);
  for(int i=0;i<N;i++){cin >> x[i] >> y[i] >> h[i];}
  int a,b,H;
  for(int a=0;a<=100;a++){
    for(int b=0;b<=100;b++){
      for(int i=0;i<N;i++){
        if(h[i]!=0){
          H=h[i]+abs(x[i]-a)+abs(y[i]-b);
          break;}
      }
      for(int j=0;j<N;j++){
        if(h[j]!=max(H-abs(x[j]-a)-abs(y[j]-b),0)){break;}
        if(j==N-1){
          cout << a << " " << b << " " << H << endl;
          return 0;}
      }
    }
  }
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 138
//B - Resistors in Parallel
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;

    cin >> n;

    vector<double> a(n);
    REP(i, n) cin >> a[i];

    double ans = 0;
    REP(i, n) ans+=1.0/a[i];

    cout << fixed;
    cout << setprecision(12) << 1.0/ans << endl;

    return 0;
}


Measured memory_bytes: 256
import std;

void main() {
    string s = read!string;
    writeln(s.canFind('7') ? "Yes" : "No");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

int a, i;
bool ada = false;

int main () {
    cin>>a;
    for (i=1; i<=a; i++) {
        if (a%i==0) {
            if (i<=9 && a/i<=9) {
                ada = true;
            }
        }
    } if (ada) {cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




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

	set<int> s;
	int m = 7 % k;


	for (int i = 1; i <= k; i++) {
		if (m == 0) {
			cout << i << endl;
			return 0;
		}

		if (s.find(m) != s.end()) {
			cout << -1 << endl;
			return 0;
		}

		s.insert(m);
		m = (m * 10 + 7) % k;

	}
}


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

int main(){
  int x, y; cin >> x >> y;
  int ans = 0;
  if (x <= 3){
    ans += 300000 - 100000*(x-1);
  }
  if (y <= 3){
    ans += 300000 - 100000*(y-1);
  }
  if (x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
}

Measured memory_bytes: 256
const numberList = require('fs').readFileSync('/dev/stdin','utf8').trim().split(' ').map(e => parseInt(e))

// answer = (a-1)n+1
var a = numberList[0]
var b = numberList[1]

for(var n=0;;n++) {
  if((a-1) * n + 1 >= b) {
    console.log(n)
    break
  }
}


Measured memory_bytes: 21064
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=999999999999;
ll frac[MAX_N];
ll ifrac[MAX_N];

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

ll comb(ll n, ll r, ll mod){
    ll res=1;
    res*=frac[n];
    res*=modpow(frac[r],mod-2,mod);
    res%=mod;
    res*=modpow(frac[n-r],mod-2,mod);
    res%=mod;
    return res;
}

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    frac[0]=frac[1]=1;
    for(int i=2;i<MAX_N;i++){
        frac[i]=frac[i-1]*i%MOD;
    }
    for(ll i=0;i<=k;i++){
        ans+=comb(n-1,i,MOD)*m%MOD*modpow(m-1,n-1-i,MOD)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7560
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    int a,b;
    cin >> a >> b;

    if(a+b==3){
        cout << 3 << endl;
    }else if(a+b==5){
        cout << 1 << endl;
    }else{
        cout << 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void) {
double a,b,c,d;
double e;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
e=(a-c)*(a-c)+(b-d)*(b-d);
e=sqrt(e);
printf("%f",e);
  return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i,m) {
        cin >> p[i] >> s[i];
    }
    int ac = 0;
    int wa = 0;
    vector<bool> isSolved(n);
    rep(i,m) {
        int num = p[i]-1;
        if (!isSolved[num] && s[i] == "AC") {
            ++ac;
            isSolved[num] = true;
        }
        if (!isSolved[num] && s[i] == "WA") {
            ++wa;
        }
    }
    rep(i,m) {
        if (!isSolved[p[i]-1] && s[i] == "WA") {
            --wa;
        }
    }
    printf("%d %d\n", ac, wa);
    return 0;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <complex>

using namespace std;

// #define mod 1000000007

int c[4][4];

int paint(int nowstate, int i, int j, int k, int l, int nowc)
{
	int result = nowstate;
	for(int s = i; s <= k; s++){
		for(int t = j; t <= l; t++){
			if(c[s][t] == nowc) result |= (1 << (4 * s + t));
			else result &= ~(1 << (4 * s + t));
		}
	}
	return result;
}

int main()
{
	int n;
	cin >> n;
	int canpaint[4][4][4][4] = {};
	// canpaint[i][j][k][l] : 右下が(i, j), 左上が(k, l)となるような範囲を塗れるスタンプがあるか否か
	for(int p = 0; p < n; p++){
		int h, w;
		cin >> h >> w;
		for(int i = -h + 1; i < 4; i++){
			for(int j = -w + 1; j < 4; j++){
				canpaint[max(i, 0)][max(j, 0)][min(i + h - 1, 3)][min(j + w - 1, 3)] = true;
			}
		}
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			char tmp;
			cin >> tmp;
			if(tmp == 'R') c[i][j] = 0;
			else if(tmp == 'G') c[i][j] = 1;
			else c[i][j] = 2;
		}
	}
	vector<int> result((1 << 16), -1);
	queue<int> qu;
	result[0] = 0;
	qu.push(0);
	while(!qu.empty()){
		int p = qu.front();
		// cout << p << endl;
		qu.pop();
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				for(int k = i; k < 4; k++){
					for(int l = j; l < 4; l++){
						if(!canpaint[i][j][k][l]) continue;
						for(int nowc = 0; nowc < 3; nowc++){
							int next = paint(p, i, j, k, l, nowc);
							if(result[next] < 0){
								result[next] = result[p] + 1;
								qu.push(next);
							}
						}
					}
				}
			}
		}
	}
	cout << result[(1 << 16) - 1] << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  char c;
  cin >> c;
  if(c - 'A' >= 0 && 'Z' - c >= 0){
    cout << "A" << endl;
  } else  {
    cout << "a" << endl;
  }
}


Measured memory_bytes: 3628
from collections import Counter

N = int(input())
Dlist = list(map(int, input().split()))

INF = 998244353

if Dlist[0] != 0:
    print(0)

else:
    D_max = max(Dlist)
    cnt = [0] * (D_max + 1)

    dic = Counter(Dlist)
    for k, v in dic.items():
        cnt[k] = v

    ans = cnt[0]

    if ans != 1:
        print(0)

    else:
        for i in range(D_max):
            ans = ans * (((cnt[i] % INF) ** cnt[i+1]) % INF)
            ans = ans % INF
        
        print(ans % INF)

Measured memory_bytes: 62572
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
const ll cutoff = 10000000000000000;
int main(void) {
    ll n,m,p;
    cin>>n>>m>>p;
    ll d[n];
    const ll lim = 1LL<<60;
    ll a[m],b[m],c[m];
    bool mat[n][n]={};
    rep(i,n){
        d[i]=lim;
    }
    rep(i,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;c[i]-=p;c[i]*=-1;
        mat[a[i]][b[i]]=true;
    }
    d[0]=0;
    bool closed[n]={};
    queue<int> que;
    DEBUG{
        rep(i,n){
            rep(j,n){
                cout << mat[i][j] << " ";
            }
            cout << endl;
        }
    }
    rep(i,n+1){
        rep(j,m){
            if(d[a[j]]!=lim&&d[b[j]]>d[a[j]]+c[j]){
                d[b[j]] = d[a[j]]+c[j];
                if(i==n){
                    closed[b[j]]=true;
                    que.push(b[j]);
                }
            }
        }
    }
    DEBUG{
        rep(i,n){
            cout << closed[i]<<endl;
        }
    }
    while(!que.empty()){
        int cur = que.front();
        DEBUG{cout <<"front : "<< cur << endl;}

        rep(i,n){
            if(mat[cur][i]&&!closed[i]&&d[cur]<=cutoff){
                DEBUG{cout << i << endl;}
                que.push(i);
                closed[i]=true;
            }
        }
        que.pop();
    } 
    if(closed[n-1]==true){
        cout << -1 << endl;
    }else{
        cout << max(0LL,-d[n-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <algorithm>
   
int main(){
    std::vector<int> a(4);
       
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
        int hit = 0, blow = 0;
           
        for(int i = 0; i < 4; ++i){
            int b;
            std::cin >> b;
               
            auto it = std::find(a.begin(), a.end(), b);
            if(it == a.begin() + i){
                ++hit;
            }else if(it != a.end()){
                ++blow;
            }
        }
        std::cout << hit << " " << blow << std::endl;
    }
      
    return 0;
}

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

#define ll long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef EBUCHKA
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

const int MAXN = 2e5 + 10000;

void solve() {

}

int main() {
    kekek();
    solve();
    int a, b;
    cin >> a >> b;
    for (int i = b - a + 1; i <= b + a - 1; i++) {
        cout << i << ' ';
    }
}


Measured memory_bytes: 256
#!/usr/bin/ruby
# coding: utf-8

PI = Math.acos(-1)

def sub(a, b)
  [a[0] - b[0], a[1] - b[1]]
end

def cross(a, b)
  a[1] * b[0] - a[0] * b[1]
end

def triangle(a, b, c)
  b = sub(b, a)
  c = sub(c, a)
  cross(b, c).abs / 2.0
end

ps = []
while true
  line = gets
  if line == nil
    break
  end
  p = line.chomp.split(',').map{|x| x.to_f}
  ps.push p
end

area = 0.0
for i in 1...ps.length-1
  area += triangle(ps[0], ps[i], ps[i+1])
end
puts area

Measured memory_bytes: 6148
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int inf = 1e9;
const int mod = 1e9 + 7;
ll a[maxn];
int n;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
    }
    ll res = 0;
    while(true){
        bool add = 0;
        for(int i = 1 ; i <= n ; ++i){
            if(a[i] >= n)add = 1;
            for(int j = 1 ; j <= n ; ++j){
                if(j != i)a[j] += a[i] / n;
            }
            res += a[i] / n;
            a[i] %= n;
        }
        if(add == 0)break;
    }
    cout << res;
}


Measured memory_bytes: 384
#include<stdio.h>
#define N 20
#define Q 200
int culc(int ,int);
int n,A[N];
int main(){
  int q,m[Q],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    if(culc(0,m[i])==1)printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}


int culc(int i ,int m){
  int Z,y;
  if(m==0)return 1;
  if(i>=n)return 0;
  if((y=culc(i+1,m))==1)Z=y;
  else if((y=culc(i+1,m-A[i]))==1) Z=y;
  return Z;
}



Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;
 
int A[200010];
 
int main() {
    int K, N;
    cin >> K >> N;
    for(int i=0; i<N; ++i) cin >> A[i];
    int mx=(K-A[N-1])+A[0];
    for(int i=1; i<N; ++i){
        mx=max(mx, A[i]-A[i-1]);
    }
    cout << K-mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  char str[3];
  for(int i=0;i<3;i++)
    scanf("%s",&str[i]);
  
  if(str[0]==str[1]&&str[1]==str[2])
    printf("No");
  else
    printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
import math
import statistics
a=int(input())
#b=int(input())
# c=[]
# for i in b:
#     c.append(i)
# e1,e2 = map(int,input().split())
f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
f.sort()
tyu = statistics.median(f)
if f[len(f)//2]==f[len(f)//2-1]:
    print(0)
else:
    print(f[len(f)//2]-f[len(f)//2-1])

Measured memory_bytes: 22988
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

typedef long long ll;

int main(){
  int N,M; cin >> N >> M;
  vector<int> P(M); vector<ll> Y(M);
  for(int i = 0; i < M; i++){ cin >> P[i] >> Y[i]; P[i]--;}
  
  vector<vector<ll>> City(N);
  for(int i = 0; i < M; i++){
    City[P[i]].push_back(Y[i]);}
  
  for(int j = 0; j < N; j++){
    sort(City[j].begin(),City[j].end());}
  
  for(int i = 0; i < M; i++){
    int v = P[i];
    int k = lower_bound(City[v].begin(),City[v].end(),Y[i]) - City[v].begin();
    cout << setw(6) << setfill('0') << v + 1;
    cout << setw(6) << setfill('0') << k + 1 << endl;}
  
  return 0;}
    
    
    
                       
                       
                       
  
  
  
                         
    

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

int main()
{
    int a,b;
    cin >> a >> b;
	int op;
	if(a>b)
	{
		int t=a;
		a=b;
		b=t;
	}
	op=b;
	op+=max(a,b-1);
	cout << op << endl;
    return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(void){
    int n;cin >> n;
  n--;
    cout << n / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n)
    {
        cin >> vec[i];
    }
    int max = *max_element(vec.begin(), vec.end());
    int min = *min_element(vec.begin(), vec.end());
    cout << max - min << endl;
}

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

int main(int argc, char *argv[])
{
    int a, b, c;
    long long ans;

    scanf("%d %d %d", &a, &b, &c);

    ans = 0;

    if (c > a) {
        ans += a;
        c -= a;
    } else {
        ans += c;
        c = 0;
    }

    if (c > b) {
        ans += b * 2;
        c -= b;
        b = 0;
        if (c > 0) {ans++;} //最後に毒入りを食べることもできる
    } else {
        ans += c * 2;
        b -= c;
    }

    ans += b; //解毒剤入りの美味しいクッキーのみも食べれる

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;

struct seg_tr{
    const static int MAX=1<<18;
    int tr[MAX<<1];
    void init(int n,int *arr) {
        for(int i=0;i<n;i++) tr[i+MAX]=arr[i];
        for(int i=MAX-1;i;i--) tr[i]=min(tr[i*2],tr[i*2+1]);
    }
    int get(int l,int r) {
        l+=MAX;r+=MAX;
    
        int mx=MAX;
        while(l<=r){
            mx=min({mx,tr[l],tr[r]});
            if(l&1)l++; if(!(r&1)) r--;
            l>>=1; r>>=1;
        }
        return mx;
    }
}tr[2];

int n,arr[200000],tmp[200000],pos[200001];
vector<int> ans;

struct td{
    int l,r,v[2];
    bool operator<(const td &rhs)const {
        return v[0]>rhs.v[0];
    }
};

bool make(int l,int r,td &v) {
    if(l>r) return false;

    v.v[0] = tr[l%2].get(l/2,(r-l%2)/2);
    
    int li=(pos[v.v[0]]+1)/2;
    v.v[1]=tr[(l%2)^1].get(li,r/2);
    v.l=l; v.r=r;
    return true;
}
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",arr+i);
    for(int i=0;i<n;i++) pos[arr[i]]=i;
    
    for(int s=0;s<2;s++) {
        for(int i=0;i<n/2;i++) tmp[i]=arr[i*2+s];
        tr[s].init(n/2,tmp);
    }
    
    priority_queue<td> que;
    td tmp;
    make(0,n-1,tmp);
    que.push(tmp);
    while(!que.empty()) {
        td cur=que.top();que.pop();
        ans.push_back(cur.v[0]);
        ans.push_back(cur.v[1]);

        if(make(cur.l,pos[cur.v[0]]-1,tmp)) que.push(tmp);
        if(make(pos[cur.v[0]]+1,pos[cur.v[1]]-1,tmp)) que.push(tmp);
        if(make(pos[cur.v[1]]+1,cur.r,tmp)) que.push(tmp);
    }
    for(auto &it:ans) printf("%d ",it);
    
    return 0;
}


Measured memory_bytes: 8820
#include<bits/stdc++.h>
#define INF 1000000000
#define MIN(x,y) ((x)<(y)?(x):(y))
using namespace std;

int mod(int x){
	return x<0?-x:x; 
}

int main(){
	string str;
	cin>>str;
	int num = 0;
	int N = str.length();
	int ans = INF;
	for(int i=0;i<N-2;i++){
		num = (str[i]-'0');
		num = num*10 + (str[i+1]-'0');
		num = num*10 + (str[i+2]-'0');
		ans = MIN(ans,mod(num-753)); 	
	}
	cout<<ans<<"\n";	
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools

a, b, c, d = list(input())

lst = ['-', '+']
for i, j, k in itertools.product(range(2), range(2), range(2)):
    ans = int(a)
    if i:
        ans += int(b)
    else:
        ans -= int(b)
    if j:
        ans += int(c)
    else:
        ans -= int(c)
    if k:
        ans += int(d)
    else:
        ans -= int(d)
        
    if ans == 7:
        print(a,lst[i],b,lst[j],c,lst[k],d,'=7',sep='')
        break

Measured memory_bytes: 9148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

d = []
s = ns()
que = collections.deque()
for c in s:
    if c not in d:
        d.append(c)

ans = inf
if len(d) == 1:
    print(0)
else:
    for c in d:
        t = copy.copy(s)
        for j in range(len(s) - 1):
            nt = []
            for i in range(len(t)-1):
                if c not in t[i:i+2]:
                    nt.append(t[i])
                else:
                    nt.append(c)
            if nt.count(c) == len(nt):
                ans = min(j+1, ans)
                break
            t = copy.copy(nt)
            
    print(ans)


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

#define MAX 1000000
#define INF 1000000000

int dp1[MAX + 1], dp2[MAX + 1];

int main()
{
    for (int i = 1; i <= MAX; i++)
    {
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for (int n = 1; n * (n + 1) * (n + 2) / 6 <= MAX; n++)
    {
        int a = n * (n + 1) * (n + 2) / 6;
        for (int i = a; i <= MAX; i++)
        {
            dp1[i] = min(dp1[i], dp1[i - a] + 1);
        }
        if (a % 2 == 0)
            continue;
        for (int i = a; i <= MAX; i++)
        {
            dp2[i] = min(dp2[i], dp2[i - a] + 1);
        }
    }

    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10900
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N,k;
  cin >> N >> k ;
  string S;
  cin >> S;
  
  if(S[k-1] == 'A')S[k-1] = 'a';
  else if(S[k-1] == 'B')S[k-1] = 'b';
  else if(S[k-1] == 'C')S[k-1] = 'c';
  stringput(S);
}

Measured memory_bytes: 256
/*  ex4_2
    hangan2020 */

#include <stdio.h>

//プロトタイプ宣言
//T_a:Tower_a, T_b:Tower_b
int SnowDepth(int T_a, int T_b);

main(void){
    int T_a, T_b;
    int snowdepth;
    scanf("%d %d", &T_a, &T_b);
    //雪積りưお計算する関数の実施
    snowdepth = SnowDepth(T_a, T_b);
    printf("%d\n", snowdepth );
    return 0;
}

int SnowDepth(int T_a, int T_b){
    int towerb_no, towerb_len;
    //towerb_no:塔の低いほうからの番号; towerb_len:塔の実際の高さ
    int snowdepth;
    //塔の高さは隣の低い塔の高さ足す自分の番号である。
    //高い塔(b)の番号を計算
    towerb_no = T_b - T_a;
    //高い塔の高さ
    towerb_len = (towerb_no*(1+towerb_no))/2;
    snowdepth = towerb_len - T_b;
    return(snowdepth);
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

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

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

int main() {
    std::ios::sync_with_stdio(false);
    LL N;cin >> N;
    for(LL h=1;h<=3500;h++){
        for(LL n=h;n<=3500;n++){
            LL hoge = 4LL*h*n-N*n-N*h;
            if(hoge <= 0) continue;
            if(N*h%hoge != 0) continue;
            LL w = N*h*n/hoge;
            if(4LL*h*n*w == N*(n*w + w*h + h*n)){
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $ans = dfs($n, 0);

  echo $ans;

  function dfs($n, $x){
    if($x > $n){
      return 0;
    }
    $p = [];
    $strx = strval($x);
    for ($i=0; $i<strlen($strx); $i++) {
      $p[$strx[$i]] = true;
    }
    if(count($p) == 3){
      $ret = 1;
    }else{
      $ret = 0;
    }
    $ret += dfs($n, 10*$x+3);
    $ret += dfs($n, 10*$x+5);
    $ret += dfs($n, 10*$x+7);
    return $ret;
  }
  

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


signed main(){
	int N;cin>>N;
	vint L(N);
	rep(i,N)cin>>L[i];
	sort(all(L));

	int ans=0;
	rep(i,N)for(int j=i+1;j<N;j++){
		int x=lower_bound(all(L),L[i]+L[j])-L.begin();
		ans+=max(0ll,x-j-1);
	}
	cout<<ans<<endl;
	return 0;
}

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        long n = in.nextLong();
        int ans = Integer.MAX_VALUE;
        for(int i=1;i<=(int)Math.sqrt(n);i++){
            if(n%i == 0){
                int a = cntDigits(i);
                int b = cntDigits(n/i);
                ans = Math.min(ans,Math.max(a,b));
            }
        }
        out.print(ans);
    }

    private int cntDigits(long a){
        int cnt =0;
        while(a>0){
            cnt++;
            a/=10;
        }
        return cnt;
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 21460
function Main(input) {
    input = input.split(" ")
    var P = parseInt(input[0],10);
    var Q = parseInt(input[1],10);
    var R = parseInt(input[2],10);
    input.sort(
        function(a,b){
          return (a < b ? -1 : 1);
        }
      );
    var a = input.slice(0,1);
    var c = a.join();
    input.shift();
    var b = input.slice(0,1);
    var d = b.join();
    e = parseInt(c,10);
    f = parseInt(d,10);
    console.log(e+f)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(){
  int K,N,r,i; cin>>K>>N;
  int a[N]; for(i=0;i<N;++i){cin>>a[i];}
  r = K-a[N-1]+a[0]; for(i=0;i<N-1;++i){r=max(a[i+1]-a[i],r);}
  cout<<K-r<<"\n"; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;  
vector<int> vis(1000001,0);

int flag;

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

int findGCD(vector<int> arr, int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
} 


void primeFactors(int n)  
{  
     if(n%2==0){
     	if(vis[2]==0){
     		vis[2]=1;
		 	
		 }
		 else{
		 	flag=1;
		 	return;
		 }
	 }
    while (n % 2 == 0)  
    {  
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
   		if(n%i==0){
   			if(vis[i]==0){
   				vis[i]=1;
			   }
			   else{
			   	flag=1;
			   	return;
			   }
		   }
   
        while (n % i == 0)  
        {  
            n = n/i;  
        }  
    }  

    if (n > 2){
    	if(vis[n]==0){
    		vis[n]=1;
		}
		else{
			flag=1;
			return;
		}
	}  
        
}  
void  solve(){
int n;
cin>>n;
vector<int> v(n);
flag=0;
for(int i=0;i<n;i++)
{
	cin>>v[i];
	
}
for(int i=0;i<n;i++){
	if(flag==1){
		break;
	}
	primeFactors(v[i]);	
	
}
if(flag==0){
	cout<<"pairwise coprime";
	return ;
}
if(findGCD(v,v.size())==1){
	cout<<"setwise coprime";
	return ;
}
cout<<"not coprime";
return ;
}

int  main(){

int t;
//cin>>t;
t=1;
while(t--){
	
		solve();
cout<<endl;
}
 
}


Measured memory_bytes: 14880
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const int INF=1e9;

int main(){
  int a,b,m;
  int mina=INF,minb=INF;
  cin >>a>>b>>m;
  vector<int> va(a),vb(b);
  vector<vector<int>> vm(m,vector<int>(3));
  rep(i,a) {
    cin >>va[i];
    mina=min(mina,va[i]);
  }
  rep(i,b){
    cin >>vb[i];
    minb=min(minb,vb[i]);
  }
  int ans=mina+minb;
  rep(i,m){
    int x,y,c;
    cin >>x>>y>>c;
    --x; --y;
    ans=min(ans,va[x]+vb[y]-c);
  }
  cout<<ans<<endl;
  
  return 0;
  
  
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;

long long f(vector<int> &arr, int b) {
    long long ret = 0;
    for (int i = 0; i < arr.size(); ++i) {
        ret += abs(arr[i] - (b + i + 1));
    }
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    int l = -1e9, r = 1e9;
    while (l < r) {
        int m = l + (r - l) / 2;
        if (f(arr, m) >= f(arr, m + 1))
            l = m + 1;
        else
            r = m;
    }

    cout << f(arr, l) << '\n';


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

struct UnionFind {
  vector< int > data;

  UnionFind() = default;

  explicit UnionFind(size_t sz) : data(sz, -1) {}

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return data[k] = find(data[k]);
  }

  int size(int k) {
    return -data[find(k)];
  }

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  UnionFind tree(n);
  vll x(n);
  vll y(n);
  vll xx(n);
  rep(i,n){
    ll cx,cy;
    cin>>cx>>cy;
    xx[i]=cx-1;
    x[cx-1]=cy-1;
    y[cy-1]=cx-1;
  }
  vll y2(n);
  rep(i,n){
    if(i==0) y2[n-1-i]=y[n-1-i];
    else y2[n-1-i]=max(y[n-1-i],y2[n-i]);
  }
  ll start=0;
  ll count=0;
  while(true){
    count++;
    ll s=x[start];
    repi(i,start+1,y2[s]+1){
      tree.unite(start,i);
    }
    if(y2[s]==n-1) break;
    while(x[start]>=s&&start!=y2[s]+1){
      start++;
      if(start==n) break;
    }
  }
  rep(i,n){
    cout<<tree.size(xx[i])<<endl;
  }
}


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

class Program {
    static string ReadLine() { return Console.ReadLine().Trim(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Display(int[] xs) {
        for (int i = 0; i < xs.Length; i++) {
            if (i > 0) Console.Write(' ');
            Console.Write(xs[i]);
        }
        Console.WriteLine();
    }

    static void Main() {
        int n = ReadInt();
        int[] xs = ReadInts();
        if (n != xs.Length) throw new Exception();

        Display(xs);
        for (int i = 1; i < xs.Length; i++) {
            int key = xs[i];
            // insert xs[i] into the sorted sequence xs[0..j-1]
            int j = i - 1;
            while (j >= 0 && xs[j] > key) {
                xs[j+1] = xs[j];
                j--;
            }
            xs[j+1] = key;

            // output
            Display(xs);
        }
    }
}

Measured memory_bytes: 6084
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
using ll = long long;

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int N;
    cin >> N;
    int A[N+1];
    for(int i=1;i<=N;i++) cin >> A[i];

    int sum[N+1];
    for(int i=1;i<=N;i++) sum[i] = 0;

    for(int i=1;i<=N;i++) sum[A[i]]++;

    ll tot=0;
    for(int i=1;i<=N;i++){
        tot += choose2(sum[i]);
    }

    for(int i=1;i<=N;i++){
        ll ans=tot;
        ans -= choose2(sum[A[i]]);
        ans += choose2(sum[A[i]]-1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n;
int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  cin >> n;
  string s;
  map < string , int > cnt;
  for(int i = 0 ; i < n ; ++i){
    cin >> s;
    cnt[s]++;
  }

  cout << "AC x " << cnt["AC"] << "\n";
  cout << "WA x " << cnt["WA"] << "\n";
  cout << "TLE x " << cnt["TLE"] << "\n";
  cout << "RE x " << cnt["RE"] << "\n";


  return 0;
}


Measured memory_bytes: 3524
#include<stdio.h>
int main(void)
{
	int i,a[9],b[9];
	char c[10][15];
	for(i=0;i<9;i++){
		scanf("%s %d %d",c[i],&a[i],&b[i]);
	}
	for(i=0;i<9;i++){
		printf("%s %d %d\n",c[i],a[i]+b[i],(a[i]*200)+(b[i]*300));
	}
	return 0;
}

Measured memory_bytes: 596