akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define State string::const_iterator
class ParseError {};
 
int Hash(State &begin);
int OP(State &begin);
int Letter(State &begin);
int factor(State &begin);
void consume(State &begin, char expected);
 
int a, b, c, d;
 
// 四則演算の式をパースして、その評価結果を返す。
int Hash(State &begin) {
    int ret = factor(begin);
 
    return ret;
 
}
 
// 乗算除算の式をパースして、その評価結果を返す。
int OP(State &begin) {
    int ret = 0;
    if(*begin == '*'){
        consume(begin, '*');
        int left_num = Hash(begin);
        int right_num = Hash(begin);
        ret = left_num & right_num;
    }
    else if(*begin == '+'){
        consume(begin, '+');
        int left_num = Hash(begin);
        int right_num = Hash(begin);
        ret = left_num | right_num;
    }
    else if(*begin == '^'){
        consume(begin, '^');
        int left_num = Hash(begin);
        int right_num = Hash(begin);
        ret = left_num ^ right_num;
    }
    else{
        cout << " out of range" << *begin << endl;
        ret = 0;
        int dummy = 5/ret;
    }
 
    return ret;
}
 
// 数字の列をパースして、その数を返す。
int Letter(State &begin) {
    if(*begin=='a'){
        consume(begin, 'a');
        return a;
    }
    else if(*begin=='b'){
        consume(begin, 'b');
        return b;
    }
    else if(*begin=='c'){
        consume(begin, 'c');
        return c;
    }
    else if(*begin=='d'){
        consume(begin, 'd');
        return d;
    }
    else{
        consume(begin, 'o');
        return -20;
    }
}
 

int factor(State &begin) {
    if (*begin == '[') {
        consume(begin, '['); // '['を飛ばす。
        int ret = OP(begin);
        consume(begin, ']'); // ']'を飛ばす。
        return ret;
    }
    else {
        return Letter(begin);
    }
}  

 
// beginがexpectedを指していたらbeginを一つ進める。
void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    } else {
        cerr << "Expected '" << expected << "' but got '" << *begin << "'"
             << endl;
        cerr << "Rest string is '";
        while (*begin) {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        throw ParseError();
    }
}
 
int main() {
  
    while(true){
 
        string S;
 
        cin >> S;
 
        if(S[0] == '.'){
            break;
        }
 
        string P;
        cin >> P;

        int count = 0;
        map<int,int> hash_memory;
       
        for(int i=0; i<10000; i++){

            State s = S.begin();

            a = i/1000;
            b = (i/100)%10;
            c = (i/10)%10;
            d = i%10;
            s = S.begin();
            hash_memory[Hash(s)]++;
        }

        State s = S.begin();

        stringstream ss;

        ss << P[0];
        ss >> a;
        ss.clear();

        ss << P[1];
        ss >> b;
        ss.clear();

        ss << P[2];
        ss >> c;
        ss.clear();

        ss << P[3];
        ss >> d;
        ss.clear();

        int P_Hash = Hash(s);

        cout << P_Hash << " " << hash_memory[P_Hash] << endl;
        
 
    }
 
    return 0;
}


Measured memory_bytes: 3180
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        
        // input:   3 5 4
        //          11100
        //          10001
        //          00111
        //
        // process: boardに切り込みを入れて
        //          どの部分も'1'がk個以下であるようにする
        //
        // output:  2 (縦1,横3の2箇所に切り込みを入れる)
        
        // board[i][j]: チョコレートの模様
        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                board[i][j] = str.charAt(j);
            }
        }
        
        // bit: 横線の引き方のbit全探索
        // min: cutの最小値
        int min = (h-1)*(w-1);
        for (int bit = 0; bit < 1<<(h-1); bit++) {
            // group[i]: i行が属するグループ番号
            // bitに基づいて各行をグループ分けする
            int[] group = new int[h];
            int g = 0;
            group[0] = g;
            for (int i = 0; i < h-1; i++) {
                // bitXが1なら次のグループにする
                if ((bit & (1<<i)) != 0) {
                    g++;
                }
                group[i+1] = g;
            }
            
            // cut: 横線の本数( + 縦線の本数)
            int cut = g;
            
            // count[i]: グループiの現在の'1'の個数
            // last: 最後に引いた縦線の位置
            // ok: 1列だけでk個を超すグループが存在しないならtrue
            int[] count = new int[g+1];
            int last = 0;
            boolean ok = true;
            
            // board -> cut
            // cut += 縦線の本数
            for (int i = 0; i < w; i++) {
                for (int j = 0; j < h; j++) {
                    if (board[j][i] == '1') {
                        count[group[j]]++;
                    }
                    
                    // '1'の個数がkを超えるグループがある場合、
                    // 今の列の前でカットし、その列は数え直し
                    if (count[group[j]] > k) {
                        if (last != i) {
                            cut++;
                            Arrays.fill(count, 0);
                            last = i;
                            i--;
                            break;
                        } else {
                            ok = false;
                        }
                    }
                }
            }
            
            if (ok) {
                min = Math.min(min, cut);
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 22564
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

static void A_FiveAntennas();

int main()
{
	
	A_FiveAntennas();
	return 0;
}


static void A_FiveAntennas()
{
	int ng = 0;
	int points[5], k;

	for (int p = 0; p < 5; p++) {
		scanf(" %d", &points[p]);
	}
	scanf(" %d", &k);

	if ((points[4] - points[0]) > k) {
		ng = 1;
	}

	const char* ans[] = { "Yay!", ":(" };

	printf("%s\n", ans[ng]);
	fflush(stdout);

	return;
}


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

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

using namespace std;

const int N = (int)2e5 + 7;
const int INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, a[N], b[N], c[N];
int main (){
  scanf ("%d", &n);
  forn (i, 1, n) scanf ("%d", a + i);
  forn (i, 1, n) scanf ("%d", b + i);
  forn (i, 1, n) scanf ("%d", c + i);
  sort (a + 1, a + n + 1);
  sort (c + 1, c + n + 1);
  sort (b + 1, b + n + 1);
  ll ans = 0;
  forn (i, 1, n){
    int x = b[i];
    ans += 1ll * (((lower_bound(a + 1, a + n + 1, x) - a) - 1) * (c + n + 1 - upper_bound(c + 1,  c + n + 1, x)));
  }
  printf ("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll m, k;
    cin >> m >> k;

    ll b = 1;
    for(int i = 0; i < m; i++){
        b*=2;
    }
    if(b-1<k){cout << -1 << endl; return 0;}
    if(m==1 && k==0){
        cout << "0 0 1 1" << endl; return 0;
    }
    if(m==1 && k==1){
        cout << -1 << endl; return 0;
    }

    for(int i = 0; i < b-1; i++){
        if(i != k){
            cout << i << " ";
        }
    }
    cout << k << " ";
    for(int i = b-2; i >= 0; i--){
        if(i != k){
            cout << i << " ";
        }
    }
    if(b-1 != k){cout << b-1 << " ";}

    cout << k << " ";
    if(b-1 != k){cout << b-1 << " ";}

    return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

bool jdg(llint x) {
	llint i;
	
	for(i=2;i<=sqrt(x);i++) {
		if (x%i==0) {
			return false;
		}
	}
	
	return true;
}

int main (void)
{
	//INPUT
	llint N,M;
	cin >> N;
	llint i,j;
	
	for(i=N;;i++) {
		
		if (jdg(i)) break;
		// for(j=2;j<i;j++) {
		// 	if(i%j==0) {
		// 		break;
		// 	}
		// }
		// if (j==i) {
		// 	break;
		// }
	}
	
	
	//SOLVE
	llint ans=i;
	
	//OUTPUT
	cout << ans << endl;
	
	return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;

int main() {
  int N;
  ll x;
  while (cin >> N >> x) {
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
      cin >> a[i];
    }
    ll ans = INF;
    vector<ll> dp(N, INF);
    for (int y = 0; y < N; y++) {
      ll sum = 0;
      for (int i = 0; i < N; i++) {
        dp[i] = min(dp[i], a[(i - y + N) % N]);
        sum += dp[i];
      }
      ans = min(ans, sum + y * x);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B;cin>>A>>B;
    cout<<max(A+B,max(A-B,A*B))<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int m, d;
  scanf("%d%d", &m, &d);
  int ans = 0;
  for (int d1 = 2; d1 <= 9; ++d1)
    for (int d10 = 2; d10 <= 9; ++d10)
      if (d10 * 10 + d1 <= d && d1 * d10 <= m)
        ++ans;
  printf("%d\n", ans);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
     
int main(){
      int n;
      cin >> n;
      int point = 0;
      int count = 0;
      long long ans = 0;
      
      int a[n * 3];
      for (int i =0; i < n * 3; ++i) 
      {
       	cin >> a[i];
      }
      
      sort(a, a + n * 3, greater<int>());
     
      while (point < n) {
        ans += a[count * 2 + 1];
        point++;
        count++;
      }
      
      cout << ans << endl;
      return 0;
}

Measured memory_bytes: 1408
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : 03 September, 2k20
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc042/tasks/arc058_a
|   Algorithm   :
|
\**============================================================================**/

#include "bits/stdc++.h"
using namespace std;

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

vector <int> dislike(10, 0);
bool ok(int n)
{
    while(n)
    {
        if( dislike[n % 10] )return false;
        n /= 10;
    }
    return true;
}

void test_case()
{
    int n, k;
    cin >> n >> k;

    int digit;
    for0(i, k)
    {
        cin >> digit;
        dislike[digit] = 1;
    }

    for(int i = n; ; ++i)
    {
        if( ok(i) )
        {
            cout << i << endl;
            return;
        }
    }
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3596
def main():
    N = int(input())
    S = input()
    al = [chr(i) for i in range(65, 65+26)]
    ans = ""
    for i in range(len(S)):
        let = S[i]
        ind = al.index(let) + N
        ind = ind % 26
        ans += al[ind]
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
long x=sc.nextLong();
long y=sc.nextLong();
int a=0,ans=0;
while((long)(pow(2,a)*x)<=y){
    a++;ans++;
}
    out.println(ans);
}}

Measured memory_bytes: 23508
a,b = map(int,input().split())
s = list(input())
for i in range(a+b+1):
    if i < a and not s[i].isdigit():
        print('No')
        exit()
    elif i == a and s[i] != '-':
        print('No')
        exit()
    elif i > a and not s[i].isdigit():
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 61776
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int ans = K;
    rep(i, N - 1) ans *= K - 1; 
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;

int com(int i) {
	return  i * (i - 1)/2;
}


	
int main() {
	int n, m;
	cin >> n >> m;

	if (n >= 2 && m >= 2) {
		cout << com(n) + com(m);
	}
	else if (n < 2 && m >= 2) {
		cout << com(m);
	}
	else if (n >= 2 && m < 2) {
		cout << com(n);
	}
	else {
		cout << 0;
	}
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    while (1) {
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;

        if (m == 0) break;

        int ans = 0;
        int tmp;
        cin >> tmp;
        int maxgap = 0;
        for (int i = 1; i < m; ++i) {
            int s;
            cin >> s;
            if (maxgap <= tmp - s && i >= nmin && i <= nmax) {
                maxgap = tmp - s;
                ans = i;
            }
            tmp = s;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())


int n;
double r[500];
double x[500];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	rep(i, n)cin >> r[i];
	rep(i,n) {
		double mx = r[i];
		rep(j,i) {
			double a = x[j] + sqrt((r[j]+r[i])*(r[j]+r[i])-(r[j]-r[i])*(r[j]-r[i]));
			mx = max(mx,a);
		}
		x[i] = mx;
	}
	double ans = 0;
	rep(i,n) {
		ans = max(ans,x[i]+r[i]);
	}
	printf("%.6f\n",ans);
	return 0;
}

Measured memory_bytes: 3320
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "Yes"<< "\n"
#define N cout<< "No"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    ld p=((ld)n/b);
    if(p<=(ld)a)
        Y;
    else
        N;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int n,i,j,k;
char s[55],a[55]="AKIHABARA";
int main(){
    scanf("%s",s);
    n=strlen(s);
    if(n>9){
        printf("NO\n");
        return 0;
    }
    j=k=0;
    for(i=0;i<9;i++){
        if(s[j]==a[i]){
            if(a[i]!='A')   k++;
            j++;
        }
    }
    if(j!=n || k!=5){
        printf("NO\n");
    }else{
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 128
def func(x1, y1, x2, y2):
    x3 = x2 - (y2 - y1)
    y3 = y2 + (x2-x1)
    return x3, y3

x1, y1, x2, y2 = [int(i) for i in input().split()]
x3, y3 = func(x1, y1, x2, y2)
x4, y4 = func(x2, y2, x3, y3)
print("{} {} {} {}".format(x3, y3, x4, y4))
"""
if x1 == x2 and y1 < y2:
    hen = y2 - y1
    print("{} {} {} {}".format(x1-hen, y2, x1-hen, y1))
elif x1 > x2 and y1 == y2:
    hen = x1 - x2
    print("{} {} {} {}".format(x2, y2-hen, x1, y1-hen))
elif x1 == x2 and y1 > y2:
    hen = y1 - y2
    print("{} {} {} {}".format(x2+hen, y2, x2+hen, y1))
elif x1 < x2 and y1 == y2:
    hen = x2 - x1
    print("{} {} {} {}".format(x2, y2+hen, x1, y1+hen))
    """

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int count=0;
  int N;
  cin>>N;
  int t;
  for(int i=0;i<N;i++){
    cin>>t;
    while(t%2==0){
      t/=2;
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)
	existsOdd := false
	for _, ai := range a {
		if ai%2 == 1 {
			existsOdd = true
			break
		}
	}
	if existsOdd {
		fmt.Println("first")
	} else {
		fmt.Println("second")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4296
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n,m;
  string s[111];
  int v[111];
  while(cin >> n >> m && n){
    for(int i = 0; i < n; i++){
      cin >> s[i] >> v[i];
    }

    int res = 0;
    for(int i = 0; i < m; i++){
      string p;
      int k;
      cin >> p;
      for(int j = 0; j < n; j++){
	for(k = 0; k < 8; k++){
	  if(s[j][k] != '*' && s[j][k] != p[k]) break;
	}
	if(k == 8){
	  res += v[j];
	  break;
	}
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;

  if ( a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<ll> t(n), a(n);
  rep(i, n) cin >> t[i] >> a[i];

  ll l = t[0], r = a[0];
  FOR(i, 1, n) {
    if (l % t[i] != 0) l += t[i] - (l % t[i]);
    if (r % a[i] != 0) r += a[i] - (r % a[i]);
    ll res = max(l / t[i], r / a[i]);
    l = res * t[i], r = res * a[i];
  }
  cout << l + r << endl;




  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;

int main()
{
	char in[101];
	while(scanf("%s",&in) != EOF){
		for(int i = 0; in[i] != '\0'; ++i){
			if(in[i] == '@'){
				for(int j=0; j<(in[i+1]-'0'); ++j){
					cout << in[i+2];
				}
				i = i + 2;
			}
			else cout << in[i];
		}
		cout << endl;
	}
}

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

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    vector<vector<int>> p(d,vector<int>(n,0));
    for(int i=0;i<d;i++){
        for(int j=0;j<n;j++){
            cin>>p[i][j];
        }
    }

    for(int i=1;i<d;i++){
        vector<vector<int>> dp(n,vector<int>(1e5+1,1000000));

        for(int j=0;j<n;j++) dp[j][0]=0;
        for(int k=0;k<1e5+1;k++){
            if(p[i-1][0]<p[i][0]){
                if(k-(p[i][0]-p[i-1][0])>=0)
                    dp[0][k]=min(dp[0][k],dp[0][k-(p[i][0]-p[i-1][0])]+p[i-1][0]);
                else{
                    dp[0][k]=min(dp[0][k],dp[0][0]+p[i-1][0]);
                }
            }
        }
        for(int j=1;j<n;j++){
            for(int k=0;k<1e5+1;k++){
                if(p[i-1][j]>=p[i][j]){
                    dp[j][k]=dp[j-1][k];
                }
                else{
                    dp[j][k]=dp[j-1][k];
                    if(k-(p[i][j]-p[i-1][j])>=0){
                        dp[j][k]=min(dp[j][k],dp[j][k-(p[i][j]-p[i-1][j])]+p[i-1][j]);
                    }
                    else{
                        dp[j][k]=min(dp[j][k],dp[j][0]+p[i-1][j]);
                    }
                }
            }
        }
        int newx=0;
        for(int k=0;k<1e5+1;k++){
            if(dp[n-1][k]<=x){
                newx=max(newx,k);
            }
        }
        x+=newx;
    }
    cout<<x<<endl;
    return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
int main(void) {
  string S;
  cin >> S;

  reverse(S.begin(), S.end());

  for (int i = 0; i < 4; i++) {
    reverse(divide[i].begin(), divide[i].end());
  }
  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  if (can) {
    cout << "YES" << endl;
    return 0;
  }

  cout << "NO" << endl;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll pre[200005];
    int a[200005];
     
     
    int main() {
    int n,i,c,k;
        scanf("%d%d%d",&n,&c,&k);
       int ans = 0;
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int pr = 0;
        int co = 0;
        for(i=0;i<n;i++)
            {
            if(a[i] <= a[pr] + k)
                {
                co++;
                if(co==c)
                    {
                    ans++;
                    co = 0;
                    pr = i+1;
                }
            }
            else {
                ans++;
                co = 1;
                pr = i;
            }
        }
        if(co)ans++;
        printf("%d\n",ans);
        return 0;
    }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  char n[5];
  cin>>n[0]>>n[1]>>n[2];
  sort(n,n +3);
  if(n[0]=='a' && n[1]=='b' && n[2]=='c') cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
  return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

const int MAXV = 90000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    vector< vector<ll> > dp1(n + 1, vector<ll>(MAXV + 1, 0));
    vector< vector<ll> > dp2(n + 1, vector<ll>(MAXV + 1, 0));
    dp1[0][0] = 1;
    dp2[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= MAXV; j++) {
            dp1[i + 1][j] = dp1[i][j] * 2 % MOD;
            dp2[i + 1][j] = dp2[i][j];
            if (j >= a[i]) {
                (dp1[i + 1][j] += dp1[i][j - a[i]]) %= MOD;
                (dp2[i + 1][j] += dp2[i][j - a[i]]) %= MOD;
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i <= sum; i++) {
        int ab = sum - i;
        if (i < ab) continue;
        if (i == ab) (ans += (dp1[n][i] + MOD - dp2[n][i]) % MOD) % MOD;
        else (ans += dp1[n][i]) %= MOD;
    }
    cout << (modpow(3, n) + MOD - ans * 3 % MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 424512
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned long long u64;
const int N=50;
int n, k, s, t, a[N], cnt;
u64 set[2*N], com[N+1][N+1], ans;
void dfs(int x, int nmust, int nmay, u64 must, u64 may) {
	if(nmust>k) return;
	while(x<cnt && (set[x]&must)) ++x;
	if(x==cnt) {
		int tmp=std::min(k, nmay)-nmust;
		ans+=com[nmay-nmust][tmp];
		return;
	}
	u64 cur=set[x]&may;
	if(cur==0) return;
	for(; cur; cur&=cur-1) {
		int id=__builtin_ctzll(cur);
		dfs(x+1, nmust+1, nmay, must|1llu<<id, may);
		--nmay;
		may^=1llu<<id;
	}
}
void gg() {
	puts("0");
	exit(0);
}
int main() {
	std::random_device dev;
	std::mt19937 rng(dev());
	scanf("%d%d%d%d", &n, &k, &s, &t);
	for(int i=0; i<n; ++i) {
		scanf("%d", a+i);
		if((a[i]&s)!=s || (a[i]|t)!=t) {
			--i;
			--n;
		}
	}
	if(n==0) gg();
	for(int i=0; i<=n; ++i) {
		com[i][0]=com[i][i]=1;
		for(int j=1; j<i; ++j)
			com[i][j]=com[i-1][j-1]+com[i-1][j];
	}
	for(int i=0; i<=n; ++i) {
		for(int j=1; j<=i; ++j)
			com[i][j]+=com[i][j-1];
	}
	for(int i=0; i<18; ++i) {
		int ss=s>>i&1, tt=t>>i&1;
		if(ss!=tt) {
			u64 cur=0;
			for(int j=0; j<n; ++j) {
				if(~a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
			cur=0;
			for(int j=0; j<n; ++j) {
				if(a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
		}
	}
	if(cnt==0) {
		printf("%lld\n", com[n][k]-1);
		return 0;
	}
	std::shuffle(set, set+cnt, rng);
	dfs(0, 0, n, 0, (1llu<<n)-1);
	printf("%llu\n", ans);
	return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>

int main(void)
{
    int n, m;
    scanf("%d %d", &n ,&m);

    int Aarray[n][m];
    int barray[m];
    int i, j;

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &Aarray[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        scanf("%d", &barray[i]);
    }

    int carray[n];
    for(i = 0; i < n; i++){
        carray[i] = 0;
    }
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            carray[i] += Aarray[i][j] * barray[j];
        }
        printf("%d", carray[i]);
        printf("\n");
    }

    return 0;
}


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

using namespace std;

#define ll long long
#define vl vector<ll>
#define pb push_back
#define sz size
#define xx first
#define yy second

#define all(x) begin(x), end(x)

#define FOR(i,start,end) for(ll i=start; i < end; ++i)
#define FORD(i,start,end) for(ll i=end-1; i >= start; --i)

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

  ll n = s.sz();
  ll m = t.sz();

  vector<vl> letters;
  letters.resize(26);

  FOR(i,0,n) {
    letters[s[i] - 'a'].pb(i);
  }

  ll i = -1;
  FOR(j,0,m) {
    ll ind = t[j] - 'a';
    if(letters[ind].sz() == 0)
      goto fail;

    auto a = lower_bound(all(letters[ind]), i % n+1);

    ll x = -1;
    if(a != letters[ind].end())
      x = *a;

    if(x >= 0) {
      i += x - i % n;
    } else {
      i += n + letters[ind][0] - i % n;
    }
  }

  cout << i+1 << endl;
  return 0;
 fail:
  cout << -1 << endl;
}


Measured memory_bytes: 1724
from bisect import bisect_left as b_l
n,q=map(int,input().split())
s=input()
pi=0
aci=[]
while 1:
    ni=s[pi:].find("AC")
    if ni==-1:
        break
    aci+=[ni+pi]
    pi+=ni+1
for i in range(q):
    si,ei=map(int,input().split())
    print(b_l(aci,ei-1)-b_l(aci,si-1))

Measured memory_bytes: 5780
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<pair<ll,ll> > v[200000];
bool maki[200000];
ll d[200000];
void dfs(int x){
    ll niko=v[x].size();
    for(int i=0;i<niko;i++){
        if(!maki[v[x][i].first]){
            maki[v[x][i].first]=true;
            d[v[x][i].first]=d[x]+v[x][i].second;
            dfs(v[x][i].first);
        }
    }
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(maki,0,sizeof(maki));
    memset(d,0,sizeof(d));
    ll n,m;
    cin>>n>>m;
    ll l[m],r[m],dis[m];
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i]>>dis[i];
        l[i]--;r[i]--;
        v[l[i]].pb(make_pair(r[i],dis[i]));
        v[r[i]].pb(make_pair(l[i],-dis[i]));
    }
    for(int i=0;i<n;i++){
        if(!maki[i]){
            maki[i]=true;
            dfs(i);
        }
    }
    bool ans=true;
    for(int i=0;i<m;i++){
        if(d[r[i]]-d[l[i]]!=dis[i]){
            ans=false;
        }
    }
    cout << ((ans)?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 24448
import java.util.Scanner;

public class Main{

	/**与えられた文字列の大文字と小文字を入れ替える。
	 *
	 * @param args
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){

		
		for(;scan.hasNext();){
			char[] swap = scan.nextLine().toCharArray();
		//	char[] swap = scan.next().toCharArray();	//char型の配列に格納する
			for(int i=0;i<swap.length;i++){
				if(Character.isUpperCase(swap[i])){			//大文字の場合
					swap[i] = Character.toLowerCase(swap[i]);
				}else if(Character.isLowerCase(swap[i])){		//小文字の場合
					swap[i] = Character.toUpperCase(swap[i]);
				}else{
					//swap[i];
				}
			}
			StringBuffer sb = new StringBuffer(new String(swap));
			System.out.print(sb.toString());
			System.out.println();
		}
	}
}




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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]){
		cout << "Yes" << endl;
		return 0;
	}
	if(s[1] == s[2] && s[2] == s[3]){
		cout << "Yes" << endl;
		return 0;
	}

		cout << "No" << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,sum=0;
	cin>>n;
	vector<int>t(n);
	for(int i=0;i<n;++i){
		cin>>t.at(i);
		sum+=t.at(i);
	}
	cin>>m;
	for(int i=0,p,x;i<m;++i){
		cin>>p>>x;
		cout<<sum+x-t.at(p-1)<<"\n"s;
	}
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
#include <cmath>
#include <vector>
#include <algorithm>

void dump(int a[],int n)
{
  for (int codeTest = 0; codeTest < n; ++codeTest) {
    if (codeTest!=0)std::cout << " ";
    std::cout << a[codeTest];
  }
  std::cout << '\n';
}

int main() {
  int n,k,h[100000],i,ans=0;
  std::cin >> n>>k;
  for (i = 0; i < n; ++i) {
    std::cin >> h[i];
  }
  for (i = 0; i < n; ++i) {
    ans+=(h[i]>=k);
  }
  std::cout << ans << '\n';
}


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

using ll = long long;

int main() {
    int N, A, x;
    ll dp[51][2501];
    rep(i, 51) rep(j, 2501) dp[i][j] = 0;
    dp[0][0] = 1;
    cin >> N >> A;
    rep(i, N) {
        cin >> x;
        rep(l, i + 1) rep(k, i * 50 + 1) {
            int j = i - l;
            if (dp[j][k] > 0) {
                dp[j + 1][k + x] += dp[j][k];
                //cout << i << " " << j + 1 << " " << k + x << " " << dp[j + 1][k + x] << endl;
            }
        }
    }
    ll ans = 0;
    rep(i, N) {
        //cout << i + 1 << " " << dp[i + 1][(i + 1) * A] << endl;
        ans += dp[i + 1][(i + 1) * A];
    }
    cout << ans << endl;
}

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

int main(void)
{
	long long int a, b, i, x=0;
	cin >> a >> b;
	
	if(a < b)
	{
		for(i=a; i<=b; i++)
		{
			if(abs(a-i)==abs(b-i))
			{
				x = i;
				break;
			}
		}
		
		if(x > 0)
			cout << x << endl;
		else
			cout << "IMPOSSIBLE" << endl;
	}
	
	else{
		for(i=b; i<=a; i++)
	{
		if(abs(b-i)==abs(a-i))
		{
			x = i;
			break;
		}
	}
	
	if(x > 0)
		cout << x << endl;
		
	else
		cout << "IMPOSSIBLE" << endl;
	}
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = Integer.parseInt(in.next());
		int b = Integer.parseInt(in.next());
		int c = Integer.parseInt(in.next());
		
		System.out.println(a < b && b < c ? "Yes" : "No");
	}
}	


Measured memory_bytes: 26148
// concatなしバージョン

"use strict";
    
const main = arg => {
  let NumAmount = arg.split("\n")[0]*1;
  let Nums = arg.split("\n")[1].split(" ").map(n => n*1);  
  let ans = 0;
  let PlusNums = Nums.map(x=> x + 1);
  let MinusNums = Nums.map(x=> x - 1);
let AllArr = [...Nums,...PlusNums,...MinusNums];
  //console.log(AllArr);
  let AllArrObj = {};
  let AllArrValues = [];
  for(let i = 0; i < AllArr.length; i++){
  if( isNaN(AllArrObj[AllArr[i]]) ){
	AllArrObj[AllArr[i]] = 0;
  }
  AllArrObj[AllArr[i]] += 1;
  }
  //console.log(AllArrObj);
  // valueのみ抽出して最大値を求める
  Object.keys(AllArrObj).forEach( function(value) {
      AllArrValues.push(this[value]);
  }, AllArrObj)
  console.log(Math.max(...AllArrValues)); 
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 44008
#include<stdio.h>

int main(){
   int a[3][3];
   int i,j,n,b,h,judge = 0,ans = 0;
   for(i = 0; i < 3; i++){
      for(j = 0; j < 3; j++){
         scanf("%d",&a[i][j]);
      }
   }
   scanf("%d",&n);
   for(h = 0; h < n; h++){
      judge = 0;
      scanf("%d",&b);
      for(i = 0; i < 3; i++){
         for(j = 0; j < 3; j++){
            if(b==a[i][j]){
               a[i][j]=0;
               judge = 1;
               break;
            }
         }
         if(judge == 1){
            break;
         }
      }
   }

   
   if(a[0][0] == 0){
      if(a[0][1] == 0 && a[0][2] == 0){
         ans = 1;
      }else if(a[1][0] == 0 && a[2][0] == 0){
         ans = 1;
      }else if(a[2][2] == 0 && a[1][1] == 0){
         ans = 1;
      }
   }

   if(a[0][2] == 0){
      if(a[1][2] == 0 && a[2][2] == 0){
         ans = 1;
      }else if(a[1][1] == 0 && a[2][0] == 0)
         ans = 1;
   }

   if(a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0){
      ans = 1;
   }

   if(a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0){
      ans = 1;
   }

   if(a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0){
      ans = 1;
   }

   if(ans == 1){
      printf("Yes");
   }else{
      printf("No");
   }
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(int i = k; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    int n;
    cin >> n;
    vector<long long> l(n);
    rep(i, 0, n) cin >> l[i];

    sort(all(l));
    int cnt = 0;
    rep(i, 0, n - 2){
        rep(j, i + 1, n - 1){
            rep(k, j + 1, n){
                if(l[i] == l[j] or l[j] == l[k])continue;
                if(l[j] - l[i] < l[k] and l[k] < l[j] + l[i])cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
using namespace std;

bool check(int x){
	if(x == 2)return true;
	if(x < 2 || x%2 == 0)return false;
	for(int i = 3;i <= sqrt(x);i+=2){
		if(x%i == 0)return false;
	}
	return true;
}

int main(){
	int n,a,b;
	while(1){
		cin >> n;
		if(n == 0)break;
		if(check(n)){
			cout << 0 <<endl;
			continue;
		}
		for(int i = n + 1;i <= 1299709;i++){
			if(check(i)){
				a = i;
				break;
			}
		}
		for(int i = n - 1;i >= 3;i--){
			if(check(i)){
				b = i;
				break;
			}
		}
		cout << a - b <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, a, b;
        cin>>n>>a>>b;
        ll ans = 0;
        ans = (n/(a+b))*a;
        n%=(a+b);
        ans  += min(n, a);
        cout<<ans;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << x << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> adj[100001];
int vis[100001];
int it = 1;
void dfs(int c){
    vis[c] = it;
    FORR(i,adj[c]){
        if(vis[i]) continue;
        dfs(i);
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m;
    sc(n,m);
    int a[n];
    GET(a);
    pair<int,int> op[m];
    FORR(i,op){
        sc(i.e1,i.e2);
        --i.e1;--i.e2;;
        adj[i.e1].push_back(i.e2);
        adj[i.e2].push_back(i.e1);
    }
    FOR(i,0,n){
        if(vis[i]) continue;;
        dfs(i);
        ++it;
    }
    int r = 0;
    FOR(i,0,n){
        r += vis[i] == vis[a[i]-1];
    }
    cout << r << '\n';
}



Measured memory_bytes: 9344
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 10;
const i64 MAXM = 10;
const i64 MAXQ = 50 + 5;

i64 cnt[MAXN + 2][MAXN + 2];

i64 a, b, n;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    
    cin >> a >> b >> n;

    i64 x = min(n, b - 1);
    i64 R = a * x / b - a * (x / b);
    cout << R << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, l, r = 1e7, mid;
vector<pair<int, int> >e[150007], p[150007], tmp;
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c > '9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w)
{
	p[w].clear();
	if (e[w].empty())
	{
		p[w].push_back(make_pair(0, 0));
		return 0;
	}
	dfs(e[w][0].first);
	dfs(e[w][1].first);
	if (p[e[w][0].first].empty() || p[e[w][1].first].empty())return 0;
	vector<pair<int, int> >& a = p[e[w][0].first], & b = p[e[w][1].first];
	int add = e[w][0].second + e[w][1].second;
	int s1 = a.size(), s2 = b.size();
	tmp.clear();
	for (int i = 0, j = 0; i < s1; i++)
	{
		while (j < s2 - 1 && a[i].second + b[j + 1].first + add <= mid)
			j++;
		if (a[i].second + b[j].first + add <= mid)
			p[w].push_back(make_pair(a[i].first + e[w][0].second, b[j].second + e[w][1].second));
	}
	for (int i = 0, j = 0; i < s2; i++)
	{
		while (j < s1 - 1 && b[i].second + a[j + 1].first + add <= mid)
			j++;
		if (b[i].second + a[j].first + add <= mid)
			p[w].push_back(make_pair(b[i].first + e[w][1].second, a[j].second + e[w][0].second));
	}
	sort(p[w].begin(), p[w].end());
	if (!p[w].empty())
	{
		tmp.push_back(p[w][0]);
		for (int i = 1, s = p[w].size(); i < s; i++)
			if (p[w][i].first != p[w][i - 1].first && p[w][i].second < p[w][i - 1].second)
				tmp.push_back(p[w][i]);
		swap(tmp, p[w]);
	}
	return 0;
}
signed main()
{
	n = read();
	for (int i = 2; i <= n; i++)
	{
		int a = read(), b = read();
		e[a].push_back(make_pair(i, b));
	}
	while (l < r)
	{
		mid = (l + r) / 2;
		dfs(1);
		if (!p[1].empty())r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 70372
// ABC165D - 

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int A, B, N;
	cin >> A >> B >> N;

	long long int ans = 0;
	if (N >= B - 1) {
		ans = A*(B-1)/B;
	} else {
		ans = A*N/B;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632