akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const ll MOD=998244353;
const int MAX_N=2e3,MAX_K=2e3;
int K,N;
ll fac[MAX_N+MAX_K],ifac[MAX_N+MAX_K];
ll mpw(int n,int m){
	ll ret=1;
	ll n2=n;
	while(m){
		if (m&1){
			ret*=n2;
			ret%=MOD;
		}
		n2*=n2;
		n2%=MOD;
		m>>=1;
	}
	return ret;
}
ll minv(ll x){
	return mpw((int)x,(int)MOD-2);
}
ll com(int n,int m){
	return fac[n]*ifac[m]%MOD*ifac[n-m]%MOD;
}
int main(){
	cin>>K>>N;
	fac[0]=1;
	REP(i,N+K-1){
		fac[i+1]=fac[i]*(i+1)%MOD;
	}
	ifac[N+K-1]=minv(fac[N+K-1]);
	for(int i=N+K-2;i>=0;i--){
		ifac[i]=ifac[i+1]*(i+1)%MOD;
	}
	FOR(i,2,K*2+1){
		ll ans=0;
		int cen=i/2,w;
		if(i&1){
			w=min(cen,K-cen);
		}else{
			w=min(cen-1,K-cen);
		}
		REP(j,w+1){
			int u,v;
			v=N-j;
			if (v<0) continue;
			if (i&1){
				u=K-w*2+j;
				if (u==0){
					continue;
				}
				ans+=com(v+u-1,v)*com(w,j)%MOD*mpw(2,j)%MOD;
				ans%=MOD;
			}else{
				u=K-w*2-1+j;
				if (u==0) continue;
				ans+=com(v+u-1,v)*com(w,j)%MOD*mpw(2,j)%MOD;
				ans%=MOD;
				v--;
				if (v<0)continue;
				ans+=com(v+u-1,v)*com(w,j)%MOD*mpw(2,j)%MOD;
				ans%=MOD;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int digitsum(int n){
	int d=0;
	while(n>0){
		int a=n%10;
		n=n/10;
		d+=a;
	}
	return d;

}

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

	int sum=0;
	for(int i=0;i<=n;i++){
		if(digitsum(i)>=a&&digitsum(i)<=b)sum+=i;
	}
	cout<<sum;
	return 0;
}

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

int main(){
	// sengen
	int h,w,k;
	// nyuryoku
	cin >> h >> w >> k;
	char c[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> c[i][j];
		}
	}
	// keisan
	int ans = 0;
	for(int bith=0;bith < (1<<h);bith++){
		for(int bitw=0;bitw < (1<<w);bitw++){
			char d[h][w];
			int count = 0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					d[i][j] = 'a';
				}
			}
			for(int i=0;i<h;i++){
				if(bith & (1<<i)){
					for(int j=0;j<w;j++){
						d[i][j] = 'r';
					}
				}
			}
			for(int j=0;j<w;j++){
				if(bitw & (1<<j)){
					for(int i=0;i<h;i++){
						d[i][j] = 'r';
					}
				}
			}
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(d[i][j] == 'a' && c[i][j] == '#'){
						count++;
					}
				}
			}
			if(count == k){
				ans++;
			}
		}
	}
	// syutsuryoku
	cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  ll N;
  ll K;
  cin >> N >> K;
  vector<pair<int,int>> A(N);
  vector<int> cnt(200005, 0);
  vector<vector<int>> id(200005);

  rep(i, N) {
    int x; cin >> x;
    A[i].first = x;
    cnt[x]++;
    A[i].second = cnt[x];
    id[x].push_back(i);
  }

  ll T = 0LL;
  int k = 0;
  vector<int> sub;
  while (true) {
    int x = A[k].first;

    if (A[k].second == cnt[x]) {
      sub.push_back(k);
      T += (ll)(N + id[x][0] - k + 1);
      k = id[x][0] + 1;
    } else {
      T += (ll)(id[x][A[k].second] - id[x][A[k].second-1] + 1);
      k = id[x][A[k].second] + 1;
    }

    if (k == N) break;
  }
  sub.push_back(N-1);

  
  ll t = T / N;
  int mod = K % t;

  if (mod == 0) {
    cout << "" << endl;
  } else {

    int k = sub[mod-1];
    while (true) {
      int x = A[k].first;
      if (A[k].second == cnt[x]) {
        cout << x << " ";
        k++;
      } else {
        k = id[x][A[k].second]+1;
      }

      if (k == N) break;
    }

    cout << endl;
  }
    

  return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A == 1)
        A = 14;
    if (B == 1)
        B = 14;
    if (A > B) {
        cout << "Alice" << endl;
    } else if (A < B) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

string s;
int cnt, a, c;


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> s;


if(s[0]=='A')a++;
int k = s.size()-1;

rep(i, 2, k-1){
if(s[i]=='C')c++;
}

rep(i, 0, k){
if(s[i]>95)cnt++;
}

if(a==1 && c==1 && a+c+cnt==k+1){
    cout << "AC" << endl;
}
else {
    cout << "WA" << endl;
}



return 0;}
///....


Measured memory_bytes: 256
n=input()


if n[-1]=="2" or n[-1]=="4" or n[-1]=="5" or n[-1]=="7" or n[-1]=="9":
  print("hon")
elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8":
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9120
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
using namespace std;
struct node{
	int l,r;
}x[110000];
bool cmp(node p,node q)
{
	if (p.l!=q.l)
	return p.l<q.l;
	else return p.r<q.r;
}
int main()
{
    int n,m,a,b;
    scanf("%d%d\n",&n,&m);
    for (int i=1;i<=m;i++)
    {
    	scanf("%d%d\n",&x[i].l,&x[i].r);
    }
    sort(x+1,x+1+m,cmp);
    int ans=0,p=0,q=x[1].r;
    for (int i=2;i<=m;i++)
    {
    	if (x[i].l>=q)
    	{
    		ans=ans+1;
    		q=x[i].r;
    	}
    	else
    	{
    		q=min(q,x[i].r);
    	}
    }
    ans=ans+1;
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
/*https://atcoder.jp/contests/abc171/tasks/abc171_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a,sum=0;
	vector <int> v;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}	
	sort(v.begin(),v.end());
	for(int i=0;i<k;i++)
		sum+=v[i];
	cout<<sum;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;
int cnt[100100];

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

  std::cin >> S;

  N = S.size();

  for(int i=0,j=1;i<N;){
      while(j < N && S[j] == S[i]){
          j += 1;
      }

      while(i < j){
          if((j - i) % 2 == 0){
              cnt[j] += 1;
          }else{
              cnt[j-1] += 1;
          }
          i += 1;
      }

      while(j < N && S[j] == S[i]){
          j += 1;
      }

      for(int k=i;k<j;++k){
          if((k - i) % 2 == 0){
              cnt[i] += 1;
          }else{
              cnt[i-1] += 1;
          }
      }

      i = j;
  }

  for(int i=0;i<N;++i){
      std::cout << cnt[i] << " \n"[i + 1 == N];
  }
}


Measured memory_bytes: 1104
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

int main(){

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

    int ans = 0;

    if (B >= C){
        ans = B + C;
    }else{
        if ((A + B) >= C){
            ans = B + C;
        }else{
            ans = B + C - (C - (A + B)) + 1;
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
	int n, m; 
	cin >> n >> m;
	vector<int> v(m);
	for(int i = 0; i < m; ++i)
		cin >> v[i];
	bool found = false;
	while(!found){
		int tempN = n;
		bool notTheOne = false;
		while(tempN != 0 && !notTheOne){
			for(int i : v){
				if(tempN%10 == i){
					notTheOne = true;
					break;
				}
			}
			tempN /= 10;
		}
		if(notTheOne){
			++n;
			continue;
		}
		found = true;
	}
	cout << n;
		


	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    long k;
    cin >> k;
    long q = k / 50, r = k % 50;
    cout << 50 << '\n';
    for (long i=0; i<50; i++) 
        cout << q + i - r + (i < r ? 51 : 0) << (i < 49 ? ' ' : '\n');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n;
  cin>>n;
  string s;
  while(n>0){
    if(n%26==0){
      s+='z';
      n=(n-26)/26;
    }
    else{
      s+=char('a'+n%26-1);
      n/=26;
    }
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}

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

const int N = 1100;

int a[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	int cnt = 0;
	for (int i = 1; i <= n; i++) if (a[i] >= 0) cnt++;
	if (!cnt) {
		int ind = 0;
		a[ind] = -1e9 - 7;
		for (int i = 1; i <= n; i++) if (a[ind] < a[i]) ind = i;
		cout << a[ind] << "\n";
		cout << n - 1 << "\n";
		for (int i = n; i > ind; i--) cout << i << "\n";
		for (int i = 1; i < ind; i++) cout << "1\n";
		return 0;
	} else {
		long long tot1 = 0, tot2 = 0;
		for (int i = 1; i <= n; i += 2) if (a[i] > 0) tot1 += a[i];
		for (int i = 2; i <= n; i += 2) if (a[i] > 0) tot2 += a[i];
		cout << max(tot1, tot2) << "\n";
		vector<int> rlt;
		int en = n;
		if (tot1 >= tot2) {
			if (n & 1) en = n;
			else en = n - 1;
		} else {
			if (n & 1) en = n - 1;
			else en = n;
		}
		a[0] = a[n + 1] = a[n + 2] = 0;
		for (int i = en; i >= 1; i -= 2) {
			if (a[i] < 0) {
				rlt.push_back(i);
			} else {
				if (i + 1 <= n) rlt.push_back(i + 1);
			}
		}
		if (tot1 >= tot2) {
			if (a[1] < 0) rlt.push_back(1);
		} else rlt.push_back(1);
		cout << rlt.size() << "\n";
		for (auto it : rlt) cout << it << "\n";
	}
	
	return 0;
}


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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int cnt[26] = {0};

string s;
int main(){
  cin >> s;
  REP(i,s.size()){
    cnt[s[i]-'a']++;
  }
  REP(i,26){
    if(cnt[i]%2==1){
      cout << "No" <<endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
}


Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    # 各頂点の次数
    deg = [0 for _ in range(n)]
    # グラフ
    edge = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        deg[b - 1] += 1

    que = deque([])
    for i in range(n):
        if deg[i] == 0:
            que.append(i)

    dp = [0 for _ in range(n)]
    while que:
        v = que.popleft()
        for nv in edge[v]:
            deg[nv] -= 1
            if deg[nv] == 0:
                que.append(nv)
                dp[nv] = max(dp[nv], dp[v] + 1)

    res = 0
    for j in range(n):
        res = max(res, dp[j])
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 23088
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdbool.h>
#include<set>
#define N 1000000007
using namespace std;
typedef long long ll;
int num[100001];
int main(void) {
	int n, m;
	cin >> n >> m;
	int x = 1900 * m + 100 * (n - m);//一回における実行時間
	double p = (double)1 / pow(2, m);//成功する確率
	cout << x/p << endl;
	return 0;
}

Measured memory_bytes: 384
#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;
    string s,A={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    cin>>n>>s;
    rep(i,s.size()) cout<<A[(s[i]-'A'+n)%26];
}

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

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> static _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _Ty> static _Ty tp_min(_Ty a, _Ty b) {
	return a < b ? a : b;
}
template <class _Ty> static _Ty tp_max(_Ty a, _Ty b) {
	return a > b ? a : b;
}
template<class T> static void get1int(T& a) {
	const char* fmt = " %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class T> static void get2int(T& a, T& b) {
	const char* fmt = " %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class T> static void get3int(T& a, T& b, T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static const int EduDp_INF = 1100000000;
static const int MOD_NUM = 1000000007;
static void H_Grid1();

#if 1
int main()
{
	H_Grid1();
	fflush(stdout);
	return 0;
}
#endif

static void H_Grid1()
{
	const int HMAX = 1000;
	int H, W;
	get2int(H, W);

	auto grid = new char[H][HMAX];
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			scanf(" %c", &grid[h][w]);
		}
	}
	auto dp = new LLONG[H + 1][HMAX + 1];
	memset(dp, 0, sizeof(dp[0][0]) * (H + 1) * (HMAX + 1));
	dp[0][0] = 1;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (grid[h][w] != '#') {
				//	上が壁じゃない
				if (((h - 1) >= 0) && (grid[h - 1][w] != '#')) {
					dp[h][w] += dp[h - 1][w];
					dp[h][w] %= MOD_NUM;
				}
				//	左が壁じゃない
				if (((w - 1) >= 0) && (grid[h][w - 1] != '#')) {
					dp[h][w] += dp[h][w - 1];
					dp[h][w] %= MOD_NUM;
				}
			}
		}
	}
	printf("%lld\n", dp[H - 1][W - 1]);

	delete[] dp;
	delete[] grid;
}


Measured memory_bytes: 9088
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Scanner;

class Robot {
	final int pos;
	final int length;

	Robot(int pos, int length) {
		this.pos = pos;
		this.length = length;
	}

	int max() {
		return pos + length;
	}

	int min() {
		return pos - length;
	}
}

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		Robot[] robots = new Robot[N];
		for (int i = 0; i < N; i++) {
			robots[i] = new Robot(sc.nextInt(), sc.nextInt());
		}

		Arrays.sort(robots, Comparator.comparingInt(Robot::max));
		BitSet remove = new BitSet(N);
		for (int i = 0; i < robots.length; i++) {
			int p = remove.previousClearBit(i - 1);
			if (p < 0) continue;
			Robot prev = robots[p];
			Robot target = robots[i];

			if (prev.max() <= target.min()) continue;
			remove.set(i);
		}
		System.out.println(N - remove.cardinality());
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 94160
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        Console.WriteLine(check(s,t) ? "Yes":"No");
    }
    public static bool check (string s, string t)
    {
        var sL = s.Length;
        for (int i = 0; i < sL; i++)
        {
            var ns = s[sL - 1] + s.Substring(0, sL - 1);
            if (ns == t) return true;
            s = ns;
        }
        return false;
    }
}


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

using namespace std;

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    bool sol = false;
    for(int i = a; i <= b; i++){
        if(i % k == 0)
            sol = true;
    }
    cout << (sol ? "OK": "NG") << '\n';
}

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

using namespace std;

#define int64 long long 
const int mod = (int) 1e9 + 7;

const int nax = 1e6 + 5;

vector<int> prime(nax, -1);

void sieve(){
	for(int i=2; i<nax; i++){
		if(prime[i] == -1){
			for(int j=i; j<nax; j+=i)prime[j] = i;
		}
	}
}

int main(){
	sieve();
	int n; 
	cin>>n;
	vector<int> arr(n);
	vector<int> freq(nax);
	for(int i=0; i<n; i++){
		cin>>arr[i];
		int x = arr[i];
		while(x > 1){
			int p = prime[x];
			freq[p] ++;
			while(x%p == 0)x = x/p;
		}
	}
	bool ok = 1;
	for(int i=2; i<nax; i++){
		if(freq[i] > 1)ok=0;
	}
	if(ok){
		cout<<"pairwise coprime";
		return 0;
	}
	int gcd = arr[0];
	for(int i=1; i<n; i++){
		gcd = __gcd(gcd, arr[i]);
	}
	if(gcd == 1){
		cout<<"setwise coprime";
		return 0;
	}
	cout<<"not coprime";
}


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

int main() {
  string s;
  string ans = "Yes";
  cin >> s;
  int n = s.size();
  int a,b,c,d,x,q,w;
    
    if(n%2 == 1){
      for(int m = 0;m<n/2;m++){
        q = s.at(m);
        w = s.at(n-1-m);
        if(q != w){
          ans = "No";
          break;}}
        for(int i = 0;i<(n-1)/4;i++){
        a = s.at(i);
        b = s.at(((n-2)/2)-i);
        if(a != b){
          ans ="No";
          break;}
      }
      for(int k = 0; k<(n+3)/4;k++){
        c = s.at(((n+2)/2)+k);
        d = s.at(n-1-k);
        if(c != d){
          ans ="No";
          break;}
      }}
      else ans = "No";
      cout << ans << endl;
      return 0;
    }

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,m;cin>>n>>m;
	string S,T;cin>>S>>T;
	llint i,x=gcd(n,m);
	for(i=0;i<x;i++){
		if(S[n*i/x]!=T[m*i/x]){cout<<-1<<endl;return 0;}
	}
	cout<<n*m/x<<endl;
	return 0;
}


Measured memory_bytes: 764
def main(N, K, A):
    for i in range(K, N): # 0 から数えるから K-1
        this = A[i]
        before = A[i-K]

        if this > before:
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Measured memory_bytes: 31616
/*
 * test.cpp
 *
 *  Created on: 2018/01/10
 *      Author: joi
 */




#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
	int n;
	cin >> n;
	int f[101][10];
	REP(i, n){
		REP(j, 10){
			cin >> f[i][j];
		}
	}
	int p[101][11];
	REP(i, n){
		REP(j, 11){
			cin >> p[i][j];
		}
	}
	int ans = -1 * 1 << 31;
	for(int t = 1; t < 1 << 10; t++){
		bitset<10> bs = t;
		int sum = 0;
		REP(i, n){
			int cnt = 0;
			REP(j, 10){
				if(bs[j] && f[i][j]) cnt++;
			}
			sum += p[i][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
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>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

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

void solve() {
  VAR(int, X);
  while (!is_prime(X)) ++X;
  print(X);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
int main() {
	int L, R;
	scanf("%d %d", &L, &R);
	if (R - L > 2019) {
		printf("0");
	}
	else {
		int min = 2019;
		for (int i = L; i < R; i++) {
			for (int j = L + 1; j <= R; j++) {
				if (min > ((i % 2019)*(j % 2019)) % 2019) {
					min = ((i % 2019)*(j % 2019)) % 2019;
				}
			}
		}
		printf("%d", min);
	}
	return 0;
}

Measured memory_bytes: 128
import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

if 0 in list_input:
    print(0)
    exit()

a = 1
for i in list_input:
    a *= i
    if a > pow(10, 18):
        break


if a > pow(10, 18):
    print(-1)
else:
    print(a)

Measured memory_bytes: 84496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int A, B;
    cin >> A >> B;
    for(int i=1; i<(B+1)*10; i++) {
        int a = floor(i * 0.08);
        int b = floor(i * 0.10);
        if(a == A && b == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

vector <ll>a;
vector <ll>pl,mi;
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll ans=0;
	ans=a[n-1]-a[0];
	for(ll i=1;i<n-1;i++){
		ans+=abs(a[i]);
	}
	cout <<ans<<endl;
	for(ll i=1;i<n-1;i++){
		if(a[i]>0){
			pl.push_back(a[i]);
		}
		else{
			mi.push_back(a[i]);
		}
	}
	ll sum=a[0];
	while(pl.size()!=0){
		cout << sum <<" ";
		ll now=pl.back();
		pl.pop_back();
		cout << now<<endl;
		sum-=now;
	}
	cout << a[n-1] <<" "<< sum<<endl;
	sum=a[n-1]-sum;
	while(mi.size()!=0){
		ll now=mi.back();
		mi.pop_back();
		cout << sum << " " << now<<endl;
		sum-=now;
	}
	//cout << sum;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int n;
int main(){
  cin >> n;
  int x[n];
  int maxX=0;
  rep(i,n){
    cin >> x[i];
    if(maxX<x[i]){
      maxX=x[i];
    }
  }
  int min=100000000;
  for(int i=0;i<=maxX;i++){
    int ans = 0;
    rep(j,n){
      ans = ans + pow(x[j]-i,2);
    }
    if(ans<min){
      min = ans;
    }
  }
  cout << min <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef  long long ll;
 
int main() {
	int ar[100] = {};
	ll d = 0, n = 0;
	std::cin >> d >> n;
	for (int i = 0; i < 100; i++) {
		ar[i] = i + 1;
	}
	if (d == 0) {
		std::cout << n + n/100 << std::endl;
	}
	else if (d == 1) {
		std::cout << (n+n/100)*100 << std::endl;
	}
	else {
		std::cout << (n+n/100)*100*100 << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

ll dp[1<<16];
ll INF=LLONG_MAX/2;
ll sum[20][1<<16];

int main(){
  int N; cin>>N;
  int A[N][N]; rep(i,N) rep(j,N) cin>>A[i][j];
  
  rep(bit,1<<N){
    rep(i,N) if((1<<i)&bit){
      ll s=0;
      rep(j,N) if((1<<j)&bit){
        s+=A[i][j];
      }
      sum[i][bit]=s;
    }
  }
  
  rep(bit,1<<N) dp[bit]=-INF;
  dp[0]=0;
  rep(bit,1<<N){
    rep(i,N) if(((1<<i)&bit)==0){
      ll s=A[i][i];
      rep(j,N) if((1<<j)&bit){
        s+=A[i][j];
      }
      dp[bit^(1<<i)]=max(dp[bit^(1<<i)],dp[bit]+s);
    }
  }
  
  for(int S=0;S<(1<<N);S++) if(dp[S]!=-INF){
    for(int T=S;T>0;T=(T-1)&S){
      int SS=S^T;
      for(int i=0;i<N;i++){
        if(((1<<i)&T)==1){
          dp[S]=max(dp[S],dp[SS]+dp[T]-sum[i][SS]);
        }
      }
    }
  }
  
  cout<<dp[(1<<N)-1]<<endl;
  return 0;
}


Measured memory_bytes: 11008
#include <cstdio>
int main() {
	int n,A,B,a,b;
	while(scanf("%d",&n),n) {
		A=B=0;
		for(int i=0;i<n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b)A+=a+b;
			else if(a<b)B+=a+b;
			else A+=a,B+=b;
		}
		printf("%d %d\n",A,B);
	}
}

Measured memory_bytes: 1028
#include <iostream>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(s,e) for(long int i=s;i<e;i++)
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int n,m;cin>>n>>m;
    long long int sum=0;
    if(n>=2) sum+=n*(n-1)/2;
    if(m>=2) sum+=m*(m-1)/2;
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1000
int main(){
    string s; int h;
    cin>>h;rep(i,h){
        cin>>s;
        sort(all(s),greater<char>());int n=stoi(s);
        sort(all(s));int n2=stoi(s);
        cout<<n-n2<<endl;
    }
}

Measured memory_bytes: 3080
#include<stdio.h>
int main(){
int i,b,ans=0,d[101],k=0;
char a[101];
while(scanf("%c",&a[0])!=EOF){
if(a[0]=='I'){
d[0]=1;
}
else if(a[0]=='V'){
d[0]=5;
}
else if(a[0]=='X'){
d[0]=10;
}
else if(a[0]=='L'){
d[0]=50;
}
else if(a[0]=='C'){
d[0]=100;
}
else if(a[0]=='D'){
d[0]=500;
}
else if(a[0]=='M'){
d[0]=1000;
}
for(i=1;;i++){
scanf("%c",&a[i]);
if(a[i]=='I'){
d[i]=1;
}
else if(a[i]=='V'){
d[i]=5;
}
else if(a[i]=='X'){
d[i]=10;
}
else if(a[i]=='L'){
d[i]=50;
}
else if(a[i]=='C'){
d[i]=100;
}
else if(a[i]=='D'){
d[i]=500;
}
else if(a[i]=='M'){
d[i]=1000;
}
else{
b=i;
break;
}
}
scanf("\n");
for(i=b-1;i>0;){
if(d[i-1]<d[i]){
ans=ans+(d[i]-d[i-1]);
i=i-2;
if(i==0){
k++;
}
}
else{
ans=ans+d[i];
if(i==1){
k++;
}
i--;
}
}
if(k==1){
ans=ans+d[0];
}
if(b==1){
ans=d[0];
}
printf("%d\n",ans);
ans=0,k=0;
for(i=0;i<b;i++){
a[i]='A';
}
}
return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
    S[++top]=x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    char input[100];
    top=0;
    int a,b;

    while(scanf("%s", input) != EOF){
        
        if(input[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
            
        }else if(input[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
            
        }else if(input[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);

        }else{
            push(atoi(input));
        }
    }
    printf("%d\n",pop());
    return 0;
}


Measured memory_bytes: 2104
A, B, C, D = gets.split.map(&:to_i)

c = (B / C) - ((A - 1) / C) 
d = (B / D) - ((A - 1) / D) 
lcm = C.lcm(D)
l = (B / lcm) - ((A - 1) / lcm)

puts (B - A + 1) - (c + d - l)

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

using namespace std;

int main()
{
    string s;
    cin>>s;

    int N = (int)s.size();
    vector<int> T(1<<26, N);
    T[0] = 0;

    int h = 0;
    for (int i=0; i<(int)s.size(); i++)
    {
        h ^= 1<<(s[i]-'a');
        int a = N;
        for (int i=0; i<26; i++)
            a = min(a, T[h^1<<i]+1);
        T[h] = min(T[h], a);
    }
    cout<<max(T[h], 1)<<endl;
}


Measured memory_bytes: 262788
h,w,k = list(map(int,input().split())); arr = [[int(i) for i in input()] for _ in range(h)]

from itertools import product
ans = 2000

for cond in product([True,False],repeat=(h-1)):
    cut = sum(cond); div = 0
    splits = [0] * (cut+1); splits[0] = arr[0][:]
    for i in range(1,h):
        if cond[i-1]:
            div += 1
            splits[div] = arr[i][:]
        else:
            splits[div] = [splits[div][j]+arr[i][j] for j in range(w)]
    
    check = [max(i) for i in splits]
    if max(check) > k:
        break
    count = [i[0] for i in splits]
    
    for j in range(1,w):
        addarr = [count[i]+splits[i][j] for i in range(cut+1)]
        if max(addarr) > k:
            div += 1
            count = [splits[i][j] for i in range(cut+1)]
        else:
            count = addarr[:]
    ans = min(ans,div)
        
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int train, taxi;

		train = N * A;
		taxi = B;

		System.out.println(Math.min(train, taxi));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll p[1000][1000];
ll m[1000];
int main(){
  ll n,t,tmp=0;
  cin>>n;
  string s[220];
  rep(i,0,n){cin>>s[i];}
  rep(i,0,30)m[i]=100;
  rep(i,0,n){
    rep(j,0,s[i].length())p[s[i][j]-0x61][i]++;
  } 
  rep(i,0,30){
    rep(j,0,n){
      m[i]=min(m[i],p[i][j]);
    }
  }
  rep(i,0,30){
    rep(j,0,m[i])cout<<char(i+0x61);
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険                                   // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int a, b; cin >> a >> b;
    if(a == 1 && b == 2) cout << 3 << endl;
    if(a == 1 && b == 3) cout << 2 << endl;
    if(a == 2 && b == 3) cout << 1 << endl;
    if(b == 1 && a == 2) cout << 3 << endl;
    if(b == 1 && a == 3) cout << 2 << endl;
    if(b == 2 && a == 3) cout << 1 << endl;
}


Measured memory_bytes: 256
import sys

def want_l(n):

    flag = False

    for i in range(Q):
        if td[i][0] == s[n]:

            if td[i][1] == "L":
                n -= 1
            else:
                n += 1

            if n >= N:
                break
            if n < 0:
                flag = True
                break

    return flag


def want_r(n):

    flag = False

    for i in range(Q):
        if td[i][0] == s[n]:

            if td[i][1] == "L":
                n -= 1
            else:
                n += 1

            if n >= N:
                flag = True
                break
            if n < 0:
                break

    return flag
    

N,Q = map(int,input().split())

s = input()

td = []

for i in range(Q):

    t,d = input().split()
    td.append([t,d])


l = 0
r = N-1
mid = (l+r) // 2
lans = 0
lflag = want_l(l)
rflag = want_l(r)

if not lflag:
    lans = 0
elif rflag:
    print (0)
    sys.exit()
    
else:

    while True:

        mid = (l+r)//2
        midflag = want_l(mid)

        if midflag:
            l = mid
            lflag = midflag

        else:
            r = mid
            rflag = midflag

        if r - l == 1:
            lans = l
            break

        #print (l,r)
        

 
l = 0
r = N-1
mid = (l+r) // 2
rans = 0
lflag = want_r(l)
rflag = want_r(r)

if lflag:
    print (0)
    sys.exit()
elif not rflag:
    rans = N-1
    
else:

    while True:

        mid = (l+r+1)//2
        midflag = want_r(mid)

        if not midflag:
            l = mid
            lflag = midflag

        else:
            r = mid
            rflag = midflag

        if r - l == 1:
            rans = l
            break

        #print (l,r)

#print (lans,rans)
print (rans - lans)

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

int main()
{
	int n;
	cin >> n;
	string s[3];
	for(int i  =0;i<3;i++)cin >> s[i];
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		int cnt = 0;
		for(int j = 0;j<3;j++)
		{
			if(s[j%3][i]!=s[(j+1)%3][i])cnt++;
		}
		if(cnt==2)ans+=1;
		if(cnt==3)ans +=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
m4 = 0
m2 = 0
for i in range(n):
    if a[i] % 4 == 0:
        m4 += 1
    elif a[i] % 2 == 0:
        m2 += 1
import math
if m4 >= math.ceil(n//2):
    print("Yes")
elif m2 >= 2 * (math.ceil(n//2) - m4):
    print("Yes")
else:
    print("No")


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int n;cin>>n;
    vi a(n);rep(i,n)cin>>a[i];sort(all(a));
    vi b;
    for(int i=a[0];i<=a[n-1];++i){
        int sum=0;
        for(int j=0;j<n;++j){
            sum+=(a[j]-i)*(a[j]-i);
        }
        b.PB(sum);
    }
    sort(all(b));
    cout<<b[0];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  lvector div(1000001,0);
  rep(i,n) {
    ll tmp=A[i];
    if(tmp%2==0) {div[2]++;while(tmp%2==0) tmp/=2;}
    for(ll d=3;d*d<=tmp;d+=2) if(tmp%d==0) {div[d]++;while(tmp%d==0) tmp/=d;}
    if(tmp>1) div[tmp]++;
  }
  ll m=*max_element(ALL(div));
  if(m<2) print("pairwise coprime");
  else if(m<n) print("setwise coprime");
  else print("not coprime");
  return 0;
}


Measured memory_bytes: 18784
#include <stdio.h>

int main( int argc , char *argv[] )
{
  int R,G,B,N;
  int cnt = 0;
  int r,g;
  
  scanf( "%d %d %d %d\n" , &R , &G , &B , &N );
  
  for( r = 0 ; r < ( N / R ) + 1 ; r++ ) {
    for( g = 0 ; g < ( N / G ) + 1 ; g++ ) {
      int tmp = N - r*R - g*G;
      
      if( tmp % B == 0 && tmp >= 0 ) {
        cnt++;
      }
    }
  }
  
  printf( "%d\n" , cnt );
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<algorithm>
#include<utility>
#include<cmath>
#include<string>
#include<tuple>
 
using namespace std;
 
const int maxn = 1e5 + 5;
const double eps = 1e-8;
int n, w, b[maxn];
pair<int, int> a[maxn];
long long ans = 0;
 
double h(int idx, long long wt) {
	long long curw = wt;
	long long curv = 0;
	for(int i = idx + 1; i <= n; i++) {
		long long diff = w - curw;
		if(diff >= a[i].first) {
			curv += a[i].second;
			curw += a[i].first;
		} else {
			curv += ((double) a[i].second) / a[i].first * diff;
			break;
		}
	}
	return curv;
}
 
long long bab() {
	priority_queue< tuple<double, long long, long long, int> > pq;
	pq.push({-1, 0, 0, 0});
	while(!pq.empty()) {
		auto e = pq.top();
		pq.pop();
		long long ev = get<1>(e); long long ew = get<2>(e); int ei = get<3>(e);
		for(int i = ei + 1; i <= n; i++) {
			double cv = ev + a[i].second + h(i, ew + a[i].first);
			if(ew + a[i].first <= w && cv > ans) {
				pq.push({cv, ev + a[i].second, ew + a[i].first, i});
				ans = max(ans, ev + a[i].second);
			}
		}
		if(fabs(get<0>(e) - ev) < eps) break;
	}
	return ans;
}
 
bool cmp(pair<int, int> &i, pair<int, int> &j) {
	return ((double) i.second) / i.first > ((double) j.second) / j.first;
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a + 1, a + 1 + n, cmp);
    long long curw = 0; long long curv = 0;
	for(int i = 1; i <= n; i++) {
		long long diff = w - curw;
		if(diff >= a[i].first) {
			curv += a[i].second;
			curw += a[i].first;
		} else {
			ans = max(curv, 0LL + a[i].second);
			break;
		}
	}
    ans = max(ans, curv);
	cout << bab() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<double>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll N, M;
vector<ll> as;
ll res;
ll bsum[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        as.push_back(A);
    }

    sort(as.begin(), as.end());
    for(int i = N - 1; i >= 0; i--){
        bsum[i] = bsum[i + 1] + as[i];
    }

    ll lb = 0, ub = 200010;
    while(ub - lb > 1){
        ll mid = (ub + lb) / 2;
        ll cnt = 0;
        for(int i = 0; i < N; i++){
            auto it = lower_bound(as.begin(), as.end(), mid - as[i]);
            cnt += as.end() - it; 
        }
        if(cnt >= M) lb = mid;
        else ub = mid;
    }
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        auto it = lower_bound(as.begin(), as.end(), lb - as[i]);
        ll p = as.end() - it;
        cnt += p;
        res += (as[i] * p) + bsum[N - p];
    }
    res -= lb * (cnt - M);
    cout << res << endl;
    return 0;
}

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

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>
#define L 26

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

struct graph
{
    int n;
    vector<vector<pair<int, int>>> adj;
    graph(int n)
    {
        this -> n = n;
        adj.resize(n);
    }
    
    void add_edge(int u, int v, int w)
    {
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << '\n';

    // cout << "        __.....__\n";
    // cout << "     .-'         '-.\n";
    // cout << "   .'               '.\n";
    // cout << "  /                   \\\n";
    // cout << " /        |\\           \\\n";
    // cout << ";        |V \\_          ;\n";
    // cout << "|        |  ' \\         ;\n";
    // cout << ";        )   ,_\\        |\n";
    // cout << ";       /    |          ;\n";
    // cout << " \\     /      \\         /\n";
    // cout << "  \\    |       \\       /\n";
    // cout << "   '.   \\       \\    .'\n";
    // cout << "     '-._|       \\.-'\n";
    // cout << "         | |\\     |    \n";
    // cout << "_________/ |_'.   /_______  \n";
    return 0;
    
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	array<array<int, 3>, 3> c;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) { cin >> c[i][j]; }
	}

	bool ok = true;
	for (int j = 0; j < 3; ++j) {
		ok = ok && (c[1][j] - c[0][j] == c[1][0] - c[0][0]);
		ok = ok && (c[2][j] - c[1][j] == c[2][0] - c[1][0]);
	}
	for (int i = 0; i < 3; ++i) {
		ok = ok && (c[i][1] - c[i][0] == c[0][1] - c[0][0]);
		ok = ok && (c[i][2] - c[i][1] == c[0][2] - c[0][1]);
	}
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var A = one[1];
  var B = one[2];
  var C = one[3];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = nextInt();
  }
  var inf = 10 ** 9;
  myout(dfs(0, 0, 0, 0));
  
  function dfs(use, sa, sb, sc){
    if(use == N){
      if(Math.min.apply(null, [sa, sb, sc]) > 0){
        return Math.abs(sa - A) + Math.abs(sb - B) + Math.abs(sc - C) - 30;
      }else{
        return inf;
      }
    }
    var min = dfs(use + 1, sa, sb, sc);
    min = Math.min(min, dfs(use + 1, sa + list[use], sb, sc) + 10);
    min = Math.min(min, dfs(use + 1, sa, sb + list[use], sc) + 10);
    min = Math.min(min, dfs(use + 1, sa, sb, sc + list[use]) + 10);
    return min;
  }
}


Measured memory_bytes: 35288
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<int,int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define all(a) a.begin(),a.end()
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void dfs(int node,vector<int> adj[],int dp[],bool chk[]){
    chk[node]=true;
    for(int i=0;i<adj[node].size();i++){
        if(!chk[adj[node][i]]){
            dfs(adj[node][i],adj,dp,chk);
        }
        dp[node]=max(dp[node],1+dp[adj[node][i]]);
    }
}
void addEdge(vector<int> adj[],int u,int v){
    adj[u].pb(v);
}
int main(){
    fast;
    int n,m;
    cin>>n>>m;
    int a,b;
    vector<int> adj[n+1];
    while(m--){
        cin>>a>>b;
        addEdge(adj,a,b);
    }
    bool chk[n+1];
    memset(chk,false,sizeof chk);
    int dp[n+1];
    memset(dp,0,sizeof dp);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!chk[i]){
            dfs(i,adj,dp,chk);
        }
    }
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 9600