akhauriyash/Code-Regression huggingface dataset:
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)


n,k = map(int,input().split())
l = list(map(int,input().split()))
d = l[0]
for i in l:
    d = gcd(d,i)

if k%d==0 and k<=max(l):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

ll gcd(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

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

    return b;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    bool nukeru = true;
    REP(i, n) {
        if(a[i] >= k) nukeru = false;
    }

    if(nukeru) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    int gcd_ = a[0];
    REP(i, n-1) {
        gcd_ = gcd(gcd_, a[i+1]);
    }

    REP(i, n) {
        if((k-a[i]) % gcd_ == 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

/*
flag管理が面倒くさそう。

いっかいMを全部見て、各問題についてどこでACしたかを記憶、
もう一回Mを全部見て、ACする前のWAの数を数える？

or ACのフラグをboolで管理して、WAの数も同時に数えておく？
*/

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

    int correct = 0;
    int penalty = 0;

    vector<int>WA(N+1, 0);
    vector<bool> AC(N + 1, false);

    for (int i = 0; i < M; i++)
    {
        int p;
        string s;
        cin >> p >> s;

        // pがWAでACしてないなら、WA数をカウント
        // そうじゃなければ飛ばす
        if (s == "WA") {
            if (AC[p] == false) {
                WA[p]++;
            }
            else
            {
                continue;
            }
                }
        else // pがACならば
        {
            AC[p] = true;
        }
    }

    for (int i = 1; i < N+1; i++)
    {
        if (AC[i]) {
            correct++;
            penalty += WA[i];
        }
    }

    cout << correct << " " << penalty << endl;
    
}

Measured memory_bytes: 768
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
ans = 1
MOD = 10**9+7
MAX = 10**5+1

fib = [0] * MAX
fib[0], fib[1] = 1, 2
for i, j in zip(a[:m-1], a[1:]):
    if j - i == 1:
        print(0)
        exit()

for i in range(2, MAX):
    fib[i] = fib[i-1] + fib[i-2]
    
for i in range(m+1):
    left = 0 if i == 0 else a[i-1] + 1
    right = n if i == m else a[i] - 1
    between = right - left
    if not between:
        continue
    ans *= fib[between-1]
    ans %= MOD
print(ans)

Measured memory_bytes: 467520
#include <iostream>
#include <cstring>

using namespace std;

int rec(int pos, int mul, int m);

int prime[] = {2, 3, 5, 7, 11, 13, 17, 19};

int cnt = 0;

int n, m;

int a[28], b[28];

int mulmax = 1;

int main(void) {
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    mulmax = mulmax * prime[i];
  }

  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }

  rec(1, 2, m);

  cout << cnt << endl;
  return 0;
}

int rec(int pos, int mul, int m) {
  if (mul >= mulmax) {
    cnt++;
    return 0;
  }

  for (int i = 0; i < m; i++) {
    if (a[i] == pos && mul % prime[b[i] - 1] != 0) rec(b[i], mul * prime[b[i] - 1], m);
    if (b[i] == pos && mul % prime[a[i] - 1] != 0) rec(a[i], mul * prime[a[i] - 1], m);
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {

    int value = 0;

    int min = 0;
    
    int max = 0;

    char str[1000];

    scanf("%d%*c",&value);
 
    fgets(str,sizeof(str),stdin);

    sscanf(str,"%d %d",&min,&max);

    for (int i = min; i <= max; i++) {

        if (i % value == 0) {

            printf("%s\n","OK");

            return 0;

        }



    }

    printf("%s\n", "NG");

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int > > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	if (n % 2 == 0) {
		cout << fixed << setprecision(10) << 0.5 << endl;
	} else {
		double evenCnt = n / 2;
		double oddCnt = evenCnt + 1;

		cout << fixed << setprecision(10) << oddCnt / n << endl;
	}
}

Measured memory_bytes: 256
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N = int(readline())
    *P, = map(int, readline().split())
    G = []
    prt = [0]*N
    for i in range(N):
        k, *t = map(int, readline().split())
        G.append([e-1 for e in t])
        for e in t:
            prt[e-1] = i
    *D, = map(len, G)
    A = [0]*N
    deg = D[:]
    que = deque()
    for v in range(N):
        if deg[v] == 0:
            A[v] = P[v]
            que.append(v)
    while que:
        v = que.popleft()
        p = prt[v]
        deg[p] -= 1
        if deg[p] == 0:
            A[p] = max(-A[w] for w in G[p])
            que.append(p)

    for v in range(N):
        if D[v] == 0:
            A[v] = P[v]
        else:
            A[v] = max(-A[w] for w in G[v])

    memo = {}
    def dfs(v, state, c, a, b):
        key = (v, state, a, b)
        if key in memo:
            return memo[key]
        if c == D[v]:
            if c == 0:
                return 1, 1
            return 0, 0
        c0 = N+1; c1 = 0
        Gv = G[v]
        for k in range(D[v]):
            if state & (1 << k):
                continue
            w = Gv[k]
            s0, s1 = dfs(w, 0, 0, -b, -a)
            val = -A[w]
            if val >= b:
                c0 = min(c0, s0); c1 = max(c1, s1)
                continue
            t0, t1 = dfs(v, state | (1 << k), c+1, max(a, val), b)
            c0 = min(c0, s0+t0)
            c1 = max(c1, s1+t1)
        memo[key] = c0, c1
        return c0, c1
    INF = 10**9
    r0, r1 = dfs(0, 0, 0, -INF, INF)
    write("%d %d\n" % (r0, r1))
solve()


Measured memory_bytes: 49968
#include <stdio.h>
int main(void){
    // Your code here!
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1) {break;}
        if(m==-1 || f==-1) printf("F\n");
        else if((m+f) >= 80) printf("A\n");
        else if(65 <= (m+f) && (m+f) < 80) printf("B\n");
        else if(50 <= (m+f) && (m+f) < 65) printf("C\n");
        else if(30 <= (m+f) && (m+f) < 50){
            if(r >= 50)printf("C\n");
            else printf("D\n");
        }
        else if((m+f) <30) printf("F\n");
    }
    return 0;
}



Measured memory_bytes: 2052
#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; cin >> N;
    string S; cin >> S;

    vector<string> t(1000);
    rep(i, 10){
        char tmp = '0' + i;
        t.at(i) = "00";
        t.at(i) += tmp;
    }

    for(int i=10; i<100; i++){
        string tmp = to_string(i);
        t.at(i) = "0";
        t.at(i) += tmp;
    }

    for(int i=100; i<1000; i++){
        t.at(i) = to_string(i);
    }

    vector<bool> used(1000, false);
    vector<bool> notok(1000, false);

    for(int i=0; i<1000; i++){
        for(ll j=0; j<S.size(); j++){
            if(t.at(i).at(0) == S.at(j)){
                for(ll k=j+1; k<S.size(); k++){
                    if(t.at(i).at(1) == S.at(k)){
                        for(ll l=k+1; l<S.size(); l++){
                            if(t.at(i).at(2) == S.at(l)){
                                used.at(i) = true;
                                break;
                            }
                            
                            if(l==S.size()-1){
                                notok.at(i) = true;
                                break;
                            }
                        }
                        if(used.at(i) || notok.at(i)) break;
                    }

                    if(k==S.size()-1){
                        notok.at(i) = true;
                        break;
                    }
                }
                if(used.at(i) || notok.at(i)) break;
            }
        }
        
    }

    int cnt = 0;
    for(int i=0; i<1000; i++){
        if(used.at(i) == true) cnt++;
    }

    cout << cnt << endl;
}

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

#include <string.h>

#define INT_INF 2000000

int m, n;

int a[100 + 1];

int memo[20 + 1][100 + 1];

int search(int i, int j)
{
  if (memo[i][j] >= 0)
    return memo[i][j];

  if (i == 1)
    return memo[i][j] = std::accumulate(a + j, a + n, 0);

  int am = INT_INF;
  
  for (int k = j, s = 0; k < n; s += a[k], k ++)
    am = std::min(std::max(search(i - 1, k), s),
			   am);

  return memo[i][j] = am;
}

int main(int argc, char** argv)
{
  while (1) {
    std::cin >> m >> n;
    
    if (m == 0)
      break;

    for (int i = 0; i < n; i ++)
      std::cin >> a[i];

    memset(memo, -1, sizeof(memo));

    std::cout << search(m, 0) << std::endl;
  }
}

Measured memory_bytes: 0
dic={}
N = int(input())
for i in range(N):
  inp = input().split()
  S = inp[0]
  P = int(inp[1])
  if S in dic:
    dic[S].append([P,i])
  else:
    dic[S] = [[P,i]]

for key in sorted(dic):
    for j in sorted(dic[key], reverse=True):
        print(j[1]+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
#define int long long
 
signed main(){
	


	int h,w;
	int nx,ny;
	int count=0;
	char ch;
	cin>>h>>w;

	char a[51][51];
	int grid[51][51]={0};

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}


	// cout<<"----"<<endl;


	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ch=a[i][j];

			// cout<<"-------"<<endl;
			// cout<<"ch:"<<i<<" "<<j<<endl;

			count=0;
			if(ch=='.'){
			
				for(int k=-1;k<2;k++){
					for(int l=-1;l<2;l++){



						nx=j+k;
						ny=i+l;

						if(nx<0||ny<0)continue;
						if(nx>=w||ny>=h)continue;
						// if(nx==i&&ny==j)continue;
						if(a[ny][nx]=='.')continue;

						// cout<<nx<<" "<<ny<<endl;
						// cout<<"hoge:"<<a[ny][nx]<<endl;
						count++;
						// cout<<"found!"<<endl;


					}
				}
				// cout<<"count:"<<count<<endl;
				grid[i][j]=count;

			}
		}

	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){

			if(grid[i][j]==0&&a[i][j]=='#'){
				cout<<"#";
			}else{
				cout<<grid[i][j];
			}
		}cout<<endl;
	}
}

Measured memory_bytes: 256
a,b,x,y = map(int, input().split())

xl = list(map(int, input().split()))
yl = list(map(int, input().split()))

xx = max(xl)
xx = max(xx,x)
yy = min(yl)
yy = min(yy,y)

if xx<yy:
    print("No War")

else:
    print("War")

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int a,b;

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

  cin>>a>>b;
  if (a>=13) out(b);
  if (a>=6 && a<=12) out(b/2);
  out(0);
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define double long double 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)(x.size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------

const double pi = 3.14159265358979323;
int mod=1000000000+7;
int modu=998244353;
const double pii=acos(-1.0);
const int INF=1e18;
const int inf=1e9;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll add(ll a, ll b){return((a % mod + b % mod) % mod);}
ll sub(ll a, ll b){return((a % mod - b % mod + mod) % mod);}
ll mul(ll a, ll b){return(((a % mod) * (b % mod)) % mod);}
ll divi(ll a, ll b){return(mul(a, powe(b, mod - 2)) % mod);}


//-------------------------------------------------------------------------------------------------------------------------------------------------------

void fun()
{
	
	//786
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

const int N = 2e5+7;

//--------------------------------------------------------------------------------------------------------------------------------------------------------

void pre()
{
	
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	pre();
	int tttt=1; //cin>>tttt;
	while(tttt--)
	{
		int n; cin>>n;
		int a[n];
		int xorr = 0;
		for(int i=0;i<n;i++) {
			cin>>a[i];
			xorr ^= a[i];
		}
		for(int i=0;i<n;i++)
		{
			cout<<(xorr^a[i])<<' ';
		}
	}	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 5348
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

int main() {
	int N; int M;
	while(~scanf("%d%d", &N, &M)) {
		UnionFind uf; uf.init(N);
		rep(i, M) {
			int a; int b;
			scanf("%d%d", &a, &b), -- a, -- b;
			uf.unionSet(a, b);
		}
		int x = 0, y = 0;
		rep(i, N) if(uf.root(i) == i) {
			(uf.size(i) == 1 ? x : y) += 1;
		}
		int ans = abs(x - y);
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        int a[1000];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int dif =1000001;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                int d=abs(a[i]-a[j]);
                if(d<dif){
                    dif=d;
                }
            }
        }
        cout<<dif<<endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}

signed main(){
	int n; cin >> n;
	if (n % 2 == 0) { cout << (n / 2 - 1) << endl; }
	else { cout << (n - 1) / 2 << endl; }
	return 0;
}

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

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

    vector<int> cnt(n + 10, 1);
    for (int i = 2; i <= n; i++)
        for (int j = i; j <= n; j += i)
            cnt[j]++;

    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += (ll)i * (ll)cnt[i];

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


Measured memory_bytes: 42316
#include <stdio.h>
int h, w;
char s[405];
int a[402][402];
int b[402][402];
long long br, wh;
long long ans;
void dfs(int x, int y) {
	b[x][y] = 1;
	if (a[x][y])br++;
	else wh++;
	if (!b[x][y + 1] && a[x][y] + a[x][y + 1] == 1) {
		dfs(x, y + 1);
	}
	if (!b[x][y - 1] && a[x][y] + a[x][y - 1] == 1) {
		dfs(x, y - 1);
	}
	if (!b[x + 1][y] && a[x][y] + a[x + 1][y] == 1) {
		dfs(x + 1, y);
	}
	if (!b[x - 1][y] && a[x][y] + a[x - 1][y] == 1) {
		dfs(x - 1, y);
	}
	return;
}
int main(){
	scanf("%d%d", &h, &w);
	for (int i = 0; i < 402; i++) {
		for (int j = 0; j < 402; j++) {
			a[i][j] = 2;
		}
	}
	for (int i = 0; i < h; i++) {
		scanf("%s", s);
		for (int j = 0; j < w; j++) {
			if (s[j] == '.')a[i + 1][j + 1] = 0;
			if (s[j] == '#')a[i + 1][j + 1] = 1;
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			br = 0; wh = 0;
			dfs(i, j);
			ans += br * wh;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll sum = 0;
    FOR(i, K, N) {
        if (A[i - K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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

string f(ll x){
  	if(x == 0) return "";
  	x--;  
 
  	return f(x/26) + string(1, 'a' + x % 26);
}

int main(){
	ll n;
  	cin >> n;
	  
  	cout << f(n) << endl;
}

Measured memory_bytes: 3608
# !/usr/bin python3
# -*- coding: UTF-8 -*-

n = int(input())
As = list(map(int, input().split(' ')))

counter = 0

def is_all_odds(list):
    return [a % 2 for a in list] == [0] * n

while is_all_odds(As):
    As = [a / 2 for a in As]
    counter += 1

print(counter)

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

using namespace std;

int main() {

	string no = "No";
	string yes = "Yes";
	int n;
	cin >> n;
	int a;
	int t0,t1,t2;
	t0 = t1 = t2 = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a % 4 == 0) t2++;
		else if (a % 2 == 0) t1++;
		else t0++;
	}
	if (t2 + 1 < t0) {
		cout << no << endl;
	}
	else if (t2 + 1 == t0) {
		if(t1 == 0)
			cout << yes << endl;
		else
			cout << no << endl;
	}
	else {
		cout << yes << endl;
	}
	return 0;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    r,c,k = map(int,ipt().split())
    pts = [[0]*c for i in range(r)]
    for i in range(k):
        ri,ci,ki = map(int,ipt().split())
        pts[ri-1][ci-1] = ki

    dp = [0]*c
    for i in range(r):
        ndp = [0,0,0,0]
        ndpp = []
        for j in range(c):
            if ndp[0] < dp[j]:
                ndp[0] = dp[j]
            for l in range(3,0,-1):
                if ndp[l] < ndp[l-1]+pts[i][j]:
                    ndp[l] = ndp[l-1]+pts[i][j]
            ndpp.append(max(ndp))
        dp = ndpp*1
    print(dp[c-1])



    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 165596
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,r=0;
  cin>>n;
  vector<int> a(n+1),b(n);
  for(auto& i:a)cin>>i;
  for(auto& i:b)cin>>i;
  for(int i=0;i<n;++i){
    if(a[i]>b[i])r+=b[i];
    else{
      if(a[i+1]>b[i]-a[i]){
        a[i+1]-=b[i]-a[i];
        r+=b[i];
      }
      else{
        r+=a[i]+a[i+1];
        a[i+1]=0;
      }
    }
  }
  cout<<r;
}

Measured memory_bytes: 1792
from collections import defaultdict
N,K = map(int,input().split())
d = defaultdict(int)
for i in range(N):
    a,b = map(int,input().split())
    d[a] += b
ls = [(k,d[k]) for k in d.keys()]
ls.sort(key = lambda x:x[0])
cnt = 0
for i in range(len(ls)):
    cnt += ls[i][1]
    if cnt >= K:
        print(ls[i][0])
        break


Measured memory_bytes: 15324
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = -1;

    for(int i =0 ; i<N-1; i++){
        int temp = 0;
        int cnt = 0;
        for(int j = 0; j < N-i; j++){
            if(S[j] == S[i+j]){
                cnt++;
            }
            else{                
                temp = max(temp, cnt);
                cnt = 0;
            }
        }
        temp = max(temp, cnt);
        ans = max(ans, temp);
        ans = min(ans, i);
    }
    cout << ans << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>>vii;
typedef vector<ll> vl;
typedef vector<vector<ll>>vll;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;

vector<ll> dig(ll a){
    vector<ll> soln;
    while(a > 0){
        soln.push_back(a%10);
        a = a/10;
    }
    return soln;
}

map <pll, ll> mp;


void solve(){
    ll n, m;
    cin>>n>>m;
    if(n%2 == 0 || m %2 == 0){
        cout<<(n*m)/2<<endl;
        return ;
    }
    else{
        ll ans = min(n/2 * m  + m/2 + 1, m/2 * n + n/2 + 1);
        cout<<ans<<endl;
        return;
    }
}

int totalMinutes(int h1, int m1, int h2, int m2){
    if(h2 > h1){
        return (h2-h1)*60 + m2-m1;
    }
    else if( h2 == h1){
        if(m2 > m1){
            return m2-m1;
        }
        else return 24*60 + m2-m1;    
    }
    else{
        return (24+h2-h1) + m2-m1;
    }
    return 0;
}


int main(){
    string a;
    cin>>a;
    for(int i =0;i< a.size();i++){
        if(a[i] == '?')a[i] = 'D';
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	string s;
	cin >> n >> k;
	cin >> s;
	for(int i =0; i< s.size(); ++i)
	{
		if(k-1 == i)
		putchar(tolower(s[i]));
		else cout << s[i];	
	}
	

	
	
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
snuke = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        snuke[a[j]-1] += 1
ans = 0
for i in range(n):
    if snuke[i] == 0:
        ans += 1
print(ans)

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

int qpow(int b,int e){
    if(!e)return 1;
    if(e&1) return qpow(b,e-1)*b;
    return qpow(b*b,e>>1);
}

int32_t main(){
    int n,k;
    cin>>n>>k;
    cout<<k*qpow(k-1,n-1)<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
VI a;

int main()
{
	cin >> N;
	a.resize(N);
	double sum =0;
	REP(i,N){
		cin >> a[i];
		sum += a[i];
	}


	double c = sum/2.0;
	double sum2 = 0;

	REP(i,N){
		sum2 += a[i];
		if(sum2 > c) {
			cout << fixed << setprecision(0) << min(sum2 - c, c - (sum2-a[i])) * 2;
			return 0;
		}
	}
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int H, W;
	cin >> H >> W;

	//input
	vector<vector<char> > grid(H+2,vector<char>(W+2));
	for (int i = 1; i <= H; i++)
	{
		string tmp;
		cin >> tmp;
		for (int j = 1; j <= W; j++)
		{
			grid[i][j] = tmp[j - 1];
		}
	}

	//main process
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (grid[i][j] != '#') {
				int bomb_count = '0';
				bomb_count += grid[i][j + 1] == '#' ? 1 : 0;
				bomb_count += grid[i + 1][j + 1] == '#' ? 1 : 0;
				bomb_count += grid[i + 1][j] == '#' ? 1 : 0;
				bomb_count += grid[i + 1][j - 1] == '#' ? 1 : 0;
				bomb_count += grid[i][j - 1] == '#' ? 1 : 0;
				bomb_count += grid[i - 1][j - 1] == '#' ? 1 : 0;
				bomb_count += grid[i - 1][j] == '#' ? 1 : 0;
				bomb_count += grid[i - 1][j + 1] == '#' ? 1 : 0;

				grid[i][j] = bomb_count;
			}
		}
	}

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cout << grid[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $x);
function isPrime($n){
  for ($i=2;$i*$i<=$n;$i++) {
    if ($n%$i==0) return false;
 }
  return true;
}
while(true){
  if (isPrime($x)) break;
  $x++;
}
echo $x;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n,k;cin>>n>>k;
    ll mod = 1e9+7;
    ll sum = 0;
    rep(i,k,n+2){
        sum += 1ll * i * (2 * n + 3 - i) / 2 - 1ll * i * (i + 1) / 2 + 1;
        sum %= mod;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
count_matw = [[0 for w in range(W)]for h in range(H)]
count_math = [[0 for w in range(W)]for h in range(H)]

for h in range(H):
    count = 0
    for w in range(W):
        if '#' == S[h][w]:
            count = 0
        else:
            count += 1
        count_matw[h][w] = count
    for w in range(W-1, 0, -1):
        if count_matw[h][w-1] == 0:
            continue
        count_matw[h][w-1] = max(count_matw[h][w], count_matw[h][w-1])

for w in range(W):
    count = 0
    for h in range(H):
        if '#' == S[h][w]:
            count = 0
        else:
            count += 1
        count_math[h][w] = count
    for h in range(H-1, 0, -1):
        if count_math[h-1][w] == 0:
            continue
        count_math[h-1][w] = max(count_math[h][w], count_math[h-1][w])
ans = 1
# for h in range(H):
#     for w in range(W):
#         ans = max(ans, count_math[h][w] + count_matw[h][w])
ans = max([count_math[h][w] + count_matw[h][w] for h in range(H) for w in range(W)])
# print(count_math)
# print(count_matw)
print(ans-1)


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

int main(){
    //入力
    string w;
    cin >> w;

    //処理
    bitset<26> alphabet;
    for(int i=0;i<w.size();i++){
        alphabet.flip(w.at(i)-'a');
    }
    //出力
    if(alphabet.any()==true){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;



int (((((main)))))() <%
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != t[i])
            ans++;
    }

    cout << ans << endl;

	return 0;
%>

Measured memory_bytes: 3748
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;



int main() {
    int h,n;
    cin >> h >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i]; 
    vector<int> dp(h+1,10e8);
    dp[0]=0;
    rep(i,h+1) {
        rep(j,n) {
            int k=min(i+a[j],h);
            dp[k]=min(dp[k],dp[i]+b[j]);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int X, Y, Z;
int A[100000], B[100000], C[100000];
long long L[100000], R[100000];

class LargestKSum {
  public:
  int K;
  priority_queue<int, vector<int>, greater<int> > q;
  long long s = 0;

  LargestKSum(int k) : K(k) {}
  void add(int x) {
    s += x;
    q.push(x);
    if (q.size() > K) {
      s -= q.top();
      q.pop();
    }
  }
  long long sum() {
    if (q.size() != K) return -(1LL<<60);
    return s;
  }
};

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> X >> Y >> Z;
  int N = X+Y+Z;
  rep(i, N) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<P> xs;
  long long sum = 0;
  rep(i, N) {
    sum += A[i];
    B[i] -= A[i];
    C[i] -= A[i];
    A[i] = 0;
    xs.pb(P(B[i] - C[i], i));
  }
  sort(all(xs), greater<P>());

  LargestKSum s1(Y);
  rep(i, N) {
    int x = xs[i]._2;
    s1.add(B[x]);
    L[i] = s1.sum();
  }

  LargestKSum s2(Z);
  for (int i=N-1; i>=0; i--) {
    int x = xs[i]._2;
    s2.add(C[x]);
    R[i] = s2.sum();
  }
  long long m = -(1LL<<60);
  rep(i, N-1) {
    m = max(m, L[i] + R[i+1]);
  }
  cout << sum + m << "\n";
}


Measured memory_bytes: 4724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int maxn=2e3+5;
typedef long long ll;
ll dp[maxn][maxn];
int n;
pair<int,int> a[maxn];
inline bool cmp1(pair<int,int> a1,pair<int,int> b1){
	return a1.first>b1.first;
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	sort(a+1,a+n+1,cmp1);
	memset(dp,0xf3,sizeof(dp));
	dp[0][0]=0;
	ll ans=-1e14;
	for (int len=1;len<=n;len++){
		for (int l=0;l<=len;l++){
			int r=len-l;
			int ot=n-r+1;
			if (l&&a[len].second-l>=0) dp[l][r]=max(dp[l][r],dp[l-1][r]+1ll*(a[len].second-l)*a[len].first);
			if (r&&ot-a[len].second>=0) dp[l][r]=max(dp[l][r],dp[l][r-1]+1ll*(ot-a[len].second)*a[len].first);
			if (len==n) ans=max(ans,dp[l][r]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35168
#B-Graph Partition
n=int(input())
uselist=[[] for i in range(n+1)]
distancelist=[[10**5 for j in range(n)] for i in range(n)]
for i in range(n):
    s=input()
    for j in range(n):
        if int(s[j])!=0:
            distancelist[i][j]=1
            distancelist[j][i]=1
            uselist[i+1].append(j+1)
#各辺がどの点とつながっているかをuselistないに保存する
for i in range(n):
    distancelist[i][i]=0
visitedlist=[-1 for i in range(n)]
pointlist=[0 for j in range(n)]
flag=True
def search(i,string):
    visitedlist[i-1]=1
    if string==0:
        pointlist[i-1]="B"
    else:
        pointlist[i-1]=string
    flags=False 
    for node in uselist[i]:
        if visitedlist[node-1]==-1:
            #訪れていない点を発見した場合
            flags=True
            visitedlist[node-1]=1
            if string=="B"or string==0:
                pointlist[node-1]="R"
            elif string=="R":
                pointlist[node-1]="B"
        else:
            pass
    if flags:
        #一度でも訪れられた点がある時
        for j in uselist[i]:
            search(j,pointlist[j-1])
    if not flags:
        # 全ての点がすでにvisitedだった時
        pass    
search(1,0)
for j in range(1,n+1):
    for some in uselist[j]:
        if pointlist[j-1]==pointlist[some-1]:
            flag=False
if flag:
    #ワーシャルフロイド法で二点間の最小距離の最大値
    for k in range(n):
        for j in range(n):
            for i in range(n):
                distancelist[i][j]=min(distancelist[i][j],distancelist[i][k]+distancelist[k][j])
    maxi=0
    for i in range(n):
        for j in range(n):
            maxi=max(maxi,distancelist[i][j])
    print(maxi+1)
else:
    print(-1)


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

int main(){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        X = max(X, x);
    }
    for(int i = 0; i < m; i++){
        int y;
        cin >> y;
        Y = min(Y, y);
    }
    cout << (X < Y ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
	string s;
  	cin >> s;
    int pos = 2;
    int ans = 0;
    while(s.size()-pos != 0) {
        string u, t, r;
        u = s.substr(0, s.size()-pos);
        t = s.substr(0, u.size()/2);
        r = s.substr(u.size()/2, u.size()/2);
        //cout << u << " " << t << " " << r << " " << pos << endl;
        if(t == r) {
            ans = u.size();
            break;
        }
        pos+=2;
    }
    cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    long long sum = 0;
    int n; cin >> n;
    for (int i = 1; i <= n; ++i){
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int a,b;

		Scanner scan = new Scanner(System.in);

		while(true)
		{
		    a = scan.nextInt();
		    b = scan.nextInt();

		    if( (a | b) == 0) break;

		    else if(b<a)
		    {
		    	a ^= b;
		    	b ^= a;
		    	a ^= b;
		    }

		    System.out.println(a + " " + b);
		}
		scan.close();
	}
}

Measured memory_bytes: 34492
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <utility>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n , m , c = 0;
    cin >> n;
    ll a[n + 1];
    for( ll i = 1 ; i <= n ; i++ ) {
    	cin >> a[i];
    	a[i] -= i;
	}
    sort( a + 1 , a + n + 1 );
    if( n % 2 ) m = a[n / 2 + 1];
    else m = a[n / 2];
	for( ll i = 1 ; i <= n ; i++ ) {
		c += abs( a[i] - m );
	}
	cout << c;
}


Measured memory_bytes: 5212
#include<iostream>
#include<functional>
#include<queue>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#define pb push_back
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(all(c)),c.end())
using namespace std;
typedef pair<int,int > P;
int main(){
	int n;
	vector<vector<int> > c(8,vector<int>(8));
	while(cin>>n){
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>c[i][j];
			}
		}
		priority_queue<P,vector<P>,greater<P> > que;
		int v=0;
		for(int i=0;i<n;i++){
			v*=10;
			v+=i;
		}
		int ans=0;
		map<int,bool> used;
		que.push(P(0,v));
		while(!que.empty()){
			
			P p=que.top();
			que.pop();
			int now=p.second;
			if(used[now]){
				continue;
			}
			int np=p.first;
			used[now]=true;
			ans=max(ans,np);
			int m=1;
			for(int i=0;i<n;i++){
				m*=10;
			}
			for(int i=1;i<m;i*=10)
			for(int j=i*10;j<m;j*=10){
				int a=(now/i)%10,b=(now/j)%10;
				int nn=now-a*i-b*j+a*j+b*i;
				//swap(now[i],now[j]);
				if(used[nn]){
					//swap(now[i],now[j]);
					continue;
				}
				//cout<<"--------"<<endl;
				que.push(P(np+c[a][b],nn));
				//swap(now[i],now[j]);
			}
			
			
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b;
    cin>>a>>b;
    cout<<((long long)(a/gcd(a,b)))*b<<endl;

    return 0;
}

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


void solve(long long X, long long A){
    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize z:i64 w:i64)(list:[i64]));
    let mut x = z;
    let mut y = w;

    if n == 1 {
        x = list[0];
    } else {
        //xが最後の要素を取った場合
        let x_last = (list[n - 1] - y).abs();
        //yが最後の要素を取った場合
        let y_last = (list[n - 2] - list[n - 1]).abs();
        if x_last > y_last {
            x = list[n - 1];
        } else {
            x = list[n - 2];
            y = list[n - 1];
        }
    }

    (x - y).abs().to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 100 100\n10 1000 100" => "900",
    test2: "3 100 1000\n10 100 100" => "900",
    test3: "5 1 1\n1 1 1 1 1" => "0",
    test4: "1 1 1\n1000000000" => "999999999",
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long AtoB = B - A + 1;
    // cで割れる数
    long long cc = B / C - (A - 1) / C;
    // cで割れない数
    long long cn = AtoB - cc;
    // dで割れる数
    long long dc = B / D - (A - 1) / D;
    // dで割れない数
    long long dn = AtoB - dc;
    // c,dの最小公倍数e
    long long e = LCM(C, D);
    // eで割れる数
    long long ec = B / e - (A - 1) / e;
    // dで割れない数
    long long en = AtoB - ec;
    cout << AtoB - cc - dc + ec << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i <n; i++) cin >> a[i];
    std::sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        if (x < a[i]) {
            cout << i << "\n";
            return 0;
        }
        x -= a[i];
        if (i == n - 1) {
          if (x > 0) {
              cout << n - 1 << "\n";
          } else {
              cout << n << "\n";
          }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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



ll n;
int k;
ll dp[100005];
ll ans;

// a^n mod を計算する
long long modpow(long long a, long long n, long long MOD) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int main() {

	cin >> n >> k;

	for (int i = k; i > 0; i--) {
		Vl vec;
		for (int j = 1; i * j <= k; j++) {
			vec.push_back((ll)i * j);
		}
		dp[i] = (modpow((ll)vec.size(), n, mod));
		REP(j, 1, vec.size()) {
			dp[i] = (dp[i] + mod - dp[vec[j]]) % mod;
		}
		ans = (ans + dp[i] * i) % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5512
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int isl, cl;
	cin >> isl >> cl;
	int ans = 0;
	int nearest = 100005;
	deque<pair<int, int>> cls(cl);
	ff(i, 0, cl) {
		int a, b;
		cin >> a >> b;
		pair<int, int> c(min(a, b), max(a, b));
		cls.push_back(c);
	}
	
	sort(cls.begin(), cls.end());
	
	ff(i, 1, isl+1) {
		//cout << "We arrived at isl. no." << i << endl;
		if (nearest==i) {//crossed bridge
			ans++;
			nearest = 100005;
			//cout << "The bridge between isl.no." <<i-1<<" and no."
				//<<i<<" was destroyed."<< endl;
		}
		if (cls.empty()) {
			continue;
		}
		while (!cls.empty()&&cls.front().first < i) {
				cls.pop_front();
			}
		if (!cls.empty()&&cls.front().first == i) {//find nearest
				nearest = min(nearest, cls.front().second);
			}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920