akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int i, n, x,m[110];
	cin >> n >> x;
	int totalcost = 0;
	rep(i, n) {
		cin >> m[i];
		totalcost += m[i];
	}
	x -= totalcost;
	int mincost = INF;
	rep(i, n) {
		mincost = min(mincost, m[i]);
	}
	int ans = n;
	cout << ans + x / mincost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a) ;i < (b) ;i++)
#define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) 
int main(){
	int N, a[100001] ;
	int ans = 0 ;
	cin >> N ;
	rep(i, 1, N + 1)cin>>a[i] ;
	rep(i, 1, N + 1)
		if (a[a[i]] == i)ans++ ;
	cout<<ans / 2<<endl ;
	return 0 ;
}


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

int main(){
    int n; cin >> n;
    int p = 0, q = 0;
    int ten = pow(10,n-1);
    int nump = 0, numq = 0;
    
    int w = ten;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        p += a*w; w /= 10;
    }
    w = ten;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        q += a*w; w /= 10;
    }

    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i+1;

    int num = 1;
    while(next_permutation(v.begin(), v.end())){
        int x = 0, w = ten;
        for(auto it: v){
            x += it*w; w /= 10;
        }
        if(p == x) nump = num;
        if(q == x) numq = num;
        num++;
    }
    
    cout << abs(nump - numq) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
 int a,b;
 cin >> a >> b;
 if(a%3==0||b%3==0||(a+b)%3==0){
  cout << "Possible" << endl;
 }else{
  cout << "Impossible" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    i = 0
    while (i + 1) ** 2 <= N:
        i += 1
    print(i ** 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62728
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

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

	if (S[K - 1] == 'A') {
		S[K - 1] = 'a';
	}
	if (S[K - 1] == 'B') {
		S[K - 1] = 'b';
	}
	if (S[K - 1] == 'C') {
		S[K - 1] = 'c';
	}

	cout << S << endl;


	return 0;
}

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

int main(){
    ll n, k;
    cin >> n >> k;
    ve<P> dt(n);
    ve<ll> fl(n,0);
    rep(i,n) {
        cin >> dt[i].second >> dt[i].first;
        dt[i].second--;
    }
    sort(dt.rbegin(), dt.rend());
    ll ans = 0;
    ll cnt = 0;
    ve<P> kouho;
    rep(i,k){
        ans += dt[i].first;
        if(fl[dt[i].second] == 0) cnt++;
        else kouho.push_back(dt[i]);
        fl[dt[i].second] += 1;
    }
    ans += cnt*cnt;
    ve<ll> x;
    x.push_back(ans);
    ll i = k;
    while(i<n && !kouho.empty()){
        if(fl[dt[i].second] != 0){
            i++;
            continue;
        }
        sort(kouho.begin(), kouho.end());
        ans -= cnt*cnt;
        ans -= kouho[0].first;
        kouho.erase(kouho.begin());
        cnt++;
        ans += cnt*cnt;
        ans += dt[i].first;
        fl[dt[i].second] = 1;
        x.push_back(ans);
        i++;
    }
    sort(x.rbegin(), x.rend());
    cout << x[0] << endl;
    return 0;
}


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

#define MAXN 1001
#define MAXV 100001
#define INF INT_MAX-1

using namespace std;

int n, v,val[MAXN], memo[MAXV];

int solve(int value){
    if (value == 0)
        return 0;
    if (value < 0)
        return INF;
    if (memo[value] != -1)
        return memo[value];
    int best=INF;
    for(int i = 0; i < n; ++i)
        best=min(best,1+solve(value-val[i]));
    return memo[value] = best;
}

int main(){
    memset(memo,-1,sizeof memo);
    n=12;
    val[0]=1;
    val[1]=6;
    val[2]=36;
    val[3]=216;
    val[4]=1296;
    val[5]=7776;
    val[6]=46656;
    val[7]=9;
    val[8]=81;
    val[9]=729;
    val[10]=6561;
    val[11]=59049;

    cin>>v;
    cout<<solve(v)<<endl;

    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
using namespace std;
int board[100]={0};
void build_board()
{
	int c=0;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			board[c]=i*j;
			c++;
		}
	}
}
int main()
{
	build_board();
	int n;
	cin>>n;
	bool flag=0;
	for(int i=0;i<100;i++)
	{
		if(n==board[i])
		{
			cout<<"Yes"<<endl;
			flag=1;
			break;
		}
	}
	if(flag==0)
	{
		cout<<"No"<<endl;
	}
 } 

Measured memory_bytes: 256
r, c = map(int, input().split(" "))
table = []
for i in range(r):
    line = list(map(int, input().split(" ")))
    table.append(line)
for i in range(r):
    x = 0
    for j in range(c):
        x += table[i][j]
    table[i].append(x)
add_table = []
for i in range(c+1):
    y = 0
    for j in range(r):
        y += table[j][i]
    add_table.append(y)
table.append(add_table)
for i in range(r+1):
    print(*table[i])


Measured memory_bytes: 6228
/* 
 * Project: Panasonic programing Contest C - Sqrt Inequality
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

long a, b, c;

void solve() {

    long diff = c - a -b;
    long ab = (a*b) << 2;

    if (diff > 0 && diff*diff > ab)
        printf("Yes\n");
    else
        printf("No\n");

}

int main() {

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

    solve();

}


Measured memory_bytes: 3108
H,W,K = map(int,input().split())
C = [0]*H
 
for i in range(H):
    C[i] = list(str(input()))
    
 
    
def gyotsubushi(n,E):
    if I[n] == 1:
        E[n] = ['R']*W
        #print('GYO')
        
def retsutsubushi(n,E):
    if J[n] == 1:
        for i in range(H):
            E[i][n] = 'R'
stock = []
counter = 0
import copy
for i0 in range(2):
    for i1 in range(2):
        for i2 in range(2):
            for i3 in range(2):
                for i4 in range(2):
                    for i5 in range(2):
                        for j0 in range(2):
                            for j1 in range(2):
                                for j2 in range(2):
                                    for j3 in range(2):
                                        for j4 in range(2):
                                            for j5 in range(2):
                                                preI = [i0,i1,i2,i3,i4,i5]
                                                preJ = [j0,j1,j2,j3,j4,j5]
                                                I = preI[0:H]
                                                J = preJ[0:W]
                                                if I+J in stock:
                                                    break
                                                stock.append(I+J)
                                                D = copy.deepcopy(C)
                                                #print(D,I,J)
                                                for i in range(H):
                                                    gyotsubushi(i,D)
                                                for j in range(W):
                                                    retsutsubushi(j,D)
                                                #print(D)
                                                count = 0
                                                for i in range(H):
                                                    for j in range(W):
                                                        if D[i][j] == '#':
                                                            count += 1
                                                if count == K:
                                                    counter += 1
 
    
print(counter)

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

int main()
{
    int N, M, count = 0, sum = 0;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        sum += A.at(i);
    }
    for (int i = 0; i < N; i++)
    {
        if (4 * M * A.at(i) >= sum)
        {
            count++;
        }
    }
    if (count >= M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


void solve(std::string S){
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }else if (S=="Cloudy"){
    cout << "Rainy" << endl;
  }else if (S=="Rainy"){
    cout << "Sunny" << endl;
  }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  cin>>c>>a>>b;
  ll n;cin>>n;
  ll now=c;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    if(s[0]=='n')now=max(0LL,a+now);
    else if(s[0]=='k')now=0;
    else now=max(0LL,now+b);
  }
  cout<<now<<endl;
  return 0;
}



Measured memory_bytes: 3204
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;

    ll flg=0;
    for(ll i=0;i<=25;i++)
    {
    	char ch=i+'a';
    	string tp=a+ch;
    	// cout<<tp<<endl;
    	if(tp==b)
    	{
    		flg=1;
    		break;
    	}

    }
    if(flg==1)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3656
fun main(args: Array<String>) {
  val (a, b, c, x, y) = readLine()!!.split(" ").map { it.toInt() }
  if (a + b <= 2 * c) {
    println(a * x + b * y)
  } else {
    val z1 = Math.min(x, y)
    val z2 = Math.max(x, y)
    val ans = Math.min(
        2 * c * z1 + a * Math.max(x - z1, 0) + b * Math.max(y - z1, 0),
        2 * c * z2)
    println(ans)
  }
}

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

int main(){
  int N,W;
  int i,j;
  cin >> N >> W;
  vector<long> w(N);
  vector<long> v(N);
  vector<vector<long>> dp(N+1,vector<long>(W+1,0));
  for(i=0;i<N;i++)
    cin >> w[i] >> v[i];
  for(i=0;i<N;i++)
    for(j=0;j<=W;j++){
      if (j >= w[i])
        dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      else
        dp[i+1][j] = dp[i][j];
    }

  cout << dp[N][W] << endl;
  
  return 0;
}


Measured memory_bytes: 83072
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int x;

void solve(){
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3636
def dot(a, b):
    return (a.real*b.real - a.imag*b.imag)
def cross(a, b):
    return (a.real*b.imag - a.imag*b.real)

EPS = 10**(-7)

def isIntersectedLS(a1, a2, b1, b2):
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)

while 1:
    try:
        x,y = [[0. for i in xrange(3)] for j in xrange(2)]
        a = []
        z = [0. for i in xrange(2)]
        line = raw_input().split()
        if line == []: break
        x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, line)
        for i in xrange(3):
            a.append((x[i]+(y[i])*1j))
        c = (sum(x)/3)+(sum(y)/3)*1j
        p = z[0]+z[1]*1j
           
        for i in xrange(3):
            #print a, c, p
            if isIntersectedLS(a[i-1], a[i], c, p) is True:
                print "NO"
                break
        else:
            print "YES"
           
    except EOFError:
        break

Measured memory_bytes: 5440
n,*a=map(int,open(0).read().split())
dp=[[0]*n for _ in range(3)]
for i in range(n):
	if i%2:
		dp[1][i]=max(dp[2][i-3]+a[i],dp[1][i-2]+a[i])
	elif i>1:
		dp[0][i]=max(dp[0][i-2]+a[i],dp[1][i-3]+a[i],dp[2][i-4]+a[i])
		dp[2][i]=dp[2][i-2]+a[i]
	else:
		dp[2][i]=dp[2][i-2]+a[i]
print(max(dp[2][-3],dp[1][-2],dp[0][-1]) if n%2 else max(dp[1][-1],dp[2][-2]))

Measured memory_bytes: 36260
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
#define MAX 3000000
long long fac[3000000],finv[3000000],inv[3000000];

void cominit(){
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for (int i = 2;i < MAX;i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

long long com(int n,int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll x,y;
    cin >> x >> y;
    ll n = (2*x-y)/3,m = (2*y - x)/3;
    if ((x+y)% 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    if (n < 0 || m < 0){
        cout << 0 << endl;
        return 0;
    }
    cominit();

    cout << com(n+m,n) << endl;

    return 0;

}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair

void ib(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long double a,b,c;

int main(){
	
	cin >> a >> b >> c;
	if( a + b + 2 * sqrt(a*b) < c ){
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;

const int N = 7e5 + 66;
ll n, m, l, r;
ll fac[N], inv[N];
const ll mo = 1e9 + 7;
ll ksm(ll x, ll y) {
	ll res = 1;
	for(; y; y >>= 1, x=x * x % mo)
		if(y & 1) res = res * x % mo;
	return res;
}
void init(int tot) {
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= tot; ++i) {
		fac[i] = fac[i - 1] * i % mo;
		inv[i] = ksm(fac[i], mo - 2);
	}
}
ll C(int n, int m) {
	if(n < m) return 0;
	return fac[n] * inv[m] % mo * inv[n - m] % mo;
}
inline ll bs(ll x) {
	x %= mo;
	if(x < 0) x += mo;
	return x;
}
inline ll add(ll &x, ll v) {
	x += v;
	if(x >= mo) x %= mo;
}
inline ll dec(ll &x, ll v) {
	x -= v;
	if(x < 0) x += mo;
}
ll cal(ll s, ll b) {
	if(s < 0) return 0;
	ll res = 0, t = 0;
	for(int i = 0; i <= n - m && t <= s; t += b,++i) {
		ll v = C(n - m, i) * C(s - t + n, n) % mo;
		if(i & 1) dec(res, v);
		else add(res, v);
	}
	return res * C(n, m) % mo;
}
ll solve(ll s) {
	ll res = C(s + n, n);
	for(int i = 0; i * m <= s; ++i)
		dec(res, bs(cal(s - i * m, i) - cal(s - (i + 1) * m, i)));
	return res;
}
int main() {
	n = read(), m = read(), l = read(), r = read();
	init(n + r);
	writeln(bs(solve(r) - solve(l - 1)));
	return 0;
}

Measured memory_bytes: 10496
# D - Blue and Red Balls

N, K = map(int, input().split())
MOD = 10**9 + 7

# nCkを漸化式で求め、メモしておく
combinations_table = [[0]*(N+1) for _ in range(N+1)]
for idx in range(N+1):
    combinations_table[0][idx] = 1
    combinations_table[idx][0] = 1
    combinations_table[idx][1] = idx
for n in range(2, N+1):
    for k in range(2, n+1):
        combinations_table[n][k] = combinations_table[n-1][k-1] + combinations_table[n-1][k]

# 連続した同色のボールの数nと、それらを何分割するか示すaを与えると、分割のパターン数を返す関数
def separate_balls(n,a):
    return combinations_table[n-1][a-1]

# 青いボールを先に並べると赤いボールが両端にあるかどうかで場合分けが必要
# 赤いボールの隙間か両端から一部を選んで青いボールを挿入すれば場合分けが少なくて済む
ans_list = []
for n_separate in range(1,K+1):
    if n_separate > K:
        ans_list.append(0)
    else:
        tmp_insert = combinations_table[N-K+1][n_separate]
        tmp_blue_group = separate_balls(K, n_separate)
        ans_list.append((tmp_insert * tmp_blue_group) % MOD)

for x in ans_list:
    print(x)

Measured memory_bytes: 356612
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    ll h, w; cin >> h >> w;
    if(h==1 || w==1) cout << 1 << ln;
    else{
        ll a = (w+1)/2;
        ll b = w/2;
        ll res = a * ((h+1)/2) + b * (h/2);
        cout << res << ln;
    }
}


Measured memory_bytes: 256
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
int memo[100003];
long long recurse(int i, bool a[], int n){
    if(memo[i] > -1) return memo[i];
    if(i > n) return memo[i] = 0;
    if(a[i]) return memo[i] = 0;
    if(i == n) return memo[i] = 1;
    return (memo[i] = (recurse(i+1, a, n) + recurse(i+2, a, n)) % 1000000007);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(memo, -1, sizeof(memo));
    int n, m;
    cin >> n >> m;
    bool a[n+1]{};
    for(int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        a[tmp] = true;
    }
    cout << recurse(0, a, n) % 1000000007;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int count = 0;

	while (true) {
		bool checker = false;
		
		
		for (size_t i = 0; i < 10000; i++)
		{

			if (i*8/100 == A &&i * 10 / 100 == B) {
				checker = true;
			}

			if (checker) break;

			count += 1;
		}

		break;
		
	}
	if (count == 10000) {
		cout << "-1";
	}
	else {
		cout << count;
	}

}

Measured memory_bytes: 256
# C - 4-adjacent
_ = input()
count1 = count4 = 0
not_exist2 = 1
for a in map(lambda x: int(x)%4, input().split()):
    if a==0: count4 += 1
    elif a==2: not_exist2 = 0
    else: count1 += 1
print("Yes" if count1 <= count4 + not_exist2 else "No")

Measured memory_bytes: 11480
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    X = I()
    ans = 0
    ans += (1000 * (X // 500))
    X -= 500 * (X // 500)
    ans += (5 * (X // 5))
    print(ans)

main()



Measured memory_bytes: 6828
#include <bits/stdc++.h>
 
using namespace std;
int a, n, b;
int main(){
cin >> n >> a >> b;
if (n == 1){
if (a == b) cout << 1;
else
cout << 0;
return 0;
}
if (a > b) {
cout << 0;
return 0;
}
cout << 1LL * (n - 2) * ( b - a) + 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    string s;
    cin>>s;
    ll ans=0;
    rep(i,s.size()){
        ll cnt=0;
        repf(j,i,s.size()){
            if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
                cnt++;
            }else{
                break;
            }
        }
        ans=max(ans,cnt);
    }
    op(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1+1 == m2) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
#define f first
#define s second
int main()
{
	int n;
	cin>>n;
	vector<int> a(n),v(n);
	int cnt[1000001]={0};
	for(int i=0;i<n;i++)
	{cin>>a[i];++cnt[a[i]];}
	if(n==1)
	{cout<<1;
	return 0;
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++)
	v[i]=a[i];
	vector<int>::iterator ip; 
   ip = std::unique(v.begin(),v.end()); 
    v.resize(std::distance(v.begin(), ip)); 
	int val[1000001]={0};
    for(int i=0;i<1000001;i++)
    val[i]=0;
	for(int i=0;i<v.size();i++)
	{
		for(int j=v[i];j<=1000000;j=j+v[i])
		++val[j];
	} 
	int ans=0;
	for(int i=0;i<n;i++)
	if(val[a[i]]==1&&cnt[a[i]]==1)
	++ans;
	cout<<ans;
}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

constexpr double PI = acos(-1);

int main() {
  int X1, Y1, X2, Y2, N;
  cin >> X1 >> Y1 >> X2 >> Y2;
  if(tie(X1, Y1) > tie(X2, Y2)) {
    swap(X1, X2);
    swap(Y1, Y2);
  }
  bool f = false;
  if(Y1 > Y2) {
    Y1 *= -1;
    Y2 *= -1;
    f = true;
  }
  cin >> N;
  vector< pair< int, int > > p;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    if(x < X1 || x > X2) continue;
    if(f) y *= -1;
    if(y < Y1 || y > Y2) continue;
    p.emplace_back(x, y);
  }
  sort(begin(p), end(p));

  double all = (Y2 - Y1) + (X2 - X1);
  all *= 100;
  vector< int > taplis(p.size(), INF);
  for(int i = 0; i < p.size(); i++) {
    *lower_bound(begin(taplis), end(taplis), p[i].second) = p[i].second;
  }
  int sz = lower_bound(begin(taplis), end(taplis), INF) - begin(taplis);
  all -= 20 * sz;
  const double one = 2 * PI * 10 / 4;
  all += one * sz;
  if(sz == min(X2 - X1, Y2 - Y1) + 1) all += one;
  cout << fixed << setprecision(15) << all << endl;
}



Measured memory_bytes: 2544
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String[] str = s.split("");
		String tmp = "";

		for (int i = 0; i < Math.pow(2, s.length() - 1); i++) {
			for (int j = 0; j < s.length() - 1; j++) {
				tmp += str[j];
				if ((i >> j & 1) == 1) {
					tmp += ",";
				}
			}
			tmp += str[s.length() - 1];
			if (i != Math.pow(2, s.length() - 1) - 1) {
				tmp += ",";
			}
		}

		String[] target = tmp.split(",", 0);

		long sum = 0;
		for (int i = 0; i < target.length; i++) {
			sum += Long.parseLong(target[i]);
		}

		System.out.println(sum);

	}
}


Measured memory_bytes: 89940
n=int(input())
L=[]
for l in range(n):
    L.append([])
M=[]
for m in range(n):
    mm=[0]*n
    M.append(mm)

for i in range(n):
    inp=list(map(int,input().split()))
    #print()
    L[inp[0]-1]=inp[2:]

for i,l in enumerate(L):
    for k in l:
        M[i][k-1]=1

for m in M:
    print(' '.join(map(str,m)))



Measured memory_bytes: 5672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int H, W, H2, W2;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                H = line[0];
                W = line[1];
            }

            {
                var line = Input.ReadIntArray();
                H2 = line[0];
                W2 = line[1];
            }

            Console.WriteLine((H - H2) * (W - W2));

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

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

int main(){
  int N,H;
  scanf("%d%d",&N, &H);
  vector<int> array1(N);
  vector<int> array2(N);
  rep(i,N){
    int a,b;
    scanf("%d%d",&a,&b);
    array1.push_back(a);
    array2.push_back(b);
  }
  sort(array1.begin(),array1.end(),greater<int>());
  sort(array2.begin(),array2.end(),greater<int>());
  int ans=0;
  rep(i,N){
    if(H<=0 or array2[i]<array1[0]){
      break;
    }
    ans+=1;
    H-=array2[i];
  }
  if(H<=0){
    printf("%d",ans);
  }
  else{
    ans+=(H+array1[0]-1)/array1[0];
    printf("%d",ans);
  }
  return 0;
}

Measured memory_bytes: 5060
using System;
using System.Collections.Generic;

namespace MyTest
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var S = Console.ReadLine();
			var N = S.Length - 1;
			long result = 0;
			List<string> strList = new List<string>();
			for (int bit = 0; bit < (1 << N); bit++)
			{
				string part = S[0].ToString();
				for (int i = 0; i < N; i++)
				{
					if ((bit & (1 << i)) != 0)
					{
						strList.Add(part);
						part = string.Empty;
					}
					part += S[i + 1];
				}
				strList.Add(part);
			}

			foreach (var item in strList)
			{
				result += long.Parse(item);
			}
			Console.WriteLine(result);
		}
		//private static void Main(string[] args)
		//{
		//	IExecutable exe = new ABC061C();
		//	exe.Execute();
		//}
	}
}

Measured memory_bytes: 13268
lena=int(input())
s=input().split()
a=[]
for i in s:
 a.append(int(i))
a.sort()
lenb=int(input())
s=input().split()
b=[]
for i in s:
 b.append(int(i))
b.sort()
i=0
j=0
while i<lena:
    if a[i]==b[j]:
        i+=1
        j+=1
        if j==lenb:
            break
    elif a[i]<b[j]:
        i+=1
    else:
        break
if j==lenb:
    print("YES")
else:
    print("NO")

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    string s;
    cin >> s;
    int n = (int)s.size();
    cout << s;
    if(s[n - 1] == 's'){
        cout << "es";
    }
    else{
        cout << "s";
    }
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

int matrix[110][110];

int main() {
  REP(x, 110) {
    REP(y, 110) {
      matrix[x][y] = 0;
    }
  }


  int n;
  cin >> n;

  REP(_, n) {
    int v, num;
    cin >> v >> num;

    REP(i, num) {
      int cv;
      cin >> cv;
      matrix[v][cv] = 1;
    }
  }


  FOR(x, 1, n + 1) {
    FOR(y, 1, n + 1) {
      if (y > 1) cout << " ";
      cout << matrix[x][y];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { int N;
  cin >> N;
  ll ans = 0;
  ll ansnum = 1;
  for (int i = 1; i <=N; i++)
  {
    ll num = 0,n=i;
    while (n%2==0)
    {
      n /= 2;
      num++;
    }
    if(ans<num){
      ans = num;
      ansnum = i;
    }
  }
  
  cout << ansnum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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

int N;
ll a[110000], a2[110000], b[110000];

int main(){
    cin >> N;
    ll a_sum = 0, b_sum = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        a_sum += a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
        b_sum += b[i];
        a2[i] = a[i] - b[i];
    }

    if(a_sum < b_sum){
        cout << -1 << endl;
        return 0;
    }

    sort(a2, a2+N);
    ll short_sum = 0;
    ll res = 0;
    for(int i = 0; i < N; i++){
        if(b[i] - a[i] > 0){
            res++;
            short_sum += b[i] - a[i];
        }
    }

    for(int i = N-1; i >= 0; i--){
        if(short_sum <= 0){
            break;
        }
        else{
            short_sum -= a2[i];
            res++;
        }
    }

    cout << res << endl;

    return 0;

}



Measured memory_bytes: 2560
using System;

class main
{
    public static void Main()
    {
        bool isEnd = false;
        while (isEnd == false)
        {
            string[] inputStr = Console.ReadLine().Split(' ');
            if (inputStr[0] == "0" && inputStr[1] == "0")
                isEnd = true;
            else
            {
                int x = int.Parse(inputStr[0]);
                int y = int.Parse(inputStr[1]);
                if (x > y)
                {
                    int temp = x;
                    x = y;
                    y = temp;
                }
                Console.WriteLine(x + " " + y);
            }
        }
    }
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vi> cnt(h+2,vi(w+2));
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      if(s[i-1][j-1] == '#'){
        cnt[i-1][j-1]++;
        cnt[i-1][j]++;
        cnt[i-1][j+1]++;
        cnt[i][j-1]++;
        cnt[i][j+1]++;
        cnt[i+1][j-1]++;
        cnt[i+1][j]++;
        cnt[i+1][j+1]++;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='.') cout << cnt[i+1][j+1];
      else cout << "#";
    }
    cout << "\n";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(){
    int x,y;
    while(cin>>x>>y){        if(x==0&&y==0)break;
for(int l=1;l<=x;l++){
        if(l%2==1){
        for(int k=1;k<=y/2;k++){
            cout<<"#";
            cout<<".";
            }
            if(y%2==1)cout<<"#"<<endl;
            else cout<<endl;
        }
        
        if(l%2==0){
        for(int s=1;s<=y/2;s++){
                    cout<<".";
                    cout<<"#";
            }
            if(y%2==1)cout<<"."<<endl;
            else cout<<endl;
        
        
        }
    }
            cout<<endl;
            
    
}
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+')
    out(a + b);
  else
    out(a - b);
}
int main(void) { solve(); }

Measured memory_bytes: 3640
#0が黒、1が白
s = input()
sirokuro = 0
kurosiro = 0
for i in range(len(s)):
    if i % 2 == 0:#奇数番目
        if s[i] == '0':#奇数番目が黒
            sirokuro += 1
        else:#奇数番目が白
            kurosiro += 1
    else:#偶数番目
        if s[i] == '0':#偶数番目が黒
            kurosiro += 1
        else:#偶数番目が白
            sirokuro += 1
print(min(sirokuro,kurosiro))

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  
  vector<int> sum_W(n+1) , sum_E(n+1);
  
  sum_W.at(0)=sum_E.at(0)=0;
  
  for(int i=0;i<n;i++){
    if(s.at(i)=='W'){
      sum_W.at(i+1)=sum_W.at(i)+1;
      sum_E.at(i+1)=sum_E.at(i);
    }
    else{
      sum_W.at(i+1)=sum_W.at(i);
      sum_E.at(i+1)=sum_E.at(i)+1;
    }
  }
  
  int res=300000;
  
  for(int i=0;i<n;i++){
    int count=0;
    count+=sum_W.at(i)+sum_E.at(n)-sum_E.at(i+1);
    
    res=min(res,count);
  }
  
  cout<<res;
}

Measured memory_bytes: 2948
#create date: 2020-05-03 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    print("ABC" if s=="ARC" else "ARC")

if __name__ == "__main__":
    main()

Measured memory_bytes: 61740
#include<stdio.h>
int main(){
	long a,b,c,tmp;
	long d;
	while(scanf("%ld%ld",&a,&b)!=EOF){
	d=a*b;
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	while(1){
		c=a%b;
		if(c==0)break;
		a=b;
		b=c;
	}
	c=d/b;
	printf("%ld %ld\n",b,c);
	}
	return 0;
}

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

int main () {
	
	long long int a=0, b=0, c=0, d=0, x=0, y=0, g=0;

	cin >> a >> b >> c >> d;

	g = __gcd(c, d);
	//cout << g << endl;
	g = (c*d)/g;
	//cout << g << endl;

	x = ((a-1)/c) + ((a-1)/d) - ((a-1)/g);
	y = (b/c) + (b/d) - (b/g);


	//cout << y << " , " << x << endl;

	//y = max(y-x, (long long int)(0));
	y -= x;

	y = (b-a+1) - y;
	cout << y << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 2e5+5;
int n, A[maxn], B[maxn], C[maxn];

int main()
{
    ios::sync_with_stdio(false);
    while (cin >> n) {
        FOR(i,0,n)
            cin >> A[i];
        FOR(i,0,n)
            cin >> B[i];
        int ans = 0;
        FOR(i,0,30) {
            const int T = 1<<i;
            FOR(j,0,n)
                C[j] = B[j]%(2*T);
            sort(C,C+n);
            LL cnt = 0;
            FOR(j,0,n) {
                const int a = A[j]%(2*T);
                const int i1 = lower_bound(C,C+n,T-a) - &C[0];
                const int j1 = upper_bound(C,C+n,2*T-a-1) - &C[0];
                if (i1 < j1)
                    cnt += j1-i1;
                const int i2 = lower_bound(C,C+n,3*T-a) - &C[0];
                const int j2 = upper_bound(C,C+n,4*T-a-1) - &C[0];
                if (i2 < j2)
                    cnt += j2-i2;
            }
            if (cnt&1)
                ans += 1<<i;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long N;
stringstream s;
string temp;
long long max(long long a,long long b)
{
    return a>b?a:b;
}

int main(void)
{
    cin>>N;
    int len1;
    int len2;
    int cnt=INT_MAX;
    int len;
    s.clear();
    for(int i=1;i<=1000;i++)
    {
       if(N%i==0)
        {
            s<<i;
            s>>temp;
            len1=temp.length();
            s.clear();
            s<<(N/i);
            s>>temp;
            len2=temp.length();
            s.clear();
            cnt=min(cnt,max(len1,len2));
        }
        s.clear();
    }
    long long j=max(1000,N/1000);
    for(int i=int(sqrt(N));i<=j;i++)
    {
        if(N%i==0)
        {
            s<<i;
            s>>temp;
            len1=temp.length();
            s.clear();
            s<<(N/i);
            s>>temp;
            len2=temp.length();
            s.clear();
            cnt=min(cnt,max(len1,len2));
            break;
        }
    }
    cout << cnt <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 1e9
#define MAX 150
#define min(a,b) ((a) < (b) ? (a) : (b))

int main(){
  int num,i;
  int u,k,j,v,con;
  int A[MAX][MAX];
  
  for(i = 0 ; i < MAX ; i++){
    for(j = 0 ; j < MAX ; j++){
     A[i][j] = INF;
    }
    A[i][i] = 0;
  }
  
  scanf("%d",&num);
  for(i = 0 ; i < num ; i++){
    scanf("%d%d" ,&u ,&k);
    for(j = 0 ; j < k ; j++){
     scanf("%d%d" ,&v ,&con);
      A[u][v] = con;
    }
  }
 
  for(k = 0 ; k < num ; k++){
    for(i = 0 ; i < num ; i++){
     for(j = 0 ; j < num ; j++){
    A[i][j] = min(A[i][j],A[i][k]+A[k][j]);
     }
    }
  }

  for(i = 0 ; i < num ; i++){
    printf("%d %d\n" ,i ,A[0][i]);
  }

  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>

typedef long long int llint;
using namespace std;
const int LIMIT = 10000;

int main() {

	llint n;
	cin >> n;


	vector<llint> A,B,C;
	A.resize(n);
	B.resize(n);
	C.resize(LIMIT,0);

	for (llint i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (llint i = 0; i < n; i++) {
		C[A[i]]++;
	}
	for (int i = 1; i < LIMIT; i++) {
		C[i] += C[i - 1]; // => c--;
		//C[i+1] += C[i]; i = 0; i < LIMIT -1; => c++
	}
	for (llint i = 0; i < n; i++) {
		B[C[A[i]]-1] = A[i];
		C[A[i]] = C[A[i]] - 1;
	}
	for (llint i = 0; i < n; i++) {
		if (i != n - 1)
			cout << B[i] << " ";
		else
			cout << B[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 34176
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int n = 0, m = 0, o = 0;
                while (true) {
                        int L[] = new int[3];
                        for (int i = 0; i < 3; i++) {
                                L[i] = sc.nextInt();
                        }
                        Arrays.sort(L);
                        if (L[0] + L[1] <= L[2]) {
                                System.out.println(n + m + o + " " + n + " " + m + " " + o);
                                break;
                        } else if (L[0] * L[0] + L[1] * L[1] == L[2] * L[2]) {
                                n++;
                        } else if (L[0] * L[0] + L[1] * L[1] > L[2] * L[2]) {
                                m++;
                        } else if (L[0] * L[0] + L[1] * L[1] < L[2] * L[2]) {
                                o++;
                        }

                }
        }
}

Measured memory_bytes: 26240
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    cout<<fixed<<setprecision(15);
    ll n,a,b,cnt=0; cin>>n>>a>>b;
    ld ans=0.0;
    vector<ll> v(n,0);
    map<ll,ll> M,m;
    rep(i,n){
        cin>>v[i];
        if(M.count(v[i])) M[v[i]]++;
        else M[v[i]]=1;
    }
    sort(al(v)); reverse(al(v));
    rep(i,a){
        ans+=v[i];
        if(m.count(v[i])) m[v[i]]++;
        else m[v[i]]=1;
    }
    ans/=a;
    cout<<ans<<endl;
    if(m.size()==1){
        ll k=min(b,M[v[0]]),ad=1;
        for(ll i=a;i<=k;i++){
            ad=1;
            for(ll j=1;j<=i;j++){
                ad*=M[v[0]]-j+1;
                ad/=j;
            }
            cnt+=ad;
        }
    }
    else{
        cnt=1;
        for(ll i=1;i<=m[v[a-1]];i++){
            cnt*=M[v[a-1]]-i+1;
            cnt/=i;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256