akhauriyash/Code-Regression huggingface dataset:
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

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)
using ll = long long;
#define EPS 1e-9
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;

int main() {
	map<string, ll> mp;
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		ans += mp[s];
		mp[s]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
# https://tjkendev.github.io/procon-library/python/prime/eulers-totient-function.html
# https://qiita.com/drken/items/a14e9af0ca2d857dad23#%E5%95%8F%E9%A1%8C-6-%E3%82%AA%E3%82%A4%E3%83%A9%E3%83%BC%E9%96%A2%E6%95%B0
# オイラー関数
# 1,2,...,NのうちNと互いに素であるものの個数
# Python3 program to calculate 
# Euler's Totient Function 
def euler_phi(n): 
	
	# Initialize result as n 
	result = n; 

	# Consider all prime factors 
	# of n and subtract their 
	# multiples from result 
	p = 2; 
	while(p * p <= n): 
		
		# Check if p is a 
		# prime factor. 
		if (n % p == 0): 
			
			# If yes, then 
			# update n and result 
			while (n % p == 0): 
				n = int(n / p); 
			result -= int(result / p); 
		p += 1; 

	# If n has a prime factor 
	# greater than sqrt(n) 
	# (There can be at-most 
	# one such prime factor) 
	if (n > 1): 
		result -= int(result / n); 
	return result; 


n=int(input())

print(euler_phi(n))



Measured memory_bytes: 5596
package main

import (
	"fmt"
)

func main() {
	var n, ac, wa, tle, re int
	var m string
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&m)
		switch m {
		case "AC":
			ac++
		case "WA":
			wa++
		case "TLE":
			tle++
		case "RE":
			re++
		}
	}
	fmt.Printf("AC x %d\n", ac)
	fmt.Printf("WA x %d\n", wa)
	fmt.Printf("TLE x %d\n", tle)
	fmt.Printf("RE x %d\n", re)
}

Measured memory_bytes: 6328
x = int(input())

beki_list = []
for i in range(1, 32): # ベース
    for j in range(2, 10): # ベースにべき乗する数
        beki = i**j
        if beki <= 1000:
            beki_list.append(beki)


# 存在する1000以下のべき乗数を、大きい順に比較していく
beki_list.sort(reverse=True)

for beki in beki_list:
    if beki <= x:
        print(beki)
        exit()

Measured memory_bytes: 3060
a,b,c=[int(i) for i in input().split()]
m,n=b-a,c-b
a,b,c=[int(i) for i in input().split()]
o,p=b-a,c-b
if m!=o or n!=p:
    print('No')
    exit()
m,n=o,p
a,b,c=[int(i) for i in input().split()]
o,p=b-a,c-b
if m!=o or n!=p:
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 3064
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int h, w, k, c = 0;
    cin >> h >> w >> k;
    char grid[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') c++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1<<h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            set <pair <int, int>> s;
            for (int a = 0; a < h; a++) {
                if ((1<<a)&i) {
                    for (int x = 0; x < w; x++) {
                        if (grid[a][x] == '#') s.insert ({a, x});
                    }
                } 
            }
            for (int a = 0; a < w; a++) {
                if ((1<<a)&j) {
                    for (int x = 0; x < h; x++) {
                        if (grid[x][a] == '#') s.insert({x, a});
                    }
                }
            }
            if (c-(int)s.size() == k) ans++;
        }
    }
    cout << ans;
    return 0;
}




Measured memory_bytes: 3644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n, m, a, b;
set<int> es[200000], esr[200000];

int main(int argc, char **argv) {
	cin >> n >> m;
	REP(i, m) {
		cin >> a >> b;
		--a; --b;
		es[a].insert(b);
		esr[b].insert(a);
	}
	bool res = false;
	FOR(i, 1, n - 1) if (es[0].count(i) > 0 && esr[n - 1].count(i) > 0) res = true;
	cout << (res ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 37760
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
use std::cmp::*;
fn main() {
    input! {
        n:usize,
        m:i32,
        q:i32,
        abcd:[(Usize1,Usize1,i32,i32);q]
    }
    let mut ans = 0;
    let mut A: Vec<i32> = vec![1; n];
    A[n - 1] = 0;

    let mut ans = 0;
    while next(&mut A, n, m) {
        let mut tmp = 0;
        for &(a, b, c, d) in abcd.iter() {
            if A[b] - A[a] == c {
                tmp += d;
            }
        }
        ans = max(ans, tmp);
    }
    println!("{}", ans);
}

fn next(a: &mut Vec<i32>, n: usize, m: i32) -> bool {
    let mut i = n - 1;
    while a[i] == m {
        if i == 0 {
            return false;
        } else {
            i -= 1;
        }
    }
    a[i] += 1;
    for j in i + 1..n {
        a[j] = a[i];
    }
    true
}


Measured memory_bytes: 2124
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};


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

	int n, k;
	cin >> n >> k;

	vector<int> x(n);

	rep(i,n){
		cin >> x[i];
	}

	int res = LINF;

	for(int i = 0; i + k - 1 < n; ++i){
		if(x[i+k-1] <= 0){
			chmin(res, abs(x[i]));
		}else if(x[i] >= 0){
			chmin(res, x[i+k-1]);
		}else{
			chmin(res, abs(x[i]) + abs(x[i+k-1]) + min(abs(x[i]), abs(x[i+k-1])));
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

template<typename T> T GCD(T a, T b)
{
    if(b == 0) return a;
    return GCD(b, a % b);
}

template<typename T> T LCM(T a, T b)
{
    T g = GCD(a, b);
    return a / g * b;
}

template<typename T> class SegmentTree 
{
    private:
        vector<T> node;
        int N = 1;
        T v = 1;
    public:
        SegmentTree() = default;
        SegmentTree(int sz, T init_val)
        {
            while(N < sz) N *= 2;
            v = init_val;
            node.assign(2 * N - 1, v);
        }
        void update(int k, T x)
        {
            k += N - 1;
            node[k] = x;
            while(k > 0)
            {
                k = (k - 1) / 2;
                node[k] = GCD(node[2 * k + 1], node[2 * k + 2]);
            }
        }
        T query(int s, int t, int k, int l, int r)
        {
            if(r <= s or t <= l) return v;
            if(s <= l and r <= t) return node[k];
            int mid  = (l + r) / 2;
            T a = query(s, t, 2 * k + 1, l, mid);
            T b = query(s, t, 2 * k + 2, mid, r);
            return GCD(a, b);
        }
        T query(int s, int t) { return query(s, t, 0, 0, N); }
};

void solve()
{
    ll n; cin >> n;
    vector<ll> A(n);
    ll lcm = 1LL;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
        lcm = LCM(lcm, A[i]);
    }
    SegmentTree<ll> seg(n, lcm);
    for(int i = 0; i < n; i++)
    {
        seg.update(i, A[i]);
    }
    ll ans = seg.query(0, n);

    for(int i = 0; i < n; i++)
    {
        ll tmp = A[i];
        seg.update(i, lcm);
        ans = max(ans, seg.query(0, n));
        seg.update(i, tmp);
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main(){
	int R;
	cin>>R;
	if(R<1200){
		cout<<"ABC"<<endl;
		return 0;
	}
	else if(R<2800){
		cout<<"ARC"<<endl;
		return 0;
	}
	else{
		cout<<"AGC"<<endl;
	}
	return 0;
}

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

int A, B, C;

int main(void) {
    cin >> A >> B >> C;
    
    if (C > A + B) {
        cout << (A + B + 1) + B << endl;
    } else {
        cout <<C + B << endl;
    }
    return 0;
}


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

        signed main() {
            int n,a;
            cin>>n;
            pair<int,int> x[n];
            for(int i=0;i<n;i++){
                cin>>a;
                x[i]=make_pair(a,i);
            }

            sort(x,x+n);
            int ans[n];
            for(int i=0;i<n;i++){
                if(i<n/2)ans[x[i].second]=x[n/2].first;
                else ans[x[i].second]=x[n/2 -1].first;
            }
            for(int i=0;i<n;i++)cout<<ans[i]<<endl;



         return 0;

        }


Measured memory_bytes: 6912
n,x,y=map(int,input().split())
k=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        k[min(j-i,abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)-1]+=1
for i in range(n-1):
    print(k[i])

Measured memory_bytes: 79668
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second

int n,d;
int x[100][100];
signed main(){
	cin >> n >> d;
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= d ; j ++)
			cin >> x[i][j];
	int ans = 0;
	for(int i = 1 ; i < n ; i ++)
		for(int j = i + 1; j <= n ; j ++){
			int cur = 0;
			for(int k = 1 ; k <= d ; k ++)
				cur += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			int k_ = sqrt(cur);
			if(cur == k_*k_) ans ++;
		}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;   
}

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }
    else if(abs(a-b)<=d&&abs(b-c)<=d){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }

}




Measured memory_bytes: 256
S = input()


def is_mirror_string(str):
    if len(str) % 2 != 0:
        return False
    else:
        i = int(len(str)/2)
        if str[0:i] == str[i:]:
            return True
        else:
            return False


def mirror_string_length(str):
    s = str[0:-1]
    while len(s):
        if is_mirror_string(s):
            return len(s)
        else:
            s = s[0:-1]
    return 0


print(mirror_string_length(S))


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

int main() {
	long long N, K, MOD = 924844033;
	cin >> N >> K;
	long long A = (N - 1) / K, B = N / K - 1;
	vector<vector<vector<long long> > > DP(A + 1, vector<vector<long long> >((A + 1) / 2 + 1, vector<long long>(2, 0)));
	DP[0][0][0] = 1;
	for (int i = 0; i < A; i++) {
		for (int j = 0; j <= (A + 1) / 2; j++) {
			DP[i + 1][j][0] = (DP[i + 1][j][0] + DP[i][j][0] + DP[i][j][1]) % MOD;
			if (j < (A + 1) / 2) DP[i + 1][j + 1][1] = (DP[i + 1][j + 1][1] + DP[i][j][0]) % MOD;
		}
	}
	vector<long long> CA(DP[0].size()), CB(DP[0].size());
	for (int i = 0; i < DP[0].size(); i++) {
		CA[i] = (DP[A][i][0] + DP[A][i][1]) % MOD;
		CB[i] = (DP[B][i][0] + DP[B][i][1]) % MOD;
	}
	vector<long long> COUNT(N + 1, 0);
	COUNT[0] = 1;
	for (int i = 0; i < 2 * (1 + (N - 1) % K); i++) {
		for (int j = N; j >= 0; j--) {
			for (int k = 1; k < CA.size() && j + k <= N; k++) {
				COUNT[j + k] = (COUNT[j + k] + COUNT[j] * CA[k]) % MOD;
			}
		}
	}
	for (int i = 0; i < 2 * (K - 1 - (N - 1) % K); i++) {
		for (int j = N; j >= 0; j--) {
			for (int k = 1; k < CB.size() && j + k <= N; k++) {
				COUNT[j + k] = (COUNT[j + k] + COUNT[j] * CB[k]) % MOD;
			}
		}
	}
	long long ANS = 0, NOW = 1;
	for (int i = 0; i <= N; i++) {
		long long C = (COUNT[N - i] * NOW) % MOD;
		if (i % 2 == N % 2) ANS = (ANS + C) % MOD;
		else ANS = (ANS - C + MOD) % MOD;
		NOW = (NOW * (i + 1)) % MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 109824
/*************************
author : coldbeer
2019-05-21 11:32:43 AM IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

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

	int n,k; cin >> n >> k;
	string str; cin >> str;
	
	int i = 0;
	while(i < k - 1) i++;
	str[i] += 32;
	cout << str << endl;
	return 0;
}


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

using namespace std;
typedef long long int lld;
#define INF 1000000000000000000
#define MOD 1000000007
lld DP[200000][400];
int n,k;
int arr[400];
/*lld compute(int left,int pos){//cout<<a<<" "<<b<<" "<<c<<endl;
	//cout<<left<<" "<<pos<<endl;
	if(pos==0 && left>0)return 0;
	if(DP[left][pos]!=-1)return DP[left][pos];
	DP[left][pos]=0;
	for(int i=0;i<=arr[pos-1];i++){
		if(left-i>=0)DP[left][pos]+=compute(left-i,pos-1);
	}
	DP[left][pos]%=MOD;
	return DP[left][pos];
}*/
lld accumulate[200000][400];
void solve(int pos){
	if(pos==0)return;
	solve(pos-1);
	lld sum=0;
	for(int i=0;i<=k;i++){
		sum+=DP[i][pos-1];
		DP[i][pos]=sum%MOD;
		if(i>=arr[pos-1])sum-=DP[i-arr[pos-1]][pos-1];
	}
}
int main(){
	cin>>n>>k;
	
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	for(int i=0;i<=k;i++){
		for(int j=0;j<=n;j++)DP[i][j]=0;
	}
	DP[0][0]=1;
	solve(n);
	/*for(int i=0;i<=k;i++){
		for(int j=0;j<=n;j++)cout<<DP[i][j]<<" ";
		cout<<endl;
	}*/
	cout<<DP[k][n]<<endl;
	
	return 0;
}

Measured memory_bytes: 313728
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define SZ(v)      ((int)(v).size())
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

struct UnionFind{
	vi par;		//par[i]:=(0以上の場合iの親, 0未満の場合はiを含むグループのサイズ).
	int num;	//num:=(グループの数).
	
	UnionFind(int n):par(n,-1),num(n){}//constructor.
	
	void init(){fill(ALL(par),-1), num=par.size();}
	int root(int x){return (par[x]<0)?x:par[x]=root(par[x]);}//recrusion.
	int size(int x){return -par[root(x)];}
	bool same(int x,int y){return root(x)==root(y);}
	bool unite(int x,int y){
		x=root(x), y=root(y);
		if(x==y) return false;//Do nothing.
		if(size(x)<size(y)) swap(x,y);//merge technique(y to x).
		par[x]+=par[y];
		par[y]=x;
		num--;
		return true;
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	
	UnionFind uf(n);
	REP(i,m){
		int a,b;
		cin>>a>>b;
		a--, b--;
		uf.unite(a,b);
	}
	
	int ans=0;
	REP(i,n) ans=max(ans,uf.size(i));
	
	cout<<ans<<endl;
}

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

int main(void){
    int N;
    int d[200];
    int count = 0;

    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    int d_uni[200];

    for (int i = 0; i < N; i++){
        for (int j = i+1; j < N; j++){
            if(d[i] == d[j]) d[j]=0;
        }
    }

    for (int i = 0; i < N; i++){
     if(d[i] != 0) count++;
    }

    cout << count << endl;
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int calc(ll a){
  int ans=0;
  while(a%2==0){
    a/=2;
    ans++;
  }
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
    A.at(i)/=2;
  }

  int cnt=calc(A.at(0));
  rep(i,N){
    if(cnt != calc(A.at(i))){
      cout << 0 << endl;
      return 0;
    }
  }

  ll x=1;
  rep(i,N)  x=lcm(x,A.at(i));
  cout << M/x - M/(2*x) << endl;

  return 0;
}

Measured memory_bytes: 3992
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var L1 = input[0].map(e => (parseInt(e, 10)));
  var N = L1[0];
  var M = L1[1];
  var X = L1[2];
  var arr_CA = [];
  for (var i = 0; i < N; i++){
    arr_CA.push(input[i + 1].map(e => (parseInt(e, 10))));
  }
  var tmpRikaido = Array.from({ length: M }, () => 0); 
  var tmpAchievement = Array.from({ length: M }, () => false); 
  var tmpBookList = Array.from({ length: N }, () => 0); 
  var tmpPrice = 0;
  var tmp = 0;
  var ans = -1;
  for (var i = 0; i < Math.pow(2, N); i++){
    tmpRikaido = Array.from({ length: M }, () => 0); 
    tmpAchievement = Array.from({ length: M }, () => false); 
    tmpBookList = Array.from({ length: N }, () => 0); 
    tmpPrice = 0;
    tmp = i;
    for (var j = (N - 1); j >= 0; j--){
      tmpBookList[j] = (tmp / Math.pow(2,j) | 0);
      tmp -= Math.pow(2,j) * tmpBookList[j];
      if (tmpBookList[j]) {
        tmpPrice += arr_CA[j][0];
        for (var k = 0; k < M; k++){
          tmpRikaido[k] += arr_CA[j][k + 1];
          if (tmpRikaido[k] >= X) tmpAchievement[k] = true;
        }
      }
    }
    if (tmpAchievement.indexOf(false) === -1) {
      if ((ans === -1) || (ans > tmpPrice)) ans = tmpPrice;
    }
  }
  console.log(ans);
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34252
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();


    LL t,n,i,j,k,x,y,c,m;
    LL a, b;
    cin >> a >> b;
    LL res = 0;
    LL origa = a;
    LL sum = 1;
    i = 0;
    if(b == 1){
        cout << 0;
        return 0;
    }
    while(sum < b){
        ++res;
        if(i > 0)sum += origa - 1;
        else{
            sum = origa;
        }
        ++i;

    }
    cout << res;
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
  int n;
  string s;
  cin>>n>>s;
  int a=0;
  for(int i=0;i<n;++i){
    int t=0;
    for(int j=0;j<n-i;++j){
      t=(t+1)*(s[j]==s[j+i]);
      a=max(a,min(t,i));
    }
  }
  cout<<a;
}

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

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

  int a, b, c, x;
  int sum = 0;
  int res = 0;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;

  REP(i, a + 1) {
    REP(j, b + 1) {
      REP(k, c + 1) {
        sum = 500 * i + 100 * j + 50 * k;
        if(sum == x) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut edges = vec![vec![]; n + 1];
    for edge_id in 0..n - 1 {
        let vertex_a = get!(usize);
        let vertex_b = get!(usize);
        edges[vertex_a].push((vertex_b, edge_id));
        edges[vertex_b].push((vertex_a, edge_id));
    }
    let color_count = edges
        .iter()
        .map(Vec::len)
        .max()
        .unwrap();
     
     let mut edge_color = vec![0; n - 1];
     
     let mut dfs_stack = vec![(0, 1)];
     
     while let Some((used_color_id, vertex)) = dfs_stack.pop() {
         let mut color_id = 1;
         for &(end_vertex, edge_id) in &edges[vertex] {
             if edge_color[edge_id] != 0 {
                 continue;
             }
             if color_id == used_color_id {
                 color_id += 1;
             }
             edge_color[edge_id] = color_id;
             dfs_stack.push((color_id, end_vertex));
             color_id += 1;
         }
     }
     
     println!("{}", color_count);
     for color_id in edge_color {
         println!("{}", color_id);
     }
}

Measured memory_bytes: 16764
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (A, B, K) = get!(usize, usize, usize);

    let (t, a) = (0..K).fold(
        (A, B),
        |(a, b), k| if k % 2 == 0 {
            (a / 2, b + a / 2)
        } else {
            (a + b / 2, b / 2)
        }
    );

    println!("{} {}", t, a);
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

// ll fact[nax], invfact[nax];

// void pre()
// {
// 	fact[0] = 1;
// 	forn(i, 1, nax)
// 	{
// 		fact[i] = mult(fact[i - 1], i);
// 	}

// 	invfact[nax - 1] = mypow(fact[nax - 1], mod - 2);

// 	ford(i, nax, 1)
// 	{
// 		invfact[i - 1] = mult(invfact[i], i);
// 	}
// }

// ll ncr(ll n, ll r)
// {
// 	if (r > n)
// 		return 0;

// 	ll ans = mult(fact[n], mult(invfact[n - r], invfact[r]));

// 	return ans;
// }

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll n,m;
		cin>>n>>m;

		ll a[3];
		a[0] = a[1] = a[2] = -1;

		ll s,c;
		string res = "";
		bool ok = 1;
		forn(i,0,m)
		{
			cin>>s>>c;

			if(a[s-1] == -1)
			{
				a[s-1] = c;
			}
			else
			{
				if(c == a[s-1])
				{
					continue;
				}
				else
				{
					ok = 0;
					//cout<<-1;
					//return 0;
				}
			}
		}

		// if(a[0] == -1)
		// 	a[0] = 1;
		// if(a[1] == -1)
		// {
		// 	a[1] = 0;
		// }
		// if(a[2] == -1)
		// {
		// 	a[2] = 0;
		// }

		if(n == 1)
		{
			if(ok)
			{
			if(a[0] == -1)
			{
				cout<<0;
			}
			else
			{
				cout<<a[0];
			}
			}
			else
			{
				cout<<-1;
			}
		}
		else
		{
			if(a[0] == 0)
			{
				cout<<-1;
			}
			else
			{
				if(a[0] == -1)
				{
					a[0] = 1;
				}
				if(a[1] == -1)
				{
					a[1] = 0;
				}
				if(a[2] == -1)
				{
					a[2] = 0;
				}

				if(ok)
				{
					forn(i,0,n)
					{
					cout<<a[i];
					}
				}
				else
				{
					cout<<-1;
				}
			}
		}
	}

	return 0;
}

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

int main()
{
    int a, ans = 0;
    std :: cin >> a;
    for (int i = 1; i <= a; i++) {
        int count = 0, num = i;
        while (num != 0) {
            count++;
            num /= 10;
        }
        if (count % 2 == 1) ans++;
    }
    std :: cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

template<typename T>
class TopologicalSort {
private:
    map<T, bool> is;
    map<T, vector<T>> g;
    vector<T> tsort;
	map<T, long long> inCnt;
    void dfs(T now) {
        if (is[now]) return;
		is[now] = true;
        for (auto &&el : g[now]) {
            dfs(el);
        }
        tsort.emplace_back(now);
    }
public:
    TopologicalSort() {}
	TopologicalSort(const vector<T>& vec) {
		for (auto &&el : vec) {
			g[el].resize(0);
			is[el] = false;
			inCnt[el] = 0;
		}
	}
    vector<T> dfsTsort() {
        for (auto &&el : g) {
            dfs(el.first);
        }
        reverse(tsort.begin(), tsort.end());
        return tsort;
    }
	void addEdge(T src, T dst) {
		g[src].emplace_back(dst);
		inCnt[dst]++;
	}
	vector<T> bfsTsort() {
		queue<T> q;
		for (auto &&el : inCnt) {
			if (el.second == 0) {
				q.push(el.first);
			}
		}
		while (!q.empty()) {
			T now = q.front(); q.pop();
			tsort.emplace_back(now);
			for (auto &&el : g[now]) {
				if (--inCnt[el] == 0) q.push(el);
			}
		}
		bool endFlag = true;
		for (auto &&el : inCnt) {
			if (el.second) endFlag = false;
		}
		return (endFlag ? tsort : vector<T>());
	}
};

int main(void) {
	int V, E;
	cin >> V >> E;
	VI v(V);
	iota(ALL(v), 0);
	TopologicalSort<int> t(v);
	REP(_, E) {
		int s, d;
		cin >> s >> d;
		t.addEdge(s, d);
	}
	auto ans = t.bfsTsort();
	FORE(el, ans) cout << el << endl;
}

Measured memory_bytes: 5432
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  priority_queue<P,vector<P>,greater<P> > Q1;
  priority_queue<P> Q2;
  P a[100000];
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i].second>>a[i].first;

  sort(a,a+n);
  reverse(a,a+n);
  int sm=0,cnt[100001]={},sh=0;
  for(int i=0;i<k;i++){
    sm+=a[i].first;
    if(cnt[a[i].second]==0)sh++;
    cnt[a[i].second]++;
    Q1.push(a[i]);
  }


  
  for(int i=k;i<n;i++){
    Q2.push(a[i]);
  }

  int ans=sm+sh*sh;

  while(!Q1.empty()&&!Q2.empty()){
    while(!Q1.empty()&&cnt[Q1.top().second]<=1)Q1.pop();
    while(!Q2.empty()&&cnt[Q2.top().second])Q2.pop();
    if(Q1.empty()||Q2.empty())break;
    P x=Q1.top(); 
    P y=Q2.top(); 
    Q1.pop();
    Q2.pop();
    sm=sm-x.first+y.first;
    cnt[x.second]--,cnt[y.second]++;
    sh++;
    ans=max(ans,sm+sh*sh);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define ll 				long long
#define vi 				vector<ll>
#define vb 				vector<bool>
#define vvi				vector<vi>
#define vvb				vector<vb>
#define vii				vector<pair<ll,ll>>
#define pii				pair<ll,ll>
#define mii 			map<ll,ll>
#define rev(a); 		reverse(a.begin(), a.end());
#define sortv(a); 		sort(a.begin(), a.end());
#define sortd(a); 		sort(a.begin(), a.end(), greater<int>());
#define FOR(i,a,b) 		for (int i = (a); i < (b); i++)
#define ROF(i,a,b) 		for (int i = (b)-1; i >= (a); i--)
#define pb 				push_back
#define mp 				make_pair
#define printv(a);		FOR(_Q,0,(int)(a).size())cout<<(a)[_Q]<<" ";cout<<'\n';
#define IOS 			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

void solve();

ll MOD = 1000000007;
ll INF = LLONG_MAX;

/*****************************************************************************/
const int k = 2019;
signed main() {
	IOS;
	string s;cin>>s;
	int n = (int)s.length();
	ll out = 0;
	ll dong = 1;
	vi locs(k);
	vi u(n+1);
	ROF(i,0,n) {
		int add=(s[i]-'0')*dong%k;
		u[i]=(u[i+1]+add)%k;
		dong*=10;
		dong%=k;
	}
	ROF(i,0,n+1) {
		out+=locs[u[i]];
		locs[u[i]]++;
	}
	cout<<out;
}

Measured memory_bytes: 5052
#include<iostream>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
using namespace std;

vector<int> encode(int,int);
void encode_rec(int&,const int, vector<int>&);

vector<int> encode(int num, int r){
	vector<int> v;
	encode_rec(num,r,v);
	return v;
}
void encode_rec(int& num,const int r, vector<int> &v){
	if(num==0)
		return;
	v.push_back(num%r);
	num=(num-num%r)/r;
	encode_rec(num,r,v);
}


int main(){
	int N;
	cin >> N;
	int min = 10000000;
	for(int i=0;i<=N;i++){
		int num6=i;
		int num9=N-i;
		vector<int> v1=encode(num6,6);
		vector<int> v2=encode(num9,9);
		int sum = 0;
		for(auto it=v1.begin();it!=v1.end();++it)
			sum+=(*it);
		for(auto it=v2.begin();it!=v2.end();++it)
			sum+=(*it);
		if(sum<min)
			min=sum;
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
var
  s: array [0..200000] of int64;
  n, i: longint;
  x, ans: int64;
function min(x, y: int64): int64; inline;
begin
  if x < y then exit(x) else exit(y);
end;
begin
  read(n);
  for i := 1 to n do
  begin
    read(x);
    s[i] := s[i - 1] + x;
  end;
  ans := 1000000000000000000;
  for i := 1 to n - 1 do ans := min(ans, abs(s[i] shl 1 - s[n]));
  writeln(ans);
end.


Measured memory_bytes: 1664
#include <stdio.h>

int BinarySearch(int);
int S[100000],n;

int main(){
  int i,q,T,sum = 0;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T);
    if( BinarySearch(T) ) sum++;
  }
  
  printf("%d\n",sum);

  return 0;
}

int BinarySearch(int key){
  int left = 0;
  int right,mid;
  right = n;
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key){
      return 1;
    }
    else if(S[mid] < key){
      left = mid+1;
    }
    else if(S[mid] > key){
      right = mid;
    }
  }
  return 0;
}



Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N,C,K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    rep(i,N) cin >> T[i];
    sort(T.begin(),T.end());
    ll ans = 0;
    for(int i=0;i<N;i++){
        ll st = i;
        while(i<N && T[i]-T[st]<=K && i-st<C) i++;
        // whileを抜けた時点ではiは次のバスの先頭なので次ループに移る前に調整する
        i--;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string a, b, c; cin >> a >> b >> c;
  int ai = 0, bi = 0, ci = 0;
  bool aok = true, bok = false;
  while (true) {
    if (aok) {
      if (ai == a.length()) {
        cout << "A" << "\n";
        return 0;
      }
      if (a[ai] == 'b') {
        aok = false;
        bok = true;
      } else if (a[ai] == 'c') {
        aok = false;
        bok = false;
      }
      ++ai;
    } else if (bok) {
      if (bi == b.length()) {
        cout << "B" << "\n";
        return 0;
      }
      if (b[bi] == 'a') {
        aok = true;
        bok = false;
      } else if (b[bi] == 'c') {
        aok = false;
        bok = false;
      }
      ++bi;
    } else {
      if (ci == c.length()) {
        cout << "C" << "\n";
        return 0;
      }
      if (c[ci] == 'a') {
        aok = true;
        bok = false;
      } else if (c[ci] == 'b') {
        aok = false;
        bok = true;
      }
      ++ci;
    }
  }
}


Measured memory_bytes: 256
K, N = gets.split.map!(&:to_i)
A = gets.split.map!(&:to_i)

longest = A[0] + (K - A[-1])
1.upto(N-1) do |i|
  d = A[i] - A[i-1]
  longest = d if longest < d
end

puts K - longest


Measured memory_bytes: 13828
#include <iostream>
using namespace std;
int main(void){
   string S,T;
   cin>>S>>T;
   int A,B;
   cin>>A>>B;
   string U;
   cin>>U;
   if(S==U){
       cout<<A-1<<" "<<B<<endl;
   }
   else {
       cout<<A<<" "<<B-1<<endl;
   }
}


Measured memory_bytes: 256
n=int(input())
boulist=list(map(int,input().split()))
boulist.sort(reverse=True)

count=0
for i in range(n):
  for j in range(0,i):
    for k in range(0,j):
      if boulist[j] != boulist[k] and boulist[i] != boulist[j] and boulist[i]+boulist[j]>boulist[k]:
        count+=1

print(count)




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

int main(){
  int64_t A,B,C;
  cin>>A>>B>>C;
  bool Q=false;
  for(int i=1;i<10000000;i++){
    if((A*i)%B==C){
      Q=true;
      break;
    }
  }
  if(Q){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}
  
  
      


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

#define fast()           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(dat)         dat.begin(), dat.end()
#define loop(i, to)      for (int i = 0; i < to; i++)
#define count(i, to)     for (int i = 1; i <= to; i++)
#define foreach(dat, i)  for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); i++)

typedef long long        num;

using namespace std;

int n, pr[100005];



pair<int, int> x[100005], y[100005];

struct triple {
    
    int d, a, b;
    
    triple(int i, int j, int k) {
        
        d = k;
        
        a = i;
        
        b = j;
        
    }
    
};

vector<triple> edge;

inline int root(int a) {
    
    if (pr[a] == a)  return a;
        
    return pr[a] = root(pr[a]);
    
}

inline void combine(int a, int b) {
    
    int pa = root(a), pb = root(b);
    
    pr[pb] = pa;
    
}

inline bool cmp(triple a, triple b) {
    
    return a.d < b.d;
    
}

int main() {
    
    register int ans = 0;
    
    cin >> n;
    
    loop (i, n) {
        
        int a, b;
        
        cin >> a >> b;
        
        x[i] = {a, i};
        
        y[i] = {b, i};
        
        pr[i] = i;
        
    }
    
    sort(x, x + n);
    
    sort(y, y + n);
    
    loop (i, n - 1) {
        
        edge.push_back(triple(x[i].second, x[i + 1].second, abs(x[i].first - x[i + 1].first)));
        
        edge.push_back(triple(y[i].second, y[i + 1].second, abs(y[i].first - y[i + 1].first)));
        
    }
    
    sort(all(edge), cmp);
    
    loop (i, edge.size()) {
        
        triple tmp = edge[i];
        
        int pa = root(tmp.a), pb = root(tmp.b);
        
        if (pa != pb) {
            
            ans += tmp.d;
            
            combine(tmp.a, tmp.b);
            
        }
        
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;
    string T = S.substr(0, N / 2);
    cout << (S == T + T ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,ans;
    ans=0;
    cin>>a>>b;
    ans=a+b;
    while(1){
        i=a%b;
        if(i==0)
        break;
        a=b;
        b=i;
    }
    ans=ans-b+1;
    cout<<ans<<endl;
    
    
}



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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    if (n % 2 == 1) cout << 0 << '\n';
    else {
        ll ans = 0;
        n /= 2;
        while (n) {
            ans += n / 5;
            n /= 5;
        }
        cout << ans << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 
 int factorial(int n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
 }
int main(){
    int n;
    cin>>n;
    string p,q;
    pan(i,n){
        int a;
        cin>>a;
        p+=to_string(a);
    }
    pan(i,n){
        int a;
        cin>>a;
        q+=to_string(a);
    }
    bool val;
    long int siz=factorial(n);
    long int ans=0;
    string w,r;
    if(p>q){ w=q;r=p;}
    else {w=p;r=q;}
    for(int i=0;i<siz;i++){
        if(w==r){
            break;
        }
        else{
            ans++;
        }
        val=next_permutation(w.begin(),w.end());
        
        /*if(val){
            cout<<p<<endl;
            if(p==q){
                ans++;
                break;
            }
            else{
                ans++;
            }
        }
        else break;*/
    }
    cout<<ans;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            String str = Integer.toString(scanner.nextInt(), 2);
            ans += str.length() - str.lastIndexOf("1") - 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37096
a,b = map(int, input().split())
ans = 0
if a>b:
    ans += a
    if a-1 > b:
        ans += a-1
    else:
        ans += b
else:
    ans += b
    if b-1 > a:
        ans += b-1
    else:
        ans += a
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

// Node(parent)
int Node[10000] = {};

int same(int x, int y){
    int x_i = x,y_i = y;
    while (x_i != Node[x_i]) {
        x_i = Node[x_i];
    }
    while (y_i != Node[y_i]) {
        y_i = Node[y_i];
    }
    
    if (x_i - y_i) {
        return 0;
    }else{
        return 1;
    }
}

void unite(int x, int y){
    
    if (same(x,y) == 1) {
        return;
    }
    
    int x_i = x,y_i = y;
    while (x_i != Node[x_i]) {
        x_i = Node[x_i];
    }
    while (y_i != Node[y_i]) {
        y_i = Node[y_i];
    }
    
    Node[y_i] = x_i;
}

int main(){
    INT(n);
    INT(q);
    REP1(i,n) Node[i] = i;
    REP1(i,q){
        INT(com);INT(x);INT(y);
        if (com) {
            printf("%d\n",same(x,y));
        }else{
            unite(x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 1224
// AtCoder Beginner Contest 121 - Problem D: XOR World (https://atcoder.jp/contests/abc121/tasks/abc121_d)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

// hs[i] = número de ocorrências do valor 1 no bit i dos números 1, 2, ..., N
// xorN = 1 ^ 2 ^ ... ^ N
ll xorN(ll N)
{
    if (N == 0)
        return 0;

    vector<int> hs(64, 0);

    for (int k = 60; k >= 0; --k)
    {
        ll mask = (1LL << k);

        if (mask > N)
            continue;

        // Todos os números até a maior potência de 2 menor que N tem k-ésimo bit
        // ligado
        hs[k] += (N - mask + 1);

        // Os números até a maior potência de 2 menos 1 distribuem o mesmo número
        // de 1s em todas as posições
        for (int j = 0; j < k; ++j)
            hs[j] += (mask / 2);

        N -= mask;
    }

    ll ans = 0;

    for (int k = 60; k >= 0; --k) 
    {
        if (hs[k] % 2)
            ans += (1LL << k);
    }

    return ans;
}

ll solve(ll A, ll B)
{
    return xorN(A - 1) ^ xorN(B);
}

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

    ll A, B;
    cin >> A >> B;

    auto ans = solve(A, B);

    cout << ans << '\n';

    return 0;
}


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

int selectionSort( int num[], int n ){
 int count = 0;
 for( int i=0; i<n; i++ ){
   int min = i;
   for( int j=i; j<n; j++ ){
    if( num[j] < num[min] ){
      min = j;
    }
   }
   if( i!=min ){
    swap( num[i], num[min] );
    count++;
   }
 }

 return count;
}

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

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

 int s_count = selectionSort( num, n );

 for( int i=0; i<n; i++ ){
  if( i!=n-1 ){
    cout << num[i] << " ";
  }else{
    cout << num[i] << endl;
  }
 }

 cout << s_count << endl;

 return 0;
}


Measured memory_bytes: 3092