akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    abc152e()
}

fun abc152e() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val lcmMap = aList.map { primeFactorization(it).toList() }.flatten()
        .groupBy { it.first }.map { entry -> entry.key to entry.value.map { it.second }.max()!! }.toMap()

    var lcm = Mint(1)
    for (l in lcmMap) {
        for (i in 0 until l.value) lcm *= l.key
    }

    var answer = Mint()
    for (a in aList) {
        val b = lcm / a
        answer += b
    }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun primeFactorization(n: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    var temp = n
    var i = 2L
    while (i * i <= temp) {
        while (temp % i == 0L) {
            factors[i] = (factors[i] ?: 0) + 1
            temp /= i
        }
        i++
    }
    if (temp > 1) factors[temp] = 1
    return factors
}

private class Mint(value: Long = 0L) {
    private val value = if (value < 0) (value % MOD) + MOD else value % MOD
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * other)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(modPow(other, MOD - 2, MOD))
    operator fun div(other: Mint) = this.div(other.value)
    override fun toString(): String = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }

    companion object Mod {
        private fun modPow(n: Long, p: Long, m: Long): Long {
            var x = n
            var y = p
            var result = 1L
            x %= m
            while (y > 0) {
                if (y % 2 == 1L) result = (result * x) % m
                y = y shr 1
                x = (x * x) % m
            }
            return result
        }
    }
}


Measured memory_bytes: 44860
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int N, K; 
vector<int> x, y;
int cnt(int x1, int y1, int x2, int y2){
  int ret = 0;
  REP(i, N){
    if(IN(x1, x[i], x2+1) && IN(y1, y[i], y2+1)) ret++;
  }
  return ret;
}

signed main() {
  cin >> N >> K;

  x.resize(N);
  y.resize(N);
  REP(i, N) cin >> x[i] >> y[i];

  vector<int> X(N), Y(N);
  REP(i, N){
    X[i] = x[i];
    Y[i] = y[i];
  }
  
  sort(ALL(X));
  sort(ALL(Y));

  int ans = 4*INF;
  REP(i, N) FOR(j, i+1, N) REP(k, N) FOR(l, k+1, N){
    if(cnt(X[i], Y[k], X[j], Y[l]) >= K) chmin(ans, (X[j]-X[i])*(Y[l]-Y[k]));
  }

  cout << ans << endl;

  return 0;
}

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

#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m;

signed main() {
	cin >> n >> m;
	rept(x,2000) {
		rept(y,2000) {
			int z = n - x - y;
			if (z>=0 && x*10000 + y*5000 + z*1000 == m) {
				cout << x << " " << y << " " << z << ln;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << ln;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for n in range(N)]
A = sorted(A)

res = []
tmp = A[0]
count = 1
for i in range(1,N):
    if A[i] == tmp:
        count += 1
    else:
        res.append(count%2 != 0)
        count = 1
    tmp = A[i]
res.append(count%2 != 0)

print(sum(res))




Measured memory_bytes: 8280
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long int N,M,H,W,x,i,j,k,ans,count,cost,tmp,a,b,c,d,c1,c2,HP;
    long long int S[110000];
    //long long int T[11000];
    //long long int U[300000];
    //long long int Ssum[300000];
    string T[110],TA,V,G,ans2;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    ans=0;
    flag=false;
    cin >>N;
    cin >>T[0];
    

    
        //cin >> c >>d;
        //count=0;
    
    //cout << count<<endl;
    
    
    
    if (T[0].size()%2==0 ){
        if (T[0].substr(0,T[0].size()/2)==T[0].substr(T[0].size()/2,T[0].size()/2)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        
        }
        
    }
        
    else{
        cout << "No" << endl;
    }

    return 0;
    
}


Measured memory_bytes: 3640
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    if (x == 0 && y == 0) break;
		    if (x < y) {
		        System.out.println(x + " " + y);
		    } else {
		        System.out.println(y + " " + x);
		    }
		}
    }
}



Measured memory_bytes: 36420
#include<iostream>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  for(int i=0; i<n; i++){
    if(i+1==k){
      if(s[i]=='A') s[i] = 'a';
      else if(s[i]=='B') s[i] = 'b';
      else s[i] = 'c';
    }
  }
  
  cout << s << endl;  
  return 0;
}

Measured memory_bytes: 256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	string s;
	cin>>s;
	bool flag=0;
	if(SZ(s)>=4){
		if(string(s,0,4)=="YAKI") flag=1;
	}
	if(flag) cout<<"Yes\n";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int stackformer = 0;
    int stacklatter = 0;

    rep(i,s.size()){
        if(s[i] == '(') stacklatter ++;
        if(s[i] == ')'){
            if(stacklatter == 0) stackformer++;
            else stacklatter--;
        }
    }

    string ans = "";

    rep(i,stackformer) ans += '(';

    ans += s;

    rep(i,stacklatter) ans += ')';

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;

	vector<pair<lli,lli>> ans;

	for(lli i=n;i>0;i--){
		for(lli j=i-1;j>0;j--){
			if(n%2==1){
				if(n-i == j)continue;
			}
			else{
				if(n+1-i == j)continue;
			}
			ans.push_back(make_pair(i,j));
		}
	}

	cout<<ans.size()<<endl;
	REP(i,0,ans.size()){
		cout<<ans.at(i).first<<" "<<ans.at(i).second<<endl;
	}



	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;

ll b, k, n = 0, z = 0,s, x, y, a[200005] = {};
	vector<ll> v,vec;
int main() {
	cin >> n >> k >> s;
	
	rep(i, n) {
		if (i < k)cout << s << " ";
		else {
			if(s==1000000000)cout << 1 << " ";
			else cout << s+1 << " ";
		}
	}
	return 0;

}


Measured memory_bytes: 3612
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = ReadInt();
           var date= Enumerable.Range(1, N+1).Select(x => new int[3]).ToArray();
            int[][] day = new int[N][];
            for (int i = 0; i < N; i++)
            {
                day[i] = ReadInts();
            }
            for(int i = 0; i < N; i++)
            {
                date[i + 1][0] = Max(day[i][0]+date[i][2],day[i][0]+date[i][1]);

                date[i + 1][1] = Max(day[i][1]+date[i][2],day[i][1]+date[i][0]);
                date[i + 1][2] = Max(day[i][2]+date[i][0],day[i][2]+date[i][1]);
            }
           Write( date.Last().Max());
        }

        
        private static void Write<T>(IEnumerable<T> target,string sep=" ") { Console.WriteLine(string.Join(sep,target)); }
        private static void Write<T>(T str) { Console.WriteLine(str); }
        private static string[] ReadStrings() { return Console.ReadLine().Split(' '); }
        private static int ReadInt() { return int.Parse(Console.ReadLine()); }
        private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        private  static int[] ReadInts() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        private static double[] ReadDoubles() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        
    }

}

Measured memory_bytes: 32300
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//126 E
class UnionFind
{

private:
	std::vector<long long> par;
	std::vector<long long> rank;

public:
	UnionFind(long long n) {
		par = std::vector<long long>(n);
		rank = std::vector<long long>(n);
		for (long long i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	};

	long long find(long long x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	void unite(long long x, long long y) {
		x = find(x);
		y = find(y);
		if (x == y)return;

		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}

	}

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

	long long count() {
		long long ret = 0;
		for (int i = 0; i < par.size(); i++) {
			if (i == par[i])ret++;
		}
		return ret;
	}
};


int main(void) {
	ll n, m;
	cin >> n >> m;
	 UnionFind uf = UnionFind(n);
	 rep(0, m) {
		 ll a, b, c;
		 cin >> a >> b >> c;
		 uf.unite(a-1, b-1);
	 }
	 cout << uf.count() << endl;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, mut y: [usize; n]);
    y.sort();
    let mut buff = y[0] as f64;
    for i in 1..y.len() {
        buff = (buff + y[i] as f64) / 2_f64;
    }
    println!("{}", buff);
}


Measured memory_bytes: 2160
def main():
    l=input().split()
    n=int(l[0])
    x=int(l[1])
    min_m=1000000
    for i in range(n):
        m=int(input())
        x-=m
        if m<min_m:
            min_m=m
    res=n+x//min_m
    print(res)

if __name__=="__main__":
    main()


Measured memory_bytes: 2940
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    N,x=map(int,input().split())
    X=list(map(int,input().split()))
    X.append(x)
    X.sort()

    from functools import reduce
    from fractions import gcd
    S=[0]*N
    for i in range(N):
        S[i]=X[i+1]-X[i]
    print(reduce(gcd,S) if N>1 else S[0])

resolve()

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

int main()
{
	int n, m;
	cin >> n >> m;

	priority_queue<int> aq;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		aq.push(a);
	}

	for (int i = 0; i < m; ++i) {
		int t = aq.top();
		aq.pop();
		aq.push(t/2);
	}

	long long ret = 0;
	for (int i = 0; i < n; ++i) {
		ret += aq.top();
		aq.pop();
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ABC056BSolve solve = new ABC056BSolve();
		solve.main();
	}
}

class ABC056BSolve {
	
	int W;
	int a;
	int b;
	
	ABC056BSolve() {
		Scanner cin = new Scanner(System.in);
		this.W = cin.nextInt();
		this.a = cin.nextInt();
		this.b = cin.nextInt();
	}
	
	void main() {
		int left = Math.min(a, b);
		int right = Math.max(a, b);
		int diff = right - (left + W);
		int ans = Math.max(0, diff);
		System.out.println(ans);
	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <cmath>

#define f(i, n) for(int i = 0; i < n; i++)
#define fc(i, j, n) for(int i = j; i < n; i++)
#define ll long long

using namespace std;


const int N = 500;
ll sum[N], a[N], dp[N][N];

int main(){
  int n;

  cin >> n;
  f(i, n){
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }

  f(i, n - 1)
    f(j, n - i - 1){
      ll mini = 1e18;
      fc(k, j, j + i + 1)
        mini = min (mini, dp[j][k] + dp[k + 1][j + i + 1]);
      dp[j][j + i + 1] = mini + sum[j + i + 2] - sum[j];
    }

    cout << dp[0][n - 1] << '\n';

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 1000000000
#define ll long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    REP(i, D){
        cin >> p[i] >> c[i];
    }

    int ans = INF;
    for(int mask=0; mask < (1<<D); mask++){
        int s = 0, num = 0, rest_max = -1;
        for(int i=0; i<D; i++){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 =100 * (rest_max+1);
            int need = (G-s+s1-1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
t = S.count("E")

mi = N
for i in range(N):
    if S[i] == "E":
        t -= 1
    # print(i, t)   
    mi = min(mi, t)
    
    if S[i] == "W":
        t += 1
    
print(mi)


Measured memory_bytes: 3700
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String S = sc.next();
    boolean check = true;
    for(int i=1; i<=S.length(); i++){
      if(i % 2 == 1){
        if(S.charAt(i-1) == 'L'){
          check = false;
          break;
        }
      }else{
        if(S.charAt(i-1) == 'R'){
          check = false;
          break;
        }
      }
    }
    if(check) out.println("Yes");
    else out.println("No");
  }
}

Measured memory_bytes: 22996
using System;

namespace AGC025_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var m = N;
            for (int a = 1; a < N; a++)
            {
                var b = N - a;
                var t = get(a) + get(b);
                if (a + b == N && m > t)
                {
                    m = t;
                }
            }
            Console.WriteLine(m);
        }

        static int get(int n)
        {
            int sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    vector<bool> f(n,false);
    rep(i,n){
        int x,y;
        cin>>x>>y;
        if(x==y){
            f[i]=true;
        }
        
    }
    rep(i,n-2){
        if(f[i]&&f[i+1]&&f[i+2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
    
    
return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define MOD 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N;
	cin >> N;
	vector<int> B(N);
	for(int i = 0; i < N; i ++){
		cin >> B[i];
	}
	vector<int> ANS;
	int tmp;
	bool flag = true;
	while(B.size() > 0){
		tmp = 1000;
		for(int i = 0; i < B.size(); i ++){
			if(B[i] - 1 == i)tmp = i;
		}
		if(tmp == 1000){
			flag = false;
			break;
		}
		ANS.pb(B[tmp]);
		B.erase(B.begin() + tmp);
	}
	if(flag){
		for(int i = ANS.size() - 1; i >= 0; i --){
			cout << ANS[i] << endl;
		}
	}
	else cout << -1 << endl;

	return 0;
}

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


int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >>e;
  
  int S = a+b+c+d+e;
  
  if(S==14){
    cout << 1 <<endl;
  }
  else if(S==13){
    cout << 2 <<endl;
  }
  else if(S==12){
    cout << 3 <<endl;
  }
  else if(S==11){
    cout << 4 <<endl;
  }
  else{
    cout << 5 <<endl;
  }
}

Measured memory_bytes: 3592
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n,x,y = MI()
	x-=1;y-=1
	dist = [0]*(n-1)
	for i in range(n-1):
		for j in range(i+1,n):
			dist[min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))-1]+=1
	printV(dist)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; ; i++)
            {
                string[] num = Console.ReadLine().Split();

                if (num[0] == num[1] && int.Parse(num[0]) == 0)
                {
                    break;
                }

                if (int.Parse(num[0]) < int.Parse(num[1]))
                {
                    Console.WriteLine(num[0] + " " + num[1]);
                }
                else
                {
                    Console.WriteLine(num[1] + " " + num[0]);
                }
            }

        }
    }
}



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


int main(){
    int N,M;
    int A[10000];
    cin >> N >> M;
    for(int i=0; i<M; i++){
        cin >> A[i];
    }

    for(int j=0; j<M; j++){
        N -= A[j];
    }

    if(N>=0){
        cout << N;
    }
    else{
        cout << -1;
    }


    return 0;
}

Measured memory_bytes: 3632
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n")
  tmp0 = input[0].split(" ")

  A = Number(tmp0[0])
  B = Number(tmp0[1])

  if(B % A == 0){
    console.log(A+B)
  }else{
    console.log(B-A)
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("1 1\n")

Measured memory_bytes: 21064
#include <stdio.h>

int main(int argc, char const *argv[]) {
  char excolor[9];
  int input, range;
  int output = 0;
  for (int i = 0; i < 9; i++) {
    excolor[i] = 0;
  }

  (void)scanf("%d", &range);

  for (int i = 0; i < range; i++) {
    (void)scanf("%d", &input);
    if (input / 400 < 8) {
      excolor[(int)input / 400] = 1;
    }else{
      excolor[8]++;
    }

  }

  for (int i = 0; i < 8; i++) {
    output += excolor[i];
  }

  if (output == 0) {
    printf("%d ", 1);
  }else{
    printf("%d ", output);
  }

  printf("%d\n", output + excolor[8]);
  return 0;
  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int LL
using namespace std;
typedef long long LL;
const int Mod=1e9+7;
typedef vector<vector<int> > mat;
mat G;
int n,K;
mat empty_mat()
{
	mat A;
	A.resize(n);
	for(int i=0;i<n;i++)A[i].resize(n);
	return A;
}
mat operator * (mat A,mat B)
{
	mat C=empty_mat();
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				C[i][j]+=A[i][k]*B[k][j];
				C[i][j]%=Mod;
			}
		}
	}
	return C;
}
mat bin_pow(mat A,int b)
{
	mat ans=A;
	b--;
	while(b>0)
	{
		if(b%2)ans=ans*A;
		A=A*A;
		b/=2;
	}
	return ans;
}
signed main()
{
	cin>>n>>K;
	G=empty_mat();
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>G[i][j];
		}
	}
	mat res=bin_pow(G,K);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
		//	cout<<res[i][j]<<" ";
			sum+=res[i][j];
		}
	//	cout<<endl;
	}
	cout<<sum%Mod<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


using namespace std;

ll N, M;
vector<ll> A, B;
vector<ll> C;

class UnionFind {
public:
    vector<ll> par;
    vector<ll> size;

    UnionFind(ll N){
        par.resize(N);
        size.resize(N);
        for(int i=0; i<N; i++){
            par[i] = i;
            size[i] = 1;
        }
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return root(par[x]);
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(size[rx] <= size[ry]){
            par[rx] = ry;
            size[ry] += size[rx]; 
        }else{
            par[ry] = rx;
            size[rx] += size[ry]; 
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        else return false;
    }

    ll get_size(ll x){
        ll rx = root(x);
        return size[rx];
    }
};

int main()
{
    cin >> N >> M;
    A.resize(M);
    B.resize(M);
    C.resize(M+1);
    rep(i, M){
        cin >> A[i] >> B[i];
    }

    UnionFind un(N);
    ll cnt = N*(N-1)/2;
    C[M] = cnt;

    for(int i=M-1; i>=0; i--){
        ll tmp1 = A[i]-1;
        ll tmp2 = B[i]-1;
        if(un.same(tmp1, tmp2)){
            C[i] = cnt;
        }else{
            cnt -= un.get_size(tmp1) * un.get_size(tmp2);
            C[i] = cnt;
            un.unite(tmp1, tmp2);
        }
    }

    reps(i, M) cout << C[i] << endl;

}

Measured memory_bytes: 5248
#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>;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll ans;
  if (x/d > k) {
    ans = x - d*k;
  } else {
    ll e = x/d;
    k -= e;
    x -= e*d;
    if (k%2 == 1) x = abs(x-d);
    ans = x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val n = 3

  val c = (0 until n).map { i ->
    br.readLine().split(" ").map { it.toInt() }
      .toIntArray()
  }

  val b = c[0]
  val a = IntArray(n, { i -> c[i][0] - b[0] })

  fun evalute() =
    (0 until n).all { i ->
      (0 until n).all { j ->
        c[i][j] == (a[i] + b[j])
      }
    }

  val ans = if(evalute()) "Yes" else "No"

  println(ans)
}

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

int main() {
  int r, g;
  cin >> r >> g;

  cout << (2*g-r) << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int A, B, C;

	scanf("%d%d%d", &A, &B, &C);

	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);

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

	int c = 0;

	if (v[0] % 2 != v[1] % 2) {
		v[1]++;
		v[2]++;
		c++;
	}

	c += (v[1] - v[0]) / 2;
	c += v[2] - v[1];

	printf("%d\n", c);

	return 0;
}


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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  //int k = ( a + b ) / 2;
  int n = ( a + b ) % 2;

  if ( n == 0 ){
    cout << ( a + b ) / 2 << endl;
  }else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,f = 0;
  scanf("%d", &n);
  for(int i=1;i<=100;i*=10){
    if((n/i)%10 == 7){
      printf("Yes\n");
      f=1;
      break;
    }
  }
  if(f==0) printf("No\n");

  return 0;
}


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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(long long& a : A) cin >> a;
  sort(A.begin(), A.end());
  int ans = 0;
  long long s = 0;
  for(long long& a : A){
    if(a <= 2 * s) ans++;
    else ans = 1;
    s += a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string s;
/**********************************************/

int main(){
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	string s=readString();
	int cnt[2]{},n=s.size(),k=n;
	REP(i,n)cnt[s[i]-'0']++;
	int i=0;
	while(cnt[0]&&cnt[1]){
		k--;
		cnt[s[i]-'0']--;
		cnt[s[n-1-i]-'0']--;
		i++;
	}
	cout<<k<<endl;
}

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

int main(){
    int N;
    cin >> N;
    int array[110];
    for(int i = 0; i < N; i++) cin >> array[i];
    int bucket[110] = {0};

    for(int i = 0; i < N; i++){
        bucket[array[i]]++;
    }

    int count = 0;
    for(int i = 1; i <= 100; i++){
        if(bucket[i]) count++;
    }
    cout << count << endl;
}

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

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

    int minimum = 0;
    vector<int> h(len + 1);
    for (int i = 0; i < len; i++) {
        h.at(i + 1) = h.at(i) + ((s.at(i) == '(') ? 1 : -1);
        minimum = min(minimum, h.at(i + 1));
    }
    
    if (minimum == 0 && h.at(len) == 0) {
        cout << s << endl;
        return 0;
    }
    
    string l;
    for (int i = 0; i < abs(minimum); i++) l += '(';
    
    s = l + s;
    
    for (int i = 0; i < h.at(len) + abs(minimum); i++) s += ')';
    
    cout << s << endl;
}   

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
  char input[150];
  char make[150];
  int n,m;
  int t;
  int i,j;
  int judge=0;

  scanf("%s",input);
  scanf("%s",make);

  n=strlen(input);
  m=strlen(make);

  for (i=0; i<n; i++) {
    if (input[i]==make[0]) {
      for (j=0; j<m; j++) {
        t=i+j;
        if (t>n-1) {
          t=t-n;
        }
        if (input[t]!=make[j]) {
          break;
        }
        else if (j==m-1) judge=1;
      }
    }
  }
  
  if (judge!=1) printf("No\n");
  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 524
import sys
import itertools

input = sys.stdin.readline

def main():
    N = int(input())
    l = ['M', 'A', 'R', 'C', 'H']
    m = [0]*5
    for _ in range(N):
        S = input()[:-1]
        Shead = S[0]
        for i, s0 in enumerate(l):
            if Shead == s0:
                m[i] += 1
                break
    ll = []
    for i, n in enumerate(m):
        if n >= 1:
            ll.append(l[i])
    if len(ll) <= 2:
        print(0)
        return
    ans = 0
    for i, j, k in itertools.combinations(ll, 3):
        ans += m[l.index(i)] * m[l.index(j)] * m[l.index(k)]

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9148
#include <iostream>

using namespace std;

int main()
{
	int n, a[200001];
	long long ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int max = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > max) {
			max = a[i];
		}
		ans += max - a[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ll n;
    vector<ll> v;
    ll sum = 0;
    cin >> n;
    for(int i = 0;i < n;i++) {
        ll t;
        cin >> t;
        v.push_back(t);
    }
    for(int i = 0;i < n;i++) {
        ll t;
        cin >> t;
        if(v[i] - t > 0) {
            sum += v[i] - t;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-23
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

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

    if (N == 1 && M == 1){
        cout << 1 << "\n";
        return 0;
    }

    if (N == 1 || M == 1){
        cout << max(N,M) - 2 << "\n";
        return 0;
    }

    cout << N * M - (N * 2 + M * 2 - 4) << "\n";

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		long ans = Long.MAX_VALUE/2;
		for(int i : x) {
			for(int j : x) {
				for(int k : y) {
					for(int l : y) {
						int c = 0;
						for(int m = 0; m < N; m++)
							if(i <= x[m] && x[m] <= j && k <= y[m] && y[m] <= l)
								c++;
						if(c >= K)
							ans = Math.min(ans, Math.abs((long)(j-i)*(l-k)));
					}
				}
			}
		}
		System.out.println(ans);
	}

}

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


int abs(int a){
	if(a<0){
		return -a;
	}
	return a;
}
int dfs(int index,vector<int>&vec,vector<int>&dp){
	int n=vec.size();
	if(index==n-1){
		return 0;
	}
	if(index==n-2){
		dp[index]=abs(vec[n-1]-vec[n-2]);
		return dp[index];
	}
	if(dp[index]!=-1){
		return dp[index];
	}

	int ans=abs(vec[index+1]-vec[index])+dfs(index+1,vec,dp);
	int ans1=abs(vec[index+2]-vec[index])+dfs(index+2,vec,dp);
	dp[index]=min(ans,ans1);
	return dp[index];
}
int32_t main(){
	int n;
	cin>>n;
	vector<int> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i];
	}
	vector<int> dp(n,-1);
	// dfs(0,vec,dp);
	cout<<dfs(0,vec,dp);
	return 0;
}


Measured memory_bytes: 8832
#include<stdio.h>
#include<math.h>
int main()
{
	double x,y,x1,x2,y1,y2,d,distance;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	x=x2-x1;
	x=pow(x,2.0);
	y=y2-y1;
	y=pow(y,2.0);
	d=x+y;
	distance=sqrt(d);
	printf("%lf\n",distance);
	return 0;

	
}

Measured memory_bytes: 1080
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	a := sc.ReadInt()
	b := sc.ReadInt()
	n := sc.ReadInt()

	x := Min(b-1, n)
	ans := a * x / b

	fmt.Println(ans)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1760
#include <iostream>

using namespace std;

int main()
{
   long long x;

   cin >> x;

  long long f = (x * 100) / 108;


    if((f * 108) / 100 < x)
        f++;

    if(x >= (f * 108)/ 100)
        cout << f;
    else
        cout << ":(";

    return 0;
}


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

int main() {
	int a, b;
	string ans;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		ans = "Even";
	}
	else {
		ans = "Odd";
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();

        int i = 1;
        int cnt = 0;
        int sum = 0;
        while (true) {
            if (sum >= x) {
                break;
            }
            sum += i;
            cnt++;
            i++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

int main() {
    int n,m;
    cin >> n;
    vector<int> t(n);
    rep(i,n) {
        cin >> t[i];
    }
    cin >> m;
    vector<int> P(m);
    vector<int> X(m);
    rep(i,m) {
        cin >> P[i] >> X[i];
    }
    rep(i,m) {
        int total = 0;
        rep(j,n) {
            int tt = t[j];
            if (P[i]-1 == j) {
                tt = X[i];
            }
            total += tt;
        }
        cout << total << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
int n,Ans,cnt,to[MN],node[MN];
ll m;
bool vis[MN];
void dfs(int st){
	vis[st]=true;m--;
	if(!m){Ans=st;return;}
	if(vis[to[st]]){
		reg int x=to[st];
		while(x!=st)node[cnt++]=x,x=to[x];
		node[cnt++]=st;
		return;
	}
	dfs(to[st]);
}
int main(){
	scanf("%d%lld",&n,&m);
	for(reg int i=1,x;i<=n;i++)
		scanf("%d",to+i);
	m++;dfs(1);m--;
	if(Ans)return 0*printf("%d\n",Ans);
	printf("%d\n",node[m%cnt]);
	return 0;
}

Measured memory_bytes: 5316
import java.util.*;

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

    int n = sc.nextInt();

    int x_500 =  n/500;
    n = n - n/500 * 500;

    int x_5 = n/5;

    int ans = x_500 *1000 + x_5 * 5;

    System.out.println(ans);

  }
}

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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

    ll q=1;
    //cin>>q;
    while(q--){

        ll n;
        cin>>n;

        ll ans= 0;

        REP(i,1,n+1){
            if(i%3==0 || i%5==0 )continue;
            else{
                ans+=i;
            }
        }


        cout<<ans<<endl;

    }

return 0;
}


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

int pow(int n) {
  int p = 1;
  for (int i = 0; i < n; i++)
    p *= 10;
  return p;
}

int calclen(int n) {
  int count = 0;
  while (n > 0) {
    n /= 10;
    count++;
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  for (int num = 0; ; num++) {
    int len;
    if (num == 0) len = 1; 
    else len = calclen(num);
    bool flag = false;
    for (int i = 0; i + len - 1 < n; i++) {
      int t = 0;
      for (int j = 0; j < len; j++) {
	t += a[i + j] * pow(len - j - 1);
      }
      if (t == num) {
	flag = true;
      }
    }
    if (flag == false) {
      cout << num << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3072