akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int value[107], weight[107];

const int INF = 1e9 + 7;

int memo[107][(int)1e6+5];          //( element, max value
int n, w;


long long dp(int i, long long val)  //min weight to obtain the value val
{
	if (val <= 0)
		return 0;
	if (i >= n)
		return INF;

	if (memo[i][val] != -1)
		return memo[i][val];

	return memo[i][val] = min(dp(i+1, val), weight[i] + dp(i+1, val - value[i]));
}

int main()
{

	long long mxValue = 0;
	memset(memo, -1, sizeof(memo));

	cin >> n >> w;
	for (int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> value[i];
		mxValue += value[i];
	}

	for (long long j = mxValue; j >= 0; j--)
	{

		if (dp(0, j) <= w)
		{
			cout << j << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 418176
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

static constexpr ll MOD = 1e9+7;
static constexpr ll MAX = 200010;

ll mod_pow(ll x, ll p) {
  ll t = 1;
  ll u = x;
  while (p) {
    if (p & 1)
      t = t*u%MOD;
    u = u*u%MOD;
    p>>=1;
  }
  return t;
}

array<ll, MAX+1> fact={}, ifact={};

void init() {
  fact[0]=1;
  for (ll i = 1; i <= MAX; i++)
    fact[i]=fact[i-1]*i%MOD;
  ifact[MAX]=mod_pow(fact[MAX], MOD-2);
  for (ll i = MAX-1; i >= 0; i--)
    ifact[i]=ifact[i+1]*(i+1)%MOD;
}

ll mod_comb(ll x, ll y) {
  return fact[x]*ifact[y]%MOD*ifact[x-y]%MOD;
}

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

  ll n,k; cin>>n>>k;

  init();
  ll ans = 0;
  for (ll t = max(n-k,1ll); t <= n; t++) {
    ans += mod_comb(n, t)*mod_comb(n-1, t-1)%MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

int ttt;
ll A , B , C , D;

int main ( void ) {
	scanf ( "%d" , &ttt );
	while ( ttt-- ) {
		scanf ( "%lld%lld%lld%lld" , &A , &B , &C , &D );
		if ( A < B ) {
			puts ( "No" );
			continue;
		}
		if ( D < B ) {
			puts ( "No" );
			continue;
		}
		if ( C + 1 >= B ) {
			puts ( "Yes" );
			continue;
		}
		ll base = std :: __gcd ( B , D );
		if ( ( A - C - 1 ) / base - ( A - B ) / base > 0 ) {
			puts ( "No" );
			continue;
		}
		else puts ( "Yes" );
	}
	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
count = Array.new(n, 0)
k.times do
  gets  # 使わない
  gets.split.map{|s| s.to_i - 1}.each{|i| count[i] += 1}
end
puts count.select{|i| i == 0}.size


Measured memory_bytes: 14440
#include <cstdio>

using namespace std;

long long v[55],v1[55];

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int n;
    long long sol=0,c=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&v[i]);
    while(1)
    {
        int p=0;
        for(int i=1;i<=n;i++)
        {
            c+=v1[i];
            v[i]+=c;
            v1[i]=0;
            if(v[i]>=n)
            {
                p=1;
                long long x=v[i]/n;
                v[i]-=1LL*x*n;
                sol+=x;
                v1[1]+=x;
                v1[i]-=x;
                v1[i+1]+=x;
            }
        }
        c=0;
        if(p==0) break;
    }
    printf("%lld",sol);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

struct Person {
	long long int h;
	long long int p;
	bool operator <(const Person& P)const {
		if (h + p < P.h + P.p) {
			return true;
		}
		if (h + p > P.h + P.p) {
			return false;
		}
		return p < P.p;
	}
	bool operator >(const Person& P)const {
		if (h + p > P.h + P.p) {
			return true;
		}
		if (h + p < P.h + P.p) {
			return false;
		}
		return p > P.p;
	}
};

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

	cin >> N;
	vector<Person>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i].h >> v[i].p;
	}
	v.push_back({ 0,0 });
	sort(v.begin(), v.end());
	vector<vector<long long int>>dp(N + 1, vector<long long int>(N + 1, MOD*MOD));
	dp[0][0] = 0;
	//cout << endl;
	for (int i = 1; i <= N; i++) {
		//cout << v[i].h << " " << v[i].p << endl;
		dp[i][0] = 0;
		for (int j = 1; j <= N; j++) {
			dp[i][j] = dp[i - 1][j];
			if (dp[i - 1][j - 1] <= v[i].h) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + v[i].p);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= N; i++) {
		if (dp[N][i] != MOD*MOD)ans = i;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
		//	cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 195968
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(N);
    vll T(N);
    rep(i, N) cin >> T[i];
    ini(M);
    vll P(M), X(M);
    rep(i, M) cin >> P[i] >> X[i];

    ll sum = accumulate(T.begin(), T.end(), 0LL);
    rep(i, M)
        out(sum - T[P[i] - 1] + X[i]);
}


Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

char writeAnsWithoutBom(char ans) {
	if (ans != '#') {
		ans++;
	}
	return ans;
}

int main(){
#ifdef DEBUG
	
#endif
	int H,W;
	char S;
	char ans[50][50];
	scanf("%d %d", &H, &W);

	int i, j;
	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++) {
			ans[i][j] = '0';
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			scanf("%c", &S);
			if (S == '\n') {
				j--;
				continue;
			}
			if (S == '#') {
				ans[i][j] = '#';
				if (i != 0) {
					if (j != 0) {
						ans[i - 1][j - 1]=writeAnsWithoutBom(ans[i-1][j-1]);
					}
					ans[i - 1][j]=writeAnsWithoutBom(ans[i - 1][j]);
					if (j != W-1) {
						ans[i - 1][j + 1]=writeAnsWithoutBom(ans[i - 1][j + 1]);
					}
				}
				if (j != 0) {
					ans[i][j - 1]=writeAnsWithoutBom(ans[i][j - 1]);
				}
				if (j != W - 1) {
					ans[i][j + 1] =writeAnsWithoutBom(ans[i][j + 1]);
				}
				if (i != H-1) {
					if (j != 0) {
						ans[i+1][j - 1]=writeAnsWithoutBom(ans[i + 1][j - 1]);
					}
					ans[i + 1][j]=writeAnsWithoutBom(ans[i + 1][j]);
					if (j != W - 1) {
						ans[i + 1][j + 1]=writeAnsWithoutBom(ans[i + 1][j + 1]);
					}
				}
			}
		}
	}

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			printf("%c", ans[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 128
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if M1 + 1 == M2 and D2 == 1:
    print(1)
    exit()
if M1 == 12 and M2 == 1:
    if D2 == 1:
        print(1)
        exit()
print(0)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    for(int i = 1; i <= N; ++i) {
        int cnt = 0;
        for(int x = 1; x <= 100; ++x) {
            for(int y = 1; x * x + y * y + x * y < i; ++y) {
                for(int z = 1; x * x + y * y + z * z + x * y + x * z + y * z <= i; ++z) {
                    if(x * x + y * y + z * z + x * y + x * z + y * z == i) {
                        ++cnt;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main()
{
int i,c=0;
double p,n;
cin>>n;
for(i=1;i<=n;i++)
{
    if(i%2==1)
    {
        c++;
    }
}
p=c/n;
cout << std::setprecision(10) << p<< endl;
}


Measured memory_bytes: 256
N, M, X = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
#0<=Xの時
ans1 = a.select{|num| num < X}.length
#X=>5の時
ans2 = a.select{|num| num > X}.length

ans = ans1>ans2 ? ans2 : ans1
puts ans


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

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

	int transNum = 5;
	long long minC = 9223372036854775807LL;

	vector<long long > c(transNum); for (int i = 0; i < transNum; i++) {
		cin >> c[i];
		minC = min(minC, c[i]);
	}

	long long ans = (n + minC - 1) / minC + 4;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int n,s,v;
		boolean is;

		while(sc.hasNextInt()){
			n = sc.nextInt();
			if(n == 0)break;
			s = 0;

			for(int i = 2; i < n; i++){
				is = true;

				for(int j = 2; j <= Math.sqrt(i); j++)
					if(i % j == 0){
						is = false;
						break;
					}

				if(is){
					s = Math.max(s, i);
				}
			}
			for(int i = n + 1; ; i++){
				is = true;

				for(int j = 2; j <= Math.sqrt(i); j++)
					if(i % j == 0){
						is = false;
						break;
					}
				if(is){
					v = i;
					break;
				}
			}
			System.out.println(s + " " + v);
		}
		sc.close();
	}
}

Measured memory_bytes: 19884
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    int l = s.find('A');
    int r = s.find_last_of('Z');
    cout << r - l + 1 << endl;

    return 0;
}

Measured memory_bytes: 720
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::min;
use num_traits::abs;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn count_two(n: u64) -> u64 {
    fn go(count:u64, num: u64) -> u64 {
        if num % 2 == 0 {
            go(count +1, num / 2)
        } else {
            count
        }
    }
    go(0, n)
}

fn main() {
    let (n, k): (usize, usize) = read_tuple2();
    let xs:Vec<i64> = (0..n).map(|_|read()).collect();
    let left_rights = (0_usize..n - k + 1).map(|s|(xs[s], xs[s + k - 1]));
    let calc_costs = |left, right| {
        let left_to_right = abs(left) + abs(right - left);
        let right_to_left = abs(right) + abs(left - right);
        min(left_to_right, right_to_left)
    };
    let ans = left_rights.map(|(left, right)|calc_costs(left, right)).min().unwrap();
    println!("{}", ans);

}



Measured memory_bytes: 2792
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

f 0 = []
f n = n `mod` 10 : f (n `div` 10)

solve a = case a of
            2 -> "hon"
            4 -> "hon"
            5 -> "hon"
            7 -> "hon"
            9 -> "hon"
            0 -> "pon"
            1 -> "pon"
            6 -> "pon"
            8 -> "pon"
            3 -> "bon"


main = do
  n <- readLn :: IO Int
  let a = head $ f n

  putStrLn $ solve a


Measured memory_bytes: 3908
Cr = input()
while Cr:
    if Cr[-7:] == 'dreamer':
        Cr = Cr[0:-7]
    elif Cr[-6:] == 'eraser':
        Cr = Cr[0:-6]
    elif Cr[-5:] in ['dream', 'erase']:
        Cr = Cr[0:-5]
    else:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
 
#define PI 3.14159265359
 
int main(){
  double a, b, c;
  scanf("%lf%lf%lf", &a, &b, &c);
  printf("%.8f\n", a * b * sin(c * PI /180) / 2);
  printf("%.8f\n", a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * PI/ 180)));
  printf("%.8f\n",  b * sin(c * PI / 180));
  return 0;
}


Measured memory_bytes: 2052
#include <stdio.h>
#include <stdlib.h>

inline long gl(void){
    long x = 0;
    for(;;){
        int c=getchar_unlocked();
        if('0'<= c && c <='9'){
            x = x*10 + c-'0';
        }else{
            break;
        }
    }
    return x;
}

long gcd(long a, long b){
    if(a==0) return b;
    if(b==0) return a;
    do{
        long t=a%b;
        a=b;
        b=t;
    }while(b!=0);
    return a;
}

int main(void){
    long n=gl(), s=gl();
    long g=0;
    for(long i=0; i<n; i++){
        long t = gl();
        g=gcd(labs(t-s), g);
    }
    printf("%ld\n", g);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        try {
            InputReader in;
            PrintWriter out;
            boolean useOutput = false;
            // if (System.getProperty("ONLINE_JUDGE") == null) useOutput = true;
            if (useOutput) {
                FileInputStream fin = new FileInputStream(new File("src/testdata.in"));
                in = new InputReader(fin);
                FileOutputStream fout = new FileOutputStream(new File("src/testData.out"));
                out = new PrintWriter(fout);
            } else {
                InputStream inputStream = System.in;
                in = new InputReader(inputStream);
                OutputStream outputStream = System.out;
                out = new PrintWriter(outputStream);
            }
            Solver solver = new Solver();
            solver.solve(in, out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class Solver {

        public void solve(InputReader cin, PrintWriter cout) {
            try {
                // 本题中w很大，但是n * v很小，可以将价值和容量对换，将价值视为容量进行dp，记录的是使用的背包空间
                // 答案就从所有可能的价值中取最大的即可
                int n = cin.nextInt(), w = cin.nextInt();
                long dp[] = new long[100005 + 1];
                Arrays.fill(dp, Long.MAX_VALUE / 2);
                dp[0] = 0;
                for (int i = 0; i < n; ++i) {
                    int weight = cin.nextInt(), value = cin.nextInt();
                    for (int j = 100005 - value; j >= 0; --j) {
                        dp[j + value] = Math.min(dp[j + value], dp[j] + weight);
                    }
                }
                long res = Long.MIN_VALUE;
                for (int i = 0; i < 100005; ++i) {
                    if (dp[i] <= w) res = Math.max(res, i);
                }
                cout.println(res);
            } catch (RuntimeException e) {
                e.printStackTrace();
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)
    cout<<"Balanced"<<endl;
  else if(a+b<c+d)
    cout<<"Right"<<endl;
  else
    cout<<"Left"<<endl;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

string s;
int k;
int main()
{
	cin>>s>>k;
	int last=0;
	vector<int> vs;
	for(int i=0;i<(int)s.size();i++)
	{
		if(i==(int)s.size()-1||s[i]!=s[i+1])
		{
			vs.pb(i-last+1);
			last=i+1;
		}
	}
	LL ans=0;
	if(s[0]!=s[s.size()-1])
	{
		for(int i=0;i<(int)vs.size();i++)
			ans+=(LL)k*(vs[i]/2);
	}
	else if(vs.size()==1)ans=(LL)s.size()*k/2;
	else
	{
		for(int i=1;i<(int)vs.size()-1;i++)
			ans+=(LL)k*(vs[i]/2);
		ans+=vs[0]/2;ans+=vs[vs.size()-1]/2;
		ans+=(LL)(vs[0]+vs[vs.size()-1])/2*(k-1);
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val (a,b,c,x,y) = readLine()!!.split(" ").map { it.toInt() }
    val cMax = Math.max(x,y)*2
    var ans = cMax * c
    for(i in (0..cMax step 2)) {
        val aCount = Math.max(x - (i/2), 0)
        val bCount = Math.max(y - (i/2),0)
        ans = Math.min(ans, aCount*a+bCount*b+i*c)
    }
    println(ans)
}


Measured memory_bytes: 37844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const int INF = 1e9;
signed main(){
    int h,n; cin >> h >> n;
    int a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    int dp[n+1][h+1];
    rep(i,n+1)rep(j,h+1)dp[i][j]=INF;
    rep(i,n+1)dp[i][0]=0;
    rep(i,n){
        rep(j,h+1){
            chmin(dp[i+1][min(h,j+a[i])],dp[i][j]+b[i]);
            chmin(dp[i+1][min(h,j+a[i])],dp[i+1][j]+b[i]);
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][h] << endl;
}


Measured memory_bytes: 39296
alp = list("abcdefghijklmnopqrstuvwxyz")
ALP = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
tex = []
dic2 = dict(zip(ALP,alp))
while(1):
    try:
        t = list(input())
        tex.extend(t)
    except EOFError:
        break
dic = dict(zip(alp,[0 for i in range(26)]))
for i in tex:
    if i in alp:
        dic[i] += 1
    elif i in ALP:
        dic[dic2[i]] += 1
for i in alp:
    print("{} : {}".format(i,dic[i]))



Measured memory_bytes: 5584
/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 10/07/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

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




	ll n;
	cin>>n;
	ll x,ans=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>x;
		if((x&1) && (i&1)) ans++;
	}
	prn(ans);

}

Measured memory_bytes: 3644
c = 1
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	xy.append(xy[0])
	print c,abs(sum(xy[i][0]*xy[i+1][1] - xy[i+1][0]*xy[i][1] for i in range(n)))/2.0
	c += 1
	raw_input()

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

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

#define encode(x,y,z) (x<<20 | y<<10 | z)

int main(){
    int n, h;
    while (cin >> n >> h && n){
        vector<int> app;
        for (int i = 0; i < h; i++){
            string c;
            int a, b;
            cin >> c >> a >> b;
            for (int t = 1; t <= n; t++){
                if (c == "xy") app.push_back(encode(a, b, t));
                else if (c == "yz") app.push_back(encode(t, a, b));
                else app.push_back(encode(a, t, b));
            }
        }
        sort(app.begin(), app.end());
        app.erase(unique(app.begin(), app.end()), app.end());
        cout << n*n*n - app.size() << endl;
    }
}

Measured memory_bytes: 1612
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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() {
    int n,x;
    while(true) {
        cin >> n >> x;
        if(n==0 && x == 0) break;
        int ans = 0;
        for(int i = 1;i<=n;i++) {
            for(int j = i+1;j<=n;j++) {
                for(int k = j+1;k<=n;k++) {
                    if(i+j+k == x) ans++;
                }
            }
        }
    cout << ans << endl;
    }    
}



Measured memory_bytes: 3104
from collections import Counter as C
n,*a=map(int,open(0).read().split())
b=[]
for i in C(a).items():
  if i[1]>3:
    b+=[i[0],i[0]]
  elif i[1]>1:
    b+=[i[0]]
b=sorted(b)
print(b[-1]*b[-2] if len(b)>1 else 0)

Measured memory_bytes: 18528
#include <stdio.h>
#include <stdlib.h>
int a[50],b[50],c[50],d[50];
int cal(int i,int j)
{
    return abs(a[i]-c[j])+abs(b[i]-d[j]);
}
main()
{
    int i,j,k=999999999,m,N,M;
    scanf("%d%d",&N,&M);
    for(i=0;i<N;i++)
        scanf("%d%d",&a[i],&b[i]);
    for(i=0;i<M;i++)
        scanf("%d%d",&c[i],&d[i]);
    for(i=0;i<N;i++)
    {
        m=0;
        for(j=0;j<M;j++)
            if(k>cal(i,j))
                k=cal(i,j),m=j+1;
        k=999999999;
        printf("%d\n",m);
    }


}

Measured memory_bytes: 128
import itertools
N = int(input())
p_list = tuple(map(int,input().split()))
q_list = tuple(map(int,input().split()))

pattern_list = list(itertools.permutations(range(1,N+1))) # 順列の生成

cnt = 1
for pattern in pattern_list:
    if pattern == p_list:
        a = cnt
    if pattern == q_list:
        b = cnt
    cnt+=1


print(abs(a-b))



Measured memory_bytes: 8052
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s,t; cin>>s>>t;
  s+=s;
  bool f=false;
  rep(i,0,s.size()-t.size()+1){
    int c=0;
    rep(j,0,t.size()){
      if(t[j]==s[i+j]) c++;
    }
    if(c==t.size()){
      f=true;
      break;
    }
  }
  if(f==false) co("No");
  else co("Yes");
  
  return 0;
}


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

#define ll long long

using namespace std;

int main()
{
	string n;
	cin >> n;
	ll rem=0;
	for(char c : n)
	{
		rem += (c-'0')%9;
	}
	bool d = (rem/9)*9==rem;
	cout << (d?"Yes":"No") << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define nmax 200005

using namespace std;

vector <int> g[nmax];

int main(){
    int n,m;
    cin >> n >> m;
    while(m--){
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        sort(g[i].begin(),g[i].end());
    }
    for(int i=2;i<n;i++){
        if(binary_search(g[1].begin(),g[1].end(),i) &&
        binary_search(g[n].begin(),g[n].end(),i)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	string s;
	cin >> s;
	int n = s.size();

	ll res = 0;
	REP(bit, 1 << (n - 1)) {
		string tmp;
		REP(i, n) {
			tmp += s[i];
			if (!(bit & (1 << i))) {
					res += stol(tmp);
					tmp = "";
			}
		}
	}

	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 3652
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(int(1e5))

N, M = map(int, input().rstrip().split(' '))

g = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().rstrip().split(' '))
    g[y-1].append(x-1)
    
dp = [-1] * N
def rec(v):
    if dp[v] != -1:
        return dp[v]
        
    count = 0
    for x in g[v]:
        count = max(count, rec(x)+1)
        
    dp[v] = count
    
    return count
   
for i in range(N):
    rec(i)

print(max(dp))

Measured memory_bytes: 103984
#include <stdio.h>

int main (void)
{
    int a[3],b[3];
    for(int i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    b[0]=a[0];
    for(int i=1;i<3;i++)
    {
        b[i]=a[i];
        int j=i;
        while(b[j]<b[j-1]&&j>0)
        {
            int t=b[j];
            b[j]=b[j-1];
            b[j-1]=t;
            j--;
        }
    }
    printf("%d\n",b[0]+b[1]);
    return 0;
}


Measured memory_bytes: 128
import itertools

n = int(input())
p_li = tuple(map(int, input().split()))
q_li = tuple(map(int, input().split()))

n_li = [ i for i in range(1, n+1)]

s = list(itertools.permutations(n_li, len(n_li)))
s.sort()

p = 0
q = 0

for i in range(len(s)):
    if s[i] == p_li:
        p = i
    if s[i] == q_li:
        q = i

print(abs(p-q))

Measured memory_bytes: 13920
#include <stdio.h>

int main(void){
  int A,B,C,D;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&D);
  while(1){
    C-=B;
    if(C<=0){
      printf("Yes");
      return 0;
    }
    A-=D;
    if(A<=0){
      printf("No");
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1724
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def primes(x):
    is_prime = [True] * (x + 1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, int(sqrt(x))+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, x+1, i):
            is_prime[j] = False

    return [i for i in range(x+1) if is_prime[i]]


def main():
    X = INT()

    lis = primes(100003)
    print(lis[bisect_left(lis, X)])


if __name__ == '__main__':
        main()

Measured memory_bytes: 39664
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;
typedef long long ll;

ll h,w,x,y;
double s;

signed main(){
    cin>>w>>h>>x>>y;

    
    s=(double)w*(double)h/2.0;
    printf("%.10lf ",s);
    if(2*x==w&&2*y==h)cout<<1<<endl;
    else cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc105
# 12:25-


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    S = [None] * (N+1)
    S[0] = 0
    s = 0
    for i in range(N):
        s += A[i]
        S[i+1] = s
    
    R = [s % M for s in S]
    d = {}
    for r in R:
        if r in d:
            d[r] += 1
        else:
            d[r] = 1

    ans = 0
    for n in d.values():
        ans += n * (n-1) // 2

    return ans


print(main())


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

vector<vector<int>>coaster;
vector < vector<pair<int, int>>>difs;
int main() {
	int C, N; cin >> C >> N;
	{
		vector<vector<int>>field(N, vector<int>(N));
		for (int y = 0; y< N; ++y) {
			string st; cin >> st;
			for (int x = 0; x < N; ++x) {
				field[y][x]=st[x]-'0';
			}
		}
		coaster = field;
		difs.resize(C-1);
		for (int i = 0; i < C-1; ++i) {
			int D; cin >> D;
			while (D--) {
				int y, x; scanf("%d %d", &y, &x); y--; x--;
				difs[i].push_back(make_pair(y, x));
				
			}
		}
	}
	vector<vector<vector<int>>>vs(N / 2, 
		vector<vector<int>>(N / 2,vector<int>( 4)));
	int sum = 0;
	for (int y = 0; y < N; ++y) {
		for (int x = 0; x < N; ++x) {
			if (y >= N / 2 && x >= N / 2)vs[N - y - 1][N - x - 1][3] = coaster[y][x];
			if (y >= N / 2 && x < N / 2)vs[N - y - 1][x][2] = coaster[y][x];
			if (y < N / 2 && x >= N / 2)vs[y][N - x - 1][1] = coaster[y][x];
			if (y < N / 2 && x < N / 2)vs[y][x][0] = coaster[y][x];

		}
	}
	for (int y = 0; y < N / 2; ++y) {
		for (int x = 0; x < N / 2; ++x) {
			int nn = 0;
			for (int t = 0; t < 4; ++t) {
				nn += vs[y][x][t];
			}
			sum += (1 - ((nn == 0) || (nn == 4)));
			//sum+= 1-(all_of(vs[y][x].begin(), vs[y][x].end(), [=](const int a) {return a == vs[y][x][0]; }));
		}
	}
	int ans = 0;
	if (!sum)ans++;
	for (int i = 0; i < C-1; ++i) {
		for (auto dif : difs[i]) {
			int y = dif.first;
			int x = dif.second;
			coaster[y][x] = !coaster[y][x];
			int ay = y >= N / 2 ? N - y - 1 : y;
			int ax = x >= N / 2 ? N - x - 1 : x;
			{

				int nn = 0;
				for (int t = 0; t < 4; ++t) {
					nn += vs[ay][ax][t];
				}
				sum -= (1 - ((nn == 0) || (nn == 4)));
			}	
			//sum-= 1-(all_of(vs[ay][ax].begin(), vs[ay][ax].end(), [=](const int a) {return a == vs[ay][ax][0]; }));
			if (y >= N / 2 && x >= N / 2)vs[N - y - 1][N - x - 1][3] = coaster[y][x];
			if (y >= N / 2 && x < N / 2)vs[N - y - 1][x][2] = coaster[y][x];
			if (y < N / 2 && x >= N / 2)vs[y][N - x - 1][1] = coaster[y][x];
			if (y < N / 2 && x < N / 2)vs[y][x][0] = coaster[y][x];
			{
				int nn = 0;
				for (int t = 0; t < 4; ++t) {
					nn += vs[ay][ax][t];
				}
				sum += (1 - ((nn == 0) || (nn == 4)));
			}
			//sum += 1-(all_of(vs[ay][ax].begin(), vs[ay][ax].end(), [=](const int a) {return a == vs[ay][ax][0]; }));

		}
		if (!sum)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30864
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for1l(n) for (ll i = 0 ; i < n ; i++)
#define for2l(n) for (ll j = 0 ; j < n ; j++)

int main() {
    ios::sync_with_stdio(false);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1;
}

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

#define REP(i,x) for (int i=0; i<n; i++)
 
using namespace std;


int main(){
    int len;
    string str;
    long long int ans = 1;
    int count_arr[26];
    
    
    for(int i=0; i<26; i++){
        count_arr[i] = 1;
    }
    
    cin >> len >> str;
    for(int i=0; i<len; i++){
        count_arr[str[i]-97]++;
    }
    
    for(int i=0; i<26; i++){
        ans = (ans*count_arr[i])%(int)(pow(10,9)+7);
    }
    
    ans = ans-1;
    cout << ans << endl;
	
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using lint = long long int;
using namespace std;

int main()
{
	int N, D;
	cin >> N >> D;
	int** X = new int* [N];
	for (int i = 0; i < N; i++) {
		X[i] = new int[D];
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}

	int count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			int dis = 0;
			for (int d = 0; d < D; d++) {
				dis += pow(abs(X[i][d] - X[j][d]), 2);
			}
			int n = sqrt(dis);
			if (n * n == dis)
				count++;
		}
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define mod 1000000007
#define INF 1000000000000000

bool flag[1000005];
pair<ll,ll> prime[500005];

void seive()
{
    flag[1]=1;

    for(int i=4;i<=1000000;i+=2)
    {
        flag[i]=1;
    }

    int root=sqrt(1000000);
    for(int i=3;i<=root;i+=2)
    {
        if(flag[i]==0)
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                flag[j]=1;
            }
        }
    }
}
int main()
{

    int cnt=0;
    seive();
    for(int i=1;i<=1000000;i++)
    {
        if(flag[i]==0)
        {
            prime[cnt]={i,0};
            cnt++;
        }
    }

    ll n,p;
    cin>>n>>p;

    if(n==1)
    {
        cout<<p;
        return 0;
    }

    for(int i=0;i<cnt;i++)
    {
        while(p%prime[i].f==0)
        {
            prime[i].s++;
            p/=prime[i].f;
        }
    }

    ll ans=1;

    for(int i=0;i<cnt;i++)
    {
        prime[i].s/=n;
        int j=0;
        while(j<prime[i].s)
        {
            ans*=prime[i].f;
            j++;
        }
    }

    cout<<ans;
}




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

const ll INF = 1e18;
ll dp[110][100010];

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

    int n,W;
    cin >> n >> W;

    rep(i,110) rep(j,100010) dp[i][j] = INF;
    dp[0][0] = 0;

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

    for(int i = 1; i <= n; i++){ //i番目までを使う
        for(int j = 0; j < 100010; j++){
            if(j - v[i] >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j - v[i]] + w[i]);
            }
            dp[i][j] = min(dp[i][j],dp[i-1][j]);
        };
    }
    int ans = 0;
    rep(i,100010) {
        if(dp[n][i] <= W){
            ans = max(ans,i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

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

int main() {
	ll a, b; cin >> a >> b;
	ll g = gcd(a, b);
	ll ans = a * b / g;
	dunk(ans);
	return 0;
}


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
import itertools

ans = 0
for ff, i in enumerate(itertools.product([0, 1], repeat=10)):
    if sum(i) == 0:
        continue
    point = 0
    for idx, f in enumerate(F):
        count = 0
        for a, b in zip(i, f):
            count += a * b
        point += P[idx][count]

    if ff == 1:
        ans = point
    else:
        # if max(ans, point) == point:
        #     print(i)
        ans = max(ans, point)

print(ans)

Measured memory_bytes: 42604
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define _GLIBCXX_DEBUG
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    string s;
    cin >> s;
    reverse(ALL(s));
    string t[4] = {"dream", "dreamer", "erase", "eraser"};
    rep(i, 4) reverse(ALL(t[i]));
    bool a = true;
    for (int i = 0; i < (int)s.size();) {
        bool b = false;
        rep(j, 4) {
            if (s.substr(i, t[j].size()) == t[j]) {
                b = true;
                i += t[j].size();
            }
        }
        if (!b) {
            a = false;
            break;
        }
    }
    if (a)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int N;
int ans[100000];
int A[100000];

template <class T>
inline void qswap(T& a,T& b);
template <class T>
void qsort(T* x,int left,int right);

template <class T>
inline void qswap(T& a,T& b){
    T tmp=a;
    a=b;
    b=tmp;
}

template <class T>
void qsort(T* x,int left,int right){
    if(right-left<=1) return;
    int pivod=x[(right+left)/2];

    qswap(ans[(right+left)/2],ans[right-1]);
    qswap(x[(right+left)/2],x[right-1]);
    int i=left;
    for(int j=left;j<right-1;j++){
        if(x[j]<pivod){
            qswap(ans[i],ans[j]);
            qswap(x[i++],x[j]);
        }
    }
    qswap(ans[i],ans[right-1]);
    qswap(x[i],x[right-1]);

    qsort(x,left,i);
    qsort(x,i+1,right);
}

int main(){
    cin>>N;
    rep(i,N){
        cin>>A[i];
        ans[i]=i+1;
    }

    qsort(A,0,N);

    rep(i,N) cout<<ans[i]<<' ';
}

Measured memory_bytes: 1536
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Measured memory_bytes: 40656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll ans = power(10, n, mod);
    ll temp1 = power(9, n, mod);
    temp1 = (temp1 * 2) % mod;
    ll temp2 = (-power(8, n, mod) + temp1 + mod) % mod;
    ans = (ans + mod - temp2) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
struct UnionFind {
  vector<long> par; 
  vector<long> siz; 
  UnionFind(long N) : par(N),siz(N,1) { 
    rep(i,N) par[i] = i;
  }
  void init(long n) {
    par.resize(n);
    siz.assign(n, 1LL);
    for (long i = 0; i < n; ++i) par[i] = i;
  }
  long root(long x) { 
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(long x, long y) {
    long rx = root(x); 
    long ry = root(y);
    if (rx == ry) return;  
    if (siz[rx] < siz[ry]) swap(rx, ry);
    siz[rx] += siz[ry];
    par[ry] = rx;  
  }
  bool same(long x, long y) {
    long rx = root(x);
    long ry = root(y);
    return rx == ry;
  }
  
  long size(long x) { 
    return siz[root(x)];
  }
};

int main() {
  long n,m;
  cin >> n>>m;
  vector<long>a(m),b(m);
  rep(i,m){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  UnionFind tree(n);
  vector<long>ans(m);
  ans.at(m-1)=n*(n-1)/2;
  for(int i=m-1;i>0;i--){
    if(tree.same(a.at(i),b.at(i))){
      ans.at(i-1)=ans.at(i);
    }
    else{
      ans.at(i-1)=ans.at(i)-tree.size(a.at(i))*tree.size(b.at(i));
      tree.unite(a.at(i),b.at(i));
    }
  }
  rep(i,m){
    cout<<ans.at(i)<<endl;
  }
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a > b) {
        cout << a - 1 << endl;
    } else {
        cout << a << endl;
    }
}

Measured memory_bytes: 256