akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

vector<int> adj[100001];
int v[100001];
int dp[100001];

void dfs(int node)
{
    v[node]=1;
    for(int i=0;i<adj[node].size();i++)
    {
        if(!v[adj[node][i]])
            dfs(adj[node][i]);
    }
    for(int i=0;i<adj[node].size();i++)
        dp[node]=max(dp[node],1+dp[adj[node][i]]);
}
void go()
{
    int n,m;
    cin>>n>>m;
    memset(v,0,sizeof(v));
    memset(dp,0,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        int p,q;
        cin>>p>>q;
        adj[p].push_back(q);
    }
    for(int i=1;i<=n;i++)
    {
        if(!v[i])
            dfs(i);
    }
    cout<<*max_element(dp,dp+100001);
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}



Measured memory_bytes: 11848
a,b,c=map(int,input().split())
ans=0
while 1:
  if a%2>0 or b%2>0 or c%2>0:
    break
  if a==b and b==c:
    ans=-1
    break
  a,b,c=b//2+c//2,c//2+a//2,a//2+b//2
  ans+=1
print(ans)

Measured memory_bytes: 38384
package main

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

func pow(base int, exponent int) int {
	if exponent == 0 {
		return 1
	}

	result := 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			result %= 998244353
		}
		exponent >>= 1
		base *= base
		base %= 998244353
	}
	return result
}

func main() {
	N := readInt()
	D := readInts(N)

	if D[0] != 0 {
		fmt.Println(0)
		return
	}

	c := map[int]int{}
	maxD := 0
	for _, i := range D {
		c[i]++
		if i > maxD {
			maxD = i
		}
	}

	if c[0] != 1 {
		fmt.Println(0)
		return
	}

	result := 1
	for i := 1; i <= maxD; i++ {
		if _, ok := c[i]; !ok {
			fmt.Println(0)
			return
		}
		result *= pow(c[i-1], c[i])
		result %= 998244353
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 8192
#include <iostream>
#include <queue>
#include <utility>
#include <string>

using namespace std;

typedef pair<string, int> task;

int main()
{
    queue<task> queue;
    int n;
    int q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        string name;
        int time;

        cin >> name >> time;
        queue.push(task(name, time));
    }

    int total = 0;
    while (!queue.empty()) {
        task t = queue.front();
        queue.pop();

        if (t.second <= q) {
            total += t.second;
            cout << t.first << " " << total << endl;
        } else {
            total += q;
            t.second -= q;
            queue.push(t);
        }
    }
}

Measured memory_bytes: 6284
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, a, b;
deque <int> d;

int main() {

    scanf("%d", &n);
    scanf("%d %d", &a, &b);

    if (1ll * a * b < n || a + b > n + 1) {
        puts("-1");
        return 0;
    }

    for (int i = 1; i <= a; i++)
        d.push_back(i);

    int num = a + 1;
    for (int i = 1; i <= b - 1; i++) {
        int len = (n - a) / (b - 1);
        if (i <= (n - a) % (b - 1))
            len++;

        for (int j = num + len - 1; j >= num; j--)
            d.push_front(j);

        num = num + len;
    }

    for (int i = 0; i < n; i++) {
        printf("%d ", d.front());
        d.pop_front();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3440
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();

		System.out.println(A==B && B!=C || A==C&&A!=B || B==C&&B!=A?"Yes":"No");

		scan.close();
	}

}


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

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

    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B/2 << endl;
    } else {
        cout << 0 << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const lb pi=acos(-1);
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;



int main(){

  ll a,b;cin>>a>>b;
  ll h,m;cin>>h>>m;

  lb hc=h*30+0.5*m;
  lb mc=6*m;

  lb rad=pi*abs(hc-mc)/180;
  // lb rad=abs((min(180-abs(hc-mc),abs(hc-mc))));

  out(setprecision(12)<<sqrt(a*a+b*b-(lb)2*a*b*cos(rad)));

  return 0;
}


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

int match(int x, int y, int z) {
    return (x * x + y * y + z * z + x * y + x * z + y * z);
}

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

    vector<int> ans(N + 1, 0);

    int mx = N;
    for(int x = 1; x <= mx; x++) {
        for(int y = x; y <= mx; y++) {
            for(int z = y; z <= mx; z++) {
                int a = match(x, y, z);
                if(a > N){
                    break;
                }
                if(x == y && y == z) {
                    ans.at(a)++;
                } else if(x == y || y == z || x == z) {
                    ans.at(a) += 3;
                } else {
                    ans.at(a) += 6;
                }
            }
        }
    }

    for(int i = 1; i <= N; i++) {
        cout << ans.at(i) << endl;
    }

    return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
int n, k;
int a[N];

int check(int x) {
    int num = 0;
    for (int i = 1; i <= n; i++) {
        num += (a[i] + x - 1) / x - 1;
    }
    return num <= k;
}

int main() {
    scanf("%d%d", &n, &k);
    int maxx = INT_MIN;
    for (int i = 1; i <= n; i++)scanf("%d", &a[i]), maxx = max(maxx, a[i]);
    int ans = 0;
    int l = 1, r = maxx;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid))r = mid - 1, ans = mid;
        else l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int K, X;
  cin >> K >> X;

  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    REP(i, N){
        cin >> A[i];
    }
    REP(i, M){
        cin >> B[i];
    }
    for (int i = 0; i <= N - M; i++) {
        for (int j = 0; j <= N - M; j++) {
            bool flag = true;
            REP(ii, M){
                REP(jj, M){
                    if(A[i+ii][j+jj] != B[ii][jj]){
                        flag = false;
                    }
                }
            }
            if(flag){
                pr("Yes");
                return 0;
            }
        }   
    }

    pr("No");
}

Measured memory_bytes: 764
using System;
class coffee
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s[2] == s[3] && s[4] == s[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}




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

int s,w;
cin >> s >> w;
if(w >= s) cout << "unsafe" << endl;
else cout << "safe" << endl;







//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define INF (1LL << 60)
typedef long long LL;
using namespace std;

int main() {
	int num[10] = {10, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
	int n, m;	cin >> n >> m;
	vector<int> a(m);
	for (auto &x : a) {
		cin >> x;
	}

	vector<LL> dp(n + 1, -INF);
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		for (auto x : a) {
			if (i < num[x]) continue;
			dp[i] = max(dp[i], dp[i - num[x]] + 1);
		}
	}
	
	sort(a.begin(), a.end(), std::greater<int>());

	LL match = n;
	while (match > 0) {
		for (auto x : a) {
			if (match < num[x]) continue;
			if (dp[match - num[x]] == dp[match] - 1) {
				cout << x;
				match -= num[x];
				break;
			}
		}
	}
}


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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

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

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

int main() {
	FREOPEN();
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > item;
	for (int i = 1; i <= n; i++) {
		int cost, cnt;
		scanf("%d %d", &cost, &cnt);
		item.pb({cost, cnt});
	}
	sort(All(item));
	ll ans = 0;
	for (auto i : item) {
		if (m <= 0) break;
		ans += i.F * 1ll * min(i.S, m);
		m -= i.S;
	}
	printf("%lld", ans);
	return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理

    // 出力
    cout << (s[0] == s[2] ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

vector<int> x(3);

void init()
{
	rep(i, 3) cin >> x[i];
}

bool ch()
{
	return x[0] % 2 == 0 && x[1] % 2 == 0 && x[2] % 2 == 0;
}

void solve()
{
	if (x[0] == x[1] && x[1] == x[2]) {
		if (x[0] % 2 == 0) {
			cout << -1 << endl;
			return;
		}
		cout << 0 << endl;
		return;
	}
	int res = 0;
	while (ch()) {
		res++;
		int y[3];
		y[2] = (x[0] + x[1]) / 2;
		y[0] = (x[1] + x[2]) / 2;
		y[1] = (x[2] + x[0]) / 2;
		rep(i, 3) x[i] = y[i];
	}
	cout << res << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define ff first
#define ss second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
#define d(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define IO ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define mem(a, b) memset(a,b,sizeof(a))

int main()
{
    int a, b, c, k; cin >> a >> b >> c >> k;
    int ans = 0;
    ans += min(k, a);
    k -= min(k, a);
    k -= min(k, b);
    ans -= min(k, c);
    cout << ans << endl;
    return 0;
}












Measured memory_bytes: 3636
package main
 
import "fmt"
 
const N = 105
const W = 1e5+5

var vs [N]int
var ws [N]int
var T [W]int64

/*
T(i, j) 表示前 i 个物品用了 j 容量达到的最大值
T(i, j) = max{T(i-1, j), T(i-1, j-w_i) + v_i}
*/

func zeroOnePack(T []int64, w, v int, totalW int) {
  for i := totalW; i - w >= 0; i-- {
    umax(&T[i], T[i-w] + int64(v))
  }
}
 
func umax(current *int64, val int64) {
  if val > *current {
    *current = val
  }
}
 
func main() {
  var n, w int
  fmt.Scanf("%d %d", &n, &w)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d %d", &ws[i], &vs[i])
  }
  for i := 0; i <= w; i++ {
    T[i] = 0
  }
  for i := 0; i < n; i++ {
    zeroOnePack(T[:w+1], ws[i], vs[i], w)
  }
  
  fmt.Println(T[w])
}


Measured memory_bytes: 2648
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // @DONE: Plan solve [DOCUMENT TIME]
        // @DONE: Test on paper [DOCUMENT TIME]
        // @DONE: Implement solve [DOCUMENT TIME]
        Scanner in = new Scanner(System.in);

        String s = in.nextLine();
        System.out.println(s.replaceAll(","," "));
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>()
#define VLL vector<long long>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define PI 3.14159265359
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int A, B, H, M; cin >> A >> B >> H >> M;
    double short_rad = 30 * H + M * 0.5, long_rad = M * 6;
  	if(long_rad == 0)  long_rad += 360;
  	if(short_rad == 0)  short_rad += 360;
    printf("%.16lf\n", sqrt(A*A + B*B - 2*A*B*cos((max(long_rad, short_rad) - min(long_rad, short_rad))/180*PI)));
    return 0;
}


Measured memory_bytes: 4208
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		H = 1;
		W = H;
	}
	cout << (H * W + 1) / 2 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

ll MOD (ll a) {
    if (a < 0)
        a += mod;
    return (a % mod);
}

void testCase() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i=k; i<=n+1; i++) {
        ll mn = (i*(i-1))/2;
        ll mx = (i*(2*n-i+1))/2;
       // cout << mn << " " << mx << endl;
        ans = MOD(ans + MOD (mx - mn + 1));
    }
    cout << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

struct Rectangle{
  int l,r,t,b;
  Rectangle(int _l,int _r,int _t,int _b):l(_l),r(_r),t(_t),b(_b){}
  Rectangle(){}
};

int Solve(int n){
  std::vector<Rectangle> rectangle;
  std::map<int,int> x_map,y_map;
  std::set<int> x_set,y_set;
  for(int i=0;i<n;i++){
    int l,t,r,b;
    cin>>l>>t>>r>>b;
    rectangle.push_back(Rectangle(l,r,t,b));
    x_set.insert(l);
    x_set.insert(r);
    y_set.insert(t);
    y_set.insert(b);
  }
  auto x_itr=x_set.begin();
  auto y_itr=y_set.begin();
  for(int i=0;i<x_set.size();i++){
    // cout<<*x_itr<<endl;
    x_map.insert(std::make_pair(*x_itr,i));
    x_itr++;
    // cout<<x_map[*x_itr]<<endl;
  }
  for(int i=0;i<y_set.size();i++){
    y_map.insert(std::make_pair(*y_itr,i));
    y_itr++;
  }
  for(auto &r:rectangle){
    r.l=x_map[r.l];
    r.r=x_map[r.r];
    r.b=y_map[r.b];
    r.t=y_map[r.t];
  }

  const int limit=500;

  char plane[limit][limit];
  for(int r=0;r<limit;r++){
    for(int c=0;c<limit;c++){
      plane[r][c]='.';
    }
  }

  for(auto r:rectangle){
    for(int i=r.b*2+2;i<=r.t*2+2;i++){
      plane[i][r.l*2+2]='#';
      plane[i][r.r*2+2]='#';
    }
    for(int i=r.l*2+2;i<=r.r*2+2;i++){
      plane[r.b*2+2][i]='#';
      plane[r.t*2+2][i]='#';
    }
  }

  int result=0;
  for(int row=0;row<limit;row++){
    for(int col=0;col<limit;col++){
      if(plane[row][col]=='.'){
        result++;
        typedef std::pair<int,int> pair;
        std::queue<pair> q;
        q.push(std::make_pair(row,col));
        while(!q.empty()){
          pair curr=q.front();
          q.pop();
          plane[curr.first][curr.second]='#';
          for(int vr=-1;vr<=1;vr++){
            for(int vc=-1;vc<=1;vc++){
              if((vr==0&&(vc==-1||vc==1))||(vc==0&&(vr==-1||vr==1))){
                if(curr.first+vr<0||limit<=curr.first)continue;
                if(curr.second+vc<0||limit<=curr.second+vc) continue;
                if(plane[curr.first+vr][curr.second+vc]=='.'){
                  plane[curr.first+vr][curr.second+vc]='#';
                  q.push(std::make_pair(curr.first+vr,curr.second+vc));
                }
              }
            }
          }
        }
      }
    }
  }

  return result;

}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  while(true){
    int n;
    cin>>n;
    if(n==0) break;
    cout<<Solve(n)<<endl;
  }

  return 0;
}




Measured memory_bytes: 3352
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
b = list(sorted(x))
c = list()
for i in range(N):
    c.append(b[i+1]-b[i])

t = 0
for i in range(N):
    t = fractions.gcd(t, c[i])
print(t)

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

int main(){
  string A, B;
  cin >> A>> B;

  

  if (A.size() > B.size()){
    cout << "GREATER" << endl;
  }
  else if (A.size() == B.size())
  {
    for (int i = 0; i < A.size(); i++)
    {
      if (A.at(i) > B.at(i)){
        cout << "GREATER" << endl;
        return 0;
      }
      else if (A.at(i) == B.at(i) && i == A.size() - 1)
      {
        cout << "EQUAL" << endl;
        
      }
      else if (A.at(i) < B.at(i))
      {
        cout << "LESS" << endl;
        return 0;
      }
      
      
    }
    
  }
  else
  {
    cout << "LESS" << endl;
  }

  
}

Measured memory_bytes: 3588
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long S=sc.nextLong();
		long C=sc.nextLong();

		if(C>=S*2) {
			System.out.println(S+(C-2*S)/4);
		}
		else {
			/*
			long fs=C/2;
			long zanC=C-fs*2+(S-fs)*2;
			System.out.println(fs+zanC/4);
			*/
			System.out.println(C/2);
		}
	}
}

Measured memory_bytes: 22736
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <set>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	VI A(2*n);
	for (int i = 0; i < 2*n; ++i) cin >> A[i];
	sort(A.begin(), A.end());
	int ans = 0;
	for (int i = 0; i < 2*n; i += 2) ans += A[i];
	cout << ans;
}

Measured memory_bytes: 256
N = int(input())

a = [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]

print(a[N-1])

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

void solve() {
	ll n; cin >> n;
	vector<ll> v;
	rep1(i, 1000000) {
		if (n%i == 0) {
			v.push_back(i);
			v.push_back(n / i);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	ll ans = 0;
	rep(i, v.size()) {
		ll k = v[i]; ll m = n / k - 1;
		if (k < 0||k>=m)continue;
		if (m <= 0)continue;
		ans += m;
		//cout << m << endl;
	}
	cout << ans << endl;
}

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


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

int ff(int x){
    int ans = 0;
    while(x != 0){
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

void solve()
{
    int n;
    cin >> n;
    if(n % ff(n) == 0) {
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
using MIte = multimap<vector<long>, int>::iterator;

const long long mod_const = 1000000007;

// i段目までの行き方
long long Pattern(int i, const vector<int>& vA) {
	if (i == 0) {
		return 1;
	}
	else if (i == 1) {
		return 1;
	}
	else {
		long long a = 0;
		long long b = 0;
		if (vA[i - 2] == 0) a = 1;
		if (vA[i - 1] == 0) b = 1;
		return ((a * Pattern(i - 2, vA) + b * Pattern(i - 1, vA)) % mod_const);
	}
}

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

	vector<int> vA(N+1, 0);
	for (int i = 0; i != M; ++i) {
		int w = 0;
		cin >> w;
		vA[w] = 1;
		if (w >= 1) {
			if (vA[w - 1] == 1) {
				cout << "0" << endl;
				return 0;
			}
		}
	}

	vector<long long> vPattern(N + 1, 0);
	vPattern[0] = 1;
	vPattern[1] = 1;
	int i = 2;
	if (N >= 2) {
		while (1) {
			long long a = 0;
			long long b = 0;
			if (vA[i - 2] == 0) a = 1;
			if (vA[i - 1] == 0) b = 1;
			if (vA[i] == 0) {
				vPattern[i] = (a * vPattern[i - 2] + b * vPattern[i - 1]) % mod_const;
			}
			else {
				vPattern[i] = 0;
			}
			i++;
			if (i == N + 1) {
				break;
			}
		}
	}

	cout << vPattern[N] << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    string S;
    cin >> S;

    rep(i,4){
        bool tok = true;
        vc<bool> B(N);
        if (i & 1) B[0] = true;
        if (i & 2) B[1] = true;

        repe(i, 1, N){
            ll l = i - 1, r = (i + 1) % N;
            
            // wolf
            if(B[i]){
                B[r] = (S[i] == 'o' ? !B[l] : B[l]);
            }
            // sheep
            else{
                B[r] = (S[i] == 'o' ? B[l] : !B[l]);
            }
        }

        if(B[0]){
            if((S[0]=='o' and B[1]==B[N-1]) or (S[0]=='x' and B[1]!=B[N-1]))
                tok = false;
        }
        else{
            if((S[0]=='o' and B[1]!=B[N-1]) or (S[0]=='x' and B[1]==B[N-1]))
                tok = false;
        }
        if(B[1]){
            if((S[1]=='o' and B[2]==B[0]) or (S[1]=='x' and B[2]!=B[0]))
                tok = false;
        }
        else{
            if((S[1]=='o' and B[2]!=B[0]) or (S[1]=='x' and B[2]==B[0]))
                tok = false;
        }
        

        if(tok){
            string ans;
            rep(i, N) ans += (B[i] ? 'W' : 'S');
            cout << ans << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 720
#include<stdio.h>
int main(void)
{
	int k,s,i,j,c,z;
	scanf("%d%d",&k,&s);
	c=0;
	for(i=0;i<=k;i++){
		for(j=0;j<=k;j++){
			z=s-i-j;
			if(z<=k&&z>=0) c++;
		}		
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M = inm()


def solve():
    accepted = [False] * N
    wacount = [0] * N
    for i in range(M):
        p, s = ins().split()
        p = int(p) - 1
        if s == "AC":
            accepted[p] = True
            continue

        assert s == "WA"
        if accepted[p]:
            continue
        wacount[p] += 1
    ac = wa = 0
    for i in range(N):
        if accepted[i]:
            ac += 1
            wa += wacount[i]
    return ac, wa


print(*solve())


Measured memory_bytes: 10576
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
m = max(a)
d = Counter(a)

ans = 0
for i in range(-1, m+2):
  count = 0
  if i in d.keys():
    count += d[i]
  if i+1 in d.keys():
    count += d[i+1]
  if i-1 in d.keys():
    count += d[i-1]
  ans = max(ans, count)
print(ans)

Measured memory_bytes: 14564
# coding: utf-8
# Your code here!

N=int(input())
A=list(map(int,input().split()))

Alice=0
Bob=0

A.sort()
A.reverse()

for i in range(len(A)):
    if i%2==0:
        Alice+=A[i]
    else:
        Bob+=A[i]
        
print(Alice-Bob)

Measured memory_bytes: 3064
n = int(input())
dat = []
import itertools
for _ in range(n):
    x, y = map(int, input().split())
    dat.append((x,y))
import math
allsum = 0
for a in itertools.permutations(range(n)):
    x, y = dat[a[0]]
    s = 0
    for b  in range(1, n):
        nx, ny = dat[a[b]]
        s += math.sqrt( (nx-x)**2 + (ny-y)**2 )
        x, y = nx, ny
    allsum += s
res = allsum / math.factorial(n)
print(res)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int read()
{
	int i=0,f=1;char c=getchar();
	while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {i=i*10+c-'0';c=getchar();}
	return i*f;
} 
struct cx
{
	int c,t;
}e[1010];
bool cmp(cx x,cx y)
{
	return x.c<y.c;
}
int main()
{
	int n,T;
	n=read(),T=read();
	for(int i=1;i<=n;i++)
	e[i].c=read(),e[i].t=read();
	sort(e+1,e+1+n,cmp);
	int v=0;
	for(int i=1;i<=n;i++)
	{
		if(e[i].t<=T)
		{
			cout<<e[i].c<<endl;
			v=1;
			break;
		}
	} 
	if(v==0) puts("TLE");
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

double get (ll x) {
	double a = 1.01, res = 1.0;
	while (x > 0) {
		if (x & 1)
			res *= a;
		x >>= 1;
		a *= a;
	}
	return res * 100;
}

int main () {
	SpeedForce;
	ll x;
	cin >> x;
	ll cur = 100;
	while (cur < x) {
		cur *= 1.01;
		++ans;
	}

	cout << ans << '\n';
	return Accepted;
}

// B...a

Measured memory_bytes: 17732
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 100002;
ll lis[MAX] = {};
ll t[MAX] = {};
ll a[MAX] = {};


int main(){
    
    int flag = 1;
    ll n;
    cin >> n;
    for (ll i=1;i<=n;i++){
        cin >> t[i];
    }
    for (ll i=1;i<=n;i++){
        cin >> a[i];
    }
    for (ll i=1;i<=n;i++){
        if(t[i] != t[i-1]){
            lis[i] = t[i];
        }
    }

    for (ll i=n;i>=1;i--){
        if(a[i] != a[i+1]){
            if(lis[i] != 0 and lis[i] != a[i]){
                cout << 0 << endl;
                flag = 0;
                break;
            }
            lis[i] = a[i];
        }
    }
    if(flag) {
        for (ll i = 1; i <= n; i++) {
            if (lis[i] > t[i] or lis[i] > a[i]) {
                cout << 0 << endl;
                flag = 0;
                break;
            }
        }
    }
    ll ans = 1;
    if(flag){
        for(ll i=1;i<=n;i++){
            if(lis[i] == 0) {
                ans *= min(a[i], t[i]);
                ans %= mop;
            }
        }
        cout << ans << endl;
    }


}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll> a;
int main() {
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll ans=inf;
	for(int i=0;i+k-1<n;i++){
		ll now=a[i+k-1]-a[i];
		ans=min(ans,now);
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

bool is_hamming[1000010];

void hamming(int n){
	memset(is_hamming,false,sizeof(is_hamming));
	queue<int> q;
	q.push(1);
	while(q.size()){
		int t=q.front(); q.pop();
		is_hamming[t]=true;
		if(2*t<=n) q.push(2*t);
		if(3*t<=n) q.push(3*t);
		if(5*t<=n) q.push(5*t);
	}
	return;
}

int sum[1000010];

signed main(){
	hamming(1000000);
	rep(i,1,1000001){
		sum[i]=sum[i-1];
		if(is_hamming[i]) sum[i]++;
	}
	int n,m;
	while(1){
		cin>>n;
		if(n==0) break;
		cin>>m;
		o(sum[m]-sum[n-1]);
	}
}

Measured memory_bytes: 10140
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    //int T; cin >> T;
    //while(T--) 
 	//{
  //    
  //}
	ll A,B,N;
	cin>>A>>B>>N;
	ll val=N/B;
	val=val*B;
	val--;
	if(N<B)
		val=N;
	cout<<(val*A)/B-A*(val/B);
	return 0;
}
 


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

int main() {
char c;
cin>>c;
if(c=='a'){
cout<<"vowel"<<endl;
}else if(c=='i'){
cout<<"vowel"<<endl;
}else if(c=='u'){
cout<<"vowel"<<endl;
}else if(c=='e'){
cout<<"vowel"<<endl;
}else if(c=='o'){
cout<<"vowel"<<endl;
}else{
cout<<"consonant"<<endl;
}
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 1e5 + 5;

int par[maxn], N, sub[maxn];
pair<ll, int> d[maxn];
ll f[maxn];
vector<int> adj[maxn];
int depth[maxn], sz[maxn];

void dfs(int u = 1, int p = -1)
{
  sz[u] = 1;
  f[1] += depth[u];
  for(int v : adj[u]) if(v != p){
    depth[v] = depth[u] + 1;
    dfs(v, u);
    sz[u] += sz[v];
  }
}

void reroot(int u = 1, int p = -1)
{
  for(int v : adj[u]) if(v != p){
    f[v] = f[u] + N - 2 * sz[v];
    reroot(v, u);
  }
}

bool check(void)
{
  for(int i = 1; i <= N; ++i)
    if(par[i]) adj[par[i]].pb(i), adj[i].pb(par[i]);
  dfs(); reroot();
  for(int i = 1; i <= N; ++i){
    if(f[d[i].se] != d[i].fi) return false;
  }
  return true;
}

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if(fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  cin >> N;
  for(int i = 1; i <= N; ++i){
    cin >> d[i].fi;
    d[i].se = i;
    sub[i] = 1;
  }
  sort(d + 1, d + 1 + N);
  for(int i = N; i >= 2; --i){
    int j = lower_bound(d + 1, d + 1 + N, mp(d[i].fi - (N - 2 * sub[d[i].se]), -1)) - d;
    if(i == j) ++j;
    if(d[j].fi != d[i].fi - (N - 2 * sub[d[i].se])){
      cout << -1;
      return 0;
    }
    par[d[i].se] = d[j].se;
    sub[d[j].se] += sub[d[i].se];
  }
  if(!check()){
    cout << -1;
    return 0;
  }
  for(int i = 1; i <= N; ++i){
    if(par[i]) cout << i << ' ' << par[i] << '\n';
  }
}


Measured memory_bytes: 16896
from collections import deque
H,W,K = map(int,input().split())
Map = [[0] * W for _ in range(H)]
for i in range(H):
    s = input()
    for j in range(W):
        Map[i][j] = s[j]

ans = [[0] * W for _ in range(H)]

now_count = 1

for y in range(H):
    q = deque()
    for x in range(W):
        q.append([y,x])
        if Map[y][x] == '#':
            while q:
                _y,_x = q.pop()
                ans[_y][_x] = now_count
            now_count += 1
    if q:
        if len(q) == W and y > 0:
            ans[y] = ans[y-1]
        elif len(q) < W:
            while q:
                _y,_x = q.pop()
                ans[_y][_x] = now_count - 1
for y in range(-1,-H-1,-1):
    if ans[y] == [0] * W:
        ans[y] = ans[y+1]
for y in range(H):
    ans[y] = list(map(str,ans[y]))
    print(' '.join(ans[y]))



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

int main() {
	int a, b;
	string s[102];

	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}
	sort(s, s + a);
	for (int i = 0; i < a; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if (H==0 && W==0){
            break;
        }else{
            for(int h=0; h<H; h++){
                for(int w=0; w<W; w++){
                    cout<<"#";
                }
                cout<<endl;
            }
        }cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a  =input()
for c in a:
    print('9' if c == '1' else '1', end='')
print()


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const string RADIX = "753";
int n;

bool is_753(string s) {
    for(char c : RADIX)if(s.find(c) == string::npos) return false;
    return true;
}

int dfs(string s) {
    if(stoll(s) > (ll)n) return 0;
    int res = is_753(s) ? 1 : 0;
    for(char c : RADIX) res += dfs(s + c);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << dfs("0") << ln;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,y,z;
  cin >> x >> y >> z;
  for(int i = 1; i<=INF; i++){
    if(y*i+z*(i+1)>x){
      cout << i-1 << endl;
      return 0;
    }
  }
}


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

string reverseStr(string target)
{
    string retStr = "";
    for (int i = target.length() - 1; i >= 0; i--) {
        retStr += target[i];
    }
    return retStr;
}

int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int t, f;
    string c;
    bool reverse = false;
    string str1 = "";
    string str2 = "";
    for (int i = 0; i < Q; i++) {
        cin >> t;
        if (t == 1) {
            reverse = !reverse;
        }
        else {
            cin >> f >> c;
            if (f == 1) {
                if (reverse) {
                    str2 += c;
                }
                else {
                    str1 += c;
                }
            }
            else {
                if (reverse) {
                    str1 += c;
                }
                else {
                    str2 += c;
                }
            }
        }
    }

    string ans;
    if (reverse) {
        ans = reverseStr(str2) + reverseStr(S) + str1;
    }
    else {
        ans = reverseStr(str1) + S + str2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4500