akhauriyash/Code-Regression huggingface dataset:
N,D=map(int,input().split())

if D ==0:
    print(N)
for i in range(1,N+1):
        P=N//(i*(2*D+1))
        L=N%(i*(2*D+1))
        if P < 1:
            print(i)
            break
        elif P == 1 and L == 0:
            print(i)
            break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,a,n) for(ll i=a;i<n;i++)
#define ford(i,a,n) for(ll i=n-1;i>=a;i--)
#define testc  ll ts;\
               cin>>ts;\
               while(ts--)
#define arn ll n;\
            cin>>n;\
            ll a[n];\
            forr(i,0,n)cin>>a[i];\
               
#define arr(a,n) ll a[n];\
                 forr(i,0,n)cin>>a[i];\
 
#define sss <<" "<<
#define nnn <<"\n"
#define nl cout<<"\n";
using namespace std;
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    if(n>=30)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int a[102];
    memset(a,0,sizeof(a));

    int n,x,y;
    cin>>n>>x;

    for(int i=0; i<x; i++){
        cin>>y;
        a[y]++;
    }
    if(a[n]==0){
        cout<<n<<endl;
    }
    else {

        int ans = 1000;
        y = 1000;

        for(int i=0; i<=101; i++){
            if(a[i]==0){
				//cout<<abs(i-n)<<"  ";
                if(abs(i-n)<y){
                    y=abs(i-n);
                    ans=i;
                }
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3640
def f(n):
    if n % 2 == 0:
        return ((n // 2) % 2) ^ n
    else:
        return (((n+1) // 2) % 2)

A, B = map(int, input().split())
if A == 0:
    print(f(B))
else:
    print(f(A-1) ^ f(B))

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    REP(i, N+1) cin >> A[i];
    REP(i, N) cin >> B[i];

    ll res = 0;
    REP(i, N){
    	ll tao = min(A[i], B[i]);
    	A[i] -= tao;
    	B[i] -= tao;
    	res += tao;

    	tao = min(A[i+1], B[i]);
    	A[i+1] -= tao;
    	B[i] -= tao;
    	res += tao;
    }

    cout << res  << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	// eachTest

	int n;
	cin >> n;
	vector <ll> arr(n);
	FOR(i,0,n) {
		cin >> arr[i];
	}
	ll sum[n][n];
	FOR(i,0,n) {
		sum[i][i] = arr[i];
		FOR(j,i+1,n) {
			sum[i][j] = sum[i][j-1] + arr[j];
		}
	}
	ll table[n][n];
	FOR(i,0,n) {
		table[i][i] = 0;
	}
	FOR(l,2,n+1) {
		FOR(i,0,n) {
			int j = i+l-1;
			if (j >= n) {
				break;
			}
			// table[i][j] = arr[i] + table[i+1][j];
			table[i][j] = arr[i] + sum[i+1][j] + table[i+1][j];
			FOR(k,i+1,j) {
				// joining [i..k] and [k+1..j]
				table[i][j] = min(table[i][j], table[i][k] + table[k+1][j] + sum[i][j]);
				// table[i][j] = min(table[i][j], table[i][k] + table[k+1][j]);
			}
		}
	}
	cout << table[0][n-1] << "\n";

	return 0;
}


Measured memory_bytes: 2816
unittest
{
	assert( [ "2", "ABCXYZ" ].parse.expand.solve == "CDEZAB" );
	assert( [ "0", "ABCXYZ" ].parse.expand.solve == "ABCXYZ" );
	assert( [ "13", "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ].parse.expand.solve == "NOPQRSTUVWXYZABCDEFGHIJKLM" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( uint );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( n, s );
}

auto solve( uint n, dchar[] s )
{
	foreach( ref c; s )
	{
		if( c + n <= 'Z' ) c = c + n;
		else               c = 'A' - 1 + c + n - 'Z';
	}
	return s;
}


Measured memory_bytes: 380
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int number = sc.nextInt();
    int[] array = new int[number];
		for(int i = 0; i < number; i++){
      array[i] = sc.nextInt();
    }

    Arrays.sort(array);
    int total = 0;
    for(int i = 0; i < array.length-2; i++){

        for(int j = 1+i; j < array.length-1; j++){

            for(int k = 1+j; k < array.length; k++){
              if(array[i]+array[j] <= array[k])
                break;
              total++;
            }

        }

    }

    System.out.println(total);
	}
}

Measured memory_bytes: 28384
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let mut ca = a.clone();
    ca.sort();
    let m = ca[n - 1];
    let sm = ca[n - 2];
    for i in 0..n {
        if a[i] < m {
            println!("{}", m)
        } else {
            println!("{}", sm)
        }
    }
}


Measured memory_bytes: 7208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
using namespace std;
using ll = long long;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

int main(){
    int n,tmp;
    vector<int> line[2];
    cin >> n;

    line[0].resize(n);
    line[1].resize(n);
    
    rep(i,2){
        rep(j,n){
            cin >> tmp;
            if(j > 0) {
                tmp += line[i][j-1];
            }
            line[i][j] = tmp;
        }
    }

    int max = 0,amount = 0;
    rep(j,n){
        amount = line[0][j] + line[1][n-1];
        if(j>0)  amount-= line[1][j-1];
        if(max < amount) max = amount;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int tst_count;

void inserSort(int A[], int n, int g){
    if (g > n) return;
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            tst_count++;
        }
        A[j + g] = v;
    }
}

void shell(int A[],int n){
    tst_count = 0;
    int m = 11;
    int G[11] = {1,4,13,40,121,364,1093,3280,9841,29524,88573};
    
    while (G[m-1] > n) {
        m--;
    }

    for (int i = m-1; i >= 0; i--) {
        inserSort(A,n,G[i]);
    }
    
    cout << m << endl << G[m-1];
    for (int i = m-2; i >= 0; i--) {
        cout << " " << G[i];
    }
    cout << endl << tst_count << endl;
}

int main(){
    int n;
    int A[1000001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    shell(A,n);
    
    for (int i = 0; i < n; i++) {
        printf("%d\n",A[i]);
    }
    
    return 0;
}

Measured memory_bytes: 5176
from math import factorial


N, M = map(int, input().split())
m = 10**9 + 7
if abs(N-M) >= 2:
    print(0)
elif abs(N-M) == 1:
    print(factorial(N) * factorial(M) % m)
else:
    print(2 * factorial(N) * factorial(M) % m)


Measured memory_bytes: 5184
import Data.List

main = do
  str <- getLine
  _ <- getLine
  getContents >>= process str . lines
  where
    process acc [] = return ()
    process acc (x:xs)
      | cmd == "print" = do
        print' params acc
        process acc xs
      | cmd == "reverse" = do
        process (reverse' params acc) xs
      | cmd == "replace" = do
        process (replace' params acc) xs
      where (cmd:params) = words x
    print' [a, b] xs = putStrLn $ slice a' b' xs
      where
        a' = read a :: Int
        b' = read b :: Int
    reverse' [a, b] str = (take a' str) ++ (reverse $ slice a' b' str) ++ (drop (b'+1) str)
      where
        a' = read a :: Int
        b' = read b :: Int
    replace' [a, b, p] str = (take a' str) ++ p ++ (drop (b'+1) str)
      where
        a' = read a :: Int
        b' = read b :: Int
    read' = lines
    slice from to xs = take (to - from + 1) (drop from xs)



Measured memory_bytes: 5240
#include <stdio.h>

int main() {

  int n,i,j,x,y,temp,A[100001];
  
  scanf("%d",&n);
  for(i = 1; i < n+1; i++) {
    scanf("%d",&A[i]);
  }

  x = A[n];
  i = 0;
  for(j = 1; j < n; j++) {
    if(A[j] <= x) {
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  
  temp = A[i+1];
  A[i+1] = A[n];
  A[n] = temp;
  y = i+1;
 

  for(i = 1; i < n+1; i++) {
    if(i == y) printf("[%d]",A[i]);
    else printf("%d",A[i]);
    
    if(i < n) printf(" ");
    else printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  ll N;
  ll ans;
  ll i=0;
  cin >> N;
  while(N>=ans){
    i++;
    ans=i*i;
  }
  ans=(i-1)*(i-1);
  cout << ans;
}

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

using namespace std;

#define INF 999999999

int main(){
	int i, j, n;
	int ans;
	cin >> n;
	while(n > 1){
		ans ++;
		if(n%3==0)n = n/3;
		else n = n/3 + 1;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    s+='$';
    ll cnt=1;
    ll ans=0;
    rep(i,n){
        if(s[i+1]==s[i])cnt++;
        else{
            ans++;
            cnt=1;
        }
    }
    cout<<ans<<endl;
}

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

typedef long long ll;

using namespace std;

int main()
{
    int n; cin >> n;
    double ans = 0;
    double x[n];
    string u[n];
    for (int i = 0; i < n; i++){
        cin >> x[i] >> u[i];
    }

    for (int i = 0; i < n; i++){
        if (u[i] == "BTC"){
            ans += x[i] * 380000.0;
        }
        else
        {
            ans += x[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    x = sorted(list(map(int, input().split())))

    d = sorted([x[i+1] - x[i] for i in range(m-1)], reverse=True)
    print(sum(d[n-1:]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 13960
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int k, r = 7, i = 1;
	cin >> k;
	while (i < 10000000) {
		if (r % k == 0) {
			printf("%d\n", i);
			return 0;
		}
		r *= 10;
		r += 7;
		r %= k;
		i++;
	}
	puts("-1");
	return 0;
}


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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int sum=0;
	for(int i=0; i<(int)s.size(); ++i)
		sum+=s[i]-'0';
	if(sum%9==0)
		cout << "Yes";
	else
		cout << "No";
	cout << "\n";
}


Measured memory_bytes: 3612
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

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

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void dfs(ll n, ll m, ll i, vector<ll> &v){
  if(i == n){
  }else{
    for(int k = 1; k <= m; k++){
      v.push_back(k);
      dfs(n, m, i+1, v);
      v.pop_back();
    }
  
  }
}

void solution(){
  ll x;
  cin >> x;
  map<ll, ll> a, b;
  for(int i = 0; i <= 10000; i++){
    a[pow(i, 5)]= i;
    b[pow(-i, 5)] = -i;
  }

  // for(auto it: a) cout << it.first << ":" << it.second << endl;
  for(auto it: a){
    for(auto it2: b){
      ll tmp = it.first - it2.first;
      if(tmp == x){
        cout << it.second << " " << it2.second << endl;
        return;
      }

      tmp = it.first + it2.first;
      if(tmp == x){
        cout << it.second << " " << -1*it2.second << endl;
        return;
      }
    }
  }
}     



Measured memory_bytes: 4488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
void read(int&x){
	x=0;char c=getchar();
	while (!isdigit(c))c=getchar();
	while (isdigit(c))x=x*10+c-'0',c=getchar();
}
#define maxn 300005



int n,a[maxn];
void solve_even(){
	int odd=0,even=0;
	rep(i,1,n)if (i&1)odd+=a[i];else even+=a[i];
	printf("%d %d\n",max(odd,even),min(odd,even));
}
bool check(int mid){
	int s=0;
	for (int i=1;i<=n;i+=2){
		s+=a[i];bool flag=false;if (s>=mid)flag=true;
		s-=a[i+1];if (flag&&s<0)s=0;
	}
	return s>=mid;
}
void solve_odd(){
	int s=0;rep(i,1,n)s+=a[i];
	int l=-s,r=s;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid))l=mid+1;else r=mid-1;
	}
	rep(i,1,n)if (~i&1)r+=a[i];
	printf("%d %d\n",r,s-r);
}
int main(){
	read(n);rep(i,1,n)read(a[i]);
	if (~n&1)solve_even();else solve_odd();
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		int s = sc.nextInt();
		if(i >= s) {
			System.out.println(i - s);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 22868
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  int n = in;
  auto d = in.Array(n);
  sort(all(d), greater<void>());
  int f = 100000;
  int cnt = 0;
  rep(i, n) {
    if (f > d[i]) {
      cnt++;
      f = d[i];
    }
  }
  cout << (cnt) << endl;

}


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

int main() {
    string s;
    cin >> s;
    if(s=="SSR")cout << 1 <<endl;
    if(s=="SRR")cout << 2 <<endl;
    if(s=="SRS")cout << 1 <<endl;
    if(s=="RRS")cout << 2 <<endl;
    if(s=="RSS")cout << 1 <<endl;
    if(s=="RSR")cout << 1 <<endl;
    if(s=="SSS")cout << 0 <<endl;
    if(s=="RRR")cout << 3 <<endl;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int find(int x) {
    return x == par[x] ? x : par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] > sizes[y]) swap(x, y);

    par[x] = y;
    sizes[y] += sizes[x];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

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

  int N, M; cin >> N >> M;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i]; p[i]--;
  }

  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int x, y; cin >> x >> y; x--; y--;
    uf.unite(x, y);
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
    if (uf.same(i, p[i])) ans++;
  cout << ans << "\n";
}

Measured memory_bytes: 1408
<?php
$W=trim(fgets(STDIN));
$Wl=strlen($W);
for($k=0;$k<$Wl;$k++){
  $n=ord($W[$k]);
  if($n<65) continue;
  if($n<91) $W[$k]=chr($n+32);
}

$C=0;
while(1){
  $T=trim(fgets(STDIN));
  if($T=='END_OF_TEXT') break;

  $Tl=strlen($T);
  for($k=0;$k<$Tl;$k++){
    $n=ord($T[$k]);
    if($n<65) continue;
    if($n<91) $T[$k]=chr($n+32);
  }

  $Ts=explode(' ',$T);
  foreach($Ts as $t) if($t==$W) ++$C;
}
echo $C;
?>

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

#define S

const int vmax=100010;

vector<int> graph[vmax],ord,low,scc,par;
stack<int>s;

void dfs(int v,int p,int &k){
	ord[v]=k++;
	low[v]=ord[v];
	par[v]=p;
	#ifdef S
		s.push(v);
	#endif
	for(auto &i:graph[v]){
		if(ord[i]==-1){
			dfs(i,v,k);
			low[v]=min(low[v],low[i]);

		#ifdef S
			}else if(scc[i]==-1){
		#else
			}else if(i!=p){
		#endif
			low[v]=min(low[v],ord[i]);
		}
	}
	#ifdef S
		if(ord[v]==low[v]){
			while(1){
				int u=s.top();s.pop();
				scc[u]=v;
				if(u==v) break;
			}
		}
	#endif
}

void lowlink(int n){
	int k=0;
	ord.assign(n,-1),low.resize(n);
	scc.assign(n,-1),par.resize(n);
	rep(i,n) if(ord[i]==-1) dfs(i,-1,k);
}

int main(void){
	int v,e;
	cin >> v >> e;
	rep(loop,e){
		int a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		#ifdef S
		#else
			graph[b].push_back(a); // B,A
		#endif
	}
	lowlink(v);

/*	rep(i,v){
		cout << "ord[" << i << "]=" << ord[i]  << endl;
		cout << "low[" << i << "]=" << low[i]  << endl;
	}
*/

// Bridge
#ifdef B
	vector<pair<int,int>> bridge;
	rep(i,v){
		int j=par[i];
		if(j==-1)
			continue;
		if(ord[i] < low[j] || ord[j] < low[i] ){
			auto in=make_pair(i,j);
			if(in.second<=in.first) swap(in.first,in.second);
			bridge.push_back(in);
		}
	}
	sort(bridge.begin(),bridge.end());
	for(auto &i:bridge)
		cout << i.first << " " << i.second << endl;
#endif

// Articulation Points
#ifdef A
	vector<int> articulation_point;
	rep(i,v){
		if(i){
			bool ok=false;
			for(auto &j:graph[i]){
				if(i==par[j]&&ord[i]<=low[j])
					ok=true;
			}
			if(ok) articulation_point.push_back(i);
		}else{
			int d=0;
			rep(j,v) if(par[j]==0) d++;
			if(d>=2) articulation_point.push_back(i);
		}
	}
	sort(articulation_point.begin(),articulation_point.end());
	for(auto &i:articulation_point)
		cout << i << endl;
#endif
// Strongly Connected Components
#ifdef S
	int q;
	cin >> q;
	rep(loop,q){
		int a,b;
		cin >> a >> b;
		cout << (scc[a]==scc[b]) << endl;
	}
#endif
	return 0;
}

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

int n ;
int p ;
int max ;
int ans[110] ;
int count[110] ;

int main ( )
{
	memset ( count , 0 , sizeof ( count ) ) ;
	max = 1 ;
	p = 0 ;
	while ( scanf ( "%d" , &n ) == 1 ) {
		count[n]++ ;
	}
	for ( int i = 0 ; i < 110 ; i++ ) {
		if ( count[i] > max ) {
			max = count[i] ;
			p = 0 ;
			ans[p++] = i ;
		}
		else if ( count[i] == max ) {
			ans[p++] = i ;
		}
	}
	for ( int i = 0 ; i < p ; i++ ) {
		printf ( "%d\n" , ans[i] ) ;
	}
	return 0 ;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define L 1000004

class RollingHash {
  ll base, mod;
  ll ptable[L];
  ll h[L];
  int sz;
public:
  RollingHash(string s, ll base, ll mod) : base(base), mod(mod) {
    sz = s.length();
    h[0] = 0;
    for(int i=0; i<sz; ++i) {
      h[i+1] = (h[i] * base + s[i]) % mod;
    }
    ptable[0] = 1;
    for(int i=0; i<sz; ++i) {
      ptable[i+1] = (ptable[i] * base) % mod;
    }
  }

  ll get(int l, int r) {
    // assert(0 <= l && r <= sz && l <= r);
    return (h[r] + ((mod - h[l]) * ptable[r-l] % mod)) % mod;
  }
};
string t, p;

int main() {
  cin >> t >> p;
  RollingHash rh1(t, 37, 1000000009), rh2(p, 37, 1000000009);
  ll v = rh2.get(0, p.size());
  for(int i=0; i<=max((int)(t.size()-p.size()), 0); ++i) {
    if(rh1.get(i, i+p.size()) == v) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define MAX 100008
ll a, b, q, posa[MAX], posb[MAX], neara[MAX], nearb[MAX], x, high, low;

int main(){
	cin >> a >> b >> q;
	for(ll i = 1; i <= a; i++){cin >> posa[i];}
	for(ll i = 1; i <= b; i++){cin >> posb[i];}
	
	ll atb = 1;
	for(ll i = 1; i <= a; i++){
		while(1){
			if(atb == b || abs(posb[atb]-posa[i]) <= abs(posb[atb+1]-posa[i])){
				neara[i] = abs(posb[atb]-posa[i]);
				break;
			}
			else{atb++;}
		}
	}
	
	ll ata = 1;
	for(ll i = 1; i <= b; i++){
		while(1){
			if(ata == a || abs(posa[ata]-posb[i]) <= abs(posa[ata+1]-posb[i])){
				nearb[i] = abs(posa[ata]-posb[i]);
				break;
			}
			else{ata++;}
		}
	}
	
	for(ll i = 1; i <= q; i++){
		cin >> x;
		ll ans;
		
		high = a;
		low = 1;
		while(high-low > 1){
			ll mid = (high+low)/2;
			if(posa[mid] < x){low = mid;}
			else{high = mid;}
		}
		ans = abs(posa[high]-x)+neara[high];
		ans = min(abs(posa[low]-x)+neara[low], ans);
		
		high = b;
		low = 1;
		while(high-low > 1){
			ll mid = (high+low)/2;
			if(posb[mid] < x){low = mid;}
			else{high = mid;}
		}
		ans = min(abs(posb[high]-x)+nearb[high], ans);
		ans = min(abs(posb[low]-x)+nearb[low], ans);
		
		cout << ans << endl;
	}
	
	return 0;
}

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

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;}

const long long INF = 1LL << 60;
const long long mod = 1000000007;
int main(void){
    ll n; cin >> n;
    ll ans = 100000000;
    ll j,k=0;
    for(ll i=1;i*i<=n;i++){	
	if(n%i != 0) continue;
	 j = n/i;
    }
    while(j>0){
	j /= 10;
    	k++;
    }
    ans = k;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

constexpr char endl('\n');

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define INF 100000000000ULL

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    //size_t n;
    //cin >> n;
    //string s;
    //cin >> s;

    size_t n, sum;
    cin >> n;
    sum = 0;

    FOR(i, 1, n+1) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << ::endl;
    

    return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(a>c){
        int tmp=a;
        a=c;
        c=tmp;
    }
    if(b>c){
        int tmp=b;
        b=c;
        c=tmp;
    }

    int ans=(c-b);
    a+=(c-b);
    ans+=((c-a)/2)+((c-a)%2)*2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	string s;
	cin>>s;
	int cnt=0;
	int ans=0;
	rep(i,s.size()){
		if (s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T') cnt++;
		else cnt=0;
		ans=max(cnt,ans);
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int find(int x);
int same(int x,int y);
void unite(int x,int y);
typedef pair<int,int>P;
typedef pair<P,P>Q;
vector<P>w;
vector<P>h;
vector<Q>vec;
int p[100009];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)p[i]=i;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    w.push_back(P(x,i));
    h.push_back(P(y,i));
  }

  sort(w.begin(),w.end());
  sort(h.begin(),h.end());

  for(int i=0;i<n-1;i++){
    int xa=w[i].fi;
    int a=w[i].se;
    int xb=w[i+1].fi;
    int b=w[i+1].se;
    vec.push_back(Q(P(xb-xa,a),P(b,0)));
  }
  for(int i=0;i<n-1;i++){
    int ya=h[i].fi;
    int a=h[i].se;
    int yb=h[i+1].fi;
    int b=h[i+1].se;
    vec.push_back(Q(P(yb-ya,a),P(b,0)));
  }

  sort(vec.begin(),vec.end());

  long long ans=0;
  for(int i=0;i<vec.size();i++){
    int w=vec[i].fi.fi;
    int s=vec[i].fi.se;
    int t=vec[i].se.fi;
    if(!same(s,t)){
      unite(s,t);
      ans+=w;
    }
  }

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

int find(int x){
  if(p[x]==x)return x;
  return p[x]=find(p[x]);
}

int same(int x,int y){
  if(find(x)==find(y))return 1;
  return 0;
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  p[x]=y;
}


Measured memory_bytes: 8424
#include<bits/stdc++.h>
#define int long long

using namespace std ;
const int  N =1e5 + 5 ;

int grundy[N] ; 
int calculateMex(unordered_set<int> &s)
{
	int mex = 0  ; 
	while(s.find(mex) != s.end())
	{
		mex++ ; 
	}
	return mex ; 
}
int calculategrundy(int n , vector<int> &a)
{
	if(grundy[n] != -1 )
		return grundy[n] ; 
	unordered_set<int> s ; 
	for(int i = 0 ; i< (int) a.size() ; ++i)
	{
		if( n >= a[i])
	 		s.insert(calculategrundy(n-a[i] , a)) ; 
	}			
	return grundy[n] = calculateMex(s) ; 
}
 
signed main()
{
	ios_base::sync_with_stdio(false) ; 
	cin.tie(NULL) ;            
	                        

	int  n ,  k  ;
	cin >> n >> k ; 
	 	 
	vector<int> a(n); 
	for(int i = 0 ; i < n ; ++i)
	{
		cin >> a[i] ;
	}
	 
	memset(grundy ,-1 , sizeof(grundy)) ; 	                                                                                  
	grundy[0] = 0 ;
	int ans = calculategrundy(k ,a) ;  
	if(ans > 0 )
	{
		cout<<"First" << endl ;
		return 0  ; 
 
	}
	cout << "Second" << endl ;



	
}


Measured memory_bytes: 21548
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
void solve(){
    int a, b;
    cin>>a>>b;
    int g = __gcd(a, b);
    cout<<(a*b)/g;   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a[110];
	int count = 0;
	int i;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(i%2 == 1){
			if(a[i]%2 == 1){
				count++;
			}
		}
	}
	
	printf("%d",count);
	
	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;

  reverse(s.begin(), s.end());
  vector<ll> acc;
  const ll mod = 2019;
  acc.resize(mod, 0);
  acc[0] = 1;

  ll d = 1;
  ll sum_of_digits = 0;
  for (auto i = 0; i < s.size(); i++)
  {
    auto digit = s.at(i) - '0';
    sum_of_digits += digit * d;
    sum_of_digits %= mod;

    // cout << "sumofdigit: " << sum_of_digits << endl;
    d *= 10;
    d %= mod;
    acc[sum_of_digits]++;
  }

  ll ans = 0;
  for (auto i = 0; i < mod; i++)
  {
    if (acc[i] > 0)
    {
      // cout << "i: " << i << "sum: " << acc[i] << endl;
      ans += acc[i] * (acc[i] - 1) / 2;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

struct vertex
{
    int i;
    int j;
    int cost;
    bool operator<(const vertex &v) const {
        return cost < v.cost;
    }
};

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h, w;
    char arr[100][100];
    int dist[100][100] = {0};
    cin >> h >> w;

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

    multiset<vertex> s;
    s.insert({0, 0, arr[0][0] == '#'?1:0}); 
    dist[0][0] = arr[0][0] == '#'?1:0;
    auto it = s.begin();
    int r, c, cost;
    while (!s.empty())
    {
        // for (auto && x : s)
        // {
        //     cout << x.i << ',' << x.j << ',' << x.cost << ' ';
        // }
        // cout << '\n';
        it = s.begin();
        r = it->i;
        c = it->j;
        if (r == h-1 && c == w-1)
            break;
        // s.erase()
        if (r < h-1)
        {
            cost = (arr[r][c] == '.' && arr[r+1][c] == '#') ? 1 : 0;
            if (dist[r+1][c] > dist[r][c] + cost)
            {
                // cout << "right insert\n";
                dist[r+1][c] = dist[r][c] + cost;
                s.insert({r+1, c, dist[r][c] + cost});
            }
        }
        if (c < w-1)
        {
            cost = (arr[r][c] == '.' && arr[r][c+1] == '#') ? 1 : 0;
            if (dist[r][c+1] > dist[r][c] + cost)
            {
                // cout << "down insert\n";
                dist[r][c+1] = dist[r][c] + cost;
                s.insert({r, c+1, dist[r][c] + cost});
            }
        }

        s.erase(it);
    }

    cout << dist[h-1][w-1];
        
}

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

int main()
{
	int N, c1 = 0, c2 = 0;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			c2++;
		}
		else if (a[i] % 2 == 0) {
			c1++;
		}
	}
	if (c1 == 0 && c2 == 0) {
		cout << "No" << endl;
	}
	else if (c1 == 0) {
		cout << (c2 * 2 + 1 >= N ? "Yes" : "No") << endl;
	}
	else if (c2 == 0) {
		cout << (c1 == N ? "Yes" : "No") << endl;
	}
	else {
		cout << (c2 * 2 + c1 >= N ? "Yes" : "No") << endl;
	}
	return 0;
}


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

int main() {
  int A,B,result;
  cin >> A >> B;
  /*最小回文数で100の位が繰り上がらないか
  a_flg:0 繰り上がりなし*/
  int a_flg = ((A/100)*100+((A%10000)/1000)*10+A/10000 <A);
  /*最大回文数で100の位が繰り下がらないか
  b_flg:0 繰り上がりなし*/
  int b_flg = ((B/100)*100+((B%10000)/1000)*10+B/10000 >B);
  
  cout << B/100-A/100 + 1-a_flg-b_flg << endl;
  return 0;
}

  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
#define M 1000000007
using namespace std;
ll t;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll power(ll x,ul y,ll p){ll res = 1;x = x % p;if(x == 0)return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
void solve(){
	double a,b,n;
	cin>>a>>b>>n;
	ll max1=min(b-1,n);
	//for(double i=n;i>=0;i--){
		ll m1=(ll)(floor((a*(max1))/b))-a*floor((max1)/b);
	//}
	cout<<m1;
 }
int main(){
	fast();
	solve();
	return 0;
}



Measured memory_bytes: 3784
def rec(h,w)
  h.times do |x|
    w.times do |y|
      if (x + y) % 2 == 0
        print '#'
      else
        print '.'
      end
    end
    print "\n"
  end
end

while true
  h, w = gets.chomp.split.map(&:to_i)
  break if w == 0 && h == 0
  rec(h, w)
  puts ""
end



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

int main() {
  int a, b, c;
  string ans = "NO";
  cin >> a >> b >> c;

  int i = 1;
  int count = 0;
  while (count < b) {
   if ((a * i) % b == c) {
     ans = "YES";
     break;
   }
   i++;
   count++;
  }
  cout << ans << endl;
}

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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
   int64_t a,x;
   long double b;
   cin >> a >> b;
   x=a*b;
   printf("%ld\n",x);
   return 0;
}


Measured memory_bytes: 3788
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let s = scan_split::<String>();
    let axc: String = s.iter().map(|x| x.chars().nth(0).unwrap()).collect();
    println!("{}", axc);
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> prices(n);
    for (int& i : prices)
        cin >> i;
    sort(begin(prices),end(prices));
    int sum = 0;
    for (int i = 0; i < k; ++i)
        sum += prices[i];
    cout << sum;
    return 0;
}



Measured memory_bytes: 3572
import math
number =int(input())

def judge_prime(number):
  n = math.floor(number**0.5)
  ar=list(range(n))+[n]
  ar.pop(0)
  ar.pop(0)
  for i in ar:
    if number%i==0:
      return 0
  return number

t = 0
while t == 0:
  if judge_prime(number) == number:
    t+=1
  else:
    number+=1
print(number)

Measured memory_bytes: 3064
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * 60
ans = 0
for i in range(n):
    for j in range(60):
        ans += (i - b[j] if a[i] >> j & 1 else b[j]) << j
    ans %= 10**9 + 7
    for j in range(60):
        b[j] += a[i] >> j & 1
print(ans)


Measured memory_bytes: 136732
#include <bits/stdc++.h>
#define m_k make_pair
#define inf 1e18
#define int long long
using namespace std;
const int N=1e5+100;
int n,m,q[N],a[N],w,MIN;
int cnt[N],ti[N];
void solve(int x,int y,int i)
{
	ti[i]+=x/a[i]*y;
	int j=upper_bound(a+1,a+1+w,x%a[i])-a-1;
	if (j==0)
	{
		cnt[1]+=y,cnt[x%a[i]+1]-=y;
		return;
	}
	solve(x%a[i],y,j);
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=m;i++) scanf("%lld",&q[i]);
	MIN=inf+inf;
	q[0]=n;
	for (int i=m;i>=0;i--)
	{
		if (MIN>q[i]) a[++w]=q[i];
		MIN=min(MIN,q[i]);
	}
	reverse(a+1,a+1+w);
	ti[w]=1;
	for (int i=w;i>=2;i--) solve(a[i],ti[i],i-1);
	cnt[1]+=ti[1],cnt[a[1]+1]-=ti[1];
	for (int i=1;i<=n;i++) cnt[i]+=cnt[i-1];
	for (int i=1;i<=n;i++) printf("%lld\n",cnt[i]);
}

Measured memory_bytes: 6912
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: isize,
        k: isize,
        d: isize,
    }
    // let sign = if x == 0 { 1 } else { x.signum() };
    let x = x.abs();
    let c = x / d;
    if k > c {
        let r = (k - c) % 2;
        println!("{}", ((x - d * c) - (r * d)).abs());
    } else {
        println!("{}", (x - k * d).abs());
    }
}


Measured memory_bytes: 2204
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        an: [usize; n],
    }

    let k_width: usize = if k > 0 {
        ((k as f32).log2() as usize) + 1
    } else {
        0
    };


    let bit_counter = {
        let mut bit_counter: Vec<usize> = vec![0; k_width];

        for mut a in an.iter().cloned() {
            for i in 0..k_width {
                if a % 2 == 1 {
                    bit_counter[i] += 1;
                }
                a /= 2;
            }
        }

        bit_counter
    };

    let x = (0..k_width).rev().fold(0, |acc, i| {
        let x = acc + (1<<i);
        if n > bit_counter[i] * 2 && k >= x {
            x
        } else {
            acc
        }
    });

    let ans: usize = an.iter().map(|a| x ^ *a).sum();

    println!("{}", ans);
}


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


int main() {
	int N;
	cin >> N;
	vector<double> v(N);

	
	
	for(int i = 0; i < N; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());

	double ans = 0; 
	for(int i = 0; i < N; i++){
		if(i < 2){
			ans += v[i] / pow(2, N - 1);
		}
		else{
			ans += v[i] / pow(2, N - i);
		}
		
	}
	
	cout << ans << endl;
	
	
}

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

int main()
{
    int n, j, k, ans = 0;
    ;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n - 1;)
    {
        k = 0;
        if (a[i] != a[i + 1])
        {
            i++;
            continue;
        }
        else
        {
            j = i;
            while (j < n - 1 && a[j] == a[j + 1])
            {
                j++;
                k++;
            }
            ans += (k + 1) / 2;
            i = j + 1;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
S = [list(map(int,input().split()))[1:] for _ in range(M)]
P = list(map(int,input().split()))

ans = 0

for mask in range(0,1<<N):
    flag = True
    for i, line in enumerate(S):
        cnt = 0
        for s in line:
            if ((mask >> (s-1) & 1)):
                cnt += 1
        if cnt % 2 != P[i]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;


int main()
{

int n;
cin>>n;
vector<P> s(n);
rep(i,n){
	int a,b;
	cin>>a>>b;
	s[i]=make_pair(b,a);
}
sort(s.begin(),s.end());
int time=0;
string ans="Yes";
rep(i,n){
	time+=s[i].second;
	if (time>s[i].first){
		ans="No";
		break;
	}
}
cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {

  int s;
  int i = 1;
  int a[1000005];
  int m[1000005];
  int ans;
  int flag = 0;

  cin >> s;

  while ( 1 ) {
    if ( i == 1 ) {
      a[i] = s;
      m[i] = a[i];
    } else {
      if ( (a[i-1]) % 2 == 0 ) {
	a[i] = (a[i-1])/2;
      } else {
	a[i] = 3 * (a[i-1]) + 1;
      }
      for ( int j = 1; j < i; j++ ) {
	if ( a[i] == m[j] ) {
	  ans = i;
	  flag = 1;
	}
      }
      m[i] = a[i];
    }
    if ( flag == 1 ) break;
    ++i;
  }
  
  cout << ans << endl;

  return 0;

}



// B - Collatz Problem
// source128.cpp


Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main()
{
    string s1, s2, s3;
    char c = 'a' - 'A';

    cin >> s1 >> s2 >> s3;
    char t1 = s1[0] - c;
    char t2 = s2[0] - c;
    char t3 = s3[0] - c;


    cout << t1 << t2 << t3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
 int n,q1;
  scanf("%d%d",&n,&q1);
  vector<vector<int>> v(n+1);
  for(int i=0;i<n-1;i++)
  {
    int x,y;
    scanf("%d%d",&x,&y);
    v[x].pb(y);v[y].pb(x);
  }
  int level[n+1]={0};
  for(int i=0;i<q1;i++)
  {
    int x,y;
    scanf("%d%d",&x,&y);
    level[x]+=y;
  }
  queue<int> q;
  q.push(1);
  int vis[n+1]={0};
  while(!q.empty())
  {
    int x=q.front();
    q.pop();
    vis[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
      if(vis[v[x][i]]==0)
      {
        level[v[x][i]]+=level[x];
        q.push(v[x][i]);
      }
    }
  }
  for(int i=1;i<=n;i++)
    printf("%d ",level[i]);
}

Measured memory_bytes: 16244