akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	map<string, int> mp;
	string tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		mp[tmp]++;
	}
	
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> tmp;
		mp[tmp]--;
	}

	int ans = 0;
	for (auto &e : mp) { ans = max(ans, e.second); }

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<ll>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll n;
	cin>>n;
	if(n==1){
	    cout<<"Yes"<<endl;
	    cout<<2<<endl;
	    cout<<"1 1"<<endl;
	    cout<<"1 1"<<endl;
	    return 0;
	}
	if(n==2){
	    cout<<"No"<<endl;
	    return 0;
	}
	ll d=floor(sqrt(n*2))+1;
	if(d*d-d!=n*2){
	    cout<<"No"<<endl;
	    return 0;
	}
	vvi ans(d);
	int p=0,q=1;
	rep(i,n){
	    ans[p].push_back(i+1);
	    ans[q].push_back(i+1);
	    if(++q==d){
	        q=++p+1;
	    }
	}
    cout<<"Yes"<<endl;
    cout<<d<<endl;
    rep(i,d){
        cout<<ans[i].size()<<" "<<ans[i]<<endl;
    }
	return 0;
}


Measured memory_bytes: 3200
def move(tt, xx, yy)
  xx.abs + yy.abs <= tt && (xx + yy) % 2 == tt % 2
end

n = gets.to_i
t, x, y = 0, 0, 0
n.times do
  tn, xn, yn = gets.split.map(&:to_i)
  t, x, y = tn - t, xn - x, yn - y
  unless move(t, x, y)
    puts 'No'
    exit
  end
end
puts 'Yes'


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

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> c(N), t(N);
    for(int i = 0; i < N; i++) {
        cin >> c[i] >> t[i];
    } 
    int MIN = 1 << 30; //INF
    for(int i = 0; i < N; i++) {
        if (T >= t[i]) {
            MIN = min(MIN, c[i]);
        }
    }
    if (MIN == 1 << 30) {
        cout << "TLE" << endl;
    } else {
        cout << MIN << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==0)cout<<n;
    vector<long long>sei(1,1);
    vector<long long>hu(1,2);
    vector<long long>sei_sum(1,1);
    vector<long long>hu_sum(1,2);
    for(int i=0;sei_sum[i]<abs(n)*2;i++){
        sei.push_back(sei[i]*4);
        hu.push_back(hu[i]*4);
        sei_sum.push_back(sei_sum[i]+sei[i+1]);
        hu_sum.push_back(hu_sum[i]+hu[i+1]);
    }
    vector<int>ans(sei.size()*2,0);
    while(true){
        int x;
        if(n==0)break;
        if(n>0){
            int x=lower_bound(sei_sum.begin(),sei_sum.end(),n)-sei_sum.begin();
            ans[x*2]=1;
            n-=sei[x];
        }
        if(n<0){
            int x=lower_bound(hu_sum.begin(),hu_sum.end(),-1*n)-hu_sum.begin();
            ans[x*2+1]=1;
            n+=hu[x];
        }
    }
    while(ans.back()==0)ans.pop_back();
    for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,d;
    ll ans;
    ll count1=-100000000000000000000;
    cin>>a>>b>>c>>d;


        ans=b*d;
        count1=max(count1,ans);



        ans=a*d;
        count1=max(count1,ans);



        ans=c*b;
        count1=max(count1,ans);



        ans=a*c;
        count1=max(count1,ans);

    cout<<count1<<endl;
}



Measured memory_bytes: 3532
N = int(input())
A = list(map(int, input().split()))
absa = [abs(a) for a in A]
m = 0
for a in A:
    if a < 0:
        m += 1
if m % 2 == 0:
    print(sum(absa))
else:
    print(sum(absa) - min(absa)*2)

Measured memory_bytes: 65184
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll fun(ll a){
    ll ans = 1;
    ll mod = 1000000007;
    for(ll i = 1; i <= a; i++)
        ans = ans * i % mod;
    return ans;
}
ll comb(ll n, ll r){
    ll child = 1, mother = 1;
    ll mod = 1000000007;
    for(ll i = 1; i <= r; i++){
        child = child * (n-i+1) % mod;
        mother = mother * i % mod;
    }
    //mother = modpow(mother, mod-2, mod);
    ll ans = child / mother;
    return ans;
}

int main(void){
    ll n, k;
    cin >> n >> k;
    ll INF = 1e+9+7;
    ll ans = 0;
    ll sum[n+1];
    for(ll i = 0; i <= n; i++){
        if(i==0) sum[i] = 0;
        else sum[i] = sum[i-1]+i;
    }
    for(ll i = k; i <= n; i++){
        ll a = sum[n]-sum[n-i];
        ll b = sum[i-1];
        ll c = a-b+1;
       // cout << a << " " << b << " " << ans << endl;
        ans = (ans + c)%INF;
    }
    ans = (ans+1)%INF;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5148
# Import
from collections import deque
import math

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.isP, self.P = self.compute(N)

    def compute(self, N):
        isP, P = [True] * (N + 1), []
        for i in range(2, N+1):
            if isP[i]:
                P.append(i)
                for j in range(2*i, N+1, i):
                    isP[j] = False
        return isP, P

    def factorization(self, x):
        ret, MAX_P = [], math.sqrt(x)
        for p in self.P:
            if p > MAX_P:
                break
            cnt = 0
            while x % p == 0:
                x /= p
                cnt += 1
            ret.append((x, cnt))
        if x > 1:
            ret.append((x, 1))
        return ret

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p, cnt in pn.factorization(N):
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
print(ans)

Measured memory_bytes: 82520
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	int cnt = 1;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1]) cnt++;
	}
	cnt -= 2 * k;
	chmax(cnt, 1);
	cout << n - cnt << endl;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd3(a, b, c int) int {
	return gcd(gcd(a, b), c)
}

// 文字列を1行取得
func StrStdin() (stringInput string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput = scanner.Text()

	stringInput = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

func main() {
	K, _ := IntStdin()

	ans := 0
	// for i := 1; i <= K; i++ {
	// 	for j := i; j <= K; j++ {
	// 		for k := j; k <= K; k++ {
	// 			a := gcd3(i, j, k)
	// 			if i == j && j == k {
	// 				ans += a
	// 			} else if i == j || j == k {
	// 				ans += a * 3
	// 			} else {
	// 				ans += a * 3 * 2
	// 			}
	// 		}
	// 	}
	// }
	// // 全探索バージョン
	// for i := 1; i <= K; i++ {
	// 	for j := 1; j <= K; j++ {
	// 		for k := 1; k <= K; k++ {
	// 			ans += gcd(gcd(i, j), k)
	// 		}
	// 	}
	// }

	// gcd(i, j) を k-loop の外でやるバージョン
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			tmp := gcd(i, j)
			for k := 1; k <= K; k++ {
				ans += gcd(tmp, k)
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1784
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
x, y = 0, 0
ans = 10**20
for i in range(N-1):
  x += A[i]
  y = sum_A - x
  ans = min(ans, abs(x-y))
print(ans)

Measured memory_bytes: 24832
ct=0
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for l in range(N)]

for i in range(N):
    a=0
    for j in range(M):
        a+=A[i][j]*B[j]
    if a+C>0:
        ct+=1
    else:
        pass
print(ct)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int x[4]={0},y[4]={0};
  int i;

  for(i=0;i<2;i++){
    scanf("%d%d",&x[i],&y[i]);
  }
  printf("%d %d %d %d\n",x[1]+y[0]-y[1],y[1]-(x[0]-x[1]),x[0]+y[0]-y[1],y[0]-(x[0]-x[1]));
  return 0;
}

Measured memory_bytes: 128
n,m = map(int, input().split())
num_list = []
for i in range(n):
  num_list.append(list(map(int,input().split())))
check_list = []
for i in range(m):
  check_list.append(list(map(int,input().split())))

for i in range(n):
  d = 10**9
  h = 0
  for j in range(m):
    if d > (abs(num_list[i][0]-check_list[j][0])+abs(num_list[i][1]-check_list[j][1])):
      d = abs(num_list[i][0]-check_list[j][0])+abs(num_list[i][1]-check_list[j][1])
      h = j+1
  print(h)

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

struct Bank{
    int b;
    int r;
    int t;
    double p;
};

int main(){
    int n;
    while(cin >> n, n){
        struct Bank bank[n];
        int y;
        cin >> y;
        for(int i=0; i<n; ++i){
            int b, r, t;
            cin >> b >> r >> t;
            bank[i].b = b;
            bank[i].r = r;
            bank[i].t = t;
        }
        double max = -1.0;
        int max_bank;
        for(int i=0; i<n; ++i){
            if(bank[i].t == 1){
                bank[i].p = 1 + y * (bank[i].r/100.0);
                if(bank[i].p > max){
                    max = bank[i].p;
                    max_bank = bank[i].b;
                }
            }else{
                double p = bank[i].p = 1 + (bank[i].r/100.0);
                for(int j=1; j<y; ++j){
                    bank[i].p *= p;
                }
                if(bank[i].p > max){
                    max = bank[i].p;
                    max_bank = bank[i].b;
                }
            }
        }
        cout << max_bank << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    auto p = [&](){REP(i, n) cout << a[i] << (i == n - 1 ? endl : ' ');};

    REP1(i, n - 1) {
        p();
        REPR(j, i) {
            if (a[j] <= a[j + 1]) break;
            swap(a[j], a[j + 1]);
        }
    }
    p();
}




Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int N,x; cin>>N>>x;
    if(x==1||x==N*2-1){
        cout<<"No"<<endl;
        return 0;
    }
    
    if(N==2){
        cout<<"Yes"<<endl;
        cout<<1<<" "<<2<<" "<<3<<endl;
        return 0;
    }
    
    deque<int> ans;
    int size=N*2-5;
    if(x==2){
        ans.push_back(3);
        ans.push_back(2);
        ans.push_back(1);
        ans.push_back(4);
        REP(i,size){
            if(i%2==0)ans.push_front(i+5);
            else ans.push_back(i+5);
        }
    }else if(x==N*2-2){
        ans.push_back(x-2);
        ans.push_back(x+1);
        ans.push_back(x);
        ans.push_back(x-1);
        REP(i,size){
            if(i%2==0)ans.push_back(x-3-i);
            else ans.push_front(x-3-i);
        }
    }else{
        bool used[200010];
        REP(i,200010)used[i]=false;
        used[x-2]=used[x+1]=used[x]=used[x-1]=true;
        ans.push_back(x-2);
        ans.push_back(x+1);
        ans.push_back(x);
        ans.push_back(x-1);
        int cnt=0;
        for(int i=1;i<=N*2-1;i++){
            if(!used[i]){
                if(cnt%2==0){
                    ans.push_back(i);
                }else{
                    ans.push_front(i);
                }
                cnt++;
            }
        }
    }
    
    cout<<"Yes"<<endl;
    
    int kai=(int)ans.size();
    REP(i,kai-1){
        cout<<ans.front()<<" ";
        ans.pop_front();
    }
    
    cout<<ans.front()<<endl;
    
    return 0;
}


/*
int middle(int a, int b, int c){
    vector<int> res={a,b,c};
    sort(res.begin(),res.end());
    return res[1];
}

int main(){
    
    vector<int> a={1,2,3,4,5,6,7};
    do{
        vector<int> t=a;
        for(int i=1;i<=a.size()/2;i++){
            vector<int> tt=t;
            for(int j=i;j<a.size()-i;j++){
                tt[j]=middle(t[j-1],t[j],t[j+1]);
            }
            t=tt;
        }
        if(t[t.size()/2]==6)REP(i,a.size())cout<<a[i]<<" ";
        if(t[t.size()/2]==6)cout<<":"<<t[t.size()/2]<<endl;
    }while(next_permutation(a.begin(),a.end()));
    
    return 0;
}*/



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    int cnt=0,ans=0;
    string s; cin>>s;
    rep(i,s.size()){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt++;
        }else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    c(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
  int main(){
     int i,cnt=0;
     double sum[1000];
     double s[11]={0};
      while(scanf("%lf",&s[1])!=EOF){
          sum[cnt]=s[1];
          for(i=2;i<=10;i++){
              if(i%2!=0){
                  s[i]=s[i-1]/3;
              }else{
                  s[i]=s[i-1]*2;
              }
              sum[cnt]=sum[cnt]+s[i];
          }
          cnt++;
      }
      for(i=0;i<cnt;i++){
          printf("%.9f\n",sum[i]);
      }
     return 0;
 }

Measured memory_bytes: 660
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,M;
vector<int> A(SIZE);

void solve(int _t) {
    cin>>N;
    cout << (N>=30 ? "Yes" : "No") << endl;
    //_PN(ans);
}
EXEC(1)



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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    double n; cin >> n;
    cout << ceil(1.0*(n/2)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int a[100003];     
int main(){
	fastIO;         
	int n,x;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long ans=0;
	for(int i=1;i<n;i++){
		int aux=a[i]+a[i-1];	
		if(aux>x){
			ans+=(aux-x);
			a[i]-=(aux-x);
			if(a[i]<0){    
				a[i-1]=a[i-1]+a[i];
				a[i]=0;
			}
		}	
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll X;
    cin >> X;
    ll x = 1;
    ll ans = 0;
    while (1) {
        if ((x * 360) % X == 0) {
            ans = (x * 360) / X;
            break;
        }
        x++;
    }
    cout << ans << endl;
    //if (360 % X == 0)
    //    cout << 360 / X << endl;
    //else
    //    cout << (180 * 4) / X << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>

using namespace std;

int main(){
    int x,y,i;
    i = 1;
    while (i > 0){
        cin >> x >> y;
        if (x == 0 and y == 0){
            i = 0;
        }
        else{
            if (x>y){
                cout << y << " " << x << endl;
            }
            else{
                cout << x << " " << y << endl;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 3068
def main():

    s = input()
    xcount = 0
    i, j = 0, len(s)-1
    ans = 0
    while i < j:
        if s[i] != s[j]:
            if s[i] == "x":
                i += 1
                ans += 1
            elif s[j] == "x":
                j -= 1
                ans += 1
            else:
                return -1
        else:
            i += 1
            j -= 1
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3316
A,B = map(int,input().split())
if A == B == 1:
    print("Draw")
if A == 1 and B != 1:
    print("Alice")
if B == 1 and A != 1:
    print("Bob")
if A != 1 and B != 1:
    if A > B:
        print("Alice")
    elif A < B:
        print("Bob")
    else:
        print("Draw")
        

Measured memory_bytes: 3060
n = input()
# n, k = map(int, input().split())
p = list(map(int, input().split()))
# s = input().split()
list =[]


for i in p:
    if i % 2 == 0:
        list.append(i)

count = 0
for i in list:
    if i % 3 == 0 or i % 5 == 0:
        count += 1

if len(list) == count:
    print('APPROVED')
else:
    print('DENIED')

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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

ll ncm(ll n, ll m, ll mod){
  ll ans = 1;
  rep(i, m){
    ans *= (n-i);
    ans %= mod;
    ans *= pow(i+1, mod - 2, mod);
    ans %= mod;
  }
  return ans;
}

void solve(){
  const ll mod = 1000000000 + 7;
  int X, Y;
  cin >> X >> Y;

  int a = 2*X - Y;
  int b = 2*Y - X;
  if(a < 0 || b < 0){
    cout << 0 << endl;
    return;
  }
  if(a % 3 != 0 || b % 3 != 0){
    cout << 0 << endl;
    return;
  }

  a /= 3;
  b /= 3;

  cout << ncm(a + b, b, mod) << endl;
}

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

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
from collections import deque

A = deque(list(map(int, input().split())))
nuriwake = 1
ans = []
for i in range(H):
    t = []
    for j in range(W):
        if A[0] == 0:
            A.popleft()
            nuriwake += 1
        A[0] -= 1
        t.append(nuriwake)
    if i % 2 != 0:
        t = reversed(t)
    ans.append(t)
for a in ans:
    print(' '.join(map(str, a)))


Measured memory_bytes: 9732
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int P=1000000007;
const int N=5005;
inline int Pow(int a,int b){
    int c=1;
    for(;b;b>>=1,a=a*1ll*a%P)if(b&1)c=c*1ll*a%P;
    return c;
}
void dec(int &a,int b){a-=b;if(a<0)a+=P;}
void add(int &a,int b){a+=b;if(a>=P)a-=P;}
int n,m;
char s[N];
int f[N][N];
int main(){
    scanf("%d",&n);scanf("%s",s+1);
    m=strlen(s+1);
    f[0][0]=1;
    rep(i,0,n-1)rep(j,0,n)if(f[i][j]){
        add(f[i+1][max(0,j-1)],f[i][j]);
        add(f[i+1][j+1],f[i][j]*2%P);
    }
    printf("%d\n",f[n][m]*1ll*Pow(Pow(2,P-2),m)%P);
    return 0;
}




Measured memory_bytes: 96384
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  string s,t;cin>>s>>t;

  string ans="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  for(int i=0;i+t.size()-1<s.size();i++){
    bool flag=true;
    string temp=s;
    for(int j=0;j<t.size();j++){
      if(s[i+j]!=t[j]&&s[i+j]!='?'){
        flag=false;
        break;
      }
      temp[i+j]=t[j];
    }
    if(flag){
      for(int k=0;k<s.size();k++){
        if(temp[k]=='?')temp[k]='a';
      }
      ans=min(ans,temp);
    }
  }
  if(ans=="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"){
    cout<<"UNRESTORABLE"<<"\n";
  }else{
    cout<<ans<<"\n";
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - A+...+B Problem
https://atcoder.jp/contests/agc015/tasks/agc015_a

"""
import sys


def solve(N, A, B):
    if A > B:
        return 0
    if N == 1 and A != B:
        return 0
    left = A * (N - 2)
    right = B * (N - 2)
    return right - left + 1


def main(args):
    N, A, B = map(int, input().split())
    ans = solve(N, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

// DATA TYPES
typedef long long ll;
#define double long double
//

// CONTAINERS
#define vec vector
#define pb push_back
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)x.size()
#define mp make_pair
#define ii pair<int, int>
#define F first
#define S second
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &L, const std::pair<T,U> &R) {
  return {L.first + R.first, L.second + R.second};
}
//

// LOOP
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
//

// BIT
#define bitcount(n) __builtin_popcountll(n)
//

// DEBUG
#define format(x) << #x << ": " << (x)
#define com << ", "
#define ndl << "\n"
#define debug1(x) cerr format(x) ndl;
#define debug2(x, y) cerr format(x) com format(y) ndl;
#define debug3(x, y, z) cerr format(x) com format(y) com format(z) ndl;
void debug_out() { cerr << "\n"; }
template <typename H, typename... T> 
void debug_out(H h, T... t) { cerr << " " << (h); debug_out(t...); }
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
// 

// CONSTANTS
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
//

// NUMERICAL OPERATIONS
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

int norm(int a) {
  return ((a % MOD) + MOD) % MOD;
}

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

int binPow(int a, int k) {
  int ans = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
  }
  return ans;
}

// If I need to find (x / a) % MOD, I need to use this function:
//    (x / a) % MOD = (x * inv(a)) % MOD
int inv(int a) {
  int b = binPow(a, MOD - 2);
  assert(mul(a, b) == 1);
  return b;
}
//

// Init variables here
const int N = 1e6 + 7;

void init() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);

}

void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  priority_queue<int> pq;
  int price;
  FOR(i, 0, n) {
    scanf("%d", &price);
    pq.push(price);
  }
  while (m and pq.size()) {
    m--;
    price = pq.top(); pq.pop();
    price /= 2;
    if (price) pq.push(price);
  }
  ll res = 0;
  while (pq.size()) {
    res += pq.top(); pq.pop();
  }
  printf("%lld\n", res);
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  //ios_base::sync_with_stdio(false); cin.tie();
  //auto beginProgram = chrono::steady_clock::now();
  //int t; scanf("%d", &t); while (t--) 
  {
    init();
    solve();
  }
  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}
vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for(long long p = 2; p * p <= n; ++p) {
        if(n % p != 0)
            continue;
        int num = 0;
        while(n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if(n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}

//二項定数のやつ
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    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;
    }
}
long long 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;
}
int main() {
    int N, M;
    COMinit();
    cin >> N >> M;
    auto vec = prime_factorize(M);
    long long res = 1;
    for(auto pa : vec) {
        int num = pa.second;
        long long tmp = COM(num + N - 1, num);
        res = (res * tmp) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 5120
<?php

$S = trim(fgets(STDIN));
$word = ['dreamer','eraser','dream','erase'];
$T = strrev($S);#逆順にする
$reserveword = [];
foreach($word as $w){
    $reserveword[] = strrev($w);#逆順にする
}
#echo "origin:".$T.PHP_EOL;
for($i=0; $i<strlen($T);){
    $is_exists = false;
    foreach($reserveword as $w){
        $index = strpos($T, $w, $i);#1文字ずつ移動して比較する
        #echo "parts:".$w.PHP_EOL;
        if($i === $index){#===で比較すること
            $is_exists = true;
            $i+=strlen($w);
        }
        #echo "result:".$T.PHP_EOL;
    }
    if($is_exists === false){
        break;
    }
}
        
echo $is_exists ? "YES" : "NO";


?>

Measured memory_bytes: 4604
#include <stdio.h>

int main(){
	int a, b, ans;
	scanf("%d%d", &a, &b);
	
	ans = a + b;
	ans = (a-b)>ans ? a-b : ans;
	ans = (a*b)>ans ? a*b : ans;
	
	printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 128
y = []
while True:
    n = int(input())
    if n == 0:
        break
    x = list(map(float,input().split()))
    m = sum(x)/n
    v = list(map(lambda l: (l-m)**2,x))
    y.append((sum(v)/n)**0.5)
for i in range(len(y)):
    print(y[i])


Measured memory_bytes: 5732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, m;
  pair<int,int> p[SIZE];

  scanf("%d%d", &n, &m);


  for(int i=0;i<n;i++){
    int a, b;
    scanf("%d%d", &a, &b);
    p[i] = {a, b};
  }

  sort(p, p+n);

  ll ans = 0;

  for(int i=0;i<n && m > 0;i++){
    ans += (ll)min(p[i].second, m) * p[i].first;
    m -= p[i].second;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;


int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n; cin >> n;
	cout << (1000 - n%1000)%1000;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
bool isprime(int k){
    for(int i=2;i*i<=k;i++){
        if(k%i==0)return false;
    }
    return true;
}
int main() {
long long x;
cin >> x;
for(int j=x;j<10000000;j++){
    if(isprime(j)){cout <<j;
    break;}
}
}


Measured memory_bytes: 256
#include <stdio.h>

int cnt=1;
int oya[500010];
int ko[2][500010];
int val[500010];

int f(int v,int mode){
    if(mode==0)printf(" %d",val[v]);
    if(ko[0][v])f(ko[0][v],mode);
    if(mode==1)printf(" %d",val[v]);
    if(ko[1][v])f(ko[1][v],mode);
    if(mode==2)printf(" %d",val[v]);
}
void push(int v,int va){
	//初回
	if(cnt==1){
		val[cnt]=va;
		cnt++;
		return;
	}
	if(ko[val[v]<va][v])push(ko[val[v]<va][v],va);
	else{
		ko[val[v]<va][v]=cnt;
		oya[cnt]=v;
		val[cnt]=va;
		cnt++;
	}
}

int find(int v,int va){
	if(val[v]==va)return 1;
	if(ko[val[v]<va][v])return find(ko[val[v]<va][v],va);
	return 0;
}

int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		char s[10];
		scanf("%s",s);
		if(s[0]=='p'){
			f(1,1);
			puts("");
			f(1,0);
			puts("");
		}else if(s[0]=='i'){
			int t;
			scanf("%d",&t);
			push(1,t);
		}else{
			int t;
			scanf("%d",&t);
			puts(find(1,t)?"yes":"no");
		}
	}
}


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

Measured memory_bytes: 3912
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
const int mo=1e9+7;
typedef long long ll;
ll n,m;
ll getstep(ll n)
{
	ll res=1;
	for(ll i=1;i<=n;i++) res=(res*i)%mo;
	return res;
}
ll geta(int n,int m)
{
	ll res=1;
	for(ll i=n-m+1;i<=n;i++) res=(res*i)%mo;
	return res;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	if(abs(n-m)>=2) printf("0\n");
	else{
		if(m<n) swap(n,m);
		if(m-n==1)
			printf("%lld\n",((getstep(n)%mo)*(getstep(m)%mo))%mo);
		else
			printf("%lld\n",((getstep(n)%mo)*(getstep(m)%mo)%mo)*2%mo);
	}
	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, raw_input().split())
a, b = 0, 0
for s in raw_input():
    if s == 'a' and a+b < A+B:
        print 'Yes'
        a += 1
    elif s == 'b' and a+b < A+B and b < B:
        print 'Yes'
        b += 1
    else:
        print 'No'


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s == "ABC")
            cout<<"ARC";
        else
        cout<<"ABC";
        
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 3624
from bisect import bisect_left,bisect
N = int(input())
info = [sorted(list(map(int,input().split()))) for i in range(3)]
ans = 0
for j in range(N):
    small = bisect_left(info[0],info[1][j])
    large = N - bisect(info[2],info[1][j])
    ans += small * large
print(ans)

Measured memory_bytes: 23076
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007
int a,b;
int go(int n){
	if(n<0) return 0;
	return (((a*n)/b)-(a*(n/b)));
}
void solve(){
	int n;
	cin>>a>>b>>n;
	int ans = max(go(n),go(n-1));
	ans = max(ans, go(n/2));
	ans = max(ans, go((n/2)+1));
	ans = max(ans, go((n/2)-1));
	if(b-1 <= n) ans = max(ans, go(b-1));
	cout<<max(ans,(int)0)<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


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

int N, M, Q;

vector<vector<int>> sum;
void buildSumTable(vector<int> L, vector<int> R)
{
    sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
    for (int i = 0; i < M; i++)
    {
        sum[L[i]][R[i]]++;
    }

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        }
    }
}

int getSumRange(int L, int R)
{
    return sum[R][R] - sum[L - 1][R] - sum[R][L - 1] + sum[L - 1][L - 1];
}

int main()
{
    cin >> N >> M >> Q;
    vector<int> L(M);
    vector<int> R(M);

    for (int i = 0; i < M; i++)
    {
        cin >> L[i] >> R[i];
    }

    vector<int> p(Q);
    vector<int> q(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> p[i] >> q[i];
    }
    buildSumTable(L, R);
    for (int i = 0; i < Q; i++)
    {
        cout << getSumRange(p[i], q[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 5120
x = 0
y = 0
an = 0
from math import *
PI = 3.1415926535898
while True:
	try:
		st, ag = map(float, raw_input().strip().split(','))
		if st == 0 and ag == 0:
			print int(x)
			print int(y)
		else:
			x += st*sin(an*PI/180)
			y += st*cos(an*PI/180)
			an += ag
	except EOFError:
		break

Measured memory_bytes: 6660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vvi;
typedef vector<vector<double> > vvd;

int main(){

    int N;
    cin >> N;
    vvi map(2, vi(N,0));

    int x;
    for(int i=0; i<N; ++i){
        cin >> x;
        map[0][i] = x;
    }

    for(int i=0; i<N; ++i){
        cin >> x;
        map[1][i] = x;
    }

    vvi map_memo(2, vi(N, 0));
    map_memo[0][0] = map[0][0];

    for(int i=1; i<N; ++i){
        map_memo[0][i] = map_memo[0][i-1] + map[0][i];
    }

    map_memo[1][0] = map[0][0] + map[1][0];

    for(int i=1; i<N; ++i){
        map_memo[1][i] = max( map_memo[0][i], map_memo[1][i-1] ) + map[1][i];
    }

    cout << map_memo[1][N-1] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      long cntR = 0;
      long cntG = 0;
      long cntB = 0;
      for(char c : s.toCharArray())
        if(c == 'R')
          cntR++;
        else if(c == 'G')
          cntG++;
        else
          cntB++;
      long cnt = cntR * cntG * cntB;
      
      long sub = 0;
      for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(s.charAt(i) == s.charAt(j)) continue;
            int k = j * 2 - i;
            if(k < n && s.charAt(i) != s.charAt(k) && s.charAt(k) != s.charAt(j)) sub++;
        }
      }
      System.out.println(cnt - sub);
  }
}

Measured memory_bytes: 28620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ll t = 1;
  while (n > 0) {
    ans += t;
    n /= 2;
    t *= 2;
  }

  cout << ans << endl;

}

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    # 終点はルート切り捨て+1
    for i in range(2, int(sqrt(num))+1):
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

def mul(C1, C2):
    return C1 + C2

def div(C1, C2):
    return C1 - C2

def gcd(C1, C2):
    return C1 & C2

def lcm(C1, C2):
    return C1 | C2

N = INT()
A = LIST()

# 素因数の状態で全体のLCMを出す
A2 = [factorize(a) for a in A]
l2 = Counter()
for a in A2:
    for k, v in a.items():
        l2[k] = max(l2[k], v)

# 通常の値に戻す
l = 1
for k, v in l2.items():
    l *= pow(k, v, MOD)
    l %= MOD

ans = 0
for a in A:
    ans += fermat(l, a, MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 53336
function main(input) {
  var a = input[1].trim().split(" ").map(e => parseInt(e, 10));
  var a_max = 10**6+1;
  var dp = new Array(a_max+1).fill(0);
  for(var i of a){
    dp[i]++;
  }
 
  for(var i=1;i<=a_max;i++){
    if(dp[i]==0){ 
      continue;
    }
    for(var j=i+i;j<=a_max;j+=i){
      if(dp[j]!=0){
        dp[j]=0;
      }
    }
  }
  console.log(dp.filter(function(x){return x==1}).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


Measured memory_bytes: 65864
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll A, B, M;
    cin >> A >> B >> M;
    VL a(A), b(B);
    vector<tuple<ll, ll, ll>> ticket(M);
    rep(i, 0, A) cin >> a[i];
    rep(i, 0, B) cin >> b[i];
    rep(i, 0, M){
        ll x, y, c;
        cin >> x >> y >> c;
        ticket[i] = make_tuple(x - 1, y - 1, c);
    }

    ll mn = INT32_MAX;

    for(tuple<ll, ll, ll> t : ticket){
        mn = min(mn, a[get<0>(t)] + b[get<1>(t)] - get<2>(t));
    }

    sort(ALL(a));
    sort(ALL(b));

    mn = min(mn, a[0] + b[0]);

    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 4096