akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int dp[400][400];

int main(){
  int n; 
  cin >> n;
  vector<int> s(n), l(n), p(n);
  rep(i, n) cin >> s[i] >> l[i] >> p[i];
  int m;
  cin >> m;
  vector<int> w(m);
  rep(i, m) cin >> w[i];
  for(int i=1; i<=n; i++) {
    rep(j, 395) {
      chmax(dp[i][j], dp[i-1][j]);
      for(int k=s[i-1]; k<=l[i-1]; k++) {
        if(j-k >= 0)
          chmax(dp[i][j], dp[i][j-k]+p[i-1]);
        else
          break;
      }
    }
  }
  rep(i, m) {
    if(!dp[n][w[i]]) {
      cout << -1 << endl;
      return 0;
    }
  }
  rep(i, m)
    cout << dp[n][w[i]] << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        ll MOD = 1000000000 + 7;
        int N;
        ll ans = 1;
        cin >> N;
        for (int i = 1; i < N + 1; i++)
        {
                ans *= i;
                ans %= MOD;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int N,W;
  cin>>N>>W;
  W++;
  int w[N],v[N];
  REP(i,N){
    cin>>w[i]>>v[i];
  }
  llong score[N][W];
  REP(i,W){
    if(i>=w[0]){
      score[0][i] = v[0];
    }else{
      score[0][i] = 0;
    }
  }

  for(int i=1;i<N;i++){
    REP(j,W){
      if(j>=w[i]){
        score[i][j] = max(score[i-1][j],score[i-1][j-w[i]] + v[i]);
      }else{
        score[i][j] = score[i-1][j];
      }
    }
  }


  cout<<score[N-1][W-1]<<endl;

  return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

map<int,int> factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
int n;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
sort(a.begin(),a.end());
map<int,int>m;
rep(i,n)m[a[i]]++;
vector<bool>furui(a[n-1]+1,true);
for(auto i:a){
  if(furui[i]==1){
  for(int t=2*i;t<a[n-1]+1;t+=i){
    if(furui.at(t))furui.at(t)=false;
  }
}
}
int ans=0;
rep(i,n){
  if(m.at(a.at(i))==1&&furui[a[i]])ans++;
}
cout<<ans<<endl;
}


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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, t = mi()
    print(b * (t // a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[26] = {0};
    string s; cin >> s;
    rep(i, s.size()) {
        a[s[i] - 'a']++;
    }
    rep(i, 26) {
        if (a[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}




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

int main()
{
    double l; cin >> l;
    double v = l*l*l/27;

    cout << fixed << setprecision(10) << v << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
mod = 10**9 + 7


ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()
ans = 0
for i in range(3):
        if s[i] == '1':
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) cout<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" ";
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 3005

bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}


double dp[N];

int main()
{
	sup; 
	ll n;
	cin>>n;
	double a[N];
	dp[0]=1;
	fab(i,0,n)
	{
	    cin>>a[i];
	    fba(j,i+1,0)
	        dp[j]=(j==0 ? 0 : dp[j-1]*a[i]) + dp[j]*(1-a[i]);
	}
	double ans=0;
	fab(i,n/2,n+1)
	{
	    ll j=n-i;
	    if(i>j)
	        ans+=dp[i];
	}
	cout<<setprecision(12);
	pr(ans);
    return 0;
}


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

using namespace std;

void read(vector<int>& x)
{	
  	for(auto& a: x)
    	cin >> a; 
}

int main()
{
    int n, s = 0; ios_base::sync_with_stdio(false),
    cin.tie(nullptr), cout.tie(nullptr),
    cin >> n; vector<int> v(n), c(n), p(n);
  
  	read(v), read(c);
  
  	for(int i = 0; i < n; ++i)
      	p[i] = v[i]-c[i];
  
  	sort(p.begin(),p.end());
    
  	while(not p.empty() and p.back() > 0)
      	s += p.back(), p.pop_back();
  
  	cout << s; 
}


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

void dfs(vector<vector<char>>& farm, 
        vector<vector<bool>>& searched,
        array<int,4>& dy, 
        array<int,4>& dx, 
        int h, 
        int w)
{
    if(searched[h][w]) return;

    searched[h][w] = true;

    for(int i = 0;i < 4;i++){
        if(h + dy[i] < 0 || h + dy[i] >= farm.size()) continue;
        if(w + dx[i] < 0 || w + dx[i] >= farm[0].size()) continue;
        if(searched[h + dy[i]][w + dx[i]]) continue;
        if(farm[h][w] != farm[h + dy[i]][w + dx[i]]) continue;
        dfs(farm, searched, dy, dx, h + dy[i], w + dx[i]);
    }
}

int main(){
    int H,W;
    while(cin >> H >> W, H,W){

        vector<vector<char>> farm(H,vector<char>(W));
        vector<vector<bool>> searched(H,vector<bool>(W,false));
        array<int,4> dy = {1, 0, 0, -1};
        array<int,4> dx = {0, 1, -1, 0};
        int ans = 0;

        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
            cin >> farm[i][j];
        }

        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(searched[i][j]) continue;
                dfs(farm, searched, dy, dx, i, j);
                ans++;
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 4100
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, k;
    cin >> n >> k;
    ll A[n];
    ll l = 1, r = 1;
    rep(i,0,n){
    	cin >> A[i];
    	r = max(r, A[i]);
    }
    ll last = r;
    while(r >= l){
    	ll m = (l+r)/2;
    	ll cut = 0;
    	rep(i,0,n){
    		ll q = (A[i]+m-1)/m - 1;
    		cut += q;
    	}
    	if(cut > k){
    		l = m + 1;
    	}
    	else{
    		last = m;
    		r = m - 1;
    	}
    }
    cout << last << endl;
    return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n, m;
  cin>>n>>m;
  int ans=0;
  int pren=1;
  int prem=1;
  for(int i=n; i>n-2&&i>0; i--){
    pren*=i;
  }
  pren/=2;
  for(int i=m; i>m-2&&i>0; i--){
    prem*=i;
  }
  prem/=2;
  if(m<2){
    prem=0;
  }
  if (n<2)
  {
    pren=0;
  }
  
  ans+=pren+prem;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$numbers = str_split($n);

for ($mask = 0; $mask < (1 << 3); $mask++) {
    
    $ans = $numbers[0];
    $ope = [];
    for ($i = 0; $i < 3; $i++) {
         
         if(($mask >> $i) & 1) {
             $ans += $numbers[$i+1];
              $ope[$i] = "+";
         } else {
             $ans -= $numbers[$i+1];
             $ope[$i] = "-";
         }
    }
    
    if($ans == 7) {
        echo $numbers[0].$ope[0].$numbers[1].$ope[1].$numbers[2].$ope[2].$numbers[3]."=7";
        break;
    }
     
}

?>


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

int main(){
  int n;
  int sum = 0;
  while(1){
    cin >> n;
    if(n == 0) break;
      while(1){
        if(n == 1) break;
        if(n % 2 == 0) n = n / 2;
        else if(n % 2 == 1){
          n = n * 3;
          n++;
        }
        sum++;
      }
    cout << sum << endl;
    sum = 0;
  }

  return 0;
}

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

int main(){
  int a[10];
  for(int i=0;i<10;i++){
    cin >> a[i];
  }
  sort(a,a+10,greater<int>());
  cout << a[0] << endl << a[1] << endl << a[2] << endl;
  return 0;
}

Measured memory_bytes: 3108
N,K = gets.split.map &:to_i
ws = []; ds = []
N.times{
  w,d = gets.split.map &:to_i
  ws << w
  ds << d
}

p (0..10**20).bsearch{ |y|
  a = 0
  (0...N).each{ |i|
    a += y >= ws[i] ? (y-ws[i])/ds[i] + 1 : 0
  }
  #p [y, a, K]
  a >= K
}



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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void func_to_create(){
    std::string T;
    cin >> T;
    for(const auto & c : T){
        if( c == '?'){
            cout << 'D';
        }else{
            cout << c;
        }
    }
    cout << endl;
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0; i < 3; i++)
    {
        if (s[i]=='9') {
            ans += '1';
        }
        else if (s[i] == '1') {
            ans += '9';
        }
        else
        {
            ans += s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
  ini_set('error_reporting', E_ALL & ~E_NOTICE);

  fscanf(STDIN, "%s", $S);
  $sum = [];

  $a = str_split($S);
  for ($i = 0; $i < count($a); $i++) {
    $sum[$a[$i]]++;
  }
  $vals = array_values($sum);

  $ans = "No";
  if (count($vals) === 2) {
    if ($vals[0] === 2 && $vals[1] === 2) {
        $ans = "Yes";
    }
  }

  echo $ans;


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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define re return
#define vi vector <int> 
#define pii pair <int,int>
#define pll pair <long long , long long>
typedef long long ll;

string t;
bool n,e,s,w;

int main()
{
	ios:: sync_with_stdio(false);
	cin >> t;
	for(int i=0;i<t.size();i++)
	{
		if(t[i]=='N')n=true;
		if(t[i]=='E')e=true;
		if(t[i]=='W')w=true;
		if(t[i]=='S')s=true;
	}
	if(n==s&&w==e)cout << "Yes"; else cout << "No";
	return 0;
}

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

int main() {
	int D;
	cin >> D;
	if(D==25) cout << "Christmas" << endl;
	if(D==24) cout << "Christmas Eve" << endl;
        if(D==23) cout << "Christmas Eve Eve" << endl;
	if(D==22) cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, k;
	cin >> n >> k;
	if((n + 1) / 2 >= k) cout << "YES\n";
	else cout <<  "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	long long A, B, N;
	scanf("%lld %lld %lld", &A, &B, &N);
	N = min(N, B - 1);
	printf("%lld", (A * N) / B - A * (N / B));
	return 0;
}

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

int main() {
    int n; cin >> n;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[n-1] << endl;
}   


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

int main(){
    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
ans_list = [0] * n
if n != 1:
    for x in range(1, int((n-2)**0.5)):
        for y in range(1, int((n-2)**0.5)):
            for z in range(1, int((n-2)**0.5)):
                k = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if k <= n:
                    ans_list[k - 1] += 1
                else:
                    break

for ans in ans_list:
    print(ans)

Measured memory_bytes: 9484
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args){

			String strcn = "ABC";
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			// スペース区切りの整数の入力
			int N = sc.nextInt();
			
			if(999>=N){
       		// 出力
				System.out.println(strcn);
				return ;
			}
			strcn = "ABD";
			N = N - 1000;

			if(999>=N){
	       		// 出力
				System.out.println(strcn);
				return ;
			}
		}
}


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


using namespace std;

#define ll long int
#define ull unsigned long long int

#define I_read()  freopen("input.tex","r",stdin);

#define O_write() freopen("output.txt","w",stdout);

#define fast() ios_base::sync_with_stdio(false); cin.tie(0);


int main(){

	fast();	
#ifdef _DEBUG

//	  I_read();
//        O_write();

#endif

string st;

cin >> st;

for(int a=0;a<st.length();a++)
{
	if(st.at(a) == '?' )
	{
		if( a-1>0 && a+1 < st.length())
		{
			if(st.at(a-1) != 'P' &&  st.at(a+1) == 'D' )
			{
				st[a]='P';
			}
			else
			{
				st[a]='D';
			}
		}
		else
		{
			st[a]='D';
		}
	}
}	

cout<<st<<endl;

 return 0;	
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
using namespace std;
typedef long long ll;

int main() {
    int A, B, C, X, Y, a, b, c, temp, sum;

    cin >> A >> B >> C >> X >> Y;

    sum = 1000000000;

    for (int c = 0; c <= max(X, Y); c++){
        temp = C * 2 * c;

        if (c < X){
            temp += (X - c) * A;
        }

        if (c < Y){
            temp += (Y - c) * B;
        }
        

        if (sum >= temp){
            sum = temp;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
import scala.io.StdIn.{readLine, readInt};
import scala.reflect.ClassTag;
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val graph = new Array[List[(Int, Int)]](n); // (cost, index)
        (0 until n).foreach { i =>
            graph(i) = readLine.trim.split(" ").map(_.toInt).zipWithIndex.filter(_._1 != -1).toList
        }
        val (dist, parent) = mst(graph);
        println(dist.sum);
    }
    
    def mst(graph: Array[List[(Int, Int)]]): (Array[Int], Array[Int])= {
        val len = graph.length;
        val dist = new Array[Int](len).map( i => -1);
        val parent = new Array[Int](len).map( i => -1);
        implicit val ord = Ordering.by((e: (Int, Int, Int)) => e._1).reverse; // (cost, index, parent)
        val pq = new PriorityQueue(10000);
        pq.enqueue((0, 0, -1));
        def go(): Unit = {
            pq.dequeueOption match {
                case None => ();
                case Some((minCost, minIdx, minParent)) => {
                    if (dist(minIdx) == -1) {
                        dist(minIdx) = minCost;
                        parent(minIdx) = minParent;
                        graph(minIdx).foreach { e => pq.enqueue((e._1, e._2, minIdx))}
                    }
                    go;
                }
            }
        }
        go;
        (dist, parent);
    }
}

class PriorityQueue[A](size: Int)(implicit m: ClassTag[A], ord: Ordering[A]) {
    import ord._;
    private[this] val pq = m.newArray(size);
    private[this] var ptr = 0;
    
    def enqueue(e: A): Unit = {
        def go(curr: Int): Unit = {
            val parent = if (curr % 2 == 1) (curr - 1) / 2 else (curr - 2) / 2;
            if (parent >= 0 && pq(curr) > pq (parent)) {
                swap(curr, parent);
                go(parent);
            }
        }
        pq(ptr) = e;
        go(ptr);
        ptr += 1;
    }
    def dequeue(): A = {
        if (ptr == 0) {
            throw new NoSuchElementException("value is not found");
        } else if (ptr == 1) {
            ptr = 0;
            pq(0);
        } else {
            ptr -= 1;
            val ret = pq(0);
            pq(0) = pq(ptr);
            heapify(0);
            ret;
        }
    }
    
    def dequeueOption(): Option[A] = {
        try {
            Option(dequeue());
        } catch {
            case e: Exception => None;
        }
    }
    
    private def heapify(curr: Int): Unit = {
        val left = curr * 2 + 1;
        val right = curr * 2 + 2;
        if (right < ptr) {
            val maxIdx = max(curr, left, right);
            if (curr != maxIdx) {
                swap(curr, maxIdx);
                heapify(maxIdx);
            }
        } else if (left < ptr) {
            if (pq(left) > pq(curr)) swap(curr, left);
        }
    }
    
    private def max(a: Int, b: Int, c: Int): Int = {
        if (pq(a) > pq(b)) {
            if (pq(a) > pq(c)) a else c;
        } else {
            if (pq(b) > pq(c)) b else c;
        }
    }
    
    private def swap(a: Int, b: Int): Unit = {
        val tmp = pq(a);
        pq(a) = pq(b);
        pq(b) = tmp;
    }
}


Measured memory_bytes: 62584
a,b,m=map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
t=[[0,0,0] for i in range(m)]
for i in range(m):
    a, b,c = map(int, input().split())
    t[i][0]=a
    t[i][1]=b
    t[i][2]=c
k=min(A)+min(B)
for i in range(m):
    if A[t[i][0]-1]+B[t[i][1]-1]-t[i][2]<k:
        k=A[t[i][0]-1]+B[t[i][1]-1]-t[i][2]
print(k)

Measured memory_bytes: 30764
from sys import stdin

if True:

    n = int(stdin.readline().strip())
    a = list(map(int, stdin.readline().strip().split()))

    if n == 1:
        print(1)
        exit()

    a.sort()

    dp = [True] * (a[-1] + 1)
    ans = 0

    for i in range(n):

        if a[i] == a[i-1]:
            continue

        if dp[a[i]]:

            for j in range(2 * a[i], a[-1] + 1, a[i]):
                dp[j] = False

            if i == n-1 or a[i] != a[i+1]:
                ans += 1

    print(ans)


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

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

    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;

    int a,b,c;
    
    a = N / 100;
    b = (N / 10) % 10;
    c = (N % 10) % 10;

    if( (a == 7) || (b == 7) || (c == 7)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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




void solve(){
  int ans = 0;
int a[5];
  for(int i =0 ;i < 5 ;i++)
  {
    cin >> a[i];
    if(a[i] == 0)
      ans = i+1;
  }
cout << ans ;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //f();
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N;
cin >> N;

ll int D1,D2;
int counter=0;
int flag=0;

rep(i,N){
	cin >> D1 >> D2;
	if(D1==D2 && counter==0){
		counter=1;
	}
	else if (D1==D2 && counter==1){
		counter=2;
	}
	else if (D1==D2 && counter==2){
		flag=1;
	}
	else{
		counter=0;
	}
}

if(flag==1){
	cout << "Yes";
}
else{
cout << "No";
}










	return 0;

}



Measured memory_bytes: 3540
#include <stdio.h>

int main(void){
   int x,y,i,j;
   scanf("%d %d",&x,&y);
   for(i=0;i<1000;i++){
      for(j=0;j<1000;j++){
         if(i+j==x&&4*j+i*2==y){
            printf("Yes");
            return 0;
         }
      }
   }
   printf("No");
}



Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int x;
    void input() { cin >> x; }
    void output() { cout << !x << endl; }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3648
program making_palindrome
  implicit none
  integer(8), parameter :: inf = 1e18
  integer :: n, i
  character(20) :: s(50, 2) = ''
  integer(8) :: c(50) = 0, m(50, 21, 2) = 0, x = inf
  logical :: u(50, 21, 2) = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i, 1), c(i)
    s(i, 2) = reverse(s(i, 1)(1:len_trim(s(i, 1))))
  end do
  do i = 1, n
    x = min(x, solve(i, 1, 1) + c(i))
  end do
  write(*,'(i0)') merge(x, -1_8, x < inf)
contains
  function reverse(s) result(res)
    character(*), intent(in) :: s
    character(len_trim(s)) :: res
    integer :: n, i
    n = len_trim(s)
    do i = 1, n
      res(i:i) = s(n - i + 1:n - i + 1)
    end do
  end
  recursive integer(8) function solve(i, j, k) result(res)
    integer, intent(in) :: i, j, k
    integer :: l, r, t
    logical :: f
    res = m(i, j, k)
    if (u(i, j, k)) return
    u(i, j, k) = .true.
    m(i, j, k) = inf
    l = j
    r = len_trim(s(i, k))
    f = .true.
    do while (l < r)
      if (s(i, k)(l:l) /= s(i, k)(r:r)) then
        f = .false.
        exit
      end if
      l = l + 1
      r = r - 1
    end do
    if (f) then
      m(i, j, k) = 0
      res = 0
      return
    end if
    do t = 1, n
      l = j
      r = 1
      do while (l <= len_trim(s(i, k)) .and. r <= len_trim(s(t, 3 - k)))
        if (s(i, k)(l:l) /= s(t, 3 - k)(r:r)) exit
        l = l + 1
        r = r + 1
      end do
      if (l == len_trim(s(i, k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(t, r, 3 - k) + c(t))
      end if
      if (r == len_trim(s(t, 3 - k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(i, l, k) + c(t))
      end if
    end do
    res = m(i, j, k)
  end
end program making_palindrome

Measured memory_bytes: 2924
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    std::vector<std::set<std::string>> st(4);
    st[0].insert("");
    for (int i = 0; i < n; i++) {
        for (int j = 2; j >= 0; j--) {
            for (auto &t : st[j]) {
                st[j + 1].insert(t + s[i]);
            }
        }
    }
    std::cout << st[3].size() << std::endl;
    return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	int a,b,c,d,k;
	cin>>a>>b>>c>>d>>k;

	b+=a*60;
	d+=c*60;

	int left=d-b;

	cout<<max(0,left-k)<<endl;

	return 0;
}


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

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

  ll a, b;
  cin >> a >> b;

  cout << (a*b) / gcd(a, b) << endl;
  
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{
  ll N, A, B, C, D, E;
  vector<ll> M(5, 0);
  cin >> N >> M[0] >> M[1] >> M[2] >> M[3] >> M[4];
  ll minV = *min_element(M.begin(), M.end());
  if (N <= minV)
  {
    cout << 5;
    return 0;
  }
  if ((N % minV) > 0)
    cout << 4 + (N / minV) + 1;
  else
    cout << 4 + (N / minV);
  // cout << 5 + (N / min(M));
  // vector<ll> v(6, 0);
  // ll cnt = 0;
  // ll time = 0;
  // v[0] = N;

  // while (true)
  // {
  //   cnt++;
  //   time++;
  //   if (cnt > 5)
  //     cnt = 5;
  //   repdm(i, cnt - 1, -1)
  //   {
  //     if (v[i] == 0)
  //       continue;
  //     if (v[i] <= M[i])
  //     {
  //       v[i + 1] += v[i];
  //       v[i] = 0;
  //     }
  //     else
  //     {
  //       v[i + 1] += M[i];
  //       v[i] -= M[i];
  //     }
  //   }
  //   if (v[5] >= N)
  //   {
  //     break;
  //   }
  // }
  // cout << time;
}

Measured memory_bytes: 256
/*input
000
*/
#include <bits/stdc++.h>
using namespace std;
#define MAX 100010

int n, ans1 = 0, ans2 = 0;
char c[MAX];

int main() {
	cin >> c;
	n = (int) strlen(c);

	for (int i = 0; i < n; i++) {
		if (c[i] == '1') {
			if (i % 2 == 0) ans1 ++;
			if (i % 2 == 1) ans2 ++;
		} else {
			if (i % 2 == 1) ans1 ++;
			if (i % 2 == 0) ans2 ++;
		}
	}
	// cout << ans1 << ' ' << ans2 << '\n';

	cout << min(ans1, ans2) << '\n';
	return 0;
}

Measured memory_bytes: 384
def solve(n,s):
  if "ABC" not in s:
    return 0
  cnt = 0
  for i in range(len(s)-2):
    if "ABC" == s[i:i+3]:
      cnt+=1
  return cnt

n = int(input())
s = input()
ans = solve(n,s)
print(ans)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define M 1000000007
#define ll long long

vector<int>adj[N];
ll dp[N][3];

ll cal(int n, int p, int pr)
{
//cout << n <<" " << pr << endl;
    //if(adj[n].size() == 1 && pr) return pr == 2? 1 : 2;
    if(dp[n][pr] != -1)
        return dp[n][pr];

    dp[n][pr] = 1LL;
    for(int x : adj[n])
    {
        if(x != p)
        {
            dp[n][pr] = (dp[n][pr] * (cal(x, n, 1) + (pr == 2? 0 : cal(x, n, 2)))) % M;
        }
    }

    return dp[n][pr];
}

int main()
{
    memset(dp, -1, sizeof(dp));
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    cout << (cal(1, -1, 1) + cal(1, -1, 2)) % M << endl;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
  ll N,K;
  ll ans=0;
  cin >> N>>K;
  priority_queue<ll> data;
  rep(i,0,N){
      ll a;
      cin >> a;
      data.push(a);
  }
  if(N<=K){
      cout << "0" << endl;
  }else{
      rep(i,0,K){
         data.pop();
      }
      rep(i,0,N-K){
          ans += data.top();
          data.pop();
      }
      
      cout << ans << endl;

  }
  
  

  return 0;
}

Measured memory_bytes: 2420
n=int(input())
A=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(A[0]-A[1])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]),)
print(dp[n-1])

Measured memory_bytes: 13980
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[200005];

void solve()
{
    int n,p;
    scanf("%d%d%s", &n, &p, str);

    if (p == 2) {
        int i;
        ll ans=0;
        for(i=0; i<n; i++) {
            int tmp=str[i]-'0';
            if (tmp % 2 == 0) {
                ans+=(i+1);
            }        
        }
        printf("%lld\n", ans);
    }
    else if (p == 5) {
        int i;
        ll ans=0;
        for(i=0; i<n; i++) {
            int tmp=str[i]-'0';
            if (tmp % 5 == 0) {
                ans+=(i+1);
            }        
        }
        printf("%lld\n", ans);
    }
    else {
        vector<int> a(n),b(n),s(n+1);
        int curr=1;
        int i;
        for (i = 0; i < n; i++) {
            a[i]=curr;
            curr=curr*10%p;
        }
        for (i = 0; i < n; i++) {
            int tmp=str[i]-'0';
            b[i]=tmp*a[n-1-i]%p;
            s[i+1]=(s[i]+b[i])%p;
        }
        vector<int> cnt(p);
        for(i=0; i<=n; i++) {
            cnt[s[i]]++;
        }
        ll ans=0;
        for (i = 0; i < p; i++) {
            ans+=(ll)cnt[i]*(cnt[i]-1)/2;
        }
        printf("%lld\n", ans);
    }

    return;
}

int main(int argc, char* argv[])
{
    solve();

	return 0;
}


Measured memory_bytes: 2816
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[]
for x in a:
    if "#" in x:b.append(x)
c=[]
for y in zip(*b):
    if "#" in y:c.append(y)
for a in zip(*c):print("".join(a))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
 
using namespace std;
 
int main(){
    int n;
    int nums[100000] = {0};
    while(cin >> n){
        int count = 0;
        int qf = 0;
        int qe = 0;
        for(int i = 2; i <= n; i++){
            bool f = false;
            for(int qe = 0; qe < qf; qe++ ){
                if(i < nums[qe] * nums[qe]) break;
                if(i % nums[qe] == 0) {
                    f = true;
                    break;
                }
            }
            if(!f) { count++; nums[qf] = i; qf++; }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1556
/*Author : Yuvraj Singh
 * Patience is Power
 * 
 * */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
#define ar array
ll power(ll x,ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return ((temp%mod)*(temp%mod))%mod; 
    else
        return ((x%mod)*(temp%mod)*(temp%mod))%mod; 
}

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}


bool cmp(pair<int,int>a,pair<int,int>b){
	return a.second<b.second;
}




void solve(){
	int n; cin>>n;
	ar<int,2>arr[n];
	bool res=false;
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
		if(arr[i][0]==arr[i][1])
			cnt++;
		else
			cnt=0;
		if(cnt>=3)
			res=true;
	}
	if(res)
		cout<<"Yes";
	else cout<<"No";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
    return 0;
}

Measured memory_bytes: 3648
def create_union_answer(a, b, c, k):
    if a >= k:
        return k
    if a + b >= k:
        return a
    # can select type[c] card numbers.
    can_c = k - (a + b)
    if can_c > c :
        can_c = c
    return a - can_c

values = input().split()

a = int(values[0])
b = int(values[1])
c = int(values[2])
k = int(values[3])

answer = create_union_answer(a, b, c, k)
print(answer)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<vector<int>> E[51];
int S;
int D[50],C[50];
ll dp[51][2525];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S;
	S=min(2500,S);
	FOR(i,M) {
		cin>>x>>y>>j>>r;
		E[x-1].push_back({y-1,j,r});
		E[y-1].push_back({x-1,j,r});
	}
	FOR(i,N) cin>>C[i]>>D[i];
	
	FOR(i,N) FOR(x,2501) dp[i][x]=1LL<<60;
	dp[0][S]=0;
	priority_queue<pair<ll,int>> Q;
	Q.push({0,S});
	while(Q.size()) {
		ll co=-Q.top().first;
		int cur=Q.top().second/10000;
		int S=Q.top().second%10000;
		Q.pop();
		if(co!=dp[cur][S]) continue;
		
		if(S<2500) {
			if(dp[cur][min(2500,S+C[cur])]>co+D[cur]) {
				dp[cur][min(2500,S+C[cur])]=co+D[cur];
				Q.push({-dp[cur][min(2500,S+C[cur])], cur*10000+min(2500,S+C[cur])});
			}
		}
		FORR(e,E[cur]) if(S>=e[1]) {
			if(dp[e[0]][S-e[1]]>co+e[2]) {
				dp[e[0]][S-e[1]]=co+e[2];
				Q.push({-dp[e[0]][S-e[1]], e[0]*10000+S-e[1]});
			}
		}
	}
	
	for(i=1;i<N;i++) {
		ll mi=1LL<<60;
		FOR(j,2501) mi=min(mi,dp[i][j]);
		cout<<mi<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6148
#include <bits/stdc++.h>
#define For( i, j, k ) for( int i = j; i <= k; ++i )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
using std::pair;
using std::cin;
using std::cout;
using std::vector;
using std::make_pair;
int main( )
{
 std::ios::sync_with_stdio( false );
 int n, a, b;
 long long ans = 0;
 cin >> n >> a >> b;
 vector < int > c( n );
 For( i, 1, n )
  cin >> c[ i - 1 ];
 For( i, 1, n - 1 )
  ans += std::min( ( long long ) a * ( c[ i ] - c[ i - 1 ] ), ( long long ) b );
 cout << ans;
 return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			long a = scanner.nextInt();
			long b = scanner.nextInt();
			long m = a ;
			long n = b ;
			while(m % n != 0){
				long tmp = m;
				m = n;
				n = tmp % n;
			}
			//最大公約数
			long  GCD = n;
			//最小公倍数
			long  LCM = a * b / GCD;

			System.out.printf("%d %d\n", GCD, LCM);
		}
		scanner.close();
	}

}



Measured memory_bytes: 26356
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N, p=1;
    cin >> N;
    REP(i,1,N+1){
        p = p*i % MOD;
    }
    P(p);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

ll int dp[101][100001];
ll int solve(int i,int x,ll int*we,ll int*ct,int w,int n){
	if(x>w)
	return INT_MIN;
	
	else if(x==w || i==n)
	return 0;
	
	ll int ans=0;
	
	if(dp[i][x]!=-1)
	return dp[i][x];
	
	ans=max(solve(i+1,x,we,ct,w,n),solve(i+1,x+we[i],we,ct,w,n)+ct[i]);
	dp[i][x]=ans;
	return ans;
}

int main(){
	fast;
	
	int n,w;
	cin>>n>>w;
	
	ll int we[n],ct[n];
	forr(i,0,n)
	cin>>we[i]>>ct[i];
	
	forr(i,0,101){
		forr(j,0,100001)
		dp[i][j]=-1;
	}
	
	ll int ans=solve(0,0,we,ct,w,n);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define find(x,i) find(x.begin(),x.end(),i)
#define getchar_unlocked getchar
char _;
typedef long long ll;
typedef pair<int,int> pii;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MAXN = 17;
int val[MAXN][MAXN];
ll groupval[1 << MAXN];
ll dp[1 << MAXN];
int curat[1 << MAXN], nwat [1 << MAXN];
int main() {
  dp[0] = 0;
    int n;
    scan(n);
    for (int i = 1; i < (1 << n); i++) dp[i] = LONG_MIN/2;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf ("%d",&val[i][j]);
    for (int mask = 1; mask < (1 << n); mask++) {
        vector<int> bitsnotset, bitsset;
        for (int i = 0; i < n; i++) bitsnotset.push_back(i);
        int first,last,i;
        for  (i = 0; i < n; i++) if (mask & (1 << i)) {bitsset.push_back(i); bitsnotset.erase(find(bitsnotset,i)); first = i; groupval[mask] = groupval[mask ^ (1 << i)]; break;}
        for (i++; i < n; i++) if (mask & (1 << i)) bitsset.push_back(i), bitsnotset.erase(find(bitsnotset,i)), groupval[mask] += val[first][i];
        int sz = bitsnotset.size();
        for (i = 0; i < (1 << sz); i++) {
          int bit = __builtin_ctz(i);
          int cur = (curat[i] = (i ? (curat[i^(1<<bit)]|(1<<bitsnotset[bit])) : 0));
          int nw = (nwat[i] = (i ? (nwat[i^(1<<bit)]|(1<<bitsnotset[bit])) : mask));
          dp[nw] = max(dp[nw],dp[cur] + groupval[mask]);
        }
   }
   printf ("%lld\n",dp[(1 << n)-1]);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



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

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

Measured memory_bytes: 3760