akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

  ll k,x;
  std::cin>>k>>x;

  if(500*k>=x)std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n, m;
vector< vector<int> > G;

int dp[100100];

int rec(int v) {
	if (dp[v] != -1) return dp[v];

	int res = 0;
	for (int i = 0; i < G[v].size(); i++) {
		res = max(res, rec(G[v][i]) + 1);
	}

	return dp[v] = res;
}

int main(void){
	cin>>n>>m;
	G.assign(n, vector<int>());
	for (int i = 0; i < m; i++) {
		int x, y; cin>>x>>y;
		--x; --y;
		G[x].push_back(y);
	}

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

	int res = 0;
	for (int v = 0; v < n; v++) res = max(res, rec(v));

	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 8192
solve :: Int -> Int -> [(Int, Int, Int)]
solve n y =
  [(a,b,c) |
      a <- [0..n]
    , b <- [0..n]
    , let c = n - a - b
    , c >= 0
    , 10000*a + 5000*b + c*1000 == y] ++ [(-1,-1,-1)]

main = do
  [n, y] <- map read . words <$> getLine :: IO [Int]
  let (a,b,c) = head $ solve n y
  putStr $ show a ++ " "
  putStr $ show b ++ " "
  putStrLn $ show c

Measured memory_bytes: 636
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll d; cin >> d; ll happy = 0;
  vl whatday(26);
  
  vector<bool> israted(26,false);
  
  vl human(26);
  rep(i,26) cin >> human[i];
  
  vvl userhappy(d,vl(26));  
  rep(i,d){
    rep(j,26){
      cin >> userhappy[i][j];
    }
  }
  
 
  rep(i,d){
    ll now = 0; ll nowhappy = 0;
    rep(j,26){
      if(israted[j]){
        if(userhappy[i][j] + human[j]*(i-whatday[j]) > nowhappy){
          now = j;
          nowhappy = userhappy[i][now] + human[j]*(i-whatday[j]);
        }
      }
      else if(userhappy[i][j] > nowhappy){
        now = j;
        nowhappy = userhappy[i][now];
      }
    }
    
    cout << now+1 << endl;
    israted[now] = true;
    whatday[now] = i;
  }
  
  
}

Measured memory_bytes: 3748
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
string S[55]; int a[26], b[26], n;
int main() {
	cin >> n; for (int i = 0; i < 26; i++)a[i] = 999999;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
		for (int j = 0; j < 26; j++)b[j] = 0;
		for (int j = 0; j < S[i].size(); j++)b[S[i][j] - 'a']++;
		for (int j = 0; j < 26; j++)a[j] = min(a[j], b[j]);
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < a[i]; j++)cout << (char)('a' + i);
	}
	cout << endl;
	return 0;
}

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

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

template <typename T>
T lcd( T a, T b ) { return a / gcd( a, b ) * b; }

template <typename T>
T lcd( std::vector<T>& a, int i = 0 )
{
    if( a.size() < 2 ) return a[0];
    if( i == (int) a.size() - 2 ) return lcd( a[i], a[i+1] );
    return lcd( a[i], lcd(a, i+1) );
}



int main()
{
    int N;
    cin >> N;
    vector<long long> T(N);
    for( int i = 0; i < N; ++i ) cin >> T[i];
    
    cout << lcd<long long>( T ) << endl;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

bool solve() {
    int n;
    cin >> n;
    if(n == 0) return false;
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    --A;
    --B;
    --C;
    --D;
    int ans = 0;
    ++n;
    vi X(n), Y(n);
    rep(i, n) {
        cin >> X[i] >> Y[i];
        X[i]--;
        Y[i]--;
    }
    rep(i, n- 1) {
        int d[110][110];
        rep(y, 110) rep(x, 110) d[y][x] = 1e9;
        d[Y[i]][X[i]] = 0;
        deque<pii> dq;
        dq.push_back(make_pair(Y[i], X[i]));
        while(!dq.empty()) {
            auto p = dq.front();
            dq.pop_front();
            int x = p.se;
            int y = p.fi;
            rep(j, 4) {
                int nx = x + dx[j];
                int ny = y + dy[j];
                if(nx < 0 || nx >= 100 || ny < 0 || ny >= 100) continue;
                int dist = d[y][x];
                if(nx < A || nx > C || ny < B || ny > D) dist++;
                if(dist < d[ny][nx]) {
                    d[ny][nx] = dist;
                    if(dist == d[y][x]) dq.push_front(make_pair(ny,nx));
                    else dq.push_back(make_pair(ny, nx));
                } 
            }
        }
        // rep(i, 20) {
        //     rep(j, 20) {
        //         printf("%4d", (d[i][j] == 1e9 ? -1 : d[i][j]));
        //     }
        //     cout << '\n';
        // }
        ans += d[Y[i+1]][X[i+1]];
    }
    cout << ans << endl;
    return true;
}

int main() {
    int n;
    while(solve()) {}
    return 0;
}


Measured memory_bytes: 3252
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

ans = 0
for pat in combinations_with_replacement(range(1, m + 1), n):
    score = 0
    for a, b, c, d in abcd:
        a -= 1
        b -= 1
        if pat[b] - pat[a] == c:
            score += d

    ans = max(ans, score)

print(ans)


Measured memory_bytes: 9016
L = input()

dp1 = [0 for i in range(len(L))]
dp2 = [0 for i in range(len(L))]

dp1[0] = 2
dp2[0] = 1

mod = 10 ** 9 + 7

for i in range(1,len(L)):
    if L[i] == "0":
        dp1[i] = dp1[i-1]
    else:
        dp1[i] = dp1[i-1] * 2
        dp2[i] = dp1[i-1]
    dp2[i] += dp2[i-1] * 3
    dp1[i] %= mod
    dp2[i] %= mod

print((dp1[len(L)-1] + dp2[len(L)-1]) % mod)

Measured memory_bytes: 46452
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

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

  ans=(b-1)/(a-1);
  if((b-1)%(a-1)) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int left(int);
int right(int);
void MaxHeapify(int,int);

int a[500000];


int main(){

  int num,i;


  scanf("%d",&num);
  for(i = 1; i <= num; i++){
    scanf("%d",&a[i]);
  }
  
  for(i = num/2; i >= 1; i--)MaxHeapify(num,i);
  
  for(i = 1; i <= num; i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  
  return 0;
}

//関数
int Left(int i){
  return 2*i;
}

int Right(int i){
  return 2*i + 1;
}

void MaxHeapify(int num,int i){
  int l,r,largest,swap;

  l = Left(i);
  r = Right(i);

  if(l <= num && a[l] > a[i])largest = l;
  else largest = i;

  if(r <= num && a[r] > a[largest])largest = r;

  if(largest != i){
    swap = a[i];
    a[i] = a[largest];
    a[largest] = swap;
    MaxHeapify(num,largest);
  }
}

Measured memory_bytes: 2980
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a[3];
	bool b = true;
	unsigned w, x, y, z;
	x = 0; y = 0; z = 0;
	while (cin >> a[0] >> a[1] >> a[2]) {
		if (b) {
			sort(a, a + 3);
			if (a[0] + a[1] < a[2])
				b = false;
			else if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
				x++;
			else if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2])
				z++;
			else y++;
		}
	}
	cout << x + y + z << ' ' << x << ' ' << y << ' ' << z << endl;
}

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

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

  int ans = 0;
  for (int i = 1; i <= N; i = i + 2) {
    int div = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) div++;
    }
    if (div == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){

    int n;
    long long total;

    while(cin >> n, n){

        int time[n], sum[n];

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

        sort(time, time + n);

        sum[0] = 0;
        for(int i = 1; i < n; ++i){
            sum[i] = sum[i - 1] + time[i - 1];
        }

        total = 0;
        for(int i = 0; i < n; ++i){
            total += sum[i];
        }

        cout << total << endl;

    }

}

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

using namespace std;

typedef unsigned long long ull;

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

  int M[300100];
  for (int i = 0; i < N * 3; ++i) {
    cin >> M[i];
  }

  sort(M, M+N*3, greater<int>());

  ull ans = 0;
  for (int i = 1; i < N * 2; i += 2) {
    ans += M[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<queue>
#define put(x,y) make_pair(x,y)
using namespace std;
const int SIZE=1e6;
deque< pair<int,int> > p;
bool vis[SIZE];
int k;
void bfs() {
    while(p.size()) {
        pair<int,int> now=p.front(); p.pop_front();
        if(vis[now.first]) continue;
        vis[now.first]=true;
        if(!now.first) {
            printf("%d\n",now.second);
            return;
        }
        p.push_front(put(now.first*10%k,now.second));
        p.push_back(put((now.first+1)%k,now.second+1));
    }
}
int main() {
    scanf("%d",&k);
    p.push_front(put(1,1));
    bfs();
    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
using namespace std;
 
int main(){
    int a, b[20], i = 0;
    cin >> a;
    while(a > i){
        cin >> b[i];
        i++;
    }
    int cnt = 1;
    int max = b[0];
    for(int i = 1;i < a;i++){
        if(max <= b[i] && b[i - 1] <= b[i]){
            cnt = cnt + 1;
        }
        if(max < b[i]){
            max = b[i];
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int n,i,h=0,c=0;
  long int a;
  long int j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%ld",&a);
    if(a==2){
      c++;
      continue;
    }
    if(a<=1 || a%2==0)
      continue;
    j=3;
    while(j<=sqrt(a)){
      if(a%j==0)h++;
      j+=2;
    }
    /*
    for(j=2;j<a-1;j++){
      if(a%j==0){
	h++;
	break;
      }
    }
    */
    if(h==0)c++;
    h=0;
  }
  
  printf("%d\n",c);
  
  return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define rep(i,x,y) for(int i=(x);i<=(y);++i) 
int fac[500010],inv[500010];
inline int C(int n,int m){
	if(n<m)return 0;
	return 1ll*fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	if(n>k)return puts("0"),0;
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	rep(i,2,500000){
		fac[i]=1ll*fac[i-1]*i%MOD;
		inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
	}
	rep(i,1,500000){
		inv[i]=1ll*inv[i-1]*inv[i]%MOD;
	}
	int ans=0;
	rep(R,0,k){
		int B=k-R;
		if(R<B)continue;
		if(R==B)--B;
		if(R-B>=n){
			ans+=C(R+B,R);
			if(ans>=MOD)ans-=MOD;
		}
		else {
			ans+=C(R+B,R);
			if(ans>=MOD)ans-=MOD;
			ans-=C(R+B,2*R-n+1);
			if(ans<0)ans+=MOD;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4096
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

int main(int argc, const char * argv[]) {

    ll N,M;
    cin >> N >> M;

    vector<ll> A(M);
    ll sum=0;
    for(ll i=0;i<M;i++){
        cin >> A[i];
        sum += A[i];
    }

    if(sum <= N){
        cout << N - sum << endl;
    }
    else{
        cout << -1 << endl;
    }


//    cout << fixed << setprecision(20) << R*2.0*M_PI << endl;

    return 0;
    

    
}




Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}
 
void scerr(vi nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}
 
int n, k, dp[N][3], a[N], b[N], c[N];
 
int main() {
	data();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
	}
	printf("%d", max({dp[n][2], dp[n][1], dp[n][0]}));
	return 0;
}
 
/*
	Timus: 288481RF
	CodeForces: __fractal
*/

Measured memory_bytes: 2560
import bisect
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
S = [0]*N
T = [0]*M
S[0] = A[0]
for k in range(1,N):
    S[k] = S[k-1] + A[k]
T[0] = B[0]
for k in range(1,M):
    T[k] = T[k-1] + B[k]

ans = bisect.bisect_right(T,K)
for k in range(N):
    if K-S[k] >= 0:
        ans = max(ans,k+1+bisect.bisect_right(T,K-S[k]))
print(ans)


Measured memory_bytes: 110984
#include <stdio.h>

void insertionSort(int as[], int n)
{
  int i, j, k;
  int key;

  for (k = 0; k < (n - 1); k++) {
    printf("%d ", as[k]);
  }
  printf("%d\n", as[n - 1]);
  for (i = 1; i < n; i++) {
    key = as[i];
    j = i - 1;
    while (j >= 0 && as[j] > key) {
      as[j + 1] = as[j];
      j--;
    }
    as[j + 1] = key;
    for (k = 0; k < (n - 1); k++) {
      printf("%d ", as[k]);
    }
    printf("%d\n", as[n - 1]);
  }
}

int main(int argc, char *argv[])
{
  char row[4];
  int n = atoi(fgets(row, sizeof(row), stdin));
  int as[n];
  int i;

  for (i = 0; i < n; i++) {
    scanf("%d", &as[i]);
  }

  insertionSort(as, n);

  return 0;
}

Measured memory_bytes: 608
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    int n,m;
    while(cin>>n>>m)
    {
        int i,x,cnt=0,j;
        vector<int>ev,od;
        x=2;
        for(i=1;i<=n;i++)
        {
            ev.push_back(x);
            x+=2;
        }
        x=1;
        for(i=1;i<=m;i++)
        {
            ev.push_back(x);
            x+=2;
        }
        for(i=0;i<(n+m)-1;i++)
        {
            for(j=i+1;j<(n+m);j++)
            {
                if((ev[i]+ev[j])%2==0)
                    cnt++;
            }
        }
        cout<<cnt<<endl;
    }
}




Measured memory_bytes: 256
program test
implicit none

integer(8) :: i,j,n,st,en,suu(0:200001)=0,kazu(26)=0,kazu2(26)=0,combo=0,ans=1,rui(200000)=0,big=10**9+7
character(len=200000) ::  s
character(len=26) :: all = "abcdefghijklmnopqrstuvwxyz"

rui(0)=1
do i=1,200000
rui(i) = mod(rui(i-1)*2,big)
enddo

read(*,*) n
read(*,*) s

do i=1,n
	do j=1,26
	if(s(i:i) == all(j:j))then
		suu(i) = j
	endif
	enddo
enddo

do i=1,n
	kazu(suu(i)) = kazu(suu(i)) + 1
enddo

do i=1,26
	ans = mod(ans * (kazu(i)+1),big)
enddo

ans = ans -1

write(*,*) ans

contains
subroutine heapsort_down(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) > y1(j+1)) j = j+1
				endif
				
				if (t1 > y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_down
 
subroutine heapsort_up(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_up
 
end program


Measured memory_bytes: 2980
N=int(input())
S=[]
M=[]
for i in range(N):
  s,m=map(str,input().split())
  S+=[s]
  M+=[int(m)]
A=str(input())

answer=sum(M)
for i in range(N):
  answer -=M[i]
  if S[i]==A:
    print(answer)
    exit()
print(0)

Measured memory_bytes: 3060
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b, c) = readListOfInt()
    val ans = c - Math.min(a-b, c)
    println(ans)
    
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 38000
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(a: int, b: int, x: int):
    print(b // x - (a-1) // x)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
import java.util.Scanner;

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

        while (sc.hasNext()) {
            int n = sc.nextInt();

            int nCombinations = 0;
            for (int a = 0; a <= 9; a++)
                for (int b = 0; b <= 9; b++)
                    for (int c = 0; c <= 9; c++)
                        for (int d = 0; d <= 9; d++)
                            if (a + b + c + d == n)
                                nCombinations++;

            System.out.println(nCombinations);
        }
    }
}

Measured memory_bytes: 26732
#include <bits/stdc++.h>
using namespace std;
int main(){
while(1){
int n, x;
cin>>n>>x;
if(n == 0 && x == 0) break;
int ans = 0;
for(int a = 1; a <= n ; a++)
for(int b = a + 1; b <= n ; b++)
for(int c = b + 1; c <= n ; c++){
if(a + b + c != x) continue;
ans++;
}
cout<<ans<<endl;
}
return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

vector<int> G[100001];

int dfs(int u, int p) {
    int ret = 0;
    for (int v : G[u]) if (v != p) ret ^= (dfs(v, u) + 1);
    return ret;
}

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;
    for (int i = 1; i < N; ++i) {
        int x, y; cin >> x >> y;
        G[x].push_back(y), G[y].push_back(x);
    }
    cout << (dfs(1, 0) ? "Alice" : "Bob");
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    cin >> S;

    bool has_a = false;
    bool has_b = false;

    for (int i = 0; i < (int) S.size(); i++) {
        if (S[i] == 'A') has_a = true;
        else if (S[i] == 'B') has_b = true;
    }

    if (has_a && has_b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
ll a[200000],b[200000],mid,ans,sum;
int n,bj[200000];
ll max1(ll a,ll b){
	if (a>b) return a;
	return b;
}
void dg(int l,int r){
	//printf("%d %d %lld\n",l,r,ans);
	if (a[l]*a[r]>=0){
		ans=ans+max1(max1(a[r],-a[r]),max1(a[l],-a[l]));
		return;
	}
	if (b[l]<b[r]){
		if (bj[l]==1){
			bj[r]=1;
			ans=ans+a[r]-a[l];
		}
		b[r]=b[r]+b[l];
		dg(l+1,r);
		return;
	}
	if (bj[r]==1){
		bj[l]=1;
		ans=ans+a[r]-a[l];
	}
	b[l]=b[l]+b[r];
	dg(l,r-1);
}
int main(){
	//freopen("Gohome.in","r",stdin);
	//freopen("Gohome.out","w",stdout);
	scanf("%d%lld",&n,&mid);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		a[i]=a[i]-mid;
	}
	if (a[1]*a[n]>=0){
		ans=max1(max1(a[1],a[n]),max1(-a[1],-a[n]));
		printf("%lld\n",ans);
		return 0;
	}
	if (b[n]<=b[1]){
		bj[n]=1;
	}
	else{
		bj[1]=1;
	}
	//printf("hellow %d %d\n",bj[1],bj[n]);
	dg(1,n);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
    vector<int>par;
    vector<int>size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x,1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if(par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }
    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if(x == y) {
            return;
        }
        if(size[x] < size[y]) {
            size[y] += size[x];
            par[x] = y;
        }
        else {
            size[x] += size[y];
            par[y] = x;
        }
    }
    bool same(int x,int y) {
        return find(x) == find(y);
    }
};
int main() {
    int n,q;
    cin >> n >> q;
    UnionFind uf(n);
    for(int i = 0; i < q; i++) {
        int x,y,z;
        cin >> x >> y >> z;
        if(x == 0) {
            uf.unite(y,z);
        }
        else{
            if(uf.same(y,z)) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int maxcost[4010][4010];
bool used[4010];
vector<int> G[4010];
int cost[4010][4010];

class UnionFindFixed{
    vector<int> data;
public:
    UnionFindFixed(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

void dfs(int v, int mcost,int ori){
    stack< pair<int,int> > sta; sta.push(make_pair(v,mcost));
    while(sta.size()!=0){
        int vt=sta.top().first;
        int costt=sta.top().second;
        sta.pop();
        used[vt]=true;
        REP(i,G[vt].size()){
            if(!used[G[vt][i]]){
                costt=max(costt,cost[vt][G[vt][i]]);
                maxcost[ori][G[vt][i]]=costt;
                maxcost[ori][G[vt][i]]=costt;
                sta.push(make_pair(G[vt][i],costt));
            }
        }
    }
}

int main(){
    
    int N,M; cin>>N>>M;
    vector< pair<int,pair<int,int> > > v(M);
    REP(i,M)cin>>v[i].second.first>>v[i].second.second>>v[i].first;
    sort(v.begin(),v.end());
    
    ll totalcost=0;
    UnionFindFixed inst(4010);
    REP(i,M){
        int a=v[i].second.first,b=v[i].second.second,c=v[i].first;
        if(!inst.findSet(a,b)){
            inst.unionSet(a,b);
            G[a].push_back(b);
            G[b].push_back(a);
            cost[a][b]=cost[b][a]=c;
            totalcost+=c;
        }
    }
    
    for(int i=1;i<=N;i++){
        REP(j,4010)used[j]=false;
        dfs(i,0,i);
    }
    
    /* for(int i=1;i<=N;i++){
     for(int j=1;j<=N;j++)cout<<maxcost[i][j]<<" ";
     cout<<endl;
     }*/
    
    int Q; cin>>Q;
    REP(i,Q){
        int S,T; cin>>S>>T;
        cout<<totalcost-maxcost[S][T]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 95232
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

int a[100002], b[100002];
int main(){
	int n, k, ans = inf;
	scanf("%d%d", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
	
	int l = 0, r = 0, sum = 0;
	while(r <= n){
		if(sum == k)ans = min(ans, r-l);
		if(sum < k){
			if(a[++r] <= k){
				if(b[a[r]]++ == 0)sum++;
			}
		}else{
			if(a[++l] <= k){
				if(--b[a[l]] == 0)sum--;
			}
		}
	}
	
	if(ans == inf)printf("0\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3968
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#define MAXN 400
#define MAXM 100000
using namespace std;
bitset<MAXN+5> vis[MAXN+5];
int n,m;
int a[MAXM+5],b[MAXM+5];
bool sp[MAXN+5];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d %d",&a[i],&b[i]);
	for(int i=1;i<=n;i++)
		for(int j=m;j>=1;j--)
		{
			vis[i][i]=1;
			if(vis[i][a[j]]==1&&vis[i][b[j]]==1)
			{
				sp[i]=true;
				break;
			}
			else if(vis[i][a[j]]==0&&vis[i][b[j]]==0)
				continue;
			else
				vis[i][a[j]]=vis[i][b[j]]=1;
		}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(sp[i]==false&&sp[j]==false&&(vis[i]&vis[j]).none())
				ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

class State
{
public:
	int x, y, c,a;
	State(int x, int y, int c, int a)
		:x(x),y(y),c(c),a(a)
	{}

	bool operator<(const State& s) const
	{
		return c > s.c;
	}
};

const int INF = (1<<28);
int W,H;
int nodeX[32][32][32];
int nodeY[32][32][32];

int d[32][32][4];

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

int dijkstra(int Sx, int Sy, int Tx, int Ty)
{
	queue<State> q;
	q.push(State(Sx,Sy,0,0));

	bool visited[32][32] = {0};

	while(!q.empty()) {
		State s = q.front(); q.pop();
		if(visited[s.x][s.y]) continue;
		visited[s.x][s.y] = true;

		 if(s.x == Tx && s.y == Ty) return s.c;

		for(int i=0; i<4; i++) {
			int tx = s.x + dx[i];
			int ty = s.y + dy[i];

			if(tx<0 || ty<0 || tx>=W || ty>=H) continue;

			if(i<2) {
				if(nodeX[s.x][tx][ty]==1) continue;
			}
			else {
				if(nodeY[tx][s.y][ty]==1) continue;
			}

			if(visited[tx][ty]) continue;

			q.push(State(tx, ty, s.c+1,0));
		}

	}

	return -1;
}

bool visited[32][32][32*32+5] = {0};

int bfs()
{
	priority_queue<State> q;
	q.push(State(0,0,0,0));

	memset(visited, 0, sizeof(visited));

	while(!q.empty())
	{
		State s = q.top(); q.pop();
		int x = s.x, y = s.y;

		if(visited[x][y][s.a]) continue;
		visited[x][y][s.a] = true;

		if(x == W-1 && y == H-1) return s.c - 1;

		for(int i=0; i<4; i++) {
			int tx = x + dx[i];
			int ty = y + dy[i];


			if(tx<0 || ty<0 || tx>=W || ty>=H) continue;

			if(i<2) {
				if(nodeX[x][tx][ty]==1) continue;
			}
			else {
				if(nodeY[tx][y][ty]==1) continue;
			}
			
			if(s.a+1 > W*H) continue;
			if(visited[tx][ty][s.a+1]) continue;

			int blockcst = d[x][y][i]; //(x,y)->(tx,ty)へ向かおうとして壁が壊れる迂回コスト
			int cst = max(s.a + 1 + blockcst, s.c); //max(今回起こるコスト,　今までの迂回コストの最大)
			if(blockcst == -1) cst = -1; //迂回不可能


			if(cst > 0) q.push(State(tx,ty,cst,s.a+1));

		}
	}

	return -1;
}

int solve()
{
	for(int y=0; y<H; y++)
	for(int x=0; x<W; x++)
	{
		for(int k=0; k<4; k++)
		{
			int tx = x + dx[k];
			int ty = y + dy[k];


			if(tx<0 || ty<0 || tx>=W || ty>=H) continue;

			if(k<2) {
				if(nodeX[x][tx][ty]==1) continue;
			}
			else {
				if(nodeY[tx][y][ty]==1) continue;
			}

			if(k<2) { nodeX[x][tx][ty]=1; }
			else {    nodeY[tx][y][ty]=1; }

			d[x][y][k] = dijkstra(x,y,W-1, H-1);

			if(k<2) { nodeX[x][tx][ty]=0; }
			else {    nodeY[tx][y][ty]=0; }
		}
	}

	return bfs();
}

int main()
{
	while(cin >> H >> W, (W||H)) {

		for(int i=0; i<H; i++) {
			for(int j=0; j<W-1; j++) {
				int t;
				cin >> t;
				nodeX[j][j+1][i] = t;
				nodeX[j+1][j][i] = t;
			}
			if(i!=H-1)
			for(int j=0; j<W; j++) {
				int t;
				cin >> t;
				nodeY[j][i][i+1] = t;
				nodeY[j][i+1][i] = t;
			}
		}

		cout << solve() << endl;

	}
}

Measured memory_bytes: 2316
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll a, b;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

ll solve() {
    return a * b / gcd(a, b);
}

void input() {
    cin >> a >> b;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int C,D,W,X;
/* [area][day] */
int E[15][30]; 
int F[15][30];

/* [day][area][direction][rest fuka][rest multiple] */
int memo[30][16][3][51][6];

int tansaku(int day,int area,int direction,int rest_fuka,int rest_multiple) {
	int result=0,nowresult;
	int i;
	if(day>=D)return 0;
	if(memo[day][area][direction][rest_fuka][rest_multiple]>0) {
		return memo[day][area][direction][rest_fuka][rest_multiple]-1;
	}
	result=tansaku(day+1,0,0,rest_fuka,rest_multiple);
	if(area==0) {
		for(i=0;i<C;i++) {
			if(E[i][day]>0 && F[i][day]<=rest_fuka) {
				int nownowresult;
				nowresult=tansaku(day+1,0,0,rest_fuka-F[i][day],rest_multiple);
				if(rest_multiple>0) {
					nownowresult=tansaku(day,i+1,0,rest_fuka-F[i][day],rest_multiple-1);
					if(nownowresult>nowresult)nowresult=nownowresult;
				}
				nowresult+=E[i][day];
				if(nowresult>result)result=nowresult;
			}
		}
	} else {
		/* direction : 0 is none, 1 is left, 2 is right */
		if(direction!=2 && area>1 && E[area-2][day]>0 && F[area-2][day]<=rest_fuka) {
			nowresult=tansaku(day,area-1,1,rest_fuka-F[area-2][day],rest_multiple);
			nowresult+=E[area-2][day];
			if(nowresult>result)result=nowresult;
		}
		if(direction!=1 && area<C && E[area][day]>0 && F[area][day]<=rest_fuka) {
			nowresult=tansaku(day,area+1,2,rest_fuka-F[area][day],rest_multiple);
			nowresult+=E[area][day];
			if(nowresult>result)result=nowresult;
		}
	}
	memo[day][area][direction][rest_fuka][rest_multiple]=result+1;
	return result;
}

int main(void) {
	int i,j;
	while(1) {
		scanf("%d%d%d%d",&C,&D,&W,&X);
		if((C|D|W|X)==0)break;
		for(i=0;i<C;i++) {
			for(j=0;j<D;j++) {
				scanf("%d",&E[i][j]);
			}
		}
		for(i=0;i<C;i++) {
			for(j=0;j<D;j++) {
				scanf("%d",&F[i][j]);
			}
		}
		memset(memo,0,sizeof(memo));
		printf("%d\n",tansaku(0,0,0,W,X));
	}
	return 0;
}

Measured memory_bytes: 2336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    int i,j;
    int n;
    while(1){
        cin>>n;
        if(n==0) break;
        VI v(2*n,0);
        for(i=0;i<n;i++){
            int x;
            cin>>x;
            x--;
            v[x]++;
        }
        set<int> s[2];
        for(i=0;i<2*n;i++){
            if(v[i]==1) s[0].insert(i);
            else s[1].insert(i);
        }
        VI score(2,n);
        int p=-1;
        int r=0;
        while(1){
            auto it=s[r].upper_bound(p);
            if(it==s[r].end()){
                p=-1;
            }
            else{
                p=*it;
                s[r].erase(it);
                score[r]--;
                if(score[r]==0) break;
            }
            r=1-r;
            //cout<<p<<endl;
        }
        cout<<score[1]<<endl<<score[0]<<endl;
    }

}


Measured memory_bytes: 3092
#include<iostream>
#include<queue>
using namespace std;
struct PAD{
    char M;
    int x;
    int y;
    int flag = 0; 
}; 
int main(){
    queue<struct PAD> que;
    struct PAD pad[20][20+1];
    int W,H,count;
    int start_x,start_y;
    char baf_char;
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    while(1){
        count = 0;
        cin >> W >> H;
        if(W==0&&H==0)break;
        for(int i=0;i<H;i++){
            for(int k=0;k<W;k++){
                cin >> baf_char;
                if(baf_char=='@'){
                    start_x = k;
                    start_y = i;
                    pad[i][k].flag = 1;
                }else if(baf_char=='#'){
                    pad[i][k].flag = 1;
                }else{
                    pad[i][k].flag = 0;
                }
                pad[i][k].x=k;
                pad[i][k].y=i;
                pad[i][k].M = baf_char;
            }
        }
        //pad[start_y][start_x].flag = 1;
        que.push(pad[start_y][start_x]);
        while(que.size()!=0){
            struct PAD p = que.front();
            que.pop();
            for(int j = 0;j<4;j++){
                int nx = p.x + dx[j];
                int ny = p.y + dy[j];
                if(ny>=0&&nx>=0&&ny<=(H-1) && nx<=(W-1) && pad[ny][nx].flag == 0 && pad[ny][nx].M == '.'){
                    pad[ny][nx].flag = 1;
                    que.push(pad[ny][nx]);
                    count++;
                }
            }
        }
        cout << count+1 << endl;
    }


    return 0;
}


Measured memory_bytes: 3176
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static int N;
    private static int M;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();

        List<int[]> al = new ArrayList<>();
        genA(1, 1, new int[N + 1], al);

        int Q = sc.nextInt();
        List<int[]> vals = new ArrayList<>();
        for (int i = 0; i < Q; i++) {
            vals.add(new int[] {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()});
        }

        int max = 0;
        for (int[] A : al) {
            int score = 0;
            for (int[] val : vals) {
                if (A[val[1]] - A[val[0]] == val[2]) {
                    score += val[3];
                }
            }
            if (max < score) {
                max = score;
            }
        }
        System.out.println(max);
    }

    private static void genA(int idx, int min, int[] base, List<int[]> al) {

        for (int i = min; i <= M; i++) {
            int[] na = clone(base);
            na[idx] = i;
            if (N < idx + 1) {
                al.add(na);
            } else {
                genA(idx + 1, i, na, al);
            }
        }
    }

    private static int[] clone(int[] base) {

        int[] clone = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            clone[i] = base[i];
        }
        return clone;
    }
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){

  int a;cin >> a;
  string s;cin >> s;

  if(a>=3200)cout << s << endl;
  else cout << "red" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define NREP(i, n) for(int i = 1; i <= (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int nums(int n){
	return to_string(n).length();
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(7);
////////////////////////////////////////////
	string s,t;
	cin >> s;
	SREP(i,s){
		t=t+'x';
	}
	cout << t << endl;
///////////////////////////////////////////
}


Measured memory_bytes: 256
n = int(input())
a = ["a","b","c","d","e","f","g","h","i","j"]
def dfs(s):
  m = len(s)
  if m == n:
    ans = ""
    for i in range(n):
      ans += a[int(s[i])]
    print(ans)
  else:
    for i in range(int(max(list(s)))+2):
      dfs(s+str(i))

dfs("0")

Measured memory_bytes: 4340