akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define rep(i,n) for(ll i=0;i < n;i++)
#define sz(x) x.size()
#define accuracy ll precision = numeric_limits<double>::digits10
#define fast_io ios_base::sync_with_stdio(false)
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define fir first
#define sec second

ll a,b;

int main() {
	fast_io;
	accuracy;
	cin >> a >> b;
	if(a*b <= 0) cout << "Zero\n";
	else {
		if(a > 0) cout << "Positive\n";
		else {
			if((b-a+1) % 2 != 0) cout << "Negative\n";
			else cout << "Positive\n";
		}
	}	
}

Measured memory_bytes: 256
W, H, x, y, r = (int(i) for i in input().split())
judge = True
while judge == True:
    if x-r < 0 or y-r < 0:
        print("No")
        judge = False
        break
    if x+r >W or y+r >H:
        print("No")
        judge = False
        break
    print("Yes")
    judge = False



Measured memory_bytes: 5604
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

Measured memory_bytes: 40812
n,q=map(int,input().split())
remains=n

name=[]
time=[]

for i in range(n):
    a=input().split()
    name.append(a[0])
    time.append(int(a[1]))


i=0
timer=0

while(1):

    if time[i]<=q:

        timer+=time[i]
        x=name.pop(i)
        time.pop(i)
        remains-=1
        print(x,timer)
        if remains==0: break
        i=i%remains
    else:
        time[i]-=q
        timer+=q
        i=(i+1)%remains


Measured memory_bytes: 9536
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline
from collections import defaultdict

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())
A = []
B = []

for i in range(N):
    x = int(input())
    A.append(x)
    B.append(x)

B.sort(reverse=True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])


Measured memory_bytes: 14640
#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<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    cout << s.size() << endl;
    return 0;
}

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

int a[100000], b[100000];
int main() {
  int an, bn, m;
  cin >> an >> bn >> m;
  int mina = INT_MAX, minb = INT_MAX;
  for (int i = 0; i < an; i++) {
    cin >> a[i];
    if (a[i] < mina)mina = a[i];
  }
  for (int i = 0; i < bn; i++) {
    cin >> b[i];
    if (b[i] < minb)minb = b[i];
  }
  int minv = mina + minb;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    if (a[x - 1] + b[y - 1] - c < minv)
      minv = a[x - 1] + b[y - 1] - c;
  }
  cout << minv << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
 
 
int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    vector<vector<int> > g(N);
    for (int i = 0; i < M; i++) {
        int p, q;
        cin >> p >> q;
        p--,q--;
        g[p].push_back(q);
        g[q].push_back(p);
    }
    vector<int> visited(N, 0);
    int depth = 0;
    function<void (int, int)> dfs = [&](int i, int parent) {
        if (!visited[i]) {
            visited[i] = 1;
            depth++;
            //cout << depth << endl;
        }
        for(int j : g[i]) if(j != parent && !visited[j]){
            dfs(j, i);
        }
    };
    int max_value = 0;
    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            dfs(i, -1);
            max_value = max(max_value, depth);
            depth = 0;
        }
        
    }
    
    cout << max_value << endl;
    
    return 0;
    
}


Measured memory_bytes: 30508
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 1e9 + 7;

int n;

LL a[N];

void solve() {

    scanf("%d", &n);

    rep(i, 1, n) scanf("%lld", &a[i]);

    LL s = a[1];

    LL ans = 0;

    rep(i, 2, n) {

        ans = (ans + a[i] * s % mod) % mod;

        s = (s + a[i]) % mod;

    }

    printf("%lld\n", ans);

}


int main() {

//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 5320
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int k , sz=9, l=0 , r=8;
ll arr[mx5] = {1,2,3,4,5,6,7,8,9};
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>k;
		while(1) {
			
			if(sz >= k) {
				cout << arr[k-1];
				break;
			}
			
			int tmp = arr[l]%10;
			if( tmp == 0 ) {
				arr[sz++] = arr[l]*10 + tmp;
				arr[sz++] = arr[l]*10 + tmp+1;
			}else if ( tmp < 9 ){
				arr[sz++] = arr[l]*10 + tmp-1;
				arr[sz++] = arr[l]*10 + tmp;
				arr[sz++] = arr[l]*10 + tmp+1;
			}else {
				arr[sz++] = arr[l]*10 + tmp-1;
				arr[sz++] = arr[l]*10 + tmp;
			}
			
			l++;
			if(l > r) {
				r = sz-1;
			}
		}
		
	}
	return 0;
}


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

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

int main(){
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const ll MOD = 1000000000+7;

ll factorial(ll x) {
    static array<ll, 100000> memo = {};
    if(memo[x] > 0) return memo[x];
    ll res = 1;
    repeat(i, 1, x + 1) {
        res = (res * i) % MOD;
    }
    return memo[x] = res;
}

int main() {
    ll N; cin >> N;    
    vector<ll> A(N), B(N); cin >> A >> B;
    sort(all(A));
    sort(all(B));

    auto solve = [&] {
        ll ans = 1;
        ll sum = 0;
        rep(i, N) {
            int target = B[i];
            sum += abs(A[i] - B[i]);
            int overlap_num = 1;
            if(target < A[i]) {
                overlap_num = i - (lower_bound(all(A), target) - begin(A));                
            } else if(target > A[i]) {
                overlap_num = i - (lower_bound(all(B), A[i]) - begin(B));                
            } else assert(0);
            // cerr << A[i] << " -> " << B[i] << " : " << overlap_num << endl;
            ans = (ans * (overlap_num + 1)) % MOD;
        }
        return make_pair(ans, sum);
    };

    auto a = solve();
    rep(i, N) {
        A[i] = MOD - A[i];
        B[i] = MOD - B[i];
    }
    sort(all(A));
    sort(all(B));
    auto b = solve();
    debug(a);
    debug(b);
    ll ans = 0;
    ans = a.second < b.second ? a.first : b.first;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>

//auto print = [](auto x){ std::cout << x; };
auto println = [](auto x){ std::cout << x << std::endl; };
auto read = [](auto &x){ std::cin >> x; };

void print(std::string, int a, int b);
std::string reverse(std::string, int a, int b);
std::string replace(std::string, int a, int b, std::string);

int main ()
{
  std::string str, command, str_rep;
  int q, a, b;

  read(str);
  read(q);

  for (int i=0; i<q; i++)
    {
      read(command);
      if (command == "print")
        {
          read(a);
          read(b);
          print(str, a, b);
        }
      else if (command == "reverse")
        {
          read(a);
          read(b);
          str = reverse(str, a, b);
        }
      else if (command == "replace")
        {
          read(a);
          read(b);
          read(str_rep);
          str = replace(str, a, b, str_rep);
        }
      else
        println("No Command!");
    }

}

void print(std::string str, int a, int b)
{
  std::for_each(str.begin()+a, str.begin()+b+1, [](auto c){std::cout << c;});
  std::cout << std::endl;
}

std::string reverse(std::string str, int a, int b)
{
  for (int i=0; i<(b-a+1)/2; i++)
    {
      auto temp = str.at(a+i);
      str.at(a+i) = str.at(b-i);
      str.at(b-i) = temp;
    }
  return str;
}

std::string replace(std::string str, int a, int b, std::string str_rep)
{
  for (int i=0; i<(b-a+1); i++)
    {
      str.at(a+i) = str_rep.at(i);
    }
  return str;
}



Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e,f;
 
    std::vector< std::pair< int64_t, int64_t > > list;
    std::cin>> a;
    std::cin>> b;
    std::cin>> c;
 
    d = 0;
    e = 0;
 
    if( b != 0 )
    {
        if( a <= b )
        {
            d = a;
        }
        else
        {
            e = a / ( b + c );
            d += e * b;
            f = a - e * ( b + c );
 
            if( f <= b )
            {                
                d += f;
            }
            else
            {
                d += b;
            }
        }
    }
 
    std::cout<< d <<"\n";
}


Measured memory_bytes: 256
//author:Deshansh Garg
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

    
int main()
{
 lli N;
 cin>>N;
 lli arr[N];
 for(lli i=0;i<N;i++)
    cin>>arr[i];

  lli a[N]={0};
  for(lli i=1;i<N;i++)
  {
    if(i==1)
    {
        a[i]=abs(arr[1]-arr[0]);
    }
    else
    {
        a[i]=min(a[i-1]+abs(arr[i]-arr[i-1]),a[i-2]+abs(arr[i]-arr[i-2]));
    }
  } 
  cout<<a[N-1]<<endl;
 return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)	
		{
			int r=in.nextInt(),c=in.nextInt();
			if((r|c)==0)
				return;
			System.out.println( r*c%2==0 ? "yes":"no");
		}
	}
}

Measured memory_bytes: 12000
s=input()
p=input()
c=0
if len(s)<len(p):
    print("UNRESTORABLE")
else:
    for i in range(len(s)-len(p),-1,-1):
        if c!=0:
            break
        d=s[i:i+len(p)]
        for j in range(len(p)):
            if d[j]!="?":
                if d[j]!=p[j]:
                    break
        else:
            s=s[:i]+p+s[i+len(p):]
            c=1
    if c!=1:
        print("UNRESTORABLE")
    else:
        for i in range(len(s)):
            if s[i]=="?":
                s=s[:i]+"a"+s[i+1:]
        print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=60;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,a[N],b[N],p[N];
LL ans,to[N];
inline bool check()
{
	For(i,0,50)
	{
		to[i]=1ll<<i;
		For(j,0,50)if(p[j])to[i]|=to[i%j];
	}
	For(i,1,n)if(!((to[a[i]]>>b[i])&1))return 0;
	return 1;
}
int main()
{
	file();
	read(n);
	For(i,1,n)read(a[i]);
	For(i,1,n)read(b[i]);
	For(i,1,50)p[i]=1;
	if(!check()){puts("-1");return 0;}
	rFor(i,50,1)
	{
		p[i]=0;
		if(!check())p[i]=1;
	}
	For(i,0,50)if(p[i])ans|=(1ll<<(1ll*i));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
# 16:07
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

bonus = 0
for i in range(1,n):
    if a[i]-a[i-1] == 1:
        bonus += c[a[i-1]-1]

print(sum(b) + bonus)



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
  int a, b, c, k = 0;
  cin >> a >> b >> c;
  for(int i = 0; i < b; i++)
  {
    if((a + a * i) % b == c)
      k++;
  }
  if(k == 0)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}

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

int main(void) {
	string T, P;
	getline(cin, T);
	getline(cin, P);
	int len1 = T.length(), len2 = P.length();
	for (int i = 0; i < len1 - len2 + 1; i++) {
		bool flag = true;
		for (int j = 0, k = i; flag && j < len2; j++, k++) {
			if (T[k] == P[j])
				continue;
			flag = false;
		}
		if (flag)
			cout << i << endl;
	}
}


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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

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

    int l,r,d;
    cin>>l>>r>>d;

    int ans = 0;

    for(int i =l; i<=r; i++)
        if(i%d == 0)
            ans++;
    
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3636
function Main(s){
  s = s.split("\n");
  var n = s[0].split(" ").map(a=>+a);
  var m = n[1], q = n[2]; n = n[0];
  var a = Array(n+1).fill(0).map(a=>[]);
  for(var i = 0; i < m; i++){
    var l = s[i+1].split(" ").map(a=>+a);
    a[l[0]].push(l[1])
  }
  for(i = 1; i <= n; i++)a[i].sort((a,b)=>a-b);
  var ans = [];
  for(i = 0; i < q; i++){
    var p = s[i+m+1].split(" ").map(a=>+a);
    var t = 0;
    for(j = p[0]; j <= p[1]; j++){
      t += upper_bound(a[j], 0, a[j].length, p[1])
    }
    ans[i] = t;
  }
  console.log(ans.join("\n"));
}
function upper_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<=e?a=c:b=c;return d[a]<=e?b:a};
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    bool r;
    if (a + b >= c) {
        r = false;
    } else {
        r = (4*a*b < (c-a-b)*(c-a-b));
    }
    cout << (r ? "Yes" : "No") << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int trie[1000006][26], cnt[1000006], c;
typedef pair<int, string>pi;
vector<pi>vec;
int freq[26];
int add(int x)
{
    memset(freq, 0, sizeof freq);
    string str= vec[x].second;
    for(int i=0; i<str.size(); i++)freq[ str[i]-'a' ]++;
    int now= 0, ret= 0;
    for(int i=str.size()-1; i>=0; i--)
    {
        for(int j=0; j<26; j++)
        if(freq[j] && trie[now][j]!=-1)ret+= cnt[ trie[now][j] ];
        if(trie[now][ str[i]-'a' ]==-1)
        {
            trie[now][ str[i]-'a' ]= ++c;
            for(int j=0; j<26; j++)trie[c][j]= -1;
        }
        now= trie[now][ str[i]-'a' ];
        freq[ str[i]-'a' ]--;
    }
    cnt[now]++;
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i=0; i<26; i++)trie[0][i]= -1;
    int n;
    cin>>n;
    string str;
    for(int i=0; i<n; i++)
    {
        cin>>str;
        vec.push_back({ str.size(), str });
    }
    sort(vec.begin(), vec.end());
    ll res= 0;
    for(int i=0; i<n; i++)res+= add(i);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 109128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	bool ans = true;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - i - 1]) ans = false;
	}
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[(n - 1) / 2 - i - 1]) ans = false;
	}
	for (int i = (n + 1) / 2; i < n; i++) {
		if (s[i] != s[(n + 1) / 2 + n - i - 1]) ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}

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

int main(){
    long long a,b;
    cin>>a>>b;
    string ans;
    if(a>0){
        ans="Positive";
    }
    else if(a<=0 && b>0){
        ans="Zero";
    }
    else if((a+b)%2==0){
        ans="Negative";
    }
    else ans="Positive";

    cout<<ans;
        

}

Measured memory_bytes: 256
function Main(input: string) {
  const lines: string[] = input.split('\n');

  const n = parseInt(lines[0]);
  const p = lines[1].split(' ').map(x => parseInt(x));
  const q = lines[2].split(' ').map(x => parseInt(x));

  const d = Math.abs(order(p) - order(q));

  console.log(d);
}

function order(p: number[]): number {
  const n = p.length;
  let result = 0;
  const set = new Set();
  for (let i = 0; i < n; i++) {
    const m = interval(1, p[i] - 1).filter(x => !set.has(x)).length;
    result += m * factorial(n - (i + 1));
    set.add(p[i]);
  }
  return result;
}

function interval(start: number, end: number): number[] {
  if (start > end) {
    return []
  } else {
    let tmp = [];
    for (let i = start; i <= end; i++) {
      tmp.push(i);
    }
    return tmp
  }
}

function factorial(n: number): number {
  let tmp = 1;
  for (let i = 2; i <= n; i++) {
    tmp *= i;
  }
  return tmp;
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1){
    }

    int root(int x){
        if(par[x] < 0){
            return x;
        }
        int r = root(par[x]);
        par[x] = r;
        return r;
    }

    bool same(int a, int b){
        return root(a) == root(b);
    }

    void unite(int a, int b){
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) return;

        if(par[ra] < par[rb]){
            swap(ra, rb);
        }
        par[ra] += par[rb];
        par[rb] = ra;
    }

    int size(int x){
        return -par[root(x)];
    }
};

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

    UnionFind uf(n);

    rep(i,q){
        int c, x, y;
        cin >> c >> x >> y;

        if(c==0){
            uf.unite(x, y);
        }else{
            cout << uf.same(x, y) << endl;
        }
    }
}



Measured memory_bytes: 3184
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//約数列挙
vector<long long> enum_divisors(long long N, ll mx) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0 && i <= mx) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i && N/i <= mx) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end(), greater<ll>());
    return res;
}

int main(){ 
    int n; ll m; cin >> n >> m;
    ll mx = m / n;
    vector<ll> yakusu = enum_divisors(m, mx);
    cout << yakusu[0] << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int K,S,R=0;
	cin >> K >> S;
	for(int i=0; i<=K; i++){
		for(int j=0; j<=K; j++){
			if(S-i-j >= 0 && S-i-j <=K){
				R++;
			}
		}
	}
	cout << R << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> ans;
  if (n % 2) {
    for (int l = 1, r = n - 1; l < r; l++, r--) {
      ans.emplace_back(l, r);
    }
  } else {
    bool flag = false;
    for (int l = 1, r = n - 1; l < r; l++, r--) {
      if (!flag && r - l <= n / 2) {
        --r;
        flag = true;
      }
      ans.emplace_back(l, r);
    }
  }
  rep(i, m) cout << ans[i].first << " " << ans[i].second << endl;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define IO() assert(freopen("in.in", "rt", stdin)),assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl

typedef long long ll;
const ll MOD=1e9+7;
const int N = 1e7+9, M = 1e5+9, OO = 0x3f3f3f3f;
const double EPS = 1e-10;

// inline int readi(){int n;scanf("%d", &n);return n;}
// inline ll readll(){ll n;scanf("%lld", &n);return n;}
// inline char readc(){char c;scanf("%c ", &c);return c;}
// inline double readd(){double n;scanf("%lf", &n);return n;}
inline bool dCMP(const long double& a, const long double& b){return fabsl(a-b)<EPS;}
int arr[N];
int main()
{
	#ifdef _LOCAL_DEFINE
	IO();
	#endif
	ll a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll ans=0;
	ans+=(b/c - (a-1)/c);
	ans+=(b/d - (a-1)/d);
	ll lcm=(c*d)/__gcd(c,d);
	ans-=(b/lcm - (a-1)/lcm);
	printf("%lld",(b-a+1)-ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main(){
    int H,W;
    char a[100][101];
    cin >> H >> W;
    for(int i=0;i<H;i++)    cin >> a[i];
    for(int i=0;i<W+2;i++){
        cout << '#';
    }
    cout << '\n';
    for(int i=0;i<H;i++){
        cout << '#' << a[i] << "#\n";
    }
    for(int i=0;i<W+2;i++){
        cout << '#';
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
x=int(input())
a=0
while True:
    g=a**5
    c=g-x
    b=(abs(c))**(0.2)
    b=round(b)
    if abs(c)-b**5==0:
        b=round(b)
        if c<0:
            b=-b
        break
    a+=1
print(a, b)

Measured memory_bytes: 9444
###
### atcorder test program
###

import sys

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Prime number search
    def Pnum(self, a):
        if a == 1: return False
        for i in range(2,int(a**0.5)+1):
            if a % i == 0:
                return False
        return True

    ### Circle area
    def caria(self, r):
        return r*r*self.pi

math = math()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

A, B, C = [int(x) for x in input().split()]

if B-A == C-B:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <deque>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
typedef pair<int,int> P;//depth,now
class Edge
{
	public:
	int cost;
	int from;
	int to;

	Edge(int n,int c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,int c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[100000];
ll used[100000];
deque<P> q;

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(Edge(b,1));
		g[b].push_back(Edge(a,1));
	}
	fill(used,used+100000,-1e14+1);
	used[0]=k;//init
	q.push_back(P(0,0));
	while(!q.empty())
	{
		P p=q[0];
		q.pop_front();
		int now=p.second;
		int nowk=max(k-p.first-1,k-2);
		for(int i=0;i<g[now].size();i++)
		{
			Edge e=g[now][i];
			if(used[e.to]==-1e14+1)
			{
				used[e.to]=nowk;
				q.push_back(P(p.first+1,e.to));
				nowk--;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(used[i]<0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		ans*=used[i];
		ans%=MOD;
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8500
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N, M;
  cin>>N>>M;
  vector<pair<pint, int > > data(M);
  vector<string> ans(M);
  REP(i,M) {
    int p, y; cin>>p>>y;
    data[i] = make_pair(make_pair(p, y), i);
  }
  sort(data.begin(), data.end());
  int num = 0;
  REP(i,M) {
    if(i == 0 || data[i].first.first != data[i-1].first.first) {
      num = 1;
    } else {
      num++;
    }
    static char id[100];
    sprintf(id, "%06d%06d", data[i].first.first, num);
    ans[data[i].second] = string(id);
  }
  REP(i,M) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
const int inf = 0x3f3f3f3f;
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
int t;
int n,m;
struct node{
	int v,w;
};
struct O{
	int a,b;
	bool operator<(const O &x)const
	{
		return a>x.a;
	}
};
vector<node>G[maxn];
int dis[maxn];
bool vis[maxn];
void Dj(int s)
{
	dis[s] = 0;
	priority_queue<O>q; q.push({0,s});
	while(!q.empty())
	{
		O p = q.top(); q.pop();
		int u = p.b;
		if(vis[u]) continue;
		vis[u] = 1;
		for(node it:G[u])
		{
			int v =it.v,w = it.w; 
			if(dis[u]+w<dis[v] && !vis[v])
			{
				dis[v] = dis[u]+w;
				q.push({dis[v],v});
			}
		}
	 } 
}
int main()
{
//	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		G[i].push_back({(i+1)%n,1});
		G[i].push_back({(i*10)%n,0});
	 }
	for(int i=0;i<=n;++i) dis[i] = inf;
	Dj(1);  
	printf("%d\n",dis[0]+1);
}


Measured memory_bytes: 9212
#!/usr/bin/env python3

import sys
import os


def main():
    n = int(sys.stdin.readline().strip())
    nstr = sys.stdin.readline().strip()

    ns = []
    i = 0
    for c in range(0, n):
        iend = nstr.find(" ", i)
        if iend < 0:
            iend = len(nstr)
        ns.append(int(nstr[i:iend]))
        i = iend + 1

    ns.sort()

    for i in range(0, n - 1):
        if ns[i] == ns[i + 1]:
            print("NO")
            return

    print("YES")

if __name__ == '__main__':
    main()

Measured memory_bytes: 13524
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int a, b, c, t, i, j;

    a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt();
    for(t = 0;t <= 3600;t += a + b){
      for(i = 0;i < 60;i++){
        if(t <= c + 60 * i && c + 60 * i <= t + a){
          out.println(c + 60 * i); break;
        }
      }
      if(i < 60)break;
    }
    if(t > 3600)out.println("-1");

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

Measured memory_bytes: 17356
import java.util.*;

public class Main {
    static int n;
    static int m;
    static int q;
    static int[] a;
    static int[] b;
    static int[] c;
    static int[] d;
    static List<Integer> ansList = new ArrayList<>();

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();
        a = new int[q];
        b = new int[q];
        c = new int[q];
        d = new int[q];
        for(int i = 0; i < q; i++) {
            int[] abcd = new int[4];
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        ArrayList<Integer> A = new ArrayList<>();
        A.add(1);
        dfs(A);
        System.out.println(Collections.max(ansList));
    }

    private static void dfs(ArrayList<Integer> A) {
        if (A.size() == n + 1) {
            int now = 0;
            for(int i = 0; i < q; i++) {
                if (A.get(b[i]) - A.get(a[i]) == c[i]) {
                    now += d[i];
                }
            }
            ansList.add(now);
            return;
        }
        A.add(A.get(A.size() - 1));
        while (A.get(A.size() - 1) <= m) {
            dfs((ArrayList<Integer>)A.clone());
            A.set(A.size() - 1, A.get(A.size() - 1) + 1);
        }
    }

}

Measured memory_bytes: 59476
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

const int MAX = 110000;
int K;
long long A[MAX];

long long calcMin(long long p, long long a) {
  long long q = p % a;
  if (q == 0) return p;
  else return p + (a - q);
}

long long calcMax(long long p, long long a) {
  long long q = p % a;
  return p - q;
}

int main() {
  while (cin >> K) {
	for (int i = 0; i < K; ++i) {
	  cin >> A[K - i - 1];
	}
	long long Min = 2, Max = 2;

	if (A[0] != 2) {
	  cout << -1 << endl;
	  return 0;
	}
	
	for (int i = 1; i < K; ++i) {
	  long long aMin = calcMin(Min, A[i]);
	  long long aMax = calcMax(Max + A[i-1] - 1, A[i]);

	  //cout << A[i] << ", " << aMin << ", " << aMax << endl;
	  
	  if (aMin >= Max + A[i-1]) {
		cout << -1 << endl;
		return 0;
	  }
	  if (aMax < Min) {
		cout << -1 << endl;
		return 0;
	  }
	  Min = aMin;
	  Max = aMax;
	}

	cout << Min << " " << Max + A[K-1] - 1 << endl;
  }
}




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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define pie 3.14159265358
#define mod2 998244353

 // lcm+min(a,b)
void solve(){   
    string s;
    cin>>s;
    if(s[1]=='R')cout<<"ABC";
    else cout<<"ARC";
    return;
} 

signed main(){
    IOS;

    int n=1; 
     // cin>>n; 
    rep(i,0,n)solve();
    
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s,t;
  cin>>s>>t;
  int m=0,n=s.size();
  for(int i=0;i<n;i++){
    //cout<<s[i]<<":"<<t[i];
    if (s[i]!=t[i])
    {m++;}
    
  }
  cout<<m<<endl;
}

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

void fnInput(vector<int> &rvnElm, vector<int> &rvnTrg )
{
  int nElmCnt, nTrgCnt;
  cin >> nElmCnt;

  rvnElm.resize(nElmCnt);
  for (int i = 0; i < nElmCnt; i++)
    cin >> rvnElm[i];

  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];
}

void fnDPtblMake(vector<vector<int>> &rvvnDP, const vector<int> &cnrvnElm, int nMaxTrg)
{
  rvvnDP[cnrvnElm.size()][0] = 1;
  for (int j = 1; j <= nMaxTrg; j++)
    rvvnDP[cnrvnElm.size()][j] = 0;

  for (int i = cnrvnElm.size() - 1; i >= 0; i--)
    for (int j = 0; j <= nMaxTrg; j++)
      if (j < cnrvnElm[i])
        rvvnDP[i][j] = rvvnDP[i + 1][j];
      else
        rvvnDP[i][j] = rvvnDP[i + 1][j] || rvvnDP[i + 1][j - cnrvnElm[i]];

}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));

  int nMaxTrg = cnrvnTrg[0]; 
  for (int i = 1; i < cnrvnTrg.size(); i++)
    nMaxTrg = max(nMaxTrg, cnrvnTrg[i]);

  fnDPtblMake(vvnDP, cnrvnElm, nMaxTrg);

  for (int i = 0; i < cnrvnTrg.size(); i++)
    if (vvnDP[0][cnrvnTrg[i]])
      cout << "yes" << endl;
    else
      cout << "no" << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnElm, vnTrg;

  fnInput(vnElm, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

int main(){
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    long long int ans, i;
    if(s1[0] == s2[0]){
        ans = 3;
        i = 1;
    }
    if(s1[0] != s2[0]){
        ans = 3 * 2;
        i = 2;
    }

    while(i < n){
        if(s1[i-1] == s2[i-1]){
            ans *= 2;
            if(s1[i] == s2[i]) i += 1;
            else i += 2;
        }
        else if(s1[i-1] != s2[i-1]){
            if(s1[i] == s2[i]) i += 1;
            else{
                ans *= 3;
                i += 2;
            }
        }

        if(ans >= MOD) ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int> d(100001);
  d.at(0)=1;
  for(int n=100;n<106;n++){d.at(n)=1;}
  for(int n=106;n<100001;n++){
  if(d.at(n-100)==1||d.at(n-101)==1||d.at(n-102)==1
     ||d.at(n-103)==1||d.at(n-104)==1||d.at(n-105)==1){d.at(n)=1;}}
  int x;
  cin>>x;
  cout<<d.at(x)<<endl;
}


Measured memory_bytes: 768
#include <stdio.h>

double ABS(double a){
	return a >= 0 ? a : -a;
}

int main(){
	int N, i, ans;
	double T, A, H, min = 1e18;
	scanf("%d", &N);
	scanf("%lf%lf", &T, &A);
	for(i = 0; i < N; i++){
		scanf("%lf", &H);
		if(min > ABS(T - H * 0.006 - A)){
			min = ABS(T - H * 0.006 - A);
			ans = i;
		}
	}
	printf("%d\n", ans + 1);
	return 0;
}

Measured memory_bytes: 128
#define mod 998244353
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=5E5+5;
const int limit=500000;
int n,k;
ll fac[maxn],inv[maxn];
inline ll C(int x,int y)
{
	if(x<y||x<0||y<0)
		return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline ll qpow(ll x,ll y)
{
	ll ans=1,base=x;
	while(y)
	{
		if(y&1)
			ans=ans*base%mod;
		base=base*base%mod;
		y>>=1;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	fac[0]=1;
	for(int i=1;i<=limit;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[limit]=qpow(fac[limit],mod-2);
	for(int i=limit-1;i>=0;--i)
		inv[i]=inv[i+1]*(i+1)%mod;
	ll ans=0;
	cin>>n>>k;
	for(int i=n;i<=k;++i)
		ans=(ans+C(k-1,i-1))%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11460
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

int main(){
    ll a,b,n;
    cin >> a >> b >>n;
    ll r=min(b-1,n);
    kaku(a*r/b);
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;
typedef pair<long long ,long long  > Edge;
Edge G[53];

int main() {
	long long  N, K;
	cin >> N >> K;

	long long  X[53], Y[53];
	long long  x, y;
	for (int i = 0; i < N; i++) {
		cin >> x >> y;
		G[i].first = x;
		G[i].second = y;
		X[i] = x;
		Y[i] = y;
	}

	

	sort(X, X + N);
	sort(Y, Y + N);
	long long  Q = 5000000000000000000;
	for (int i =0 ; i < N; i++) {
		for (int k = i+1; k < N; k++) {
			for (int m = 0; m < N; m++) {
				for (int n = m+1; n < N; n++) {
					int W = 0;
					for (int r = 0; r < N; r++) {
						if (X[i] <= G[r].first&&G[r].first <= X[k] && Y[m] <= G[r].second&&G[r].second <= Y[n]) {
							W++;
						}
					}
					if (W >= K) {
						long long  f = (X[k] - X[i])*(Y[n] - Y[m]);
							
						
						if (f < Q)Q = f;
					
					}
				
				}
			}
		}
	}

	cout << Q << endl;
	
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		int sanjo = 1;
		for (int i = 0; i<3; i++) {
			
			sanjo = sanjo * num;
			
		}
		
		
		
		
		System.out.println(sanjo);
	}

}


Measured memory_bytes: 26076
fn main(){
    let n :f64 = input().parse::<f64>().unwrap();
    println!("{}", ceil(n / 2.0) / n);
}

fn ceil(n :f64) -> f64{
    let m = n as i32 as f64;
    if n - m != 0.0 {
        m + 1.0
    }else{
        m
    }
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}


Measured memory_bytes: 4352
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll arr[1005][3];

vector<ll> v;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n, m;

    cin>>n>>m;

    for(int i = 1; i <= n; i++){
    	for(int j = 0; j < 3; j++){
    		cin>>arr[i][j];
    	}
    }

    ll res = 0;
    for(int k = 0; k < 8; k++){
    	v.clear();
    	for(int i = 1; i <= n; i++){
    		ll temp = 0;
    		for(int j = 0; j < 3; j++){
    			if((k / (1 << j)) % 2 == 0)
    				temp += arr[i][j];
    			else
    				temp -= arr[i][j];
    		}
    		v.pb(temp);
    	}
    	sort(v.begin(), v.end());
    	reverse(v.begin(), v.end());
    	ll sum = 0;
    	for(int i = 0; i < m; i++){
    		sum += v[i];
    	}
    	res = max(res, sum);
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]
for i in range(n):
    c = []
    for j in range(m):
        c.append(a[i][j] * b[j])
    print(sum(c))



Measured memory_bytes: 6020
i3=lambda : map(int,input().split())

N,K=i3()
*D,=i3()

D=set(D)

for i in range(N,10**5):
    ans=1
    for s in str(i):
        if int(s) in D:
            ans=0
            break
    if ans : break
print(i)

Measured memory_bytes: 8928
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
const int mod = 998244353 ;
const int inf = 1e9 + 5;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 1e5 + 5 ;
int n,wt ;
ll dp[101][maxn] ;
int v[123], w[123] ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n >> wt ;
    rep(i,0,n-1)
    cin >> w[i] >> v[i] ;
    rep(i,0,n-1)
    rep(j,0,maxn-1)
    dp[i][j] = inf ;
    dp[0][0] = 0 ;
    dp[0][v[0]] = w[0] ;
    rep(i,1,n-1)
    {
        rep(j,0,maxn-1)
        {
            if(j-v[i] >= 0)
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]) ;
            else dp[i][j] = dp[i-1][j] ;
        }
    }
    int res = -63 ;
    rep(i,0,maxn-1) if(dp[n-1][i] <= wt) res = i ;
     cout << res << "\n" ;
    return 0 ;
}


Measured memory_bytes: 78336
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;


int main(){
    ll N,M;cin>>N>>M;
    ll a,d[100010];
    vector<pair<ll,ll> > bc;
    rep(i,0,N){
        cin>>a;
        bc.push_back(make_pair(a,1));
    }
    rep(i,0,M){
        ll b,c;cin>>b>>c;
        bc.push_back(make_pair(c,b));
    }
    sort(bc.begin(),bc.end(),greater<>());
    ll cn=0,ite=0;
    while(N>0){
        cn+=bc.at(ite).first*min(N,bc.at(ite).second);
        N-=bc.at(ite).second;
        ite++;
    }

    cout<<cn<<endl;
}







Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
    int t;
    cin >> t;
    cout << t + pow(t, 2) + pow(t, 3) << endl;
    return 0;
}


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

typedef unsigned long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define All(i, c) for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 202;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
	int n, m; cin >> n; m = n/2;
	int a[n], b[m], c[m];
	Rep(i, n){
		cin >> a[i];
		if(i % 2 == 0) b[i/2] = a[i];
		else c[i/2] = a[i];
	}
	sort(b, b+m); sort(c, c+m);
	vector<P> v_b;
	vector<P> v_c;
	int t = 0, index = 0;
	Rep(i, m){
		if(t == 0){
			t = b[i];
		}else{
			if(t != b[i]){
				v_b.pb(P(i-index, t));
				index = i;
				t = b[i];
			}
			if(i == m-1){
				v_b.pb(P(i-index+1, t));
			}
		}
	}
	t = 0; index = 0;
	Rep(i, m){
		if(t == 0){
			t = c[i];
		}else{
			if(t != c[i]){
				v_c.pb(P(i-index, t));
				index = i;
				t = c[i];
			}
			if(i == m-1){
				v_c.pb(P(i-index+1, t));
			}
		}
	}
	sort(v_b.begin(), v_b.end(), greater<P>());
	sort(v_c.begin(), v_c.end(), greater<P>());
	if((int)v_b.size() == 1){
		if((int)v_c.size() == 1){
			if(v_b[0].second == v_c[0].second){
				cout << m << endl;
			}else{
				cout << 0 << endl;
			}
		}else{
			if(v_b[0].second == v_c[0].second){
				cout << m - v_c[1].first << endl;
			}else{
				cout << m - v_c[0].first << endl;
			}
		}
	}else{
		if((int)v_c.size() == 1){
			if(v_b[0].second == v_c[0].second){
				cout << m - v_b[1].first << endl;
			}else{
				cout << m - v_b[0].first << endl;
			}
		}else{
			if(v_b[0].second == v_c[0].second){
				cout << min(n - v_b[0].first - v_c[1].first, n - v_b[1].first - v_c[0].first) << endl;
			}else{
				cout << n - v_b[0].first - v_c[0].first << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2168