akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	int X, A, B, j;

	cin >> X >> A >> B;

	if(B <= A) cout << "delicious" << endl;
	else if(A-B+X>=0) cout << "safe" << endl;
	else cout << "dangerous" << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> c(H);
  for (int i = 0; i < H; ++i)
    cin >> c[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << H + W); ++bit)
  {
    auto t = c;
    for (int i = 0; i < H + W; ++i)
    {
      if (bit & (1 << i))
      {
        if (i < H)
        {
          for (int j = 0; j < W; ++j)
          {
            t[i][j] = '$';
          }
        }
        else
        {
          for (int j = 0; j < H; ++j)
          {
            t[j][i - H] = '$';
          }
        }
      }
    }
    int cnt = 0;
    for (int i = 0; i < H; ++i)
    {
      for (int j = 0; j < W; ++j)
      {
        if (t[i][j] == '#')
          cnt++;
      }
    }
    if (cnt == K)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3616
t = input()
if t == "SSS":
    print(0)
if t == "RSS":
    print(1)
if t == "SRS":
    print(1)
if t == "SSR":
    print(1)
if t == "SRR":
    print(2)
if t == "RSR":
    print(1)
if t == "RRS":
    print(2)
if t == "RRR":
    print(3)

Measured memory_bytes: 8984
#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>

using namespace std;

long long dfs(vector<bool> open, vector<vector<bool>> &f, vector<vector<long long>> &p) {
    int n = f.size();
    if (open.size() == 10) {
        bool flag = false;
        for (int i = 0; i < open.size(); i++)
            if (open[i])
                flag = true;
        if (!flag)
            return -1000000000000000;
        
        vector<int> cnt(n, 0);
        for (int i = 0; i < 10; i++) {
            if (!open[i])
                continue;
            for (int j = 0; j < n; j++) {
                if (f[j][i])
                    cnt[j]++;
            }
        }
        long long ans = 0;
        for (int i = 0; i < n; i++)
            ans += p[i][cnt[i]];

        return ans;
    }
    else {
        long long maxx = -1000000000;
        open.push_back(true);
        maxx = max(maxx, dfs(open, f, p));
        open.back() = false;
        maxx = max(maxx, dfs(open, f, p));

        return maxx;
    }
}




int main() {
    int n;
    cin >> n;
    vector<vector<bool>> f(n, vector<bool>(10, false));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            int tmp;
            cin >> tmp;
            f[i][j] = (tmp == 1);
        }
    }
    vector<vector<long long>> p(n, vector<long long>(11, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }

    cout << dfs(vector<bool>(), f, p) << endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
map<ll,ll> d;
long long N,per[51],K,peti[51],cnt,ans;
vector<ll> r;
int main()
{
	cin >> N >> K;
	per[0]=1;
	peti[0]=2;
	for(int i=1; i<=N; i++)
	{
		per[i]=per[i-1]*2+3;
		peti[i]=peti[i-1]*2;
		peti[i-1]--;
	}
	peti[N]--;
	cnt=N;
	
	while(K>0)
	{
		if(K>=per[cnt])
		{
			if(K==per[cnt])
			K-=per[cnt],ans+=peti[cnt];
			else
			{
				K-=per[cnt]+1,ans+=peti[cnt]+1;
			}
		}
		else
		cnt--,K--;
	}
	
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
	//code
 
	    int n,k1;
	    cin>>n>>k1;
	    int a[n];
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	    }
	    
	    int dp[n+1];
	    dp[0]=0;
	    dp[2]= abs(a[1]-a[0]);
	    dp[1]=0;
	    for(int i=3;i<n+1;i++)
	    {
	        int k=k1;
	        int minM=INT_MAX;
	        if(k>=i)
	            k=i-1;
	        while(k>0)
	        {
	            minM=min(dp[i-k]+abs(a[i-1]-a[i-k-1]),minM);
	            k--;
	        }
	        dp[i]=minM;
	    }
        cout<<dp[n];
	return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<max(a,b);i++){
		cout<<min(a,b);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#my_answer
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))#N times
#print(H)
#temp=T-x*0.006
temp=[0]*N
gap=[0]*N

for i in range(N):
	temp[i]=T-0.006*H[i]
	gap[i]=abs(temp[i]-A)

#print(temp)
for i in range(N):
	if(gap[i]==min(gap)):
		print(i+1)





Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
using namespace std;
int main(void)
{
  int n;
  scanf("%d",&n);
  int a[101];
  int n3=1;
  for(int i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
      n3=n3*3;
    }
  int ansl=1;
  for(int i=0;i<n;i++)
    {
      if(a[i]%2==0)
	{
	  ansl*=2;
	}
    }
  int ans=n3-ansl;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll n;

void dfs(string s, char ma) {
    if(s.length() == n) {
        out(s);
        return;
    }
    for(char c = 'a'; c <= ma; c++) {
        if(c == ma) {
            dfs(s + c, (char)(ma + 1));
        }
        else {
            dfs(s + c, ma);
        }
    }
}

int main() {
    cin >> n;
    dfs("", 'a');
    re0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		 int n = scan.nextInt();
		 int x = scan.nextInt();
		 int t = scan.nextInt();

		 if(n%x != 0){
			System.out.print(n/x*t+t);
		 }else{
			System.out.print(n/x*t);
		 }

	}
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

int main(){
  int n;
  while(cin >> n){
    double ans = 0;

    vector<int> x(n), y(n);
    REP(i,n) cin >> x[i] >> y[i];


    vector<int> p(n);
    iota(ALL(p),0);

    do{
      double s = 0;

      REP(i,n-1){

        double dx = x[p[i]]-x[p[i+1]];
        double dy = y[p[i]]-y[p[i+1]];

        s += sqrt(dx*dx+dy*dy);
      }

      ans += s;
      
    }while(next_permutation(ALL(p)));
    

    FORE(i,1,n){
      ans /= i;
    }



    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

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

int dp[1001][5001];

int main(){
	int n,r,w[1000],maxr,sum,sumr,p;
	for(;;){
		scanf("%d",&n);
		if(!n)break;
		sum = sumr = maxr = p = 0;
		rep(i,n){
			scanf("%d%d",&r,w+i);
			sum += r+w[i];
			sumr += r;
			if(maxr < r){
				p = i;
				maxr = r;
			}
		}
		sumr -= maxr;
		if(maxr <= sumr){
			printf("%d\n",sum);
			continue;
		}
		memset(dp,0,sizeof(dp));
        sumr = maxr - sumr;
		rep(i,n){
			rep(j,sumr+1){
				if(j >= w[i] && i!=p)
				    dp[i+1][j] = max(dp[i][j],dp[i][j - w[i]]+w[i]);
				else dp[i+1][j] = dp[i][j];
			}
		}
("%d %d %d %d\n",sum, maxr, sumr);
		printf("%d\n",sum + sumr - dp[n][sumr]);
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln << "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
struct edge {
	int to,cost;
	edge(int t, int c):to(t),cost(c) {}
};

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

// dp[i][j]: i???????????§??????????????§j??????????????¨???????????????????????°???????°????(???????????????????????¨??????????????°inf)
int n, m, c[21], dp[21][50001];

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	cin >> n >> m;
	repst(i,1,m) cin >> c[i];
	rept(i,m) fill(dp[i], dp[i]+n+1, inf);
	dp[0][0] = 0;
	
	repst(i,1,m) {
		rept(j,n) {
			if (j<c[i]) dp[i][j] = dp[i-1][j];
			else dp[i][j] = min(dp[i-1][j], dp[i][j-c[i]]+1);
		}
	}
	
	/*
	rept(i,m) {
		rept(j,n) {
			printf("%4d  ", dp[i][j]);
		}
		printf("\n");
	}
	*/
	
	cout << dp[m][n] ln;
}

Measured memory_bytes: 7240
#include <bits/stdc++.h>
#define REP(i,n) for (int 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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B; cin >> A >> B;
    cout << (A <= 8 && B <= 8 ? "Yay!":":(") << endl;
}

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

typedef long long ll;

ll gcd(ll m, ll n) {
    if (n == 0) return m;
    return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
    return m * n / gcd(m, n);
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll cOnly, dOnly, both;

    cOnly = (b / c) - ((a-1) / c);
    dOnly = (b / d) - ((a-1) / d);
    both = (b / lcm(c, d)) - ((a-1) / lcm(c, d));
    cout << b - (a-1) - (cOnly + dOnly - both) << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int  n;double m;
    cin>>n>>m;
    double a[n], ans=0;
    for(int i=0;i<n;i++)
    {
     cin>>a[i];
    ans+=a[i];
    }
ans=ans/(4*m);int cnt=0;//cout<<ans<<endl; 
for(int i=0;i<n;i++)
{
if(a[i]>=ans)cnt++;
}
if(cnt>=m)
    {
        cout<<"Yes";return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
	int n,m; cin >> n >> m;
	map<int,vector<pair<int,int>>> yp;
	vector<pair<int,int>> ans(m);
	int y,p;
	rep(i,m){
		cin >> p >> y;
		yp[p].push_back(make_pair(y,i));
	}
	for(auto [pp,yi]: yp){
		sort(all(yi));
		rep(i,yi.size()){
			ans[yi[i].sc] = make_pair(pp,i+1);
		}
	}
	for(auto [pp,ii]: ans){
		printf("%06d%06d\n",pp,ii);
	}
}

Measured memory_bytes: 17872
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a,b;
int main(){
cin>>a>>b;
int mx=max(a-b,a+b);
mx=max(mx,a*b);
cout<<mx;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
#pragma warning(disable: 4996)
int n, a[100009], b[100009], c[100009], bit[100009]; vector<tuple<long double, long double, long double>>F, G;

void add(int p, int x) {
	while (p <= 100008) { bit[p] += x; p += (p&-p); }
}
void zero() {
	for (int i = 0; i < 100009; i++)bit[i] = 0;
}
int sum(int p) {
	int s = 0;
	while (p >= 1) { s += bit[p]; p -= (p&-p); }
	return s;
}
int search(double p) {
	vector<pair<long double, int>>T; vector<long double>E;
	for (int i = 0; i < F.size(); i++) {
		long double V = (get<2>(F[i]) - get<0>(F[i])*p) / get<1>(F[i]);
		long double W = get<0>(F[i]) / get<1>(F[i]);
		E.push_back(W);
	}
	sort(E.begin(), E.end());
	for (int i = 0; i < F.size(); i++) {
		long double V = (get<2>(F[i]) - get<0>(F[i])*p) / get<1>(F[i]);
		long double W = get<0>(F[i]) / get<1>(F[i]);
		int pos1 = lower_bound(E.begin(), E.end(), W) - E.begin();
		T.push_back(make_pair(V, pos1 + 1));
	}
	sort(T.begin(), T.end());
	int ret = 0;
	for (int i = 0; i < T.size(); i++) {
		ret += sum(T[i].second);
		add(T[i].second, 1);
	}
	return ret;
}
long double solve() {
	long double L = -1e9, R = 1e9, M;
	for (int i = 0; i < 90; i++) {
		M = (L + R) / 2; zero();
		int F = search(M);
		if (F <= (n*(n - 1) / 2) / 2)R = M; else L = M;
	}
	return M;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i] >> b[i] >> c[i];
	for (int i = 1; i <= n; i++)F.push_back(make_tuple(a[i], b[i], c[i]));
	long double I = solve();
	for (int i = 1; i <= n; i++)G.push_back(make_tuple(b[i], -a[i], c[i]));
	F = G;
	long double J = solve();
	printf("%.15Lf %.15Lf\n", I, J);
	return 0;
}

Measured memory_bytes: 10300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=3e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    vector<ll>cnt(m+1,0);
    for(ll i=0;i<n;i++){
        ll k;cin>>k;
        for(ll j=0,x;j<k;j++)cin>>x,cnt[x]++;
    }
    ll ans=0;for(ll i=1;i<=m;i++)ans+=(cnt[i]==n);
    cout<<ans;
}



Measured memory_bytes: 256
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <stack>
# include <bitset>
# include <algorithm>
# include <functional>
# include <numeric>
# include <utility>
# include <sstream>
# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cmath>
# include <cstdlib>
# include <cctype>
# include <string>
# include <cstring>
# include <ctime>
# include <queue>


# define FOR(i, a, b) for(int i{a}; i < (b); ++i)
# define REP(i, n)    FOR(i, 0, n)

using namespace std;

using ll = long long;

template<typename T>
using Vec = vector<T>;



int main()
{


    while (true)
    {
        int n, p;
        cin >> n >> p;

        if (n == 0 && p == 0) {
            break;
        }

        int owan = p;


        Vec<int> counts(n, 0);
        int index = 0;

        while (true) {
            if (owan > 0) {
                counts[index]++;
                owan--;
                if (counts[index] == p) {
                    break;
                }
                index++;
                index %= n;
            }
            else {
                if (counts[index] > 0) {
                    owan += counts[index];
                    counts[index] = 0;
                }
                index++;
                index %= n;
            }
        }

        cout << index << endl;

    }
}


Measured memory_bytes: 3068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& s,T t){if(s<t){s=t;return 1;} return 0;}
template<class T> inline bool chmin(T& s,T t){if(s>t){s=t;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  vector<string> s(N);
  vector<int> t(N);
  rep(i,N){
    cin >> s[i] >> t[i];
  }
  string X; cin >> X;
  vector<int> S(N+1);
  rep(i,N){
    S[i+1]=S[i]+t[i];
  }
  int basho;
  rep(i,N){
    if(s[i]==X){
      basho=i;
    }
  }
  cout << S[N]-S[basho+1] << endl;

}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M = map(int,input().split())
    if N == M:
        res = 'Yes'
    else:
        res = 'No'
    print(res)



main()


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

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> AB(100000, vector<int>(0));
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        AB[--a].push_back(b);
    }
    priority_queue<int> q;
    int ans = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < AB[i].size(); j++) {
            q.push(AB[i][j]);
        }
        if (q.empty()) continue;
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
module Main where

import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import qualified Data.Vector.Generic           as VG
import qualified Data.Vector.Generic.Mutable   as VGM
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )
import Data.List.Extra 

main :: IO ()
main = do
  x <- readLn :: IO Int
  ds <- VU.replicateM x $ (\v -> (v VU.! 0, v VU.! 1)) . VU.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  putYN $ (>=3) $ maximum $ map length $ splitOn [False] $ map (\(a, b) -> a == b) $ VU.toList ds

putYN :: Bool -> IO ()
putYN True  = putStrLn "Yes"
putYN False = putStrLn "No"

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

string s, t;

ll getIt(ll pos, ll n) {
	ll summ = 0;
	for(ll i=pos;i<pos + n;i++) if(s[i] != t[i - pos]) summ ++ ;
	return summ;
}

void thisIsMain() {
	cin>>s;
	cin>>t;
	ll ans = LLONG_MAX;
	forl(i,s.size() - t.size() + 1) ans = min(ans, getIt(i, t.size()));
	cout<<ans<<"\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

Measured memory_bytes: 3624
N = int(input())
S = input()

whites = []
reds = []
for i in range(N):
    if S[i] == 'W':
        whites.append(i)
    else:
        reds.append(i)

whites.reverse()

ans = 0
while reds and whites and whites[-1] < reds[-1]:
    whites.pop()
    reds.pop()
    ans += 1

print(ans)
    

Measured memory_bytes: 80892
from bisect import bisect_right

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(1, N-1):
    for j in range(i+1, N):
        ans += max(0, i - bisect_right(L, L[j] - L[i]))
print(ans)


Measured memory_bytes: 43612
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,c,k = li()
t = [ni() for _ in range(n)]

t.sort()

ans = 0
people = 0
isfirst = True
for ti in t:
    if isfirst:
        first = ti
        people = 1
        isfirst = False
        
    else:
        if ti <= first + k and people < c:
            people += 1
            
        else:
            ans += 1
            
            people = 1
            first = ti

print(ans+1)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long r)
{
    cout << r * r << endl;
}

int main()
{
    long long r;
    scanf("%lld", &r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100005];
    while(cin>>s)
    {
        int a[29];
        int i,len,manx=0;
        len=strlen(s);
        memset(a,0,sizeof(a));
        for(i=0;i<len;i++)
        {
            if(s[i]>='a'&&s[i]<='z'){
            a[s[i]-'a']=1;
            }
        }
        for(i=0;i<=25;i++)
        {
            if(a[i]==0)
            {
                printf("%c\n",i+'a');
                break;
            }
        }
        if(i==26)
            printf("None\n");
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
vector<int>G[100005];
signed main(){
    string s;cin>>s;
    if(s[0]=='0'||s[s.size()-1]=='1')cout<<-1<<endl;
    else{
        rep(i,s.size()-1){
            if(s[i]!=s[s.size()-2-i]){
                cout<<-1<<endl;
                return 0;
            }
        }
        int nowpar=s.size()-1;
        for(int i=s.size()-2;i>=0;i--){
            G[nowpar].push_back(i);
            if(s[i]=='1')nowpar=i;
        }
        rep(i,s.size()){
            rep(j,G[i].size()){
                cout<<i+1<<' '<<G[i][j]+1<<endl;
            }
        }
    }
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++) ans+=a[i];
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

bool s(P left, P right) {
  if (left.second == right.second) {
    return left.first > right.first;
  }
  return left.second > right.second;
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  vector<vector<ll>> tasks(M + 1);
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    if (a > M) {
      continue;
    }
    tasks[a].pb(b);
  }

  priority_queue<ll> q;
  ll ans = 0;
  rep(i, M + 1) {
    rep(j, tasks[i].size()) {
      q.push(tasks[i][j]);
    }

    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 3005;

ll solve(vi a) {
  if (sz(a)%2 == 0) {
    ll res = 0;
    rep(i,sz(a)) res += (i&1)?-a[i]:a[i];
    if (res < 0) res = -res;
    return res;
  }
  ll res = -LINF;
  rep(ti,2) {
    vi b = a;
    ll now = 0;
    if (ti) {
      now = b.back();
      b.pop_back();
      now -= solve(b);
    } else {
      now = b[0];
      b.erase(b.begin());
      now -= solve(b);
    }
    maxs(res,now);
  }
  return res;
}

ll dp[MX][MX];
int used[MX][MX];
vi a;

ll dfs(int l, int r) {
  if (l == r) return 0;
  if (used[l][r]) return dp[l][r];
  used[l][r] = 1;
  ll res = -LINF;
  maxs(res, a[l]-dfs(l+1,r));
  maxs(res, a[r-1]-dfs(l,r-1));
  return dp[l][r] = res;
}

int main() {
  int n;
  scanf("%d",&n);
  a = vi(n);
  cin>>a;
  // ll ans = solve(a);
  // cout<<ans<<endl;
  cout<<dfs(0,n)<<endl;
  return 0;
}






















Measured memory_bytes: 105088
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	string s;
	cin >> s;

	REP(i, s.size()) {
		if (s[i] == ',') {
			cout << " ";
		} else {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, W, w, v;
ll DP[100001];

int main() {
	cin >> N >> W;
	for (int i = 0; i != N; ++i) {
		cin >> w >> v;
		for (int i = W; i >= w; --i) {
			DP[i] = max(DP[i], DP[i - w] + v);
		}
	}
	cout << DP[W] << endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    x = min(a[i], b[i])
    ans += x
    a[i] -= x
    b[i] -= x
    if b[i] > 0:
        x = min(a[i + 1], b[i])
        ans += x
        a[i + 1] -= x
print(ans)


Measured memory_bytes: 19156
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, A, B;
  cin>>H>>W>>A>>B;
  int ans[H][W];
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      ans[i][j] = 0;
    }
  }
  map<int, int> gyo[H], retu[W];
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(gyo[i][1]<W-A && retu[j][1]<H-B) {
        ans[i][j] = 1;
        gyo[i][1]++;
        retu[j][1]++;
      }
    }
  }
  bool can = true;
  for(int i=0;i<H;++i) {
    if(gyo[i][1]!=A && gyo[i][1]!=W-A) can = false;
    if(retu[i][1]!=B && retu[i][1]!=H-B) can = false;
  }
    for(int i=0;i<H;++i) {
      for(int j=0;j<W;++j) {
        cout<<ans[i][j];
      }
      cout<<endl;
    }
}


Measured memory_bytes: 7572
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll count=0;
	for(ll i=1; i<n; i++){
		ll num=n-i;
		ll var=1;
		for(ll j=2; j*j<=num; j++){
			int cnt=0;
			while(num%j==0){
				cnt++;
				num/=j;
			}
			var*=(cnt+1);
		}
		if(num>1)
		 var*=2;
		count+=var;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3632
def score(T):
    s1 = sum(W[:T])
    s2 = w_sum - s1
    # s1 - s2 = 2*s1 - w_sum
    return abs(s1 - s2)

N = int(input())
W = list(map(int, input().split()))
w_sum = sum(W)
scores = []
for i in range(N):
    scores.append(score(i+1))
print(min(scores))

Measured memory_bytes: 3060
n = int(input())
Route = [list(map(int,input().split())) for i in range(n-1)]
Station = [0 for i in range(n)]

for i in range(n):
  time = 0
  for j in range(i,n-1):
    
    time = max(-(-(time-Route[j][1])//Route[j][2])*Route[j][2],0)+Route[j][0]+Route[j][1]
    
  Station[i] = time
for s in Station:
  print(s)

Measured memory_bytes: 3188
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll dp[2005][2005];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<pair<int,int> > z(n);  // val,id
    int i,j;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        z[i] = make_pair(tmp, i);
    }
    sort(z.rbegin(), z.rend());

    for (i = 0; i <= n; i++) {
        for (j = 0; j <= n; j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    for (i = 0; i < n; i++) {
        for (j = 0; j <= i; j++) {
            if (dp[i][j] < 0) continue;

            int val = z[i].first;
            int id  = z[i].second;
            dp[i + 1][j+1] = MAX(dp[i + 1][j+1], dp[i][j]+(ll)val*(id-j));
            dp[i + 1][j] = MAX(dp[i + 1][j], dp[i][j]+(ll)val*(n-1-(i-j)-id));
        }
    }

    ll ans = 0;
    for (j = 0; j <= n; j++) {
        ans=MAX(ans, dp[n][j]);
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 34576
n = int(input())
a = list(map(int,input().split()))
ans = 1000
cnt = 0
for i in range(0,len(a)-1):
    if a[i]<a[i+1]:
        cnt = ans//a[i]
        ans = ans-a[i]*cnt
        ans = ans+a[i+1]*cnt
print(ans)

Measured memory_bytes: 9192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      InputStream inputStream = System.in;
      OutputStream outputStream = System.out;
      Scanner sc = new Scanner(inputStream);
      PrintWriter out = new PrintWriter(outputStream);
      double a = Integer.parseInt(sc.next());
      double b = Integer.parseInt(sc.next());
      int ans = (int)Math.ceil((a + b) / 2);
      out.println(ans);
      out.close();
    }
}

Measured memory_bytes: 23124
n = int(input())
l = [0] * n
for i in range(n):
    a, b = map(int, input().split())
    l[i] = (a + b, a, b)
ans = 0
l.sort(reverse=True)
for i in range(n):
    if i % 2:
        ans -= l[i][2]
    else:
        ans += l[i][1]
print(ans)


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

vector<int> to[100005];
const int INF = 1001001001;

int main(){
    int n,m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(! q.empty()){
        int v = q.front();
        q.pop();
        for(int u: to[v]){
            if(dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    for(int d: dist) if(d == INF) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i == 0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10604
N = int(input())
c = [0, 0, 0]  # 0, 2, 4

for i in map(int, input().split()):
    if i % 4 == 0:
        c[2] += 1
    elif i % 2 == 0:
        c[1] += 1
    else:
        c[0] += 1

if c[0] + (c[1] > 0) <= c[2]+1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11096
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <numeric>
#include <math.h>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    if(n%2){
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        cout << b[n/2]-a[n/2]+1 << endl;
    }
    else{
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        cout << b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1 << endl;
    }
}

Measured memory_bytes: 4780
import Data.ByteString.Char8 as BS

main :: IO ()
main = do
  _ <- BS.getLine
  s <- BS.getLine :: IO BS.ByteString
  print $ calc s 0 0

calc :: BS.ByteString -> Int -> Int -> Int
calc xs n m
  | xs == mempty = m 
  | BS.head xs == 'I' = calc t ninc (max ninc m)
  | otherwise         = calc t ndec m
    where t = BS.tail xs
          ninc = n+1
          ndec = n-1 



Measured memory_bytes: 380
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
#define showp(p) cout << " (" << p.fst << "," << p.snd << ")";
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    const int MAX = 1e5;
    vector<pair<int, int>> a(MAX+1), b(MAX+1);
    repeat_from_to (i, 1, MAX) {
        a[i] = make_pair(i, 0);
        b[i] = make_pair(i, 0);
    }
    
    repeat (i, n/2) {
        int t, s;
        cin >> t >> s;
        a[t].snd += 1;
        b[s].snd += 1;
    }
    
    auto cmp = [](pair<int, int> a, pair<int, int> b) -> bool {
        return a.snd > b.snd;
    };
       
    sort(a.begin(), a.end(), cmp);
    sort(b.begin(), b.end(), cmp);
    
    //for (auto e: a) showp(e); el;
    //for (auto e: b) showp(e); el;
    
    if (a[0].fst != b[0].fst) {
        int t = a[0].snd + b[0].snd;
        cout << n - t << endl;
    }
    else {
        int t = max(a[0].snd + b[1].snd, a[1].snd + b[0].snd);
        cout << n - t << endl;
    }
}
    

Measured memory_bytes: 1920
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
static const int N=100;
static const int inf=(1<<29);
int M[N][N];
int d[N];
int n;

void dfs(int u){
    rep(i,n)d[i]=inf;
    
    queue<int> q;
    q.push(u);
    d[u]=0;
    int l;
    while(!q.empty()){
        l=q.front();
        q.pop();
        for(int v=0;v<n;v++){
            if(M[l][v]==0)continue;
            if(d[v]!=inf)continue;
            d[v]=d[l]+1;
            q.push(v);
        }
    }
    
    rep(i,n){
        cout<<i+1<<" "<<(d[i]==inf?-1:d[i])<<endl;
    }
    
    
}



int main(){
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    
    
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    dfs(0);
    
}



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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);
template<typename... T> void read(T&... x) {((cin >> x),...);}

int main() {
    godspeed;
    
    int h, w, k;
    cin >> h >> w >> k;

    char v[h][w];
    for(int i = 0 ; i < h ; ++i) 
        for(int j = 0 ; j < w ; ++j)
            cin >> v[i][j];

    int ans = 0;
    
    for(int r = 0 ; r < (1<<h) ; ++r)
        for(int c = 0 ; c < 1<<w ; ++c) {
            int cnt = 0;

            for(int i = 0 ; i < h ; ++i) for(int j = 0 ; j < w ; ++j)
                if (((r >> i) & 1) == 0 && ((c >> j) & 1) == 0)
                    if(v[i][j] == '#') cnt++;

            if(cnt == k) ans++;
        }


    cout << ans;
}



Measured memory_bytes: 3612
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
const LL MOD = 1000000007;

int N;
LL K;
int A[2011];

void MAIN() {
    scanf("%d%lld", &N, &K);
    REP (i, N) scanf("%d", A+i);

    LL B = K * (K-1) / 2;
    B %= MOD;
    LL ans = 0;
    REP (i, N) {
	REP (j, i) if (A[j] > A[i]) ans += K;
	REP (j, N) if (A[j] > A[i]) ans += B;
	ans %= MOD;
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256