akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    rep(i, N) P[i]--;
    vector<int> idx(N);
    rep(i, N) idx[P[i]] = i;
    set<int> s;
    ll ans = 0;
    for (int n=N-1; n>=0; --n) {
        int i = idx[n];
        ll c = 0;
        {// calc c
            s.insert(i); // sにiを追加してから以降でiの場所を検索している
            vector<int> l(2,-1);
            vector<int> r(2, N);
            { // calc l
                auto it = s.find(i); // iがいる場所のイテレータを返す
                rep(j,2) {
                    if (it == s.begin()) break;
                    --it;
                    l[j] = *it; // イテレータの場所にある値を返す
                }
            }
            { // calc r
                auto it = s.find(i); // iがいる場所のイテレータを返す
                rep(j,2) {
                    ++it;
                    if (it == s.end()) break; // end()は末尾の場所+1(nullを返す)
                    r[j] = *it; // イテレータの場所にある値を返す
                }
            }
            vector<int> ls(2);
            ls[0] = i-l[0]; ls[1] = l[0]-l[1];
            vector<int> rs(2);
            rs[0] = r[0]-i; rs[1] = r[1]-r[0];
            c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];
        }
        ans += c*(n+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, A = 0, B = 1, sumA = 0, sumB = 0;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  if(n % 2 == 0) {
    for(int i = 0; i < n / 2; i++) {
      sumA += vec.at(A);
      A += 2;
    }
    for(int i = 0; i < n / 2; i++) {
      sumB += vec.at(B);
      B += 2;
    }
    cout << sumA - sumB << endl;
  }
  else {
    for(int i = 0; i < (n + 1) / 2; i++) {
      sumA += vec.at(A);
      A += 2;
    }
    for(int i = 0; i < n / 2; i++) {
      sumB += vec.at(B);
      B += 2;
    }
    cout << sumA - sumB << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

/*
    ユークリッドの互除法（正の整数x, yの最大公約数を返す）
*/

long long gcd(long long x, long long y) {
    if (x < y) swap(x, y);
    while (x % y != 0) {
        long long divisor = x % y;
        x = y;
        y = divisor;
    }
    return y;
}

/*
    最小公倍数を求める
*/

long long lcm(long long x, long long y) {
    long long g = gcd(x, y);
    return g * (x / g) * (y / g);
}

int main() {

    int N;
    cin >> N;
    long long T[N];
    for (int i = 0; i < N; i++) cin >> T[i];

    long long ans = T[0];
    for (int i = 1; i < N; i++) ans = lcm(ans, T[i]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
"use strice";

function main(arg) {
    const price   = parseInt(arg.split("\n")[0]);
    const cake    = parseInt(arg.split("\n")[1]);
    const donut   = parseInt(arg.split("\n")[2]);
    console.log((price - cake) % donut);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define MOD ((int)1e9+7)

typedef long long int lld;
typedef pair<int, int> pii;

const int maxn = 2005;
string s[maxn];
int dp[maxn][maxn];

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

	int n, m;
	cin >> n >> m;

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

	dp[1][1] = 1;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1][j - 1] != '#') {
				dp[i][j] = (dp[i][j] + dp[i - 1][j] + (lld)dp[i][j - 1]) % MOD;
			}
		}
	}

	cout << dp[n][m] % MOD << endl;
}

Measured memory_bytes: 9472
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

// vars
int n;
string s;


void input(){
    cin >> n;
    cin >> s;
    return;
}

void solve(){
    if(n % 2 == 1){
        cout << "No" << endl;
        return;
    }
    int m = n / 2;
    bool isOK = true;
    REP(i, m){
        if(s[i] != s[m + i]){
            isOK = false;
        }
    }
    if(isOK){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 888
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      long x = sc.nextLong();
      long y = sc.nextLong();
      if(x%y==0||y==1){
      	System.out.println(-1);
        return;
      }
     for(long i = x;i <= (long)Math.pow(10,18);i+=x){
     	if(i%y!=0){
        	System.out.println(i);
          return;
        }
     }
      System.out.println(-1);
    }
}


Measured memory_bytes: 23508
import sys
input=sys.stdin.readline

s = input().strip()
op = ["+","-"]
for i in op:
    for j in op:
        for k in op:
            x = s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(x) == 7:
                print(x+"=7")
                exit()


Measured memory_bytes: 3060
n,m = gets.split.map &:to_i
a = Array.new(n){ -1 }

m.times do
  s,c = gets.split.map &:to_i
  s -= 1

  if a[s] != -1 && a[s] != c
    puts -1
    exit
  end

  a[s] = c
end

n.times do |i|
  if a[i] == -1
    if i == 0 && n != 1
      a[i] = 1
    else
      a[i] = 0
    end
  end
end

if a[0] == 0 && n != 1
  puts -1
else
  puts a.join
end
    

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	int a,b,c;
	ll ans=0;
	cin>>a>>b>>c;
	if(a+b+c<=21)
		cout<<"win"<<endl;
	else
		cout<<"bust"<<endl;
	return 0;
}

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


int n;
map<string, vector<pair<int,int>>> guide;
vector<string> order;
set <string> s;
void orderit(string str){
	for(int i = 0; i < (int)order.size(); i++){
		string x = order[i];
		sort(guide[x].begin(), guide[x].end());
		for(int i = guide[x].size() - 1; i >= 0; i--){
			cout << guide[x][i].second << "\n";
		}
	}
}

int main() {
	cin >> n;
	for(int i = 1; i <= n; i ++){
		string str;
		int a;
		cin >> str >> a;
		guide[str].push_back({a, i});
		s.insert(str);
	}
	for(string str : s) order.push_back(str);
	sort(order.begin(), order.end());
	orderit("");
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int

	fmt.Scan(&a, &b, &c)

	if a == b && a != c {
		fmt.Println("Yes")
	} else if a == c && a != b {
		fmt.Println("Yes")
	} else if b == c && b != a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q;
    string s;
    cin >> n >> q >> s;
    int a[100005]{};
    for(int i = 0;i < n-1;i++){
        a[i] = (s[i] == 'A' && s[i+1] == 'C');
        if(i > 0)a[i] += a[i-1];
    }
    a[n-1] = a[n-2];
    while(q--){
        int l,r;
        cin >> l >> r;
        l--,r--;
        cout << a[r] - a[l-1] - (s[r] == 'A' && s[r+1] == 'C')<< endl;
    }

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    char s[101];
    rep(i, 101) s[i] = '\0';
    scanf("%s", s);
    int count = 0;
    while(s[count] != '\0')
        count++;
    rep(i, count) printf("x");
    printf("\n");
    return 0;
}


Measured memory_bytes: 3644
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * ((10**6)+1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10**6)+1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10**6)+1)

a = list(set(a))

for elem in a:
    for m in range(elem*2, (10**6)+1, elem):
        cnt[m] = 1

ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans+=1

print(ans)


Measured memory_bytes: 143612
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  for(int i=1; i<=9; i++){
      if(n%i==0 && (n/i)/10==0) {
        cout<<"Yes"<<endl;
      return 0;
    }
    else continue;
  }
  cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll N;
	cin >> N;

	static ll ansNum[15];
	static ll x[15][15];
	static ll y[15][15];

	REP(i, N) {
		ll xyNum;
		cin >> xyNum;
		ansNum[i] = xyNum;
		REP(j, xyNum) {
			cin >> x[i][j];
			cin >> y[i][j];
			x[i][j]--;
		}
	}

	ll ans = 0;
	ll maxCnt = 2 << (N - 1);
	for (ll bitPtn = 0; bitPtn < maxCnt; bitPtn++) {
		ll ansCnt = 0;
		vector<int> ansList(N, 0);
		REP(i, N) {
			if (bitPtn & (1 << i)) {
				ansList[i] = 1;
				ansCnt++;
			}
		}

		bool isOk = true;
		REP(i, N) {
			REP(j, ansNum[i]) {
				int ansListOne = ansList[x[i][j]];
				if (ansList[i]) {
					if (ansListOne != y[i][j]) {
						isOk = false;
						goto EXIT;
					}
				}
			}
		}
EXIT:
		if (isOk) {
			ans = max(ans, ansCnt);
		}
	}

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



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

int main(){
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	for(int i = n-1; i >= 0; i--){
		cout << arr[i];
		if(i != 0)
			cout << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3068
#include <iostream>

using namespace std;

int main(){
  int N; cin>>N;
  int num1=N%4; num1+=4; num1%=7; 
  int num2=N%7; num2%=4; 
  if(N>=21){cout<<"Yes"<<endl; return 0;}
  if((N>7&&num1==0)||N%4==0) cout<<"Yes"<<endl;
  else if(num2==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    char c[2][3];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    if ((c[0][0] == c[1][2]) && (c[0][1] == c[1][1]) && (c[0][2] == c[1][0])) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int sx,sy,tx,ty;
	 cin>>sx>>sy>>tx>>ty;
	 int diffx=tx-sx;
	 int diffy=ty-sy;
	 for(int i=0;i<diffy;i++)
	 	cout<<"U";
	 for(int i=0;i<diffx;i++)
	 	cout<<"R";
	 for(int i=0;i<diffy;i++)
	 	cout<<"D";
	 for(int i=0;i<diffx;i++)
	 	cout<<"L";
	 cout<<"D";
	 for(int i=0;i<diffx+1;i++)
	 	cout<<"R";
	 for(int i=0;i<diffy+1;i++)
	 	cout<<"U";
	 cout<<"L";
	 cout<<"U";
	 for(int i=0;i<diffx+1;i++)
	 	cout<<"L";
	 for(int i=0;i<diffy+1;i++)
	 	cout<<"D";
	 cout<<"R";
	 cout<<endl;
	 return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int A = 0,B = 0;
	int n,a,b; cin >> n >> a >> b;
	string t; cin >> t;
	for(int i=0;i<n;i++){
		if(t[i] == 'c'){
			puts("No");
			continue;
		}
		else if(t[i] == 'a'){
			if(A+B < a+b){
				A++;
				puts("Yes");
			}
			else{
				puts("No");
			}
		}else{
			if(A+B < a+b && B<b){
				B++;
				puts("Yes");
			}
			else{
				puts("No");
			}
		}
	}
}

Measured memory_bytes: 896
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N-1); cin >> A >> B >> C;
  for (auto& x : A) --x;

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += B[A[i]];
  }
  for (int i = 1; i < N; ++i) {
    if (A[i-1] + 1 == A[i]) {
      ans += C[A[i-1]];
    }
  }
  cout << ans << endl;
}


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

using namespace std;
const auto MOD = (long long) 1e9 + 7;

// powermod
long long powMod(long long x, long long k) {
    if (k == 0) return 1;
    if (k % 2 == 0) return (powMod((x * x + MOD) % MOD, k / 2) + MOD) % MOD;
    else return (x * powMod(x, k - 1) + MOD) % MOD;
}

// invMod
long long invMod(long long x) {
    return powMod(x, MOD - 2);
}

// combMod
long long combMod(long long n, long long r) {
    long long a = 1, b = 1;
    for (long long i = 1; i <= r; i++) {
        a = a * (n - i + 1) % MOD;
        b = b * i % MOD;
    }
    return a * invMod(b) % MOD;
}


int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans = powMod(2, n) - 1;
    ans = (ans - combMod(n, a) - combMod(n, b)) % MOD;
    while (ans < 0) ans += MOD;
    cout << ans << 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(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<int> v={1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,22,24,25,27,28,30,32,35,36,40,42,45,48,49,51,54,56,63,64,72,81};
  bool j=false;
  rep(i,v.size()) if(v.at(i)==n) j=true;
  (j)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while(true){
    double r;
    LL n;
    cin >> r >> n;
    if (r == 0)
    {
      break;
  }
  vector<double> plusH(21,0);
  vector<double> minusH(21,0);
  
  REP(i,n){
    LL xl, xr;
    double H;
    cin >> xl >> xr >> H;
    if(xl<=0&&xr<=0){
      for (LL i = -xr; i < -xl;++i){
        minusH[i] = max(minusH[i], H);
      }
    }else
    if(xl<=0&&xr>=0){
      for (LL i = 0; i < xr;++i){
        plusH[i] = max(plusH[i], H);
      }
      for (LL i = 0; i < -xl;++i){
        minusH[i] = max(minusH[i], H);
      }
    }else
    if(xl>=0&&xr>=0){
      for (LL i = xl; i < xr;++i){
        plusH[i] = max(plusH[i], H);
      }
    }
  }

  double mint = 1e10;
  
  REP(i,r){
    double starty = -(r-sqrt(r * r - i * i));

    double tt = min({plusH[i] - starty, minusH[i] - starty});
    mint = min({mint, tt});
  }

  cout << max(0.,mint) << endl;
  }
}



Measured memory_bytes: 3308
from heapq import heappop, heappush
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

INF = 10**15

def dijkstra(E, s, g):
    d = [INF] * len(E)
    d[0] = 0

    queue = []
    heappush(queue, (0, s))

    while queue:
        dist_v, v = heappop(queue)
        if dist_v > d[v]:
            continue
        
        for e, w in E[v]:
            tmp = d[v] + w
            if tmp < d[e]:
                d[e] = tmp
                heappush(queue, (tmp, e))
    
    return d[g]


def main():
    x_s, y_s, x_t, y_t = map(int, readline().split())
    N,*xyr = map(int, read().split())

    XYR = []
    XYR.append((x_s, y_s, 0))
    XYR.append((x_t, y_t, 0))
    for x, y, r in zip(*[iter(xyr)]*3):
        XYR.append((x, y, r))
    
    E = [[] for _ in range(N+2)]
    for i in range(N+1):
        x_i, y_i, r_i = XYR[i]
        for j in range(i+1, N+2):
            x_j, y_j, r_j = XYR[j]
            d = sqrt((x_i - x_j)**2 + (y_i - y_j)**2)
            d -= r_i + r_j
            d = max(0, d)
            E[i].append((j, d))
            E[j].append((i, d))

    ans = dijkstra(E, 0, 1)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 125192
#include<iostream>
using namespace std;
int main(){
  long long ans = 100000000000000;
  long long n; cin >> n;
  long long i=1;
  while(i <= n/i){
    if(n%i==0){
      if((i+n/i-2) < ans) ans = i+n/i-2;
    }
    i++;
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
    int countNum[100001] = {0};
    int maxCount = 0;

    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        int a; cin >> a;
        countNum[a]++;
        if (a > 0) countNum[a - 1]++;
        if (a < 100000) countNum[a + 1]++;

        if (a > 0 && a < 100000) {
            maxCount = max(max(maxCount, countNum[a]), max(countNum[a - 1], countNum[a + 1]));
        } else if (a == 0) {
            maxCount = max(max(maxCount, countNum[a]), countNum[a + 1]);
        } else if (a == 99999) {
            maxCount = max(max(maxCount, countNum[a]), countNum[a - 1]);
        }
    }
    cout << maxCount << endl;

    return 0;
}

Measured memory_bytes: 640
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
g = 1
lcm = 1
A = [I() for _ in range(n)]
for a in A:
    g = gcd(lcm,a)
    #print(g)
    lcm = lcm * a // g
    #print(lcm)
print(lcm)


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


int main(){
  char s[100],t[100];
  int sl,tl,x,y,tmp,i,j;
  y=0;
  scanf("%s",s);
  scanf("%s",t);
  sl = strlen(s);
  tl = strlen(t);
  if(sl > tl){
    x = tl;
  }else{
    x = sl;
  }
  for(i=0;i<sl;i++){
    for(j=i+1;j<sl;j++){
      if(s[i] > s[j]){
        tmp = s[j];
        s[j] = s[i];
        s[i] = tmp;
      }
    }
  }
  for(i=0;i<tl;i++){
    for(j=i+1;j<tl;j++){
      if(t[i] < t[j]){
        tmp = t[j];
        t[j] = t[i];
        t[i] = tmp;
      }
    }
  }
  for(i=0;i<x;i++){
    if(s[i]<t[i]){
      printf("Yes\n");
      break;
    }else if(s[i]>t[i]){
      printf("No\n");
      break;
    }else if(s[i]==t[i]){
      y += 1;
    }
  }
  if(y==x){
    if(tl > sl){
      printf("Yes");
    }else{
      printf("No");
    }
  }
  return 0;
}

Measured memory_bytes: 128
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    //val datA = readLine.split("").filterNot(_ == "")
    val datA = readLine

    /*
    val ans = (0 until datA.length).map{ lead =>
      datA.take(lead).filter(_ == "W").length +
      datA.drop(lead + 1).filter(_ == "E").length
    }.min
    */

    /*
    def countLeftW(res: Vector[Int], count: Int, dat: Array[String]): Vector[Int] = {
      if (dat.isEmpty) res
      else countLeftW(res :+ count, (if (dat.head == "W") count + 1 else count), dat.tail)
    }
    */

    /*
    def countRightE(res: Vector[Int], count: Int, dat: Array[String]): Vector[Int] = {
      if (dat.isEmpty) res.reverse
      else countRightE(res :+ count, (if (dat.last == "E") count + 1 else count), dat.init)
    }
    */

    //val ans = (countLeftW(Vector(), 0, datA) zip countRightE(Vector(), 0, datA)).map{case (a, b) => a + b}.min
    /*
    val leftW = countLeftW(Vector(), 0, datA)
    val rightE = countRightE(Vector(), 0, datA)
    val ans = (0 until datN).map(x => leftW(x) + rightE(x)).min
    */

    val leftW = datA.scanLeft(0){ (acc, ch) =>
      if (ch == 'W') acc + 1 else acc
    }.init
    //println(leftW)
    val rightE = datA.scanRight(0){ (ch, acc) =>
      if (ch == 'E') acc + 1 else acc
    }.tail
    //println(rightE)
    val ans = (leftW zip rightE).map{case (a, b) => a + b}.min
    println(ans)
  }
}


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 6e6 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main ()
{
	hey();
	string s;
	cin >> s;
	string t;
	cin >> t;
	if (s.size() >= t.size())
	{
		cout << "No";
		return 0;
	}
	string check = t.substr(0, s.size());
	if (check == s && t.size() - 1 == s.size() && t[t.size() - 1] >= 'a' && t[t.size() - 1] <= 'z')
	{
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}



Measured memory_bytes: 3644
import sys

for in_str in sys.stdin:
    comp_list = list(map(int, in_str.split(" ")))
#    a, b = map(int, in_str.split())
    a = comp_list[0]
    b = comp_list[1]
    if (a == 0) & (b == 0) : break
    elif a < b :
        print(a, b)
    else :
        print(b, a)

Measured memory_bytes: 8068
program main
  implicit none
  integer :: n, m, i, j, input(11), s(10, 10), k(10), p(10)
  integer :: res, state
  read (*, *) n, m
  do i = 1, m
    read (*, *) k(i), s(i, 1:k(i))
  end do
  read (*, *) p(1:m)

  res = 0
  do state = 0, 2 ** n - 1
    if (satisfy(state)) res = res + 1
  end do
  write (*, "(i0)") res

  contains

  pure logical function satisfy(state)
    integer, intent(in) :: state  ! Bit
    integer :: i, j, cnt
    ! i-th switch is on if btest(state, i - 1)
    satisfy = .true.
    do i = 1, m
      cnt = 0
      do j = 1, k(i)
        if (btest(state, s(i, j) - 1)) cnt = cnt + 1
      end do
      if (mod(cnt, 2) /= p(i)) satisfy = .false.
    end do
  end function satisfy
end program main


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

int main() {
  int n; cin>>n;
  ll sum=0;
  rep(i, n) {
    ll a; cin>>a;
    sum^=a;
  }
  if (sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, K;
        public int[] A;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                K = line[1];
                A = Input.ReadIntArray();
            }

            Dictionary<int, int> count = new Dictionary<int, int>();

            for (int i = 0; i < N; i++)
            {
                if(!count.ContainsKey(A[i])) count.Add(A[i], 0);
                count[A[i]]++;
            }

            List<int> c = new List<int>();
            foreach (var kv in count)
            {
                c.Add(kv.Value);
            }

            c.Sort();

            int ret = 0;
            for (int i = 0; i < c.Count - K; i++) ret += c[i];
            Console.WriteLine(ret);

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 41796
n=int(input())
account=0
wacount=0
tlecount=0
recount=0
for i in range(n):
  s=input()
  if s=='AC':
    account+=1
  if s=='WA':
    wacount+=1
  if s=='TLE':
    tlecount+=1
  if s=='RE':
    recount+=1
print('AC x',account)
print('WA x',wacount)
print('TLE x',tlecount)
print('RE x',recount)

Measured memory_bytes: 69860
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, q, i;
    int[] y;
    String[] name;

    n = sc.nextInt(); q = sc.nextInt();
    y = new int[n]; name = new String[n];
    for(i = 0;i < n;i++){
      y[i] = sc.nextInt(); name[i] = sc.next();
    }
    for(i = 0;i < n;i++)if(q < y[i]){
      if(i == 0)out.println("kogakubu10gokan");
      else out.println(name[i - 1]);
      break;
    }
    if(i == n)out.println(name[i - 1]);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 18128
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;


struct NODE{
	int x,y,cst;
	NODE(int x,int y,int cst) : x(x) , y(y) , cst(cst) {}
};
bool operator < (const NODE &a,const NODE &b){
	return a.cst > b.cst;
}
int room[500][500];
bool flag[500][500];
int from[500*500];
int main(){
	int R;
	while(cin >> R && R){
		map<int,int> result[2];
		result[0][0] = 0;
		result[1][0] = 0;
		
		for(int i = 0 ; i < 2 ; i++){
			int W,H,sx,sy;
			cin >> W >> H >> sx >> sy;
			sx--,sy--;
			for(int y = 0 ; y < H ; y++)
				for(int x = 0 ; x < W ; x++)
					cin >> room[y][x];
			priority_queue<NODE> Q;
			Q.push(NODE(sx,sy,room[sy][sx]));
			memset(flag,0,sizeof(flag));
			while(Q.size()){
				NODE q = Q.top(); Q.pop();
				if(flag[q.y][q.x]) continue;
				else flag[q.y][q.x] = true;
				result[i][q.cst]++;
				int dx[] = {-1,0,1,0} , dy[] = {0,-1,0,1};
				for(int d = 0 ; d < 4 ; d++){
					int tx = q.x + dx[d] , ty = q.y + dy[d];
					if(tx >= 0 && ty >= 0 && tx < W && ty < H && !flag[ty][tx]) Q.push(NODE(tx,ty,max(q.cst,room[ty][tx])));
				}
			}
		}
		vector<int> u;
		int prev = 0;
		for(map<int,int>::iterator it = result[1].begin() ; it != result[1].end() ; ++it){
			from[u.size()] = it->first;
			u.push_back(it->second + prev);
			prev = u.back();
		}
		int ans = INT_MAX;
		u.push_back(INT_MAX);
		int prev2 = 0;
		for(map<int,int>::iterator it = result[0].begin() ; it != result[0].end() ; ++it){
			int thisLevel = it->first;
			int thisCount = it->second + prev2;
			int anotherCount = *lower_bound(u.begin(),u.end(),R-thisCount);
			if(anotherCount != INT_MAX){
				int anotherLevel = from[ lower_bound(u.begin(),u.end(),R-thisCount) - u.begin() ] ;
				ans = min(ans,thisLevel+anotherLevel);
			}
			prev2 += it->second;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 6132
//Training Camp

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    ll ans = 1;
    rep(i,1,n+1){
        ans=(ans*i)%1000000007;
    }
    cout << ans << nnn;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>

using namespace std;

int main()
{
    int x=0,y=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(isupper(s[i])){
            x++;}

        }
        for(int i=2;i<s.length()-1;i++){
            if (s[i]=='C')
                y=1;
        }


    if (x==2 && s[0]=='A' && y==1 )
        cout<<"AC";
    else
        cout<<"WA";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int num = 1001,num1 = 10000, INF = 2000000000;
int n, a[num], b[num], c[num1], tf[num], s = INF;
inline int mini() {
    int an = 0;
    int cu = 0;
    for (int i = 0; i < n; i++) {
        if (tf[i]) continue;
        cu = i;
        int m = INF;
        int sum = 0;
        int cnt = 0;
        while (true) {
            tf[cu] = 1;
            int v = a[cu];
            cnt++;
            m = min(v, m);
            sum += v;
            cu = c[v];
            if (tf[cu]) break;
        }
        an += min(sum + m*(cnt - 2), sum + m*(cnt - 2) + 2 * (m + s) - (m - s)*(cnt - 1));
    }
    return an;
}
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s = min(a[i], s);
        b[i] = a[i];
        tf[i] = 0;
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++) 
        c[b[i]] = i;
    int ans = mini();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  int n = in() ;
  ll ans = 0 ;
  for(int i = 1; i <= n ;i ++ )
   ans += 1ll * i * (n - i + 1) ;
  for(int i = 1; i < n ;i ++ )
   {
     ll a = in() , b = in() ;
     if(a > b) swap(a , b) ;
     ans -= 1ll * a * (n - b + 1) ;
   }
  cout << ans << endl ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3160
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
// ****  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fl(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define fi(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> dmap;
typedef set<int> dset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
/********** solver function **********/
long long int solve(int i, vector<int>&w, vector<int>&v, int we, int s, vector<vector<long long int>>&dp){
    if( s==we) return 0;
    if( i==v.size()){ if( s+w[i]<=we) return v[i];
    else return 0;
    }
    if( s>we || i>=v.size())  return INT_MIN;
    if( dp[i][s]!=-1) return dp[i][s];
    long long int a=INT_MIN, b=INT_MIN;
    if( s+w[i]<=we)
    {a=v[i]+solve( i+1, w, v, we,s+w[i], dp);b=solve( i+1, w,v,we,s, dp);
    return dp[i][s]= max(a,b);
    }
    else{
        return dp[i][s]=solve( i+1, w,v,we,s,dp);
    }
}
/********** Main()  function **********/
int main()
{std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
    int we; cin>>we;
    vector<int>w(n);
    vector<int>v(n);
    vector<vector<long long int>>dp(n,vector<long long int>(we+1, -1));
    //  cout<<"hwd";
    //  cout<<n<<" "<<we;
     for( int i=0;i<n;i++){
         cin>>w[i]>>v[i];
        //  cout<<w[i]<<" "<<v[i]<<endl;
     }
    //  cout<<"ksdh";
    cout<<solve(0, w, v, we,0, dp)<<endl;
	return 0;
}

Measured memory_bytes: 81936
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

constexpr int64 MOD = 1e9 + 7;

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

    int64 N, K;
    cin >> N >> K;

    int64 min_sum = 0,
          max_sum = 0,
          ans = 0;
    for (int i = 0; i < N + 1; i++) {
        min_sum += i;
        max_sum += N - i;

        if (i + 1 >= K) {
            (ans += MOD + max(0LL, max_sum - min_sum + 1)) %= MOD;
            // cerr << "i: " << i << " " << max_sum - min_sum + 1 << endl;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3192
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}


void solve()
{
	ll a , b, n;
	cin>>a>>b>>n;
	ll rem = min(b-1 , n);
	cout<<(a*rem)/b<<endl;

}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3812
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
lastday=[0 for j in range(26)]
points=[0 for i in range(D)]
t=[0 for i in range(D)]

# first day
lastday=[lastday[i]+1 for i in range(26)]
minus=[x*y for (x,y) in zip(c,lastday)]
firstday=minus.index(max(minus))
lastday[firstday]=0
t[0]=firstday+1

for days in range(1,D):
    temp=[x*y for (x,y) in zip(c,lastday)]
    today=temp.index(max(temp))
    lastday=[lastday[i]+1 for i in range(26)]
    lastday[today]=0
    t[days]=today+1

for ts in t:
    print(ts)

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstring>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

const int cap = 1e5 + 1;
const int mod = 1e9 + 7;
int N, x, y, root;
vector<int> G[cap];
int P[cap];

void build_tree(int i) {
    for (int j : G[i])
        if (j != root && P[j] == 0) {
            P[j] = i;
            build_tree(j);
        }
}

pair<int64_t, int64_t> dp(int i) {
    int64_t w = 1, b = 1;
    for (int j : G[i])
        if (j != P[i]) {
            auto res = dp(j);
            w = (w * (res.first + res.second)) % mod;
            b = (b * res.first) % mod;
        }
    // cout << i << " " << w << " " << b << endl;
    return make_pair(w, b);
}

int main() {
    scanf("%d", &N);
    fill(P, P + N + 1, 0);
    for (int i = 1; i <= N; ++i)
        G[i].clear();
    for (int i = 1; i < N; ++i) {
        scanf(" %d %d", &x, &y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    
    for (int i = 1; i <= N; ++i)
        if (G[i].size() == 1) {
            root = i;
            build_tree(i);
            break;
        }
    
    auto ans = dp(root);
    printf("%" PRId64 "\n", (ans.first + ans.second) % mod);
}











Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};
//BEGIN CUT HERE
// no muliple edge
template<typename Graph>
bool hasMultipleEulerianTrail(Graph &G){
  int n=G.size();
  vector<int> ind(n,0),outd(n,0),pre(n,-1),loop(n,0);
  for(int v=0;v<n;v++){
    for(int u:G[v]){
      ind[u]++,outd[v]++;
      if(u==v) loop[v]=1;
      if(u!=v) pre[u]=v;
    }
  }

  int st=-1,en=-1,sz=0;
  for(int i=0;i<n;i++){
    if(ind[i]>=3||outd[i]>=3) return true;
    if(ind[i]<outd[i]) st=i;
    if(ind[i]>outd[i]) en=i;
    if(ind[i]+outd[i]) sz++;
  }
  if(sz<2) return false;
  if(st<0) return true;

  while(ind[en]==1+loop[en]&&st!=en) en=pre[en];
  if(st==en) return false;

  queue<int> que;
  vector<int> rs(n,0);
  que.emplace(st);
  rs[st]=1;
  while(!que.empty()){
    int v=que.front();que.pop();
    for(int u:G[v]){
      if(u==en||rs[u]) continue;
      rs[u]=1;
      que.emplace(u);
    }
  }
  vector<int> us(n,0);
  que.emplace(en);
  us[en]=1;
  while(!que.empty()){
    int v=que.front();que.pop();
    if(rs[v]) return true;
    for(int u:G[v]){
      if(u==en||us[u]) continue;
      us[u]=1;
      que.emplace(u);
    }
  }
  return false;
}
//END CUT HERE
//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  const int MAX = 52;
  auto idx=[&](char c)->int{
             if(islower(c)) return c-'a';
             assert(isupper(c));
             return c-'A'+26;
           };

  string s;
  while(cin>>s,s!="#"){
    int n=s.size();
    if(n<=2){
      cout<<"No Results"<<endl;
      continue;
    }

    vector< set<int> > G(MAX);
    for(int i=0;i+1<n;i++){
      int x=idx(s[i]);
      int y=idx(s[i+1]);
      G[x].emplace(y);
    }

    vector<int> ind(MAX,0),outd(MAX,0);
    for(int v=0;v<MAX;v++)
      for(int u:G[v]) ind[u]++,outd[v]++;

    int res=0;
    for(int i=0;i<MAX;i++)
      res+=max<int>(ind[i]-outd[i],0);

    int m=accumulate(ind.begin(),ind.end(),0)+1;
    int add=max<int>(res-1,0);
    m+=add;

    if(m<n||add){
      cout<<m<<endl;
      continue;
    }

    vector< vector<int> > H(MAX);
    for(int v=0;v<MAX;v++)
      for(int u:G[v])
        H[v].emplace_back(u);

    int flg=hasMultipleEulerianTrail(H);
    cout<<(flg?m:m+1)<<endl;
  }
  return 0;
}
/*
  verified on 2019/06/24
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2324
*/



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n, m; cin >> n;
    map<ll, ll> b;
    vector<ll> a;
    m = n;
    for(ll i = 2; i * i <= n; ++i){
        if(n%i != 0) continue;
        ll ex = 1;
        while(n%i == 0){
            n /= i;
            ex *= i;
            a.push_back(ex);
        }
    }
    if(n != 1) a.push_back(n);
    
    sort(a.begin(), a.end());
    ll cnt = 0;
    for(auto i : a){
        if(m < i) break;
        if(m%i != 0) continue;
        m /= i;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
grid = []
for i in range(3):
    c=list(map(int,input().split()))
    grid.append(c)

a1=0
b1=grid[0][0] - a1
b2=grid[0][1] - a1
b3=grid[0][2] - a1
a21=grid[1][0] - b1
a22=grid[1][1] - b2
a23=grid[1][2] - b3
a31=grid[2][0] - b1
a32=grid[2][1] - b2
a33=grid[2][2] - b3
if a21==a22==a23:
    if a31==a32==a33:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <random>
using namespace std;
#define Would
#define you

long long a, b, k[100005], l[100005], m[100005], n[100005], n2[100005], o[100005], o2[100005], ans;
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i + 1] >> l[i + 1];
		m[i + 1] = m[i] + l[i + 1];
		n[i + 1] = max(n[i], m[i + 1] - k[i + 1]);
		n2[i + 1] = max(n2[i], m[i + 1] - 2 * k[i + 1]);
	}
	for (int i = a; i >= 1; --i) {
		o[i] = max(o[i + 1], m[a] - m[i - 1] - b + k[i]);
		o2[i] = max(o2[i + 1], m[a] - m[i - 1] - 2 * b + 2 * k[i]);
	}
	for (int i = 0; i < a + 1; ++i) { ans = max({ ans,n[i] + o2[i + 1] ,n2[i] + o[i + 1] }); }
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int G[100][100] = {0};
queue<int> v;

void adjacent(int u, int k){
    int j;
    for(int i=0; i<k; i++){
        j = v.front(); v.pop();
        G[u-1][j-1] = 1;
    }
}

int main(){
    int n; cin >> n;
    int u, k, num;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int i=0; i<k; i++){
            cin >> num;
            v.push(num); 
        }
        adjacent(u, k);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j != n-1){
                cout << G[i][j] << " ";
            }else{
                cout << G[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
import copy
from collections import deque
n, m, q = list(map(int, input().split()))

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

ans = 0
def dfs(A, low, high, n):
    global ans
    if len(A) >= n:
        result = 0
        for a,b,c,d in abcd:

            if A[b-1]-A[a-1] == c:
                result += d
        ans = max(ans, result)
        return

    for i in range(low, high+1):
        A.append(i)
        dfs(A, i, high, n)
        A.pop()

dfs([], 1, m, n)
print(ans)


Measured memory_bytes: 9596