akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> m >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	sort(RALL(v));
	if(m < v[0] * 2 + 1){
		cout << v[0] - 1 - (m - v[0]) << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//----------------------//

int n;
ll dp[53][4][4];
string s[2];

int main() {
	cin >> n;
	cin >> s[0] >> s[1];
	
	if (n == 1) {
		cout << 3 << endl;
		return 0;
	}
	
	dp[0][0][0] = 1;
	REP(i, n) {
		REP(j, 4) {
			REP(k, 4) {
				if (dp[i][j][k] == 0) continue;
				
				int nex1 = -1, nex2 = -1;
				
				if (i < n - 1) {
					if (s[0][i] == s[0][i + 1]) nex1 = 0;
					if (s[1][i] == s[1][i + 1]) nex2 = 0;
					
					if (s[0][i] == s[1][i]) nex1 = -2, nex2 = -2; // 同じ値
				}
				else {
					if (s[0][i] == s[1][i]) nex1 = -2, nex2 = -2; // 同じ値
				}
				
				FOR(col1, 1, 4) {
					FOR(col2, 1, 4) {
						if (nex2 == -2) {
							if (col1 != col2 || col1 == j || col2 == k) continue;
							(dp[i + 1][col1][col2] += dp[i][j][k]) %= MOD;
						}
						else {
							if (col1 == col2) continue;
							
							if (nex1 == -1 && j != col1) continue;
							if (nex1 == 0 && col1 == j) continue;
							
							if (nex2 == -1 && k != col2) continue;
							if (nex2 == 0 && col2 == k) continue;
							
							(dp[i + 1][col1][col2] += dp[i][j][k]) %= MOD;
						}
					}
				}
			}
		}
	}
	
	ll ans = 0;
	
	FOR(j, 1, 4) FOR(k, 1, 4) {
		(ans += dp[n][j][k]) %= MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = INT_MAX;

priority_queue<double, vector<double>, greater<double>> pq;

int main(){
  int N;
  cin >> N;
  rep(i, N){
    int a;
    cin >> a;
    pq.push(a);
  }
  while(pq.size() != 1){
    double x = pq.top();
    pq.pop();
    double y = pq.top();
    pq.pop();
    double z = (x + y)/2;
    pq.push(z);
  }
  double ans = pq.top();
  printf("%lf\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  ll l, r;
  cin>>l>>r;
  ll ans = 4000*4000;

  if(r-l>=2019)
    ans = 0;
  else
    for(ll i=l; i<=r; i++) {
      for(ll j=i+1; j<=r; j++) {
	ans = min((i*j)%2019, ans);
      }
    }
  std::cout << ans << std::endl;

  //   std::cout << 0 << std::endl;
  // else
  //   std::cout << (l*(l+1))%2019 << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
int cnt[100009];
int n;
int main()
{
    memset(cnt,0,sizeof(cnt));
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;scanf("%d",&x);
        cnt[x]++;
    }
    int ans=0;
    for(int i=1;i<=100000;i++)
    {
        if(cnt[i])ans++;
    }
    if(ans%2==0)ans--;
    printf("%d\n",ans);
    return 0;
}

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

#define MAX_N 100
#define MAX_L 10

void set_words(int n);
int check_shiritori1(int n);
int check_shiritori2(int n);
  
char words[MAX_N][MAX_L+1];

int main(void) {

  int n;
  int result;
  
  scanf("%d", &n);
  set_words(n);

  result = check_shiritori1(n);

  if (result == 0) {
    printf("No");
  	return 0;
  } 

  result = check_shiritori2(n);

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

void set_words(int n) {

  int k;
  char str_temp[MAX_L+1];
  
  for (k = 0; k < n; k++) {
    scanf("%s", str_temp);
    strcpy(words[k], str_temp);
  }

}

int check_shiritori1(int n) {

  int k1,k2;

  for (k1 = 0; k1 < n; k1++) {
    for (k2 = 0; k2 < n; k2++) {
      if (k1 == k2) { continue; }
      if (strcmp(words[k1], words[k2]) == 0) {
	    return 0;
      }
    }
  }

  return 1;
}

int check_shiritori2(int n) {

  int k;

  for (k = 1; k < n; k++) {
    if (words[k][0] != words[k-1][strlen(words[k-1])-1]) {
      return 0;
    }
  }

  return 1;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<ll> A=vecin<ll>(N);
	auto maxA=*max_element(ALL(A));
	int B=0;
	while(maxA){
		B++;
		maxA>>=1LL;
	}

	ll ans=0;
	vector<ll> zero(B,0),one(B,0);
	REP(n,N){
		ll v=A[n];
		REP(index,B){
			if(v&1) one[index]++;
			else zero[index]++;
			v>>=1LL;
		}
	}
	REP(i,B){
		ans += (((zero[i]*one[i])%atcoder_mod)*((1LL<<(ll)i)%atcoder_mod))%atcoder_mod;
		ans %= atcoder_mod;
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
// #define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long double val = 2 * 3.141592653589793238;
   long int r;
   cin>>r;

   val *= r;

   cout<<fixed<<setprecision(15)<<val;
   return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll A, B, C, D, E, F;

signed main(){
    cin >> A >> B >> C >> D >> E >> F;
    ll w = F, s = 0;
    for(ll a = 0; a <= F; a += 100 * A){
        for(ll b = 0; a + b <= F; b += 100 * B){
            if(a + b == 0) continue;
            for(ll c = 0; a + b + c <= F; c += C){
                for(ll d = 0; a + b + c + d <= F; d += D){
                    if(100 * (c + d) > E * (a + b)) continue;
                    if(s * (a + b + c + d) <= (c + d) * (w + s)){
                        w = a + b;
                        s = c + d;
                    }
                }
            }
        }
    }
    cout << w + s << " " << s << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5;
vector<int> g[N];
int d[N], anc[N], a[N];
int n;

bool on_diam[N];

int bfs(int s) {
    fill(d, d + n, -1);
    d[s] = 0;

    queue<int> q;
    q.push(s);

    while (!q.empty()) {
        int node = q.front();
        q.pop();

        for (int to : g[node]) {
            if (d[to] == -1) {
                d[to] = d[node] + 1;
                anc[to] = node;
                q.push(to);
            }
        }
    }

    return max_element(d, d + n) - d;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    int x = bfs(bfs(0));

    vector<int> diam;

    while (true) {
        diam.push_back(x);
        on_diam[x] = true;
        if (d[x] == 0)
            break;
        x = anc[x];
    }

    bool ok = true;

    for (int y : diam) {
        for (int to : g[y]) {
            if (!on_diam[to] && g[to].size() != 1) {
                ok = false;
                break;
            }
        }
    }

    if (ok) {
        vector<int> perm;

        for (int i = 0; i < diam.size(); i++) {
            a[i] = g[diam[i]].size();
            if (i > 0)
                a[i]--;
            if (i + 1 < diam.size())
                a[i]--;
        }

        for (int k = 0; k < 2; k++) {
            int last = 0;
            vector<int> cur;
            for (int i = 0; i < diam.size(); i++) {
                int x = ++last;
                for (int j = 0; j < a[i]; j++) {
                    cur.push_back(++last);
                }
                cur.push_back(x);
            }
            if (perm.empty() || perm > cur)
                perm = cur;
            reverse(all(diam));
            reverse(a, a + diam.size());
        }

        for (int y : perm)
            cout << y << " ";
    }
    else {
        cout << "-1\n";
    }

    return 0;
}

Measured memory_bytes: 8688
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, K, l[51];
int ans;

int main()
{
	in >> N >> K;
	rep(i, N) { in >> l[i]; }

	std::sort(l, l + N, std::greater<int>());
	rep(i, K) { ans += l[i]; }

	out << ans << std::endl;
	return 0;
}

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

int main(void){
    int p, q, r;
    cin >> p >> q >> r;
    int pq = p+q;
    int qr = q+r;
    int rp = r+p;
    if(pq <= qr && pq <= rp) cout << pq << endl;
    else if(qr <= rp) cout << qr << endl;
    else cout << rp << endl;
}

Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ab = readInts()
    let a = ab[0]
    let b = ab[1]
    
    if (a + b) % 2 == 0 {
        print((a + b) / 2)
    } else {
        print("IMPOSSIBLE")
    }
}

main()


Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

void selection (int n, vector<int> &a) {
    int cnt = 0;
    rep (i, 0, n) {
        int minj = i;
        rep (j, i, n) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            int v = a[i];
            a[i] = a[minj];
            a[minj] = v;
            cnt++;
        }
        // rep (i, 0, n) cout << a[i] << " ";
        // cout << "\n";
    }
    rep (i, 0, n) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << "\n" << cnt << "\n";
}

int main() {
    int n;
    cin >> n;
    vector<int> a (n);
    rep (i, 0, n) cin >> a[i];
    selection (n, a);
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define SIZE 100005

using namespace std;
typedef long long int ll;

int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	ll ret=0;
	bool up=false;
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		if(up&&a>0)
		{
			a--;
			ret++;
		}
		ret+=a/2;
		up=a%2==0?false:true;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int h,w,n;scanf("%d%d%d",&h,&w,&n),h;){
		static int B[1000][1000];
		rep(i,h) rep(j,w) scanf("%d",B[i]+j);

		static int dp[1000][1000];
		rep(i,h) rep(j,w) dp[i][j]=0;
		dp[0][0]=n-1;
		rep(i,h) rep(j,w) {
			if(i<h-1) dp[i+1][j]+=(dp[i][j]+(B[i][j]==1?0:1))/2;
			if(j<w-1) dp[i][j+1]+=(dp[i][j]+(B[i][j]==0?0:1))/2;
		}

		int y=0,x=0;
		while(y<h && x<w) if((B[y][x]+dp[y][x])%2==0) y++; else x++;
		printf("%d %d\n",y+1,x+1);
	}

	return 0;
}

Measured memory_bytes: 8092
n = int(input())
ss = list(map(int, (input() for _ in range(n))))

full = sum(ss)
non0s = list(s for s in ss if s%10!=0)

if full%10!=0:
    print(full)
else:
    if len(non0s)==0:
        print(0)
    else:
        print(full - min(non0s))

Measured memory_bytes: 3060
#include <stdio.h>

 long int min(long int a, long int b);

 long int sub_child( long int c1,  long int m1,  long int c2,  long int m2);

int main(void){
  long int N, h, i, j, tmp1, tmp2, tmp3, c1, m1, n, w=0, not_found = 1;

  scanf("%ld", &N);

  if(!(N%2)) printf("%ld %ld %ld\n", N, N, N/2);
  else{
    if(N%4 == 3){
      h = (N+1)/4;
      printf("%ld %ld %ld\n", h, 2*N*h, 2*N*h);
    }
    else{
      h = (N+3)/4;
      if(!(h%2)) printf("%ld %ld %ld\n", h, N*h, N*h/2);
      else{
	for(i=h;i<=min(N*3/4 + 1, 3500) && !w && not_found;i++){
	  tmp1 = sub_child(4, N, 1, i);
	  tmp2 = N*i;
	  if(!(tmp2%tmp1)){
	    h=i;
	    n=2*tmp2/tmp1;
	    w=n;
	    break;
	  }
	  else if(!(tmp1%2) && !(tmp2%(tmp1/2))){
	    h=i;
	    n=tmp2/(tmp1/2);
	    w=n;
	    break;
	  }
	  else{
	    for(j=tmp2/tmp1 + 1; j<=min(2*tmp2/tmp1 + 1, 3500);j++){
	      //if tmp1/tmp2 - 1/j is in the form of 1/k 
	      if(!(tmp2*j % (tmp3=sub_child(tmp1, tmp2, 1, j)))){
		h=i;
		n=j;
		w=tmp2*j/tmp3;
		not_found=0;
		break;
	      }
	    }
	  }
	}
      }
    }
  }
  if(w) printf("%ld %ld %ld\n", h, n, w);

  return 0;
}

  long int min(long int a, long int b){
    if(a < b) return a;
    else return b;
  }

  /*c1/m1 - c2/m2を計算する。
    =(c1m2 - c2m1) / m1m2 */
  
long int sub_child(long int c1, long int m1, long int c2, long int m2){
    return c1*m2 - c2*m1;
  }


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long Max = LONG_MAX;
int n, ar[100050] = {};
long long dp[100005] = {};
void findSolution(int pos, int pre)
{
    if(dp[pos] != Max)
    {
        long long d = abs(ar[pre]-ar[pos]);
        d += dp[pos];
        dp[pre] = min(dp[pre], d);
        return;
    }
    if(pos == n)
    {
        long long d = abs(ar[pos]-ar[pre]);
        d += dp[pos];
        dp[pre] = min(dp[pre], d);
        return;
    }
    if(pos+1 <= n)
    {
        findSolution(pos+1, pos);
    }
    if(pos+2 <= n)
    {
        findSolution(pos+2, pos);
    }
    dp[pre] = min(dp[pre], abs(ar[pre]-ar[pos])+dp[pos]);
}
void solve()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &ar[i]);
    }
    for(int i = 0; i <= n+2; i++)
    {
        dp[i] = Max;
    }
    dp[n] = 0;
    findSolution(1, 0);
    cout << dp[1] << endl;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a, b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    if (S.size()<=K) {
        cout << S << endl;
    }
    else {
        rep(i,0,K) {
            cout << S[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3620
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
a_cnt = collections.Counter(a).most_common()[::-1]
ans = 0
n = len(list(set(a)))
if n <= k:
    print(0)
    exit()
for v in range(n):
    ans += a_cnt[v][1]
    n -= 1
    if n <= k:
        print(ans)
        exit()


Measured memory_bytes: 41388
n, m= list(map(int, input().split()))
a = []
cnt=[]
num=0
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(31):
    cnt.append(0)
for i in range(n):
    for j in range(1,a[i][0]+1):
        tmp=a[i][j]
        cnt[tmp]+=1
for i in range(31):
    if cnt[i]==n:
        num+=1
print(num)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N, i; cin >> N >> i;
  cout << N - i + 1 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "Yes" << endl;}                                               
void no() {cout << "No" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);

void solve() {
    long long x, p; cin >> x >> p;
    cout << fixed << setprecision(6) << (double)((x + 1) / 2 * 100.0 / p) << endl;
} 

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

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

typedef long long ll;

int n,mi;
vector<int> w;

int solve(){

    int ret = 0;
    vector<int> sub(w);
    sort(sub.begin(),sub.end());
    vector<int> cir(10001);
    vector<bool> bol(n);

    for(int i=0;i<n;i++){
        cir[sub[i]] = i;
        bol[i]=false;
    }
    for(int i=0;i<n;i++){
        int sum=0,sn=0;
        int loc=i;
        int mmi=1e9;

        for(;;){
            bol[loc]=true;
            sn++;
            mmi=min(w[loc],mmi);
            sum+=w[loc];
            loc=cir[w[loc]];
            if(bol[loc])break;
        }
        ret+=min(sum+(sn-2)*mmi,sum+mmi+mi*(sn+1));
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    mi = 1e9;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        mi = min(mi,a);
        w.push_back(a);
    }
    int ans = solve();
    cout << ans << endl;
}



Measured memory_bytes: 3244
import java.util.Scanner;
public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			if(n==0)break;
			int min = 100000;
			
			
			for(int z=0;z<=1000000;z++) {
				if(z > n)break;
				for(int y=0;y<=1000000;y++) {
					if(z*z*z+y*y>n || min<=z+y)break;
					int x = n-y*y-z*z*z;
					min = Math.min(x+y+z, min);
				}
			}
			
			System.out.println(min);
		}
		
	}
}



Measured memory_bytes: 34772
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <unordered_map>
#include <deque>
#include <set>
#include <stack>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
#define Endl '\n'
#define ll long long int
/*I can do this*/
int main()
{
    int n;
    cin>>n;
    for (int i = 1; i < 10000; ++i)
    {
        if ((i*n)%360==0)
        {
            cout<<i;
            break;
        }
    }
}
    

Measured memory_bytes: 3616
#coding:utf-8

import sys

S = int(input())
S1 = int(S/100)
S2 = int(S-100*S1)

if (1 <= S1 <= 12) and (1 <= S2 <= 12):
    print("AMBIGUOUS")
    sys.exit()

if (1 <= S2 <= 12):
    print("YYMM")
    sys.exit()

if (1 <= S1 <= 12):
    print("MMYY")
    sys.exit()

else:
    print("NA")


Measured memory_bytes: 3060
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    if a[i] == 0:
        continue
    if a[a[i]-1]-1 == i:
        ans += 1
        a[a[i]-1], a[i] = 0, 0
        
print(ans)

Measured memory_bytes: 13880
N, P = map(int, input().split())


def factorization(n):
    """
    素因数分解
    factorization(24)
    [[2, 3], [3, 1]]
    24 = 2^3 * 3^1
    """
    arr = []
    temp = n
    for i in range(2, int(-(-(n ** 0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


d = factorization(P)
ans = 1
# print(d)
for p, num in d:
    # print(p, num, num // N)
    if num // N != 0:
        ans = ans * pow(p, (num // N))
print(ans)



Measured memory_bytes: 9400
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct sushi{
  int t;
  LL d;

  bool operator<(const sushi &r) const{
    return d<r.d;
  }
};

int main(){
  int n, k;
  cin>>n>>k;
  priority_queue<sushi> q;
  priority_queue<LL> q2;
  sushi s;
  LL slist[n];
  REP(i, n) slist[i]=0;

  REP(i, n){
    cin>>s.t>>s.d;
    --s.t;
    q.push(s);
  }

  if(n==1){
    cout<<1+s.d<<endl;
    return 0;
  }

  LL sum=0;
  LL kind=0;
  REP(i, k){
    sushi ss = q.top();
    q.pop();
    if(slist[ss.t]==0) ++kind;
    else q2.push(-ss.d);
    ++slist[ss.t];
    sum += ss.d;
  }
  LL ans = sum + kind*kind;

  FOR(i, k, n){
    if(q2.empty()==true) break;
    sushi ss = q.top();
    q.pop();
    if(slist[ss.t]>0) continue;
    ++slist[ss.t];
    sum = sum + ss.d + q2.top();
    ++kind;
    q2.pop();

    ans=max(ans, sum + kind*kind);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <algorithm>
using namespace std;
int g(int n) {
	int cnt=0;
	while (n != 0){
		n /= 10;
		cnt++;
	}
	return cnt;
}
int main()
{
	int n;
	int ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		//cout << "tes" << i << endl;
		if ((g(i)) % 2 != 0) ans++;
	}
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <utility>
using namespace std;

int main(void) {
  int i, j, k, n, m, ans = 0;
  scanf("%d%d", &n, &m);
  pair< pair<int, int> , int> a[m];
  int dis[n][n];
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) dis[i][j] = 1e9;
  for(i = 0; i < n; ++i) dis[i][i] = 0;
  for(i = 0; i < m; ++i) {
    scanf("%d%d%d", &a[i].first, &a[i].first.second, &a[i].second);
    a[i].first.first--, a[i].first.second--;
    dis[a[i].first.first][a[i].first.second] = dis[a[i].first.second][a[i].first.first] = a[i].second;
  }
  for(k = 0; k < n; ++k) for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) if(dis[i][j] > dis[i][k] + dis[k][j]) dis[i][j] = dis[i][k] + dis[k][j];
  for(i = 0; i < m; ++i) if(dis[a[i].first.first][a[i].first.second] != a[i].second) ++ans;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
a,p = divmod(A-1,50)
b,q = divmod(B-1,50)
ans = []
cnt = 0
for i in range(2*a):
  if i%2==0:
    ans += ['.#'*50]
  else:
    ans += ['#'*100]
cnt += 2*a

if p!=0:
  ans += ['.#'*p+'#'*(100-2*p)]
  cnt += 1
ans += ['#'*100]
ans += ['.'*100]
cnt += 2
for i in range(2*b):
  if i%2==0:
    ans += ['.#'*50]
  else:
    ans += ['.'*100]
cnt += 2*b
if q!=0:
  ans += ['.#'*q+'.'*(100-2*q)]
  cnt += 1
print(cnt,100)
print('\n'.join(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	ll res = abs(x / d);
	ll ans = abs(x) - res * d;
	if (res >= k) {
		cout << abs(x) - k * d << endl;
	}
	else {
		k -= res;
		if (k % 2) {
			ans -= d;
			cout << abs(ans) << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n; cin >> n;
	string res;

	while (n > 0)
	{
		long long a = n % 26;
		if(a == 0) a = 26;
		res.push_back('a' + a - 1);
		n = (n - a) / 26;
	}
	reverse(res.begin(), res.end());

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3632
#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 <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep (i, n) cin >> a[i];
	rep (i, n) eprintf("%d ", a[i]); eprintf("\n");
	ll now_min = 0, ans = 0;
	rep (i, n) {
		if (a[i] > now_min + 1) {
			ans += (a[i] - 1) / (now_min + 1);
			chmax(now_min, 1LL);
		} else {
			chmax(now_min, (ll)a[i]);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
/*
  This C++ Source Is
  Writen By syksykCCC
  (After July, 2019)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i < y; i++)
#define REP(i, x, y) for(int i = x; i <= y; i++)
#define per(i, x, y) for(int i = x; i > y; i--)
#define PER(i, x, y) for(int i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c))
	{
		if(c == '-') f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		val = (val << 3) + (val << 1) + (c ^ 48);
		c = getchar();
	}
	val *= f;
}
template<typename T> void write_(T val)
{
	if(!val) return;
	write_(val / 10);
	putchar(val % 10 + 48);
}
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0)
	{
		putchar('-');
		write_(-val);
	}
	else write_(val);
}

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
//	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	A -= B << 1;
	cout << max(A, 0) << endl;
	return 0;
}


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

int main(){
    int A, B;

    cin >> A >> B;
    for (int i = 1; i <= 3; i++){
        if((A * B * i) % 2 == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int n,m;

int x[50];

int main() {
  std::cin>>n>>m;
  
  for(int i=0;i<n;++i){
    int k;
    std::cin>>k;
    for(int j=0;j<k;++j){
      int a;
      std::cin>>a;
      ++x[a];
    }
  }
  
  int ans=0;
  
  for(int i=0;i<=m;++i){
    if(x[i]==n)
      ++ans;
  }
  
  std::cout<<ans<<"\n";
  
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

string s;

signed main() {
    cin >> s;
    if (s.size()==2) cout << s << endl;
    else reverse(all(s)),cout << s << endl;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int h;
  cin >> h;
  
  vector<ll> heap(h);
  rep(i, h) cin >> heap[i];

  for (int i = 1; i <= h; i++) {
    printf("node %d: key = %lld, ", i, heap[i - 1]);
    int parent = i / 2 - 1, left = i * 2 - 1, right = i * 2;

    if (parent >= 0 && parent < h) printf("parent key = %lld, ", heap[parent]);
    if (left >= 0 && left < h) printf("left key = %lld, ", heap[left]);
    if (right >= 0 && right < h) printf("right key = %lld, ", heap[right]);
    cout << endl;
  }
}



Measured memory_bytes: 3224
#include<stdio.h>
int main()
{
  int r=0,i,j,n,d,list[100];
  for(i=0;i<100;i++){
    list[i]=0;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d);
    r++;
    for(j=0;j<n;j++){
      if(d==list[j]){
        r--;
        break;
      }
    }
    list[i]=d;
  }
  printf("%d\n",r);
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] res = helper(s);
        String ans = Integer.toString(res[0])+" "+Integer.toString(res[1]);
        System.out.print(ans);
    }
    static int[] helper(String s){
        int len = s.length();
        for(int i=0;i<26;i++){
            char cur = (char)(i+'a');
            int left=0;
            while(left<len-1){
                if(s.charAt(left)!=cur){
                    left++;
                    continue;
                }
                int right=left+1;
                if(s.charAt(right)==cur) return new int[]{left+1,right+1};
                right++;
                if(right<len&&s.charAt(right)==cur) return new int[]{left+1,right+1};
                left=right;
            }
        }
        return new int[]{-1,-1};
    }
}


Measured memory_bytes: 24124
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    int ans = 0, ct = 0;
    FOR(i, 1, N+1){
        int x = i, tmp = 0;
        while(x%2 == 0){
            x /= 2;
            tmp++;
        }
        if(ct <= tmp){
            ans = i;
            ct = tmp;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	sort(s.begin(),s.end()); sort(t.begin(),t.end(),greater<char>());
	cout<<(s<t?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,i,k,tmp;

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

    for(i=1;i<=k;i++){
        a/=2;
        b+=a;

        tmp=a;
        a=b;
        b=tmp;
    }

    if(k%2==1){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d",a,b);
    return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h = inp()
w = inp()
n = inp()
print(math.ceil(n/max(h,w)))

Measured memory_bytes: 64108
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    vector<int> arr(3, 0);
    for(auto& val: arr)
        cin >> val;
    cout << accumulate(arr.begin(), arr.end(), 0) - *max_element(arr.begin(), arr.end()) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

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

    int left = X - K + 1;
    int right = X + K - 1;
    for (int i = left; i <= right; i += 1) {
        if (i != left) {
            std::cout << " ";
        }
        std::cout << i;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long a, b, n;
    cin >> a >> b >> n;

    long long x = 0;
    long long ans = 0;

    if (b > n)
    {
        x = n;
        ans = a * x / b;
    }
    else
    {

        ans = (int)((double)a * (double)(b - 1) / (double)b);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int>a(N), b(N);
    vector<int>c(M), d(M);
    rep(i, N){
        cin >> a[i] >> b[i];
    }
    rep(i, M){
        cin >> c[i] >> d[i];
    }
    //int min = INF;
    rep(i, N){
        int min = INF;
        int min_n;
        rep(j, M){
            //int min = INF;
            int man = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(man < min){
                min = man;
                min_n = j + 1;
            }
        }
        cout << min_n << endl;
    }
    //cout << min << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int main()
{
	int n, k; cin >> n >> k;
	vector<bool> d(10, false);

	REP(i, k)
	{
		int x; cin >> x;
		d[x] = true;
	}

	for (int v = n; v < 100000; v++)
	{
		bool flag = true;
		int tmp = v;
		do
		{
			if (d[tmp % 10])
			{
				flag = false;
				break;
			}
			tmp /= 10;

		} while (tmp);
		
		if (flag)
		{
			cout << v << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)

using namespace std;

int main() {
   int p,q,r;
   cin >> p >> q >> r;
   cout << p+q+r-max({p,q,r}) << endl;
 }

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



int main() {
	string s;
	int n,k;
	cin >> n >> k;
	cin >> s;
	s[k-1] = s[k-1] - 'A' + 'a';

	cout << s << endl;

	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


// Two Color Card Game
int main(){
    int n, m;
    cin >>n;
    map<string, int> map{};
    rep(i,n){
        string s;
        cin >> s;
        if(map.count(s)){
            map[s] += 1;
        }else{
            map[s];
        }
    }
    cin >> m;
    rep(i,m){
        string s;
        cin >> s;
        if(map.count(s)){
            map[s] -= 1;
        }else{
            map[s];
        }
    }
    int ans=-1;
    for( pair<string, int> element : map){
        if(element.second > ans) ans = element.second;
    }
    if(ans < 0){
        cout << 0 << endl;
    }else{
        cout << ans+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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


const ll N = 100005;
const int mod = 1000000007;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);
ll n;





int main()
{
   string s;
   cin>>s;
   ll n = s.length();
   ll cnt=0;
   for(ll i=0,j=n-1;i<j;i++,j--){
      if(s[i]!=s[j]) cnt++;
   }
   cout<<cnt<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   return ((a%mod)+(b%mod)+mod)%mod;
}
ll modpower(ll a, ll n){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a);
      a = modmulti(a,a);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
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); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
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);}
template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num + 1 >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T &a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};



signed main(){
    int N; cin >> N ;
    vector<int>A(N);
    for(auto& e : A) cin >> e;
    auto sgt = segtree<int>(A,-INF,[](int a,int b){return max(a,b);});
    rep(i,N){
        cout << max(sgt.query(0,i),sgt.query(i+1,N)) << endl;
    }
}


Measured memory_bytes: 7296
n=input()
l=[]
m=[]
for i in range(n):
    x=raw_input().split()
    l.append(x[0])
    m.append(int(x[1]))
u=raw_input()
for i in range(n):
    if l[i]==u:
        print sum(m[i+1:])
        break

Measured memory_bytes: 2568