akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct E{
	int to;
	int clr;
	int len;
};
vector<E> g[100005];
int anc[18][100005],d[100005];
void dfs(int u,int fa){
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		anc[0][v.to]=u;
		d[v.to]=d[u]+1;
		dfs(v.to,u);
	}
}
int LCA(int x,int y){
	if(d[x]>d[y]){
		swap(x,y);
	}
	for(int ind=0;d[x]<d[y];++ind){
		if((d[y]-d[x])>>ind&1){
			y=anc[ind][y];
		}
	}
	if(x==y){
		return x;
	}
	for(int ind=18;ind--;){
		if(anc[ind][x]!=anc[ind][y]){
			x=anc[ind][x],y=anc[ind][y];
		}
	}
	return anc[0][x];
}
struct info{
	int ind;
	char typ;
	int clr;
	int cnt;
	info(){}
	info(int in,char ty,int cl,int cn){
		ind=in,typ=ty,clr=cl,cnt=cn;
	}
}; 
vector<info> q[100005];
int sum[100005];
int cnt[100005];
int ans[100005];
void DFS(int u,int fa,ll len){
	for(auto now:q[u]){
		if(now.typ=='d'){
			ans[now.ind]+=len*now.cnt;
		}
		else if(now.typ=='s'){
			ans[now.ind]+=sum[now.clr]*now.cnt;
		}
		else{
			ans[now.ind]+=cnt[now.clr]*now.cnt;
		}
	}
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		sum[v.clr]+=v.len;
		cnt[v.clr]++;
		DFS(v.to,u,len+v.len);
		sum[v.clr]-=v.len;
		cnt[v.clr]--;
	}
}
int main(){
	int n,Q;
	cin>>n>>Q;
	for(int i=1;i<n;++i){
		int u,v,clr,leng;
		cin>>u>>v>>clr>>leng; 
		u--,v--,clr--;
		E a;
		a.to=v,a.len=leng,a.clr=clr;
		E b;
		b.to=u,b.len=leng,b.clr=clr;
		g[u].push_back(a),g[v].push_back(b);
	}
	dfs(0,0);
	for(int ind=0;ind<17;++ind){
		for(int u=0;u<n;++u){
			anc[ind+1][u]=anc[ind][anc[ind][u]];
		}
	}
	for(int i=0;i<Q;++i){
		int clr,leng,u,v;
		cin>>clr>>leng>>u>>v;
		clr--;
		u--;
		v--;
		int lca=LCA(u,v);
		q[u].emplace_back(i,'d',0,1);
		q[u].emplace_back(i,'s',clr,-1);
		q[u].emplace_back(i,'c',clr,leng);
		q[v].emplace_back(i,'d',0,1);
		q[v].emplace_back(i,'s',clr,-1);
		q[v].emplace_back(i,'c',clr,leng);
		q[lca].emplace_back(i,'d',0,-2);
		q[lca].emplace_back(i,'s',clr,2);
		q[lca].emplace_back(i,'c',clr,-2*leng);
	}
	DFS(0,0,0);
	for(int i=0;i<Q;++i){
		cout<<ans[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 46080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	if(s.size()!=2)reverse(all(s));
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <cstdio>

int main(){
    int a, b;
    scanf("%d %d\n",&a,&b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2588
// E. Magical Permutation
// time limit per test1 second
// memory limit per test256 megabytes
// inputstandard input
// outputstandard output
// Kuro has just learned about permutations and he is really excited to create a
// new permutation type. He has chosen 𝑛 distinct positive integers and put all
// of them in a set 𝑆. Now he defines a magical permutation to be:

// A permutation of integers from 0 to 2𝑥−1, where 𝑥 is a non-negative integer.
// The bitwise xor of any two consecutive elements in the permutation is an
// element in 𝑆. Since Kuro is really excited about magical permutations, he
// wants to create the longest magical permutation possible. In other words, he
// wants to find the largest non-negative integer 𝑥 such that there is a magical
// permutation of integers from 0 to 2𝑥−1. Since he is a newbie in the subject,
// he wants you to help him find this value of 𝑥 and also the magical
// permutation for that 𝑥.

// Input
// The first line contains the integer 𝑛 (1≤𝑛≤2⋅105) — the number of elements in
// the set 𝑆.

// The next line contains 𝑛 distinct integers 𝑆1,𝑆2,…,𝑆𝑛 (1≤𝑆𝑖≤2⋅105) — the
// elements in the set 𝑆.

// Output
// In the first line print the largest non-negative integer 𝑥, such that there
// is a magical permutation of integers from 0 to 2𝑥−1.

// Then print 2𝑥 integers describing a magical permutation of integers from 0 to
// 2𝑥−1. If there are multiple such magical permutations, print any of them.

// Examples
// inputCopy
// 3
// 1 2 3
// outputCopy
// 2
// 0 1 3 2
// inputCopy
// 2
// 2 3
// outputCopy
// 2
// 0 2 1 3
// inputCopy
// 4
// 1 2 3 4
// outputCopy
// 3
// 0 1 3 2 6 7 5 4
// inputCopy
// 2
// 2 4
// outputCopy
// 0
// 0
// inputCopy
// 1
// 20
// outputCopy
// 0
// 0
// inputCopy
// 1
// 1
// outputCopy
// 1
// 0 1
// Note
// In the first example, 0,1,3,2 is a magical permutation since:

// 0⊕1=1∈𝑆
// 1⊕3=2∈𝑆
// 3⊕2=1∈𝑆
// Where ⊕ denotes bitwise xor operation.

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

using namespace std;

int n, m, d;
int i, j, k;

void solve() {
  cin >> n >> d;
  d = 2 * d + 1;
  cout << ((n + d - 1) / d) << endl;
  return;
}

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


Measured memory_bytes: 384
n=int(input())
kot="Yes"
at,a1,a2=0,0,0
for i in range(n):
  a=list(map(int,input().split()))
  a[0]=a[0]-at
  a[1]=a[1]-a1
  a[2]=a[2]-a2
  gou=max(a[1]+a[2],(-1*a[1])+a[2],a[1]+(-1*a[2]),(-1*a[1])+(-1*a[2]))
  if a[0]%2!=(gou)%2:
    kot="No"
    break
  if a[0] < gou:
    kot="No"
    break
  at,a1,a2=a
print(kot)

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;






void one_case() {
    vector<bool> prime(5e5, true);
    prime[0] = prime[1] = 0;
    for (int p = 2; p < prime.size(); ++p) {
        if (!prime[p]) {
            continue;
        }
        auto cur = 2 * p;
        while (cur < prime.size()) {
            prime[cur] = 0;
            cur += p;
        }
    }
    vector<bool> similar(5e5);
    for (int i = 0; i < similar.size(); ++i) {
        if (i % 2) {
            similar[i] = prime[i] && prime[(i + 1) / 2];
        }
    }
    vector<int> cnt(5e5);
    for (int i = 1; i < 5e5; ++i) {
        cnt[i] = cnt[i - 1] + int(similar[i]);
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << "\n";
    }

}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

int inp(){
  int x; 
  cin>>x;
  return x;
}

//=============================================================================//

void solve() {
    string s;
    cin>>s;
    if(s[s.length()-1]=='s') cout<<s<<"es";
    else cout<<s<<'s';
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string s; cin >> s;
    int res = 700;
    repp(i,0,3) res += s[i] == 'o' ? 100 : 0;
    cout << res << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
  long long MOD=1000000007;
  #define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
  typedef long long ll;
  #define pb push_back
  typedef pair<ll,ll> pi;

int main()
{
  IOS();
  int n;
  cin>>n;
  int a[n+1];
  int b[n+1];
  int c[n+1];
  for (int i = 1;i<=n; ++i)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  int dp[n+1][3];
  dp[1][0]=a[1];
  dp[1][1]=b[1];
  dp[1][2]=c[1];

  for(int i=2;i<=n;i++)
  {
    dp[i][0]=a[i]+std::max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+std::max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i]+std::max(dp[i-1][0],dp[i-1][1]);
  }

  cout<<std::max(dp[n][0],std::max(dp[n][1],dp[n][2]))<<endl;
  return 0;
}

Measured memory_bytes: 5980
K = int( input() )
A, B = map( int, input().split() )

is_we_love_golf = False
for i in range( A, B + 1 ):
  if i % K == 0:
    is_we_love_golf = True
    break
if is_we_love_golf:
  print( "OK" )
else:
  print( "NG" )

Measured memory_bytes: 9172
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int n, m, x;
vector<int> c(15);
vector<vector<int>> a(15, vector<int> (15));

void cal(int j, vector<int> &cnt) {
    rep(i, m) {
        cnt[i] += a[j][i];
    }
}

int main() {
    
    cin >> n >> m >> x;
    
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    int ans = 1e8;
    for (int i = 0; i < (1 << n); i++)  {
        bitset<12> b(i);
        vector<int> cnt(m, 0);
        int mon = 0;
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {//ｊ番の教科書を買う
                //cout << j << endl;
                mon += c[j];
                cal(j, cnt);
            }
        }
        //cout << endl;
        
        bool flag = true;
        rep(k, m) {
            if (cnt[k] < x) flag = false;
        }
        if (flag) ans = min(ans, mon);
    }

    if (ans == 1e8) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct point
{
	double x, y;
	point(double x = 0, double y = 0) :x(x), y(y) {};
	
	point operator + (point p) { return point(x + p.x, y + p.y); }
	point operator - (point p) { return point(x - p.x, y - p.y); }
	point operator * (double s) { return point(x * s, y * s); }
	point operator / (double s) { return point(x / s, y / s); }

	double abs() { return sqrt(norm()); }
	double norm() { return x*x + y*y; }

	bool operator < (const point &p) const
	{
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};
struct line
{
	point a, b;
	line(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0) :a(point(x1, y1)), b(point(x2, y2)) {};

	point univec() { return (b - a) / (b-a).norm(); }
};

double dot(point a, point b)
{
	return a.x*b.x + a.y*b.y;
}

point project(line l, point p)
{
	point base = l.b - l.a;
	double r = dot(p - l.a, base) / base.norm();
	return l.a + base*r;
}

int main()
{
	double a[4];
	REP(i, 4) cin >> a[i];
	line l(a[0], a[1], a[2], a[3]);
	int q;
	cin >> q;
	while (q--)
	{
		int x, y;
		cin >> x >> y;
		point p(x, y);
		auto t = project(l, p);
		point ans = t + (t - p);
		cout << D10 << ans.x << " " << ans.y << endl;
	}
	return 0;
}

Measured memory_bytes: 1296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		
		int largest = 0;
		int largestI = 0;
		int second = 0;
		int secondI = 0;
		
		for(int i=0; i<N; i++) {
			A[i] = scan.nextInt();
			if(largest < A[i]) {
				largest = A[i];
				largestI = i;
			} else if(second < A[i]) {
				second = A[i];
				secondI = i;
			}
		}
		scan.close();

		for(int i=0; i<A.length; i++) {
			if(i==largestI) {
				System.out.println(A[secondI]);
			} else {
				System.out.println(A[largestI]);
			}
		}
		
	}

}

Measured memory_bytes: 86012
require 'bigdecimal'
input = STDIN.read.split("\n")
Array.new(input.shift.to_i) do
  x1, y1, x2, y2, x3, y3, x4, y4 = input.shift.chomp.split.map { |e| BigDecimal.new(e) }
  if y1 == y2 && y3 == y4
    puts 'YES'
    next
  end
  ab = (y2 - y1) / (x2 - x1)
  cd = (y4 - y3) / (x4 - x3)
  puts(ab == cd ? 'YES' : 'NO')
end

Measured memory_bytes: 8804
<?php
$inning = trim(fgets(STDIN));
$scores = array();
for($i = 0; $i < $inning; ++$i) {
  $scores[$i] = 0;
}
$outcount = 0;
$base = 0;
while(true) {
  $turn = floor($outcount / 3);
  $key = trim(fgets(STDIN));

  switch($key) {
    case 'HIT':
      $scores[$turn] += $base & 1;
      $base = ($base >> 1) | 4;
      break;
    case 'OUT':
      if (++$outcount%3 == 0) {
        $base = 0;
      }
      break;
    case 'HOMERUN':
      $base |= 8;
      while ($base) {
       $scores[$turn] += $base & 1;
        $base = $base >> 1;
      }
      break;
  }

  if ($outcount == 3 * $inning) {
    break;
  }
}
foreach ($scores as $score) {
  echo $score . PHP_EOL;
}

Measured memory_bytes: 15164
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		long k = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++)
			b[i] = in.nextInt();

		long at = 0;
		int ac = 0;
		for (int i = 0; i < n; i++)
			if (at + a[i] > k)
				break;
			else {
				ac++;
				at += a[i];
			}
		long bt = 0;
		int bc = 0;
		for (int i = 0; i < m; i++)
			if (at + bt + b[i] > k)
				break;
			else {
				bc++;
				bt += b[i];
			}

		int ans = ac + bc;
		while (ac > 0) {
			ac--;
			at -= a[ac];
			while (bc < m)
				if (at + bt + b[bc] > k)
					break;
				else {
					bt += b[bc];
					bc++;
				}
			if (ans < ac + bc)
				ans = ac + bc;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 61024
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     itos(a)             to_string(a)
#define     ctoi(a)             int(a)-48
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'


void solve(){
    int n,m;cin>>n>>m;
    int a[n][2];
    for(int i = 0; i < n; ++i) cin>>a[i][0]>>a[i][1];
    int dp[n][m+1];clr(dp);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= m; ++j){
            dp[i][j]=max((i-1<0?0:dp[i-1][j]),(j-a[i][0]<0?0:(i-1<0?0:dp[i-1][j-a[i][0]])+a[i][1]));
        }
    }
    cout<<dp[n-1][m]<<'\n';
}

signed main() { 
    IO();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


Measured memory_bytes: 78336
N,Q = map(int,input().split())
S = input()
questions = [[i for i in map(int,input().split())] for j in range(Q)]
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2]=='AC' else 0)  

for q in questions:
  print(t[q[1]-1] - t[q[0]-1])

Measured memory_bytes: 26068
//
// D - 井井井 / ###
//

#include <iostream>

using namespace std;
using LL = long long;

const LL MOD = 1000000007;

int main() {

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

    LL xx = 0, yy = 0;

    for (int i = 0; i < n; i++) {
        LL x;
        cin >> x;
        xx += i * x - (n - i - 1) * x;
        xx %= MOD;
    }

    for (int i = 0; i < m; i++) {
        LL y;
        cin >> y;
        yy += i * y - (m - i - 1) * y;
        yy %= MOD;
    }

    cout << (xx * yy) % MOD << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

/*
#######
#.#.#.#
#######
.......
.#.#.#.
.......
*/

char mp[105][105];
llong wh;
llong bl;

int main() {
    for (int i = 0; i < 49; i++) {
        if (i & 1) {
            for (int j = 0; j < 100; j++) {
                if (j & 1) {
                    mp[i][j] = '.';
                    wh++;
                }
                else {
                    mp[i][j] = '#';
                }
            }
        }
        else {
            for (int j = 0; j < 100; j++) {
                mp[i][j] = '#';
            }
        }
    }
    for (int j = 0; j < 100; j++) mp[49][j] = '#';
    
    for (int i = 50; i < 99; i++) {
        if (i & 1) {
            for (int j = 0; j < 100; j++) {
                if (j & 1) {
                    mp[i][j] = '#';
                    bl++;
                }
                else {
                    mp[i][j] = '.';
                }
            }
        }
        else {
            for (int j = 0; j < 100; j++) {
                mp[i][j] = '.';
            }
        }
    }
    for (int j = 0; j < 100; j++) mp[99][j] = '.';
    
    wh++, bl++;
    
    llong a, b;
    cin >> a >> b;

    llong s, t;
    s = t = 0;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 100; j++) {
            if (mp[i][j] == '.' && wh > a) {
                mp[i][j] = '#';
                wh--;
                s++;
            }
        }
    }

    for (int i = 50; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (mp[i][j] == '#' && bl > b) {
                mp[i][j] = '.';
                bl--;
                t++;
            }
        }
    }

    cout << 100 << ' ' << 100 << endl;
    for (int i = 0; i < 100; i++) {
        cout << mp[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Max 100   //?????§???????????????
#define MAX 1000000000

int top=0;
int S[Max];
char s[MAX];

void initialize(); 
//top???0??¨??????????????????????????????
int isEmpty();     
//top???0???????????????????????????????????????????????????????????????
int isFull();      
//??????????????????????????????????????????
void push(int);
//top???1????¢????????????????x?????????
int pop();         
//top?????????????´?(????????????????????????????´?)???????????????top??????????????????????????????????´??????????


void initialize(){
  top = 0;
}

void push(int x){
 top++;
 S[top] = x;
}

int pop(){ 
  top--;
  return S[top+1];
}



int main(){
  int a,b;
  int x;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } 
    else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    } 
    else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } 
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define M 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
void input(vector<ll>& v,ll n){ ll i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<ll> v) { ll i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<ll,int>  frequency(vector<ll> v){ ll i; map<ll,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ll a,b,c;
	cin >> a >> b >> c;
	ll x = a/b;
	if (a % b == 0)
		cout<<x*c<<endl;
	else 
		cout<<c*(x+1)<<endl;
	
}
// Check for corner cases
// Check for special case like n = 0 or n = INT_MAX
// Check for Buffer Overflow or use of unsigned variable if any
// Check if problem can be solved mathematically 



Measured memory_bytes: 3636
N,K = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
ans = 0

if K == 1:
    print(p[0])
elif K == 2:
    print(p[0]+p[1])
else:
    for i in range(K):
        ans += p[i]
    print(ans)


Measured memory_bytes: 62412
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int maxr = 0;
        int r = 0;
        int t = 0;
        for (int i = 0; i < 5; i++) {
            int tmp = s.nextInt();
            if (tmp % 10 == 0) {
                t += tmp;
            } else {
                r = 10 - tmp % 10;
                t += tmp + r;
                if (maxr < r) {
                    maxr = r;
                }
            }
        }
        s.close();

        System.out.println(t - maxr);
    }
}

Measured memory_bytes: 22996
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

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

int x, ans;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x;
    int tmp = x / 500;
    ans += tmp * 1000;
    x -= tmp * 500;
    ans += x - (x % 5);
    cout << ans << E;
    //system("pause");
    return 0;
}

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

ll solve() {
    string S, e = "CODEFESTIVAL2016";
    cin >> S;
    ll ans = 0;
    for ( int i = 0; i < S.size(); i++ ) {
        if ( S[i] != e[i] ) ans++;
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[])
{
	int N, K;
	int V[51];
	vector<int> q;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		int V;
		cin >> V;
		q.push_back(V);
	}

	int a = min(N, K);
	int max = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= a - i; j++) {
			vector<int> q2;
			for (int k = 0; k < i; k++) {
				int L = q[k];
				q2.push_back(L);
			}
			for (int k = 0; k < j; k++) {
				int R = q[N - 1 - k];
				q2.push_back(R);
			}
			sort(q2.begin(), q2.end());
			for (int k = 0; k < K - i - j && q2.size() > 0; k++) {
				if (q2[0] < 0) {
					q2.erase(q2.begin());
				}
			}
			int sum = 0;
			for (int k = 0; k < q2.size(); k++) {
				sum += q2[k];
			}
			max = sum > max ? sum : max;
		}
	}

	cout << max << "\n";

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    d = {"a": input(), "b": input(), "c": input()}
    now = "a"
    while True:
        if len(d[now]) == 0:
            print(now.upper())
            break
        nex, d[now] = d[now][0], d[now][1:]
        now = nex


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n,a,b; cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(a+b-n,0)<<endl;
}


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

using namespace std;

#define MAX 51

struct Point{
  int x,y;
  double dist(const Point &p){
    return abs(x-p.x)+abs(y-p.y);
  }
};

int N,m[MAX];
vector<Point> lines[MAX];

int getDir(Point &p1,Point &p2){
  if(p1.x == p2.x){
    return (p1.y < p2.y ? 0 : 2);
  }else{
    return (p1.x < p2.x ? 3 : 1);
  }
}

bool equals(vector<Point> &l1,vector<Point> &l2){
  int s1 = l1.size(), s2 = l2.size();
  if(s1 != s2) return false;
  bool flg = false;
  int dir1,dir2,diff;
  for(int i = 0 ; i < s1-1 ; i++){
    double d1 = l1[i].dist(l1[i+1]);
    double d2 = l2[i].dist(l2[i+1]);
    dir1 = getDir(l1[i],l1[i+1]);
    dir2 = getDir(l2[i],l2[i+1]);
    if(d1 != d2){ flg = true; break; }
    if(i > 0){
      if(diff != (dir1-dir2+4)%4){
        flg = true;
        break;
      }
    }else{
      diff = (dir1-dir2+4)%4;
    }
  }
  if(!flg) return true;
  flg = false;
  for(int i = s1-1 ; i > 0 ; i--){
    double d1 = l1[s1-i-1].dist(l1[s1-i]);
    double d2 = l2[i].dist(l2[i-1]);
    dir1 = getDir(l1[s1-i-1],l1[s1-i]);
    dir2 = getDir(l2[i],l2[i-1]);
    if(d1 != d2){ flg = true; break; }
    if(i != s1-1){
      if(diff != (dir1-dir2+4)%4){
        flg = true;
        break;
      }
    }else{
      diff = (dir1-dir2+4)%4;
    }
  }
  return !flg;
}

int main(){
  while(cin >> N,N){
    for(int i = 0 ; i <= N ; i++){
      cin >> m[i]; lines[i].clear();
      for(int j = 0 ; j < m[i] ; j++){
        int x,y;
        cin >> x >> y;
        lines[i].push_back((Point){x,y});
      }
    }
    for(int i = 1 ; i <= N ; i++){
      if(equals(lines[0],lines[i])){
        cout << i << endl;
      }
    }
    cout << "+++++" << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
N = int(input())
ans = 0
if N<105:
  ans = 0
else:
  for i in range(105,N+1,2):
    cnt = 0
    for j in range(1,N+1,2):
      if i%j == 0:
        cnt += 1
        if cnt == 8:
          ans += 1
print(ans)

Measured memory_bytes: 3060
def solve():
    from sys import stdin
    f_i = stdin
    
    N, C = map(int, f_i.readline().split())
    
    # ranking: [(score, team number), ...]
    ranking = [(0, i) for i in range(1, N + 1)]
    ranking.insert(0, (-1000000000 * C, 0))
    score = [0] * (N + 1)
    
    from bisect import bisect_left, insort
    ans = []
    for i in range(C):
        cmd = f_i.readline().split()
        if cmd[0] == '0':
            t, p = map(int, cmd[1:])
            pre_score = score[t]
            pre_rec = (pre_score, t)
            ranking.pop(bisect_left(ranking, pre_rec))
            new_score = pre_score - p # score is negative value
            score[t] = new_score
            insort(ranking, (new_score, t))
        else:
            m = int(cmd[1])
            p, t = ranking[m]
            ans.append(' '.join(map(str, (t, -p))))
    print('\n'.join(ans))

solve()


Measured memory_bytes: 24464
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl


int main() {
	double R;
	cin >> R;
	cout << fixed << setprecision(10) << 2 * R * 3.141592 << endl;
}

Measured memory_bytes: 3780
/*
      友利奈緒かわいい！！！！！！！！！！！！
      Charlotteまだ見てない人は見ような！！！！！！！

  ／　 /:／　　　　　　　　　　　 　 ＼:ヽ　＼
  　　　　　　　 /　　／　　　　　　 　 　 　 　 　 　 　 ＼　　ヽ
  　　　　　＼__L 彡　　　　　　　　　　　　　　　　　　　 ヽ　　',
  　　　　　　　ﾌ /　　　/　　/　 /　　　,　　 　 　 　 ヽ　　', 　ｊ
  　　　　　　　ﾚ　　　 /　　/ 　/　 　 　 　 　 　 　 　 ', 　ヽ　j
  　　　 　 　 // 　 　 !　/_l＿/__ノ 　　{ ＼}　　　　 　 ',　　',/
  　　　　　　i ﾊ 　 　 {　从j　ﾊ　i　　　 ',　 ト-､}　 i i　 }　　jj
  　　　　　　( ﾊ　　　(　 川　ハ ﾊ　 !　 '　ﾊ　 ﾊ　j j　,' 　 八
  　　　 ＜＿,ｨ∧　　　斗芹ﾃミxハ ﾊ　 ﾚ　} /__ﾚﾚ　/ 　 ∧ ＼　ﾉ
  　　　 　 　 ∨　＼ 　ゝ　辷:ソ　　 　)　芹ﾚ心ヾレ′　/ ト--　´
  　　　＼ｰ‐'　ﾉ　　 ＼ゝ　　　　　　 　 　 ゞ:_ソ "/ 　／ 　ヽ
  　　　　 　 フ　　　　i八 " "　　　,　　　　　　　ム彡　　　　＼
  　　　　 　/　　/　　j　 ト　　　　　　 　 　 " "イト＜　 　 　 ＼＼
  　　　　 /　　/　　　j　/／ヽ､ 　 ∩　　 　 イ　{ {　　￣ フフへ ＼＼
  　　　　(　／　　　 ,/ / 　　i　＞――＜ニニニﾆ┐　 〃／: : ヽ　ヽヽ
  　　　　／　　ィT´/ /┌―　￣￣ /::: , ,)　 　 　 〃／／: : : : : :}　ヽヽ)
  　　　/ /　 ∧ヾi┌― { {￣　　　 ﾉ:::トﾟ<　 　 　 ∥//: : : : : : : : i　 ﾉ ﾉ
  . 　　( 人　 {:ヽヾi∨　∧V　　　 /:::/　､ヽ　　　 ∥/: : : : : : : : : :}　/
  　　　V　( ∧: :＼'∨　∧V　　 ﾉ:::/　 ∧ 〉＿__∥: : : : : :／: : : :ﾚ
  　　 　 　 /∧: : : : ∨　∧V┬ｲ:::ﾉ　 〈 TT　|　|{{: : : : ／: : : : : ∧　　 ﾉ
  　　　 　 (　ハ: : : : :∨'T∧Vi　i (　 　 V　!　!　{{: : ／ : : : : : : /　ｰ　ノ
  　　　　　V　ハ: : : : :∨ﾍ∧V　i ゝゝ　 i／⌒＼{／ : : : : : : : /ｰ― ´
  　　　　　 ∨　ヽ: : : : :∨ﾍ∧∨i　〉 〉 /　/二　 ): : : : : : : : :/
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  sort(ALL(a));
  cout << a.back()-a.front() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll x,y,a,b,c;
 cin>>x>>y>>a>>b>>c;
 vector<ll> p(a),q(b),r(c);
 for(ll i=0;i<a;i++)cin>>p[i];
 for(ll i=0;i<b;i++)cin>>q[i];
 for(ll i=0;i<c;i++)cin>>r[i];
 /*
 sort( p.begin() , p.end() );
 reverse( p.begin() , p.end() );
 //for(auto i:p)cout<<i<<endl;
 sort( q.begin() , q.end() );
 reverse( q.begin() , q.end() );
 sort( r.begin() , r.end() );
 reverse( r.begin() , r.end() );
 
 for(ll i=1;i<a;i++) p[i] += p[i-1];
 for(ll i=1;i<b;i++) q[i] += q[i-1];
 for(ll i=1;i<c;i++) r[i] += r[i-1];
*/

 vector< mp > tmp;
 for(auto i:r ) tmp.push_back( mp(i,2) );
 for(auto i:q ) tmp.push_back( mp(i,1) );
 for(auto i:p ) tmp.push_back( mp(i,0) );
 sort(tmp.begin() , tmp.end() );
 reverse( tmp.begin() , tmp.end() );
 /*
 for(auto i:tmp){
  cout<<i.first<<' '<<i.second<<endl;
 }*/

 ll res = x+y;
 ll ans = 0;
 for(ll i=0;i<tmp.size()&& res>0;i++){
  if( tmp[i].second == 0 && x>0){
   x--;
   res--;
   ans += tmp[i].first;
  }else if( tmp[i].second == 1 && y>0 ){
   y--;
   res--;
   ans += tmp[i].first;
  }else if( tmp[i].second == 2 && res > 0 ){
   res--;
   ans += tmp[i].first;
  }
 }
 cout<<ans<<endl;


 return 0;
}


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

int n;

int main() {
    while(~scanf("%d",&n)){
        if(n == 0) break;

        int ans = 0;
        for(int i=1; i<=n; i++) {
            int sum = 0;
            for(int j=i; j<=n; j++) {
                if(sum > n) break;
                if(sum == n) ans++;
                sum += j;
            }
        }
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int uf[200001];

int root(int a)
{
  return uf[a] < 0 ? a : (uf[a] = root(uf[a]));
}

int unite(int a, int b)
{
  int ra = root(a);
  int rb = root(b);
  if (ra == rb) return 0;
  if (ra < rb) {
    uf[ra] += uf[rb];
    uf[rb] = ra;
    return -uf[ra];
  } else {
    uf[rb] += uf[ra];
    uf[ra] = rb;
    return -uf[rb];
  }
}

int main(void)
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    uf[i] = -1;
  }
  int ans = 1;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    int t = unite(a, b);
    if (t > ans) ans = t;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 2488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b;
int p(int n) {
	for (int i = 1; i <= 9; i++) {
		if (n % i == 0) {
			if (n / i <= 9)return 1;
		}
	}
	return 0;

}
int main() {
	int n;
	cin >> n;
	if (p(n))cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007
fib = [1,1,2]
for i in range(3,n+1):
    fib.append((fib[i-2]+fib[i-1])%mod)
if (m==0):
    print(fib[n])
    exit()
ans = 0
ans += fib[a[0]-1]

for i in range(1,m):
    if (a[i]-a[i-1]!=1):
        ans *= fib[a[i]-a[i-1]-2]
        ans %= mod
    else:
        print(0)
        exit()
ans *= fib[n-a[m-1]-1]
print(ans%mod)

Measured memory_bytes: 11064
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long


  int a[300000];
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans=DEKAI;
  int stat=0;
  a[s.size()]=0;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='.') a[i]=a[i+1]+1;
    else a[i]=a[i+1];
  }
  int cnt=0;
  lp(i,n){
    if(s[i]=='#'){
      //cout<<a[i]<<" "<<cnt<<endl;
      ans=min(ans,a[i]+cnt);
      cnt++;
    }
  }
  ans=min(ans,cnt);
  if(ans==DEKAI)ans=0;
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2180
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	ll a, b, n; cin >> a >> b >> n;
	ll x = min(b - 1, n);
	ll ans = (a*x) / b - a * (x / b);
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//experi();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 7696
def illegal_number? (price, denies)
  price.to_s.split('').map(&:to_i).each {|i|
    if denies.include?(i) then
      return true
    end
  }

  return false
end

price, count = gets.chomp.split.map(&:to_i)
denies = gets.chomp.split.map(&:to_i)

# base = 1

while illegal_number?(price, denies) do
  price += 1
end

puts price


Measured memory_bytes: 2172
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-06-04
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    __FastIO;
    //~ cout << setprecision (10) << fixed;
    int a, b, t;
    cin >> a >> b >> t;
    double tim = 0;
    double final_time = (double) t + 0.5;
    int cnt = 0;

    for (int i = a; ; i += a) {
        tim = (double) i;

        if (tim <= final_time) cnt += b;
        else break;
    }

    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 0) {
    COUT("Even");
  } else {
    COUT("Odd");
  }
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <bitset>

using namespace std;

int main() {
  int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int n, s, sum, cnt;

  while (cin >> n >> s) {
    if (!n && !s) { break; }
    cnt = 0;
    for (int bit = 0; bit < (1 << 10); bit++) {
      sum = 0;
      for (int i = 0; i < 10; i++) {
        // if (bitset<10>(bit).test(i)) {
        // i bit 目が立っていたら, a[i] を足す
        if ((bit >> i) & 1) { sum += a[i]; }
      }
      if (sum == s && bitset<10>(bit).count() == n) { cnt++; }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3072
N = gets.to_i
PS = (0...N).map{ gets.split.map(&:to_i) }

(0..100).each{ |cx|
  (0..100).each{ |cy|
    hmax = 1000000000*100
    hv = nil
    PS.each{ |x,y,h|
      d = (cx-x).abs + (cy-y).abs
      if h == 0
        hmax = [hmax, d].min
      else
        g = h + d
        if hv && hv != g
          hv = nil; break
        end
        hv = g
      end
    }
    if hv && hv <= hmax
      puts "#{cx} #{cy} #{hv}"; exit
    end
  }
}
fail

Measured memory_bytes: 1916
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main () {
    char s[1005], t[1005];
    scanf("%s%s", s, t);
    int a = strlen(s), b = strlen(t), Min = 0x3f3f3f3f;
    for (int i = 0; i + b <= a; i++) {
        int res = 0;
        for (int j = 0; j < b; j++) {
            if (s[i + j] != t[j]) res++;
        }
        // printf("(%d)", res);
        Min = min(Min, res);
    }
    printf("%d", Min);
    return 0;  
}


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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  long long int D,T,S;
  cin >> D >> T >> S;
  if(T*S>=D){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3632