akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,n,m,x,y,ans;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	n=a/c;
	x=a%c;
	m=b/d;
	y=b%d;
	if(x>=1){
		n=n+1;
	}
	if(y>=1){
		m=m+1;
	}
	if(n<=m){
		ans=l-m;
	}
	else if(m<=n){
		ans=l-n;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2744
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();
        var T = ReadLine();

        static int GetDiff(string s, string t) => s.Zip(t, (_s, _t) => _s != _t ? 1 : 0).Sum();
        
        var ans = GetDiff(S.Substring(0, T.Length), T);

        for (int i = 0; i < S.Length - T.Length; i++)
        {
            ans = Math.Min(ans, GetDiff(S.Substring(i, T.Length), T));
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 26792
int n;
ans[555][555];
id[555];
main()
{
	scanf("%d",&n);
	int k=1;
	for(;k*(k-1)<n*2;k++);
	if(k*(k-1)!=n*2)
	{
		puts("No");
		return 0;
	}
	printf("Yes\n%d\n",k);
	int p=0,q=1;
	for(int i=1;i<=n;i++)
	{
		ans[p][id[p]++]=i;
		ans[q][id[q]++]=i;
		q++;
		if(q>=k)p++,q=p+1;
	}
	for(int i=0;i<k;i++)
	{
		printf("%d",k-1);
		for(int j=0;j<k-1;j++)printf(" %d",ans[i][j]);
		puts("");
	}
}

Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;
    map<int, vector<int>> mp;
    for(int i=0; i<N; i++){
        int t, d;
        cin >> t >> d;
        mp[t].push_back(d);
    }
 
    vector<int> maxes, others;
    for(auto& p : mp){
        auto nums = p.second;
        sort(nums.rbegin(), nums.rend());
        maxes.push_back(nums[0]);
        for(int i=1; i<nums.size(); i++) others.push_back(nums[i]);
    }
 
    sort(maxes.rbegin(), maxes.rend());
    sort(others.rbegin(), others.rend());
 
    vector<int64_t> maxes_s(N+1, 0), others_s(N+1, 0);
    for(int i=0; i<maxes.size(); i++) maxes_s[i+1] = maxes_s[i] + maxes[i];
    for(int i=0; i<others.size(); i++) others_s[i+1] = others_s[i] + others[i];
 
    int kmax = min(K, (int) mp.size());
    int64_t ans = 0;
    for(int64_t k=1; k<=kmax; k++){
        int64_t result = maxes_s[k] + others_s[K-k] + k*k;
        ans = max(ans, result);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
  char str[1010];
  int a[30]={};
  int i;
  int sum=0;
  
  scanf("%s",str);
  for(i=0;str[i];i++)
    a[str[i]-'a']=!a[str[i]-'a'];
  for(i=0;i<30;i++)
    sum+=a[i];
  
  printf("%d\n",sum/2);
  return 0;
}

Measured memory_bytes: 540
d={t:0for t in'MARCH'};a=0
for t in open(0).read().split():
 if t[0]in d:d[t[0]]+=1
for i in range(32):
 c=t=1
 for j,l in enumerate(d.values()):
  if i>>j&1:t*=l;c+=1
 a+=t*(c==4)
print(a)

Measured memory_bytes: 66388
h,w,n=map(int,input().split())
d=dict()
def change(a,b):
    global h,w,d
    if 1<=a<h-1 and 1<=b<w-1:
        if (a,b) in d:
            d[(a,b)]+=1
        else:
            d[(a,b)]=1
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    for j in range(3):
        for k in range(3):
            change(a+j-1,b+k-1)
ans=[0]*10
ans[0]=(h-2)*(w-2)

for i in d:
    ans[d[i]]+=1
    ans[0]-=1
for i in range(10):
    print(ans[i])



Measured memory_bytes: 166476
// ARC102A.cpp
#include <bits/stdc++.h>

using namespace std;

int n, k;

int main()
{
    scanf("%d%d", &n, &k);
    long long ret = 0;
    if (k % 2 == 0)
    {
        k /= 2;
        int part1 = (n / k) / 2;
        int part2 = ((n / k) + 1) / 2;
        ret += 1LL * part1 * part1 * part1 + 1LL * part2 * part2 * part2;
    }
    else
        ret += 1LL * (n / k) * (n / k) * (n / k);

    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll a = 0, b = 0, c = 0, n = 0, m = 0;
int ar1[100000] = {}, ar2[100000] = {};
string str;
vector<int> vec;


int main() {

	cin >> str;


	rep(i, str.length()) {

		if (str[i] == 'x')a++;
	}

	if (a >= 8) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int a, b;
    cin >> a >> b;
    cout << max({a * 2 - 1, b * 2 - 1, a + b}) << endl;
    
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    if(s == "AAA"){
        cout << "No" << endl;
    }else if(s == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


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

vector<int> perm(8);
vector<bool> taken(8, false);
vector< pair<int, int> > coord;
int n = 0;
double ans = 0;

double dist() {
    double d = 0;
    for (int i = 1; i < n; ++i) {
        d += sqrt( ((coord[perm[i-1]].first - coord[perm[i]].first) * (coord[perm[i-1]].first - coord[perm[i]].first)) +
                ((coord[perm[i-1]].second - coord[perm[i]].second) * (coord[perm[i-1]].second - coord[perm[i]].second)) );
    }
    return d;
}

void solve(int pos) {
    if (pos == n) {
        ans += dist();
        return;
    }
    for (int i = 0; i < n; ++i) {
        if (taken[i]) continue;
        taken[i] = true;
        perm[pos] = i;
        solve(pos + 1);
        taken[i] = false;
    }
}

double fact(int n) {
    double f = 1;
    while (n > 1) {
        f *= n;
        n--;
    }
    return f;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y; cin >> x >> y;
        coord.push_back(make_pair(x, y));
    }
    solve(0);
    cout << setprecision(15) << ans / fact(n);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    
    priority_queue<P, vector<P>, greater<P>> q;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        q.push({b, a});
    }

    bool f = true;

    int now = 0;
    while(!q.empty()){
        P p = q.top();
        q.pop();
        now += p.second;
        if(p.first < now){
            f = false;
            break;
        }
    }

    if(f and q.empty()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 2420
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let s: String = read();
    let t: String = read();
    let mut ans = 2 * N;
    for i in 0..N {
        if s[(N - i - 1)..] == t[0..i + 1] {
            ans = 2 * N - (i + 1);
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
    }
    let mut ans = 0;
    let mut cnt = 0;
    let mut max_cnt = 0;
    for i in 1..n+1 {
        let mut tmp = i;
        loop {
            if tmp%2!=0 {
                break;
            }
            tmp /= 2;
            cnt += 1;
        }
        if max_cnt<cnt {
            max_cnt = cnt;
            ans = i;
        }
        cnt = 0;
    }
    if ans==0 {
        println!("1");
    } else {
        println!("{}", ans);
    }
}


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

int main() {
	int n, k;
	int sum = 0;
	cin >> n >> k;
	vector<int> a(n+1);
	for(int i=0;i<k;i++){
		int d;
		cin >> d;
		for(int j=0;j<d;j++){
			int aa;
			cin >> aa;
			a.at(aa)++;
		}
	}
	for(int i=1;i<=n;i++){
		if(a.at(i)==0) sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3608
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()

a,b=mi()
print(math.ceil((b-1)/(a-1)))

Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int x,y; cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
signed main(){
  string a,b;
  cin>>a>>b;
  Sort(a);
  Sort(b);
  rev(b);
  if(a<b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
ac = [0] * n
cnt = [0] * n
for i in range(m):
    p, s = [x for x in input().strip().split()]
    p = int(p)
    if ac[p-1]:
        continue
    if s == 'AC':
        ac[p-1] = 1
    elif s == 'WA':
        cnt[p-1] += 1

for i in range(n):
    cnt[i] *= ac[i]
    
print(sum(ac), sum(cnt))

Measured memory_bytes: 4724
#include <iostream>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int a[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }
    int b[m];
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        b[i] = x;
    }
    for (int i = 0; i < n; i++)
    {
        int sum = 0;
        for (int j = 0; j < m; j++)
        {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	int Q = rei();
	bool Rev = false;
	vector<char> fr;
	vector<char> ba;
	for(int i=0;i<Q;i++){
		int x = rei();
		if(x == 1){
			Rev = !Rev;
		}
		else{
			int y = rei();
			string s = res();
			if((y == 1  && !Rev) || (y != 1 && Rev)){
				fr.push_back(s[0]);
			}
			else{
				ba.push_back(s[0]);
			}
		}
	}
	if(Rev){
		for(int i=ba.size()-1;i>=0;i--){
			cout << ba[i];
		}
		for(int i=S.length()-1;i>=0;i--){
			cout << S[i];
		}
		for(int i=0;i<fr.size();i++){
			cout << fr[i];
		}
		cout << endl;
	}
	else{
		for(int i=fr.size()-1;i>=0;i--){
			cout << fr[i];
		}
		for(int i=0;i<S.length();i++){
			cout << S[i];
		}
		for(int i=0;i<ba.size();i++){
			cout << ba[i];
		}
		cout << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string ans="No";
  int N; string S; cin>>N>>S;
  int count=0;
  rep(i,0,N){
    if(S[i]=='R')
      count++;
  }
  if(count>N/2)
    ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
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:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


n, m = map(int, input().split())

divisors = make_divisors(m)

for ans in divisors:
    if ans <= m/n:
        print(ans)
        exit()


Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

constexpr ll LINF = 0x3f3f3f3f'3f3f3f3fLL;

ll mcos[101][101];

bool floyd(int n)
{
    rep(k, n) {
        rep(i, n) {
            if (mcos[i][k] == LINF) continue;
            rep(j, n) {
                if (mcos[k][j] == LINF) continue;
                mcos[i][j] = min(mcos[i][j], mcos[i][k] + mcos[k][j]);
            }
        }
    }

    rep(i, n) {
        if (mcos[i][i] < 0) return (true); //negative
    }

    return (false);
}

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

    int N, E;

    cin >> N >> E;

    memset(mcos, 0x3f, sizeof(mcos));
    rep(i, N) mcos[i][i] = 0;

    rep(i, E) {
        int s, t, c;
        cin >> s >> t >> c;
        mcos[s][t] = c;
    }

    if (floyd(N)) {
        outl("NEGATIVE CYCLE");
        return 0;
    }

    rep(i, N) {
        rep(j, N) {
            if (mcos[i][j] == LINF) cout << "INF";
            else cout << mcos[i][j];

            cout << (j+1 < N ? ' ' : '\n');
        }
    }

}




Measured memory_bytes: 3276
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    string S,T ;
    cin >> S >> T;
    bool result=true;
    for(int i=0; i<S.size(); i++){
        if(S.at(i)!=T.at(i)) result=false;
    }
    if(result) cout << "Yes";
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    int cnt=0;
    while(1){
        for(int i=0; i<n; i++){
            if(a[i]%2==0){
                a[i]/=2;
            }
            else goto END;
        }
        cnt++;
    }
    END:;
    cout << cnt << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

N, M = map(int, input().split())
As = list(map(int, input().split())) + [0]
Bs = list(map(int, input().split())) + [0]

NM = N*M
As.sort(reverse=True)
Bs.sort(reverse=True)

ans = 1
iA, iB = 0, 0
for x in reversed(range(1, NM+1)):
    isOnly = False
    if As[iA] == x:
        r = 1
        isOnly = True
        iA += 1
    else:
        r = iA
    if Bs[iB] == x:
        c = 1
        isOnly = True
        iB += 1
    else:
        c = iB

    if isOnly:
        ans *= r*c
    else:
        ans *= r*c - (NM - x)
    ans %= MOD

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    int N=in();
    // string S=in<string>()
    cout<<(double)N*2*pie<<endl;
    return 0;

}


Measured memory_bytes: 3808
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if not (L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]):
                continue
            if not(L[i] != L[j] and L[j] != L[k] and L[k] != L[i]):
                continue
            ans += 1
print(ans)


Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    int count = 0;
    vector<int> res(1);
    for(int i = 0;i < S.size();i++){
        if(S.at(i) == 'A'||S.at(i) == 'T'||S.at(i) == 'G'||S.at(i) == 'C'){
            res.at(count)++;
        }else{
            res.push_back(0);
            count++;
        }
        
    }
    sort(res.rbegin(),res.rend());
    cout <<res.at(0)<<endl;
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

ll mul(ll a, ll b) {
    if (a*b/a != b) return oo;
    return min(oo, a*b);
}

int n, x[maxN], y[maxN], t[maxN];

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d%d%d", &t[i], &x[i], &y[i]);

    fto(i, 1, n) {
        int d = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if (d > t[i]-t[i-1] || d%2 != (t[i]-t[i-1])%2) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");

    return 0;
}


Measured memory_bytes: 1408
// atcoder/abc162/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int k;
  while (cin >> k) {
    lli sum = 0;
    for (int a = 1; a <= k; ++a) {
      for (int b = 1; b <= k; ++b) {
        for (int c = 1; c <= k; ++c) {
          sum += __gcd(__gcd(a, b), c);
        }
      }
    }
    cout << sum << endl;
  }

  return 0;
}


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

int main(){
  ll Q;
  cin >> Q;
  rep(i,Q){
    ll a,b,t;
    cin >> a >> b;
    if(a>b)swap(a,b);
    t=(ll)sqrt(a*b-1);
    while((t+1)*(t+1)<a*b) t++;
    while(t*t>=a*b)t--;
    if(a==b||a+1==b){
      cout << 2*a-2 << endl;
    }else if(t*(t+1)>=a*b){
      cout << 2*t-2 << endl;
    }else{
      cout << 2*t-1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans[10002];
  for(int i=0;i<10002;i++){
    ans[i]=0;
  }
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k =1;k<=100;k++){
        int v=i*i+j*j+k*k+i*j+j*k+k*i;
          if (v>10000) continue;
          else  ans[v]+=1;
        }
      }
    }
  for(int i=1;i<=N;i++){
    cout << ans[i] << endl;
  }
return 0;
}

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

int main(){

    long long N;
    cin >> N;

    string ans = "";
    while(N){
        char c = 'a';
        c += (N - 1) % 26;
        ans += c;
        N = (N - 1) / 26;
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    int N;
    int X;
    cin >> N;
    ll a = 0, b = 0;
    int max = 0;
    for (auto i = 0; i < N; i++) {
        cin >> X;
        a += X*X;
        b += 2*X;
        max = std::max(max, X);
    }
    int P = 1;
    ll ret = a - b * P + N * P * P;
    for (auto i = 2; i <= max; i ++) {
        ll r = a - b * i + N * i * i;
        ret = std::min(ret, r);
    }
    cout << ret << endl;
    return 0;
}

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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int cnt;

void printvector2(vector<int> v) {
    REP(i,v.size()-1) {
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
}

void bubblesort(vector<int> &v) {
    int N = v.size();
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int j = N-1; j > 0; j--) {
            if (v[j] < v[j-1]) {
                cnt++;
                int temp = v[j];
                v[j] = v[j-1];
                v[j-1] = temp;
                flag = 1;
            }
        }
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> v;
    REP(i,N) {
        int j;
        cin >> j;
        v.push_back(j);
    }
    bubblesort(v);
    printvector2(v);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
int T;
map <ll,ll> m;
const ll d[]={2,3,5};
ll cost[3];
ll bs;

inline ll pre(ll x,ll m)
{
	return ((ll)(x/m)*m);
}

inline ll nxt(ll x,ll m)
{
	return (ceil(x,m)*m);
}

int lenmul(ll a,ll b)
{
	return (log(a)+log(b))/log(10);
}

ll dfs(ll x)
{
	if(m.count(x)) return m[x];
	ll res=1LL*inf*inf;
	for(int i=0;i<3;i++)
	{
		ll a=pre(x,d[i]);
		ll b=nxt(x,d[i]);
		res=min(res,(x-a)*bs+dfs(a/d[i])+cost[i]);
		res=min(res,(b-x)*bs+dfs(b/d[i])+cost[i]);
	}
	if(lenmul(x,bs)<=16) res=min(res,x*bs); 
	m[x]=res;
	return res;
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>T;
	ll n;
	while(T--)
	{
		cin>>n>>cost[0]>>cost[1]>>cost[2]>>bs;
		m.clear();
		m[0]=0;
		m[1]=bs;
		cout<<dfs(n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4508
import java.math.BigDecimal;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        String line = sc.nextLine();
        check(num, line);
    }

    public static void check(String num, String line) {
        int cnt = Integer.parseInt(num);
        String[] strs = line.split(" ");
        int[] nums = new int[strs.length];
        for(int i=0; i<strs.length; i++) {
            nums[i] = Integer.parseInt(strs[i]);
        }
        Arrays.sort(nums);
        int size = cnt/2;
        if(nums[size-1]==nums[size]) {
            System.out.println(0);
            return;
        }
        System.out.println(nums[size]-nums[size-1]);
    }
}

Measured memory_bytes: 49664
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_S = 100;
string S;
bool changed[MAX_S];
ll K;

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

  cin >> S;
  cin >> K;
  
  if (len(S) == 1) {
    cout << K/2 << endl;
    return 0;
  }

  bool isAllSame = true;
  for (int i = 1; i < len(S); ++i) {
    if (S[i-1] != S[i]) {
      isAllSame = false; break;
    }
  }

  if (isAllSame) {
    cout << (K*len(S))/2 << endl;
    return 0;
  }

  ll ans = 0;
  for (int i = 1; i < len(S); ++i) {
    if (!changed[i-1] && S[i-1] == S[i]) {
      ++ans;
      changed[i] = true;
    }
  }

  if (!changed[len(S)-1] && S[0] == S[len(S)-1]) {
    int sequence = 1;
    for (int i = 1; i < len(S); ++i) {
      if (S[i-1] == S[i]) ++sequence;
      else break;
    }
    if (sequence%2 == 0) ans = ans * K;
    else ans = ans + (ans+1) * (K-1);
  } else {
    ans = ans * K;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
As = list(map(lambda x: int(x)//2, input().split()))

from fractions import gcd
from math import ceil

cnt = 1
flg = True
while 1:
    num = 2**cnt
    lis = [1 if x%num==0 else 0 for x in As]
    s = sum(lis)
    if s==N:
        cnt+=1
        continue
    elif s==0:
        break
    else:
        flg = False
        break

if flg:
    lcm = As[0]
    for i in range(1, N):
        a = As[i]
        lcm = a*lcm//gcd(lcm, a)
    
    print(ceil((M//lcm)/2))
else:
    print(0)


Measured memory_bytes: 121496
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  vin c(n-1),s(n-1),f(n-1);
  rep(i,0,n-1){
     cin>>c[i]>>s[i]>>f[i];    //i から　間　start 周期
  }
  ///////// station  0index
  rep(i,0,n){//i駅から 0
                int ans=0;
                if(i==n-1) {
                  cout<<0<<endl;
                  break;
                }
                else{
                  ans+=s[i];  
                  ans+=c[i];//i+1に到着
                          rep(j,1,n-i-1 ){
                              if(ans<s[i+j]){
                               ans=s[i+j];
                               ans+=c[i+j];//i+2に到着
                              }
                              else{
                               while(ans%f[i+j]!=0){
                                ans++; 
                               }
                                ans+=c[i+j];
                              }
                               //cout<<i<<i+j<<ans<<endl;
                          }
                     
                }
                 cout<<ans<<endl;
  }
}









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

int main(){
    int x, a, b;
    string s;
    while(1){
        cin >> a >> s >> b;
        if(s == "?"){
            break;
        }
        if(s == "+"){
            x = a + b;
        }
        else if(s == "-"){
            x = a - b;
        }
        else if(s == "*"){
            x = a * b;
        }
        else if(s == "/"){
            x = a / b;
        }
        cout<<x<<endl;
    }
   
}


Measured memory_bytes: 3148
/**
 *      ///----- My Info -----///
 *      Code by: Unk
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      CopyRight
**/
#include <bits/stdc++.h>
#ifdef Ernest0_0Abreu 
#include <debug/to_string.h>
#endif
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
        ///----- My Template -----///
///===================================================================================================================================
/// Debug
#define _end cout << "\n"
#ifndef Ernest0_0Abreu
#define db(x) ;
#define dbrange(x,begin,end) ;
#define dbname(x) ;
#define dbnamerange(x,begin,end) ;
#define dbmat(x,begin_n,end_n,begin_m,end_m) ;
#define dbST(x,end) ;
#define db_end ;
#endif
///Function
#define pi (acos(-1))
#define lg2(x) ( 31-__builtin_clz(x) )
#define lgx(x,n) ( log(n) / log(x) )
/// Macros
#define fst first
#define scd second
#define left (node<<1)
#define right ((node<<1)+1)
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/// Constant
const int MAXN = 1e6+7;
const int MOD = 1e9+17;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
const ll oo = 2e18;
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027, 3079, 10079;
/// Module Prime Numbers: 3, 200017, 1000033, 998244353, 1000000007, 1000000009, 1000000021;
#define int long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
///===================================================================================================================================
        ///----- My code -----///



int32_t main(){
    
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

 	int N;
 	cin >> N;
 	int x = N%10;
 	if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout << "hon";
 	if(x == 0 || x == 1 || x == 6 || x == 8) cout << "pon";
 	if(x == 3) cout << "bon";
         
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstring>

using namespace std;

struct Data{
	int len;
	char data;
};

int n, j=0;
Data val[50];

int solve(){
	int ans, depth = val[j].len;
	char c=val[j++].data;
	if(c=='+')ans=0;
	else if(c=='*') ans=1;

	while(j<n && val[j].len > depth){
		if(isdigit(val[j].data)){
			if(c=='+')ans+=val[j++].data-'0';
			else if(c=='*') ans*=val[j++].data-'0';
		} else{
			if(c=='+')ans+=solve();
			else if(c=='*') ans*=solve();
		}
	}
	return ans;
}

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		for(int j=0; j<n; j++){
			val[j].len = 0;
			val[j].data = '\0';
		}

		char tmp[50];
		for(int i=0; i<n; i++){
			cin >> tmp;
			val[i].len = strlen(tmp);
			val[i].data= tmp[strlen(tmp)-1];
		}
		j=0;
		if(n==1) cout << val[j].data << endl;
		else cout << solve() << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-02 19:49:51
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<map>
#include<algorithm>
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
ll  n=0, k,m; //variables
long long w,x;
ll  a, b, d;
ll c;
ll p=100.0;
string s;
set<string>st;
ll i;
int main() {
	cin>>a>>b>>n;
	if(b==1){
		cout<<0;
	}
	else if(n<b){
		cout<<floor((a*n)/b)-a*floor(n/b);
	}
	else{
		m=0;
		for(i=1;b*i-1<=n;i++){
			w=b*i-1;
			d=(floor((a*w)/b)-a*floor(w/b));
			m=max(m,d);

		}
		cout<<m;
	}
	

	return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
   int N,L; cin >> N >> L;
   vector<string> S(N);
   rep(i,N){
     cin >> S[i];
   }
   sort(S.begin(),S.end());
   string ans = "";
   rep(i,N){
      ans += S[i];
   }
   cout << ans << endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
const ll mod = 1e9+7;
const int inf  = 0x3f3f3f3f;

struct cmp
{
	bool operator()(const pii & a, const pii & b)
	{
		return a.second > b.second;
	}
};

const int maxn = 2e5+5;
int a[maxn];
int b[maxn];
int c[maxn];
std::vector<int> vv;
map<int,int> mm;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i =1 ; i <= n; i ++ )
		scanf("%d",&a[i]);
	for (int i = 1; i <= n; i ++ )
	{
		b[i] = i - a[i];
		c[i] = a[i] + i;
		vv.push_back(c[i]);
	}
	ll ans =0 ;
	for (int i = 1; i <= n; i ++ )
	{
		ans += mm[b[i]];
		mm[c[i]] ++ ;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 23128
//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int 
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repr(i,a,b) for(int i=(a);i>(b);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
/*******************************************************************************************/
/*******************************************************************************************/
template<typename T> T maxi(T a , T b) {return a>b ? a : b;}
template<typename T> T mini(T a , T b) {return a<b ? a : b;}
int fpow(int x, int y, int p); 
int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>tcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n ,w;
    cin>>n >> w;
    vector<int> v(n) , wt(n);
    rep(i , 0 , n)
        cin>> wt[i] >> v[i];
    //cout<<v<<wt;  
    int dp[n+1][w+1];
    rep(i , 0 , w+1)
        dp[0][i] = 0;
    rep(i , 0 , n+1)
        dp[i][0] = 0;
    rep(i , 1 , n+1)
        rep(j , 1 , w+1)
        {
            if(j >= wt[i-1])
            dp[i][j] = maxi( v[i-1] + dp[i-1][j - wt[i-1] ] , dp[i-1][j] );
            else
            dp[i][j] = dp[i-1][j];            
        }
    cout<<dp[n][w];
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


Measured memory_bytes: 79232
#include <cstdio>
int n,a[200003],max;
long long ans;//ans要开long long
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    max=a[1];//max初值为a[1]
    for(int i=2;i<=n;i++){
        if(max>a[i]) ans+=max-a[i];
        else max=a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2484
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iostream>
using namespace std;
int main(){
    string mes[3]={"Fizz","Buzz","FizzBuzz"};
    int n,m;
    while(scanf("%d%d",&n,&m),n||m){
        bool f[10000];fill(f,f+10000,true);
        int idx=0,cnt=0;
        for(int i=1;i<=m;i++){
            while(!f[idx])idx=(idx+1)%n;
            string str;
            cin>>str;
            if(cnt+1==n)continue;
            int state=-1;
            if(i%3==0)state=0;
            if(i%5==0)state=1;
            if(i%3==0&&i%5==0)state=2;
            stringstream ss;
            ss<<i;
            string s;
            ss>>s;
            if(state==-1){
                if(s!=str){
                    f[idx]=false;cnt++;
                }
            }
            else{
                if(mes[state]!=str){
                    f[idx]=false;
                    cnt++;
                }
            }
            idx=(idx+1)%n;
        }
        bool flag=false;
        for(int i=0;i<n;i++){
            if(!f[i])continue;
            if(flag)printf(" ");
            printf("%d",i+1);
            flag=true;
        }
        puts("");
    }
    return 0;
}

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

int main() {
    int N; cin >> N;
    ll sum = 0;
    vector<int> v;
    for (int i = 0; i < N; i++)
    {
        int s; cin >> s;
        sum +=s;
        if(s%10!=0) v.push_back(s);
    }
    sort(v.begin(), v.end());
    if(sum%10==0){
        if(v.size()>0) cout << sum - v[0] << endl;
        else cout << 0 << endl;
    } 
    else cout << sum << endl;
        
}

Measured memory_bytes: 256
l = [True]*10000000

s = int(input())
l[s] = False
for i in range(2, 100000000):
  if s % 2 == 0:
    s //= 2
  else:
    s = 3*s + 1
  if l[s]:
    l[s] = False
  else:
    print(i)
    break

Measured memory_bytes: 81140
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
typedef long long ll;
using namespace std;
ll a[1000];
int main()
{
    ll t,n,k,ans,m;
    scanf("%lld %lld",&n,&m);
    ans=n*(n-1)/2+m*(m-1)/2;


    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c;
  cin >> a >> b >> c;
  if (min(a, b) < c && max(a, b) > c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256