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

int a[100005], n, b;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++) scanf("%d", a+i);
	sort(a, a+n); b = a[0];
	for (int i = 1;i < n-1;i++) if (abs(a[i]*2-a[n-1]) < abs(b*2-a[n-1])) b = a[i];
	printf("%d %d\n", a[n-1], b);
	return 0;
}


Measured memory_bytes: 640
//
// Created on 2020/05/07.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    double ans;
    int ok = 0;
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    ans = w*h/2;
    if(x == w/2 && y == h /2) ok = 1;

    printf("%.10f", ans);
    cout<<" "<<ok<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int n,tmp,sum=0;
    scanf("%d",&n);
    int l[2*n];
    for(int i=0;2*n>i;++i)
    scanf("%d",&l[i]);
    for(int i=0;2*n>i;++i){
        for(int j=i+1;2*n>j;++j){
            if(l[i]>l[j]){
                tmp=l[i];
                l[i]=l[j];
                l[j]=tmp;
            }
        }
    }
    for(int i=0;2*n>i;i+=2)
    sum+=l[i];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

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

const int INF = 1<<29;

bool check(string &s, string &t){
	for(int k = 0; k < t.size(); k++){
		for(int i = 0; k+i*2+3 <= t.size(); i++){
			bool ok = true;
			for(int j = 0; j < s.size(); j++){
				if(s[j] != t[k+j*(i+1)]){
					ok = false;
					break;
				}
			}
			if(ok) return true;
		}
	}

	return false;
}

int main(){
	int N;
	cin >> N;
	string name;
	cin >> name;

	int ans = 0;
	rep(i, N){
		string s;
		cin >> s;
		ans += check(name, s);
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int P, Q, R,ans=1e9; cin >> P >> Q >> R;
	ans = min(ans, P + Q);
	ans = min(ans, P + R);
	ans = min(ans, R + Q);
	cout << ans << endl;
}




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

using namespace std;

const int P = 1000000007;

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

	int n;
	cin >> n;

	vector<vector<int> > G;
	G.resize(n);

	for(int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;

		--a;
		--b;

		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	vector<long long> dp;
	dp.resize(n);

	vector<long long> fac;
	fac.resize(n + 1);
	
	fac[0] = 1;

	for(int i = 1; i < n + 1; ++i) {
		fac[i] = fac[i - 1] * i % P;
	}
	
	auto power = [&] (long long x, long long t) {
		long long ret = 1;
		
		for(; t; t >>= 1, x = x * x % P) {
			if(t & 1) {
				ret = ret * x % P;
			}
		}

		return ret;
	};

	vector<int> sz;
	sz.resize(n);

	function<void(int, int)> pre = [&] (int u, int f) {
		dp[u] = 1;	
		sz[u] = 1;

		for(auto v : G[u]) {
			if(v != f) {
				pre(v, u);

				dp[u] = dp[u] * dp[v] % P;
				dp[u] = dp[u] * power(fac[sz[v]], P - 2) % P;
				sz[u] += sz[v];
			}
		}

		dp[u] = dp[u] * fac[sz[u] - 1] % P;
	};

	vector<long long> ans;
	ans.resize(n);

	pre(0, -1);

	function<void(int, int, long long)> dfs = [&] (int u, int f, long long up) {
		ans[u] = 1;

		for(auto v : G[u]) {
			if(v != f) {
				ans[u] = ans[u] * dp[v] % P;
				ans[u] = ans[u] * power(fac[sz[v]], P - 2) % P;
			}
		}

		ans[u] = ans[u] * up % P;
		ans[u] = ans[u] * power(fac[n - sz[u]], P - 2) % P;
		ans[u] = ans[u] * fac[n - 1] % P;

		for(auto v : G[u]) {
			if(v != f) {
				long long tmp = ans[u];

				tmp = tmp * power(dp[v], P - 2) % P;
				tmp = tmp * fac[sz[v]] % P;
				tmp = tmp * power(fac[n - 1], P - 2) % P;
				tmp = tmp * fac[n - sz[v] - 1] % P;

				dfs(v, u, tmp);
			}
		}
	};

	dfs(0, -1, 1);

	for(auto x : ans) {
		cout << x << '\n';
	}

	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<pair<int, int> > ret;
  vector<int> p(N+1);
  if(N % 2 == 1){
  	for(int i = 1; i < N; i++){
      p[i] = N - i;
    }
    p[N] == -1;
  }else{
    for(int i = 1; i <= N; i++){
      p[i] = N - i + 1;
    }
  }
  
  for(int i = 1; i <= N; i++){
    for(int j = i + 1; j <= N; j++){
      if(j != p[i]) ret.push_back(make_pair(i, j));
    }
  }
  
  cout << ret.size() << endl;
  for(auto e: ret){
    cout << e.first << ' ' << e.second << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,a[50],sum=0,j;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum+=a[i]*a[j];
        }
    }
    cout << sum;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int W, a, b;
    cin >> W >> a >> b;
    if ((a <= b && b <= a + W) || (b <= a && a <= b + W))
        cout << 0;
    else if (a + W < b)
        cout << b - (a + W);
    else if (b + W < a)
        cout << a - (b + W);
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<vector<long>> score(N, vector<long>(N));
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
		{
			cin >> score[i][j];
		}

	vector<long> dp(1<<N);

	for (int s = 0; s < 1<<N; s++)
		for (int i = 0; i < N-1; i++)
			for (int j = i+1; j < N; j++)
			{
				if (s >> i & 1 && s >> j & 1)
				{
					dp[s] += score[i][j];
				}
			}

	for (int s = 0; s < 1<<N; s++)
	{
		for (int t = s; t; t = (t-1)&s)
		{
			dp[s] = max(dp[s], dp[t]+dp[s^t]);
		}
	}
	cout << dp.back() << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
  unordered_map<char,char> m = {
    {'A','T'},
    {'T','A'},
    {'C','G'},
    {'G','C'}
  };
  char in;
  
  cin >> in;
  if(m.find(in) == m.end()) cout << "" << endl;
  else cout << m[in] << endl;

  return 0;
  
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    unsigned a, b; cin >> a >> b;
    cout << bitset<32>(a & b) << "\n";
    cout << bitset<32>(a | b) << "\n";
    cout << bitset<32>(a ^ b) << endl;
    return 0;
}



Measured memory_bytes: 3152
from itertools import product
n = int(input())

nums = [0]*(n+1)
for i in product(range(1, int(n**0.5)+1),repeat=3):
  t = i[0]**2 + i[1]**2 + i[2]**2 + i[0]*i[1] + i[1]*i[2] + i[0]*i[2]
  if t <= n: nums[t] += 1

for i in range(1,n+1): print(nums[i])

Measured memory_bytes: 9568
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l().sort((a,b)=>a-b);
  var yes = "Yes", no = "No";
  if(a[n-1] >= n)return no;
  if(a[0] === a[n-1] && a[0] <= n/2)return yes;
  if(a[0] === a[n-1] && a[0] === n-1)return yes;
  for(var i = 1; i < n-1; i++){
    var k = n-i >> 1;
    if(i <= a[0] && a[0] < i+k && a[0] === a[i-1] && a[0]+1 === a[i] && a[i] === a[n-1])return yes;
  }
  return no;
}

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

int main() {
    int n;
    cin>>n;
    vector<int>b(n);
    for(int i=0;i<n;i++){
        cin>>b.at(i);
    }
    vector<int>a;
    int flag=0;
    int tmp=n-1;
    for(int j=0;j<n;j++){
        flag=0;
        for(int i=tmp;i>=0;i--){
            if(b.at(i)==i+1){
                a.push_back(b.at(i));
                b.erase(b.begin()+i);
                flag=1;
                tmp--;
                break;
            }
        }
        if(flag==0){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    for(int i=n-1;i>=0;i--){
        cout<<a.at(i)<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Measured memory_bytes: 57440
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

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

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

ll A, B;

int main() {
	cin >> A >> B;
	int Before[110] = {};
	ll onenum;
	ll tmp = A - 1;
	onenum = (tmp + 1) / 2;
	if (tmp % 2 == 0) {
		for (int i = 0; i < 100; i++) {
			Before[i] = tmp % 2;
			tmp /= 2;
		}
	}
	if (onenum % 2 != 0) {
		Before[0] = 1 - Before[0];
	}

	ll After[110] = {};
	tmp = B;
	onenum = (tmp + 1) / 2;
	if (tmp % 2 == 0) {
		for (int i = 0; i < 100; i++) {
			After[i] = tmp % 2;
			tmp /= 2;
			
		}
	}
	if (onenum % 2 != 0) {
		After[0] = 1 - After[0];
	}

//	for (int i = 19; i >= 0; i--) {
//		cout << Before[i];
//	}
//	cout << endl;
//	for (int i = 19; i >= 0; i--) {
//		cout << After[i];
//	}
//	cout << endl;

	ll ans = 0;
	ll j = 1;

	REP(i, 100) {
		ans += (ll)(Before[i] != After[i]) * j;
		j *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

if S[0] == "A" and S[2:-1].count("C") == 1 and S.count("A") == 1 and S.count("C") == 1:
    S = S.replace("A", "")
    S = S.replace("C", "")
    if S == S.lower():
        print('AC')
        quit()
print('WA')


Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int N; cin>>N;
    vector<int> X(N);
    rep(i,N) cin>>X[i];
    ll ans=INF;
    rep(i,105){
        ll sum=0;
        rep(j,N){
            sum+=(i-X[j])*(i-X[j]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

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

int main(){
  int *S;
  int n;
  int q;
  int *T;
  int i,j;
  int jg=0;

  scanf("%d",&n);
  S=(int *)malloc(n*sizeof(int));

  for(i=0;i<n;i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  T=(int *)malloc(q*sizeof(int));

  for(i=0;i<q;i++)scanf("%d",&T[i]);
  
  for(j=0;j<q;j++){
    for(i=0;i<n;i++){
      if(S[i]==T[j]){
	jg++;
	break;
      }
    }
  }
  printf("%d\n",jg);
  return 0;
}

     
    
      



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

#define int long long

const int N = 2e5 + 10;
int r, ans;
string s;

int32_t main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		if (s[i] == 'W')
			r++;
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B')
			ans += r;
		else
			r--;
	}
	cout << ans;
}

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

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

using namespace std;

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

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

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

int H, W;
char F[2011][2011];
int Y[2011];

void MAIN() {
    scanf("%d%d", &H, &W);
    REP (i, H) scanf("%s", F[i]);

    int ans = 0;
    amax(ans, H);
    amax(ans, W);

    REP (j, W) Y[j] = 1;

    for (int i=1; i<H; i++) {
	Y[0] = i+1;
	stack<pair<int, int> > st; st.emplace(i+1, 0);

	for (int j=1; j<W; j++) {
	    int cnt = 0;
	    cnt += (F[i][j] == '#');
	    cnt += (F[i-1][j] == '#');
	    cnt += (F[i][j-1] == '#');
	    cnt += (F[i-1][j-1] == '#');

	    if (cnt & 1) {
		Y[j] = 1;
	    } else {
		Y[j]++;
	    }
	    int last = -1;
	    while (!st.empty() && st.top().first >= Y[j]) {
		amax(ans, st.top().first * (j - st.top().second));
		last = st.top().second;
		st.pop();
	    }
	    if (last != -1) {
		st.emplace(Y[j], last);
	    }
	    st.emplace(i+1, j);
	}
	while (!st.empty()) {
	    amax(ans, st.top().first * (W - st.top().second));
	    st.pop();
	}
    }

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

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



Measured memory_bytes: 4224
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		for (int i = 0; i < c.length; i++) {
			if(i==4)
				System.out.print(" ");
			System.out.print(c[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 9556
S = input()

if S[0] == S[1] and S[0] == S[2] and S[0] == S[3]:
	print('No')
elif S[0] == S[1] and S[2] == S[3] :
	print('Yes')
elif S[0] == S[2] and S[1] == S[3] :
	print('Yes')
elif S[0] == S[3] and S[2] == S[1] :
	print('Yes')
    
else :
	print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sheets = sc.nextInt();
		
		while(sheets != 0){
			int pointA = 0, pointB = 0;
			for (int i = 0; i < sheets; i++) {
				int cardA = sc.nextInt();
				int cardB = sc.nextInt();
				
				if (cardA > cardB) {
					pointA += (cardA + cardB);
				}else if (cardA < cardB) {
					pointB += (cardA + cardB);
				}else {
					pointA += cardA;
					pointB += cardB;
				}
			}
			System.out.printf("%d %d\n", pointA, pointB);
			sheets = sc.nextInt();
		}
		
	}

}

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

long long int table[1001][1001];

int main(){

    int n,m;

    cin >> n >> m;

    int dir[n],weather[m];

    for(int i=0;i<n;i++){
      cin >> dir[i];
    }

    for(int i=0;i<m;i++){
      cin >> weather[i];
    }

    n++;m++;

    for(int i=0;i<n;i++){
      table[0][i] = 10000000000;
    }

    for(int i=0;i<m;i++){
      table[i][0] = 0;
    }

    for(int i=1;i<m;i++){
      for(int j=1;j<n;j++){
        if(m-n+1 < i  && (m-i+j<n) ){
          table[i][j] = 10000000000;
          continue;
        }
        table[i][j] = min(table[i-1][j],table[i-1][j-1]+dir[j-1]*weather[i-1]);
      }
    }

    cout << table[m-1][n-1] << endl;


    return 0;
}

Measured memory_bytes: 10928
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

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

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N;
  cin>>N;
  ll a[N];
  FOR(i,0,N-1){
    cin>>a[i];
  } 
  FOR(i,0,N-1){
    ll k;
    if(N%2==0){
      if(i<N/2){
        k=N-2*i;
      }else{
        k=2*i-N+1;
      }
    }else{
      if(i<N/2+1){
        k=N-2*i;
      }else{
        k=2*i-N+1;
      }
    }
    //cout<<k;
    cout<<a[k-1];
    if(i!=N-1){
      cout<<" ";
    }
  } 




}
 


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

int main(){
	int N,count=0,ans=1;
    cin>>N;
    vector<string>A(N);
    for(int i=0;i<N;i++){
    	cin>>A.at(i);
    }
    sort(A.begin(), A.end());
    for(int i=0;i<N-1;i++){
    	if(A.at(i)!=A.at(i+1)){
        	ans++;
          	continue;
        }else{
        	continue;
        }
      
    }
  cout<<ans<<endl;
 
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 2e18;
    if(a & 1){
        ans = min(ans, b * c);
    }else{
        ans = min(ans, 0LL);
    } 
    if(b & 1){
        ans = min(ans, a * c);
    }else{
        ans = min(ans, 0LL);
    } 
    if(c & 1){
        ans = min(ans, b * a);
    }else{
        ans = min(ans, 0LL);
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9 + 7
count = 0
for n in range(K, N+2):
  maxSum = (n*(N + N-n+1))//2
  minSum = (n*(n-1))//2
  count += maxSum - minSum + 1
  count %= mod

print(count)

Measured memory_bytes: 9016
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 1e5
#define EPS 1e-9
#define PI 3.14159265358979323846264338327950

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

	int a, b, c, k;
	int ans = 0;
	cin >> a >> b >> c >> k;
	if (a > k) {
		ans += k;
		k = 0;
	} else {
		ans += a;
		k -= a;
	}
	if (k > 0) {
		k = (b > k ? 0 : k - b);
	}
	if (k > 0) {
		ans += -k;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3176
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
x=y=t=0
ans='Yes'
for i in range(n):
  xy=a[i][1]+a[i][2]-(x+y)
  if xy>a[i][0]-t:
    ans='No'
    break
  else:
    if xy%2!=(a[i][0]-t)%2:
      ans='No'
      break
    elif abs(a[i][1]-x)+abs(a[i][2]-y)>a[i][0]-t:
      ans='No'
      break
  x=a[i][1]
  y=a[i][2]
  t=a[i][0]
print(ans)

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

using namespace std;
using pii = pair<int,int>;

const int INF = 1e9;
int R,C;
vector<vector<char>> field;
vector<vector<int>> depth;

int getMaxDepth(){
    int res = 0;
    for(int r=0; r<R; r++){
        for(int c=0; c<C; c++)res = max(depth.at(r).at(c), res);
    }
    return res;
}

void bfs(queue<pii> blacks){
    queue<pii> que;
    vector<pii> dirs = {pii(1,0), pii(-1,0), pii(0,1), pii(0,-1)};

    while(!blacks.empty()){
        pii bl = blacks.front(); blacks.pop();

        int r = bl.first;
        int c = bl.second;
        depth.at(r).at(c) = 0;

        que.push(bl);
    }

    while(!que.empty()){
        auto q = que.front(); que.pop();
        int d = depth.at(q.first).at(q.second);

        for(auto dir : dirs){
            int nr = q.first + dir.first;
            int nc = q.second + dir.second;

            if(0<=nr && nr<R && 0<=nc && nc<C && depth.at(nr).at(nc) == INF){
                depth.at(nr).at(nc) = d+1;
                que.push(pii(nr,nc));
            }
        }
    }
}

int main(){
    cin >> R >> C;

    queue<pii> blacks;
    field = vector<vector<char>>(R, vector<char>(C));
    depth = vector<vector<int>>(R, vector<int>(C, INF));
    for(int r=0; r<R; r++){
        for(int c=0; c<C; c++){
            char ch;
            cin >> ch;
            field.at(r).at(c) = ch;
            if(ch == '#')blacks.push(pii(r,c));
        }
    }

    bfs(blacks);

    cout << getMaxDepth() << endl;
}

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

int main() {
  int d;
  scanf("%d",&d);
  string s="Christmas";
  for(int i=25;i>d;i--) s+=" Eve";
  cout<<s<<endl;;
  return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int n; cin>>n; 
    vector <pii> v(n);
    for (int i=0;i<n;i++) {
    	cin>>v[i].ff>>v[i].ss; 
    	swap(v[i].ff,v[i].ss);
    }
    bool ok=true; 
    sort(v.begin(), v.end()); 
    int sum=0; 
    for (int i=0;i<n;i++){ 
    	sum += v[i].ss; 
    	if (sum>v[i].ff) ok=false; 
    } 
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

signed main()
{
    int n=1; // cin>>n; 
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6436
from collections import deque

DIRECTIONS = [(0, 1), (1, 0), (0, -1), (-1, 0)]


def count(start, S, H, W, tested):
    if tested[start[0]][start[1]]:
        return 0
    q = deque()
    q.append((start[0], start[1], "#"))
    white = 0
    black = 0
    while(len(q)):
        i, j, color = q.popleft()
        if tested[i][j]:
            continue
        tested[i][j] = True
        if color == ".":
            white += 1
            ncolor = "#"
        else:  # color == "#":
            black += 1
            ncolor = "."
        for d in DIRECTIONS:
            ni = i + d[0]
            nj = j + d[1]
            if 0 <= ni and ni < H and 0 <= nj and nj < W and S[ni][nj] == ncolor:
                q.append((ni, nj, ncolor))
    return black * white


def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    tested = [[False] * W for _ in range(H)]
    retval = 0
    for i in range(H):
        for j in range(W):
            if(S[i][j] == "#"):
                retval += count((i, j), S, H, W, tested)
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 51036
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int b, e, k;
    cin >> b >> e >> k;
    int count = 0;
    for (int j = b; j < e; j++){
      if (a[j] == k){
        count++;
      }
    }
    cout << count << endl;
  }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

// convex hull
vector<pair<int,int>> convex_hull(vector<pair<int,int>> point){
    sort(point.begin(), point.end());
    int n = point.size();
    int vertices = 0;
    vector<pair<int,int>> conv(2 * n);

    // lower half
    for(int i=0; i<n; i++){
        while(vertices >= 2){
            long long int dx1 = conv[vertices-1].first  - conv[vertices-2].first;
            long long int dy1 = conv[vertices-1].second - conv[vertices-2].second;
            long long int dx2 = point[i].first  - conv[vertices-1].first;
            long long int dy2 = point[i].second - conv[vertices-1].second;

            long long int det = dx1 * dy2 - dx2 * dy1;
            if(det < 0) vertices -= 1;// remove conv[vertices-1]
            else break;
        }
        conv[vertices] = point[i];
        vertices += 1;
    }

    int memo = vertices;

    // upper half
    for(int i=n-2; i>=0; i--){
        while(vertices > memo){
            long long int dx1 = conv[vertices-1].first  - conv[vertices-2].first;
            long long int dy1 = conv[vertices-1].second - conv[vertices-2].second;
            long long int dx2 = point[i].first  - conv[vertices-1].first;
            long long int dy2 = point[i].second - conv[vertices-1].second;

            long long int det = dx1 * dy2 - dx2 * dy1;
            if(det < 0) vertices -= 1;// remove conv[vertices-1]
            else break;
        }
        conv[vertices] = point[i];
        vertices += 1;
    }
    vertices -= 1;
    conv.resize(vertices);
    return conv;
}

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

    vector<pair<int, int>> hole(n);
    map<pair<int,int>, int> id;
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        hole[i] = {x, y};
        id[{x,y}] = i;
    }
    sort(hole.begin(),hole.end());
    vector<pair<int, int>> ch = convex_hull(hole);
    ch.push_back(ch[0]);
    ch.push_back(ch[1]);
    int v = ch.size();

    vector<double> ans(n);
    for(int p=1; p+1<v; p++){
        //cout << ch[p].first << " " << ch[p].second << endl;
        int i = id[ch[p]];

        int dx1 = ch[p-1].first  - ch[p].first;
        int dy1 = ch[p-1].second - ch[p].second;
        int dx2 = ch[p+1].first  - ch[p].first;
        int dy2 = ch[p+1].second - ch[p].second;
        double theta1 = atan2(dy1,dx1);
        double theta2 = atan2(dy2,dx2);

        ans[i] = (theta2 + PI - theta1) / (2 * PI);
        if(ans[i] >= 1) ans[i] -= 1;
    }

    for(int i=0; i<n; i++){
        cout << fixed << setprecision(10) << ans[i] << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s=="Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s=="Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vi a(n);
  int mini = 1e9;
  int minid;
  int maxi = -1e9;
  int maxid;
  rep(i,n){
    cin >> a.at(i);
    if(a.at(i) > maxi){
      maxi = a.at(i);
      maxid = i;
    }
    if(a.at(i) < mini){
      mini = a.at(i);
      minid = i;
    }
  }
  cout << 2*n - 1 << endl;
  if(abs(maxi) > abs(mini)){
    rep(i,n) cout << maxid+1 << " " << i+1 << endl;
    rep(i,n-1) cout << i+1 << " " << i+2 << endl;
  }else{
    rep(i,n) cout << minid+1 << " " << i+1 << endl;
    rep(i,n-1) cout << n-i << " " << n-i-1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a;
  cin >> a;
  int ans = a*a*a + a*a + a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3172
N,K = map(int,input().split())
A = list(map(int,input().split()))


#%%
L = 50
# bins[i]: 2進数でi桁目にある1の数の合計
bins = [0]*L
kb = [0]*L


for i in range(L):    
    for j in range(N):
        bins[i] += A[j]%2
        A[j] >>= 1
    kb[i] = K%2
    K >>= 1

bins.reverse()
kb.reverse()
#%%
start = L

for i,k in enumerate(kb):
    if k==1:
        start = i
        break


#dp[i+1][t]:上からi桁目まで決めたときの最大スコア
#t=0: K未満となるとき，　t=1: Kとその桁まで一致するとき　　
        
dp = [[0]*2 for _ in range(L+1)]



cur = 0
base = 2**(L-1)
for i in range(L):
    if i<start:
        dp[i+1][1] = dp[i][1] + bins[i]*base
        
    elif i==start:
        dp[i+1][0] = dp[i][1]+(bins[i])*base
        dp[i+1][1] = dp[i][1] + (N-bins[i])*base
        
    else:
        if kb[i]:
            dp[i+1][0] = max(dp[i][0] + max(bins[i],N-bins[i])*base,
                             dp[i][1] + (bins[i]) * base)
            
            dp[i+1][1] = dp[i][1] + (N-bins[i])*base      
        else:
            dp[i+1][0] = dp[i][0] + max(bins[i],N-bins[i])*base
            
            dp[i+1][1] = dp[i][1] + (bins[i])*base            
    base >>= 1
        
print(max(dp[L][0],dp[L][1]))

    






Measured memory_bytes: 68696
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 62);
vector<int> to[2505];
vector<int> from[2505];
bool ok[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];

void dfs(int v)
{
  if (reachableFrom1[v])
    return;
  reachableFrom1[v] = true;
  for (int u : to[v])
  {
    dfs(u);
  }
}

void rdfs(int v)
{
  if (reachableToN[v])
    return;
  reachableToN[v] = true;
  for (int u : from[v])
  {
    rdfs(u);
  }
}

int main()
{
  int64_t N, M, P;
  cin >> N >> M >> P;
  vector<tuple<int64_t, int64_t, int64_t>> edges;
  for (int i = 0; i < M; i++)
  {
    int64_t a, b, c;
    cin >> a >> b >> c;
    edges.emplace_back(a - 1, b - 1, -(c - P));
    to[a - 1].push_back(b - 1);
    from[b - 1].push_back(a - 1);
  }
  dfs(0);
  rdfs(N - 1);
  for (int i = 0; i < N; i++)
  {
    ok[i] = reachableFrom1[i] && reachableToN[i];
  }
  vector<int64_t> d(N, INF);
  d[0] = 0;
  bool upd = true;
  int64_t step = 0;
  while (upd)
  {
    upd = false;
    for (int i = 0; i < M; i++)
    {
      int64_t a, b, c;
      tie(a, b, c) = edges[i];
      if (!ok[a] || !ok[b])
        continue;
      int64_t newD = d[a] + c;
      if (newD < d[b])
      {
        upd = true;
        d[b] = newD;
      }
    }
    step++;
    if (step > N)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  int64_t ans = -d[N - 1];
  ans = max(ans, (int64_t)0);
  cout << ans << endl;
}


Measured memory_bytes: 4068
import math

time = [0]*5
time_ = [0]*5
for i in range(5):
  time[i] = int(input())
  time_[i] = (time[i]-1)%10

ans = 0
tmin = min(time_)
flag = True
for i in range(5):
  if (time[i]-1)%10==tmin and flag:
    ans += time[i]
    flag = False
  else:
    ans += math.ceil(time[i]*0.1)*10
print(int(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <vector>
using namespace std;
const int N=302;
int h,w,k,a[N][N]; 
char s[N][N];
int d[N],r[N];
int main(){
    scanf("%d%d%d",&h,&w,&k);
    for(int i=1;i<=h;i++) scanf("%s",s[i]+1); 
    set<int> st; 
    for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
        if(s[i][j] == '#') st.insert(i);
    }
    st.erase(st.begin()); st.insert(1);  st.insert(h+1);

    int C=0;
    vector<int> v; for(auto x: st) v.push_back(x);
    for(int i=0;i<v.size()-1;i++){
        int u=v[i],d=v[i+1]-1;

        set<int> st;  
        for(int x=u;x<=d;x++)
        for(int j=1;j<=w;j++){
            if(s[x][j]=='#') st.insert(j);
        }
        st.erase(st.begin()); st.insert(1); st.insert(w+1);
        vector<int> v1; for(auto x: st) v1.push_back(x);
        for(int j=0;j<v1.size()-1;j++){
            int l=v1[j], r=v1[j+1]-1;
            ++C;
            for(int x=u;x<=d;x++)for(int y=l;y<=r;y++)a[x][y]=C;
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)printf("%d ", a[i][j]);
        printf("\n");
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int n;
    cin >> n;

    vector<pii> ab(n);
    vector<pii> v(n);
    FOR(i,n){
        int ai, bi;
        cin >> ai >> bi;
        ab[i] = make_pair(ai, bi);
        v[i].first = -ai-bi;
        v[i].second = i;
    }

    sort(v.begin(), v.end());

    ll sol = 0;
    FOR(i, n){
        if (i%2==0)
            sol += ab[v[i].second].first;
        else
            sol -= ab[v[i].second].second;
    }
    cout << sol;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void)
{
	int N, K, ans = 0;
	
	cin >> N >> K;
	
	for (int i = 0; i < N; ++i) {
		int t;
		
		cin >> t;
		
		if (t >= K) {
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  char a;
  cin >> a;
  if ('a' <= a && 'a' <= 'z') {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main() 
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N; cin >> N;
  vector<int> V(N), X;
  for (int i=0; i<N; i++)
  {
     cin >> V.at(i); 
  }
  for (int i=0; i<N; i++)
  {
     int c;
     cin >> c;
     int v = V.at(i);
     if (v-c > 0) X.push_back(v-c);
  }

  cout << accumulate(X.begin(), X.end(), 0) << endl; 
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

clock_t time_p=clock();
void printTime(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
 

const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int main(){
    io();
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n,a,b; cin>>n>>a>>b;
    ll p;
    ll ansa=0,ansb=0,ansc=0;
    for(int i=0;i<n;i++){
		cin>>p;
		if(p<=a){
			ansa++;
		}else if(p<=b){
			ansb++;
		}else{
			ansc++;
		}
	}
	ll ans;
	if(ansa<=ansb){
		ans=ansa;
	}else{
		ans=ansb;
	}
	cout<<min(ans,ansc)<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    bool ok = true;
    REP(i, 3)if(s[i]==s[i-1])ok = false;
    if(ok)cout << "Good";
    else cout << "Bad";
}


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

using std::cout;
using std::cerr;
using std::cin;
using std::endl;

using std::vector;
using std::string;

void funcA() {

	int a;
	string s;

	cin >> a;
	cin >> s;
	if (a >= 3200) {
		cout << s << endl;;
	}
	else {
		cout << "red" << endl;
	}
}

void func() {
	int N;
	cin >> N;

	double x = 0.0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;

		x += 1.0 / (double)a;
	}
	double y = 1.0 / x;
	printf("%.16f\n",y);
 
}
int main() {
	func();

}




Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ull unsigned long long
#define ll long long
const ll mod=998244353;
using namespace std;
//priority_queue
inline ll in()
{
    ll res=0;
    char c=getchar();
    while(c<'0'||c>'9') c=getchar();
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return res;
}
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kk(ll a,ll b)
{
    ll c=0;
    while(b)
    {
        if(b&1)c=(c+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return c;
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=c*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}
char s[200006];
int main()
{
    //ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll aa=s.size();
    ll a,b,c;
    a=b=c=0;
    ll sum=0;
    for(ll i=0; i<aa; i++)
    {
        if(s[i]=='A')
        {
            if(b) a=1,b=0;
            else
                a++;
        }
        if(a&&s[i]=='B'){
                if(b)a=0;
                b=1;}
        if(s[i]=='C')
        {
            if(!b)a=0;
            else c=1,b=0;
        }//cout<<a<<endl;
        if(c)sum+=a,c=b=0;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int n,m,a;

int main() {
	string s,t;
	cout << fixed << setprecision(18);
	cin>>n>>m>>a;
	while(n!=0){
		long long int h[1004],p[1004],q[1004];
		for(int i=0;i<m;i++){
			cin>>h[i]>>p[i]>>q[i];
		}
		long long int now=a;
		for(int i=1000;i>=1;i--){
			for(int j=0;j<m;j++){
				if(h[j]==i&&(p[j]==now||q[j]==now)){
					now=p[j]+q[j]-now;
					//cout<<j<<" "<<h[j]<<" "<<p[j]<<" "<<q[j]<<" "<<now<<endl;
					break;
				}
			}
		}
		cout<<now<<endl;
		cin>>n>>m>>a;
	}
	

} 


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a),t(b);
    for(int i = 0; i < a; i++) cin >> s[i];
    for(int i = 0; i < b; i++) cin >> t[i];
    s.emplace_back(-1e17),s.emplace_back(1e17);
    t.emplace_back(-1e17),t.emplace_back(1e17);
    sort(s.begin(),s.end()),sort(t.begin(),t.end());
    for(int j = 0; j < q; j++){
        ll x; cin >> x;
        ll ss = lower_bound(s.begin(),s.end(),x)-s.begin();
        ll tt = lower_bound(t.begin(),t.end(),x)-t.begin();
        ll ans = abs(x-s[ss])+abs(s[ss]-t[tt]);
        ans = min(ans,abs(x-s[ss])+abs(s[ss]-t[tt-1]));
        ans = min(ans,abs(x-s[ss-1])+abs(s[ss-1]-t[tt]));
        ans = min(ans,abs(x-s[ss-1])+abs(s[ss-1]-t[tt-1]));
        ans = min(ans,abs(x-t[tt])+abs(t[tt]-s[ss]));
        ans = min(ans,abs(x-t[tt])+abs(t[tt]-s[ss-1]));
        ans = min(ans,abs(x-t[tt-1])+abs(t[tt-1]-s[ss]));
        ans = min(ans,abs(x-t[tt-1])+abs(t[tt-1]-s[ss-1]));
        cout << ans << endl; 
    }
    return 0;
}


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

int main()
{
	int n,p;
	while(cin>>n>>p){
		if(n==0 && p==0) return 0;
		vector<int> have(n,0);
		int now=0;
		while(true){
			if(p>0){
				have[now]++;
				p--;
				if(p==0){
					bool ok=true;
					for(int i=0;i<n;i++){
						if(i==now) continue;
						if(have[i]>0){
							ok=false;
							break;
						}
					}
					if(ok){
						cout<<now<<endl;
						break;
					}
				}
			}
			else{
				p+=have[now];
				have[now]=0;
			}
			now++;
			if(now==n) now=0;
		}

	}
	return 0;
}

Measured memory_bytes: 904
while True:
    m,f,r = map(int,input().split())
    s = m+f
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        o="F"
    elif s >= 80:
        o="A"
    elif s >= 65 and s < 80:
        o="B"
    elif s >= 50 and s < 65:
        o="C"
    elif s >= 30 and s < 50:
        if r >= 50:
            o = "C"
        else:
            o = "D"
    else:
        o = "F"
    print(o)
    


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s.length()<4)
        cout<<"No"<<endl;
    else if(s.substr(0,4)=="YAKI")
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256