akhauriyash/Code-Regression huggingface dataset:
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[MAXn];

int main()
{
    IOS();
    ll n,k;
    cin>>n>>k;
    REP(i,n)cin>>d[i];
    ll mn = INF;
    for(int i = 0; i + k <= n;i ++)
    {
        if(d[i+k-1] <= 0)mn = min(mn, abs(d[i]));
        else if(d[i] >= 0)mn = min(mn, d[i+k-1]);
        else mn = min(mn, min(abs(d[i]), d[i+k-1]) + d[i+k-1] - d[i]);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVd = V<Vd>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;

  ll sum = 0;
  for (auto c : s) sum += (c - '0');

  if (sum % 9 == 0) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3684
#include <cstdio>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)

inline int read(){
  int ans=0,c=getchar_unlocked();
  while(c<'0'||c>'9'){c=getchar_unlocked();}
  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}
  return ans;
}

int main(){
  int n;
  n=read();
  int a,count4=0,odd=0;
  rep(i,n){
    a=read();
    if(a%2){
      odd++;
    }else if(a%4==0){
      count4++;
    }
  }

  if(odd==0||odd+((n-count4-odd)?1:0)<=count4+1){
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 2001
#define int long long
using namespace std;
vector<int>G[N];
int n,K,S;
struct point{int x,y,z;};

int Area(){return S*S*6;}
int sArea(point a,point b){
  int x = min(a.x+S, b.x+S), X = max(a.x, b.x);
  int y = min(a.y+S, b.y+S), Y = max(a.y, b.y);
  int z = min(a.z+S, b.z+S), Z = max(a.z, b.z);
  if(y <= Y || x <= X || z <= Z) return 0;
  int area=0;
  area += 2*(x-X)*(y-Y);
  area += 2*(y-Y)*(z-Z);
  area += 2*(z-Z)*(x-X);
  return area;
}

vector<point> A;
int dfs(int pos,int k,int start,int prev){
  if(prev!=-1 && pos==start) return 1LL<<55;
  if(k == K) return prev==-1||prev==start? 0:-sArea(A[pos],A[start]);
  
  int res = 1e9;
  for(int nx:G[pos]){
    if(nx == prev)continue;
    int area = Area() - sArea(A[pos],A[nx]);
    res = min(res,area+dfs(nx,k+1,start,pos));
  }
  return res;
}

signed main(){
  while(1){
    cin>>n>>K>>S;
    if(!n&&!K&&!S)break;
    
    A.resize(n);
    for(int i=0;i<n;i++)cin>>A[i].x>>A[i].y>>A[i].z;
    
    for(int i=0;i<N;i++) G[i].clear();

    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	if(!sArea(A[i],A[j]))continue;
	G[i].push_back(j);
	G[j].push_back(i);
      }

    int ans = 1e9;
    for(int i=0;i<n;i++)ans = min(ans,Area()+dfs(i,1,i,-1));
    if(ans == 1e9) ans = -1;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3036
#include<stdio.h>

int main(void){
  int n,i,count,coin[6]={500,100,50,10,5,1};

  while(scanf("%d",&n),n){
    for(i=0,count=0,n=1000-n;i<6;i++)
      while(n-coin[i]>=0){
	n-=coin[i];
	count++;
      }
    printf("%d\n",count);
  }
  return 0;
}

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

const double PI = acos(-1);
struct L{
	double rad;
	int A, B;
	bool operator < (const L& x) const{
		return rad < x.rad;
	}
};

double sum[100];
using P = complex<double>;
P p[100];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		double x, y;
		cin >> x >> y;
		p[i] = P(x, y);
	}

	int cnt[100] = { 0 };
	vector<L> ls;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			P c = (p[i] + p[j]) / 2.0;
			P p1 = p[i] - c, p2 = p[j] - c;
			double rad1 = atan2(p1.imag(), p1.real());
			while(rad1 < 0) rad1 += 2 * PI;
			double rad2 = atan2(p2.imag(), p2.real());
			while(rad2 < 0) rad2 += 2 * PI;

			double dx = p1.real() - p2.real();
			double dy = p1.imag() - p2.imag();
			double t = dy / dx;
			double rad = atan(t);
			while(rad < 0) rad += 2 * PI;
			if(rad >= PI) rad -= PI;

			assert(0 <= rad && rad < PI);
			if(rad1 < rad2){
				ls.push_back({ rad, i, j });
				ls.push_back({ rad + PI, j, i });
				cnt[j]++;
			}
			else{
				ls.push_back({ rad, j, i });
				ls.push_back({ rad + PI, i, j });
				cnt[i]++;
			}
		}
	}
	sort(ls.begin(), ls.end());

	double r = 0;
	for(auto l : ls){
		{
			int idx = min_element(cnt, cnt + N) - cnt;
			double diff = abs(r - l.rad);
			sum[idx] += diff;
		}

		cnt[l.B]--;
		cnt[l.A]++;
		r = l.rad;
	}
	{
		int idx = min_element(cnt, cnt + N) - cnt;
		double diff = 2 * PI - r;
		sum[idx] += diff;
	}

	for(int i = 0; i < N; i++){
		cout << fixed << setprecision(15) << sum[i] / (2 * PI) << endl;
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <string>

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

using namespace std;
typedef long long ll;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,string> > vp(M);
  rep(i,M) cin >> vp[i].first >> vp[i].second;

  int AC[N+10]={}, WA[N+10]={}, Done[N+10]={};
  rep(i,M){
    int f=vp[i].first;
    string s=vp[i].second;
    if(Done[f]==0){
      if(s=="AC"){
	AC[f]++;
	Done[f]++;
      }
      else if(s=="WA"){
	WA[f]++;
      }
    }
  }
  int ac=0, wa=0;
  rep(i,N+10){
    if(AC[i]!=0){
      ac += AC[i];
      wa += WA[i];
    }
  }
  cout << ac << " " << wa << endl;
}


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

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

const int INF = 1000000;
int N, X, Y;
int dist[2000][2000];
queue<int> que;
int ans[2000] = {0};


void bfs(int i) {
  que.push(i);
  dist[i][i] = 0;

  while(que.size()) {
    int p = que.front();
    que.pop();

    if(p != X-1 && p != Y-1) {
      int di[2] = {-1, 1};

      for(int t = 0; t < 2; t++) {
        int ni = p + di[t];
        if(0 <= ni && ni < N && dist[i][ni] > dist[i][p] + 1) {
          dist[i][ni] = dist[i][p] + 1;
          que.push(ni);
          ans[dist[i][ni]] += 1;
        }
      }

    } else if(p == X - 1) {
      int ni[3] = {p + 1, p - 1, Y - 1};
      for(int t = 0; t < 3; t++) {
        if(0 <= ni[t] && ni[t] < N && dist[i][ni[t]] > dist[i][p] + 1) {
          dist[i][ni[t]] = dist[i][p] + 1;
          que.push(ni[t]);
          ans[dist[i][ni[t]]] += 1;
        }
      }
    } else if(p == Y - 1) {
      int ni[3] = {p + 1, p - 1, X - 1};
      for(int t = 0; t < 3; t++) {
        if(0 <= ni[t] && ni[t] < N && dist[i][ni[t]] > dist[i][p] + 1) {
          dist[i][ni[t]] = dist[i][p] + 1;
          que.push(ni[t]);
          ans[dist[i][ni[t]]] += 1;
        }
      }
    }


    
  }

}


int main() {
  cin >> N >> X >> Y;

  rep(i, N) {
    rep(j, N) {
      dist[i][j] = INF;
    }
  }

  for(int i = 0; i < N; i++) {
    bfs(i);
  }

  for(int i = 1; i < N; i++) {
    cout << ans[i] / 2 << endl;
  }

  return 0;
}

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

int main(){
    ll n,m,s=0,ans=0;
    cin >> n >> m;
    map<ll,ll> mp;
    for(int i = 0;i < n;i ++){
        ll a,b;
        cin >> a >> b;
        mp[a] += b;
    }
    for(auto ite = mp.begin();ite != mp.end();++ite){
        if(s+ite->second<m){
            s += ite->second;
            ans += ite->first*ite->second;
        }else{
            ans += ite->first*(m-s);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
n, k = map(int, input().split())
p = list(map(int, input().split()))

tmp_sum = sum(p[0:k])
ans = (tmp_sum + k) / 2
count = float(0)
for i in range(k, n):
    tmp_sum = tmp_sum + p[i] - p[i - k]
    tmp = (tmp_sum + k) / 2
    if ans <= tmp:
        ans = tmp

print(ans)


Measured memory_bytes: 71792
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
h=[0]*n
for i in range(n):
    h[i]=int(input())
h.sort()
#print(h)
ans=10**10
for i in range(n-k+1):
    if ans>h[i+k-1]-h[i]:
        ans=h[i+k-1]-h[i]
print(ans)

Measured memory_bytes: 7472
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define ld long double
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;

ll mode=pow(10,9)+7;
bool cmp(pair<ll,ll> x, pair<ll, ll> y){
	return x.S<y.S;
}


int main(){ 
    
//    #ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	#endif
//	
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	string s;
	cin>>s;
	ll n;
	n=s.size();
	ll ans=0, l=0, r=n-1;
	for (int i=0;i<n/2;i++){
		if (s[l]!=s[r]){
			ans++;
		}
		l++;
		r--;
	}
	
	cout<<ans<<endl;
	
 	return 0;
}

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

int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  rep(i1,n){
    rep(i2,n){
      int l = 0;
      if(!(i2 > i1)) continue;
      rep(j,d){
        l += (x[i1][j] - x[i2][j])*(x[i1][j] - x[i2][j]);
      }
      rep(k,180){
        if(l == k*k) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int a[110];
int cnt[110];

bool solve(){
	sort(a, a + N);
	if(N == 2){
		if(a[0] == 1 && a[1] == 1) return true;
		return false;
	}
	
	for(int i = 0; i < N; ++i) cnt[i] = 0;
	for(int i = 0; i < N; ++i) cnt[a[i]]++;
	int d = a[N - 1];
	for(int i = 0; i <= d; ++i){
		int x = max(i, d - i);
		cnt[x]--;
		if(cnt[x] < 0) return false;
	}
	int m = (d + 3) / 2;
	for(int i = 0; i < m; ++i) if(cnt[i] > 0) return false;
	return true;
}

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", a + i);
}

int main(){
	input();
	bool flg = solve();
	if(flg) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if (N <= K) cout << N * X << endl;
	else if (N > K) cout << K * X + (N - K) * Y << endl;
	return 0;
}


Measured memory_bytes: 256
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)


import sys
import numpy as np


def solve(H, W, AB):
    A = W+1
    identity = -(1<<62)
    sqrtA = 256
    n_buckets = A//sqrtA+1
    Data = np.zeros(n_buckets*sqrtA, dtype=np.int64)
    Data[0] = 1<<30
    Data[W+1:] = 1<<30
    Bucket_min = np.zeros(n_buckets, dtype=np.int64)
    Lazy = np.full(n_buckets, identity, dtype=np.int64)

    def eval_data(k):
        if Lazy[k] != identity:
            l, r = k*sqrtA, (k+1)*sqrtA
            for i in range(l, r):
                Data[i] = i-Lazy[k]
            Lazy[k] = identity

    def update(s, t, x):
        for k in range(s//sqrtA, (t-1)//sqrtA+1):
            l, r = k*sqrtA, (k+1)*sqrtA
            if s <= l and r <= t:
                Bucket_min[k] = l-x
                Lazy[k] = x
            else:
                eval_data(k)
                for i in range(max(l, s), min(r, t)):
                    Data[i] = i-x
                Bucket_min[k] = Data[l:r].min()

    def get(i):
        k = i//sqrtA
        eval_data(k)
        return Data[i]

    Ans = np.zeros(H, dtype=np.int64)
    for i in range(H):
        a, b = AB[i]
        update(a, b+1, a-1-get(a-1))
        ans = Bucket_min.min()
        Ans[i] = ans+i+1 if ans < 1<<25 else -1

    return Ans


numba_compile([
    [solve, "i8[:](i8,i8,i8[:,:])"]
])


def main():
    H, W = map(int, sys.stdin.buffer.readline().split())
    AB = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(H, 2)
    Ans = solve(H, W, AB)
    print("\n".join(map(str, Ans.tolist())))


main()


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

typedef long long ll;
typedef complex<double> Vec;

ll N, M;
vector<vector<ll>> New;
multiset<ll, greater<ll>> Now;
ll R;

int main() {
  cin >> N >> M;
  New.resize(M);
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    if (a >= M) continue;
    New[a].push_back(b);
  }
  for (ll i = 0; i < M; ++i) {
    for (ll b : New[i]) Now.insert(b);
    if (Now.empty()) continue;
    auto it = Now.begin();
    R += *it;
    Now.erase(it);
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int n,k;
typedef long long ll;
const ll MOD=1e9+7;
ll d[2003][2003];
int main(){
	d[1][1]=1; 
	for (int i=2;i<=2000;i++){
		for (int j=1;j<=i;j++) d[i][j]=(d[i-1][j]+d[i-1][j-1])%MOD;
	}
	cin>>n>>k;
	if (k==n){
		cout<<1<<"\n";
		for (int i=2;i<=k;i++) cout<<0<<"\n";
		return 0;
	}
	for (int i=1;i<=k;i++){
		ll res=0;
		if (n-k>=i+1)res+=d[n-k][i+1];
		if (i>=2 && n-k>=i-1)res+=d[n-k][i-1];
		if (n-k>=i) res+=d[n-k][i]*2;
		cout<<res%MOD*d[k][i]%MOD<<"\n";
	}
}

Measured memory_bytes: 30080
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  
  int w,h;
  cin >> w >> h;
  int wl[1501]={},hl[1501]={};
  int wb,hb;
  int i,j,k;
  while(w!=0){
    for(i=0;i<w;i++) {
      cin >> wb;
      wl[i+1]=wl[i]+wb;
      
    }
    for(i=0;i<h;i++) {
      cin >> hb;
      hl[i+1]=hl[i]+hb;
    }
    vector <int> ws,hs;
    
    for(i=0;i<=w;i++){
      for(j=i+1;j<=w;j++){
	ws.push_back(wl[j]-wl[i]);
      }
    }
    for(i=0;i<=h;i++){
      for(j=i+1;j<=h;j++){
	hs.push_back(hl[j]-hl[i]);
      }
    }
    
    sort(ws.begin(),ws.end());
    sort(hs.begin(),hs.end());
    /*
    for(i=0;i<ws.size();i++) cout << ws[i] << ",";
    cout << endl;
    for(i=0;i<hs.size();i++) cout << hs[i] << ",";
    cout << endl;
    */
    int wc=0,hc=0;
    int x,y;
    int o=0;
    while(!(wc>=ws.size()||hc>=hs.size())){
      
      if(ws[wc]==hs[hc]){
	x=0;y=0;
	while(ws[wc+x]==ws[wc]&&wc+x<ws.size()) x++;
	while(hs[hc+y]==hs[hc]&&hc+y<hs.size()) y++;
	//cout << x*y << endl;
	o+=x*y;
	wc+=x;hc+=y;
      }else if(ws[wc]>hs[hc]){
	while(ws[wc]>hs[hc]&&hc<hs.size()) hc++;
      }else{
	while(ws[wc]<hs[hc]&&wc<ws.size()) wc++;
      }
      //cout << wc<<":"<<hc<<endl;
    }
    cout << o << endl;
    
    cin >> w >> h;
  }
  return 0;
}

Measured memory_bytes: 19924
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
     
    int main() 
    { 
         ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        ll a, b;
        ll a2=0,b2=0;
        cin>>a>>b;
        for (int i = 0; i < 10000; i++) 
        {
          a2=i*.08;
          b2=i*.1;
          if(a2==a && b2==b)
          {
              cout<<i<<endl;
              return 0;
          }
        }
     
           cout<<-1<<endl;
    }

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

const int MOD=1000000007;

typedef vector<ll>vec;
typedef vector<vec>mat;

mat mul(mat&a, mat&b) {
	mat c(a.size(), vec(b[0].size()));
	rep(i, a.size())rep(j, b[0].size())rep(k, b.size())
		(c[i][j] += a[i][k] * b[k][j]) %= MOD;
	return c;
}
mat ppow(mat a, ll b) {
	mat res(a.size(), vec(a.size()));
	rep(i, a.size())res[i][i] = 1;
	while (b) {
		if (b & 1)res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int s[2000],t[200],f[200];
int main(){
	int n,m;ll d;cin>>n>>m>>d;
	rep(i,n)scanf("%d",&s[i]);
	rep(i,n)scanf("%d",&t[i]);
	rep(i,m)scanf("%d",&f[i]);
	mat A(n+m+1,vec(n+m+1));
	rep(i,n){
		A[i][(i+1)%n]=1;
	}
	rep(i,m){
		A[i+n][n+(i+1)%m]=1;
	}
	rep(i,n){
		A[n+m][i]=t[i];
	}
	A[n+m][n+m]=1;
	A[n-1][n]=1;
	mat B(n+m+1,vec(1));
	rep(i,n)B[i][0]=s[i];
	rep(i,m)B[n+i][0]=f[i];
	auto res=ppow(A,d);
	res=mul(res,B);
	cout<<res[n+m][0]<<endl;
}


Measured memory_bytes: 3436
#include <stdio.h>
#include <algorithm>
using ll = long long;
int main() {
	int n, m;
	scanf("%d %d", &n, &m);

	ll time = (n - m) * 100 + m * 1900;
	time *= 0x1 << m;

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

Measured memory_bytes: 128
// Example program
#include <iostream>

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 1;

int a[MAXN];

int main()
{
    ll n;
    cin >> n;
    ll cnt = 0;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        if (x != 0)
            a[x - 1]++;
        a[x]++;
        a[x + 1]++;
    }
    for (int i = 0; i < MAXN; i++)
        if (a[i] > cnt)
            cnt = a[i];
    cout << cnt;
}


Measured memory_bytes: 640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	string s;
	int w;
	cin >> s >> w;
	for (int i = 0; i < s.size(); i += w)
		cout << s[i];
	cout << "\n";
	return 0;
}




Measured memory_bytes: 256
s=input()
n=len(s)
if n>9 or n<5:
    print("NO")
else:
    ans="NO"
    if n==5:
        if s=="KIHBR":
            ans="YES"
    elif n==6:
        if s=="AKIHBR" or s=="KIHABR" or s=="KIHBAR" or s=="KIHBRA":
            ans="YES"
    elif n==7:
        if s=="AKIHABR" or s=="AKIHBAR" or s=="AKIHBRA" or s=="KIHABAR" or s=="KIHABRA" or s=="KIHBARA":
            ans="YES"
    elif n==8:
        if s=="KIHABARA" or s=="AKIHBARA" or s=="AKIHABRA" or s=="AKIHABAR":
            ans="YES"
    else:
        if s=="AKIHABARA":
            ans="YES"
    print(ans)


Measured memory_bytes: 38384
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    var letters = input[1].split('')
    const find = "ABC"
    var count = 0
 
	//文字列から10進数に変換するときはparseIntを使います
	for(var i = 0; i < letters.length; i++) {
      if(letters[i] === 'A') {
        if(letters[i+1] === 'B' && letters[i+2] ==='C') {
          count++
        }
      }
    }
	//出力
	console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int> > G(n);
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> ans(n);
	vector<bool> used(n);
	used[0] = true;
	int cnt = 1;
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (auto e : G[v]) {
			if (used[e]) continue;
			ans[e] = v + 1;
			used[e] = true;
			++cnt;
			q.push(e);
		}
	}
	if (cnt == n) {
		cout << "Yes" << endl;
		for (int i = 1; i < n; ++i) cout << ans[i] << endl;
	} else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 10128
using System;
using System.Linq;
class Program {
	static void Main() {
		while(true) {
			int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = b[0], m = b[1];
			if(n == 0 && m == 0) break;
			int[] x = new int[n];
			for(int i = 0; i < n; i++) x[i] = int.Parse(Console.ReadLine());
			int[] c = new int[m];
			for(int i = 0; i < m; i++) c[i] = int.Parse(Console.ReadLine());
			int pos = 0;
			for(int i = 0; i < m; i++) {
				pos += c[i];
				if(pos >= n - 1) {
					Console.WriteLine(i + 1);
					break;
				}
				pos += x[pos];
				if(pos >= n - 1) {
					Console.WriteLine(i + 1);
					break;
				}
			}
		}
	}
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long D, std::vector<long long> c,
           std::vector<std::vector<long long>> s,
           std::vector<long long> t)
{
  ll manzoku = 0;
  vec<ll> last(26,0);
  rep(d,D){
    manzoku += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(i,26){
      manzoku -= c[i]*(d+1-last[i]);
    }
    cout << manzoku << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long D;
  std::cin >> D;
  std::vector<long long> c(26);
  for (int i = 0; i < 26; i++) {
    std::cin >> c[i];
  }
  std::vector<std::vector<long long>> s(D, std::vector<long long>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      std::cin >> s[i][j];
    }
  }
  std::vector<long long> t(D);
  for (int i = 0; i < D; i++) {
    std::cin >> t[i];
  }
  solve(D, std::move(c), std::move(s), std::move(t));
  return 0;
}


Measured memory_bytes: 3744
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EStringsOfImpurity solver = new EStringsOfImpurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class EStringsOfImpurity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            String y = in.next();
            ArrayList<Integer> a[] = new ArrayList[26];
            for (int i = 0; i < 26; i++) a[i] = new ArrayList<Integer>();
            for (int i = 0; i < x.length(); i++) a[x.charAt(i) - 'a'].add(i);
            int j = -1;
            long count = 0;
            for (int i = 0; i < y.length(); i++) {
                if (a[y.charAt(i) - 'a'].size() == 0) {
                    out.println(-1);
                    return;
                }
                int p = CustomList.upperBound(a[y.charAt(i) - 'a'], 0, a[y.charAt(i) - 'a'].size(), j);
                if (p == a[y.charAt(i) - 'a'].size()) {
                    count += x.length();
                    j = a[y.charAt(i) - 'a'].get(0);
                } else {
                    j = a[y.charAt(i) - 'a'].get(p);
                }

            }
            count += j + 1;
            out.println(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }

    static class CustomList {
        public static int upperBound(List<Integer> a, int low, int high, int element) {
            while (low < high) {
                int middle = low + (high - low) / 2;
                if (a.get(middle) > element)
                    high = middle;
                else
                    low = middle + 1;
            }
            return low;
        }

    }
}



Measured memory_bytes: 29744
n = int(input())

for i in range(n):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
    v0 = (x1 - x0, y1 - y0)
    v1 = (x3 - x2, y3 - y2)

    dot = v0[0] * v1[0] + v0[1] * v1[1]
    cross = v0[0] * v1[1] - v0[1] * v1[0]

    if dot == 0:
        print(1)
    elif cross == 0:
        print(2)
    else:
        print(0)


Measured memory_bytes: 5620
#include<stdio.h>
int main()
{
	int a,b,c;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF)
	{
		if(a==b&&a==c)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
		
} 

Measured memory_bytes: 128
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i

suma = []
sumb = []
sum = []
n.times do |i|
	suma[i] = a[0..i].inject(:+)
	sumb[i] = b[i..-1].inject(:+)
	sum[i] = suma[i] + sumb[i]
end

puts sum.max


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define ll long long int

int main(){
	int n;
	scanf("%d", &n);
	char a[n+5];
	scanf("%s", &a);
	if(n%2==1) printf("No\n");
	else{
		if(!strncmp(a, a+n/2, n/2)) printf("Yes\n");
		else printf("No\n");
	}
}

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

int main() {
  long long max_diff = -1E10;
  long long min_price = 1E10;
  long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long price;
    cin >> price;
    long long curr_diff = price - min_price;
    if (price < min_price) {
      min_price = price;
    }
    if (curr_diff > max_diff) {
      max_diff = curr_diff;
    }
  }
  cout << max_diff << endl;
}

Measured memory_bytes: 3108
#include <cstdio>

int main()
{
    long a, b;
    long m, n, temp;

    while (scanf("%ld %ld", &a, &b) != EOF) {
        if (a < b) {
            temp = a;
            a = b;
            b = temp;
        }
        m = a;
        n = b;

        while (n != 0) {
            temp = n;
            n = m % n;
            m = temp;
        }

        printf("%ld %ld\n", m, a / m * b);
    }

    return 0;
}

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


using namespace std;
int fv [100000];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 100; ++ i) {
        for (int j = 1; j <= 100; ++ j) {
            for (int k = 1; k <= 100; ++ k) {
                int sum = i * i + j * j + k * k + i * j + i * k + j * k;
                if (sum <= 10000)
                    fv[sum] += 1;
            }
        }
    }
    for (int i = 1; i <= n; ++ i) {
        cout << fv[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS
    //io_set();
    ll i,n,f=1,st,e;
    string a;
    cin>>a; 
    n=a.size();
    for(i=1;i<n;i++){
        if(a[i]==a[i-1]){
            st=i-1,e=i;
            f=0;
            break;
        }
    }
    if(f){
        for(i=2;i<n;i++){
            if(a[i] == a[i-2]){
                st=i-2,e=i;
                f=0;
                break;
            }
        }
    }
    if(f){
        cout<<"-1 -1\n";
    }
    else{
        cout<<st+1<<" "<<e+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(C, B / A) << endl;

    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        vector<int> key(n);
        for(int i=0;i<n;i++)cin >> key[i];
        string code;
        cin >> code;
        int c=0;
        string ans;
        for(int i=0;i<code.length();i++){
            char temp;
            temp=code[i];
            if(temp>'Z')temp-=6;
            temp-='A';
            temp=(52+temp-key[c])%52+'A';
            if(temp>'Z')temp+=6;
            ans.push_back(temp);
            c++;
            if(c==n)c=0;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3172
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


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


const long long INF = 1e12;

void solve() {
    int N, W; cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N, vector<long long>(100001, INF));

    dp[0][v[0]] = w[0];

    for (int i = 0; i < N; i++) {
        dp[i][0] = 0;
    }

    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= 100000; j++) {
            chmin(dp[i][j], dp[i-1][j]);
            if (j - v[i] >= 0) {
                if (dp[i-1][j-v[i]] == INF) continue;
                chmin(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }

    long long ans = 0;
    for (int i = 100000; i >= 0; i--) {
        if (dp[N-1][i] <= W) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 82460
import math

def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

a,b,c = miinps()
r = (c-a-b)
if r < 0:
  print("No")
  exit()
r = r**2
l = 4*a*b
if l < r:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2000005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    ll ans = 0,sa = INF;
    rep(i,n){
        if (a[i] > b[i]){
            chmin(sa,b[i]);
        }
        ans += a[i];
    }
    if (sa == INF) PRINT(0);
    else PRINT(ans-sa);
}


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

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

int main(){

	ll k;
	cin>>k;
	ll sum = 0;
	f(i,k){
		f(j,k){
			f(t,k){
				sum = sum + solve(i,j,t);
			}
		}
	}
	cout<<sum;
	

}

Measured memory_bytes: 3628
use proconio::input;

fn main() {
  input! {
    r: [i64; 4],
  }
  let mut ans = r[0] * r[3];
  for i in 0..2 {
    for j in 2..4 {
      let mut x = r[i] * r[j];
      if ans < x { ans = x; }
    }
  }
  
  println!("{}", ans);
}

Measured memory_bytes: 2128
until(s=gets.gsub(/\d+/){|k|?1*k.hex})[?#]
n=1+s.index(?/)
eval"s[n*c-n+e-1]=?1;s[n*g-n+i-1]=?bdfh".tr('c-i',gets)
$><<s.gsub(/1+/,&:size)
end

Measured memory_bytes: 8812
a1,a2,a4=0,0,0

for i in range(1):
    # Start Input code ---------------------------------------
    
    h,w=map(int,input().split())
    n=int(input())
    a=list(map(int,input().split()))
    ser=[]
    for i in range(len(a)):
        for j in range(a[i]):
            ser.append(i+1)

k=1
for i in range(h):
    ans=ser[i*w:(i+1)*w]
    if k==-1:
        ans=ans[::-1]
    print(*ans)
    k*=-1


Measured memory_bytes: 42224
p = Array.new(120, 0)
n = gets.to_i
for i in 1..n do
  a = gets.split(" ").map{|x| x.to_i}
  b = a[0] - 1
  f = a[1] - 1
  r = a[2] - 1
  v = a[3]
  idx = b * 30 + f * 10 + r
  p[idx] += v
end
for b in 0..3 do
  for f in 0..2 do
    for r in 0..9 do
      idx = b * 30 + f * 10 + r
      printf " %d", p[idx]
    end
    puts
  end
  puts "#" * 20 if b < 3
end


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll min=a*(n-1)+b;
    ll max=b*(n-1)+a;
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(n==1&&a!=b){cout<<0<<endl;return 0;}
    if(n==1&&a==b){cout<<1<<endl;return 0;}
    cout<<max-min+1<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=1e5+6;
typedef long long LL;
int n,head[N],cnt,nod,sz[N],mxd[N],rt;
LL dis[N];
struct edge{
	int to,nxt,w;
}e[N<<1];
LL ans,mn=0x3fffffffffffffff;
void getrt(int now,int pre){
	sz[now]=1;
	for(int i=head[now];i;i=e[i].nxt)
	if(e[i].to!=pre){
		getrt(e[i].to,now);
		sz[now]+=sz[e[i].to];
		if(mxd[now]<sz[e[i].to])mxd[now]=sz[e[i].to];
	}
	if(mxd[now]<n-sz[now])mxd[now]=n-sz[now];
	if(!rt||mxd[now]<mxd[rt])rt=now;
}
void dfs(int now,int pre){
	sz[now]=1;
	for(int i=head[now];i;i=e[i].nxt)
	if(e[i].to!=pre){
		dis[e[i].to]=dis[now]+e[i].w;
		dfs(e[i].to,now);
		sz[now]+=sz[e[i].to];
	}
}
inline void update(LL x,LL y){ans+=x+y;}
int main(){
	scanf("%d",&n);
	for(int i=1,u,v,w;i<n;++i){
		scanf("%d%d%d",&u,&v,&w);
		e[++cnt]=(edge){v,head[u],w},head[u]=cnt;
		e[++cnt]=(edge){u,head[v],w},head[v]=cnt;
	}
	getrt(1,0);
	for(int i=head[rt];i;i=e[i].nxt){
		dis[e[i].to]=e[i].w;
		if(e[i].w<mn)mn=e[i].w;
		dfs(e[i].to,rt);
	}
	for(int i=head[rt];i;i=e[i].nxt)if(sz[e[i].to]==(n+1)/2)mn=e[i].w;
	for(int i=1;i<=n;++i)ans+=2*dis[i];
	printf("%lld\n",ans-mn);
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// verified : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// 負辺があると動作しない?
// O(E log V)

// verified : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// 負辺があると動作しない?
// O(E log V)
//

int hoge[100001];

template<typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, int s){
     
  int n = g.size();
  // numeric_limits がうまく使えない場合は自分で INF を定義する.
  const auto inf = numeric_limits<T>::max();
  vector<T> dist(n, inf);

  using P = pair<T, int>;
  // 小さい順に取り出せる
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()){
    T cost;
    int node;
    tie(cost, node) = que.top();
    que.pop();
    if(dist[node] < cost) continue;
    for(auto &e : g[node]){
      auto next_cost = cost + e.second;
      int next_node = e.first;
      if(dist[next_node] <= next_cost) continue;
      dist[next_node] = next_cost;
      hoge[next_node] = node;
      que.emplace(next_cost, next_node);
    }
  }

  return dist;
}

int main() {
  
  int n, m; cin >> n >> m;
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    a--;
    b--;
    g[a].push_back({b, 1});
    g[b].push_back({a, 1});
  }

  auto ans = dijkstra(g, 0);
  for (int i = 0; i < n; i++) {
    if (ans[i] > n + 10) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << hoge[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 13644
#include<stdio.h>
int main(void)
{
	int array1[100][100],i,j,r,c;
	static int array2[100],a=0;
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&array1[j][i]);
			array2[j]+=array1[j][i];
		}
	}
		for(i=0;i<=r;i++){
			for(j=0;j<=c;j++){
				if(i<r){
					if(j<c){
						printf("%d ",array1[j][i]);
						a+=array1[j][i];
					}else{
						printf("%d\n",a);
						a=0;
					}
				}else{
					if(j<c){
						printf("%d ",array2[j]);
						a+=array2[j];
					}else{
						printf("%d\n",a);
					}
				}
			}
		}
		return 0;
	}

Measured memory_bytes: 2684
import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1

la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = 0
    cntb[ib] = 0

if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
else:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)


Measured memory_bytes: 38504