akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  string s;
  cin >> s;
  long n =0;
  n = s.size();

  //B基準に数える


long ans = 0;
  long b_count =0;
  for(int i=0;i<n;i++){
    if (s[i] =='B'){
      b_count++;
    }else{
      ans += b_count;
    }
  }












  cout << ans << endl;


}




















Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define inf (1LL<<60)
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
template<typename T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll> > a;
    ll s = 0;
    rep(i,n){
        ll c,d;
        cin >> c >> d;
        if(c<d){
            s += d-c;
            a.push_back(make_pair(d,inf));
        }else{
            a.push_back(make_pair(c,d));
        }
    }
    ll sm = s;
    if(s==0){
        cout << 0 << " " << 1 << endl;
        return 0;
    }
    sort(a.begin(),a.end());
    ll k = 0;
    ll pid = -1;
    ll id = -1;
    ll sk = 0;
    ll sk1 = 0;
    rep(i,n){
        if(s>=a[i].first){
            k++;
            s-=a[i].first;
        }else{
            sk = s;
            sk1 = sk - a[i].first;
            break;
        }
    }
    ll x = k;
    ll y = n;
    ll z = gcd(k,n);
    x /=z;
    y /=z;
    ll xx,yy,zz;
    //cerr << sk << " " << sk1 << endl;
    rep(i,n){
        // cerr << a[i].first << " " << a[i].second << endl;
        // cerr << x  << " " << y << endl;
        if(a[i].second==inf){    
            if(i<k){
                if(sk1 + a[i].first >0){
                    xx = a[i].first*k + sk1+a[i].first;
                    yy = a[i].first*n;
                }else{
                    continue;
                }
            }else{
                if(sk >0){
                    xx = a[i].first*k + sk;
                    yy = a[i].first*n;
                }else{
                    continue;
                }
            }
            zz = gcd(xx,yy);
            xx /=zz;
            yy /=zz;
            if((__uint128_t)(x) * (__uint128_t)(yy) < (__uint128_t)(y) * (__uint128_t)(xx) ){
                x = xx;
                y = yy;
            }
        }else{
            if(i<k){
                if(sk1 + a[i].second >0){
                    xx = a[i].second*k + sk1 + a[i].second;
                    yy = a[i].second*n;
                }else{
                    continue;
                }
            }else{
                if(sk - a[i].first+a[i].second >0){
                    xx = a[i].second*k + sk - a[i].first+a[i].second;
                    yy = a[i].second*n;
                }else{
                    continue;
                }
            }
            zz = gcd(xx,yy);
            xx /=zz;
            yy /=zz;
            if((__uint128_t)(x) * (__uint128_t)(yy) < (__uint128_t)(y) * (__uint128_t)(xx) ){
                x = xx;
                y = yy;
            }
        }
    }
    cout << x << " " << y << endl;
    
    return 0;
}

Measured memory_bytes: 2420
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0108
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int[] arr = RIntAr();
                int[] before = Enumerable.Repeat(int.MaxValue, n).ToArray();

                int cnt = -1;
                while (!arr.SequenceEqual(before))
                {
                    arr.CopyTo(before, 0);
                    arr = before.Select(x => before.Count(y => y == x)).ToArray();
                    cnt++;
                }
                Console.WriteLine(cnt);
                Console.WriteLine(WAr(arr));
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

int a,b;

bool vis[3001][3001];
mint memo[3001][3001];

mint dfs(int c,int d){
	if(a==c && b==d) return 1;

	if(vis[c][d]) return memo[c][d];
	vis[c][d]=true;

	mint res=0;
	if(a<c) res+=dfs(c-1,d)*d;
	if(b<d) res+=dfs(c,d-1)*c;
	if(a<c && b<d) res-=dfs(c-1,d-1)*(d-1)*(c-1);
	return memo[c][d]=res;
}

int main(){
	int c,d; cin>>a>>b>>c>>d;
	cout<<dfs(c,d)<<'\n';
	return 0;
}


Measured memory_bytes: 48004
# include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a.find('C')==string::npos){
		cout<<"No"<<endl;
	}
	else{
		a.erase(0,a.find('C'));
		if(a.find('F')!=string::npos)
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import fractions

def solve():
    A, B, C, D = map(int, input().split())
    gcd = (C * D) // fractions.gcd(C, D)
    ans_sub = A-1 - ((A-1) // C + (A-1) // D - (A-1) // gcd)
    ans = B - (B // C + B // D - B // gcd) - ans_sub
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 5728
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	m=read();n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	ans=a[n]-a[1];
	for(int i=2;i<=n;i++)
		ans=min(ans,m-a[i]+a[i-1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int N, dg[300003], db[300003];
int pg[300003] = {}, pb[300003] = {};
bool flg = true;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int d; cin >> d; d /= 10;
		dg[i] = db[N - 1 - i] = d;
	}
	pg[0] = dg[0]; pb[0] = db[0];
	if (!(pg[0] * pb[0]))
		flg = false;
	else {
		for (int i = 1; i < N - 1; i++) {//行き
			pg[i] = max(pg[i - 1] - 1, dg[i]);
			if (!pg[i]) {
				flg = false; break;
			}
		}
		if (flg) {
			for (int i = 1; i < N - 1; i++) {//帰り
				pb[i] = max(pb[i - 1] - 1, db[i]);
				if (!pb[i]) {
					flg = false; break;
				}
			}
		}
	}
	cout << (flg ? "yes" : "no") << endl;
	return 0;
}



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

int main() {
  int n;
  int count = 100;
  std::cin >> n;
  std::vector<int> A;
  for (int i = 0; i < n; ++i){
    int a;
    std::cin >> a;
    A.push_back(a);
  }
  for (auto x : A) {
    int c = 100;
    for (int i = 0; i < 100; ++i) {
      if (x % 2) {
        c = i;
        break;
      }
      x /= 2;
    }
  count = std::min(count, c);
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

cnt = 0
for i in range(10):
  k1 = s.find(str(i))
  if k1 == -1:
    continue
  for j in range(10):
    k2 = s[k1+1:].find(str(j))
    if k2 == -1:
      continue

    k3 = set(list(s[k1+k2+2:]))
    cnt += len(k3)

print(cnt)

Measured memory_bytes: 3444
# input
A, B = map(int, input().split())

if A > 1 and B > 1:
    if A > B:
        print('Alice')
    elif B > A:
        print('Bob')
    else:
        print('Draw')
else:
    if A > B:
        print('Bob')
    elif B > A:
        print('Alice')
    else:
        print('Draw')

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  int n;
  cin >> n;
  long double ans = 0;
  while (n--) {
    long double val;
    string t;
    cin >> val >> t;
    if (t == "BTC") {
      ans += (val * 380000.0);
    } else {
      ans += val;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
use std::io::{self, Read};

fn main() {
	let mut input = String::new();
	let _ = io::stdin().read_to_string(&mut input);
	let lines: Vec<&str> = input.split("\n").collect();
	let N = lines[0].parse::<usize>().unwrap();
	let (left, right) = {
		let words: Vec<&str> = lines[1].split(" ").collect();
		(words[0], words[1])
	};
	for i in 0..N {
		print!("{}{}", left.chars().nth(i).unwrap(), right.chars().nth(i).unwrap());
	}
	println!("");
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    string s;
    cin>>s;
    int cnt=0,ans=0;
    for (int i=0;i<x;i++){
        if (s[i]=='D')
            cnt--;
        else
            cnt++;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Tap Dance
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[128];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  for (int i = 0; s[i]; i++) {
    int p = (i & 1);
    if ((! p && s[i] == 'L') || (p && s[i] == 'R')) {
      puts("No");
      return 0;
    }
  }

  puts("Yes");
  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int dx[]={1,0}, dy[]={0,1};
int N, M, D[100][100];
vector<string> F;

bool valid_coord(int x, int y)
{
	return 0<=x && x<N && 0<=y && y<M;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	deque<pair<int,int>> Q;
	cin>>N>>M; F.resize(N);
	for(int i=0;i<N;i++) cin>>F[i];
	memset(D,0x7f,sizeof(D));
	D[0][0]=F[0][0]=='#';
	Q.emplace_back(0,0);
	while(!Q.empty()) {
		int x, y;
		tie(x,y)=Q.front();
		Q.pop_front();
		for(int k=0;k<2;k++) if(valid_coord(x+dx[k],y+dy[k]) && D[x+dx[k]][y+dy[k]]>D[x][y]+(F[x+dx[k]][y+dy[k]]!=F[x][y])) {
			D[x+dx[k]][y+dy[k]]=D[x][y]+(F[x+dx[k]][y+dy[k]]!=F[x][y]);
			if(D[x+dx[k]][y+dy[k]]>D[x][y]) Q.emplace_back(x+dx[k],y+dy[k]);
			else Q.emplace_front(x+dx[k],y+dy[k]);
		}
	}
	cout<<(D[N-1][M-1]+(F[N-1][M-1]=='#'))/2<<'\n';
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
int n, a, b;
vector<int> h(100005);

// 二分探索用判定関数
bool C(int num)
{
    vector<int> temp(h.begin(), h.begin() + n);

    ll res = 0;
    ll subtraction = b * num;
    for (int i = 0; i < n; ++i)
    {
        if (h[i] > subtraction)
        {
            res += ceil((double)(h[i] - subtraction) / (a - b));
        }
    }

    return res <= num;
}

int main()
{

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

    int lb = 0, ub = ceil((double)*max_element(h.begin(), h.begin() + n) / b);
    while (ub - lb > 1)
    {
        int mid = (lb + ub) / 2;
        if (C(mid))
            ub = mid;
        else
            lb = mid;
    }

    cout << ub << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <unordered_set>

using namespace std;

int min(int a, int b){
    return a < b ? a : b;
}

int max(int a, int b){
    return a > b ? a : b;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    unordered_set<string> productos;
    for (int i=0; i<N; i++){
        string aux;
        cin >> aux;
        productos.insert(aux);
    }
    cout << productos.size() << "\n";
    return 0;
}



Measured memory_bytes: 13724
import numpy as np
n, k = (int(i) for i in input().split())

h=[]
for i in range(n):
    h.append(int(input()))
h=np.array(h)

sorted_h = np.sort(h)
diff = np.hstack((sorted_h[k-1:], np.zeros(k-1)))

print(int(np.min(np.abs(diff - sorted_h)[:-k+1])))

Measured memory_bytes: 17104
// AtcoderTemplate.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"
using namespace std;

int main()
{
	string num;
	cin >> num;
	for (auto & c : num) {
		switch (c)
		{
		case '1':
			c = '9';
			break;
		case '9':
			c = '1';
			break;
		default:
			break;
		}
	}
	cout << num << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


ll bits(ll x,ll k){
	ll fb = x&-x;
	x += fb;
	ll pcount=0;
	for(int i=0;i<18;i++){
		if(x&(1LL<<i))pcount++;
	}
	ll p = 1;
	for(int i=0;i<k-pcount;i++){
		x += p;
		p *= 2;
	}
	return x;
}


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

	ll n,k,f;
	cin >> n >> k;
	ll x=0,p=1;
	FOR(i,0,k){
		x+=p;
		p*=2;
	}
	f = x<<(n-k);
	while(1){
		cout << x << ":" ;
		FOR(i,0,n){
			if(x&(1LL<<i))cout<<" "<<i;
		}
		cout << endl;
		if(x==f)break;
		x = bits(x,k);
	}

}


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

int main(){
    int a,b;
    cin >> a >> b;
    int res = 1;
    int rep = 0;
    while(res < b){
        res += (a-1);
        rep++;
    }
    cout << rep << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  ll dp[10][10]={};
  rep(i,n){
    string s=to_string(i+1);
    char f=s[0];
    char l=s[s.size()-1];
    dp[f-'0'][l-'0']++;
  }
   ll ans=0;
  rep(i,10){
    rep(j,10){
      ans+=dp[i][j]*dp[j][i];
    }
  }
  cout << ans << endl;  
}


Measured memory_bytes: 384
n, m = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

ans = 1
for v in make_divisors(m):
    if v <= m / n:
        ans = max(ans, v)
print(ans)

Measured memory_bytes: 38640
import java.io.*;

/**
 * Created by Ayushi on 27 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String a = br.readLine();
        String b = br.readLine();
        br.close();
        int ans = 0;
        for (int i = 0; i < a.length(); i++) {
            if (a.charAt(i) != b.charAt(i)) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 36556
import java.util.*;
import java.lang.*;
import java.util.stream.LongStream;


// 10 3
// 4 5 6
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(solve(inputStr(sc, " ")));
    }

    /**
     * 指定された区切り文字で区切られた１行の文字列を、文字列配列にして返します。
     */
    private static String[] inputStr(Scanner sc, String... delimiter) {
        return sc.nextLine().split(delimiter == null ? " " : delimiter[0]);
    }

    private static Long[] convertStrToInt(String[] strArray) {
        return Arrays.stream(strArray).map(e -> new Long(Long.parseLong(e))).toArray(Long[]::new);
    }

    private static long outputResult(long a, long b) {
        return LongStream.range(0, b).reduce((long) 0, (sum, i)->sum+=(Math.pow(10, i) * a));
    }

    private static long solve(String[]... inputs) {
        Long[] firstArr = convertStrToInt(inputs[0]);
        long a = firstArr[0];
        long b = firstArr[1];
        return a > b ? outputResult(b, a) : outputResult(a, b);
    }
}


Measured memory_bytes: 25808
n = int(input())
a = list(map(int, input().split()))
used = [0] * n
a.sort(reverse=True)
x = 0
y = 0
for i in range(1,n):
    if a[i - 1] == a[i] and used[i-1] == 0 and used[i] == 0:
        if x == 0:
            x = a[i]
            used[i] = 1
            used[i-1] = 1
        elif y == 0:
            y = a[i]
            used[i] = 1
            used[i-1] = 1
            break
print(x*y)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
ll n,a,b;
int main()
{
    cin>>n>>a>>b;
    if(a+b==0)cout<<0<<endl;
    ll ans=n/(a+b)*a+min(n%(a+b),a);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = sorted(A, reverse=True)
    b = {}
    for i in range(N - 1):
        if a[i] == a[i+1]:
            if a[i] in b.keys():
                b[a[i]] += 1
            else:
                b[a[i]] = 2
    if len(b) < 2:
        ans = 0
    elif b[max(b)] >= 4:
        ans = max(b) ** 2
    else:
        c = sorted(b, reverse=True)
        ans = c[0] * c[1]

    print(ans)

main()


Measured memory_bytes: 14800
Scanf.scanf "%d %d %d %d %d %s %s" (fun h w n sr sc s t ->
    let check st m cs ct =
        let rec loop i p =
            if i = n then true else
                let p = if s.[i] = cs then p - 1 else p in
                if p < 1 then false else
                    let p = if t.[i] = ct then min (p + 1) m else p in
                    loop (i + 1) p
        in
        loop 0 st
    in
    print_endline @@
        if check sr           h 'U' 'D' &&
           check (h + 1 - sr) h 'D' 'U' &&
           check sc           w 'L' 'R' &&
           check (w + 1 - sc) w 'R' 'L' then "YES" else "NO"
)


Measured memory_bytes: 3072
a, b = map(int, input().split())

if a == 1 and b == 1:
    print('Draw')
elif a == 1:
    print('Alice')
elif b == 1:
    print('Bob')
else:
    if a == b:
        print('Draw')
    elif a > b:
        print('Alice')
    else:
        print('Bob')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int X,R=0,G=0,B=0;
  cin>>X;
  string S;
  cin>>S;
  for(int i=0;i<X;i++)
    if(S[i]=='R')
      R++;
    else if(S[i]=='G')
      G++;
    else B++;
  long long Ans=1ll*R*G*B;
  for(int i=0;i<X;i++)
    for(int j=i+1;j<X;j++)
      if(j+j-i<X&&S[i]!=S[j]&&S[i]!=S[j+j-i]&&S[j]!=S[j+j-i])
        Ans--;
  cout<<Ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a,b int) int {
	if a< b {
		return a
	}
	return b
}

func main() {
	var n,tmp int
	fmt.Scan(&n)
	sum := 0
	var v [100]int

	for i := 0; i< n; i++ {
		fmt.Scan(&tmp)
		sum += tmp
		v[i] = sum
	}
	mi := 1000000
	for i := 0; i< n; i++ {
		mi = min(mi, abs(v[i]-(sum-v[i])))
	}
	fmt.Println(mi)
}

Measured memory_bytes: 512
import math

A, B = [int(_) for _ in input().split()]
N = math.gcd(A, B)

ans = 1
for i in range(2, int(math.sqrt(N)+1) + 1):
    if N % i == 0:
        ans += 1
        while N % i == 0:
            N //= i
if N > 1:
    ans += 1
print(ans)


Measured memory_bytes: 9180
# C - Peaks

N, M = map(int, input().split())
H = [int(h) for h in input().split()]

mapping = [[] for _ in range(N)]
for _ in range(M):
    i, j = map(int, input().split())
    mapping[i - 1].append(j - 1)
    mapping[j - 1].append(i - 1)

cnt = 0
for i in range(N):
    ls = mapping[i]
    for j in ls:
        if H[i] <= H[j]:
            break
    else:
        cnt += 1

print(cnt)


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;

int main(int argc, char const* argv[])
{
  int a, b;
  cin >> a >> b;

  if (a > b) cout << string(a, '0'+b) << endl;
  else cout << string(b, '0'+a) << endl;

  return 0;
}

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

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

	bool n_prime = true;
	int cnt = 0;
	while(n_prime) {
		for (int i = 2; i < sqrt(X); i++) {
			if (X % i == 0) cnt++;
		}
		if (cnt == 0) {
			n_prime = false;
		}
		else {
			X++;
			cnt = 0;
		}
	}
	cout << X << endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<lli> a(n);
    each (i, a) cin >> i;
    map<lli, lli> cnt;
    lli x = 0;
    for (int i = 0; i < a.size(); ++i) {
      x += a[i];
      x %= m;
      ++cnt[x];
    }
    lli sum = cnt[0];
    each (i, cnt) {
      sum += i.second * (i.second - 1) / 2;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  N , A;
  cin >> N >> A;
  
  int x; //Nを500で割った余り
  x = N % 500;
  
  if ( x <= A ) {
    cout << "Yes" << endl;
  }
  
  else {
  cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl6
int n,k;
int a[maxn];
int SG[maxn];
int S[maxn];
void getSG()
{
    SG[0]=0;
    for(int i=1;i<maxn;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i>=a[j]) S[SG[i-a[j]]]=i;
        }
        for(SG[i]=0;S[SG[i]]==i;SG[i]++);
    }
    return ;
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    getSG();
    if(SG[k]==0) puts("Second");
    else puts("First");
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



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

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b) * h * 1/2 << endl;
    return 0;
}

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

int main(){
    int x,h;
    double sBtm, sSide;
    
    while (scanf("%d\n%d",&x,&h)){
        if (x==0 && h==0) break;
        sBtm = x*x;
        sSide = x * sqrt(x*x/4.0 + h*h)/2.0;
        printf("%f\n",sSide*4+sBtm);
    }
    
    return 0;
}

Measured memory_bytes: 1060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT false

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{ 
  int N,M;
  cin>>N>>M;
  int A = M*1900 + (N-M)*100;
  cout<<A*(int)pow(2,M)<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

using namespace std;

int main(void) {
  string s;
  while (getline(cin, s) && s != ".") {
    int ssz = s.size();
    stack<char> st;
    bool flag = true;
    for (int i = 0; i < ssz; i++) {
      if (s[i] == '(' || s[i] == '[') st.push(s[i]);
      else if (s[i] == ')') {
        if (st.empty() || st.top() != '(') {
          flag = false;
          continue;
        }
        st.pop();
      } else if (s[i] == ']') {
        if (st.empty() || st.top() != '[') {
          flag = false; 
          continue;
        }
        st.pop();
      }
    }
    if (st.size()) flag = false;

    if (flag) cout << "yes\n";
    else cout << "no\n";
  }

  return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)

int d[20][20];
int dp[1<<15][15];
int main(){
	int v,e;
	scanf("%d%d",&v,&e);
	for(int i=0;i<v;i++)for(int j=0;j<v;j++)d[i][j]=1e6;
	for(int i=0;i<e;i++){
		int s,t,c;
		scanf("%d%d%d",&s,&t,&c);
		d[s][t]=c;
	}
	for(int i=1;i<1<<v;i++)for(int k=0;k<v;k++)dp[i][k]=1e6;
	dp[1][0]=0;
	for(int i=1;i<1<<v;i++){
		for(int k=0;k<v;k++)if(bit(i,k)){
			for(int j=0;j<v;j++)if(!bit(i,j)){
				dp[i|1<<j][j]=min(dp[i|1<<j][j],dp[i][k]+d[k][j]);
			}
		}
	}
	int ans=1e6;
	for(int i=0;i<v;i++)ans=min(ans,dp[(1<<v)-1][i]+d[i][0]);
	printf("%d\n",ans==1e6?-1:ans);
}


Measured memory_bytes: 3776
main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  (s1, s2) <- break (=='-') <$> getLine
  if (not . null) s2 && po s1 && (po . tail) s2 && length s1 == a && length s2 == b + 1
    then putStrLn "Yes"
    else putStrLn "No"

po :: String -> Bool
po = notElem '-'


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end(), greater<int>());
    map<int, int> m;
    for (int i = 0; i < N; i++)
    {
        m[A.at(i)]++;
    }

    int u = 1 << 30, l = 1 << 29;
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        if (m.at(A.at(i)) == 0)
            continue;
        m.at(A.at(i))--;
        while (A.at(i) < l)
        {
            u >>= 1;
            l >>= 1;
        }
        if (m[u - A.at(i)] > 0)
        {
            res++;
            m[u - A.at(i)]--;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 19712
program main
  implicit none
  integer i,N,D
  !read(*, *) (L(i), i = 1,N)
  read(*, *)N,D
  i = 2*D + 1
  if (mod(N,i)==0) then 
    i = N/i
  else
    i = N/i + 1
  end if


  write(*, *) i
end program main


Measured memory_bytes: 640
#include<bits/stdc++.h>
   	using namespace std;
#define debug1(x) cout << #x <<" " <<  x << endl
#define debug2(x,y) cout << #x <<" " <<  x << " " << #y << " " << y << endl
#define debug3(x,y,z) cout << #x <<" " <<  x << " " << #y << " " << y << " " << #z << " " << z<< endl
struct cmpStruct {
  bool operator() (int const & lhs, int const & rhs) const
  {
    return lhs > rhs;
  }
};
void clear(priority_queue<int,vector<int>,cmpStruct> &q)
{
  while(!q.empty())
    q.pop();
}

int main()
{
  
  int n,m,a,b;
  cin >> n >> m;
  std::vector<pair<int,int> > query;
  priority_queue<int,vector<int>,cmpStruct> q;
  for(int i=0;i<m;i++)
  {
    cin >> a >> b;
    query.push_back(pair<int,int> (a,b));
  }
  sort(query.begin(),query.end());
  int cnt=0;
  int i=1,start=query[0].first;
  int end=query[0].second;
  q.push(end);
  while(i<m)
  {
    
    start=query[i].first;
   // debug2(q.top(),start);
    if(start <= q.top()-1)
    {
      end=query[i].second;
   //   cout << "pushing " << end << endl;
      q.push(end);
    }
    else
    {
      cnt++;
    //  cout << "clear " << start << endl;
      clear(q);
      end=query[i].second;
      q.push(end);
    } 
    i++;
  }
  if(!q.empty())
    cnt++;
  cout << cnt << endl;
  return 0;
}





Measured memory_bytes: 1400
# Code for B - Papers, Please
# Use input() to fetch data from STDIN

n = int(input())
a = [int(x) for x in input().split()]

s = True
for x in a:
    if x % 2 != 0:
        continue
    if not (x % 3 == 0 or x % 5 == 0):
        s = False

if s:
    print("APPROVED")
else:
    print("DENIED")


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

int main() {
	int n;cin>>n;
	vector<int> p(n),a(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	int error=0;
	for(int i=0;i<n;i++){
		if(p[i]!=i+1){
			error++;
		}
	}
	if(error<=2){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,d,x,y;
    scanf("%lld %lld %lld %lld", &a,&b,&c,&d);
    x = max(max(a*c,a*d), max(b*c,b*d));
    printf("%lld\n", x);
    return 0;
}

Measured memory_bytes: 3824
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp1[102][20001];
ll dp2[102][20001];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	dp1[num + 1][0] = 1;
	dp2[num + 1][0] = 0;
	int maxi = 0;
	for (int i = num; i >= 1; i--)
	{
		int xx = 0;
		for (int j = 0; j <= maxi; j++)
		{
			for (int k = 0; k <= kai; k++)
			{
				if (k > i)dp1[i][j] = (dp1[i][j] + dp1[i + 1][j]) % mod, dp2[i][j] = (dp2[i][j] + dp2[i + 1][j] + dp1[i + 1][j] * (j + k)) % mod;
				else dp1[i][(j + (j + k) / i)] = (dp1[i][(j + (j + k) / i)] + dp1[i + 1][j]) % mod, dp2[i][j + (j + k) / i] = (dp2[i][(j + (j + k) / i)] + dp2[i + 1][j] + dp1[i + 1][j] * ((j + k) % i)) % mod;
				xx = max(xx, j + (j + k) / i);
			}
		}
		maxi = xx;
	}
	ll sum = 0;
	for (int i = 0; i <= maxi; i++)sum += dp2[1][i];
	printf("%lld\n", sum%mod);
}

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

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

    string s,t;
    cin>>s>>t;
    long long int cnt=0;
    for(unsigned int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i))
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 3732
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, ans[int(1e5 + 5)];
vector <int> Graph[int(1e5 + 5)];

int DFS(int node){
  if (ans[node] != -1) return ans[node];
  if (Graph[node].size() == 0) return ans[node] = 0;

  int now = 0;
  for (int i = 0; i < Graph[node].size(); i++){
    int next = Graph[node][i];
    now = max(now, DFS(next) + 1);
  }
  return ans[node] = now;
}

int main(){
  scanf("%d%d", &N, &M);
  fill(ans, ans + N, -1);
  for (int i = 0; i < M; i++){
    int X, Y; scanf("%d%d", &X, &Y);
    X--; Y--;
    Graph[X].push_back(Y);
  }
  
  int Ans = 0;
  for (int i = 0; i < N; i++) Ans = max(Ans, DFS(i));
  printf("%d\n", Ans);

  return 0;
}


Measured memory_bytes: 8192
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

int main(){
	int n;
	while(cin>>n,~n){
		double a,b = n/2.0;
		do{
			a = b;
			b = a - (a*a*a-n)/(3*a*a);
		}while(abs(b*b*b-n) >= 0.00001*n);

		printf("%lf\n",b);
	}
    return 0;
}

Measured memory_bytes: 0
from itertools import permutations
n, C = map(int, input().split())
d = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(n)]
l = [[0] * C for i in range(3)]
for i in range(n):
    for j, k in enumerate(c[i]):
        l[(i + j) % 3][k - 1] += 1
ans = float("inf")
for i in permutations(range(C), 3):
    cnt = 0
    for j in range(3):
        for k in range(C):
            cnt += d[k][i[j]] * l[j][k]
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 11640
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
    
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3064
N, Y = [int(x) for x in input().split(" ")]

num = [-1,-1,-1]

for i in range(0,N+1):
  for j in range(0,N+1-i):
    if i*10000+j*5000+(N-i-j)*1000 == Y:
      num = [i,j,N-i-j]
      break

print(num[0],num[1],num[2])


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}

template <class T>
T lcm(T a, T b) {
  T h = gcd(a, b);
  return (h != 0) ? (a * (b / h)) : 0;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  const ll m = lcm(C, D);

  const ll before_A = A - 1;

  const ll ansB = B - (B / C) - (B / D) + (B / m);

  const ll ans_before_A = before_A - (before_A / C) - (before_A / D) + (before_A / m);
  const ll ans = ansB - ans_before_A;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        String S = sc.next();
        String ans = "None";
        for (int i = 0; i < 26; i++) {
            if (S.indexOf((char)('a' + i)) == -1) {
                ans = "" + (char)('a' + i);
                break;
            } else {

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


Measured memory_bytes: 23980
#include <stdio.h>
#include <math.h>

int main()
{
  double a,b;
  double x1,y1,x2,y2;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

  a = (x2 - x1) * (x2 - x1);
  b = (y2 - y1) * (y2 - y1);

  printf("%lf\n",sqrt(a + b));
  return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
int main(void)
{
  int a,ans;
  scanf("%d",&a);
  if(a==1)
    ans=1;
 else if(a>=2&&a<4)
    ans=2;
 else if(a>=4&&a<8)
    ans=4;
  else if(a>=8&&a<16)
    ans=8;
  else if(a>=16&&a<32)
    ans=16;
  else if(a>=32&&a<64)
    ans=32;
  else if(a>=64&&a<=100)
    ans=64;
printf("%d",ans);
}

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


public class Main {

	static int[] first;
	static int [] end;
	static List[] arLs;

	static int dfs(int cur,int ts) {
		first[cur] = first[cur]==0 ? ts : first[cur];
		int now = ts+1;
		for(int i=0;i<arLs[cur].size();i++) {
			int a = (Integer)arLs[cur].get(i);
			if (first[a]==0){
				now = dfs(a, now);
			}
		}
		end[cur] = end[cur]==0 ? now : end[cur];
		return now+1;
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		arLs = new List[n];
		first = new int[n];
		end = new int[n];
		for (int i=0;i<n;i++) {
			List<Integer> ls = new ArrayList<Integer>();
			scan.nextInt();
			int np = scan.nextInt();
			for (int j=0;j<np;j++) {
				ls.add(scan.nextInt()-1);
			}
			arLs[i] = ls;
		}
		int now = 1;
		for (int i=0;i<n;i++) {
			if (first[i]==0)
				now = dfs(i,now);
		}
		for (int i=0;i<n;i++) {
			System.out.println(i+1+" "+first[i]+" "+end[i]);
		}
	}
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k, q, inp;
    cin >> n >> k >> q;
    map<int, int>mp;
    for (int i = 0; i < q; i++){
        cin >> inp;
        mp[inp - 1]++;
    }
    for (int i = 0; i < n; i++){
        if (k - q + mp[i] > 0)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


Measured memory_bytes: 5376
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
        int n = sc.nextInt();
        if(n==0){System.out.println(x);}
        else{
		int [] in = new int [n];
       
        for(int i=0;i<n;i++){
                             in[i] = sc.nextInt()-x;
                            }
        Arrays.sort(in);
		int ans = x;
        int b = 0; 
        int point = 0;
        while(b==0){for(int i=0;i<n;i++){if(in[i]==point){break;}
                            else{if(i==n-1){b=1;ans+=point;}
                                }
                                        }
                       if(point==0){point=-1;}
                                        else{if(point<0){point*=-1;}
                                            else{point*=-1;
                                                point--;}                   
                                            }
                   }
		System.out.println(ans);
        }
	}
}

Measured memory_bytes: 35836
a, b, c = map(int, raw_input().split())
aa = 0
bb = 0
if a > b:
    aa = a - b
elif a < b:
    aa = b - a
if a > c:
    bb = a - c
elif a < c:
    bb = c - a
if aa > bb:
    print "B"
else:
    print "A"

Measured memory_bytes: 2568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String S = in.readLine();

		if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23380
fn main() {
    let abn = read_vec::<u64>();
    let a = abn[0];
    let b = abn[1];
    let n = abn[2];

    let x;
    if b - 1 < n {
        x = b - 1;
    } else {
        x = n;
    }
    let ret = (a * x) / b - a * (x / b);
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 2148
#include<stdio.h>
int main()
{
  char n[200001];
  scanf("%s",n);
  int sum=0;
  for (int i=0;n[i]!='\0';i++) sum+=n[i]-'0';
  if (sum%9==0) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 1920
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

yes = "War"
no = "No War"

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split())) + [X]
y = list(map(int, input().split())) + [Y]

if max(x) + 1 <= min(y):
    print(no)
else:
    print(yes)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n;
  double a[110];
  double ans=0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i]=1/a[i];
    ans+=a[i];
  }
  cout << 1/ans << endl;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> ps(n);
    for (int i = 0; i < n; i++) cin >> ps[i];
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            vector<int> qs = ps, rs;
            swap(qs[i], qs[j]);
            rs = qs;
            sort(rs.begin(), rs.end());
            if (qs == rs) {
                cout << "YES";
                return 0;
            }
        }
    }
    cout << "NO";
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define N 110
using namespace std;
int a[N],sum[N],f[N][N],n;
int main(){
	int x,y,z;
    while(scanf("%d%d",&x,&y)!=EOF)
	{
		z = y / 2 + x;
		cout<<z<<endl;
	}
} 

Measured memory_bytes: 256