akhauriyash/Code-Regression huggingface dataset:
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << '\n';

    return 0;
}



Measured memory_bytes: 256
#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>;
bool isPrime (int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	int x; 
	cin >> x;
	if (x == 2) {
		cout << 2 << endl;
		return 0;
	}
	while (!isPrime(x)) {
		x += 1;
	}
	cout << x << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];
    ll sum = 0;
    for(int d = 0; d < 60; d++) {
        ll n1 = 0;
        ll n0 = 0;
        for(int i = 0; i < N; i++) {
            if((A[i] >> d) & 1) n1++;
            else n0++;
        }
        ll tmp = (1ll << d) % 1000000007;
        ll n = n0 * n1 % 1000000007;
        tmp = tmp * n % 1000000007;
        sum = (sum + tmp) % 1000000007;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll c[100][100];
main(){
    ll n,m,k,tmp=0,ans=0;
    cin>>n;
    rep(i,1,n+1){
        string s=to_string(i);
        c[s[0]-'0'][i%10]++;
        
    }
    rep(i,0,10){
      rep(j,0,10){
        ans+=c[i][j]*c[j][i];
      }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<sstream>

using namespace std;


int main(void) {

  int n, m, p;
  while( cin >> n >> m >> p ){
    if( n == 0 ) break;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin >> x[i];

    int sum = accumulate(x.begin(), x.end(), 0);
    if( x[m-1] == 0 ) cout << 0 << endl;
    else cout << sum * (100-p) / x[m-1] << endl;

  }

  return 0;
}










//

Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main()
{
	int A[100], N, M, i, count = 0;
	float sum = 0;
	cin >> N >> M;
	for (i = 0;i < N;++i)
	{
		cin >> A[i];
		sum += A[i];
	}
	sum /= (4 * M);
	for (i = 0;i < N;++i)
	{
		if (A[i] >= sum)
			++count;
	}
	if (count >= M)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

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

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = null;
    while (!(line = br.readLine()).equals("0 0")) {
      String[] str = line.split(" ", 2);
      int n = Integer.parseInt(str[0]);
      int s = Integer.parseInt(str[1]);
      System.out.println(dfs(n, s, 0));
    }
  }

  private static int dfs(int n, int s, int min) {
    if (n == 0) {
      return s == 0 ? 1 : 0;
    }
    int ret = 0;
    for (int i = min; i <= Math.min(9, s); i++) {
      ret += dfs(n - 1, s - i, i + 1);
    }
    return ret;
  }
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 100010 };

vector<ii> adj[MAX];

void dfs(ll u, int color, vector<int>& cs)
{
    if (cs[u] > -1)
        return;

    cs[u] = color;

    for (auto p : adj[u])
    {
        auto v = p.first, w = p.second;
//cout << "u = " << u << ", v = " << v << ", w = " << w << endl;
        if (w % 2 == 0)
            dfs(v, color, cs);
        else
            dfs(v, 1 - color, cs);
    }
}

vector<int> solve(int N, ll u)
{
    vector<int> cs(N + 1, -1);
    
//cout << "u = " << u << endl;
    dfs(u, 0, cs);

    return cs;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    ll u, v, w;

    for (int i = 0; i < N; ++i)
    {
        cin >> u >> v >> w;

        adj[u].push_back(ii(v, w));
        adj[v].push_back(ii(u, w));
    }

    auto ans = solve(N, u);

    for (int i = 1; i <= N; ++i)
        cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 11904
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

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

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug1(a,n)  loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef deque<ll> dll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 998244353;	//1000000007;
const ld pi =  3.1415926535; //acos((ld) - 1);

void solve()
{
	ll k;	cin >> k;
	loop(i, 0, k)		cout << "ACL";
}

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


	// test
	solve();

	return 0;
}

Measured memory_bytes: 3540
#include<stdio.h>
 
int main(){
  int a,e,k,dum;
  scanf("%d",&a);
  for(int i=0;i<3;i++){
    scanf("%d",&dum);
  }
  scanf("%d",&e);
  scanf("%d",&k);
  if((e-a)<=k){
    	printf("Yay!");
  }else{
    printf(":(");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	priority_queue<int>line;
	int n,a,x;
	cin >> n >> a;
	for(int i = 1;i <= n;i ++)
	{
		cin >> x;
		line.push(x);
	}
	int tot = 0;
	while(a > 0)
	{
		tot += line.top();
		line.pop();
		a --;
	}
	cout << tot;
}

Measured memory_bytes: 256
#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& x:c){cout<<x<<' ';}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)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	string S;
	while(cin>>S){
		auto SS = split_naive(S,',');
		double X[4],Y[4];
		for(int i=0;i<4;i++){
			sscanf(SS[2*i].c_str(),"%lf",&X[i]);
			sscanf(SS[2*i+1].c_str(),"%lf",&Y[i]);
		}

		array<double,4> outer;
		REP(i,4){
			double VX[2],VY[2],VN[2];
			VX[0] = X[(i+1)%4]-X[i];
			VY[0] = Y[(i+1)%4]-Y[i];
			VN[0] = hypot(VX[0],VY[0]);
			VX[0] /= VN[0];
			VY[0] /= VN[0];

			VX[1] = X[(i+2)%4]-X[(i+1)%4];
			VY[1] = Y[(i+2)%4]-Y[(i+1)%4];
			VN[1] = hypot(VX[1],VY[1]);
			VX[1] /= VN[1];
			VY[1] /= VN[1];

			outer[i] = VX[0]*VY[1]-VY[0]*VX[1];
		}
		if(all_of(ALL(outer),[](double c){return c>0;}) || all_of(ALL(outer),[](double c){return c<0;})){
			out("YES");
		}
		else out("NO");
	}
	return 0;
}


Measured memory_bytes: 3224
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <stack>
#include <vector>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <bitset>
#include <map>
#define INF 0x3f3f3f3f3f3f3fLL
#define ULL unsigned long long
#define LL long long
#define N 100100
#define eps 10e-9
#define MOD 100000000
#define mem(a,n) memset(a,n,sizeof(a))
#define fread freopen("in.txt","r",stdin)
#define fwrite freopen("out.txt","w",stdout)
using namespace std;
const double PI=acos(-1.0);
LL num[N*2];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	LL sum=0,sumtil=0,ans=INF;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>num[i];
		sum+=num[i];
	}
	for(int i=0;i<n-1;++i){
		sumtil+=num[i];
		ans=min(ans,abs(sum-2*sumtil));
		//cout<<abs(sum-2*sumtil)<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll L, R; cin >> L >> R;
  if (R - L > 2019) {cout << 0 << endl; return 0;}
  else {
    ll ans = INF;
    for (ll i = L; i <= R; ++i){
      for (ll j = i + 1; j <= R; ++j){
        ans = min(ans, (i * j) % 2019);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14);
}

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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	rep(i, k) {
		if (a >= b) b *= 2;
		else if (b >= c) c *= 2;
	}
	if (a < b && b < c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
 
int main(){
int a,b;
while(true){
scanf("%d %d",&a,&b);
if(a==0) break;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
#define ll long  long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define FOR(i, a, b)    for(int i=a; i<b; i++)
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    fastio
    
    ll t,i,j,x;
	ll n;
	
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	
    return 0 ;
}

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

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

int main(){
   int n, d;
   cin >> n >> d;

   int p = 1;
   int res = 0;
   while(p <= n){
       res++;
       p += d+1;
       p += d;
   }
   cout << res;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;
int solve(){
    long long a,b,k;
    cin>>a>>b>>k;
    vector<long long> re(2,0ll);
    re[0] = max(0ll,a-k);
    if(k>a) re[1] = max(0ll,b+a-k);
    else re[1] = b;
    cout<<re[0]<<" "<<re[1]<<endl;
    return 0;
}

int main(){
    int T = 1;
    while(T--){
        int res = solve();
        // cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.6
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n,qw;
  cin >> n;
  vector<tuple<int,int,int>> a(n);
  
  rep(i,0,n) {
    cin >> qw;
    a[i] = make_tuple(qw,i,0);
  }
  sort(ALL(a));
  rep(i,0,n){
    swap(get<0>(a[i]),get<1>(a[i]));
    get<2>(a[i]) = i;
  }
  sort(ALL(a));
  Vi b(n);
  rep(i,0,n) b[i] = get<2>(a[i]);
  //Vout(b);
  
  int ans = 0;
  rep(i,0,n){
    if(b[i]%2 != i%2) ans++;
  }
  cout << ans/2 << endl;
  return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    if (s == t) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const T = input[1].map(Number);
  const M = Number(input[2][0]);

  const total = T.reduce((acc, cur) => acc + cur);
  const answer: number[] = [];

  for (let i = 3; i < M + 3; i++) {
    const [P, X] = input[i].map(Number);

    answer.push(total - (T[P - 1] - X));
  }

  return answer.join("\n");
};

console.log(main(read()));


Measured memory_bytes: 29920
#include <algorithm>
#include <iostream>
#include <string>
#include <numeric>
typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll dcc = (b / c) - ((a - 1) / c);
  ll ddc = (b / d) - ((a - 1) / d);

  ll gc = min(c, d);
  ll gd = max(c, d);
  ll r = gc % gd;
  while(r!=0){
    gc = gd;
    gd = r;
    r = gc % gd;
  }
  ll lcm = c * d / gd;

  ll dcdc = (b / lcm) - ((a - 1) / lcm);
  cout << b - a + 1 - dcc - ddc + dcdc << endl;}

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


int main(){
    ll n; cin>>n;
    ll m=0, a=0, r=0, c=0, h=0;
    rep(i,n){
        string s; cin>>s;
        if(s[0]=='M') m++;
        if(s[0]=='A') a++;
        if(s[0]=='R') r++;
        if(s[0]=='C') c++;
        if(s[0]=='H') h++;
    }
    ll res=0;
    res+=m*a*r;
    res+=m*a*c;
    res+=m*a*h;
    res+=m*r*c;
    res+=m*r*h;
    res+=m*c*h;
    res+=a*r*c;
    res+=a*r*h;
    res+=a*c*h;
    res+=r*c*h;

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()

if '##' in s[b+1:d]:
    print('No')
    exit()
if '##' in s[a+1:c]:
    print('No')
    exit()

if d < c:
    if '...' not in s[b-1:d+2]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 41072
S = input()
N = len(S)

mod = 10 ** 9 + 7
A, AB, ABC, ALL = 0, 0, 0, 1
for s in S:
    if s == "A":
        A += ALL

    if s == "B":
        AB += A

    if s == "C":
        ABC += AB

    if s == "?":
        ABC = (ABC * 3 + AB) % mod
        AB = (AB * 3 + A) % mod
        A = (A * 3 + ALL) % mod
        ALL = (ALL * 3) % mod

print(ABC % mod)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int x,n;
int p;
bool ok[101];
int ans;
int d;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> x >> n;
    rep1(i,0,n){
        cin >> p;
        ok[p] = true;
    }
    d = 100000;

    rep2(i,-200,200){
        if(i >= 0 && ok[i]) continue;
        if(abs(x - i) < d){
            d = abs(x - i);
            ans = i;
        }
    }    
    cout << ans;
	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>

int main(){
	int sx, sy, tx, ty;
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
	tx -= sx, ty -= sy;
	for (int i = 0; i < tx; ++i) printf("R");
	for (int i = 0; i < ty + 1; ++i) printf("U");
	for (int i = 0; i < tx + 1; ++i) printf("L");
	for (int i = 0; i < ty + 1; ++i) printf("D");
	printf("R");
	for (int i = 0; i < ty; ++i) printf("U");
	for (int i = 0; i < tx + 1; ++i) printf("R");
	for (int i = 0; i < ty + 1; ++i) printf("D");
	for (int i = 0; i < tx + 1; ++i) printf("L");
	printf("U\n");
	return 0;
}

Measured memory_bytes: 128
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
  
s=0
t=0
u=0
  
for q in P:
  if q<=A:
    s += 1
  elif A+1<=q<=B:
    t += 1
  else:
    u += 1
print(min(s,t,u))

Measured memory_bytes: 3064
n=int(input())
count=1
index=1
while count<n:
  index+=1
  count+=index
if count!=n:
  print("No")
elif n==1:
  print("Yes")
  print(2)
  print("1 1")
  print("1 1")
else:
  print("Yes")
  print(index+1)
  l=[]
  now=1
  num=1
  while now<n:
    l.append(now)
    now+=num
    num+=1
  for i in range(index):
    l1=[str(index)]
    l1.append(str(l[i]))
    num=l[i]
    count1=0
    while count1<i:
      num+=1
      count1+=1
      l1.append(str(num))
    for j in range(1+i,index):
      num+=j
      l1.append(str(num))
    print(" ".join(l1))
  l1=[str(index),str(l[0])]
  num=0
  for j in range(2,index+1):
    num+=j
    l1.append(str(l[0]+num))
  print(" ".join(l1))


Measured memory_bytes: 4212
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int n, a, b;

void solve()
{
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int main()
{
  int n,m;
  cin >> n;
  m = n%10;
  
  switch(m){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon";
      break;
    case 3:
      cout << "bon";
      break;
    default:
      break;
  }
  return 0;
}

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

int x, y, s, i, j, k, mx;

int tax (int x, int i){
	k = i * (100 + x) / 100;
	return k;
}

int main (){
	while (cin >> x >> y >> s && x > 0){
		mx = 0;
		for (i = 1; i < s; i++){
			for (j = 1; j < s; j++){
				if (tax (x, i) + tax (x, j) == s){
					mx = max (mx, tax (y, i) + tax (y, j));
				}
			}
		}
		cout << mx << endl;
	}
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;

using R=long double;

const int limit=150010;
R dp[20][limit];

int main(void){
	int n,a[20];
	cin >> n;
	rep(i,n) cin >> a[i];

	rep(i,n)rep(j,limit) dp[i][j]=1e30;
	rep(j,1,limit) dp[0][j]=1.0*abs(j-a[0])/a[0];


	rep(i,n-1)rep(j,1,limit){
		for(int k=j;k<limit;k+=j){
			chmin(dp[i+1][k],max<R>(dp[i][j],1.0*abs(k-a[i+1])/a[i+1]));
		}
	}

	R ans=1.0;
	rep(j,1,limit) chmin(ans,dp[n-1][j]);
	
	cout.precision(20);
	cout << fixed << ans << endl;

	return 0;
}

Measured memory_bytes: 50084
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>N>>H;
    
        if (N<10 && H<10){
            cout <<N*H <<endl;
        }else{
            cout <<-1 <<endl;
        }
    

    
    

    return 0;
    
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
int main(){
  char s[11] = {0};
  char ans[11] = {0};
  int ans_cnt = 0;

  scanf("%s", s);

  for(int cnt = 0; cnt < strlen(s); cnt++){
    if(s[cnt] == '0' || s[cnt] == '1'){
      ans[ans_cnt] = s[cnt];
      ans_cnt++;
    }else{
      if(ans_cnt > 0){
	ans_cnt--;
	ans[ans_cnt] = '\0';
      }else{
	// do nothing
      }
    }
  }

  printf("%s", ans);

  printf("\n");
  
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
long long dp[3000][3001];
int main()
{
    long long n;
    cin>>n;
    long long moves[n];
    for(int i=0;i<n;i++)
    {
        cin>>moves[i];
    }
    for(int i=0;i<n;i++)
    {
        dp[i][1]=moves[i];
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=n-i;j++)
        {
            dp[j][i]=max(-dp[j][i-1]+moves[i+j-1],-dp[j+1][i-1]+moves[j]);
        }
    }
    cout<<dp[0][n]<<endl;
}


Measured memory_bytes: 70144
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;
 
ll DP[20000];
 
signed main(){
  int N,W;
  cin >> N >> W;
  ll v,w,m;
  FOR(i,0,N){
    cin >> v >> w >> m;
    ll n = 1;
    while(1){
      REP(i,0,10001){
        if((DP[i] || i == 0) && i+w*n < 20000)DP[i+w*n] = max(DP[i+w*n],DP[i]+v*n);
      }
      m -= n;
      if(m == 0)break;
      n *= 2;
      if(m < n)n = m;
    }
  }
  ll ans = 0;
  FOR(i,0,W+1){
    ans = max(DP[i],ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}

int modinv(int a){ return power(a,mod-2);}

void solve()
{
	int n,k;
	cin>>n>>k;
	int val=n%k;
	cout<<min(val,k-val)<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	while(t--)	solve();
	return 0;
}

Measured memory_bytes: 256
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
    exit()
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Measured memory_bytes: 38512
def main():
    N, W = (int(i) for i in input().split())
    v = []
    w = []
    for i in range(N):
        a, b = (int(i) for i in input().split())
        v.append(a)
        w.append(b)
    done = [[False for i in range(W+1)] for j in range(N+1)]
    memo = [[0 for i in range(W+1)] for j in range(N+1)]

    def dp(i,u):
        if done[i][u]: 
            return memo[i][u]
        if i == N:
            return 0
        elif u < w[i]:
            return dp(i + 1, u)
        else:
            res1 = dp(i + 1, u)
            res2 = dp(i + 1, u - w[i]) + v[i]
            res = max(res1,res2)
            done[i][u] = True
            memo[i][u] = res
            return res

    print(dp(0,W))

if __name__ == '__main__':
    main()


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

int main()
{
  for (int i = 1; i < 6; ++i)
  {
    int x;
    std::cin >> x;
    if (x == 0)
    {
      std::cout << i << std::endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3596
INF = 10**9
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
dp = [[INF for _ in range(51)] for _ in range(1<<N)]
dp[0][0] = 0
for S in range(1 << N):
  j = bin(S).count("1")
  c = 0
  for i in range(N):
    if not (S & 1<<i):
      if (i - j) % 2 == 0:
        k = A[i]
      else:
        k = B[i]
      for l in range(k+1):
        dp[S|1<<i][k] = min(dp[S|1<<i][k],dp[S][l]+c)
      c += 1
ans = min(dp[-1])
print(-1 if ans == INF else ans)



Measured memory_bytes: 234416
#define DEBUG 0

/**
 * File    : D4.cpp
 * Author  : Kazune Takahashi
 * Created : 2/21/2019, 12:09:38 AM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const string base = "-";

void char_max(string &a, string b)
{
  if (a == base)
  {
    a = b;
  }
  else if (a.size() < b.size())
  {
    a = b;
  }
  else if (a.size() == b.size() && a < b)
  {
    a = b;
  }
}

ll X[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string DP[10010];
int N, M;
ll A[10];

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    cin >> A[i];
  }
  for (auto i = 0; i < 10010; i++)
  {
    DP[i] = base;
  }
  DP[0] = "";
  for (auto i = 0; i <= N; i++)
  {
    if (DP[i] == base)
    {
      continue;
    }
    for (auto j = 0; j < M; j++)
    {
      char_max(DP[i + X[A[j]]], DP[i] + (char)('0' + A[j]));
    }
  }
  cout << DP[N] << endl;
}

Measured memory_bytes: 43776
#include<bits/stdc++.h>
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define ll long long
#define MAX 200005  
#define mp make_pair
const int M=1e9+7;
const int mod=998244353;
typedef double ld;
bool visited[MAX];
//vector<ll>adj[MAX];
ll qpow(ll x, ll k,ll m) {return k==0? 1: 1ll*qpow(1ll*x*x%m,k>>1,m)*(k&1?x:1)%m;}
ll modinv(ll a,ll m){ll g=__gcd(a,m);return (g==1)? qpow(a,m-2,m):-1;}
int group[MAX];


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL); 
    int n,m;
    cin>>n>>m;
    vector<int> v[m+1];
    priority_queue<int> q;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        if(x<=m)
            v[x].pb(y);
    }
    ll ans=0;
    for(int i=1;i<=m;i++)
    {
        for(int k:v[i])
        {
            q.push(k);
        }
        if(!q.empty())
        {
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 5632
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();

  for (int i = 0; k > 0 && i < n; i++) {
    int d = ('a' + 26 - s[i]) % 26;
    //printf("s[%d]=%c, d=%d, k=%d\n", i, s[i], d, k);
    if (k >= d) {
      s[i] = 'a';
      k -= d;
    }
  }

  s[n - 1] = (s[n - 1] - 'a' + k) % 26 + 'a';

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int h,a;
     cin>>h>>a;
     cout<<(int)ceill(h*1.0/a)<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;

  auto money = [](int i) {
    if (i <= 3) {
      return 100000 * (4 - i);
    } else {
      return 0;
    }
  };

  int ans = money(x) + money(y);
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } 


void solve(ll ts){
    //ll n; cin>>n; vector<ll>arr(n,0); rep(n) cin>>arr[i];
    ll n; cin>>n;
    cout<<(pw(10,n)-pw(9,n)-pw(9,n)+pw(8,n)+mod+mod+mod+mod)%mod<<endl;
}

//
int main(){
    ffast
    ll t=1;
//    cin>>t;
    rep(t) solve(i+1);
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int rate = scanner.nextInt();

    if(rate < 1200) {
      System.out.println("ABC");
    } else {
      System.out.println("ARC");
    }
  }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

LL n;
VL a = {3,5,7};

LL dfs(LL num) {
	if (num > n) {
		return 0;
	}

	LL ret = 0;
	set<LL> st;
	LL tmp = num;
	while (tmp) {
		st.insert(tmp%10);
		tmp /= 10;
	}
	if (st.size() == 3) {
		ret = 1;
	}

	for (auto&& var : a) {
		ret += dfs(num*10 + var);
	}
	return ret;
}

int main(int argc, char const* argv[])
{
	cin >> n;

	cout << dfs(0) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        Character s = null;
        for (Character si : S.toCharArray()) {
            if (s == si) {
                System.out.println("Bad");
                return;
            }
            s = si;
        }
        System.out.println("Good");
    }

}


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

int main() {
    string S;
    cin >> S;
    
    int N = S.size();
    
    int count = 0;
    for ( int i = 0; i < N; ++i){
        count = count + ( S[i] - '0' );
    }
    
    int ans1 = count * 2;
    int ans2 = ( N - count ) * 2;
    
    cout << min(ans1,ans2) << endl;
    
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i=1;i*2<n;++i){
		++ans;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  REP(i, 4) {
    int c = ccw(s[i&1],s[!(i&1)],t[!(i>>1&1)]);
    if (s[i&1]==t[i>>1&1]&&c!=-2&&c)
      return 0;
  }
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

bool intersectGG(G a, G b) {
  a.push_back(a[0]);
  b.push_back(b[0]);
  REP(i, a.size()-1)
    REP(j, b.size()-1)
      if (intersectSS(L(a[i], a[i+1]), L(b[j], b[j+1])))
        return 1;
  return 0;
}

int n;
int num;

vector<int> graph[10];
int color[10];

int dfs(int id, int maxcolor) {
  if (id == num) return maxcolor;
  int res = INF;
  for (int i=1; i<=maxcolor; ++i) {
    bool dame = 0;
    FOR(it, graph[id]) {
      if (color[*it] == i) {
        dame = 1;
        break;
      }
    }
    if (!dame) {
      color[id] = i;
      res = min(res, dfs(id+1, maxcolor));
    }
  }
  color[id] = maxcolor+1;
  res = min(res, dfs(id+1, maxcolor+1));
  return res;
}

int main() {
  //cout << intersectSS(L(P(100,100), P(100,0)), L(P(100,100), P(100,200))) << endl;
  while(cin >> n, n) {
    vector<G> polygon[n];
    num = 0;
    map<string, int> id;
    REP(i, n) {
      string name;
      cin >> name;
      int x, y;
      G tmp;
      while(cin >> x, x!=-1) {
        cin >> y;
        tmp.push_back(P(x,y));
      }
      if (id.count(name) == 0) id[name] = num++;
      polygon[id[name]].push_back(tmp);
    }
    REP(i, num) graph[i].clear();
    REP(i, num) {
      REP(j, i) {
        FOR(it, polygon[i]) {
          FOR(jt, polygon[j]) {
            if (intersectGG(*it, *jt)) {
              graph[i].push_back(j);
              graph[j].push_back(i);
              goto NEXT;
            }
          }
        }
      NEXT:;
      }
    }
    // REP(i, num) {
    //   cout << i << " : ";
    //   FOR(it, graph[i])
    //     cout << *it << " ";
    //   cout << endl;
    // }
    memset(color, 0, sizeof(color));
    cout << dfs(0, 0) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
void solve() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N), B(N);
  vector<pair<ll, ll>> jobs(N);
  REP(i, N) {
    cin >> A[i] >> B[i];
    jobs[i] = make_pair(-A[i], -B[i]);
  }
  sort(ALL(jobs));
  ll sum = 0;
  ll today = 0;
  priority_queue<ll> queue;
  for(auto j: jobs) {
    ll days = -j.first, reward = -j.second;
    if(today + days <= M) {
      // cerr << "insert: " << days << " " << reward << endl;
      sum += reward;
      today++;
      queue.push(-reward);
    } else {
      if(!queue.empty()) {
        ll cheapest = -queue.top();
        if(cheapest < reward) {
          queue.pop();
          queue.push(-reward);
          // cerr << "replace " << cheapest << " -> " << reward << endl;
          sum += reward - cheapest;
        }
      }
    }
  }
  cout << sum << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

int main(){
	bool prime[60000] = {};
	for (int i = 2; i < 60000; i++){
		if (prime[i]) continue;
		for (int j = 2; i * j < 60000; j++){
			prime[i * j] = true;
		}
	}
	int n, situ[2] = { -1, 1 };
	while (cin >> n){
		for (int i = 0; i < 2; i++){
			for (int j = 1;; j++){
				if (!prime[n + situ[i] * j]){
					printf("%d", n + situ[i] * j);
					if (i == 0) printf(" ");
					break;
				}
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1216
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
mat g;
ll solve(ll now){
  ll i,N=g[now].size(),res=0;
  vec v(N);
  rep(i,N){
    v[i]=solve(g[now][i]);
  }
  vrsort(v);
  rep(i,N)chmax(res,v[i]+i+1);
  return res;
}
int main(){
  startupcpp();
  ll i,N,M,K,x;
  cin>>N;
  g.resize(N);
  rep1(i,N){
    cin>>x;x--;
    g[x].pb(i);
  }
  cout<<solve(0)<<endl;
  return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

const int maxn=1e5+7;
int a[maxn];
int main()
{
    int n=read(),x=read();
    for(int i=1; i<=n; i++)a[i]=read();
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        if(i==n)
        {
            if(x==a[i])ans++;
            break;
        }
        if(x>=a[i])
        {
            x-=a[i];
            ans++;
        }
        else break;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a, b = max(n-x,x),min(n-x,x)
res = a+b
while b!=0:
    q = a//b
    r = a%b
    res += (b*2)*q
    if (r==0):
        res -= b
    a, b = b, r

print(res)

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

int main() {
  int N, K, h, C=0;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    cin >> h;
    if (K<=h) {
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 3640