akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using   ll=long long;

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

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int n , m;
	
	cin >> n >> m;
	
	string s[n];
	
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	
	int ans[n][m] {};
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0;j < m; ++j) {
			if(s[i][j] == '#') {
				continue;
			}
			else {
				if(i-1 >= 0) {
					ans[i][j] += (s[i-1][j] == '#');
				}
				if(j-1 >= 0) {
					ans[i][j] += (s[i][j-1] == '#');
				}
				if(j+1 < m) {
					ans[i][j] += (s[i][j+1] == '#');
				}
				if(i+1 < n) {
					ans[i][j] += (s[i+1][j] == '#');
				}
				
				if(i-1 >= 0 && j-1 >= 0) {
					ans[i][j] += (s[i-1][j-1] == '#');
				}
				if(i-1 >= 0 && j+1 < m) {
					ans[i][j] += (s[i-1][j+1] == '#');
				}
				if(i+1 < n && j-1 >=0) {
					ans[i][j] += (s[i+1][j-1] == '#');
				}
				if(i+1 <n && j+1 < m) {
					ans[i][j] += (s[i+1][j+1] == '#');
				}
			}
		}
	}
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(s[i][j] == '#') {
				cout << "#";
			}
			else {
				cout << ans[i][j];
			}
		}
		
		cout << endl;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int c=0,c1=0;
		for(int i=0;i<n;i++){
			int a=sc.nextInt();
			if(a%2==0){
				c++;
				if(a%3==0||a%5==0)
					c1++;
			}
		}
		if(c1!=c)
			System.out.println("DENIED");
		else
			System.out.println("APPROVED");
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < N; i++){
            sum = sum + A[i];
        }
        Arrays.sort(A);
        double c = (double)sum/(4*M);
        if(A[N-M] < c){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
} 

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

void solve() {
	cout << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
    cin >> n;
    while (n > 0) {
        auto d = n % 10;
        if (d == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	a, b = rli()
	print(a * b)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 65380
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let _: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = if s.contains("Y") { "Four" } else { "Three" };
    println!("{}", ans);
}


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



int main()
{
	string ABCD;
	int a, b, c, d;
	cin >> ABCD;
	a = ABCD[0] - '0';
	b = ABCD[1] - '0';
	c = ABCD[2] - '0';
	d = ABCD[3] - '0';
	
	if (a + b + c + d == 7)cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a + b + c - d == 7)cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a + b - c + d == 7)cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a - b + c + d == 7)cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a + b - c - d == 7)cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	else if (a - b - c + d == 7)cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a - b + c - d == 7)cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a - b - c - d == 7)cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
h = gets.chomp.split(' ').map(&:to_i)

delta = ->(x) { (a - (t - h[x] * 0.006)).abs }
ans = (0...n).reduce(0) do |min, i|
  delta[i] < delta[min] ? i : min
end

puts ans + 1


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

using namespace std;

#define prr pair<int,int>
#define ll long long
#define pb push_back
#define int long long
#define ld long double
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 //   cout<<"here";
   ll r,c;
   cin>>r>>c;
   if(r==1 || c==1){
       cout<<1;
       return 0;
   }
    ll a1;
    a1=r*c;
    if(a1%2!=0){
        a1=(a1+1)/2;
    }else{
        a1=a1/2;
    }
   cout<<a1;
}

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

int main(){
    int n, b, f, r, v, a[5][4][11];
    for(int i = 1; i < 5; i++){
        for(int j = 1; j < 4; j++){
            for(int k = 1; k < 11; k++){
                a[i][j][k] = 0;
            }
        }
    }
    cin >> n;
    for(int l = 0; l < n; l++){
        cin >> b >> f >> r >> v;
        a[b][f][r] = a[b][f][r] + v;
    }
    for(int s = 1; s < 5; s++){
        if(s > 1) cout << "####################" << endl;
        for(int t = 1; t < 4; t++){
            for(int u = 1; u < 11; u++){
                cout << " " << a[s][t][u];
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   int a,b,c;
   cin>>a>>b>>c;
   int cmax=max(max(a,b),c);
   int sum=a+b+c-cmax;
   int k;
   cin>>k;
   cmax=cmax*pow(2,k);
   sum+=cmax;
   cout<<sum;



 return 0;
}








Measured memory_bytes: 4032
import sys
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
for i in range(N):
    P[i] -= 1
# ループを検知して、それまでのiの遷移、合計値を保持する
ans = -1e18
for i in range(N):
    s = []
    total = 0
    x = i
    while True:
        x = P[x]
        total += C[x]
        s.append(C[x])
        if x == i:
            break
    l = len(s)
    t = 0
    for j in range(l):
        t += s[j]
        if j + 1 > K:
            break
        now = t
        if total > 0:
            e = (K-(j+1))//l
            now += total * e
        ans = max(ans, now)

print(ans)    



        
        
    


    

Measured memory_bytes: 81148
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


vector<ll> getP(ll n){
    vector<ll> state;
    for(ll i = 1; i <= n; i++){
        if(n % i == 0 && (n / i) % 2 == 1){
            state.push_back(i);
        }
    }
    return state;
}

bool judgeJust(string x, ll pos){
    string t[2];
    t[0] = x.substr(0, pos);
    string t2;
    for(int i = 0; i < pos; i++){
        if(x[i] == '1'){
            t2 += '0';
        }
        else{
            t2 += '1';
        }
    }
    t[1] = t2;

    for(int i = 0; i < x.length() / pos; i++){
        for(int j = 0; j < t[0].length(); j++){
            if(x[i * pos + j] > t[i%2][j]){
                return true;
            }
            else if(x[i * pos + j] < t[i%2][j]){
                return false;
            }
        }
    }
    return true;
}


int main(){
    ll N;
    cin >> N;
    string x;
    cin >> x;

    ll num = 0;
    ll already[210000];  fill(already, already+210000, 0);
    ll res = 0;
    ll total = 0;

    for(ll i = 1; i <= N; i++){
        num = add(mul(num, 2), (x[i - 1] - '0'));
        if(N % i == 0 && (N / i) % 2 == 1) {
            ll count = num;
            if (judgeJust(x, i)) {
                count++;
            }
            count = sub(count, already[i]);
            total = add(total, count);
            res = add(res, mul(count, 2 * i));

            ll now = i;
            while (now <= N) {
                already[now] = add(already[now], count);
                now += i;
            }
        }
    }

    cout << res << endl;

    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

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

void solve() {
	int n;
	cin >> n;
	vector<multiset<int>> left(n), right(n);
	long long res = 0;
	for(int i = 0; i < n; i++) {
		int k, l, r;
		cin >> k >> l >> r;
		--k;
		if(l >= r) {
			res += r;
			left[k].insert(l - r);
		}
		else {
			res += l;
			if(k < n - 1)
				right[n - 2 - k].insert(r - l);
		}
	}

	multiset<int> chosen;
	for(int i = 0; i < n; i++) {
		if(left[i].empty())
			continue;
		while(!left[i].empty() && (int) chosen.size() < i + 1) {
			int val = *left[i].rbegin();
			res += val;
			chosen.insert(*left[i].rbegin());
			left[i].erase(left[i].find(val));
		}

		while(!left[i].empty() && *left[i].rbegin() > *chosen.begin()) {
			int val = *chosen.begin();
			res -= val;
			chosen.erase(chosen.begin());
			val = *left[i].rbegin();
			left[i].erase(left[i].find(val));
			chosen.insert(val);
			res += val;
		}
	}

	chosen.clear();
	swap(left, right);

	for(int i = 0; i < n; i++) {
		if(left[i].empty())
			continue;
		while(!left[i].empty() && (int) chosen.size() < i + 1) {
			int val = *left[i].rbegin();
			res += val;
			chosen.insert(*left[i].rbegin());
			left[i].erase(left[i].find(val));
		}

		while(!left[i].empty() && *left[i].rbegin() > *chosen.begin()) {
			int val = *chosen.begin();
			res -= val;
			chosen.erase(chosen.begin());
			val = *left[i].rbegin();
			left[i].erase(left[i].find(val));
			chosen.insert(val);
			res += val;
		}
	}

	// for(int x : chosen)
	// 	cout << x << ' ';

	cout << res << '\n';
}

int main() {
	fast();
	int t;
	cin >> t;
	while(t--)
		solve();
}


Measured memory_bytes: 31444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <stack>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <array>

using namespace std;

const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1e9 + 7;

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

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

    int n, k;
    cin >> n >> k;
    vector<long long> dp(k + 2, 0);
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        vector<long long> ndp(k + 2, 0);
        for (int j = 0; j <= k; j++) {
            ndp[j + 1] = (ndp[j] + dp[j]) % MOD;
        }
        for (int j = 0; j <= k; j++) {
            dp[j] = ((ndp[j+1] - ndp[max(0, j - a)]) + MOD) % MOD;
        }
        ndp = dp;
    }
    cout << dp[k] << endl;
}


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

void change(long long *a,long long *b);
long long gcd(long long x,long long y);
long long lcm(long long x,long long y);


int main(void){
	long long a, b, gcd1, lcm1;
	while(cin >> a >> b){
		gcd1 = gcd(a,b);
		lcm1 = lcm(a,b);
		
		cout << gcd1 << ' ' << lcm1 << endl;
	}
	return 0;
}

void change(long long *a,long long *b){
	long long temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

long long gcd(long long x,long long y){
	if(x < y)
	change(&x, &y);
	
	while(y){
		x %= y;
		change(&x, &y);
	}
	return x;
}

long long lcm(long long x,long long y){
	long long ans = x*y / gcd(x, y);
	return ans;
}

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

string s;
int p = 0;

bool is_digit(char c){
    return '0' <= c && c <= '9';
}

int dfs(){
    vector<int> v;
    while( p < s.size() ){
        if( is_digit(s[p]) ){
            int res = 0;
            while( is_digit(s[p]) ){
                res *= 10;
                res += s[p] - '0';
                p++;
            }
            p++;
            return (res+1)/2;
        }else if( s[p] == '[' ){
            p++;
            v.push_back( dfs() );
        }else if( s[p] == ']' ){
            p++;
            sort(v.begin(), v.end());
            int res = 0;
            for(int i = 0; i <= v.size()/2; i++){
                res += v[i];
            }
            return res;
        }
    }
    return 0;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        p = 1;
        cout << dfs() << endl;
    }
}

Measured memory_bytes: 1276
n = int(input())
a = list(map(int, input().split( )))

#前から貪欲でよいか
#a[0]を正か負に定めて貪欲

#a[0]が正と仮定してよい
if a[0]<0:
    for i in range(n):
        a[i]*=-1

#場合分け用
a2 = [a[i] for i in range(n)]


ans1 = 0
if not a[0]:
    ans1 += 1
    a[0] = 1
sm = a[0]

for i in range(1,n):
    sm2 = sm + a[i]
    #print(sm,sm2)
    if sm2*sm>=0:
        if sm<0:#sm+a[i]=1
            ans1 += abs((1-sm)-a[i])
            a[i]=1-sm
            sm = 1
            
        else:#sm+a[i] = -1
            ans1 += abs(-1-sm-a[i])
            a[i]=-1-sm
            sm = -1
    else:
        sm=sm2

ans2 = abs(-1-a2[0])
a2[0]=-1
sm = -1

for i in range(1,n):
    sm2 = sm + a2[i]
    if sm2*sm>=0:
        if sm<0:#sm+a[i]=1
            ans2 += abs((1-sm)-a2[i])###a[i]と間違えるから関数として定義してa1,a2投げる
            a2[i] = 1-sm
            sm = 1
        else:#sm+a[i] = -1
            ans2 += abs(-1-sm-a2[i])###
            a2[i]=-1-sm
            sm = -1
    else:
        sm =sm2
   

print(min(ans1,ans2))
            

Measured memory_bytes: 64212
#coding: utf-8
from collections import defaultdict
import sys

N = int(input())
A = [int(x) for x in input().split()]

totalStep = 0

prev = 0

for a in A:
    step = 0
    if a < prev:
        step = prev-a
        a += step

    totalStep += step
#    print(a, step, totalStep)
    prev = a
    totalStep

print(totalStep)


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

vector<int> parent, size, sub;

void init(int n){
    for(int i = 1; i <= n; i++)
        parent[i] = i, size[i] = 1;
}
int find_root(int u){
    if(parent[u] == u)
        return u;
    return parent[u] = find_root(parent[u]);
}
bool same(int u, int v){
    return find_root(u) == find_root(v);
}
void union_set(int u, int v){
    u = find_root(u);
    v = find_root(v);
    if(u != v){
        if(size[u] > size[v])  swap(u,v);
        parent[u] = v;
        size[v] += size[u];
    }
}

void input(int n, int f, int b){
    parent.resize(n+1), size.resize(n+1), sub.resize(n+1);
    init(n);
    while(f--){
        int x, y;
        cin >> x >> y;
        union_set(x,y);
        sub[x]++, sub[y]++;
    }
    while(b--){
        int x, y;
        cin >> x >> y;
        if(same(x,y)){
            sub[x]++, sub[y]++;
        }
    }
}
int main(){
    int n, f, b;
    cin >> n >> f >> b;
    input(n, f, b);
    for(int i = 1; i <= n; i++){
        cout << size[find_root(i)] - sub[i] - 1 << ' ';
    }
    cout << endl;
}




Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if(a<b && b<c) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 26112
#include<stdio.h>
int main()
{
    int a,b,i,j;
    scanf("%d %d",&a,&b);
    while(a!=0 || b!=0)
    {
        for(i=0;i<a;i++)
        {
            for(j=0;j<b;j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d",&a,&b);
    }
    return 0;
}



Measured memory_bytes: 2100
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  int res = 10000000;
  REP(pat, 1 << n) {
    int cur = 1;
    REP(i, n) {
      if(pat & (1 << i)) {
        cur *= 2;
      } else {
        cur += k;
      }
    }
    res = min(res, cur);
  }
  printf("%d\n", res);
  return 0;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 200005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
int n,m;
const ll INF = 1LL << 60;
ll dp[3][MAX];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0]=a[0],dp[1][0]=b[0],dp[2][0]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
		dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
		dp[2][i]=max(dp[1][i-1],dp[0][i-1])+c[i];
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	return 0;	
}


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

int times[10001][721];

int main() {
    int n, m;
    while( cin >> n >> m, n||m ) {
        memset( times, 0, sizeof(times) );
        int r;
        cin >> r;
        for(int i=0; i<r; i++) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if( s == 1 ) {
                times[m][t-540] += 1;
            } else {
                times[m][t-540] += -1;
            }
        }
        int q;
        cin >> q;
        for(int i=0; i<q; i++) {
            int res = 0;
            int ts, te, m;
            cin >> ts >> te >> m;
            int state = 0;
            for(int i=0; i<te-540; i++) {
                if( times[m][i] != 0 ) {
                    state += times[m][i];
                }
                if( i >= ts-540 && state>0 ) {
                    res++;
                }
            }
            cout << res << endl;
        }
    }
    return 0;
}

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

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

pll arr[1005];
ll h, n;
ll dp[1001][10001];

ll solve(ll pos, ll hit)
{
    if(hit <= 0) return 0;

    if(pos > n) return mxlld;

    ll &ret = dp[pos][hit];

    if(ret != -1) return ret;

    ret = 0;

    ll p1 = solve(pos + 1, hit);
    ll p2 = solve(pos, hit - arr[pos].first) + arr[pos].second;

    return ret = min(p1,p2);
}

int main()
{
    ll i, j, k, l, m, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> h >> n)
    {
        ans = 0;

        for(i = 1; i <= n; i++)
        {
            slld(arr[i].first);
            slld(arr[i].second);
        }

        memset(dp,-1,sizeof dp);

        ans = solve(1,h);

        cout << ans << endl;
    }


}




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

int main() {
  int n;
  cin >> n;
  set<vector<int> > s;
  int ans=0;
  for(int i=0; i<n; i++) {
    vector<int> a(3);
    for(int j=0; j<3; j++) cin >> a[j];
    sort(a.begin(),a.end());
    ans+=s.count(a);
    s.insert(a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3228
N, K = map(int, input().split())
H = list(map(int, input().split()))

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

# print(H)
# print(f'N={N} K={K}')
if N <= K:
    print(0)
    exit()


H.sort(reverse=True)
# print(H)


r_H = H[K:]
# print(r_H)
# print(sum(r_H))

sum_H = 0
for hp in r_H:
    sum_H += hp
print(sum_H)

# print(type(10**9))
# print(type(2*10**14))

Measured memory_bytes: 26180
function main(input) {
    const args = input.split('\n');
    const A = parseInt(args[0], 10),
          B = parseInt(args[1], 10),
          C = parseInt(args[2], 10),
          X = parseInt(args[3], 10);

    var count = 0;

    for (var a = 0; a <= A; ++a) {
        for (var b = 0; b <= B; ++b) {
            for (var c = 0; c <= C; ++c) {
                var sum = (a * 500) + (b * 100) + (c * 50);
                if (sum === X) ++count;
            }
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,arr[200005]={0},x;
	cin >> n;
	for(i=0;i<n-1;i++)
	{
		cin >> x;
		arr[x]++;
	}
	for(i=1;i<=n;i++)
	{
		cout << arr[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4412
n = int(input())
l = list(map(int, input().split()))

l.sort()

from itertools import combinations

ans = 0
for i in combinations(list(range(0, n)), 3):
    if l[i[0]] == l[i[1]] or l[i[1]] == l[i[2]] or l[i[2]] == l[i[0]]:
        continue
    if l[i[0]] + l[i[1]] > l[i[2]]:
        ans += 1

print(ans)

Measured memory_bytes: 67864
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


int main() {
    string s;
    cin >> s;
    int ans = 0;
    auto n = s.length();
    for (int i = 0; i < (n+1)/2; ++i) {
        if(s[i] != s[n-i-1]) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const long long int INF = 12 * 100000 + 1;
long long int dp[4096];

int main() {
    for (int i = 0; i < 4096; i++) dp[i] = INF;
    dp[0] = 0;
    int N, M;
    cin >> N >> M;

    vector<int> a(M);
    int b;
    vector<vector<int>> c;
    vector<int> mask(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b;
        vector<int> ci(b);
        int count = 0;
        for (int j = 0; j < b; j++) {
            cin >> ci[j];
            count += (int)pow(2, ci[j]-1);
        }
        mask[i] = count;
        c.push_back(ci);
    }

    for (int i = 0; i < M; i++) {
        for (int j = 0; j < (int)pow(2, N); j++) {
            //for (int k = 0; k < c[i].size(); k++) {
                if(!((j & mask[i]) == mask[i])) {
                    dp[j | mask[i]] = min(dp[j] + a[i], dp[j | mask[i]]);
                //if ((j - (int)pow(2, c[i][k]-1) >= 0) && ((j & mask[i]) == mask[i])) {
                //    dp[j] = min(dp[j - (int)pow(2, c[i][k]-1)] + a[i], dp[j]);
                //    cout <<i << " "<< j << " " << k << " " <<dp[j - (int)pow(2, c[i][k]-1)] << " " << dp[j] << endl;
                }
            //}
        }
    }

    if (dp[(int)pow(2, N)-1] == INF)
        cout << -1 << endl;
    else
        cout << dp[(int)pow(2, N)-1] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
double a[N], b[N], s[N];
int main() {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        s[i] = s[i-1] + (a[i] * (a[i] + 1)) / 2 / a[i];
        if(i >= k) {
            b[i] = s[i] - s[i-k];
            ans = max(ans, b[i]);
        }
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 6016
n, x = map(int, input().split())

if x == 1 or x == 2*n-1:
  print('No')
else:
  print('Yes')
  if n == 2:
    print(*[1,2,3], sep='\n')
  elif x == 2:
    ans = [3, 2, 1, 4]
    remain = [i for i in range(5, 2*n)]
    ans = remain[:len(remain) // 2] + ans + remain[len(remain) // 2:]
    print(*ans, sep='\n')
  else:
    ans = [x-1, x, x+1, x-2]
    remain = [i for i in range(1, x-2)] + [i for i in range(x+2, 2*n)]
    ans = remain[:len(remain) // 2] + ans + remain[len(remain) // 2:]
    print(*ans, sep='\n')


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

class THuman
{
public:
	void Move(int Distance);
	void Turn(int Degree);
	double GetX();
	double GetY();
	THuman();
private:
	double FX;
	double FY;
	int FDegree;
};

void THuman::Move(int Distance)
{
	FX += Distance * sin(FDegree * M_PI / 180);
	FY += Distance * cos(FDegree * M_PI / 180);
}

void THuman::Turn(int Degree)
{
	FDegree += Degree;
}

double THuman::GetX()
{
	return FX;
}

double THuman::GetY()
{
	return FY;
}

THuman::THuman()
{
	FX = 0;
	FY = 0;
	FDegree = 0;
}

int GetIntegerPart(double A)
{
	double IntegerPart;
	modf(A, &IntegerPart);
	return IntegerPart;
}

int main()
{
	THuman Human;
	while(true){
		int Distance;
		int Degree;
		char Dummy;
		cin >> Distance >> Dummy >> Degree;
		if(Distance == 0 && Degree == 0) break;
		Human.Move(Distance);
		Human.Turn(Degree);
	}
	cout << GetIntegerPart(Human.GetX()) << endl << GetIntegerPart(Human.GetY()) << endl;
	return 0;
}

Measured memory_bytes: 3232
$n=<>;
@a=glob<>;
$ans=0;
for($i=0;$i<$n;$i++){
	for($j=$i+1;$j<$n;$j++){
		for($k=$j+1;$k<$n;$k++){
			($x,$y,$z)=sort{$a-$b}map{$a[$_]}$i,$j,$k;
			if($x!=$y&&$y!=$z&&$x!=$z&&$x+$y>$z){
				$ans++;
			}
		}
	}
}
print $ans

Measured memory_bytes: 5364
#include<iostream>
using namespace std;
int main(){
  int X,Y,Z,a,b;
  std::cin>>X>>Y>>Z;
  a=Y;
  b=Z;
  Y=X;
  X=a;
  Z=X;
  X=b;
  std::cout<<X<<" "<<Y<<" "<<Z;
  return 0;
}

Measured memory_bytes: 256
N,K= list(map(int,input().split()))
S = input()
S = list(S)
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
    S[K-1] = 'c'
Snew = ''.join(S)
print(Snew)

Measured memory_bytes: 3060
#include <stdio.h>
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a > b) {
    printf("a > b\n");
  } else if (a < b) {
    printf("a < b\n");
  } else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

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

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


int main(){
    int N; cin >> N;
    vector<Pi> A(N);
    rep(i,N) cin >> A[i].first,A[i].second = i;
    sort(A.begin(),A.end());
    int ans = 0;
    rep(i,N){
        if(i % 2 == 0){
            if(A[i].second % 2 != 0) ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long  ll;
// constexpr ll mod = 1e9 + 7;

bool hasEight(int i) {
    int cnt=0;
    for (int j = 1; j < i+1; j++) {
        if(i%j==0)cnt++;
    }
    return cnt==8 ? true : false;
}
int main(){
    int N;
    cin >> N;


    int ans=0;
    for (int i = 1; i < N+1; i++) {
        if(i%2==1 && hasEight(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#AGC26 A問題
#1:連続する文字列ごとに分割する。（もしくは連続する文字列の長さを記録していく）
#2:連続する文字列内で魔法を使い、連続しないようにするためには？　偶数と奇数でどうなるか

def main():
    n = int(input())
    slimes = list(map(int,input().split()))
    length = length_of_sequences(slimes)
    total = 0
    for l in length:
        total += l//2
    print(total)

def length_of_sequences(l):
    length = []
    counter = 1
    for i,slime in enumerate(l):

        if i == 0:
            continue
        if l[i-1] == l[i]:
            counter += 1
        else:
            length.append(counter)
            counter = 1
        if i == len(l)-1:
            length.append(counter)

    return length



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> p(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> p[i];
  vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i + 1][j] += p[i + 1] * dp[i][j];
      dp[i + 1][j + 1] += (1.0 - p[i + 1]) * dp[i][j];
    }
  }
  double ret = 0;
  for (int i = 0; i <= (n - 1) / 2; i++) ret += dp[n][i];
  cout << setprecision(10) << ret;
  return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int n,d;

    cin>>n>>d;

    if(n%(2*d+1)==0){
        cout<<n/(2*d+1)<<endl;
    }else{
        cout<<n/(2*d+1)+1<<endl;
    }
}


Measured memory_bytes: 256
var input = function()
{
  return input= require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
};

var out = function(x)
{
  console.log(x);
  return x;
}

var add =function(a,b)
{
  return a+b;
}

var sub = function(a,b)
{
  return a-b;
}

var mult = function(a,b)
{
  return a*b;
}

var dev = function(a,b)
{
  return Math.floor(a/b);
}

var operatorSelect = function(x)
{
  if(x=='+')return add;
  if(x=='-')return sub;
  if(x=='*')return mult;
  if(x=='/')return dev;
  if(x=='?')return "end";
  return "end";
}

var calc = function(a,op,b)
{
  var f = operatorSelect(op);
  if (f=="end")
  {
    return;
  }
  var str = f(a,b)
  out(str);
  return str;
};

var array = input();
array.forEach(function(a){
  var x = a.split(' ');
  calc(Number(x[0]),x[1],Number(x[2]));
});

Measured memory_bytes: 7908
N, K = map(int, input().split())
A = list(map(int, input().split()))

Log= N*[-1]
count = 0
i = 1
restartflag = False


while count < K:
    i = A[i - 1]
    # count
    count += 1
    # 訪れたことのある街でない
    if Log[i-1]==-1:
        Log[i-1] = count # n 回目に訪れた
    else:
    # 訪れたことのある街であるならば
        looplen = count - Log[i-1]
        loopstart = Log[i - 1]
        loopend_city= i 
        restartflag = True
        break

if restartflag:
    count = 0
    remain =(K-loopstart) % looplen
    i = loopend_city
    while count < remain:
        i = A[i-1]
        count += 1

print(i)

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

int main(void) {                                                                
    char str[21];                                                               
    int i;                                                                      
                                                                                
    scanf("%s", str);                                                           
    for (i = strlen(str) - 1; i >= 0; i--) {                                    
        putchar(str[i]);                                                        
    }                                                                           
    putchar('\n');                                                              
    return 0;                                                                   
}

Measured memory_bytes: 524
#include<stdio.h>
#define NUM 100000

int main(){
  
  int n,S[NUM],q,T[NUM];
  int i,j;
  int count = 0;
  int a[NUM];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    a[i] = 0;
  }    
  
  for(i=0;i<n;i++){
    for(j=0;j<q;j++){
      if(S[i] == T[j]){
	a[j]++;
	if(a[j]<2){
	  count++;
	  break;
	}
	
      }
    }
  }
  
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct Stack{
	ll table[1000];
	ll top;
	void init(){
		top=0;
	}
	bool empty(){
		return top==0;
	}
	void push(ll x){
		table[top]=x;
		top++;
	}
	ll pop(){
		if(empty()) return 0;
		top--;
		return table[top];
	}
};

ll calc(ll x,string op,ll y){
	if(op=="+")return x+y;
	if(op=="-")return x-y;
	if(op=="*")return x*y;
}

int main(){
	string str;
	Stack stack;
	ll numA,numB;
	stack.init();
	while(cin >> str){
		if(str=="+"||str=="-"||str=="*"){
			numA=stack.pop();
			numB=stack.pop();
			stack.push(calc(numB,str,numA));
		}else{
			numA=0;
			for(int i=0;i<(int)str.size();i++){
				numA*=10;
				numA+=str[i]-'0';
				}
			stack.push(numA);
		}
	}
	cout << stack.pop()<<endl;
	return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<map>
#include<utility>
using namespace std;
int N;
long long A[201000];
long long sum=0l;
map<long long,long long> M;

int main(){
    cin>>N;
    for(int i=1;i<=N;++i){
        cin>>A[i];
        A[i]+=A[i-1];
        //cout<<A[i]<<endl;
        if(M.find(A[i])==M.end()){
            M.insert(make_pair(A[i],1l));
        }
        else{
            ++M[A[i]];
        }

    }
    for(auto i= M.begin();i!=M.end();++i){
        //cout<<i->first<<" "<<i->second<<endl;
        if(i->first!=0){
            sum+=(i->second)*(i->second-1)/2;
        }
        else{
            sum+=(i->second)*(i->second+1)/2;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 14336
import Data.List (nub, sort)

data Color = Gray | Brown | Green | LightBlue | Blue | Yellow | Orange | Red | Undef deriving (Enum, Eq, Ord, Show)

judgeColor :: Integral a => a -> Color
judgeColor r
    | r < 400 = Gray
    | r < 800 = Brown
    | r < 1200 = Green
    | r < 1600 = LightBlue
    | r < 2000 = Blue
    | r < 2400 = Yellow
    | r < 2800 = Orange
    | r < 3200 = Red
    | otherwise = Undef

compMinMax :: Integral a => [a] -> (Int, Int)
compMinMax xs = (max 1 numOtherTypes, numOtherTypes + numUndefMems)
    where
        numUndefMems = length $ filter (== Undef) $ fmap judgeColor xs
        numOtherTypes = length $ nub $ sort $ filter (/= Undef) $ fmap judgeColor xs

main :: IO ()
main = do
    _ <- getLine
    xs <- fmap read . words <$> getLine :: IO [Int]
    let (mi, ma) = compMinMax xs
    putStrLn $ unwords $ fmap show [mi, ma]


Measured memory_bytes: 1020
#include<cstdio>

int f(int x){return x*x;}

int main(){
  int d;
  while(scanf("%d", &d) == 1){
    int sum = 0;
    for(int i=1;i<600/d;i++){
      sum+=f(i*d)*d;
    }
    printf("%d\n", sum);
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cassert>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <string>
#include <cstring>
#include <cmath>

#define forn(x, a)             for (int x = 0; x < a; x++)
#define fore(x, a, b, c)       for (int x = a; x <= b; x += c)
#define forr(x, a)             for (int x = a; x >= 0; x--)
#define all(container)         (container).begin(), (container).end()
#define rall(container)        (container).rbegin(), (container).rend()
#define sz(container)          (int) container.size()
#define mp                     make_pair
#define fi                     first
#define se                     second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector< vector< int > > vvi;
typedef vector<bool> vb;
typedef vector<long long> vll;

#ifdef LOCAL_DEFINE
    #include "../../library/debug.hpp"
#else
    #define debug(...) 0
#endif

void read(int &a) {scanf("%d", &a);}
void read(ll &a) {scanf("%lld", &a);}
void read(char* a, string& s) {scanf("%s", a); s = string(a);}
void read(float &a) {scanf("%f", &a);}
void read(double &a) {scanf("%lf", &a);}
void print(vi &a) {for (auto& x: a) printf("%d ", x); puts("");}
void print(int &a) {printf("%d ", a);}
void println(int &a) {printf("%d\n", a);}
void print(ll &a) {printf("%lld ", a);}
void println(ll &a) {printf("%lld\n", a);}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int maxn = 1e5 + 9;
char line[maxn];

void solve() {
    ll a, b, n;
    read(a), read(b), read(n);
    ll ans = (a * min(n, b - 1)) / b;
    print(ans);
}

int main(void) {
    int T = 1;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
    int w,h,i,j;
    while(1)
    {
        scanf("%d%d",&h,&w);
        if(w==0&&h==0)
        {
            break;
        }
        for(i=0;i<w;i++)
        {
            printf("#");
        }
        printf("\n");
        for(i=0;i<h-2;i++)
        {
            printf("#");
            for(j=0;j<w-2;j++)
            {
                printf(".");
            }
            printf("#\n");
        }
        for(i=0;i<w;i++)
        {
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}

Measured memory_bytes: 588
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if (a<b)
    {
        cout << "a < b" << endl;
    }else if (a > b)
    {
        cout << "a > b" << endl;
    }else {
        cout << "a == b" << endl;
    }
    
    
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int n,m,ans=1,i;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
    	if(ans>=m)ans=ans+m;
    	if(ans<m)ans=ans*2;
	}
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  int H=100, W=100;
  vector<vector<int> > Grid(H, vector<int>(W, 0));

  ll A, B;
  cin >> A >> B;

  ll x=0;
  ll y=0;
  while(A>1){
    Grid[y][x] = 1;
    A--;
    x+=2;
    if(x>=W){
      x=0;
      y+=2;
    }
  }

  x=0;
  y=H-1;
  while(B>1){
    Grid[y][x] = 2;
    B--;
    x+=2;
    if(x>=W){
      x=0;
      y-=2;
    }
  }

  for(int i=0; i<H/2; ++i){
    for(int j=0; j<W; ++j){
      if(Grid[i][j] == 0){
        Grid[i][j] = 2;
      }
    }
  }

  for(int i=H-1; i>=H/2; --i){
    for(int j=0; j<W; ++j){
      if(Grid[i][j] == 0){
        Grid[i][j] = 1;
      }
    }
  }

  cout << W << " " << H << "\n";
  rep(i, 0, H){
    rep(j, 0, W){
      if(Grid[i][j] == 1){
        cout << ".";
      }else{
        cout << "#";
      }
    }
    cout << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
ABCD = input()
for i in range(1<<3):
    ans = ABCD
    for j in range(3):
        if (i>>j)&1 == 1:
            ans = ans[:3-j] + "-" + ans[3-j:]
        else:
            ans = ans[:3-j] + "+" + ans[3-j:]
    # print(ans)   
    if eval(ans)==7:
        print(ans+"=7")
        break

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
struct Edge { int to, cap, rev, cost; };
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;





int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int p = -1;
	vi v(n);
	REP(i, n)cin >> v[i];
	REP(i, n) {
		if (v[i] == 1)p = i;
	}
	cout << (n - p - 1 + p + k - 2) / (k - 1) << endl;
}


Measured memory_bytes: 640
n = int(input())
arr = [int(input()) for index in range(n)]

cnt, m = 0, 0
G = []


def insertion_sort(nums, n, g):
    global cnt
    for idx1 in range(g, n):
        v = nums[idx1]
        idx2 = idx1 - g
        while idx2 >= 0 and nums[idx2] > v:
            nums[idx2+g] = nums[idx2]
            idx2 -= g
            cnt  += 1
        nums[idx2+g] = v

h = 1
while not h > n:
    G.append(h)
    h = 3 * h + 1

m = len(G)
G.reverse()

for index in range(m):
    insertion_sort(arr, n, G[index])


print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(n):
	print(arr[i])


Measured memory_bytes: 45512