akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
signed main() {
    int n;
    cin >> n;
    vector<long long> as(n);
    vector<long long> bs(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        if (as[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long double ans = 1e18;
    long long ab = 1;
    REP(i, n) {
        ans = (long double)(ans) / as[i];
        // cout << ans << endl;
        if (ans < 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    REP(i, n) { ab *= as[i]; }
    cout << ab << endl;
}


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

int a[111111];
int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<pair<int, int>> q;
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		q.emplace(a[i], i);
	}
	for (int i = 0; i < m; i++) {
		int x = q.top().second;
		q.pop();
		q.emplace(a[x] /= 2, x);
	}
	long r = 0;
	for (int i = 0; i < n; i++)
		r += a[i];
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1656
N, M, Q = map(int, input().split())
B = [tuple(int(i) for i in input().split()) for i in range(Q)]

A = [1]*N
def recur(A=A, index=0, lim=M):
    if index>len(A)-2:
        return
    while A[index] <= lim-1:
        A[index] += 1
        yield A[::-1]
        yield from recur(A[:], index+1, A[index])
    return

def get_point(A):
    return sum((A[b[1]-1]-A[b[0]-1]==b[2])*b[3] for b in B)

print(max(0, get_point(A), *(get_point(i) for i in recur())))


Measured memory_bytes: 11252
def main():
    H, W, A, B = map(int, input().split())

    g = [[0] * W for _ in range(H)]
    for r in range(H):
        for c in range(W):
            g[r][c] = int((c < A) ^ (r >= B))

    for row in g:
        print(*row, sep='')


if __name__ == '__main__':
    main()


Measured memory_bytes: 13300
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

class Rect
{
public:
    s64 l, r, u, d;
    Rect(int l, int r, int u, int d)
    : l(l), r(r), u(u), d(d)
    {}

    bool in(int x, int y)
    {
        return IN(l, r + 1, x) && IN(u, d + 1, y);
    }

    s64 area()
    {
        return (r - l) * (d - u);
    }
};

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

    int n, k;
    cin >> n >> k;
    vs32 x(n), y(n);
    rep (i, n)
    {
        cin >> x[i] >> y[i];
    }

    s64 ans = ((s64)1 << 62);
    rep (p, n) rep (q, n) rep (r, n) rep(s, n)
    {
        if (p == q || r == s) continue;
        int ll = MIN(x[p], x[q]);
        int rr = MAX(x[p], x[q]);
        int uu = MIN(y[r], y[s]);
        int dd = MAX(y[r], y[s]);
        Rect rec(ll, rr, uu, dd);
        int cnt = 0;
        rep (i, n)
        {
            if (rec.in(x[i], y[i]))
            {
                ++cnt;
            }
        }
        if (cnt >= k)
        {
            ans = MIN(ans, rec.area());
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long int sum=0;
  int n;
  cin>>n;
  for(long int i=1;i<=n;i++)
  {
    if(i%5!=0 && i%3!=0 &&i%15!=0)
    {
      sum=sum+i;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char wolf[10]="MARCH";
long long c[10];
char in[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",in);
		for(int j=0;j<5;j++){
			if(in[0]==wolf[j])c[j]++;
		}
	}
	long long ret=0;
	ret+=c[0]*c[1]*c[2];
	ret+=c[0]*c[1]*c[3];
	ret+=c[0]*c[1]*c[4];
	ret+=c[0]*c[2]*c[3];
	ret+=c[0]*c[2]*c[4];
	ret+=c[0]*c[3]*c[4];
	ret+=c[1]*c[2]*c[3];
	ret+=c[1]*c[2]*c[4];
	ret+=c[1]*c[3]*c[4];
	ret+=c[4]*c[2]*c[3];
	printf("%lld\n",ret);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a0(n);
    REP(i, n){
        cin >> a0[i];
    }
    vector<pair<ll, ll>> b(n);
    REP(i, n){
        ll bi;
        cin >> bi;
        b[i] = {bi, i};
    }
    sort(b.begin(), b.end());
    vector<pair<ll, ll>> a(n);
    REP(i, n){
        a[i] = {a0[b[i].second], i};
    }
    vector<pair<ll, ll>> sa = a;
    sort(sa.begin(), sa.end());

    REP(i, n){
        if(sa[i].first > b[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    REP(i, n - 1){
        if(sa[i + 1].first <= b[i].first){
            cout << "Yes" << endl;
            return 0;
        }
    }

    vector<ll> perm(n);
    REP(i, n){
        perm[sa[i].second] = i;
    }
    vector<bool> visited(n, false);
    ll ncycle = 0;
    REP(i, n){
        if(visited[i]){ continue; }
        ncycle++;
        ll cur = i;
        while(!visited[cur]){
            visited[cur] = true;
            cur = perm[cur];
        }
    }

    if(n - ncycle < n - 1){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 6528
#!/usr/bin/env python3
#!/usr/bin/env pypy3

import sys
sys.dont_write_bytecode = True
stdin = sys.stdin
input = stdin.readline
sys.setrecursionlimit(10000000)

#import numpy as np
#import scipy as sp

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from operator import itemgetter, attrgetter
from itertools import permutations, combinations
from functools import reduce, lru_cache
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5.  Import from math after it.
from fractions import gcd
from fractions import Fraction as Frac

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(func = input, sep = None, conv = int):
    return list(map(conv, func().split(sep = sep)))

################################################################################


def main():
    N, = list(map(int, input().split()))
    T = [None for i in range(N)]
    for i in range(N):
        T[i] = tuple(list(map(int, input().split())))
    T.sort(key = lambda t: t[1] * 1e10 + t[0])

    now = 0
    for i in range(N):
        t = T[i]
        if now + t[0] <= t[1]:
            now += t[0]
        else:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38704
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<map>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;

int n,a[10],b[10],ans=0; 

void F(int a[],int b[]){
	do{
		int flag=1;
//		cout<<a[0]<<a[1]<<a[2]<<endl;
		for(int i=0;i<n;i++){
			if(a[i]!=b[i]){
				flag=0;ans++;
				break;
			}
		}
		if(flag) break;
	}while(next_permutation(a,a+n));
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++){
		if(a[i]<b[i]){
			F(a,b);
			break;
		}
		else if(a[i]>b[i]){
			F(b,a);
			break;
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
    int menu[5];
    int maxtime = 10;
    for (int i = 0; i < 5; i++){
        cin >> menu[i];
    }
    int menu_first[5];
    for (int i = 0; i < 5; i++){
        menu_first[i] = menu[i] % 10;
    }
    int kiroku = 0;
    for (int i = 0; i < 5; i++){
        if (menu_first[i] < maxtime && menu_first[i] != 0){
            maxtime = menu_first[i];
            kiroku = i;
        }
    }
    int total = 0;
    for (int i = 0; i < 5; i++){
        if (i == kiroku) total += menu[i];
        else if(menu_first[i] != 0) total += menu[i] - menu_first[i] + 10;
        else total += menu[i];
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define sq(x) (x*x)
#define is_right(a, b, c) (sq(a)+sq(b) == sq(c))

void swap(int *x, int *y) {
    int tmp = *x;
    *x = *y;
    *y = tmp;
}

int main(void) {
    int n;
    scanf("%d", &n);
    int i, j, a[n], b[n], c[n];

    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    }
    for (j = 0; j < i; j++) {
        if (b[j] < a[j]) swap(&a[j], &b[j]);
        if (c[j] < b[j]) swap(&b[j], &c[j]);
        if (is_right(a[j], b[j], c[j])) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 588
//************************
//*  Date: 2018.10.22    *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,q;
vector <int> g[100010];
int colo[100010],most[100010];
vector <pair<pii,int> > pa;
bool vis[100010];

int main()
{
	memset(most,-1,sizeof(most));
	cin>>n>>m;
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	cin>>q;
	rep(i,q)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		pa.pb({{x,y},z});
	}
	for(int i=pa.size()-1;i>=0;i--)
	{
		int x=pa[i].fi.fi,y=pa[i].fi.se,z=pa[i].se;
		queue <pii> q;
		q.push({x,0});
		memset(vis,0,sizeof(vis));
		while(!q.empty())
		{
			int pos=q.front().fi,all=q.front().se;
			q.pop();
			if(y-all<=most[pos]) continue;
			most[pos]=y-all;
			if(all>y) continue;
			if(vis[pos]) continue;
			//if(x==1) cout<<pos<<endl;
			vis[pos]=true;
			if(colo[pos]==0) colo[pos]=z;
			rep(i,g[pos].size()) q.push({g[pos][i],all+1});
		}
	}
	repn(i,n) printf("%d\n",colo[i]);
	rt0;
}

Measured memory_bytes: 9588
#include<iostream>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string t;
        cin >> t;
        int a,b;
        cin >> a >> b;
        if(t == "replace"){
            string u;
            cin >> u;
            s.replace(a,b-a+1,u); 
            //cout << s << endl;
        }else if(t == "reverse"){
            reverse(s.begin()+a,s.begin()+b+1);
            //cout << s << endl;
        }else if(t == "print"){
            cout << s.substr(a,b-a+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3216
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

struct uf{

  static const int MAXN=10005;
  int par[MAXN];
  int size[MAXN];
  void init(){
    memset(par,-1,sizeof(par));
    REP(i,MAXN) size[i]=1;
  }
  int root(int a){
    if(par[a]==-1) return a;
    return par[a]=root(par[a]);
  }
  void unite(int a,int b){
    a=root(a);b=root(b);
    if(a==b) return;
    if(size[a]<size[b]) swap(a,b);

    par[b]=a;
    size[a]+=size[b];
  }
  bool same(int a,int b){
    return root(a)==root(b);
  }
};

uf u;
int h,w;

int cnt[30];

char buf[105][105];

bool solve(){
  if(h==1 && w==1) return true;
  if(h>w) swap(h,w);

  int ocnt=0;
  REP(i,26) if(cnt[i]&1) ++ocnt;
  if(h==1){
    int odd=(w&1);
    if(odd==ocnt) return true;
    return false;
  }

  if(h%2==0 && w%2==0){
    REP(i,26) if(cnt[i]%4) return false;
    return true;
  }
  if(h%2==1 && w%2==1){
    if(ocnt!=1) return false;
    int Tcnt=0;
    REP(i,26){
      if(cnt[i]&1) --cnt[i];
      if(cnt[i]%4==2) ++Tcnt;
    }
    int twocnt=(h+w-2)/2;
    if(twocnt>=Tcnt) return true;
    return false;
  }
  {
    int eve=(w%2==0?w:h);

    int Tcnt=eve/2;
    if(ocnt>0) return false;

    int twocnt=0;
    REP(i,26) if(cnt[i]%4==2) ++twocnt;
    if(twocnt<=Tcnt) return true;
    return false;
  }
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>h>>w;
  REP(i,h) cin>>buf[i];

  REP(i,h) REP(j,w) ++cnt[buf[i][j]-'a'];

  puts(solve()?"Yes":"No");
  return 0;
}






Measured memory_bytes: 256
N=int(input())
s=list(input().split())
count=0
while len(s)>1:
    a=0
    if s[0]!=s[1]:
        s.pop(0)
    else:
        while len(s)>=2 and s[0]==s[1]:
            a+=1
            s.pop(0)
        else:
            count+=(a+1)//2
print(count)

    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000;
typedef pair<string,string> PS;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	string s,s1,s2;
	cin>>n>>s;
	FOR(i,0,n){
		s1+=s[i];
	}
	FOR(i,n,2*n){
		s2+=s[i];
	}	
	ll ans = 0;
	PS p;
	map<PS,int> m;
	FOR(i,0,(1<<n)){
		string r,b;
		FOR(j,0,n){
			if(i&(1<<j))r+=s1[j];
			else b+=s1[j];
		}
		REV(b);
		m[{r,b}]++;
	}
	FOR(i,0,(1<<n)){
		string r,b;
		FOR(j,0,n){
			if(i&(1<<j))r+=s2[j];
			else b+=s2[j];
		}
		REV(b);
		ans+=m[{b,r}];
	}
	cout<<ans<<endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, r;
    cin >> n >> r;
    cout << r + (n >= 10 ? 0 : 100*(10 - n)) << endl;

    return 0;
}


Measured memory_bytes: 764
import math

n, a,b = map(int,input().split())
one_set = a+b

set_count = math.floor(n / one_set)

def get_blue_count():
  last_balls = n - one_set * set_count
  if last_balls >= a:
    return a
  else:
    return last_balls

print(a * set_count + get_blue_count())

Measured memory_bytes: 3060
def main():
  from collections import Counter
  n = int(input())
  D = list(map(int,input().split()))
  m = int(input())
  T = list(map(int,input().split()))
  
  d = dict(Counter(D))
  ans = "YES"
  for t in T:
    try:
      if d[t] - 1 >= 0:
        d[t] -= 1
      else:
        ans = "NO"
    except:
      ans = "NO"

  print(ans)

main()

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

int main(){
    string s,t;
    cin >> s >> t;
    vector<string> cand;
    for(int i=0; i<=(int)s.length()-(int)t.length(); i++){
        bool good = true;
        string tmp = s;
        for(int j=0; j<(int)t.length(); j++){
            if(tmp[i+j]!='?' && tmp[i+j]!=t[j]){
                good = false;
                break;
            }else{
                tmp[i+j] = t[j];
            }
        }
        if(good){
            for(int j=0; j<(int)tmp.length(); j++){
                if(tmp[j]=='?') tmp[j]='a';
            }
            cand.push_back(tmp);
        }         
    }
    
    if(cand.empty()){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << *min_element(cand.begin(), cand.end()) << endl;
    }
    return 0;
}


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

vector<vector<int>> warps;

bool DFS(vector<vector<char>>& grid, int x, int y, deque<pair<int, int>>& dq, int EX, int EY)
{
	if(x < 0 || x >= grid.size() || y < 0 || y >= grid[0].size() || grid[x][y] == '#') return false;
	grid[x][y] = '#';

	if(x == EX && y == EY)
		return true;

	// std::cout << x << ", " << y << std::endl;

	for(int i = -2; i <= 2; i++)
		for(int j = -2; j <= 2; j++)
			dq.push_back({x+i, y+j});

	bool result = DFS(grid, x-1, y, dq, EX, EY) ||
			      DFS(grid, x+1, y, dq, EX, EY) ||
			      DFS(grid, x, y-1, dq, EX, EY) || 
			      DFS(grid, x, y+1, dq, EX, EY);

	return result;
}


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

    int H, W;
    cin >> H >> W;

    int startX, startY;
    cin >> startX >> startY;
    startX--, startY--;

    int endX, endY;
    cin >> endX >> endY;
    endX--, endY--;

    vector<vector<char>> grid(H, vector<char>(W, '#'));
    for(int i = 0; i < H; i++)
    	for(int j = 0; j < W; j++)
    		cin >> grid[i][j];


    deque<pair<int, int>> dq{{startX, startY}};

    int result = 0;
    while(!dq.empty())
    {
    	int dqSize = dq.size();

    	// std::cout << "======RESULT: " << result << std::endl;
    	for(int i = 0; i < dqSize; i++)
    	{
    		pair<int, int> coord = dq.front();
    		dq.pop_front();

    		if(coord.first == endX && coord.second == endY)
    		{
    			std::cout << result << "\n";
    			return 0;
    		}

    		if(DFS(grid, coord.first, coord.second, dq, endX, endY))
    		{
    			std::cout << result << "\n";
    			return 0;
    		}
    	}

    	result++;
    }


    std::cout << "-1\n";


	return 0;
}

Measured memory_bytes: 6372
#include <stdio.h>

int main(){
	long long x,y;
	scanf("%lld %lld",&x,&y);

	int kaisu;
	if(x<y){
		if(x*y>=0)kaisu=y-x;
		if(x*y<0){
			if(x*-1<y)kaisu=y-x*-1+1;
			if(x*-1==y)kaisu=1;
			if(x*-1>y)kaisu=x*-1-y+1;		
		}
	}
	if(x>y){
		if(x*y>0){
			if(y>0)kaisu=x-y+2;
			if(y<0)kaisu=y*-1+x+2;
		}
		if(x*y<0){
			if(x<y*-1)kaisu=y*-1-x+1;
			if(x==y*-1)kaisu=1;
			if(x>y*-1)kaisu=x-y*-1+1;
		}
		if(x==0){
			kaisu=y*-1+1;
		}
		if(y==0){
			kaisu=x+1;
		}

	}
	printf("%d",kaisu);

}


Measured memory_bytes: 128
#include<cmath>
#include<cstdio>
#include<algorithm>

int main(){
  int s;
  long long st[100001],p[100001];
  scanf("%d",&s);
  for(int i=1;i<=s;i++){
    scanf("%lld",&st[i]);
  }
  p[0]=0;
  p[1]=0;
  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];
  for(int i=3;i<=s;i++){
    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));
  }
  printf("%lld\n",p[s]);
  return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    int n;
    int a[202020];
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    int mx1=0, mx2=-1;
    REP(i, 0, n){
        if(a[i]>mx1){
            mx2=mx1;
            mx1=a[i];
        }
        else if(a[i]>mx2){
            mx2=a[i];
        }
    }

    REP(i, 0, n){
        if(a[i]==mx1){
            cout<<mx2<<endl;
        }
        else{
            cout<<mx1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  
  char dif = 'A'-'a';
  cout << (char)(s1.at(0)+dif)
       << (char)(s2.at(0)+dif)
       << (char)(s3.at(0)+dif)
       << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int N,K,R,S,P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int point=0;
    REP(i,N){
        if(T[i]=='r'){
            point+=P;
        }else if(T[i]=='s'){
            point+=R;
        }else if(T[i]=='p'){
            point+=S;
        }
        if(i+K<=N){
            if(T[i]==T[i+K]){
                T[i+K]='n';
            }
        }
    };
    cout << point;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const ll MOD = 1e9 + 7;

int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

int main() {
  int N;
  while (cin >> N) {
    vec<int, 2> a = make_v(N, N, 0);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> a[i][j];
      }
    }
    vector<ll> dp(1 << N, 0);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
      for (int bit = (1 << (i + 1)) - 1; bit < (1 << N); bit = next_combination(bit)) {
        for (int j = 0; j < N; j++) {
          if (((bit >> j) & 1) == 1 && a[i][j] == 1) {
            (dp[bit] += dp[bit ^ (1 << j)]) %= MOD;
          }
        }
      }
    }
    cout << dp.back() << endl;
  }
  return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define P pair<int, int>
int main(){
  int h,w,n;
  cin >> h >> w >> n;
  vector<P> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  int xs = 1, ys = 0, answer = h;
  for(int i=0;i<n;i++){
    if(v[i].first >= v[i].second + xs){
      answer = v[i].first-1;
      break;
    }
    if(v[i].first == v[i].second + ys){
      xs++;
      ys++;
    }
  }
  cout << answer << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int A, B, M;
    cin >> A >> B >> M;

    vector<int> VA, VB;
    VA.resize(A);
    VB.resize(B);
    int min_a = LLINF, min_b = LLINF; 
    REP(i, A) {
         cin >> VA[i];
         chmin(min_a, VA[i]);
    }
    REP(i, B) {
         cin >> VB[i];
         chmin(min_b, VB[i]);
    }

    int ans = min_a + min_b;

    REP(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        int cand = VA[x] + VB[y] - c;
        chmin(ans, cand);
    }
    printf("%lld\n", ans);

    return 0;
}



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

using namespace std;
//DP用
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 long long INF = 1LL << 60;

int main() {
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) {
        cout << a-1 << " " << b;
    }
    if(t == u) {
        cout << a << " " << b-1;
    }
    return 0;
}



Measured memory_bytes: 256
N, K, A = map(int, input().split())
dp = [0] * (K+1) + [1] * N  # 残りが i 点のときの勝率
dp[0] = 1
c = 1
mod = 998244353
p_coin = A * pow(100, mod-2, mod) % mod
p_dice = pow(N, mod-2, mod)
for i in range(1, K+1):
    dp[i] = c * p_coin % mod
    c += (dp[i] - dp[i-N]) * p_dice % mod
print(dp[K] * pow(p_coin, mod-2, mod) % mod)



Measured memory_bytes: 10220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

// 0^1^~~^a を求める
ll calc(ll a) {
  a = a + 1;
  // 10^12 2^40
  ll ans = 0;
  // i桁目の偶奇を調べる
  for (ll i = 0; i < 50; i++) {
    // 0桁目: 周期が2 010101
    // 1桁目: 周期が4 001100110011
    ll loop = (1LL << (i+1));
    // i桁目の1の数
    ll cnt = (a/loop) * (loop/2) + max(0LL, ((a % loop) - (loop / 2)));
    if (cnt % 2 == 1) {
      ans += 1LL << i;
    }
  }
  return ans;
};

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = calc(B) ^ calc(A-1);
  cout << ans << endl;
}

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


int main(){
	int N=3;
	char s[N];
	// scanf("%s",s);
	if(scanf("%s",s)==1);
	int num=0;
	// printf("%c",s[0]);
	// printf("%c",s[1]);

	// printf("%c",s[2]);

	int a[N];
	for(int i=0;i<N;i++){
		if(s[i]=='R'){
			a[i]=1;
			num++;
		}else{
			a[i]=0;
		}
	}
	// for(int i=0;i<N;i++){
	// 	printf("%d\n",a[i]);
	// }
	// printf("num=%d\n",num );
	if(num==1||num==3){
		printf("%d\n",num);
	}else if(num==2){
		if(a[1]==1)printf("%d\n",num);
		else printf("1\n");
	}else{
		printf("0\n");
	}

}
	
// 1変数
	// int N;
	// if(scanf("%d",&N)==1);

// 2変数
	// int a[N];
	// for(int i=0;i<N;i++){
	// 	a[i]=0;
	// 	if(scanf("%d ",&a[i])==1);
	// }

//文字列
	// char s[101];
	// scanf("%s",s);

// N個の変数
	// int X[N],Y[N];
	// for(int i=0;i<N;i++){
	// 	(void)scanf("%d %d",&X[i],&Y[i]);	
	// }





// for文
	// for(int i=0;i<N;i++){

	// }

	// for(int j=0;j<N;j++){
		
	// }

Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
class dsu{
private:
    const int default_size = 100100;
    vector<int> parent;
    int size;
    int find(int vertex){
        return (parent[vertex] < 0)?vertex:parent[vertex] = find(parent[vertex]);
    }
public:
    dsu(){
        this->size = default_size;
        parent.assign(size, -1);
    }
    dsu(int size){
        this->size = size;
        parent.assign(size, -1);
    }
    void clear(){
        parent.assign(size, -1);
    }
    bool isConnected(int u, int v){
        return find(u) == find(v);
    }
    bool connect(int u, int v){
        u = find(u);
        v = find(v);
        if(u != v){
            if(-parent[u] < -parent[v]) swap(u, v);
            parent[u] += parent[v];
            parent[v] = u;
        }
        return u != v;
    }
    int componentSize(int u){
        return - parent[find(u)];
    }
    bool isRoot(int u){
        return parent[u] < 0;
    }
};

const int maxn = 55;
char grid[maxn][maxn];
int dx[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[] = {1,-1, 0, 1,-1, 0, 1, -1};
int M(){
    int n, m;
    if(!(cin >> n >> m)) return 0;
    vector<int> a(m), b(m);
    for(int e = 0; e < m; e++){
        cin >> a[e] >> b[e];
        a[e]--;
        b[e]--;
    }
    int cnt = 0;
    for(int e = 0; e < m; e++){
        dsu solver(n);
        for(int f = 0; f < m; f++) if(f != e) solver.connect(a[f], b[f]);
        int rr = 0;
        for(int f = 0; f < n; f++) if(solver.isRoot(f)) rr++;
        if(rr > 1) cnt++;
    }
    cout << cnt << endl;
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 256
sum = 0
A,B,C,X,Y = map(int,input().split())
AB = A+B
sum += min(C*2*(min(X,Y)),AB*(min(X,Y)))
Z = max(X-Y,Y-X)
if X-Y>0:
    sum += min(A*(X-Y),C*2*(X-Y))
else:
    sum += min(B*(Y-X),C*2*(Y-X))

print(sum)


Measured memory_bytes: 3060
"use strict"
function Main(stdin){
let stdout = [];

stdin = stdin.trim().split("\n");
let n = parseInt(stdin[0].split(" ")[0])
let m = parseInt(stdin[0].split(" ")[1])

let ab = [];
for (let i = 0; i < m; i++){
    ab.push(Array.from(stdin[i+1].split(" "), x => parseInt(x)))
}

let s1 = new Set();
for (let i = 0; i < m; i++){
    if (ab[i][0] === 1){ s1.add(ab[i][1]) }
}

let s2 = new Set();
for (let i = 0; i < m; i++){
    if (ab[i][1] === n){ s2.add(ab[i][0]) }
}

function intersection(setA, setB) {
    var _intersection = new Set();
    for (var elem of setB) {
        if (setA.has(elem)) {
            _intersection.add(elem);
        }
    }
    return _intersection;
}

if (intersection(s1,s2).size > 0){
    stdout.push("POSSIBLE")
}else{
    stdout.push("IMPOSSIBLE")
}


console.log(stdout.join("\n"));
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 74912
def examA():
    S = SI()
    if "W" in S and not "E" in S:
        print("No")
    elif "E" in S and not "W" in S:
        print("No")
    elif "N" in S and not "S" in S:
        print("No")
    elif "S" in S and not "N" in S:
        print("No")
    else:
        print("Yes")
    return

def examB():
    N = I()
    A = [I()for _ in range(N)]
    ans = 0
    for i in range(N-1):
        ans += A[i]//2
        if A[i]%2 and A[i+1]>=1:
            ans += 1
            A[i+1] -= 1
    ans += A[N-1]//2
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N = I()
    S = [I()for _ in range(N)]

    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 8004
/* Author : Pranav Deshmukh
            PICT,Pune
   Purpose: Practice Atcoder
*/

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define dip(type,var)   type var; cin>>var;
#define dipi(x)			int x; cin>>x;
#define w(x)            int x; cin>>x; while(x--)
#define mka(arr,n,type) type *arr=new type[n];
#define fo(i,n)			for(int i=0;i<n;i++)
#define mod             pow(10,9)+7
#define inf             1e18
#define pi 				3.141592653589793238
#define fo(i,n)        for(int i=0;i<n;i++)
#define endl			"\n"
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mimp             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if(true)
#else
#define dout if(false) cout
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define vrep(i, v) for(auto &i : v)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n,0);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int N, D;

	cin>>N>>D;

	D = D*2+1;

	int ans;
	if(N%D == 0){
		ans = N/D;
	}
	else{
		ans = N/D + 1;
	}

	cout<<ans<<endl;
	
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

int main(void){
    int N, M;
    priority_queue<int> A;
    int Abuf;

    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push(Abuf);
    }

    for(int i=0; i<M; i++){
        Abuf = A.top();
        Abuf /= 2;
        A.pop();
        A.push(Abuf);
    }

    long long Asum=0;
    for(int i=0; i<N; i++){
        Asum += A.top();
        A.pop();
    }

    cout << Asum << endl;

    return 0;
}

Measured memory_bytes: 892
H,W=map(int,input().split())
c=["#"*(W+1)]+["#"+input()+"#" for _ in range(H)]+["#"*(W+1)]
mod=10**9+7

dp=[[0]*(W+2) for _ in range(H+2)]
dp[1][1]=1

direction=[(0,-1),(0,1),(1,0),(-1,0)]
for h in range(1,H+1):
    for w in range(1,W+1):
        for x,y in direction:
            if c[h+x][w+y]==".":
                dp[h+x][w+y]=(dp[h+x][w+y]+dp[h][w])%mod

print(dp[H][W])

Measured memory_bytes: 54636
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, m;
        cin >> n >> m;
        pair<int, int> ans;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                string s;
                cin >> s;
                if(s == "snuke"){
                    ans = {i, j};
                }
            }
        }
        cout << char(ans.ss + 'A') << ans.ff + 1 << '\n';
    }
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
const ll mod = 1e9+7;
const int sz = 62;
#define afdafafafdafaf y1;
int n,m;

int main()
{
    scanf("%d", &n);
    ll x = n;
    printf("%lld\n", (x-1)*(x-0)/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,answer;
long long temp;

int main(){
 cin >> N;
 for(int i = 0; i < N; i++){
    scanf("%lld",&temp);
    while( !(temp % 2) ){
        temp /= 2;
        answer++;
    }
 }

 cout << answer <<endl;
 return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let na: i32 = read::<i32>() * n;
    let b: i32 = read();
    println!("{}", if na > b { b } else { na });
}


Measured memory_bytes: 4352
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    t = min(c, a)
    c -= t
    a -= t
    cnt += t
    t = min(c, b)
    c -= t
    b -= t
    cnt += (t * 2)
    if b > 0:
        print(cnt + b)
    else:
        print(cnt + min(c, 1))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38328
r,p=range,print
n,a,b=map(int,input().split())
if a+b>n+1or a*b<n:exit(p(-1))
l=[[]for i in r(b-1)]+[list(r(1,a+1))]
for i in r(a+1,n+1):l[-2-(i-a-1)%(b-1)].append(i)
for i in l:p(*i,end=" ")

Measured memory_bytes: 37636
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

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

	if (A == B) { cout << 1 << endl; }
	else {
		ll x = -1;
		ll y = -1;

		rep(j, 60) {
			if (((A >> j) & 1) != ((B >> j) & 1)) { x = j; }
		}

		rep(j, x) {
			if (((B >> j) & 1) == 1) { y = j; }
		}

		//cout << x << y << endl;

		ll ans = (1ull << x) - (A&((1ull << x) - 1));
		//cout << ans << endl;

		ll k = (A&((1ull << x) - 1)) >> (y + 1);

		if (k == 0) { ans += (1ull << x); }
		else {
			ans += ((1ull << (x - y - 1)) - k)*(1ull << (y + 1));
			ans += (1ull << (y + 1)) - (A&((1ull << (y + 1)) - 1));
		}
		
		cout << ans << endl;
	}
	
	system("PAUSE");

}

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

int main()
{
    string s;
    getline(cin, s);

    int i;

    for(i = 0; s[i]; i++){
        if((s[i] >= 'a') && (s[i] <= 'z')){
            cout << char(s[i] - 32);
        }else if((s[i] >= 'A') && (s[i] <= 'Z')){
            cout << char(s[i] + 32);
        }else{ cout << s[i];}
    }

    cout << endl;

    return 0;
}

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

int main() {
    string i;
    string o;
    cin >> i;
    for (int n = 0;n<i.size();n++){
        if(i[n]!= 'B'){
            o.push_back(i[n]);
        }
        else {
            if (o.size()!=0){
            o.pop_back();
            }
        }
    }
    cout << o;
}


Measured memory_bytes: 3588
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[][] p = new String[m][2];
		for(int i = 0; i < m; i++) {
			p[i][0] = sc.next();
            p[i][1] = sc.next();
		}
		int AC = 0;
		int WA = 0;
		boolean[] ac = new boolean[n];
		int [] wa = new int[n];
		for(int i = 0; i < m; i++) {
			int a = Integer.parseInt(p[i][0])-1;
			if(ac[a]) continue;
			if(p[i][1].equals("WA")) wa[a]++;
			else {
				AC++;
				WA+=wa[a];
				ac[a] = true;
			}
		}
		System.out.println(AC + " " + WA);
	}
}

Measured memory_bytes: 70876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 302, M = 1e9 + 7	;
ll n, p;
vector<pair<int, ll>>v;
int main() {
	cin >> n >> p;
	for (ll i = 2; i * i <= p; i++) {
		int c = 0;
		while (p % i == 0) {
			c++;
			p /= i;
		}
		if (c) {
			v.push_back({c, i});
		}
	}
	if (p != 1)v.push_back({1, p});
	ll ans = 1;
	for (int i = 0; i < v.size(); ++i) {
		if (v[i].first < n)continue;
		int z = v[i].first / n;
		for (int j = 0; j < z; j++) {
			ans *= v[i].second;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val S = readString()
  var flag = true
  S.forEachIndexed { index, c ->
    if (index % 2 == 0) {
      if (c != 'R' && c != 'U' && c != 'D') flag = false
    } else {
      if (c != 'L' && c != 'U' && c != 'D') flag = false
    }
  }
  println(if (flag) "Yes" else "No")
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<char> nums(N);
    int wnum = 0;
    for (int i = 0; i < N; i++){
        cin >> nums[i];
        if (nums[i] == 'W') wnum++;
    }
    int res1 = 0;
    for (int i = 0; i < N - wnum; i++) {
        if (nums[i] == 'W') res1++;
    }
    cout << res1 << endl;
    
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a;
    ll b, n;
    cin >> a >> b >> n;
    ll x = min(n, b-1);
    ll ans = a * x / b - a * (x / b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_157_a
{
        
#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int N = ReadInt();
            int ans = N / 2;
            if (N % 2 > 0)
            {
                ans++;
            }
            
            Console.WriteLine(ans.ToString());
        }

        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
#if TEST
#else
    }
}
#endif

Measured memory_bytes: 13140