akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int bruh (int a, int b) {
  return a/b + (a%b>0);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int h, a; cin >> h >> a;
  cout << bruh(h, a);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,s,a=100,max=0,i,j;
  int p[14][14]={0};
  int X[]={0,0,1,0,-1,1,1,-1,-1,0,2,0,-2};
  int Y[]={0,1,0,-1,0,1,-1,-1,1,2,0,-2,0};
  int l[]={0,5,9,13};
  while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
    for(i=0;i<l[s];i++)p[y+Y[i]+2][x+X[i]+2]++;
  }
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(p[i+2][j+2])a--;
      if(max<p[i+2][j+2])max=p[i+2][j+2];
    }
  }
  printf("%d\n%d\n",a,max);
  return 0;
}

Measured memory_bytes: 600
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0]

    ret = []
    for i, c in enumerate(s):
        if i % 2 == 0:
            ret.append(c)
    return ''.join(ret)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 41968
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A1[N], A2[N];
    REP(i,0,N) cin >> A1[i];
    REP(i,0,N) cin >> A2[i];
    for (int i = 1; i < N; ++i) A1[i] += A1[i-1];
    for (int i = N-2; -1 < i; --i) A2[i] += A2[i+1];
    int ans = 0;
    REP(i, 0, N){
        int cur = A1[i]+A2[i];
        if (ans < cur) ans = cur;
    }
    CO(ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] a) throws IOException{

//    	for(int i=1; i<=9; i++) {
//    		for (int j=1; j<=9; j++) {
//    			System.out.println(i + "x" + j + "=" + (i*j));
//    		}
//    	}

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            String line1 = br.readLine();
            int N = Integer.parseInt(line1);

            for (int i=0; i<N; i++) {
            	String line = br.readLine();
            	String[] tmp = line.split(" ");
            	int[] tri = {Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]),Integer.parseInt(tmp[2])};


            	if (pitagoras(tri[0], tri[1], tri[2])
            			|| pitagoras(tri[1], tri[2], tri[0])
            			|| pitagoras(tri[2], tri[0], tri[1]) ) {

            		System.out.println("YES");
            	} else {
            		System.out.println("NO");
            	}

            }
        }


    }


    private static boolean pitagoras(int a, int b, int c) {
    	return Math.pow(a, 2) + Math.pow(b, 2) == Math.pow(c, 2) ? true : false;
    }
}

Measured memory_bytes: 25636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M = MAP()
ab = [LIST() for _ in range(M)]
cnt = [0]*N

for i in range(M):
	cnt[ab[i][0]-1] += 1
	cnt[ab[i][1]-1] += 1

for i in range(N):
	print(cnt[i])

Measured memory_bytes: 5200
fun main(args: Array<String>) {
    a67(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a67(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val numList = args[0].split(" ").map { it.toInt() }
    println(if (numList.any { it % 3 == 0 } || numList.sum() % 3 == 0) "Possible" else "Impossible")
}




Measured memory_bytes: 37980
#include<stdio.h>
int main()
{
	int i,n,a,r=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a%2==0){
			r++;
		}
	}
	printf("%d\n",r);
	return 0;
}



Measured memory_bytes: 2756
#include<stdio.h>
int main(void){
    int b,c,n,d,e;
    scanf("%d",&n);
    e=n;
    int a[n];
    for(b=0;b<n;b++){
        scanf("%d",&c);
        a[b]=c;
    }
    for(d=e-1;d>0;d--){
    printf("%d ",a[d]);
    }
    printf("%d\n", a[0]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define LL long long
#define maxn    100000
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n%2==0)
            cout<<(n/2)-1<<endl;
        else
            cout<<n/2<<endl;
    }
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] s = stdIn.next().split("");
		int cnt = s.length-2;
		
		System.out.println(s[0]+cnt+s[s.length-1]);
		
		
		
		
		
	}

}


Measured memory_bytes: 21972
H,W,N,*a=map(int,open(0).read().split())
O=[[0]*W for _ in range(H)]
i=0
for j in range(N):
 for k in range(a[j]):w=i%W if i//W%2 else W-1-i%W;O[i//W][w]=str(j+1);i+=1
for i in range(H):print(' '.join(O[i]))


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

string s;
int n, k;
long long ans = 0;

int main() {
	cin >> s >> k;
	n = s.size();
	int h = 0, f = n - 1;
	while (s[h] == s[h + 1])
		h++;

	if (h == n - 1) {
		cout << (long long) n * k / 2 << endl;
		return 0;
	}

	while (s[f] == s[f - 1])
		f--;
	for (int i = h + 1, c = 1; i < f; i++) {
		if (i + 1 == f || s[i + 1] != s[i]) {
			ans += c / 2;
			c = 1;
		} else
			c++;
	}
	ans *= k;
	ans += (h + 1) / 2 + (n - f) / 2;
	if (s[0] == s[n - 1])
		ans += (long long) (h + 1 + n - f) / 2 * (k - 1);
	else
		ans += (long long) ((h + 1) / 2 + (n - f) / 2) * (k - 1);
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ls = [0]*(n+1)
ans = []
for i in reversed(list(range(n))):
    if sum(ls[::i+1][1:]) % 2 != a[i]:
        ls[i+1] = 1
        ans.append(i+1)
print(sum(ls))
if ans: print(' '.join(map(str, ans)))

Measured memory_bytes: 21408
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;


const int INF = (1<<30);
const int MAX_n = 100000;

//最長増加部分列の長さの計算
int LIS(vector<int> V) {
	int DP[MAX_n] = { 0 };
	fill(DP, DP + V.size(), INF);
	for (int i = 0; i < V.size();++i) {
		*lower_bound(DP, DP + V.size(), V[i]) = V[i];
	}
	return lower_bound(DP, DP + V.size(), INF) - DP;
}

int main() 
{
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; ++i) cin >> A[i];
	cout << LIS(A) << endl;
	return 0;
}



Measured memory_bytes: 3876
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
ll a[maxn];
ll c[maxn];
int n, k;
struct node{
    ll v;
    ll t;
    int id;
}d[maxn];

bool cmp(node f, node g){
    return f.v < g.v;
}

bool cmp1(node f, node g){
    return f.id < g.id;
}

int lowbit(int x){
    return x & (-x);
}

void add(int x, ll value){
    while(x < maxn){
        c[x] += value;
        x = x + lowbit(x);
    }
}

ll sum(int x){
    ll ans = 0;
    while(x > 0){
        ans += c[x];
        x = x - lowbit(x);
    }
    return ans;
}

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

    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        a[i] = a[i] - k;

    }
    for(int i = 1; i <= n; i++){
        d[i].v = d[i - 1].v + a[i];
        d[i].id = i;
    }
    d[0].v = 0;
    d[0].id = 0;
    sort(d, d + n + 1, cmp);
    int cnt = 0;
    for(int i = 0; i <= n; i++){
        if(i == 0 || d[i].v != d[i - 1].v){
            cnt++;
            d[i].t = cnt;
        }else d[i].t = d[i - 1].t;
    }
    sort(d, d + n + 1, cmp1);
    ll ans = 0;


    for(int i = 0; i <= n; i++){

       ans += sum(d[i].t);
       add(d[i].t, 1);
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

#define MAX 200010
ll N,M,K;
deque<ll> A,B;
ll sumA[MAX], sumB[MAX];

bool check(ll x) {
  if( x > N + M ) return false;
  rep(i,x+1) { // A
    ll readA = (ll)i;
    ll readB = x - (ll)i;
    if( readA >= (ll)A.size()+1 || readB >= (ll)B.size()+1 ) continue;
    if( sumA[readA] + sumB[readB] <= K ) {
      //cout << "? x = " << x << ", readA = " << readA << " readB = " << readB << endl;
      //cout << "  sumA = " << sumA[readA] << " sumB = " << sumB[readB] << endl;
      return true;
    }
  }
  return false;
}

int main() {
  cin >> N >> M >> K;
  A.resize(N);
  B.resize(M);
  rep(i,N) cin >> A[i];
  rep(i,M) cin >> B[i];
  /*
  sumA[0] = A[0];
  REP(i,1,(int)A.size()) sumA[i] = sumA[i-1] + A[i];
  sumB[0] = B[0];
  REP(i,1,(int)B.size()) sumB[i] = sumB[i-1] + B[i];
  */
  sumA[0] = 0;
  REP(i,1,(int)A.size()+1) sumA[i] = sumA[i-1] + A[i-1];
  sumB[0] = 0;
  REP(i,1,(int)B.size()+1) sumB[i] = sumB[i-1] + B[i-1];
  
  ll L = 0, R = K+10LL;
  while( R - L ){
    ll M = ( L + R ) / 2LL;
    if( check(M) ) L = M + 1LL;
    else           R = M;  
  }
  cout << L - 1LL << endl;
  return 0;
}


Measured memory_bytes: 10036
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef vector<long long> vll;

// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a/ gcd(a,b)*b;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H,W;
	string S[60];
	cin >> H >> W;
	REP(i, H) cin >> S[i];
	int dx[] = { 1,1,0,-1,-1,-1, 0, 1 };
	int dy[] = { 0,1,1, 1, 0,-1,-1,-1 };
	REP(i, H) {
		REP(j, W) {
			if (S[i][j] == '.') {
				int cnt = 0;
				REP(k, 8) {
					int x = i + dx[k];
					int y = j + dy[k];
					if (x >= 0 && x < H 
						&& y >= 0 && y <= W && S[x][y] == '#') {
						cnt++;
					}
					S[i][j] = '0' + cnt;
				}
			}
		}
	}
	REP(i, H) cout << S[i] << endl;
	return 0;
}


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

const int MOD=1000000007;

int main(){
    int N, M; cin >> N >> M;
    int a[100100];
    for(int i=0; i<M; i++){
        cin >> a[i];
    }
    int dp[100100];
    int flag=0; //a[flag]に今注目している
    dp[0]=1;
    if(a[0]!=1) dp[1]=1;
    else dp[1]=0;

    for(int i=1; i<N; i++){
        while( flag <=M-1 && i+1 > a[flag]  ){ flag++;}
        if( flag <=M-1 && (i+1)==a[flag]) {dp[i+1]=0;}
        else{
            dp[i+1]=dp[i]+dp[i-1];
            dp[i+1]%=MOD;
        } 
    }



    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

struct edge {
    int to, cost;
    size_t idx;
};
int n, m;
vec<edge> g[100];
bool used[1001];

int main() {
    fastio();

    cin >> n >> m;

    forn(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back({ b, c, i });
        g[b].push_back({ a, c, i });
    }

    using elem = tuple<int, int, int>;
    forn(i, n) {
        vec<int> d(n, 1000 * 1000);
        d[i] = 0;

        priority_queue<elem, vector<elem>, greater<elem>> q;
        q.push((elem) { 0, i, 1000 });

        while (!q.empty()) {
            auto p = q.top();
            q.pop();

            int cost, i, idx;
            tie(cost, i, idx) = p;

            if (cost > d[i]) {
                continue;
            }

            used[idx] = true;
            d[i] = cost;

            for (edge e : g[i]) {
                if (d[e.to] >= d[i] + e.cost) {
                    d[e.to] = d[i] + e.cost;
                    q.emplace(d[e.to], e.to, e.idx);
                }
            }
        }
    }

    cout << count(used, used + m, false) << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mat[21][21];
ll dp[22][1<<22];
ll n;
ll solve(ll womensubset,ll i)
{
	if(i== n+1)
	{
		if(womensubset==0)
			return 1;
		return 0;//Left woman cannot be paired again making invalid pair.
	}
	if(dp[i][womensubset]!=-1)
		return dp[i][womensubset];
	ll ans=0;
	for(ll woman=0;woman<n;woman++)
	{
		bool available=(((1<<woman)&(womensubset))==0) ? 0 : 1;
		if(available&&mat[i-1][woman])
		{
			ans = (ans + solve(womensubset^(1<<woman),i+1))%1000000007;
			//turn off bit of that particular woman.
		}
	}
	return dp[i][womensubset]=ans;
}
int main()
{
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll p=0;p<n;p++)
	{
		for(ll j=0;j<n;j++)
		{
			cin>>mat[p][j];
		}
	}
	cout<<solve((1<<n)-1,1);
}

Measured memory_bytes: 724500
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100;
int n,dir,lim; //[lim,dir]
int dis[N+5],tot[N+5];
const char ANS[2][20]={"Impossible","Possible"};
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&dis[i]);
		tot[dis[i]]++;
	}
	sort(dis,dis+n);
	dir=dis[n-1];
	lim=(dir+1)/2;
	if(dis[0]<lim || dir+1>n){
		printf("%s\n",ANS[0]);
		return 0;
	}
	for(int i=dir;i>=lim;i--){
		if(i==lim){
			if((dir%2==0 && tot[i]!=1) || (dir%2==1 && tot[i]!=2)){
				printf("%s\n",ANS[0]);
				return 0;
			}
		}
		else
			if(tot[i]<2){
				printf("%s\n",ANS[0]);
				return 0;
			}
	}
	printf("%s\n",ANS[1]);
	return 0;
}

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

int main() {
  ll h,w;
  cin>>h>>w;
  if(h==1||w==1) cout<<1<<endl;
  else if(w%2==0) cout<<w/2*h<<endl;
  else if(h%2==0) cout<<w*h/2<<endl;
  else cout<<w*(h-1)/2+(w-1)/2+1<<endl;
  return 0;
}


Measured memory_bytes: 256
S=list(input())

if not S[0]=="A":
  print("WA")
else:
  if not S.count("C") == 1:
    print("WA")
  elif S[-1]=="C" or S[1]=="C":
    print("WA")
  else:
    S.remove('A')
    S.remove('C')
    if str(S).islower():
      print("AC")
    else:
      print("WA")
    

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

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

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

template<class T> bool chmin(T &a, const T &b){ return a > b && (a = b, true);}
template<class T> bool chmax(T &a, const T &b){ return a < b && (a = b, true);}

int main() {
    int n;
    while(cin >> n, n){
        vector<string> S(n);
        vector<int> W(n), A(n);
        for (int i = 0; i < n; ++i) {
            cin >> S[i] >> W[i] >> A[i];
        }
        vector<int> T(1 << n), cnt(1 << n);
        for (int i = 0; i < (1 << n); ++i) {
            for (int j = 0; j < n; ++j) {
                if(i&(1 << j)) {
                    T[i] = T[i^(1 << j)]+W[j];
                    cnt[i] = cnt[i^(1 << j)]+1;
                }
            }
        }
        vector<int> dp(1 << n, INF<int>), top(1 << n, INF<int>);
        dp[0] = 0;
        for (int i = 0; i < (1 << n); ++i) {
            for (int j = 0; j < n; ++j) {
                if(!(i & (1 << j)) && A[j] >= T[i]){
                    if(chmin(dp[i^(1 << j)], dp[i]+(n+1-cnt[i])*W[j])){
                        top[i^(1 << j)] = j;
                    }
                }
            }
        }
        int cur = (1 << n)-1;
        queue<string> ans;
        while(cur){
            ans.emplace(S[top[cur]]);
            cur -= 1 << top[cur];
        }
        while(!ans.empty()){
            cout << ans.front() << "\n"; ans.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 3048
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;
int main(){
    int n; 
    cin>>n;
    vector<ll>inp(n);
    ll rst=1;;
    for(int i=0;i<n;i++){
        cin>>inp[i];
        if(inp[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0; i<n; i++){
        if(inp[i]<=1000000000000000000/rst)rst*=inp[i];
        else{ 
        cout<<-1<<endl;
        return 0;
        }
    }
        cout<<rst<<endl; 
        return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  
  int count=0;
  rep2(i,a,b+1){
    int d1,d2,d3,d4,d5;
    d1 = i/10000;
    d2 = (i%10000)/1000;
    d3 = (i%1000)/100;
    d4 = (i%100)/10;
    d5 = i%10;
    
    if(d1==d5 && d2==d4) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main ()
{
	long [] a;
	while ((a = readln.split.map !(to !(long)).array) !is null)
	{
		sort (a);
		long res = long.max;
		do
		{
			res = min (res, a[0] * a[1] * (a[2] - a[2] / 2 * 2));
		}
		while (nextPermutation (a));
		writeln (res);
	}
}


Measured memory_bytes: 256
import Foundation

/*
// 1
let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let S = Int(split[1])!

// 1 2 3 4 5
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

func pow(_ number: Int, multiplier: Int) -> Int {
  var answer = 1
  for _ in 0 ..< multiplier {
    answer *= number 
  }
  return answer
}


*/
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let A = Int(split[1])!
let B = Int(split[2])!
var answer = 0
answer = (N / (A + B)) * A
let surplus = N % (A + B)
if surplus < A {
	answer += surplus
} else {
 	answer += A 
}
print(answer)

Measured memory_bytes: 7780
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;

int main(void) {
	string o, e;
	cin >> o >> e;
	string t = o + e;
	for (int i = 0; i < t.size(); i++) {
		if (i % 2 == 0) {
			cout << o[0];
			o.erase(o.begin());
		}
		else {
			cout << e[0];
			e.erase(e.begin());
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    vector<int> d(N); repp(i,0,N) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[N/2] - d[N/2-1] << endl;
}


Measured memory_bytes: 640
n,m=map(int,input().split(" "))
c=sorted(list(map(int,input().split(" "))))[1:]
ans=list(range(n+1))
for i in c:
    for j in range(i,n+1):
        ans[j]=min([ans[j],(ans[j-i]+1)])
print(ans[-1])


Measured memory_bytes: 7520
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll D;

signed main(){
    cin >> N >> D;
    int ans = 0;
    rep(i, N){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y <= D*D) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;


int main()
{
    int n, ans = 0;
    map<string, bool> keihin;

    cin >> n;

    rep(i, n) {
        string s;
        cin >> s;
        if (keihin[s] != true)
        {
            keihin[s] = true;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e3+10;

int main()
{

   string s;
   cin>>s;
   for(int i=1;i<s.size();i++)
   {
       if(s[i]==s[i-1])
       {
           puts("Bad");
        return 0;
       }

   }
   puts("Good");

    return 0;
}


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

int frog2(vector<int>A,int n,int k)
{
    vector<int>dp(n);
    int ans;
    dp[0]=0;
    //dp[1]=abs(A[1]-A[0]);
    for(int i=1;i<n;i++)
    {
        ans= INT_MAX;
        for(int j=i-1;j>=i-k;j--)
        {
            
            if(j>=0)
            {
                //cout<<i<<j<<endl;
                ans=min(ans, dp[j]+abs(A[i]-A[j]));
            }
            
        }
        dp[i]=ans;
       // cout<<dp[i]<<endl;
    }return dp[n-1];
}

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> A(n);
	
	for(int i=0;i<n;i++)cin>>A[i];
	cout<<frog2(A,n,k);
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    string s;
    map<string ,int> mp;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
  	int maxx=0;
    for(auto it:mp){
        if(it.second > maxx)
            maxx=it.second;
    }
    
    for(auto it:mp){
        if(it.second == maxx)
            cout<<it.first<<"\n";;
    }
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define phi 3.1415926535
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
 
using namespace std;

const ll mod = 1000000007;    

ll tc, cnt = 0, number, many, total = 0, query;
// vector <vector <int> > adjList;
int rmove[8] = {-1, 0, 1, 0, -1, 1, -1, 1};
int cmove[8] = {0, 1, 0, -1, 1, -1, -1, 1};

ll power(ll x, ll y, ll mod)
{
    if(y == 0)
        return 1;
    else if(y % 2 == 0)
        return (power(x, y / 2, mod) % mod * power(x, y / 2, mod) % mod) % mod;
    else
        return x * (power(x, y / 2, mod) % mod * power(x, y / 2, mod) % mod) % mod;
}

ll dp[100 + 5][100000 + 5], answer = 0;

int main()
{
    fastio();
        
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // g++ -std=c++11 Default.cpp  -o test
    // g++ -Wl,--stack=268435456 -std=c++11 Default.cpp  -o test

    cin >> many >> number;

    pair<ll, ll> arr[many];
    ll sum = 0;
    for(int i = 0; i < many; i++)
    {
        cin >> arr[i].fi >> arr[i].se;
        sum += arr[i].se;
    }

    memset(dp, 0, sizeof(dp));

    for(int i = 0; i <= 100000; i++)
        dp[0][i] = 1e14;

    ll answer = 0;
    for(int i = 1; i <= many; i++)
    {
        for(int j = 0; j <= 100000; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if(j - arr[i - 1].se >= 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - arr[i - 1].se] + arr[i - 1].fi);
            if(j <= arr[i - 1].se)
                dp[i][j] = min(dp[i][j], arr[i - 1].fi);

            if(dp[i][j] <= number)
                answer = max(answer, j * 1LL);
        }
    }

    cout << answer << endl;

    //
    return 0;
}

Measured memory_bytes: 85612
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pis = pair<double,string>;
using piii = pair<int,pis>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll

signed main(){
    int n;
    while(cin >> n,n){
        vector<pis>v;
        map<double,string>mp;
        rep(i,n){
            string  L; int P, A, B, C, D, E, F, S, M;
            cin >> L;
            cin >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            if(M == 1){
                v.push_back(pis(-(double)(F*S*M-P)/(A+B+C+D+E),L));
            }else {
                int val = F*S*M-P;
                int t = A+B+C+D+E+(M-1)*(D+E);
                v.push_back(pis(-(double)val/t,L));
            }
            
        }
        string name;
        sort(all(v));
        rep(i,v.size())cout << v[i].second << endl;
        cout << "#" << endl;
    }
}




Measured memory_bytes: 3040
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int N=sc.nextInt();
            int R=sc.nextInt();
            if(N+R==0) break;
            int A[]=new int[N];
            for(int i=0;i<N;i++) A[i]=N-i;
            for(int i=0;i<R;i++){
                int p=sc.nextInt();
                int c=sc.nextInt();
                int B[]=new int[N];
                int now=0;
                for(int j=p-1;j<p-1+c;j++){
                    B[now]=A[j];
                    now++;
                }
                for(int j=0;j<p-1;j++){
                    B[now]=A[j];
                    now++;
                }
                for(int j=p-1+c;j<N;j++){
                    B[now]=A[j];
                    now++;
                }
                for(int j=0;j<N;j++) A[j]=B[j];
            }
            System.out.println(A[0]);
        }
    }
}


Measured memory_bytes: 39256
#include <bits/stdc++.h>
#include <atcoder/all>
 
using namespace std;
using namespace atcoder;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define lb(x,a) lower_bound(all(x),a)
#define ub(x,a) upper_bound(all(x),a)
#define maxe(x,a) max_element(all(x))
#define mine(x,a) min_element(all(x))
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

ll op(ll a, ll b) {return max(a, b);}
 
ll e() {return 0;}

void solve(){
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  segtree<ll, op, e> seg(300010);
  
  rep(i,0,n){
  ll a;
    cin >> a;
    ll l=max(0ll,a-k),r=min(a+k,300000ll);
    ll now=seg.prod(l,r+1)+1;
    chmax(ans,now);
    
    seg.set(a,now);
  }
 cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 13768
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#include<climits>

using namespace std;

int main(void){
    string S;
    cin >> S;
    unsigned long long ans = S.length();
    for(unsigned long long i = 0; i < S.length() - 1; i++){
        if(S[i] != S[i + 1]){
            ans = min(ans, max(i + 1, S.length() - i - 1));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
dp = [[[[0, 0, 0, 0] for _ in range(4)] for _ in range(4)] for _ in range(n - 2)] #a,c,g,t
arr = [[0, 2, 1], [0, 1, 2], [2, 0, 1]]
for i in range(4):
    for j in range(4):
        for k in range(4):
            if not [i, j, k] in arr:
                dp[0][i][j][k] = 1

arr2 = [[0, 2, 2, 1], [0, 3, 2, 1], [0, 2, 3, 1], [0, 2, 2, 1]]
for nn in range(1, n - 2):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if not [i, j, k, l] in arr2 and not [j, k, l] in arr:
                        dp[nn][j][k][l] += dp[nn - 1][i][j][k]
                        dp[nn][j][k][l] %= mod
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[n - 3][i][j][k]
            ans %= mod
print(ans)

Measured memory_bytes: 63832
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
#define ii pair<int,int>
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
vector<int> g[111111];
int d[111111];
int main(){
	memset(d,-1,sizeof(d));
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int q2;
	cin>>q2;
	priority_queue<ii,vector<ii>,greater<ii> >q;
	while(q2--){
		int a,b;
		cin>>a>>b;
		d[a]=b;
		q.push(make_pair(d[a],a)); 
	}
	while(!q.empty()){
		ii x=q.top();
		q.pop();
		for(int i=0;i<g[x.second].size();i++){
			if(d[g[x.second][i]]==-1){
				d[g[x.second][i]]=x.first+1;
				q.push(make_pair(d[g[x.second][i]],g[x.second][i]));
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<g[i].size();i++)if(abs(d[i]-d[g[i][j]])!=1){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=1;i<=n;i++)cout<<d[i]<<endl;
	return 0;
}

Measured memory_bytes: 8180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int k,x;
  cin >> k >> x;
  for(int i= -k; i<k-1; i++){
    cout << x + 1 +i << " ";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

int f[MAX_N], _f[MAX_N];

int binpow(int a, int b) {
    int res = 1;
    while(b) {
        if (b & 1)
            res = 1ll * res * a % mod;
        b >>= 1;
        a = 1ll * a * a % mod;
    }
    return res;
}

int CnK(int n, int k) {
    if (n < k)
        return 0;
    int res = f[n] * 1ll * _f[k] % mod;
    res = res * 1ll * _f[n - k] % mod;
    return res;
}

int n;
int a[MAX_N];

int pr[MAX_N];

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; i++)
        scanf("%d", &a[i]);
    
    f[0] = _f[0] = 1;
    for (int i = 1; i <= n + 1; i++) {
        f[i] = 1ll * f[i - 1] * i % mod;
        _f[i] = binpow(f[i], mod - 2);
    }
    
    int l = 0, r = 0;
    for (int i = 1; i <= n + 1; i++) {
        if (pr[a[i]]) {
            l = pr[a[i]], r = i;
            break;
        }
        pr[a[i]] = i;
    }
    
    for (int i = 1; i <= n + 1; i++) {
        if (i == 1) {
            printf("%d\n", n);
            continue;
        }
        if (i == n + 1) {
            printf("1\n");
            continue;
        }
        
        int f = CnK(n, i);
        int s = CnK(n, i - 1) - CnK(n + 1 - (r - l + 1), i - 1);
        if (s < 0)
            s += mod;
        
        int res = f + s;
        if (res >= mod)
            res -= mod;
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 2816
# f127_7では中央値を毎回抜き出しているせいで遅かったので改善
# heapの最小値は[0]で出せる

import heapq

n = int(input())

# 中央値より左・右の管理
l=[10**10]
r=[10**10]
heapq.heapify(l)
heapq.heapify(r)
lenl=0
lenr=0

ans = 0

for i in range(n):
    q = list(map(int,input().split()))
    if q[0]==1:
        ans += q[2]
        if lenl>lenr:
            lenr+=1
            x = -l[0]
            ans+=abs(x-q[1])
            if x<=q[1]:
                heapq.heappush(r,q[1])
            else:
                heapq.heappush(r,x)
                heapq.heapreplace(l,-q[1])
        else:
            lenl+=1
            x = r[0]
            if x<q[1]:
                heapq.heappush(l,-x)
                heapq.heapreplace(r,q[1])
            else:
                heapq.heappush(l,-q[1])
            ans+=abs(-l[0]-q[1])
    if q[0]==2:
        print(-l[0], ans)


Measured memory_bytes: 79448
// 2012/11/19 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;

	int N;
	cin >> N;

	int cnt = 0;
	for(int i=0; i<N; i++){
		string R;
		cin >> R;

		R = R+R;

		if(R.find(S)!=string::npos){
			cnt++;
		}
	}

	cout << cnt << '\n';

	return 0;
}

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

int main() {
  char N, M;
  string A = "";
  cin >> N >> M;
  
  int in, im;
  in = (int)N - '0';
  im = (int)M - '0';
  
  if (N > M) {
  	for (int i = 0; i < in; i++) {
      A += M;
    }
  } else {
  for (int i = 0; i < im; i++) {
      A += N;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
N = input()
A = map(int, raw_input().split())
ans = 0
flag = True
while flag:
    flag = False
    for j in xrange(N-1, 0, -1):
        if A[j] < A[j-1]:
            ans += 1
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
print ' '.join(map(str, A))
print ans

Measured memory_bytes: 6448
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [[] for i in range(n)]
for i in range(m):
    s, t = map(int, input().split())
    a[s-1].append(t-1)
    a[t-1].append(s-1)
cnt = 0
for i in range(0, n):
    flag = True
    for j in range(len(a[i])):
        if h[i] <= h[a[i][j]]:
            flag = False
            break
    if flag:
        cnt += 1
print(cnt)

Measured memory_bytes: 92892
#include<bits/stdc++.h>
using namespace std;
long long k;
int n;
long long dp[100001];
long long mod=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    memset(dp,0,sizeof(dp));
    cin>>n>>k;
    int i,j;
    long long a;
    dp[0]=1;
    for(i=0;i<n;i++)
    {
        cin>>a;
        for(j=1;j<=k;j++)
        dp[j]=(dp[j-1]%mod+dp[j]%mod)%mod;
        for(j=k;j>=a+1;j--)
        dp[j]=(dp[j]%mod-dp[j-a-1]%mod+mod)%mod;
    }
    cout<<dp[k];
    return 0;
}


Measured memory_bytes: 1152
def main():
    n = int(input())
    a = list(map(int, input().split()))
    x = int(input())
    bc = [list(map(int, input().split())) for _ in [0]*x]
    ans = [0]*100001
    for i in a:
        ans[i] += 1
    ans2 = sum(a)
    for b, c in bc:
        ans2 += (c-b)*ans[b]
        ans[c] += ans[b]
        ans[b] = 0
        print(ans2)


main()


Measured memory_bytes: 32844
import java.math.BigInteger;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int M = sc.nextInt();
			BigInteger A = new BigInteger(Math.min(N, M) + "");
			BigInteger B = new BigInteger(Math.max(N, M) + "");
			if(B.add(A.negate()).intValue() > 1){
				System.out.println(0);
			}else{
				BigInteger sub = new BigInteger((B.equals(A))? "2" : "1");
				BigInteger result = mult(A).multiply(mult(B)).multiply(sub).mod(new BigInteger("1000000007"));
				System.out.println(result.toString());
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	private static BigInteger mult(BigInteger x){
		BigInteger result = new BigInteger("1");
		while(x.intValue() > 1){
			result = result.multiply(x).mod(new BigInteger("1000000007"));
			x = x.add(new BigInteger("1").negate());
		}
		return result;
	}
}

Measured memory_bytes: 60580
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long N=sc.nextLong();
		System.out.println((A*Math.min(N, B-1))/B);
	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void inp_str(int*);


int main(void) {

int input1[120];
inp_str(input1);

int A,B,C;
A=input1[0];
B=input1[1];
C=input1[2];


/*printf("%d\n",A);
printf("%d\n",B);
printf("%d\n",C);*/

int D;

if(A>B){D=A;
}else{D=B;
}

if(C<D){
	
if(A<B){D=A;
}else{D=B;
}

if(D<C){
printf("Yes\n");
}else{
printf("No\n");
}	
	
	
	
	
	
	
}else{
printf("No\n");
}




/*int i;
for(i=0;i<N;i=i+1){
if(input2[i]>=M){
	M=input2[i];
	C=C+1;
}

}
*/


//printf("%d\n",M);

//printf("%d\n",C);




/*

if(flag==1) {
	printf(":(\n");
}else{
printf("Yay!\n");
} 

*/                       
    return 0;
}


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
//template
typedef double db;
const db eps=1e-10;
const db pi=acosl(-1.0);
int sign(db x){if(x<-eps)return -1;if(x>eps)return 1;return 0;}
int cmp(db x,db y){return sign(x-y);}
bool inmid(db x,db l,db r){return cmp(x,l)*cmp(x,r)<=0;}
struct po{
	db x,y;
	po(db _x=0,db _y=0):x(_x),y(_y){}
	void read(){scanf("%lf%lf",&x,&y);}
};
po operator +(const po &a,const po &b){return po(a.x+b.x,a.y+b.y);}
po operator -(const po &a,const po &b){return po(a.x-b.x,a.y-b.y);}
po operator *(const po &a,const db &b){return po(a.x*b,a.y*b);}
po operator /(const po &a,const db &b){return po(a.x/b,a.y/b);}
db operator *(const po &a,const po &b){return a.x*b.x+a.y*b.y;}
db operator ^(const po &a,const po &b){return a.x*b.y-a.y*b.x;}
db mo2(po a){return a*a;}
db mo(po a){return sqrt(a*a);}
po proj(po x,po y){//proj x to y
	return y*((x*y)/mo2(y));
}
po refl(po x,po y){//refl x from y
	return proj(x,y)*2-x;
}
bool onseg(po x,po l,po r){
	return (sign((x-l)^(r-l))==0)&&inmid(x.x,l.x,r.x)&&inmid(x.y,l.y,r.y);
}
bool inter(db l1,db r1,db l2,db r2){
	if(cmp(l1,r1)==1)swap(l1,r1);
	if(cmp(l2,r2)==1)swap(l2,r2);
	return cmp(min(r1,r2),max(l1,l2))>=0;
}
bool checkss(po a,po b,po c,po d){
	return sign((b-a)^(c-a))*sign((b-a)^(d-a))<=0&&sign((d-c)^(a-c))*sign((d-c)^(b-c))<=0&&inter(a.x,b.x,c.x,d.x)&&inter(a.y,b.y,c.y,d.y);
}
po getll(po a,po b,po c,po d){
	db u=((b-a)^(c-a));
	db v=((d-a)^(b-a));
	return (c*v+d*u)/(u+v);
}
db dispp(po x,po y){return sqrt((x-y)*(x-y));}
db disps(po x,po l,po r){
	po y=proj(x-l,r-l)+l;
	if(onseg(y,l,r))return dispp(x,y);
	else return min(dispp(x,l),dispp(x,r));
}
db disss(po x,po y,po l,po r){
	if(checkss(x,y,l,r))return 0;
	return min(min(disps(x,l,r),disps(y,l,r)),min(disps(l,x,y),disps(r,x,y)));
}
db area(vector<po> a){
	db ans=0;
	rep(i,0,a.size()-1)ans+=(a[i]^a[(i+1)%a.size()]);
	return fabs(ans)/2;
}
//template
int main(){
	int n;scanf("%d",&n);
	vector<po> a;
	rep(i,0,n-1){
		po x;x.read();a.pb(x);
	}
	printf("%.1lf\n",area(a));
	return 0;
}






Measured memory_bytes: 3260