akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long a[s.size()+1];
	long long sum=0;
	long long p=1;
	for(int i=s.size()-1;i>=0;i--){
		sum=(s[i]-'0')*p+sum;
		p*=10;
		p%=2019;
		sum%=2019;
		a[i+1]=sum;
	}
	sort(a+1,a+s.size()+1);
	sum=1;
	long long ans=0;
	a[0]=0;
	for(int i=1;i<=s.size();i++){
		if(a[i]==a[i-1]){
			sum++;
		}else{
			ans+=sum*(sum-1)/2;
			sum=1;
		}
	}
	ans+=sum*(sum-1)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5328
/*  
    ┬┴┬┴┤(･_├┬┴┬┴ hiding from those WAs
*/

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

void ngk(){
    int a, b;
    cin >> a >> b;
    for(int i=1;i<=1000000;i++){
    	int x = i*8/100;
    	int y = i*10 / 100;
    	if (x == a && y == b){
    		cout << i;
    		return;
    	}
    }
    cout << -1;
}

int main(int argc, char *argv[]){
    iostream::sync_with_stdio(0);
    int test = 1;
    while(test--){
        ngk();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,n,count,ans;
  scanf("%d",&n);
  
  for(i=1,ans=0;i<=n;i+=2){
    for(j=1,count=0;j<=i;j+=2){
      if( i % j == 0 ) count++;
    }
    if(count == 8) ans ++;
  }
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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


#define REP(i, n) for(ll i = 0; i < n; i++)


























int main(){
    ll d, t ,s;
    cin >> d >> t >> s;
    cout << ((s * t >= d)? "Yes" : "No") << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll dp[60][2];
int main(){
  memset(dp,-1,sizeof(dp));
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  dp[0][0]=0;
  rep(i,50)rep(j,2){
    if(dp[i][j]==-1) continue;
    ll num=0;
    ll mask=1LL<<(50-i-1);
    rep(r,n){
      if(a[r]&mask) num++;
    }
    ll cost0=mask*num;
    ll cost1=mask*(n-num);
    if(j==0){
      if(k&mask){
        dp[i+1][0]=max(dp[i+1][0],dp[i][j]+cost1);
        dp[i+1][1]=max(dp[i+1][1],dp[i][j]+cost0);
      }
      else{
        dp[i+1][0]=max(dp[i+1][0],dp[i][j]+cost0);
      }
    }
    if(j==1){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]+max(cost1,cost0));
    }
  }
  COUT(max(dp[50][0],dp[50][1]));
}


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

int main() {
  string s;
  cin >> s;
  int r = 0, b = 0;
  int i;
  for (i = 0; i < s.length(); i++) {
    (s.at(i) == '0' ? r++ : b++);
  }
  cout << min(r, b) * 2 << endl;
  return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

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

void print() {
    cout << endl;
}

// template <class Head, class... Tail>
// void print(Head&& head, Tail&&... tail) {
//     cout << head;
//     if (sizeof...(tail) != 0) cout << " ";
//     print(forward<Tail>(tail)...);
// }

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i,k-1)cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    cout << p.first << " " << p.second << "\n";
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<ll> h(n+1);
    rep(i,n) cin >> h[i + 1];
    h[0] = INF;
    vector<ll> dp(n + 1, INF);
    dp[0] = dp[1] = 0;
    for(int i = 2; i < n + 1; i++){
        reps(j,2)chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
    // print(dp);
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <memory.h>

using namespace std;

long long gcd(long long a, long long b) {
    while (b > 0) {
        long long r = a % b;
        a = b;
        b = r;
    }
    return a;
}


int main() {
    
    int n;
    cin >> n;
    long long cur1 = 0;
    long long cur2 = 0;
    for (int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        long long int g = gcd(a, b);
        a /= g;
        b /= g;
        if (cur1 == 0) {
            cur1 = a;
            cur2 = b;
            continue;
        }
        long long int i1 = (cur1 + a - 1 ) / a;
        long long int i2 = max(i1, (cur2 + b - 1) / b);
        cur1 = i2 * a;
        cur2 = i2 * b;
    }

    cout << cur1 + cur2 << endl;

    
    return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int M = 12;

struct Perm {
	vector<int> a;

	Perm() : a() {}
	Perm(int z) {
		a.resize(z);
		for (int i = 0; i < z; i++)
			a[i] = i;
	}
	Perm(vector<int> _a) : a(_a) {}

	Perm getRev() {
		vector<int> b;
		b.resize(a.size());
		for (int i = 0; i < (int)a.size(); i++)
			b[a[i]] = i;
		return Perm(b);
	}
	Perm operator * (const Perm &P) {
		vector<int> b;
		b.resize(a.size());
		for (int i = 0; i < (int)a.size(); i++)
			b[i] = P.a[a[i]];
		return Perm(b);
	}
	Perm getPow(int k) {
		vector<int> b;
		vector<bool> used;
		int n = (int)a.size();
		b.resize(n);
		used.resize(n, false);
		for (int i = 0; i < n; i++) {
			if (used[i]) continue;
			vector<int> cur;
			int v = i;
			while(!used[v]) {
				cur.push_back(v);
				used[v] = 1;
				v = a[v];
			}
			int L = (int)cur.size();
			for (int j = 0; j < L; j++)
				b[cur[j]] = cur[(j + k) % L];
		}
		return Perm(b);
	}

	void print() {
		for (int x : a)
			printf("%d ", x + 1);
		printf("\n");
	}
};

Perm z[M];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n, k;
	scanf("%d%d", &n, &k);
	k--;
	vector<int> a;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	z[0] = Perm(a);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	z[1] = Perm(a);
	for (int i = 2; i < M; i++)
		z[i] = z[i - 2].getRev() * z[i - 1];

	if (k < M) {
		z[k].print();
	} else {
		int p = k % 6;
		if (p < 3) p += 6;
		k = (k - p) / 6;
		Perm P = z[1].getRev() * z[0] * z[1] * z[0].getRev();
		P = P.getPow(k);
		P = P * z[p] * P.getRev();
		P.print();
	}

	return 0;
}


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

using namespace std;


#define MAXN 200001
const double pi = acos(-1);

int n;

int lis(vector<pair<int, int>> &p) {
  int n = p.size();
  int res = 0, dp[n+1];
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = -1e9;
  for (int i = 0; i < n; ++i) {
    int v = lower_bound(dp, dp+n+1, p[i].second) - dp;
    res = max(res, v);
    dp[v] = min(dp[v], p[i].second); // vrijednost najmanjeg elementa koji daje niz duljine v
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(15);
  cout << fixed;
  vector <pair<int, int>> p;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  if (x1>x2) {
    swap(x1, x2);
    swap(y1, y2);
  }
  int py = y1<y2 ? 1 : -1;
  y1 *= py;
  y2 *= py;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    y *= py;
    if (x>=x1 && x<=x2 && y>=y1 && y<=y2) {
      p.push_back({x, y});
    }
  }
  sort(p.begin(), p.end());
  int res = lis(p);
  double ans = (double)100*((x2-x1)+(y2-y1)) - res*(20-5*pi);
  if (res==min(x2-x1, y2-y1)+1) ans += 5*pi;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2800
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
c = a[p-1]
#print(a)

b = 0
d = 0
ans = 0
for i in range(n):
  if i < p-1:
    ans += 1
    continue
  if a[i] + m < c:
    continue
  now = a[i]
  vv = v - (n-i) - (p-1)
  #print(i,a[i],vv)
  if vv <= 0 or d * (now+m) >= b + vv * m:
    ans += 1
  b += now
  d += 1
print(ans)

Measured memory_bytes: 62576
from functools import reduce

n,a,b = map(lambda x:int(x),input().split(" "))

ans = 0
for ni in range(a,n+1):
    add_each_dig = int(reduce(lambda x, y: int(x) + int(y), str(ni) ))
    if a <= add_each_dig and add_each_dig <= b:
        ans += ni

print(ans)

Measured memory_bytes: 9624
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807/2;
const int MOD = 1000000007;
const int N_MAX = 100;
const int W_MAX = 300;

int main() {
  ll N, W; cin >> N >> W;
  ll w[N], v[N]; rep(i,N) cin >> w[i] >> v[i];;

  vector<vector<ll>> x(4, vector<ll>());
  ll dw = w[0];
  rep(i, N) x[w[i]-dw].push_back(v[i]);
  rep(i, 4) {
    sort(x[i].begin(), x[i].end(), greater<int>());
    for(int j=1; j<x[i].size(); j++) x[i][j] += x[i][j-1];
    x[i].insert(x[i].begin(), 0);
  }


  ll result = 0;
  rep(w0, x[0].size()) rep(w1, x[1].size())
  rep(w2, x[2].size()) rep(w3, x[3].size()) {
    ll w_sum = dw*w0 + (dw+1)*w1 + (dw+2)*w2 + (dw+3)*w3;
    ll v_sum = x[0][w0] + x[1][w1] + x[2][w2] + x[3][w3];
    if (w_sum <= W) result = max(result, v_sum);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define li long int
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y>
#define qq(x) queue<x>
#define pqq(x) priority_queue<x> 
#define search(x,y,z) binary_search(x,y,z)
#define pi(x,y) pair<x,y>
#define forf(i,x,y) for(ll i=x;i<y;i++)
#define forl(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pob pop_back
#define pp push
#define po pop
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define vp(x,y) vec(pi(x,y) )
#define vv(x) vector<vector<x> >
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{
	fastio;
	/*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif*/
	
	int k;
	cin>>k;
	
	ll ans,a,b;
	a=k/2;
	b=k-a;
	ans=a*b;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Sugoroku {
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        string[] A = Console.ReadLine().Split(' ');
        // This program needs to count the continuous '1' in A[].
        // And the maximum number of the count value of continuous '1' will lead an answer.
        int maxCount = 0;
        int currentCount = 0;
        for (int i=0;i<A.Length;i++)
        {
            while (i<A.Length && A[i] == "1")
            {
                currentCount++;
                i++;
            }
            if (currentCount > 0)
            {
                if (currentCount > maxCount)
                {
                    maxCount = currentCount;
                }
                currentCount = 0;
            }
        }
        Console.WriteLine(maxCount+1);
    }
}



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

using namespace std;

template <class T> inline bool chmin(T &a, T b) { /* {{{ */
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<int> dp(H + 1, 1e9);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= H; j++) {
      chmin(dp[min(j + A[i], H)], dp[j] + B[i]);
    }
  }
  cout << dp[H] << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

#define INF 1 << 30

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)

using namespace std;

int main()
{
  int n, W; cin >> n >> W;
  vector<int> v(n);
  vector<int> w(n);
  REP(i,n) cin >> v[i] >> w[i];
  vector<int> dp(10001,0);
  REP(i,n) DOWN(j, W, w[i])
    dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
  cout << *max_element(dp.begin(),dp.begin()+W+1) << endl;
}

Measured memory_bytes: 3092
a,b,c = map(int,input().split())

if a<b and a<c:
	print(a,"",end="")
	if b<c:
		print(b,c)
	else:
		print(c,b)
elif b<c:
	print(b,"",end="")
	if a<c:
		print(a,c)
	else:
		print(c,a)
else:
	print(c,"",end="")
	if a<b:
		print(a,b)
	else:
		print(b,a)



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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll dp[1005],i,j;
    rep(i,0,1001){
        dp[i] = pow(i,5);
    }
    ll n,l1,l2;
    cin >> n;
    rep(i,0,1001){
        rep(j,0,i){
            if(dp[i] - dp[j] == n){
                cout << i << " " << j << nl;
                return;
            }
        }
    }
    rep(i,0,1001){
        rep(j,i,1001){
            if(dp[i] + dp[j] == n){
                cout << j << " " << -i << nl;
                return; 
            }
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
   // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 4120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void Grouping2() {
	int N;
	cin >> N;
	cout << (N / 3) << endl;
}
int main() {
	Grouping2();
	return 0;
}

Measured memory_bytes: 256
import random
import time

# 処理前の時刻
t1 = time.time() 

def f_last(d, i, lt):
  idx = []
  if i in lt[0:d]:
    idx = [j+1 for j, x in enumerate(lt[0:d]) if x == i]
  else:
    idx.append(0)
  return idx[-1]

d = int(input())
lc = list(map(int, input().split()))
ls = []
for _ in range(d):
  ls.append(list(map(int, input().split())))

v_max = -(10**5)
lt_max = [1]*d
while 1:
  lt = [random.randint(1, len(lc)) for i in range(d)]
  v = 0
  for dd in range(1, d+1):
    v_d = 0
    for i in range(len(lc)):
      v_d += lc[i]*(dd-f_last(dd, i+1, lt))
    v = v + ls[dd-1][lt[dd-1]-1] - v_d
  if v_max < v:
    v_max = v
    lt_max = lt[:]
  t2 = time.time()
  if t2-t1 > 1.8:
    break

for t in lt_max:
  print(t)

Measured memory_bytes: 9748
import math

N,X,M = map(int, input().split())
MAP = [-1]*(M+1)
TMAP = [0]*(M+1)
ans = 0

for i in range(N):
    if (X%M!=0):
        X = X%M
        ans += X
        if MAP[X]==-1:
            MAP[X] = i
            TMAP[X] = ans
        else:
            loopcnt = i-MAP[X]
            loopsum = ans-TMAP[X]
            ans += (((N-MAP[X])//loopcnt)-1)*loopsum
            jmax = N-(MAP[X]+((N-MAP[X])//loopcnt)*loopcnt)
            ans -= X
            for j in range(jmax):
                X = X%M
                ans += X
                X = X**2
            X=M
        X = X**2
    else:
        break

print(ans)


Measured memory_bytes: 67040
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n , k ; 
	cin >> n >> k ; 
	if ( k == 1 ) {
		cout << 0 << endl;
	}
	else cout << n-k << endl;
    return 0 ;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    vector<vector<int>>board(h, vector<int>(w)),ans(d);
    rep(i, 0, h)rep(j, 0, w)cin >> board[i][j];
    map<int, pii>mp;
    rep(i, 0, h)rep(j, 0, w)mp[board[i][j]] = pii(i+1, j+1);
    rep(i, 0, d){
        int temp = i, dist = 0;
        while(temp<=h*w){
            ans[i].push_back(dist);
            dist += abs(mp[temp+d].first-mp[temp].first)
            +abs(mp[temp+d].second-mp[temp].second);
            temp += d;
        }
    }
    int q;
    cin >> q;
    vector<int>l(q),r(q);
    rep(i, 0, q)cin >> l[i] >> r[i];
    rep(i, 0, q){
        int p = l[i]%d;
        //rep(j, 0, ans[p].size())cout << ans[p][j] << endl;
        cout << ans[p][r[i]/d]-ans[p][l[i]/d] << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int main() {
  ll a, b, c, d;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

  // printf("max(c, d): %d\n", max(c, d));

  ll ans = 0;

  ans = max(a, b) * max(c, d);

  ans = max(ans, min(a, b) * max(c, d));

  ans = max(ans, max(a, b) * min(c, d));

  ans = max(ans, min(a, b) * min(c, d));

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1736
from math import sin,cos,pi,sqrt
a,b,C = map(int,input().split())
h = b * sin(pi*C/180)
S = a  * h * 1/2
L = sqrt(a**2+b**2-2*a*b*cos(pi*C/180)) + a + b
print(S)
print(L)
print(h)

Measured memory_bytes: 7928
#include<cstdio>
#include<map>
#include<algorithm>
#include<iostream>
using namespace std;
map<string,int>mp;
string a[200005];
int n,maxn;
int main(){
	cin>>n;
	for (register int i=1;i<=n;++i){
		cin>>a[i];
		++mp[a[i]];
	}
	sort (a+1,a+1+n);
	for (register int i=1;i<=n;++i){
		maxn=max(maxn,mp[a[i]]);
	}
	for (register int i=1;i<=n;++i){
		if (mp[a[i]]==maxn){
			cout<<a[i]<<endl;
			mp[a[i]]=-1;
		}
	}
	return 0;
}

Measured memory_bytes: 27136
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
tate=[False]*h
yoko=[False]*w
for i in range(h):
    for j in range(w):
        if l[i][j]=="#":
            tate[i]=True
            yoko[j]=True
for i in range(h):
    if tate[i]:
        for j in range(w):
            if yoko[j]:
                print(l[i][j],end="")
        print()

Measured memory_bytes: 9332
#include<stdio.h>

int dp[50];


int fibonacci(int n){
  if(n == 0||n == 1)
    return dp[n]=1;
  if(dp[n]!= -1) return dp[n];
  return dp[n]=fibonacci(n-2) + fibonacci(n-1);
}


int main(){
  int n,i;

  for(i = 0;i<50;i++) dp[i] = -1;




  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}



Measured memory_bytes: 1996
import java.util.Stack;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		Stack<Integer> a = new Stack<Integer>();
		Stack<Integer> b = new Stack<Integer>();
		boolean yes_no;
		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			a.push(0); b.push(0);
			yes_no = true;
			for (int j = 0; j < 10; j++) {
				int num = Integer.parseInt(s.split(" ")[j]);
				int	subA = num - a.peek(); 
				int subB = num - b.peek();
				if(subA < 0 && subB < 0){
					yes_no = false;
					break;
				}
				else if (subA > 0 && subB > 0) {
					if(subA <= subB)
						a.push(num);
					else
						b.push(num);
				}
				else if	(subB >= subA)
					b.push(num);
				else
					a.push(num);
			}
			if(yes_no) System.out.println("YES");
			else 	   System.out.println("NO");
		}
	}
}

Measured memory_bytes: 9736
s = list(input())

ans = [0] * len(s)
aft = False
preL, preR = 0, 0
left = 0
for i in range(1, len(s)):
    if s[i-1] == 'R' and s[i] == 'L':
        ans[i-1] += (i-1-left) // 2 + 1
        ans[i] += (i-left) // 2 + 1
        preL, preR = i-1, i
        left = i
        aft = True
    else:
        if aft:
            if s[i] == 'R':
                ans[preL] += (i-left) // 2
                ans[preR] += (i-1-left) // 2
                left = i
                aft = False
            else:
                pass

ans[preL] += (len(s)-left) // 2
ans[preR] += (len(s)-1-left) // 2

for i in ans:
    print(i, end=' ')
print()

Measured memory_bytes: 5552
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad.State (State, evalState, gets, modify)
import Data.Map.Strict (Map, lookup, insert, empty)

main :: IO ()
main = readLine >>= print . solve 

-- | 
-- >>> solve [1,3,2]
-- 1
-- >>> solve [1,3,1]
-- 2
-- >>> solve [2,3,3]
-- 1
-- >>> solve [2,3,1]
-- 5
-- >>> solve [7,1,1]
-- 1
-- >>> solve [15,8,5]
-- 437760187
solve :: [Int] -> Int 
solve [h, w, k] = run calc (1, 1)
    where
        calc recf (i, j)
            | j < 1 || j > w = return 0
            | i == h && j == k = return $ mul (cmb $ w - k - 1) (cmb $ j - 2)
            | i == h && j == k - 1 = return $ mul (cmb $ w - j - 2) (cmb $ j - 2)
            | i == h && j == k + 1 = return $ mul (cmb $ w - j - 1) (cmb $ j - 3)
            | i == h = return 0
            | otherwise = sumM [prodf (w - j - 1) (j - 2) <$> recf (i + 1, j), prodf (w - j - 2) (j - 2) <$> recf (i + 1, j + 1), prodf (w - j - 1) (j - 3) <$> recf (i + 1, j - 1)]

        sumM = foldl' (\acc x -> add <$> acc <*> x) (return 0)
        prodf x y v = mul (mul (cmb x) (cmb y)) v

        cmb x
            | x < 1 = 1
            | x == 1 = 2
            | x == 2 = 3
            | otherwise = cmb (x - 1) + cmb (x - 2)

type Memoizer a b = a -> State (Map a b) b

run :: (Ord a) => (Memoizer a b -> Memoizer a b) -> a -> b
run f = flip evalState empty . memoizeFix f

memoizeFix :: (Ord a) => (Memoizer a b -> Memoizer a b) -> Memoizer a b
memoizeFix f x = gets (Data.Map.Strict.lookup x) >>= maybe (f (memoizeFix f) x >>= ((<$) <*> (modify . Data.Map.Strict.insert x))) return

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

add :: Int -> Int -> Int
add x y = val $ x + y

mul :: Int -> Int -> Int
mul x y = val $ x * y

inv :: Int -> Int
inv x = pow x $ modVal - 2

pow :: Int -> Int -> Int
pow b e
    | e == 0 = 1
    | odd e = mul b . pow b $ e - 1
    | otherwise = mul v v
    where
        v = pow b $ e `div` 2

val :: Int -> Int
val = (`mod` modVal)

modVal :: Int
modVal = 10 ^ 9 + 7

primes :: [Int]
primes = build [2..]
    where
        build (x : xs) = x : build (filter (\n -> n `mod` x /= 0) xs)
        
isPrime :: Int -> Bool
isPrime n = check primes
    where
        check (x : xs)
            | x == n = True
            | x > n = False
            | otherwise = check xs

Measured memory_bytes: 1276
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<int> ans(n+1, 0);
    IFOR(x, 1, 100){
        IFOR(y, 1, 100){
            IFOR(z, 1, 100){
                int t = x*x+y*y+z*z+x*y+y*z+z*x;
                if(t <= n) ans[t]++;
            }
        }
    }
    IFOR(i, 1, n)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3216
/*
 *
 *	Author: r3gz3n
 *	Description: 
 *	Difficulty: 
 *
 */

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y); }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(int argc, char* argv[])
{
	if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
	if(argc == 3) freopen(argv[2], "w", stdout);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i, 0, s.length(), 1)
	{
		if(s[i] == ',') cout << ' ';
		else cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
typedef long long LL;
const double INF = 1e9;
int main(){
  int N,K;
  cin>>N>>K;
  double sum=0;
  int i,j;
  FOR(i,1,N+1){
    REP(j,10000){
      if(i*pow(2,j)>=K){
        sum+=pow(0.5,j);
        break;
      }
    }
  }
  sum/=N;
  cout<<setprecision(12)<<sum<<endl;
  }

Measured memory_bytes: 256
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse);
            var asum = a.Sum();
            var imax = 1 << n;
            var res = int.MaxValue;
            for (int i = 0; i < imax; i++)
            {
                var t = 0;
                for (int j = 0; j < n; j++)
                    if (((i >> j) & 1) == 1) t += a[j];
                res = Math.Min(res, Math.Abs(2 * t - asum));
            }
            Console.WriteLine(res);
        }
    }
}


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

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

  ll ans;
  if((A - B) % 2 == 0)
    ans = (B - A) / 2;
  else if(A - 1 < N - B)
    ans = A + (B - A - 1) / 2;
  else
    ans = N - B + 1 + (B - A - 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self,n):
        # リンク情報　子→親の番号　親(根)→負のサイズ
        self.d=[-1 for i in range(n)]
    
    def find(self,x):
        if(self.d[x]<0):return x
        self.d[x]=self.find(self.d[x])
        return self.d[x]

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):return False
        if(self.d[x]>self.d[y]):x,y=y,x
        self.d[x]+=self.d[y]
        self.d[y]=x
        return True

    def same(self,x,y):return self.find(x)==self.find(y)
    def size(self,x):return -1*self.d[self.find(x)]

n,m,k=map(int,input().split())
uf=UnionFind(n)
deg=[0 for i in range(n)]
to=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    uf.unite(a,b)
    deg[a]+=1
    deg[b]+=1

for i in range(k):
    a,b=map(int,input().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)

for i in range(n):
    ans=uf.size(i)-1-deg[i]
    for j in to[i]:
        if(uf.same(i,j)):ans-=1
    print(ans,end=" ")

Measured memory_bytes: 26280
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] x={scan.nextInt(),scan.nextInt(),scan.nextInt()};
        if(x[0]>x[1]){
            x[0]^=x[1];
            x[1]^=x[0];
            x[0]^=x[1];
        }
        if(x[1]>x[2]){
            x[1]^=x[2];
            x[2]^=x[1];
            x[1]^=x[2];
        }
        if(x[0]>x[1]){
            x[0]^=x[1];
            x[1]^=x[0];
            x[0]^=x[1];
        }
        System.out.println(x[0]+" "+x[1]+" "+x[2]);
    }
}


Measured memory_bytes: 26096
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    cout << (N + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    group = dict()
    ls = set()
    for i in range(n):
        g,s = input().split(':')
        group[g] = set(s[:-1].split(','))
        if i == 0:
            ls.add(g)
    ans = set()
    while len(ls) > 0:
        s = ls.pop()
        if s in group.keys():
            ls |= group[s]
        else:
            ans.add(s)
    print(len(ans))
        



Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int X, Y; cin >> X >> Y;
    bool ans = false;
    REP(i, X + 1){
        int j = X - i;
        if(2 * i + 4 * j == Y) ans = true;
    }
    Ans(ans, "Yes", "No");

    return 0;
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

ll n, a, b, mx, mn;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> a >> b;
	mx = a + (n - 1) * b;
	mn = (n - 1) * a + b;
	if (a == b && n == 1)
		cout << 1 << endl;
	else if (b < a || n == 1)
		cout << 0 << endl;
	else
		cout << mx - mn + 1 << endl;
}

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

int main() {
  string s;
  cin >> s;
  int a,b,c;
  a = 0;
  b = 0;
  c = 0;
  for (int i = 0;i<3;i++) {
    if (s.at(i) == 'a') a++;
    else if (s.at(i) == 'b') b++;
    else if (s.at(i) == 'c') c++;
  }
  if ((a==1) && (b==1) &&(c==1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

    vector<set<ll>> v(N);
    rep(i,M) {
        ll t1, t2; cin >> t1 >> t2;
        t1--;
        t2--;
        v[t1].insert(t2);
        v[t2].insert(t1);    
    }
#if 0
    rep(i,N) {
        for (auto j : v[i]) {
            cout << j << " ";
        }
        cout << endl;
    }
#endif
    vector<int> dist(N, -1);
    vector<int> m(N, -1);
    for (int j = 0; j < N; ++j) {
        if (m[j] == 1) continue;        
        queue<ll> que;
        que.push(j);
        m[j] = 1;
        int num = 0;
        while (1) {
            if (que.empty()) break;
            ll f = que.front();
            num++;
            que.pop();
            for (auto i : v[f]) {
                if (m[i] != 1) {
                    que.push(i);
                    m[i] = 1;
                }
            }
        }
        dist[j] = num;
    }
    sort(dist.begin(), dist.end(), greater<ll>());
    cout << dist[0] << endl;

}


Measured memory_bytes: 33392
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int r, g;
	cin >> r >> g;
	cout << 2*g - r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;


int main() {
	int n;
	while(cin >> n, n) {
		vector< vector<int> > f;
		REP(i, n) {
			int m; cin >> m;
			vector<int> hoge;
			REP(j, m) {
				int in; cin >> in;
				hoge.push_back(in);
			}
			sort(hoge.begin(), hoge.end());
			f.push_back(hoge);
		}
		int k; cin >> k;
		int cnt, ans = 0;
		vector<int> l;
		REP(i, k) {
			int in; cin >> in;
			l.push_back(in);
		}
		sort(l.begin(), l.end());

//		REP(i, n) REP(j, f[i].size()) cout << i << ' ' << j << ' ' << f[i][j] << endl;
		REP(i, f.size()) {
			cnt = 0;
			REP(j, f[i].size()) {
				if(f[i][j] == l[cnt])
					cnt++; 
				if(cnt == k) {
					if(!ans) ans = i+1;
					else ans = -1;
					break;
				}
			}
		}
		if(ans == 0) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    string S; cin >> S;
    string ans = "AC";
    if (S.at(0) != 'A') {
        ans = "WA";
    }
    int cnt = 0;
    for (int i = 2; i < S.size() - 1; i++) {
        if (S.at(i) == 'C') {
            cnt++;
        }
    }
    if (cnt != 1) {
        ans = "WA";
    }
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) != 'A' && S.at(i) != 'C') {
            if (S.at(i) <= 'Z') {
                ans = "WA";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

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

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

template <typename T> inline string toString(const T &a){ostringstream oss; oss<<a; return oss.str();};

int main(){
    int n; cin>>n;
    vector<int> t(n), v(n);
    for(int i=0; i<n; i++) cin>>t[i];
    for(int i=0; i<n; i++) cin>>v[i];

    vector<int> sumt(n+10, 0);
    for(int i=1; i<=n; i++){
        sumt[i]=sumt[i-1]+t[i-1];
    }

    vector<double> maxv(40010, 0);
    int cnt=0;
    for(int i=1; i<sumt[n]*2; i++){
        if(2*sumt[cnt]<i && i<2*sumt[cnt+1]){
            maxv[i]=v[cnt];
        }
        else if(i==2*sumt[cnt+1]){
            maxv[i]=min(v[cnt], v[cnt+1]);
            cnt++;
        }
    }

    /*
    for(int i=0; i<=sumt[n]*2; i++){
        cout << i << " " << maxv[i] << endl;
    }*/

    for(int i=1; i<=sumt[n]*2; i++){
        maxv[i]=min(maxv[i], maxv[i-1]+0.5);
    }

    for(int i=sumt[n]*2-1; i>=0; i--){
        maxv[i]=min(maxv[i], maxv[i+1]+0.5);
    }

    /*
    for(int i=0; i<=sumt[n]*2; i++){
        cout << i << " " << maxv[i] << endl;
    }*/

    double ans=0;
    for(int i=0; i<sumt[n]*2; i++){
        ans+=1.*(maxv[i]+maxv[i+1])/4;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n % 2) {
        cout << 0 << endl;
    } else {
        ll now = 10;
        ll ans = 0;
        while(now <= n) {
            ans += n / now;
            now *= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int ans,num=-1,tmp,cnt;
	loop(i,1,n+1){
		tmp=i;
		cnt=0;
		while(tmp%2==0){
			tmp/=2;
			cnt++;
		}
		if(cnt>num){
			ans=i;
			num=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int x;
    
    scanf("%d", &x);
    
    if (x<30) {
        printf("No");
    } else {
        printf("Yes");
    }
    
    return 0;
}


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

int main(){
   int n,m;
   ll ans=0,count=0;
   cin >> n >> m;
   vector<pair<ll,ll>> a(n);
   rep(i,n){
       ll x,y;
       cin >> x >> y;
       a[i]=make_pair(x,y);
   }
   sort(a.begin(),a.end());
   rep(i,n){
       count+=a[i].second;
       if(count>=m){
           count-=a[i].second;
           ans+=a[i].first*(m-count);
           break;
       }else{
           ans+=a[i].first*a[i].second;
       }
   }
   cout << ans;
}

Measured memory_bytes: 1792
/*  Kadai4_2
    saitomo   */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
//10^-9以下の誤差になるよう十分に PIを定義

int main(void){
    double len_h,len_m,hour,min;
    //左から順に時針の長さ、分針の長さ、時、分
    scanf("%lf%lf%lf%lf",&len_h,&len_m,&hour,&min);
    double angle,ans;
    //時針と分針の間の角度、答え
    angle=(0.5*(60*hour+min)-6*min)*PI/180;
    /*時針は1分に0.5度、分針は1分に6度動くことを利用し、差をとってからradに直している。
  　この際、cos(x)=cos(-x)より、正負は考えなくて良い*/
    ans=sqrt(len_h*len_h+len_m*len_m-2*len_h*len_m*cos(angle));
    //余弦定理の利用
    printf("%.10lf\n",ans);    
    //10^-9まで出す
    return 0;
}


Measured memory_bytes: 2540