akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        StringBuffer sb = new StringBuffer();
        
        while(true)
        {
            String[] strAry = (br.readLine()).split(" ");
            int h = Integer.parseInt(strAry[0]);
            int w = Integer.parseInt(strAry[1]);
        
            if(0 == h & 0 == w)
            {
                break;
            }

            for(int i = 0; i < h; i++)
            {
                sb.append("#");
                for(int j = 0; j < (w - 2); j++)
                {
                    if(0 == i || (h - 1) == i )
                    {
                        sb.append("#");
                    }
                    else
                    {
                        sb.append(".");
                    }
                }
                sb.append("#").append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25316
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 998244353;
const int N = 4e5 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
}

int C(int n, int k) {
	return divv(f[n], mul(f[k], f[n - k]));
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	init();

	int n, m, k;
	cin >> n >> m >> k;
	int ans = 0;
	for (int t = 0; t <= k; t++) {
		int cnt = C(n - 1, t);
		int all = mul(m, binpow(m - 1, n - 1 - t));
		ans = add(ans, mul(all, cnt));
	}
	cout << ans << endl;
}


Measured memory_bytes: 6352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,t,ans=0,p; cin>>n>>t;
    rep(i,n){
        int T; cin>>T;
        if(i==0) p=T;
        if(p>=T) ans+=T+t-p;
        else ans+=t;
        p=T+t;
    }
    cout<<ans<<endl;
}

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

bool card[4][14];
string suit = "SHCD";

int main() {
    memset(card, false, sizeof card);
    int n;
    cin >> n;
    char c; int num;
    for (int i=0; i<n; ++i) {
        cin >> c >> num;
        if (c == 'S') {
            card[0][num] = true;
        } else if (c == 'H') {
            card[1][num] = true;
        } else if (c == 'C') {
            card[2][num] = true;
        } else if (c == 'D') {
            card[3][num] = true;
        }
    }
    for (int i=0; i<4; ++i) {
        for (int j=1; j<=13; ++j) {
            if ( ! card[i][j]) {
                cout << suit[i] << " " << j << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1208
<?php
fgets(STDIN);
$txt = rtrim(fgets(STDIN));
$guusuu = [];
$txt = explode(" ", $txt);
foreach($txt as $t){
    if($t % 2 == 0){
       $guusuu[] = $t;
    }
}
$c = 0;
foreach($guusuu as $g){
    if($g % 3 == 0 || $g % 5 == 0){
        $c++;
    }
}
if(count($guusuu) == $c)
       echo "APPROVED";
 else 
    echo "DENIED";

Measured memory_bytes: 3828
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N,M;cin>>N>>M;vector<int>c(M);for(int i=0;i<M;i++){int k;cin>>k;for(int j=0;j<k;j++){int s;cin>>s;s--;c[i]|=1<<s;}}int p=0;for(int i=0;i<M;i++){int t;cin>>t;p|=t<<i;}int cnt=0;for(int S=0;S<(1<<N);S++){int i=0;for(;i<M;i++){if((__builtin_popcount(c[i]&S)&1)!=((p>>i)&1))break;}if(i==M)cnt++;}cout<<cnt<<endl;}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
double dp[610];
vector<int>g[610];
int X[210000];
int Y[210000];
int n;
double calc(int a,int b){
	if(dp[a]>-0.5)return dp[a];
	if(a==n-1)return dp[a]=0;
	double ret=0;
	int bb=0;
	double wr=0;
	for(int i=0;i<g[a].size();i++){
		double tmp=calc(g[a][i],b);
		
		ret+=tmp+1;
		wr=max(wr,tmp+1);
		bb++;
	}
	if(b==a&&bb>1){
		bb--;
		ret-=wr;
	}
	ret/=bb;
	return dp[a]=ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);n=a;
	for(int i=0;i<b;i++){
		int p,q;
		scanf("%d%d",&p,&q);
		p--;q--;
		X[i]=p;
		Y[i]=q;
		
		g[p].push_back(q);
	}
	double ret=mod;
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			dp[j]=-1;
		}
		ret=min(ret,calc(0,i));
		// printf("%.12f\n",calc(0,i));
	}
	printf("%.12f\n",ret);
}

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

int main() {
	int x1,y1,x0,y0,r;
	cin >> x1 >> y1 >> x0 >> y0 >> r;
	if(x0-r>=0 && y0-r>=0 && x0+r<=x1 && y0+r<=y1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3116
//Author:  Pranta
//Date:    2020-Aug-03
//Problem: C_Repsept
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
const int mxn=1e6+5;
void solve()
{
    int k;
    cin>>k;
    int mainValue=7,cnt=1;
    //after every k iterations cycles of modulo will repeat as (2*k+1)%k=(k+1)%k=1%k. 
    for(int i=0;i<mxn;++i){
        if(mainValue%k==0){
            cout<<cnt;
            return;
        }
        else
        {
            mainValue=((mainValue*10)+7)%(9*k);
        }
        cnt++;
    }
    cout<<-1;
}
int main()
{
    fast;
    int t;
    solve();
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> operand = new Stack<Integer>();
		String input = sc.nextLine();
		sc.close();
		String num = "";
		
		for(int i = 0; i < input.length(); i++) {
			String temp = input.substring(i, i + 1);
			if(temp.contentEquals("+")) {
				int j = operand.pop();
				int k = operand.pop();
				operand.push(k + j);
			}
			else if(temp.contentEquals("-")) {
				int j = operand.pop();
				int k = operand.pop();
				operand.push(k - j);
			}
			else if(temp.contentEquals("*")) {
				int j = operand.pop();
				int k = operand.pop();
				operand.push(k * j);
			}
			else if(temp.trim().length() == 0 && num.length() > 0) {
				operand.push(Integer.parseInt(num));
				num = "";
			}
			else if(temp.trim().length() > 0){
				num = num.concat(temp);
			}
		}
		System.out.println(operand.pop());
	}
}



Measured memory_bytes: 26156
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;

using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
template<typename T>
//templateをつかってみｔか
ll pow(T x, int y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
    if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
    return pow(pow(x, y / 2), 2) % MOD;
}



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

    int n,m;
    cin >> n >> m;
    cout << pow(n,m) << endl;


    return 0;
}




Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int t;
    int ans = 0;
    rep(i,n){
        cin >> t;
        if(a>t || b<=t)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i <= int(n); i++)
#define mod 1000000007

int main()
{
 string a,b;
 cin >> a >> b;
 int s = stoi(a+b);
 for(int i = 0; i <= 100000; i++){
     if(i * i == s){
         cout << "Yes" << endl;
         return 0;
     }
 }
 cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var a = Console.ReadLine().Split().Select(int.Parse).Skip(1).Concat(Console.ReadLine().Split().Select(int.Parse)).OrderBy(x => x).ToArray();
        Console.WriteLine(a.Zip(a.Skip(1), (x, y) => y - x).Aggregate(GCD));
    }

    static int GCD(int a, int b)
    {
        while (true)
        {
            if (a > b)
            {
                if (b == 0) return a;
                a %= b;
            }
            else
            {
                if (a == 0) return b;
                b %= a;
            }
        }
    }
}


Measured memory_bytes: 23776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 2*1e5+5;
int N,M;
int L[MAX],R[MAX];

int main() {
	cin >> N >> M;
	set<int> st;
	map<int,int> mp;
	for(int i=0;i<N;i++)
	{
		cin >> L[i] >> R[i];
		st.insert(L[i]);
		st.insert(R[i]);
	}
	int cnt = 0;
	for(auto itr=st.begin();itr!=st.end();itr++)
	{
		mp[*itr] = cnt++;
	}
	vector<ll> imos(st.size()+5,0);
	for(int i=0;i<N;i++)
	{
		imos[mp[L[i]]]++;
		imos[mp[R[i]]+1]--;
	}
	for(int i=0;i<st.size()+1;i++)
	{
		imos[i+1] = imos[i+1] + imos[i];
	}
	ll mx = 0;
	int restR = -1, restL = M+5;
	for(int i=0;i<st.size()+1;i++)
	{
		if(mx < imos[i])
			mx = imos[i];
	}
	for(int i=0;i<N;i++)
	{
		if(imos[mp[L[i]]]==mx)
			if(L[i]<restL)
				restL = L[i];

		if(imos[mp[R[i]]]==mx)
			if(restR<R[i])
				restR = R[i];
	}
	ll ans = (mx-1)*M + ((mx%2==1)? restR: (M-restL) );
	cout << ans << endl;
}


Measured memory_bytes: 45004
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[][] input = new int[n][3];
        for(int i=0;i<n;i++){
            input[i][0] = sc.nextInt();
            input[i][1] = sc.nextInt();
            input[i][2] = sc.nextInt();
        }

        int[][] dp = new int[n][3];
        //Arrays.fill(dp, Integer.MAX_VALUE);

        for(int i=0;i<n;i++){
            if(i==0){
                dp[i][0] = input[i][0];
                dp[i][1] = input[i][1];
                dp[i][2] = input[i][2];
            }else{
                //System.out.println("for:" + dp[i-1][0] + "/" + dp[i-1][1] + "/" + dp[i-1][2]);

                dp[i][0] = Math.max(dp[i-1][1],dp[i-1][2])+input[i][0];
                dp[i][1] = Math.max(dp[i-1][0],dp[i-1][2])+input[i][1];
                dp[i][2] = Math.max(dp[i-1][0],dp[i-1][1])+input[i][2];
            }
        }
        //System.out.println(dp[n-1][0] + "/" + dp[n-1][1] + "/" + dp[n-1][2]);
        int ans = Math.max(Math.max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
        System.out.println(ans);



    }
}

Measured memory_bytes: 99192
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int a, b;
		cin >> a >> b;
		if(a > 9 || b > 9)
			cout << -1;
			else
				cout << a*b;
    return 0;
} // What is to be written here?


Measured memory_bytes: 256
#include <cstdio>

const int kBits = 18, kLen = (1 << 17) + 5;

int N, A, B, ans[kBits][kLen];

void Solve(int s, int t, int bit);

int main() {
	scanf("%d%d%d", &N, &A, &B);

	int ca = 0, cb = 0;
	for (int i = 0; i < N; i++) ca += A >> i & 1;
	for (int i = 0; i < N; i++) cb += B >> i & 1;
	if ((ca & 1) == (cb & 1)) {
		puts("NO");
		return 0;
	}

	Solve(A, B, N);
	puts("YES");
	for (int i = 0, u = 1 << N; i < u; i++) {
		printf("%d ", ans[N][i]);
	}
	putchar('\n');
	return 0;
}

inline int DelBit(int n, int i) {
	return n >> i + 1 << i | n & (1 << i) - 1;
}

inline int InsBit(int n, int i, int b) {
	return n >> i << i + 1 | n & (1 << i) - 1 | (1 & b) << i;
}

void Solve(int s, int t, int bit) {
//	printf(" Solve from %d to %d, bit = %d\n", s, t, bit);
	if (bit == 1) {
		ans[1][0] = s, ans[1][1] = t;
		return;
	}
	for (int i = 0; i < bit; i++) {
		if (!(s >> i & 1 ^ t >> i & 1)) continue;
		int c = DelBit(s, i) ^ 1, u = 1 << bit - 1;
	//	printf("  s and t differ at %d bits, c = %d\n", i, c);
		Solve(DelBit(s, i), c, bit - 1);
		for (int j = 0; j < u; j++) {
			ans[bit][j] = InsBit(ans[bit - 1][j], i, s >> i & 1);
		}
		Solve(c, DelBit(t, i), bit - 1);
		for (int j = 0; j < u; j++) {
			ans[bit][u + j] = InsBit(ans[bit - 1][j], i, t >> i & 1);
		}
		break;
	}
}


Measured memory_bytes: 7936
#include <iostream>
using namespace std;
 
int main(){
    int a[101][101] = {0};
    int b,c;
    int d = 0;
    cin >> b >> c;
    for(int i = 0; i < b; i++){
        for(int j = 0; j < c; j ++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < b; i++){
        int w = 0;
        for(int j = 0; j < c; j ++){
            w += a[i][j];
        }
        a[i][c] = w;
    }
    for(int j = 0; j < c; j++){
        int h = 0;
        for(int i = 0; i < b; i ++){
            h += a[i][j];
        }
        a[b][j] = h;
    }
    for(int i = 0; i < b; i++){
        for(int j = 0; j < c; j ++){
            d += a[i][j];
        }
        a[b][c] = d;
    }
    for(int i = 0; i < b + 1; i++){
        for(int j = 0; j < c + 1; j ++){
            if(j == 0){
                cout << a[i][j];
            }else{
                cout << " " << a[i][j];
            }
        }
        //if(i != b) break;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readLong()

    val ans = if(n == 1L) 0L else n * (n+1) / 2 - n
    println(ans)

    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left";
    } else if (a + b == c + d) {
        cout << "Balanced";
    } else {
        cout << "Right";
    }
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int N,M;
	cin >>N >>M;
	VI a(M), b(M);
	rep(i, M){
		int x,y; cin >>x >>y;
		a[i]=x-1; b[i]=y-1;
	}
	
	VI ba(N, 0);
	rep(i, M){
		ba[a[i]]++;
		ba[b[i]]++;
	}
	//for(auto x :ba) printf("%d, ",x); puts("");
	bool ok=1;
	for(auto x :ba) if(x%2) ok=0;
	
	cout << (ok? "YES":"NO") << endl;
	
	return 0;
}



Measured memory_bytes: 1408
def main():
    import sys
    input = sys.stdin.readline

    sys.setrecursionlimit(10 ** 8)

    MOD = 10 ** 9 + 7

    N = int(input())
    G = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        x, y = map(int, input().split())
        G[x].append(y)
        G[y].append(x)

    # B = [0] * (N + 1) #自分自身が黒色の時
    # W = [0] * (N + 1) #自分自身が白色の時
    # T = [0] * (N + 1) #B + W
    C = [False] * (N + 1) #訪れたことのチェック

    def calc(x): #xからの動き方を調べる
        C[x] = True

        b = 1
        w = 1

        for next_ in G[x]:
            if C[next_]:
                continue
            tmp_b, tmp_w = calc(next_)
            b = (b * tmp_b) % MOD
            w = (w * tmp_w) % MOD
        # B[x] = b
        # W[x] = w
        return w, (b + w) % MOD

    tmp, ans = calc(1)
    print (ans)
    # print ((B[1] + W[1]) % MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 123568
N,K = list(map(int,input().split()))
prob = 0.0
for i in range(1,N+1):
    count = 0
    powerdice = i
    while(powerdice<K):
        powerdice *= 2; count+=1
    prob+= 1.0/(2**count)

print("{:.12f}".format(prob/N)) 

Measured memory_bytes: 3060
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    n,m=map(int,input().split())
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i: # 平方数の場合n**0.5を1つだけにしてる
                    divisors.append(n//i)

        divisors.sort(reverse=True) # ソートしたけりゃして
        return divisors
    l=make_divisors(m)
    for i in l:
        if n*i<=m:
            print(i)
            break



resolve()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a <= 9 && b <= 9 ? a * b : -1) << endl;
}


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

int main() {
  string s,t; cin>>s>>t;
  string t_=t.substr(0,t.size()-1);
  if(t_==s){ cout<<"Yes";}
  else{cout<<"No";}
}

Measured memory_bytes: 3592
from collections import defaultdict
n,*h=map(int,open(0).read().split())
h=[y for x,y in zip([-1]+h,h) if x!=y]
d=defaultdict(list)
for i,x in enumerate(h):d[x].append(i+1)
t=ans=int(h!=[0])
h=[-1]+h+[-1]
for y,l in sorted(d.items()):
	for i in l:
		if h[i-1]<y>h[i+1]:t-=1
		elif (h[i-1]>y)^(h[i+1]>y):pass
		else:t+=1
	ans=max(t,ans)
print(ans)


Measured memory_bytes: 35704
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

ll X,sum=100;

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> X;

    ll i=0;
    while(sum<X)
        sum+=sum/100ll , i++;

    cout << i;





}


Measured memory_bytes: 3692
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double s=sc.nextDouble();
double c=sc.nextDouble()/2;
long ans;
if(s>=c)ans=(long)c;
else{
double x=(c-s)/2;
if((long)(x+0.5)>x)ans=(long)(c-x);
else ans=(long)(s+x);
}
System.out.println((long)ans);
}
}

Measured memory_bytes: 23124
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
llsum = a[0]
lrsum = a[1]
l = [0] * n
l[2] = 1
for mid in range(3, n-1):
    new = a[mid-1]
    lrsum += new
    l[mid] = l[mid-1]
    unk = a[l[mid]]
    while(abs(lrsum - llsum) > abs(lrsum - llsum - 2 * unk)):
        llsum += unk
        lrsum -= unk
        l[mid] += 1
        unk = a[l[mid]]
rrsum = a[n-1]
rlsum = a[n-2]
r = [0] * n
r[n-2] = n-1
for mid in reversed(range(2, n-2)):
    new = a[mid]
    rlsum += new
    r[mid] = r[mid+1]
    unk = a[r[mid] - 1]
    while(abs(rlsum - rrsum) > abs(rlsum - rrsum - 2 * unk)):
        rrsum += unk
        rlsum -= unk
        r[mid] -= 1
        unk = a[r[mid] - 1]
minabs = 10 ** 20
for mid in range(2, n-1):
    c0 = cum[l[mid]]
    c1 = cum[mid]
    c2 = cum[r[mid]]
    sums = (c0, c1 - c0, c2 - c1, cum[n] - c2)
    minabs = min(minabs, max(sums) - min(sums))
print(minabs)


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

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> backet(N);	
  for(ll i=0;i<N;i++){
    ll tmp=0;
	cin >> tmp;
    tmp--;
    A[i]=tmp;
    	backet[tmp]=i;
	}
  for(ll i=0;i<N;i++){
    cout << backet[i]+1 << endl;
  }
}

Measured memory_bytes: 4824
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
#ifdef _WIN32
inline unsigned int __builtin_clz(unsigned int x) {
	unsigned long r;
	_BitScanReverse(&r, x);
	return 31 - r;
}
#endif
class SparseTable {
	// bit-or sparse table
	vector<vector<ll> > st;
public:
	void init(vector<ll> v) {
		int b = 0;
		for (; (1 << b) <= v.size(); b++);
		st.assign(b, vector<ll>(1 << b));
		for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
		for (int i = 1; i < b; i++) {
			for (int j = 0; j + (1 << i) <= (1 << b); j++) {
				st[i][j] = (st[i - 1][j] | st[i - 1][j + (1 << (i - 1))]);
			}
		}
	}
	ll query(int l, int r) {
		int b = 32 - __builtin_clz(r - l) - 1;
		return (st[b][l] | st[b][r - (1 << b)]);
	}
	SparseTable() {}
	SparseTable(vector<ll> v) { init(v); }
};
inline ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
inline int modpow(int a, int b, int m) {
	int ret = 1; a %= m;
	while (b) {
		if (b & 1) ret = 1LL * ret * a % m;
		a = 1LL * a * a % m;
		b >>= 1;
	}
	return ret;
}
inline int modinv(int a, int m) {
	return modpow(a, m - 2, m); 
}
const int mod = 1000000007;
int N, Q, l, r; vector<int> p;
int main() {
	scanf("%d%d", &N, &Q); p.resize(N);
	for (int i = 0; i < N; i++) scanf("%d", &p[i]), p[i]--;
	vector<int> a(N), used(N, false);
	vector<ll> s(N);
	for (int i = 0; i < N; i++) {
		if (used[i]) continue;
		vector<int> comp; int r = i;
		while (!used[r]) {
			used[r] = true;
			comp.push_back(r);
			r = p[r];
		}
		int sum = 0;
		for (int j : comp) sum += j + 1, sum = (sum < mod ? sum : sum - mod);
		for (int j : comp) {
			a[j] = comp.size();
			s[j] = 1LL * sum * modinv(a[i], mod) % mod;
		}
	}
	vector<ll> b(N), sumv(N + 1);
	for (int i = 0; i < N; i++) b[i] = (1LL << a[i]);
	for (int i = 0; i < N; i++) sumv[i + 1] = sumv[i] + s[i];
	SparseTable S(b);
	while(Q--) {
		scanf("%d%d", &l, &r); l--;
		ll res = S.query(l, r);
		ll rep = 1;
		for (int i = 1; i <= 40; i++) {
			if (res & (1LL << i)) rep = rep / gcd(rep, i) * i;
		}
		rep %= mod;
		printf("%lld\n", (sumv[r] - sumv[l]) % mod * rep % mod);
	}
	return 0;
}

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var a = cin.ReadIntArray(N);

            var cnt1 = 0;
            var cnt2 = 0;
            var cnt4 = 0;
            foreach (var x in a)
            {
                if (x % 4 == 0) cnt4++;
                else if (x % 2 == 0) cnt2++;
                else cnt1++;
            }

            YesNo(cnt4 >= cnt1 || (cnt2 == 0 && cnt4 + 1 == cnt1));
        }

        public void YesNo(bool f) => WriteLine(f ? "Yes" : "No");
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


Measured memory_bytes: 22496
M, D = map(int, input().split())


ans = 0
for m in range(1, M+1):
    for day in range(1, D+1):
        d10 = day // 10
        d1 = day - d10*10
        #print(d1, d10, m)
        if d1 >= 2 and d10 >= 2:
            if d1 * d10 == m:
                ans += 1

print(ans)

Measured memory_bytes: 3060
S = input()
ans = str()

if S[0] == S[1]:
  if S[0] != S[2] and S[2] == S[3]:
    ans = "Yes"
  else :
    ans = "No"

else :
  if S[0] == S[2] and S[1] == S[3]:
    ans = "Yes"
  elif S[0] == S[3] and S[1] == S[2]:
    ans = "Yes"
  else:
    ans = "No"
  
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

//A - Rated for Me
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        if (R < 1200)
            System.out.println("ABC");
        else if (R < 2800)
            System.out.println("ARC");
        else
            System.out.println("AGC");
        sc.close();
    }
}


Measured memory_bytes: 21460
a[1<<17];
main(){
	int n,k,t;
	scanf("%d%d",&n,&k);
	long ans=k;
	for(int i=0;i<2*n-2;i++){
		scanf("%d",&t);
		if(a[--t]++||!t)ans=ans*(k-a[t])%1000000007;
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


int main() {

    ll N;
    cin >> N;
    vector <ll> p(N);
    vector <ll> s_p(N);

    vector <pair<ll,ll>> vp;

    string res;

    REP(i,N)
    {
        cin >> p[i];
    }

    s_p = p;

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


    REP(i,N)
    {
        if(p[i] != s_p[i])
        {
            vp.push_back(pair<ll,ll>(p[i],s_p[i]));
        }
    }


    if(vp.size() == 0)
    {
        res = "YES";
    }
    else if(vp.size() == 2)
    {
        if(vp[0].first == vp[1].second && vp[0].second == vp[1].first)
        {
            res = "YES";
        }
        else
        {
            res = "NO";
        }

    }
    else
    {
        res = "NO";
    }




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

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

int main(){
  int n;
  int count =0;
  cin >> n;
  vector<int> l(n),r(n);
  rep(i,n){
    cin >> l[i] >> r[i];
    count +=(r[i]-l[i]+1);
  }
  cout << count <<endl;

  return 0;
}


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

using I = long long;
const I M = 1e9+7;

int H, W, K;

int get(auto b, auto i) {return (b>>i)&1;};
int set(auto b, auto i) {return b|(1<<i);};
bool valid(auto b) {
  for(auto i=0; i<W-1; ++i) if(get(b, i) && get(b, i+1)) return false;
  return true;
}

I dp[102][10];

int main() {
  cin >> H >> W >> K;

  dp[0][1] = 1;
  for(auto i=0; i<H; ++i) for(auto k=1; k<=W; ++k) {
    for(auto b=0; b<(1<<W-1); ++b) if(valid(b)) {
      auto nk = k;
      if((b>>(k-1))&1) ++nk;
      if((b>>(k-2))&1) --nk;
      (dp[i+1][nk] += dp[i][k]) %= M;
    }
  }

  cout << dp[H][K] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	char x, y;
	cin >> x >> y;
	if(x == y) puts("=");
	else if(x < y) puts("<");
	else puts(">");
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (1e18)
using namespace std;
typedef pair<int, int> P;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main(void) {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int ans1 = 0, ans2 = 0;
	for (int i = 0;i <= 30;i++) {
		for (int j = 0;j <= 30;j++) {
			int num = a * i + b * j;
			int w = 100 * num;
			int l = e * num;
			for (int k = 0;k <= 100;k++) {
				for (int m = 0;m <= 100;m++) {
					int mass = c * k + d * m;
					int all = w + mass;
					if ((w!=0)&&(mass <= l) && (all <= f)) {
						if ((ans1 == 0) && (ans2 == 0)) {
							ans1 = all;
							ans2 = mass;
						}
						else {
							if (mass*ans1 > ans2*all) {
								ans1 = all;
								ans2 = mass;
							}
						}
					}
				}
			}
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();
	rep(i,n) if(s[i]=='?') s[i]='D';
	cout<<s<<'\n';

	return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int max_p = max(a,max(b,c));
    int ans=0;
    if(max_p != a){
        ans += a;
    }
    if(max_p != b){
        ans += b;
    }
    if(max_p != c){
        ans += c;
    }
    if(ans == 0){
        ans += a*2;
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F            first
#define S            second
#define PB           push_back
#define MP           make_pair
#define Fin          freopen("input.txt","r",stdin)
#define Fout         freopen("output.txt","w",stdout)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF9 2147483647
#define INF18 9223372036854775806
#define ll long long
#define ull unsigned long long
#define nn printf("\n")
#define no printf("NO\n")
#define yes printf("YES\n")
#define pp pair<int,int>
#define ppp pair<int,pp >
#define mapii map<int,int>
#define mapll map<ll,ll>
#define mapsi map<string,int>
#define mapss map<string,string>

char Uplowch(char ch)
{
    if(ch >= 'A' &&  ch <= 'Z')
        ch += 32;
    return ch;
}
char Lowupch(char ch)
{
    if(ch >= 'a' &&  ch <= 'z')
        ch -= 32;
    return ch;
}

int ara[111];
int ara2[111];
vector<int>v;
int main()
{
    int t,n,m,a,b,i,j,x,y,mx,mn,sum,k=0,flag;

    while(scanf("%d",&n)==1)
    {
        if(n==0)printf("1\n");
        else printf("0\n");
    }

    return 0;
}


Measured memory_bytes: 3760
#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<ll> a(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> a[i];

  //入力された整数を昇順に並び替える
  sort(a.begin(), a.end());

  //次の整数が一致しているかどうかチェックする
  int ans = 0;
  rep(i,n) {
    if (a[i] == a[i+1]) {
      ++ans;
      break;
    }
  }
  
  if (ans > 0) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

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

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(6)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};	
void solve(){
	ll a,b,n;
	cin>>a>>b>>n;
	if(b==1){
		cout<<0<<endl;
		return;
	}
	if(n<b) cout<<((a*n)/b)<<endl;
	else{
		ll ans=((a*(b-1))/b);
		for(ll i=b-1;i<=n;i+=(b-1)){
			ans=max(ans,(((a*i)/b)-(a*(i/b))));
		}
		ans=max(ans,((a*n)/b)-(a*(n/b)));
		cout<<ans<<endl;
	}
		
		
	
	
	
		
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define modi 1000000007
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
IOS;
lli n,m,i,j;
cin>>n>>m;
string s[n];
for(i=0;i<n;i++){
    cin>>s[i];
}
lli dp[n+1][m+1];
for(i=0;i<=n;i++){
    dp[i][0]=0;
}
for(i=0;i<=m;i++){
    dp[0][i]=0;
}
dp[1][1]=1;
for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
            if(i==1&&j==1)
            continue;
        if(s[i-1][j-1]=='#'){
            dp[i][j]=0;
        }
        else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modi;
    }
}
cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 9088
from itertools import permutations

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
cmat = [list(map(int, input().split())) for _ in range(n)]

dcnt = [[0] * c for _ in range(3)]
for i, ci in enumerate(cmat):
    for j, cij in enumerate(ci):
        mod = (i + j) % 3
        dcnt[mod][cij - 1] += 1

ans = 10 ** 9
for color in permutations(range(c), 3):
    tmp = 0
    for tgt, cnt in zip(color, dcnt):
        tmp += sum(d[i][tgt] * cnt[i] for i in range(c))
    ans = min(ans, tmp)
print(ans)


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

signed main(){
 int a,b,c,sum=0;cin>>c>>a>>b;
 for(int d=0;d<c;d++){
     int e;scanf("%d",&e);
     if(e>=a&&e<b)sum++;
     }cout<<c-sum<<endl;
    }


Measured memory_bytes: 256