akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

ll GCM(ll a,ll b){
  ll r = a%b;
  while(r!=0){
    a = b;
    b = r;
    r = a%b;
  }

  return b;
}

int main(){
  ll n,m; cin >> n >> m;
  string s1,s2; cin >> s1 >> s2;

  ll gcd = GCM(max(n,m),min(n,m)); /*最小公倍数*/
  ll lcm = n*m/gcd;
  ll a = n/gcd,b = m/gcd;

  bool ok = true;
  for(int i=0;i<gcd;i++){
    if(s1.at(a*i)!=s2.at(b*i)) ok = false;
  }

  if(ok) cout << lcm << endl;
  else puts("-1");
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	vector<int> I(3,0);
	rep (i, 3){
		cin >> I[i];
	} // end rep

	int res = 0;
	while(I[0] != I[1] || I[1] != I[2] || I[2] != I[0]){
		sort(ALL(I));
		if (I[0] == I[1] && I[1] < I[2]){
			I[0] += 1, I[1] += 1;
		}else
		if (I[0] + 1 == I[1] && I[1] == I[2]){
			res += 2;
			break;
		}else{
			I[0] += 2;
		} // end if
		++res;
	} // end while

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin>> a.at(i);
  rep(i,n) a.at(i)--;
  int i = 0;
  int k = 0;
  int count =0;
  while(i!=1){
    k = a.at(i);
    i = k;
    count ++;
    if(count == 100010){
      cout << "-1"<<endl;
      return 0;
    }
  }
  cout << count << endl;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    cin >> N;
    if(N % 10 == 9 || N/10 % 10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char a[100][100]={0};
	int H,W;
	cin>>H>>W;
	for(int i=0;i<H;i++){
		for(int k=0;k<W;k++){
			cin>>a[i][k];
		}
	}
	for(int i=0;i<H+2;i++){
		if(i==0){
			int tmp=W+2;
			while(tmp--){
				cout<<"#";
			}
			cout<<endl;
		}
		else if(i==H+1){
			int tmp=W+2;
			while(tmp--){
				cout<<"#";
			}
			cout<<endl;
		}
		else {
			cout<<"#";
			for(int k=0;k<W;k++){
				cout<<a[i-1][k];
			}
			cout<<"#"<<endl;
			
		}

	}
}








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

struct Edge
{
	int from;
	int to;
	ll cost;
};

bool calcShortest(vector<Edge>& list, int s, int t, int maxV, vector<ll>& d)
{
	for (auto i = 0; i < maxV; ++i)
	{
		d.push_back(LLONG_MAX);
	}
	d[s] = 0;

	auto isLoop = false;
	for (auto i = 0; i <= maxV; ++i)
	{
		auto isUpdate = false;
		for (auto e : list)
		{
			if (d[e.from] < LLONG_MAX && d[e.to] > d[e.from] + e.cost)
			{
				d[e.to] = d[e.from] + e.cost;
				isUpdate = true;

				if (e.to == t && i >= maxV)
				{
					isLoop = true;
				}
			}
		}
		if (!isUpdate)
		{
			break;
		}
	}

	return isLoop;
}

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

	vector<Edge> list;
	for (auto i = 0; i < M; ++i)
	{
		int a, b;
		ll c;
		cin >> a >> b >> c;
		--a;
		--b;
		list.push_back({ a, b, -c });
	}

	vector<ll> d;
	if (calcShortest(list, 0, N - 1, N, d) != false)
	{
		cout << "inf" << endl;
	}
	else
	{
		cout << -d[N - 1] << endl;
	}

	return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  vector<ll> C(N);
  REP(i, N){
    cin >> P[i];
    P[i]--;
  }
  REP(i, N){
    cin >> C[i];
  }
  vector<int> modoru(N, -1);
  vector<vector<ll>> value(N, vector<ll>(2*N+1, 0));
  REP(i, N){
    int pos = i;
    REP(j, 2*N){
      pos = P[pos];
      value[i][j+1] = value[i][j] + C[pos];
      if(pos == i && modoru[i] == -1){
        modoru[i] = j+1;
      }
    }
  }

  int roop;
  if(K <= N){
    roop = K;
  }
  else{
    roop = N + K % N;
  }
  ll ans = -INF;
  REP(i, N){
    ll score ;
    if(value[i][modoru[i]] <= 0){
      score = 0;
      roop = min(N, K);
    }
    else{
      int n = modoru[i];
      if(K <= n){
        roop = K;
      }
      else{
        roop = n + K % n;
      }
      score = max(K/n-1, 0) * value[i][n];
    }
    FOR(j, 1, roop+1){
      ans = max(ans, score + value[i][j]);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 394240
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B, C;
	cin >> A >> B >> C;

	for (int i = 1; i <= B; i++)
	{
		if (A * i % B == C)
		{
			cout << "YES";
			return 0;
		}
	}

	cout << "NO";

	return 0;
}

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

using ll = long long;

int n, A[20];

unordered_map<int, ll> mem[20][20];

ll solve(int l, int r, int a, int b) {
    if (r - l == 1) return 1LL * a * A[l] + 1LL * b * A[r];
    int hsh = a * 100000 + b;
    if (mem[l][r].count(hsh)) return mem[l][r][hsh];
    ll ans = 1e18;
    for (int j = l + 1; j < r; ++j) {
        ans = min(solve(l, j, a, a + b) + solve(j, r, a + b, b) - 1LL * A[j] * (a + b), ans);
    }
    // printf("solve(%d, %d, %d, %d) = %lld\n", l, r, a, b, ans);
    mem[l][r][hsh] = ans;
    return ans;
}

int main() {
    // freopen("data.txt", "r", stdin);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", A + i);
    printf("%lld\n", solve(1, n, 1, 1));
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

const ll INF = 5e15;
const ll MOD = 1e9 + 7;

vector<vector<ll>> dp(22, vector<ll>(1 << 21, 0));

int main(){
    ll N;
    cin >> N;
    dp[0][0] = 1;
    vector<vector<ll>> A(N, vector<ll>(N));
    for(auto &v : A) for(auto &e : v) cin >> e;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < (1 << N); j++){
            bitset<21> b(j);
            if(b.count() != i + 1) continue;
            for(ll dig = 0; dig < N; dig++){
                if(!(j & (1 << dig))) continue;
                if(A[i][dig] == 1) (dp[i + 1][j] += dp[i][j ^ (1 << dig)]) %= MOD;
            }
        }
    }
    cout << dp[N][(1 << N) - 1] << endl;
    return 0;
}


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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>

#define ff first
#define ss second

using namespace std;
const ll maxn=1e6+2;
const ll maxx=1e16;
const ll mod=998244353;
const ll mod1=998244353;

vector<ll>  ans[maxn];
pll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
   string s;
    string t;
     cin>>s>>t;
      ll ans=0;
      for (int i=0;i<s.length();i++)
      {
          if (s[i]!=t[i]) ans++;
      }
      cout <<ans;



}


Measured memory_bytes: 27224
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

vector<ll> divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
  ll n;
  cin >> n;
  vector<ll> d = divisor(n);
  ll ans = divisor(n - 1).size() - 1;
  for (ll i: d) {
    if (i == 1) continue;
    ll a = n;
    while(a % i == 0) {
      a /= i;
    }
    if (a % i == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int dp[3010][3010] = {0};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < m; j ++) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      }
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], max(dp[i + 1][j], dp[i][j + 1]));
    }
  }

  string ans = "";
  int i = n, j = m;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      i --;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j --;
    } else {
      ans = s[i - 1] + ans;
      i --, j --;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 110
using namespace std;

ll n, ans = INT_MAX, a[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void init(){
	n = read();
	REP(i, 1, n) a[i] = read();
}

inline void work(){
	init();
	sort(a + 1, a + n + 1);
	REP(i, 1, a[n]){
		ll sum = 0;
		REP(j, 1, n) sum += pow(abs(a[j] - i), 2);
		ans = min(ans, sum);
	}
	printf("%lld\n", ans);
}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a<b){
            for(int i=0;i<b;i++){
                System.out.print(a);
            }
        } else {
            for(int i=0;i<a;i++){
                System.out.print(b);
            }
        }
    }
}


Measured memory_bytes: 35860
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main(void) {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=0;
    rep(i,n){
        int t=v[i];
        v[i]-=t;
        ans+=t;
        for(int j=i+1;j<n;j++){
            if(v[j]<=t){
                t=v[j];
                // ans+=t;
                v[j]=0;
            } else{
                // ans+=t;
                v[j]-=t;
            }
        }
    }
    fin(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4][4],n,b;
bool f[4][4];
int main(){
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin>>a[i][j];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>b;
		for(int j=1;j<=3;j++)
			for(int k=1;k<=3;k++){
				if(b==a[j][k])
					f[j][k]=true;
			}
	}
	if((f[1][1]&&f[1][2]&&f[1][3])||(f[2][1]&&f[2][2]&&f[2][3])||(f[3][1]&&f[3][2]&&f[3][3])||(f[1][1]&&f[2][1]&&f[3][1])||(f[1][2]&&f[2][2]&&f[3][2])||(f[1][3]&&f[2][3]&&f[3][3])||(f[1][1]&&f[2][2]&&f[3][3])||(f[1][3]&&f[2][2]&&f[3][1]))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl; 
	return 0;
} 

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

int main()
{
    int n,i;
    long long ans = 1;
    string s;
    cin >> n >> s;
    vector<long long> al(26,0);
    for(i = 0;i < n;++i){
        ++al.at(s.at(i)-97);
    }
    long long t = 1000000000+7;
    for(i = 0;i < 26;++i){
        ans *= (al.at(i)+1);
        ans %= t;
    }
    cout << ans-1 << endl;
    return 0;
}

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

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

  int c = max(a,b);
  int d = min(a,b);

  prt(max(c-w-d, 0));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <cmath>

using namespace std;

int main()
{

  unsigned long long A,B,M;
  cin>>A>>B>>M;
  vector<unsigned long long> a;
  vector<unsigned long long> b;
  array<unsigned long long,3> c;
  
  unsigned long long min_a=pow(10,5);
  unsigned long long min_b=min_a;
  unsigned long long min_sum = 0;
  
  for(unsigned long long i=0;i<A;++i){
  	unsigned long long x;
    cin>>x;
    if(x<min_a)
      min_a = x;
    a.emplace_back(x);
  }
  cout<<endl;
  
   for(unsigned long long i=0;i<B;++i){
  	unsigned long long x;
    cin>>x;
    if(x<min_b)
      min_b = x;
    b.emplace_back(x);
  }
  cout<<endl;
  
  min_sum = min_a+min_b;
  for(unsigned long long j =0;j<M;++j){
  for(int i=0;i<3;++i){
  	cin>>c[i];
  }
    unsigned long long x = a[c[0]-1] + b[c[1]-1] - c[2];
    if(x<min_sum)
      min_sum = x;
  cout<<endl;
  }
  
 cout<<min_sum<<endl;
}


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

typedef long long ll;

int main(){
	int N,Q;
	string S;
	cin >> N >> Q;
	cin >> S;

	vector<int> C(N);
	rep(i,N-1){ if(S[i]=='A' && S[i+1]=='C'){ C[i+1]=1; } }
	rep(i,N-1){ C[i+1] += C[i]; }

	rep(i,Q){
		int l,r;
		cin >> l >> r;
		l--; r--;
		cout << (C[r] - C[l]) << endl;
	}
}




Measured memory_bytes: 1408
x, y=map(int, input().split())
c1=x<=y
c2=x*y>=0
a=0
if c1 and c2: # 正正か負負でｘ＜Y
  print(y-x)
elif c1 and not c2: # 負正でx<y
  print(abs(y-abs(x))+1)
elif not c1 and c2: # 正正か負負でx>y
  if x*y==0:
    a=1
  else:
    a=2
  print(x-y+a)
elif not c1 and not c2: # 正負でx>y
  print(abs(x-abs(y))+1)


Measured memory_bytes: 8988
#include<stdio.h>
#include <iostream>
#include<string>
#include<vector>

using namespace std;
int main() {
	string str;

	cin >> str;

	for (int i = 0; i < 2; i++) {
		if (str.at(i) != str.at(i + 1)) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

#define MAX 1000005

typedef long long ll;

ll N, A, B;
ll G[MAX];

int main() {
	cin >> N >> A >> B;

	for (int i = 0; i < N; i++) {
		cin >> G[i];
	}

	sort(G, G + N);

	ll left = G[0] / A;
	ll right = G[N - 1] / B + 1;

	//cout << right << endl;
	while (left < right) {
		ll mid = (left + right) / 2;  //mid回で倒す

		//cout << mid << endl;

		ll cost = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (G[i] > B * mid) {	//マイナスいらない
				if ((G[i] - B * mid) % (A - B) == 0) cost += (G[i] - B * mid) / (A - B);
				else cost += (G[i] - B * mid) / (A - B) + 1;
			}
			if (cost > mid) {
				left = mid + 1;
				break;
			}
			else if(i==0) right = mid;
		}
	}

	cout << left << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int N, tmp, len;
    int X, minlen;
    cin >> N >> X;
    vector<int> xs;
    for(int i = 0; i < N; ++i){
        cin >> tmp;
        xs.push_back(abs(tmp - X));
        len = abs(tmp - X);
        if(i == 0){
            minlen = len;
        }else{
            minlen = min(len, minlen);
        }
    }
    

    for(int i = minlen; i > 0; --i){
        for(int j = 0; j < N; j++){
            if(xs[j] % i != 0) break;
            if(j == N-1){
                cout << i << endl;
                return 0;
            }
        }
    }


    return 0;
}



Measured memory_bytes: 892
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll sum=0;
    sum+=a;
    sum*=10;
    sum+=b;
    sum*=10;
    sum+=c;
    if(sum%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3476
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;

            var ans = (n - 1) * (m - 1);
            WriteLine(ans);
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
let () =
  let n = Scanf.scanf "%d" (fun n -> n) in
  let xs = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let xs' = Array.copy xs in
  Array.sort compare xs';
  let m1 = xs'.(n/2 -1) in
  let m2 = xs'.(n/2) in
  for i = 0 to n-1 do
    Printf.printf "%d\n"
      (if xs.(i) <= m1 then m2 else m1)
  done;

Measured memory_bytes: 7808
# coding: utf-8
import math
N,M=map(int,input().split())
A=[]
for i in range(1,int(math.sqrt(M))+1):
    if M%i==0:
        if M//i>=N:
            A.append(i)
            if i>=N and M//i>i:
                A.append(M//i)

A.sort()

ans=A[-1]

print(ans)

Measured memory_bytes: 38640
//F
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int Segtree[600003], ans[200001], arr[200001], N;
vector<int> adjlist[200001];

void update(int p, int L, int R, int idx, int val) {
	if (L == R) {
		Segtree[p] = val;
		return;
	}
	int mid = (L + R) >> 1;
	if (idx <= mid) update(p << 1, L, mid, idx, val);
	else update(p << 1 | 1, mid + 1, R, idx, val);
	Segtree[p] = max(Segtree[p << 1], Segtree[p << 1 | 1]);
}

int query(int p, int L, int R, int qL, int qR) {
	if (L > qR || R < qL) return 0;
	if (L >= qL && R <= qR) return Segtree[p];
	int mid = (L + R) >> 1;
	int q1 = query(p << 1, L, mid, qL, qR);
	int q2 = query(p << 1 | 1, mid + 1, R, qL, qR);
	return max(q1, q2);
}

void dfs(int now, int bef) {
	int x = 0;
	if (arr[now] > 0) x = query(1, 0, N - 1, 0, arr[now] - 1);
	if (bef != -1) ans[now] = ans[bef];
	int maks = x + 1;
	if (x + 1 > ans[now]) ans[now] = x + 1;
	int sblm = query(1, 0, N - 1, arr[now], arr[now]);
	if (sblm < maks) update(1, 0, N - 1, arr[now], maks);
	for (auto i : adjlist[now]) {
		if (i != bef) {
			dfs(i, now);
		}
	} 
	if (sblm < maks) update(1, 0, N - 1, arr[now], sblm);
}

int main() {
	vector<int> v;
	map<int, int> hs;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", & arr[i]);
		v.pb(arr[i]);
	}
	sort (all(v));
	for (int i = 0; i < N; i++) {
		hs[v[i]] = i;
	}
	for (int i = 1; i <= N; i++) {
		arr[i] = hs[arr[i]];
	}
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adjlist[u].pb(v);
		adjlist[v].pb(u);
	}
	dfs(1, -1);
	for (int i = 1; i <= N; i++) {
		printf("%d\n", ans[i]);
	}	
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<double> a(n);
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    cin>> a[i];
    sum += a[i];
  }

  double x = sum / (4. * m);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= x) cnt++;
  }
  if (cnt >= m) puts("Yes");
  else puts("No");
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node* nil;

void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

Node* listSearch(int key)
{
    Node* cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void printList() 
{
    Node* cur = nil->next;
    int isf = 0;
    // while (cur != nil) {
    //     if (isf++) printf(" ");
    //     printf("%d", cur->key);
    //     cur = cur->next;
    // }
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t)
{
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst()
{
    deleteNode(nil->next);
}

void deleteLast()
{
    deleteNode(nil->prev);
}

void deleteKey(int key)
{
    deleteNode(listSearch(key));
}

void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}


int main(int argc, char const *argv[])
{
    int n;
    char com[20];
    int key;
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
        } else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key);
            }
        }
    }

    printList();

    return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  string x;
  
  for (int i = 0; i < H+2; i++) {
    if (i == 0 || i == H+1)
      for (int j= 0; j < W+2; j++)
        cout << '#';
    else {
    for (int j = 0; j < 3; j++) {
      if (j > 0 && j < 2) {
        cin >> x;
        cout << x;
      }
      else if (j == 0)
        cout << '#';
      
      else if (j == 2)
        cout << '#';
    }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int mint=60*(h2-h1)-m1+m2;
  int ans=mint-k;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n; unsigned long long t[100], t_max = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%llu", &t[i]);
    if(t_max < t[i]) t_max = t[i];
  }

  unsigned long long ans = t_max;
  unsigned long long k;
  for(int i = 0; i < n; i++){
    k = 1;
    while((k * ans) % t[i] != 0) k++;
    ans *= k;
  }
  printf("%llu\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int MAX_N = 100100;
const int D = 13;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while (e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

int main() {
    string s;
    cin >> s;
    int n = s.length();
    ModInt<MOD> dp[MAX_N][D];
    dp[0][0] = 1;
    
    for (int i = 0; i < n; i++) {
        const int c = (s[i] == '?' ? -1 : s[i] - '0');
        for (int k = 0; k < 10; k++) {
            if (c != -1 && c != k) continue;
            for (int d = 0; d < D; d++) {
                dp[i+1][(k+10*d)%D] += dp[i][d];
            }
        }
    }
    
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int nmax=8;
bool graph[nmax][nmax];
 
int dfs(int v,int N,bool visited[nmax]){
	
	bool all_visited=true;
	
	for(int i=0;i<N;++i){
		if(visited[i]==false)
			all_visited=false;
	}
 
	if(all_visited){
		return 1;
	}
 
	int ret=0;
	
	for(int i=0;i<N;++i){
		if(graph[v][i]==false) continue; 
		if(visited[i]) continue;
 
		visited[i]=true;
		ret+=dfs(i,N,visited);
		visited[i]=false;
	}
 
	return ret;
}
 
int main(void){
	int N,M;
	cin >> N >> M;
 
	for(int i=0;i<M;++i){
		int A,B;
		cin >> A >> B;
		graph[A-1][B-1]=graph[B-1][A-1]=true;
	}
 
	bool visited[nmax];
	for(int i=0;i<N;++i){
		visited[i]=false;
	}
 
	visited[0]=true;
	cout << dfs(0,N,visited) << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++)
    cin >> s.at(i);
  sort(s.begin(), s.end());
  
  int m = 0;
  int count = 0;
  string now = s.at(0);
  for(int i=0; i<n; i++) {
    if(now == s.at(i)) {
      count++;
    }
    else {
      if(count > m) {
        m = count;
      }
      now = s.at(i);
      count = 1;
    }
    if(i == n-1) {
      if(count > m) {
        m = count;
      }
      now = s.at(0);
      count = 0;
    }
  }
  for(int i=0; i<n; i++) {
    if(now == s.at(i)) {
      count++;
    }
    else {
      if(m == count) {
        cout << s.at(i-1) << endl;
      }
      count = 1;
      now = s.at(i);
    }
    if(i == n-1) {
      if(m == count) {
        cout << s.at(n-1) << endl;
      }
    }
  }
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s;cin>>s;
    if(s[6] <= '4'&&s[5] != '1') cout<<"Heisei";
    else cout<<"TBD";
  	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
#define all(c) c.begin(), c.end()
#define sec second
#define fst first
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
int main()
{
	
	
	FAST
	ll n;cin>>n;
	ll a[n],b[n],c[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	ll dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(ll i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	ll ans=max(dp[n-1][0],dp[n-1][1]);
	ans=max(ans,dp[n-1][2]);
	cout<<ans;
}	

Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
	int h1,h2,k1,k2,a,b,c,d,x,y;
	scanf("%d %d",&h1,&h2);
	scanf("%d %d",&k1,&k2);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=h1*a+h2*b;
	y=k1*a+k2*b;
	if(h1>=10||k1>=10){
		x=x+h1/10*c;
		y=y+k1/10*c;
	}
	if(h2>=20||k2>=20){
		x=x+h2/20*d;
		y=y+k2/20*d;
	}
	if(x>y){
		printf("hiroshi\n");
	}
	else if(y>x){
		printf("kenjiro\n");
	}
	else {
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2104
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		int city[][] = new int[m + 1][4]; // id, pref, year, number in pref

		// 県、年でソート
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				if ( o1[1] != o2[1] ) {
					return o1[1] - o2[1];	// １．prefでソート
				} else {
					return o1[2] - o2[2];	// ２．yearでソート
				}
			}
		});

//		for ( int[] is : city ) {
//			for ( int i : is ) {
//				System.out.print(i + " ");
//			}
//			System.out.println();
//		}

		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		int pref = 0;
		int num = 0;
		for ( int i = 1; i <= m; i++ ) {
			int p = city[i][1];
			if ( pref != p ) {
				pref = p;
				num = 1;
			} else {
				num++;
			}
			result[city[i][0] -1] = df.format(pref) + df.format(num);
		}
		
		PrintWriter pw = new PrintWriter(System.out);
		for ( String s : result ) {
			
			pw.println(s);
		}
		pw.flush();
		in.close();
	}
}

Measured memory_bytes: 98844
#include"bits/stdc++.h"
using namespace std;

map<int, int> factorize(int n) {
  map<int, int> result;
  for (int i = 2; i * i <= n; i++) {
    if (n % i) {
      continue;
    }
    while (n % i == 0) {
      n /= i;
      result[i]++;
    }
  }
  if (n != 1) {
    result[n]++;
  }

  return result;
}

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

void Main() {
  int N;
  cin >> N;

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


  map<int, int> result;
  for (int j = 0; j < N; j++) {
    auto tmp = factorize(A[j]);
    for (auto i: tmp) {
      result[i.first]++;
    }
  }

  bool pairwise = true;
  for (auto r: result) {
    if (r.second > 1) {
      pairwise = false;
      break;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return;
  }
  int r = A[0];
  for (int i = 1; i < N; i++) {
    r = gcd(r, A[i]);
  }
  if (r == 1) {
    cout << "setwise coprime" << endl;
    return;
  }
    cout << "not coprime" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

int main()
{
	int N;
	cin >> N;
	vector<ll> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	ll sum = accumulate(d.begin(), d.end(), 0LL);
	sum *= sum;
	for (int i = 0; i < N; i++) {
		sum -= d[i] * d[i];
	}
	cout << sum / 2 << endl;
	return 0;
}


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

const int maxn=1004,maxh=1e4+7;
int h,n,a[maxn],b[maxn];
long long f[maxh];

int main()
{
	scanf("%d %d",&h,&n);
	for(int i=1;i<=n;++i) {
		scanf("%d %d",&a[i],&b[i]);
	}
	memset(f,63,sizeof f);
	f[0]=0;
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=h;++j) {
			if(j<a[i]) f[j]=min(f[j],1ll*b[i]);
			else f[j]=min(f[j],f[j-a[i]]+b[i]);
		}
	}
	printf("%lld",f[h]);
}

Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
#define INF2 1140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


void solve()
{
    int x, y, a, b, c;
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    vector<int> p(a), q(b), r(c), v;
    ll sum = 0;
    int i;
    for (i = 0; i < a; i++) {
        scanf("%d", &p[i]);
    }
    sort(p.rbegin(), p.rend());
    for (i = 0; i < x; i++) {
        sum += p[i];
        v.push_back(p[i]);
    }
    for (i = 0; i < b; i++) {
        scanf("%d", &q[i]);
    }
    sort(q.rbegin(), q.rend());
    for (i = 0; i < y; i++) {
        sum += q[i];
        v.push_back(q[i]);
    }
    sort(v.begin(), v.end());
    for (i = 0; i < c; i++) {
        scanf("%d", &r[i]);
    }
    sort(r.rbegin(), r.rend());

    ll ans = sum;
    int num = MIN(c, x+y);
    for (i = 0; i < num; i++) {
        sum += r[i] - v[i];
        ans = MAX(ans, sum);
    }
    printf("%lld\n", ans);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if ( (i > 0 && i < 10)
            || (i >= 100 && i < 1000)
            || (i >= 10000 && i < 100000)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
B = [list(map(int,input().split())) for i in range(H)]
C = [[abs(a-b) for a,b in zip(arow,brow)] for arow,brow in zip(A,B)]

ofs = 80*(H+W)
dp = [[0]*W for _ in range(H)]
dp[0][0] = (1<<(ofs+C[0][0])) | (1<<(ofs-C[0][0]))
for i,crow in enumerate(C):
    for j,c in enumerate(crow):
        if i:
            dp[i][j] = (dp[i-1][j]<<c) | (dp[i-1][j]>>c)
        if j:
            dp[i][j] |= ((dp[i][j-1]<<c) | (dp[i][j-1]>>c))

ans = ofs*2
for i in range(ofs*2):
    if dp[-1][-1]&(1<<i):
        ans = min(ans, abs(i-ofs))
print(ans)

Measured memory_bytes: 19700
import java.util.ArrayList;
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		
		ArrayList<String> candidate = new ArrayList<>();
		candidate.add("1");
		candidate.add("2");
		candidate.add("3");
		
		candidate.remove(a);
		candidate.remove(b);
		
		System.out.println(candidate.get(0));
		sc.close();

	}
}
	

Measured memory_bytes: 35644
#include<stdio.h>

int main(){

  int A[100];
  int i,j,N,k;
  int change=0;
  int mini;

  scanf("%d",&N);
  for(i=0; i<N; i++)scanf("%d",&A[i]);

  for(i=0; i<N; i++){
      mini=i;
      for(j=i; j<N; j++){
          if(A[j]<A[mini])mini=j;
        }

      if(mini!=i){
          k=A[i];
          A[i]=A[mini];
          A[mini]=k;
          change++;
        }
    }

  for(i=0;i<N-1;i++)printf("%d ",A[i]);
  
  printf("%d\n",A[i]);
  printf("%d\n",change);
  
  return 0;
}

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
bool comp(const II& a, const II& b){
	return a.S < b.S;
}
int main(){
	IO();
	LL n;
	cin>>n;
	VII arr(n);
	rep(i,0,n){
		cin>>arr[i].F>>arr[i].S;
	}
	int ok = 1;
	sort(ALL(arr), comp);
	LL cur = 0;
	rep(i,0,n){
		if(cur + arr[i].F > arr[i].S){
			ok = 0;
			break;
		}
		cur += arr[i].F;
	}
	if(ok)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define ll long long
#define MAX 2005
using namespace std;

int cnt, n;
int head[MAX], Next[MAX*2], vet[MAX*2];
ll ans[MAX];

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

bool vis[MAX];
int dis[MAX];
void bfs(int s){
    memset(vis, 0, sizeof(vis));
    queue<int> q;
    dis[s] = 0, vis[s] = 1;
    q.push(s);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i = head[x]; i; i = Next[i]){
            int v = vet[i];
            if(vis[v]) continue;
            vis[v] = 1;
            dis[v] = dis[x]+1;
            q.push(v);
        }
    }
    for(int i = s+1; i <= n; i++){
        ans[dis[i]]++;
    }
}

int s, e;

int main()
{
    cin >> n >> s >> e;
    for(int i = 1; i < n; i++){
        add(i, i+1);
        add(i+1, i);
    }
    add(s, e);
    add(e, s);
    for(int i = 1; i <= n; i++){
        bfs(i);
    }
    for(int i = 1; i < n; i++){
        printf("%lld\n", ans[i]);
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    vector<ll> f(n);
    for (int i = 0; i < n; i++)cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<>());

    ll ok = 1145141919810364364;
    ll ng = -1;
    while (abs(ok - ng) > 1) {
        ll mid = ok + (ng - ok) / 2;

        ll count = 0;
        for (int i = 0; i < n; i++) count += max(0LL, a[i] - mid / f[i]);

        if (k >= count)ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;

  vector<int> L(K, -1), R(K, -1);
  for (int i = 0, c = 0; i < N && c < K;) {
    if (S[i] == 'o') {
      L[c++] = i;
      i += C;
    }
    ++i;
  }
  for (int i = N - 1, c = 0; i >= 0 && c < K;) {
    if (S[i] == 'o') {
      R[c++] = i;
      i -= C;
    }
    --i;
  }

  for (int i = 0; i < (int)(K); ++i) {
    if (L[i] == R[K - 1 - i]) cout << L[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int m,n,s,i,j,m2,cnt,a[1000];
int main()
{
    cin>>n>>m;
    s=0;
    for(i=0; i<n; i++)
        cin>>a[i],s+=a[i];
    sort(a,a+n);
    for(i=0; i<n; i++)
        if(a[i]>=s/(4.0*m))
            cnt++;
    if(cnt>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256