akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
s = ns()
a = 0
b = 0
for i in range(len(s)):
  if s[i] in "ATCG":
    b += 1
  else:
    if b > 0:
      a = max(a,b)
      b = 0
 
print(max(a,b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
ll xpowy(ll x, ll y) {
    ll res = 1LL;
    while (y > 0) {
        if ((y & 1)) 
            res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}
int n, m;
ll ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    ans = (1900 * m + 100 * (n - m)) * xpowy(2, m);
    cout << ans << endl;
    return 0;
}


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


int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> Esum(n+1),Wsum(n+1);
    Esum[0] = 0;
    Wsum[0] = 0;
    rep(i,n){
        if(s[i] == 'E'){
            Esum[i+1] = Esum[i] + 1;
            Wsum[i+1] = Wsum[i];
        }else{
            Esum[i+1] = Esum[i];
            Wsum[i+1] = Wsum[i] + 1;
        }
    }
    int asum = 1e10;
    rep(i,n) if(asum > Esum[n] - Esum[i+1] + Wsum[i]) asum = Esum[n] - Esum[i+1] + Wsum[i];
    cout << asum << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define int long long
#define INF 1e+9
using namespace std;

signed main(){
	int a,b,k;
	set<int> st;
	cin >> a >> b >> k;
	for(int i = a;i < a + k;i++) st.insert(i);
	for(int i = b - k + 1;i <= b;i++) st.insert(i);
	for(auto v : st){
		if(a <= v && v <= b) cout << v << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main(){
  int h,w,n;
  cin>>h>>w>>n;

  map<pair<int,int>,int> cnt;
  while(n--){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    for(int i=-1;i<2;i++){
      for(int j=-1;j<2;j++){
        if(a+i>0&&a+i<h-1&&b+j>0&&b+j<w-1){
          cnt[make_pair(a+i,b+j)]++;
        }
      }
    }
  }
  long long ans[10] = {(long long)(h-2)*(w-2)};
  for(auto& elem : cnt){
    ans[0]--;
    ans[elem.second]++;
  }

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

Measured memory_bytes: 56448
#include<stdio.h>

int main(){
  int n,a[21],b[21],c[21],i,sum=0,v[21]={0};
  a[0]=10000;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
   if(a[i]==a[i-1]+1){
     v[a[i-1]]++;
   }
  }
  for(i=1;i<=n;i++){
    scanf("%d",&b[i]);
    sum+=b[i];
  }
  
  for(i=1;i<n;i++){
    scanf("%d",&c[i]);
    if(v[i]!=0){
      sum+=c[i];
    }
  }

  printf("%d\n",sum );
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int s;
	cin >> s;
	set<int> st;
	st.insert(s);
	int ans = 2;
	while(1){
		if(s % 2 == 0) s /= 2;
		else s = 3*s + 1;
		int siz = st.size();
		st.insert(s);
		if(st.size() == siz){
			cout << ans << endl;
			return 0;
		}
		ans++;
	}

	return 0;
}

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

int n, m;
vector<int> vs[100001];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (m - a < 0) continue;
    vs[m - a].push_back(b);
  }
  
  priority_queue<int> q;
  long ans = 0;
  for (int j = m; j >= 0; --j) {
    for (int c : vs[j]) {
      q.push(c);
    }
    if (q.empty()) continue;
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  
}

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

const int inf=10101010;
const int N_MAX=41;
const int AB_MAX=11;
int dp[N_MAX][N_MAX*AB_MAX][N_MAX*AB_MAX];

int main() {
  int n,ma,mb; cin>>n>>ma>>mb;
  vector<int> a(n),b(n),c(n);
  rep(i, n) cin>>a[i]>>b[i]>>c[i];
  rep(i, n+1) {
    rep(j, n*AB_MAX+1) {
      rep(k, n*AB_MAX+1) {
        dp[i][j][k]=inf;
      }
    }
  }
  dp[0][0][0]=0;
  rep(i, n) {
    rep(j, n*AB_MAX) {
      rep(k, n*AB_MAX) {
        if (dp[i][j][k]==inf) continue;
        dp[i+1][j][k]=min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  int res=inf;
  for (int i=1; i<n*AB_MAX+1; i++) {
    for (int j=1; j<n*AB_MAX+1; j++) {
      if (i*mb==j*ma) res=min(res, dp[n][i][j]);
    }
  }
  if (res!=inf) cout<<res<<endl;
  else cout<<-1<<endl;
}

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

int main() {
	int a,b,c;
	int sum=0;
	cin>>a>>b;
	for (int i=0; i<b;i++)
	{
		cin>>c;
		sum+=c;
	}
	if(sum>=a)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int ans=0;
  int m=0;
  rep(i,n){
    int a;
    cin >> a;
    if(a>=m){
      m=a;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){

		string s;
		cin >>s ;
		if(s=="SUN")
			cout<<"7";
		else if (s=="MON")
			cout<<"6";
		else if (s=="TUE")
			cout<<"5";
		else if (s=="WED")
			cout<<"4";
		else if (s=="THU")
			cout<<"3";
		else if (s=="FRI")
			cout<<"2";
		else if (s=="SAT")
			cout<<"1";


		return 0;
	}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int a=in(),b=in(),i,j,ans=0;
	char s[10];
	for(i=a;i<=b;i++){
		sprintf(s,"%d",i);
		rep(j,strlen(s)/2)if(s[j]!=s[strlen(s)-j-1])break;
		if(j==strlen(s)/2)ans++;
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 128
h,w=map(int,input().split())
s=['#'*(w+2)]+['#'+input()+'#' for _ in range(h)]+['#'*(w+2)]
u=[[0]*(w+2) for _ in range(h+2)]
d=[[0]*(w+2) for _ in range(h+2)]
l=[[0]*(w+2) for _ in range(h+2)]
r=[[0]*(w+2) for _ in range(h+2)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]=='.':
      l[i][j]=l[i][j-1]+1
    if s[i][w+1-j]=='.':  
      r[i][w+1-j]=r[i][w+2-j]+1
for i in range(1,w+1):
  for j in range(1,h+1):
    if s[j][i]=='.':
      u[j][i]=u[j-1][i]+1
    if s[h+1-j][i]=='.':  
      d[h+1-j][i]=d[h+2-j][i]+1
m=0
for i in range(1,h+1):
  for j in range(1,w+1):
    m=max(m,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(m)

Measured memory_bytes: 179844
#include <stdio.h>

int main(void)
{
	int i, j, k;
	int n, sum;		//sum x.
	int ans;

	while(1)
	{

		scanf("%d%d", &n, &sum);
		if(n == 0 && sum == 0)
			return (0);

		i = 1;
		while(i <= n - 2)
		{
			j = i + 1;
			while(j <= n - 1)
			{
				k = j + 1;
				while(k <= n)
				{
					if(i + j + k == sum)
						ans++;
					k++;
				}
				j++;
			}
			i++;
		}
		printf("%d\n", ans);
		ans = 0;
	}
	return (0);
}



Measured memory_bytes: 2148
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string N;
    cin >> N;

    map<string, string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";

    print(m[N]);


}


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

w = list(map(int, input().split()))

small = []
large = []

tmpSmall = 0
tmpLarge = 0
for i in range(n-1):
    tmpSmall = tmpSmall + w[i]
    tmpLarge = tmpLarge + w[n-1-i]
    small.append(tmpSmall)
    large.append(tmpLarge)

ans = 999999999
for i in range(n-1):
    tmp = abs(small[i] - large[n-2-i])
    if(tmp < ans):
        ans = tmp

print(ans)

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

int arr[105];

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n,k;cin>>n>>k;

  for(int i=0;i<k;i++){
    int d;cin>>d;
    for(int j=0;j<d;j++){
      int a;cin>>a;
      arr[a]=1;
    }
  }
  int cnt=0;
  for(int i=1;i<=n;i++){
    if(!arr[i])cnt++;
  }
  cout<<cnt<<endl;
  
  return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

dp = [[[0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 0

cnt1 = a.count(1)
cnt2 = a.count(2)
cnt3 = a.count(3)

for i in range(cnt3 + 1):
    for j in range(cnt3 + cnt2 + 1 - i):
        for k in range(cnt3 + cnt2 + cnt1 + 1 - i - j):
            if i + j + k == 0:
                continue
            res = 1
            if k > 0:
                res += (k/n) * dp[i][j][k-1]
            if j > 0:
                res += (j/n) * dp[i][j-1][k+1]
            if i > 0:
                res += (i/n) * dp[i-1][j+1][k]
            dp[i][j][k] = (n/(i+k+j)) * res

print(dp[cnt3][cnt2][cnt1])

Measured memory_bytes: 500488
using System;

class C
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int n = h[0], y = h[1] / 1000;

		for (int i = 0; i <= n; i++)
			for (int j = 0; j <= n - i; j++)
				if (9 * i + 4 * j + n == y) { Console.WriteLine($"{i} {j} {n - i - j}"); return; }
		Console.WriteLine("-1 -1 -1");
	}
}


Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    public static void Main() {
        int[]nk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nk[0],k=nk[1];
        int[]a=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[]g=new int[k+1];
        for(int i=1;i<=k;i++){
            bool[]ckd=new bool[n+1];
            foreach(int x in a){
                if(i<x)continue;
                ckd[g[i-x]]=true;
            }
            for(int j=0;j<=n;j++){
                if(!ckd[j]){
                    g[i]=j;
                    break;
                }
            }
        }
        Console.WriteLine(g[k]==0?"Second":"First");
    }
}



Measured memory_bytes: 17632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair
using namespace std;

typedef long long int64;

class A {
public:
    void solve(std::istream &in, std::ostream &out) {
        int x, a;
        in >> x >> a;
        if (x < a)out << '0' << '\n';
        else out << 10 << '\n';
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    A solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

string s;
signed main(){
    int a[100];
    cin >> s;
    int n = s.size();
    int now = 0;
    rep(i,n){
        if(s[i] == '0'){
            a[now] = 0;
            ++now;
        }
        else if(s[i] == '1'){
            a[now] = 1;
            ++now;
        }
        else if(now){
            --now;
        }
    }   
    rep(i,now){
        cout << a[i];
    }   
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(k, n):
        if a[i] > a[i-k]:
            print("Yes")
        else:
            print("No")
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 33000
#include<cstdio>
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];
// 最大積載量 P の k台のトラックで何個の荷物を積めるか
int check(llong P){
    int i =0;
    for(int j=0; j<k; j++){
        llong s = 0;
        while(s+T[i] <= P){
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000; // 荷物の個数×1個あたりの最大重量
    while(right - left>1){
        llong mid = (left+right)/2;
        int v = check(mid); // mid==Pを決めて何個積めるかチェック
        if(v>=n) right=mid;
        else left = mid;    
    }
    return right;
}
int main(){
    scanf("%d %d", &n, &k);
    for(int i=0;i<n; i++) scanf("%d", &T[i]);
    llong ans =solve();
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int D =int.Parse(Console.ReadLine());
            if (D == 25)
                Console.WriteLine("Christmas");
            else if (D == 24)
                Console.WriteLine("Christmas Eve");
            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");
            else
                Console.WriteLine("Christmas Eve Eve Eve");

            Console.ReadKey();
                 

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath> 
#define ll long long
using namespace std;
ll n, dis[200010], k, det[200010], mx = -1, loc;
int main(){
	while(cin >> k >> n)
	{
		for(int i = 1; i <= n; i++)
		{
			scanf("%lld", &dis[i]);
			det[i] = abs(dis[i] - dis[i - 1]);
		}
		det[1] = det[1] + k - dis[n];
		mx = det[1], loc = 1;
		for(int i = 1; i <= n; i++)
		{
			if(mx < det[i])
			{
				mx = det[i];
				loc = i;
			}
		}
		cout << k - mx << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
int x,y;
while(1){
cin>>x>>y;
if(x==0 && y==0)break;
if(x<=y){
cout<<x<<" "<<y<<endl;
}else if(x>y){
cout<<y<<" "<<x<<endl;
}
}
return 0;
}


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

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

  for (int i = X - K + 1; i <= X + K - 1; i++) {
      if (i != X + K - 1) {
          cout << i << ' ';
      }
      else {
          cout << i << endl;
      }
  }
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll r=0,g=0,b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')r++;
    if(s[i]=='G')g++;
    if(s[i]=='B')b++;
  }
  ll q=r*g*b;  //1個目の条件を満たした数
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k=j*2-i; // ２個目の条件式を変形して2個目の条件に合わないkを出した
      if(k>=n|| s[i]==s[j]||s[k]==s[i]||s[k]==s[j])continue; // kがn以上（インデントがn-1までより）または、文字が合うもの（1個目の条件）を除く（ｑが1個目の条件を満たす仮想状態である為）
      q--; //これにより、1個目の条件を満たすものの中から、2個目の条件を満たさないものを削る
    }
  }
  cout << q << endl;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
// ll pas[5001][5002];

struct edge {
	int to, cap, rev;
};

class Flow {
	int n;
	std::vector<std::vector<edge>> G;
	std::vector<int> level, iter;

	void bfs(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front();
			que.pop();
			for (int i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (level[v] < level[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, std::min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

  public:
	Flow(int n) : n(n) {
		G.resize(n);
		level.resize(n);
		iter.resize(n);
	}
	void add_edge(int from, int to, int cap) {
		G[from].push_back((edge){to, cap, (int)G[to].size()});
		G[to].push_back((edge){from, 0ll, (int)G[from].size() - 1});
	}
	int max_flow(int s, int t) {
		int flow = 0;
		while (1) {
			bfs(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = dfs(s, t, 1e9)) > 0) {
				flow += f;
			}
		}
	}
};

int main() {
	IOS();
	ll h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	ll sx, sy, tx, ty;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == 'S') sx = i, sy = j;
			if (s[i][j] == 'T') tx = i, ty = j;
		}
	}
	if (sx == tx || sy == ty) {
		dump(-1);
		return 0;
	}
	Flow fl(h + w + 2);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] != '.') fl.add_edge(i, h + j, 1);
			if (s[i][j] != '.') fl.add_edge(h + j, i, 1);
		}
	}
	const int unko = 114514810;
	fl.add_edge(h + w, sx, unko);
	fl.add_edge(h + w, h + sy, unko);
	fl.add_edge(tx, h + w + 1, unko);
	fl.add_edge(h + ty, h + w + 1, unko);
	dump(fl.max_flow(h + w, h + w + 1));

	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n + 1);
    copy_n(istream_iterator<int64_t>(cin), n + 1, A.begin());

    vector<int64_t> S(n + 1);
    for (int i = n; i > 0; i--)
        S[i - 1] = S[i] + A[i];

    vector<int64_t> DP(n + 1);
    DP[0] = 1;
    for (int i = 0; i < n; i++){
        DP[i + 1] = min(2 * (DP[i] - A[i]), S[i]);
    }

    for (int i = 0; i <= n; i++){
        if (DP[i] <= 0){
            puts("-1");
            return 0;
        }
    }

    if (DP[n] != A[n]){
        puts("-1");
        return 0;
    }
    cout << accumulate(DP.begin(), DP.end(), 0L) << endl;
}

Measured memory_bytes: 5584
from math import ceil
from collections import deque

N,D,A = map(int,input().split())
monsters = sorted([list(map(int,input().split())) for _ in range(N)])

q = deque([])
s = 0

ans = 0
for i in range(N):
  while len(q) > 0 and q[0][0] < monsters[i][0]:
    s -= q[0][1]
    q.popleft()

  h = monsters[i][1] - s * A
  if h > 0:
    num_bombs = ceil(h / A)

    q.append((monsters[i][0] + 2 * D, num_bombs))
    s += num_bombs
    ans += num_bombs
    
print(ans)


Measured memory_bytes: 66368
#include <stdio.h>

int main( void ) {
	int n, a, b, c, d, sum;

	for ( ; scanf( "%d", &n ) == 1; printf( "%d\n", sum ) ) {
		sum = 0;
		for ( a = 0; a < 10; a++ )
			for ( b = 0; b < 10; b++ )
				for ( c = 0; c < 10; c++ )
					for ( d = 0; d < 10; d++ )
						sum += a + b + c + d == n;
	}

	return 0;
}

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_vars(...) do { cerr << "DEBUG: line "<< __LINE__ << ": " << __PRETTY_FUNCTION__ << ":  "; \
                            pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;
#define X first
#define Y second
#define pb push_back

istream &operator>> (istream &fin, mp &p) { fin >> p.first >> p.second; return fin; }
ostream &operator<< (ostream &fout, const mp &p)
{ fout << "{" << p.first << ", " << p.second << "} "; return fout; }

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cerr << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cerr << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr ll INF = numeric_limits<ll>::max();
constexpr ll MOD = 1e9 + 7;


constexpr ll MAX = 1e5 + 5;

int main()
{
    ll n; cin >> n;
    ll s = 0;
    ll m = n;
    while (m) {
        s += m % 10;
        m /= 10;
    }
    if (n % s == 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
using namespace std;
int main(){
    int N;
    cin>>N;
    double total=0;
    for(int i=0;i<N;i++){
        double x;
        string v;
        cin>>x>>v;
        if(v=="JPY"){
            total+=x;
        }else{
            total+=x*380000;
        }
    }
    cout<<total<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<ctype.h>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    string A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;
    bool fir=true;

int main(){
    cin>>A>>B>>C;
    if(A[(signed)A.size()-1]==B[0]&&B[(signed)B.size()-1]==C[0]){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i<N; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        if(N-K<=0){
            p(0);
            return;
        }
        long sum = 0;
        for(int i = N-1-K; i>=0; i--) {
            sum += a[i];
        }
        p(sum);
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll,ll>> A(N);
  REP(i, N) cin >> A[i].first >> A[i].second;
  sort(A.begin(), A.end());
  ll ans = 0;
  REP(i,N){
    if (M == 0) break;
    if(M<=A[i].second){
      ans += A[i].first * M;
      M = 0;
    }else{
      ans += A[i].first * A[i].second;
      M -= A[i].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4824
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  string s;
  cin >> s;
  string x = string(s.length(), 'x');
  cout << x;
  return 0;
}


Measured memory_bytes: 256
// abc117_a
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;

int main(int argc, char *argv[])
{
  int t, x;
  cin >> t >> x;
  double ans;
  ans = (double)t / x;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

double P[200100];

signed main(void){
  int N,K; cin >> N >> K;
  for(int i = 0; i < N; i++){ cin >> P[i]; P[i] = (P[i]+1)/2;}
  
  double ans = 0;
  queue<double> Q; double sum = 0;
  for(int i = 0; i < K; i++){
    Q.push(P[i]); sum += P[i];
  } 
  
  ans = sum;
  
  for(int i = K; i < N; i++){ 
    
    double q = Q.front(); sum -= q;
    Q.pop(); sum += P[i]; Q.push(P[i]);
    ans = max(ans, sum);
    
  }
  
 printf("%.20f\n",ans);
  
  return 0;
}


Measured memory_bytes: 3456
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    String[] ab = line.split(" ");
    int a = Integer.parseInt(ab[0]);
    int b = Integer.parseInt(ab[1]);
    int c = Integer.parseInt(ab[2]);
    if(a < b && b < c) {
      System.out.println("Yes");
    }else {
      System.out.println("No");
    }

  }
}



Measured memory_bytes: 26296
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

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

#define MAX 1000
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

int w,h;
char b[64][16];
bool f[64][16];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int bb[64][16];

int ss[200];
int sminx[200];
int smaxx[200];
int g[200];
int nums[200];
int on[200][200];
int cl;

void clustering(int x, int y, char num, int cl){
  if(f[y][x]) return;
  if(b[y][x] != num) return;

  f[y][x] = true;
  bb[y][x] = cl;

  REP(i,4){
    int xx = x + dx[i];
    int yy = y + dy[i];
    if(xx >= 0 && xx <= w-1 && yy >= 0 && yy <= h-1)
      clustering(xx, yy, num, cl);
  }
}

int main(){
  while(scanf("%d%d",&w,&h), w+h){
    REP(i,h) scanf("%s",b[i]);
    memset(f, 0, sizeof(f));
    cl = 1;
    REP(i,h) REP(j,w){
      if(!f[i][j]){
        if(b[i][j] != '.')
          clustering(j,i,b[i][j],cl++);
        else
          bb[i][j]=0;
      }
    }
    REP(i,w) bb[h][i] = cl;
    REP(i,cl){
      smaxx[i] = -1;
      sminx[i] =  w;
      g[i]     =  0;
      nums[i]  =  0;
    }

    REP(i,cl+1) REP(j,cl+1) on[i][j] = MAX;

    REP(i,h) REP(j,w){
      int b1 = bb[i][j];
      int b2 = bb[i+1][j];
      if(b1 != 0){
        g[b1] += j;
        nums[b1]++;
      }
      if(b1 == 0 || b2 == 0 || b1 == b2) continue;
      ss[b1] = b2;
      on[b1][b2] = 1;
      sminx[b1] = min(sminx[b1], j);
      smaxx[b1] = max(smaxx[b1], j);
    }

    REP(k,cl) REP(i,cl) REP(j,cl)
      on[i][j] = min(on[i][j], on[i][k] + on[k][j]);

    /*
    REP(i,h){REP(j,w)printf("%d ",bb[i][j]); puts("");}
    for(int i=1; i<cl; i++){
      printf("%d: nums=%d, g=%.1f, minx=%d, maxx=%d, ss=%d\n",i,nums[i],(double)g[i]/nums[i],sminx[i],smaxx[i],ss[i]);
      printf(" ue: ");
      for(int j=1; j<cl; j++)
        if(on[j][i] != MAX)
          printf("%d ",j);
      puts("");
    }
    */

    bool ans = true;

    for(int i=1; i<cl; i++){
      int gg = g[i];
      int nn = nums[i];
      for(int j=1; j<cl; j++){
        if(on[j][i] != MAX){
          gg += g[j];
          nn += nums[j];
        }
      }
      double ggg = (double)gg/nn;
      double minx = sminx[i] - 0.5 + EPS;
      double maxx = smaxx[i] + 0.5 - EPS;

      if(minx > ggg || maxx < ggg){
        ans = false;
        break;
      }
    }

    puts(ans?"STABLE":"UNSTABLE");


  }
  return 0;
}

Measured memory_bytes: 0
/*
AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com
*/

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define seti set<lli>
#define pii pair<lli,lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";
#define printset(st) for(auto xt : st) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define endl '\n'

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}

lli sumdig(lli n){
    if(n==0)return 0;
    return(n%10+sumdig(n/10));
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n;
    cin>>n;
    print(n+n*n+n*n*n);
  }
return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

typedef struct{
  int num;
  int p_key;
  int r_key;
  int l_key;
} Tree;

Tree data[251];

void shokika(int);

int main(){
  
  int n, i;

  scanf("%d",&n);

  for(i = 1; i <= n; i++)
    {
      shokika(i);
      
      scanf("%d",&data[i].num);

      if(i == 0)continue;

      data[i].p_key = data[i/2].num;
      if(i % 2 == 0)data[i/2].l_key = data[i].num;
      else data[i/2].r_key = data[i].num;
    }

  for(i = 1; i <= n; i++)
    {
      printf("node %d: key = %d, ", i, data[i].num);
      if(i != 1)printf("parent key = %d, ",data[i].p_key);
      if(data[i].l_key != 2000000001)printf("left key = %d, ", data[i].l_key);
      if(data[i].r_key != 2000000001)printf("right key = %d, ", data[i].r_key);
      printf("\n");
    }
   
    return 0;   
}

void shokika(int i)
{
  data[i].l_key = 2000000001;
  data[i].r_key = 2000000001;
}



Measured memory_bytes: 2048
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	if (s.substr(0,1) == s.substr(1,1) || s.substr(1,1) == s.substr(2,1) || s.substr(2,1) == s.substr(3,1)) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
row1 = map(int, input().split())
row2 = map(int, input().split())
row3 = map(int, input().split())
row = list(row1) + list(row2) + list(row3)

bs = [int(input()) for i in range(int(input()))]

comb = [
    [0,1,2],
    [3,4,5],
    [6,7,8],

    [0,3,6],
    [1,4,7],
    [2,5,8],

    [0,4,8],
    [2,4,6],
]

for lst in comb:
    if len([1 for num in lst if row[num] in bs]) == 3:
        print('Yes')
        exit()
print('No')



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

int main() {
  int A, B;
  cin >> A >> B;
  double C, D, E, F;
  C = A / 0.08;
  D = B / 0.1;
  E = (A + 1) / 0.08;
  F = (B + 1) / 0.1;
  C = ceil(C);
  E = floor(E);
  if (E <= D || F <= C) {
    cout << -1;
  }
  else {
    cout << int(max(C,D));
  }
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<pair<int,int> > x(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    x[i]=make_pair(a[i]+b[i],i);
  }
  sort(x.begin(),x.end(),greater<pair<int,int> >());
  int ans=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      ans+=a[x[i].second];
    }else{
      ans-=b[x[i].second];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
def func():
    N, K, Q = map(int, input().split())
    Ncorrect = [0] * N

    for i in range(Q):
        A = int(input()) - 1
        Ncorrect[A] += 1

    for i in range(N):
        if K - Q + Ncorrect[i] > 0:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    func()


Measured memory_bytes: 50776
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int main(){

  int a,b;  
  scanf("%d %d",&a,&b);
 
  if(a < b){
    printf("a < b\n");
  }

  else if(a == b){
    printf("a == b\n");
  }

  else{
    printf("a > b\n");
  }
  
 

  return 0; 
}

Measured memory_bytes: 580
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	long long int num;
	int a, b, c;
	int flag = 0;
	cin >> a >> b >> c;
	for (num = a; num < 100000000; num = num + a)
	{
		if (num%b == c)
		{
			flag = 1;
			break;
		}
	}
	if (flag == 1)
	{
		cout << "YES" << endl;
	}
	else if (flag == 0)
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll c = b*100+0.5;
    ans = (a*c)/100;
    cout << ans << endl;
    }
       


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

int main() {
    long a,b,c,x,y,sum;
    cin>>a>>b>>c>>x>>y;
    if(x>y) {
        swap(x,y);
        swap(a,b);
    }
    if(a+b>2*c) {
        sum = 2*c*x + (y-x)*b;
    } else{
        sum = a*x+b*y;
    }
    if(sum > 2*c*y) sum = 2*c*y;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int main(void){
    int N;
    vector<int> H;

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        int v;
        scanf("%d", &v);
        H.insert(H.begin() + i, v);
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        int a = H[i];
        bool is = false;
        for (int j = 0; j < i; j++) {
            int b = H[j];
            if (b > a) {
                is = true;
                break;
            }
        }
        if (!is) {
            count++;
        }
    }

    printf("%d\n", count);
    fflush(stdout);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include <cstring>
using namespace std;
char ch[1000000],l,r;
int a;

int main(){
    scanf("%s",ch);
    a=strlen(ch);
    for(int i=0;i<a;i++){
        if(l==0){
            if(ch[i]=='C'){
                l=1;
            }
        }
        else{
            if(ch[i]=='F'){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  if (B > A) {
    if (A - B + (V - W) * T >= 0) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  else {
    if (A - B - (V - W) * T <= 0) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int n,k;

int main()
{
    
        scanf("%d%d",&n,&k);
        if(k==1)
        {
            printf("0");
            return 0;
        }
        int sum = n, c=1;
        while(sum < k)
        {
            sum += n-1;
            c++;
        }
        printf("%d",c);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main{
	public void solve(){
		String s = next();
		int len = (1 << (s.length() - 1));
		
		long ans = 0;
		for(int i = 0; i < len; i++){
			int prev = 0;
			for(int j = 0; j < s.length() - 1; j++){
				if((i & (1 << j)) != 0){
					ans += Long.parseLong(s.substring(prev, j + 1));
					prev = j + 1;
				}
			}
			ans += Long.parseLong(s.substring(prev));
		}
		out.println(ans);
	}
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 8660
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  while(cin>>n>>m,n||m){
    int l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    bool flg=0;
    for(int i=0;i<(1<<m);i++){
      int tmp=__builtin_popcountll(i);
      if(tmp!=l[0]) continue;
      string s;
      for(int j=0;j<m;j++) s.push_back('0'+((i>>j)&1));
      bool ok=1;
      for(int j=1;j<n;j++){
	tmp-=(s[j-1]=='1');
	if(tmp==l[j]) s.push_back('0');
	else if(tmp==l[j]-1) s.push_back('1'),tmp++;
	else{
	  ok=0;
	  break;
	}
      }
      if(ok){
	cout<<s<<endl;
	flg=1;
	break;
      }
    }
    if(!flg) cout<<"Goofy"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

void solve(ll n,ll a,ll b){
    if(a*b==n){
        for(ll i=b-1;i>=0;i--){
            for(int j=1;j<=a;j++){
                cout<<i*a+j<<" ";
            }
        }
    }
    else if(a*(b-1)>=n-1){
        cout<<n<<" ";
        solve(n-1,a,b-1);
    }
    else{
        int u=n-a*(b-1);
        for(ll i=-u+1;i<=0;i++){
            cout<<n+i<<" ";
        }
        solve(n-u,a,b-1);
    }
}

int main(){
    ll i,j;
    ll n,a,b;
    cin>>n>>a>>b;
    if(a+b-1>n){
        cout<<-1<<endl;
        return 0;
    }
    if(a*b<n){
        cout<<-1<<endl;
        return 0;
    }
    solve(n,a,b);
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	}

}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
const int M=2e5+5;
int L[M],R[M],A[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++)L[i]=max(A[i],L[i-1]);
	for(int i=n;i>=1;i--)R[i]=max(A[i],R[i+1]);
	for(int i=1;i<=n;i++)printf("%d\n",max(L[i-1],R[i+1]));
	return 0;
}


Measured memory_bytes: 3968