akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define  pb push_back
#define sort1(v) sort(v.begin(),v.end())
#include <sstream>
//cout<<fixed<<setprecision(n)<<number - for n digits after decimal
long long int max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}
void print(vector<int>arr)
{
    for(int i=0;i<(int)arr.size();i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void upd(int a[],int l,int r,int num)
{
    for(int i=l;i<=r;i++)
        a[i]+=num;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll mod=1e9+7;
    ll a=1,b=1,c=1;
    for(int i=0;i<n;i++)
    {
        a=a*10;
        a=a%mod;
        b=b*9;
        b=b%mod;
        c=c*8;
        c=c%mod;
    }
    ll ans=(a-2*b+c)%mod;
    ans=(ans+mod)%mod;
    cout<<ans;
}








Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

void solve()
{
    int n;
    cin >> n;
    
    cout << ((n <= 999) ? "ABC" : "ABD");
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;

int main() {
    fastio();

    cin >> n;
    vec<pii> x(n);
    forn(i, n) {
        cin >> x[i].fst >> x[i].snd;
    }

    sort(all(x), [](pii x, pii y) { return x.fst + x.snd < y.fst + y.snd; });

    int c = 1;
    int cur = x[0].fst + x[0].snd;
    for (int i = 1; i < n; i++) {
        if (x[i].fst - x[i].snd >= cur) {
            cur = x[i].fst + x[i].snd;
            c++;
        }
    }

    cout << c << endl;

    return 0;
}

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

const int MAXL = ( int ) 1e5 + 1;

string S, T;
int sapfx[ MAXL ], sbpfx[ MAXL ];
int tapfx[ MAXL ], tbpfx[ MAXL ];

signed main(){
  ios::sync_with_stdio( 0 );
  cin >> S >> T;
  for( int i = 0; i < S.size(); ++i ){
    sapfx[ i + 1 ] = sapfx[ i ] + ( S[ i ] == 'A' );
    sbpfx[ i + 1 ] = sbpfx[ i ] + ( S[ i ] == 'B' );
  }
  for( int i = 0; i < T.size(); ++i ){
    tapfx[ i + 1 ] = tapfx[ i ] + ( T[ i ] == 'A' );
    tbpfx[ i + 1 ] = tbpfx[ i ] + ( T[ i ] == 'B' );
  }
  int Q; cin >> Q;
  for( int qi = 0; qi < Q; ++qi ){
    int slb, srb, tlb, trb;
    cin >> slb >> srb >> tlb >> trb;
    --slb, --tlb; // [ lb, rb )
    int sa = sapfx[ srb ] - sapfx[ slb ];
    int sb = sbpfx[ srb ] - sbpfx[ slb ];
    int ta = tapfx[ trb ] - tapfx[ tlb ];
    int tb = tbpfx[ trb ] - tbpfx[ tlb ];
    int x = sa * 2 + sb;
    int y = ta * 2 + tb;
    if( x % 3 == y % 3 ){
      cout << "YES\n";
    } else{
      cout << "NO\n";
    }
  }
  return 0;
}


Measured memory_bytes: 2512
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);
  int A[N+1];
  for (int i = 1; i <= N; ++i) {
    int t;
    scanf("%d", &t);
    A[t] = i;
  }
  for (int i = 1; i <= N; ++i) {
    printf("%d\n", A[i]);
  }
  return 0;
}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    long double a, b, c; cin >> a >> b >> c;
    long double eps = 1e-14;
    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々


Measured memory_bytes: 256
import heapq

N,u,v = map(int,input().split())
u -= 1
v -= 1

du = [float('inf')]*N
dv = [float('inf')]*N
G = [[]]*N

def calcDist(s, dist):
    q = []
    heapq.heappush(q,[0, s])
    dist[s] = int(0)
    
    while q!=[]:
        p = heapq.heappop(q)
        pv = p[1]
        if dist[pv] < p[0] :
            continue
        for i in range(len(G[pv])):
            eto = G[pv][i]
            if dist[eto] > dist[pv] + 1:
                 dist[eto] = int(dist[pv] + 1)
                 heapq.heappush(q, [dist[eto], eto])


for i in range(N-1):
    e1,e2 = map(int, input().split())
    e1 -= 1
    e2 -= 1
    if G[e1] == []:
        G[e1] = [e2]
    else:
        G[e1].append(e2)
    if G[e2] == []:
        G[e2] = [e1]
    else:
        G[e2].append(e1)

if v in G[u]:
    ans = 0
else:    

    calcDist(v,dv)
    calcDist(u,du)
    maxD = 0
    for idu,idv in zip(du,dv):
        if idu < idv:
            maxD = max(maxD, idv)       
    ans = maxD-1
    
print(ans)

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

int main(){
long long n;
cin>>n;
long long sum1=0;
long long sum2=0;
long long sum3=0;
long long sum4=0;
string s;
for(long long i=0;i<n;i++){
    cin>>s;
    if(s=="AC"){
        sum1++;
    }
    else if(s=="WA"){
        sum2++;
    }
    else if(s=="TLE"){
        sum3++;
    }
    else{
        sum4++;
    }
}
cout<<"AC"<<' '<<"x"<<' '<<sum1<<endl;
cout<<"WA"<<' '<<"x"<<' '<<sum2<<endl;
cout<<"TLE"<<' '<<"x"<<' '<<sum3<<endl;
cout<<"RE"<<' '<<"x"<<' '<<sum4<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <limits>
using namespace std;
int main(){
    int n,l,a[201];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum;
    int minsum=numeric_limits<int>::max();
    for(int i=-100;i<=100;i++){
        sum=0;
        for(int j=0;j<n;j++){
            sum+=(a[j]-i)*(a[j]-i);
        }
        if(sum<minsum){
            minsum=sum;
        }
    }
    cout<<minsum;
}

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

int main() {
	int a, b;
	
	cin >> a >> b;
	
	if (a < b) {
		cout << "a < b" << endl;
	}
	if (a > b) {
		cout << "a > b" << endl;
	}
	if (a == b) {
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

string ToUpper(string str)
{
  string upper = str;
  transform(upper.begin(), upper.end(), upper.begin(), ::toupper);

  return upper;
}

void solve()
{
  string a,b,c;
  cin >> a >> b >> c;

  a = ToUpper(a);
  b = ToUpper(b);
  c = ToUpper(c);

  cout << a[0] << b[0] << c[0] << endl;
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        long s = 1;
        
        for (int i = 1; i <= n ; i++) {
            s = s * i % 1000000007;
        }
        System.out.println(s);   
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<uint32_t> A(N);
  for(auto &&a: A) std::cin >> a;

  uint64_t money = 1000, stock = 0;
  for (size_t i = 1; i < N; i++)
  {
    if(A[i-1] < A[i]){
      stock += money / A[i-1];
      money = money % A[i-1];
    }else if(A[i-1] > A[i]){
      money += A[i-1]*stock;
      stock = 0;
    }
  }  

  std::cout << money + stock*A.back() << std::endl;

  return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int H, W, K;
char c[12][12];

int main() {

	cin >> H >> W >> K;
	rep(i, H) {
		cin >> c[i];
	}

	int ans = 0;
	rep(h, 1 << H) {
		rep(w, 1 << W) {
			vector<vector<bool>> red(H, vector<bool>(W, false));
			rep(i, H) {
				if ((h >> i) & 1) {
					rep(j, W) red[i][j] = true;
				}
			}
			rep(i, W) {
				if ((w >> i) & 1) {
					rep(j, H) red[j][i] = true;
				}
			}
			int cnt = 0;
			rep(i, H) {
				rep(j, W) {
					if (!red[i][j] && c[i][j] == '#') cnt++;
				}
			}
			if (cnt == K) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << max(C - (A - B), 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);
  vector<int> t(n);
  for (auto& e : t) cin >> e;
  Cin(int, m);
  vector<int> p(m), x(m);
  for (int i = 0; i < m; ++i) cin >> p[i] >> x[i];

  for (int i = 0; i < m; ++i) {
    int ans = 0;
    for (int j = 0; j < n; ++j) {
      if (j == p[i]-1)
        ans += x[i];
      else
        ans += t[j];
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())

# 連続するn区間に橋をかける方法は何通りあるか
# kakekata[b][i] : bが0の時はi区間目に橋をかけない方法 bが1の時はi区間目に橋をかける方法 が何通りあるか
kakekata = [[0] * 10] + [[0] * 10]
kakekata[0][0] = 1
for i in range(8):
    kakekata[0][i + 1] = kakekata[0][i] + kakekata[1][i]
    kakekata[1][i + 1] = kakekata[0][i]


MOD = 10 ** 9 + 7
class modint:
    def __init__(self, x):
        self.x = x.x if isinstance(x, modint) else x % MOD
    def __str__(self): return str(self.x)
    __repr__ = __str__
    def __int__(self): return self.x
    __index__ = __int__
    def __add__(self, other): return modint(self.x + modint(other).x)
    def __sub__(self, other): return modint(self.x - modint(other).x)
    def __mul__(self, other): return modint(self.x * modint(other).x)
    def __pow__(self, other): return modint(pow(self.x, modint(other).x, MOD))
    def __floordiv__(self, other): return modint(self.x * pow(modint(other).x, MOD - 2, MOD))
    def __eq__(self, other): return self.x == modint(other).x
    def __ne__(self, other): return self.x != modint(other).x
    def __inv__(self): return pow(self.x, MOD - 2, MOD)


dp = [[modint(0)] * (W + 2) for h in range(H + 1)]
dp[0][1] += 1
for h in range(H):
    for w in range(1, W + 1):
        # 左に何区間あるか 右に何区間あるか
        l, r = w - 1, W - w

        # そのまま渡す
        dp[h + 1][w] += dp[h][w] * kakekata[0][l] * kakekata[0][r]
        # 右に渡す
        dp[h + 1][w + 1] += dp[h][w] * kakekata[0][l] * kakekata[1][r]
        # 左に渡す
        dp[h + 1][w - 1] += dp[h][w] * kakekata[1][l] * kakekata[0][r]

print(dp[H][K])


Measured memory_bytes: 3188
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char tehuda[100005];
int main(void) {
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    ll sum = 0;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == 'r') {
            tehuda[i] = 'p';
        }
        else if (t[i] == 's') {
            tehuda[i] = 'r';
        }
        else {
            tehuda[i] = 's';
        }
    }
  
    for (int i = 0; i < t.size(); i++) {
        if (i > k - 1) {
            if (tehuda[i - k] != tehuda[i]) {
                if (t[i] == 'r') {
                    sum+=p;
                }
                else if (t[i] == 's') {
                    sum += r;
                }
                else {
                    sum += s;
                }
            }
            else {
                tehuda[i] = 'd';
                continue;
            }
        }
        else {
            if (t[i] == 'r') {
                sum += p;
            }
            else if (t[i] == 's') {
                sum += r;
            }
            else {
                sum += s;
            }
        }
        
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3848
N,K = map(int,input().split())
P_LIST = list(map(int,input().split()))
for i in range(N):
    P_LIST[i] = (P_LIST[i] + 1) / 2
ruisekiwa = [0] * (N + 1)
for i in range(N):
    ruisekiwa[i+1] = P_LIST[i] + ruisekiwa[i]
#print(P_LIST)
#print(ruisekiwa)
result = 0
for i in range(N-K+1):
    result = max(ruisekiwa[i+K] - ruisekiwa[i],result)
    #print(max(ruisekiwa[i+K] - ruisekiwa[i],result))
print(result)

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

int main()
{
	int n;
	cin>>n;
	int house[4][3][10] = {0};
	for(int i = 0; i < n ; i++){
		int b,f,r,v;
		cin>>b>>f>>r>>v;
		house[b-1][f-1][r-1] += v;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10 ; k++){
				cout<<" "<<house[i][j][k];
			}
			cout<<endl;
		}
		if(i != 3){
			cout<<"####################"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$ans = array_sum($b);
for ($i = 1; $i < $n; $i++) if ($a[$i] - $a[$i - 1] == 1) $ans += $c[$a[$i] - 2];
echo $ans;
?>

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#include <tr1/unordered_map>

using namespace std::tr1;
using namespace std;

typedef long long ll;

bool isprime[1000000+100];
int n = 1000000;
void sieve(int x)
{
    memset(isprime,true,sizeof(isprime));

    isprime[0]=isprime[1]=false;
    for(int i=2; (long long)i*i<=(long long)x; i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i; j<=x; j+=i)
            {
                isprime[j]=false;
            }
        }
    }

}

long long bigmod(long long a,long long b,long long m)
{
    ll res = 1%m;

    while(b>0)
    {
        if(b&1)
        {
            res = (res * a) %m;
        }

        a = (a * a)%m;
        b>>=1;

    }
    return res;



}

int main(void)
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    map<string,int>m;
   while(t--)
   {
       string s;
       cin>>s;
       m[s]++;
   }
   cout<<"AC x "<<m["AC"]<<endl;
   cout<<"WA x "<<m["WA"]<<endl;
   cout<<"TLE x "<<m["TLE"]<<endl;
   cout<<"RE x "<<m["RE"]<<endl;

}








Measured memory_bytes: 3664
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

string VACANT = "Vacant", MALE = "Male", FEMALE = "Female";

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string last;
	int n; cin >> n;
	
	cout << 0 << endl;
	cin >> last;
	if (last == VACANT) return 0;
	
	int start = (last == MALE);
	int left = 0, right = n;
	while (left + 1 < right) {
		int mid = (left + right) / 2;
		cout << mid << endl;
		cin >> last;
		if (last == VACANT) return 0;
		
		int shouldBeenMale = (start + mid) % 2;
		int isMale = (last == MALE);
		if (shouldBeenMale == isMale) {
			left = mid;
		} else {
			right = mid;
		}
	}
	
	cout << right << endl;
}


Measured memory_bytes: 852
W, H , N = list(map(int, input().split()))
W0 = 0
H0 = 0
X = []
Y = []
A = []
for i in range(N):
    x,y,a=[int(i) for i in input().split()]
    X.append(x)
    Y.append(y)
    A.append(a)
for j in range (N):
    if A[j] == 1:
        if X[j] >=  W0:
            W0 = X[j]
    elif A[j] == 2:
        if X[j] <= W:
            W = X[j]
    elif A[j] == 3:
        if Y[j] >= H0:
            H0 = Y[j]
    elif A[j] == 4:
        if Y[j] <= H:
            H = Y[j]
h = H - H0
w = W - W0
if h >=0 and w >= 0:
    print(h*w)
else:
    print(0)
    


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n;
ll a[200005];
ll b[200005];

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i], &b[i]);
    }
    sort(a, a + n);
    sort(b, b + n);
    ll mn, mx;
    if(n % 2 == 1)
    {
        mn = a[(n - 1) / 2];
        mx = b[(n - 1) / 2];
    }
    else
    {
        mn = a[n / 2] + a[n / 2 - 1];
        mx = b[n / 2] + b[n / 2 - 1];
    }
    printf("%lld\n", mx - mn + 1);
    return 0;
}


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
const int maxn=1e5;
struct wjmzbmr
{
    ll d;
    int id;
    bool operator < (const wjmzbmr &x) const
    {
        return d<x.d;
    }
}a[maxn+5];
int n;
vector<int> g[maxn+5];
unordered_map<ll,int> s;
int dep[maxn+5],sz[maxn+5];
vector<pair<int,int> > ans;
bool work()
{
    for(int i=n;i>1;--i)
    {
        int u=s[a[i].d+2*sz[a[i].id]-n];
        if(u==0||u==a[i].id) return false;
        s[a[i].d]=0;
        ans.push_back(mp(u,a[i].id));
      //  printf("%d %d\n",u,a[i].id);
        g[u].push_back(a[i].id);
        sz[u]+=sz[a[i].id];
    }
    return true;
}
void dfs(int k,int deep)
{
    dep[k]=deep+1;
    for(auto x:g[k]) dfs(x,dep[k]);
}
int main()
{

    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&a[i].d),a[i].id=i,s[a[i].d]=i,sz[i]=1;
    sort(a+1,a+n+1);
    if(!work()) printf("-1");
    else
    {
        dfs(a[1].id,-1);
        ll tmp=0;
        for(int i=1;i<=n;++i) tmp+=dep[i];
       // cout<<tmp<<endl;
        if(tmp!=a[1].d) printf("-1");
        else
        {
            for(auto x:ans) printf("%d %d\n",x.first,x.second);
        }
    }
    return 0;
}


Measured memory_bytes: 15648
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		sc.close();
		
		int ten = n/10;
		int one = n-ten*10;
		
		if(ten==9 || one==9) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


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

using namespace std;

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  list<int> ls;
  list<int>::iterator it = ls.end();
  while(q--) {
    int op;
    cin >> op;
    if (op == 0) {
      int x;
      cin >> x;
      it = ls.insert(it, x);
    }
    else if (op == 1) {
      int d;
      cin >> d;
      if (d > 0) {
        for(int i = 0; i < d; i++) {
          it++;
        }
      }
      else {
        for(int i = 0; i < -d; i++) {
          it--;
        }
      }
    }
    else if (op == 2) {
      it = ls.erase(it);
    }
  }
  for(auto i : ls) {
    cout << i << endl;
  }
  return 0;
}



Measured memory_bytes: 18672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
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; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

template <typename T> inline
map<T, int> prime_factor(T n) {
  map<T, int> ret;
  for(T i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b; cin >> a >> b;
  ll g = gcd(a,b);
  auto mp = prime_factor(g);
  cout << mp.size()+1 << endl;
  return 0;
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
N = map(int, input().split())
Alist = list(map(int, input().split()))
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


lcm_a = lcm_list(Alist)
mod = 10**9 + 7
ans = 0

for a in Alist:
    ans += (lcm_a // a)
print(ans % mod)


Measured memory_bytes: 5588
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable(current, next_data)
    tc, xc, yc = current
    tn, xn, yn = next_data
    dist = (xc - xn).abs + (yc - yn).abs
    
    return false if dist > tn - tc

    (dist - (tn - tc)).even?
end

current = [0, 0, 0]
data.each do |d|
    unless is_reachable(current, d)
        puts 'No'
        exit 0
    end
    current = d
end

puts 'Yes'


Measured memory_bytes: 9468
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);

//main function
int main() {
    int n = iin(), i, haveZero = 0, mc = 0, min = INT_MAX, tmp;
    int a[n];
    long long total = 0;
    REP(i,n) {
        a[i] = iin();
        if (a[i] == 0) haveZero = 1;
        else if (a[i] < 0) mc++;
    }
    REP(i,n) {
        tmp = abs(a[i]);
        total += tmp;
        if (min > tmp) min = tmp;
    }
    if (haveZero) {
        llout(total);
    } else if (mc % 2) {
        llout(total - (min * 2));
    } else {
        llout(total);
    }


    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
struct Node{
	   int key,id;
	   Node *parent,*left,*right;
};
Node *root,*NIL;
vector<int> r;
void insert(int k){
	 Node *y,*x,*z;
	 y=NIL;
	 x=root;
	 z=(Node *)malloc(sizeof(Node));
	 z->key=k;
	 z->left=NIL;
	 z->right=NIL;
	 while (x!=NIL){
	 	   y=x;
	 	   if (z->key<x->key)
	 	     x=x->left;
	 	   else
	 	     x=x->right;
	 }
	 if (y==NIL){
	 	root=z;
	 }
	 else
	    if (z->key<y->key)
	       y->left=z;
	    else
	       y->right=z;
}
void pre(Node *u){
	 if (u==NIL) return;
	 //r.push_back(u->key);
	 cout<<' '<<u->key;
	 pre(u->left);
	 pre(u->right);
}
void in(Node *u){
	 if (u==NIL) return;
	 in(u->left);
	 cout<<' '<<u->key;
	 //r.push_back(u->key);
	 in(u->right);
}
int n,x;
string s;
int main(){
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>s;
		if (s[0]=='i'){
			cin>>x;
			insert(x);
		}
		else{
			in(root);
		    cout<<'\n';
			pre(root);
			cout<<'\n';
		    //cout<<r[n];
		    //for (int j=n+1; j<2*n; j++)
		     //   cout<<' '<<r[j];
		}
		   
	}
	
	return 0;
} 


Measured memory_bytes: 26636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//How I Mathematician Wonder What You Are!
public class Main{

	final double EPS = 1.0e-8;
	double norm(Point p) {
		return Math.hypot(p.x, p.y);
	}
	double inp(Point p1, Point p2) {
		return p1.x*p2.x + p1.y*p2.y;
	}
	double extp(Point p1, Point p2) {
		return p1.x*p2.y - p2.x*p1.y;
	}
	Point sub(Point p1, Point p2) {
		return new Point(p1.x-p2.x, p1.y-p2.y);
	}
	int ccw(Point a, Point b, Point c) {
		Point p = sub(b, a);
		Point q = sub(c, a);
		if(extp(p, q) > EPS) return 1;		// counter clockwise
		if(extp(p, q) < -EPS)return -1;		// clockwise
		if(inp(p, q) < -EPS) return 2;		// c--a--b on line
		if(Math.abs(norm(p) - norm(q)) < EPS) return -2;	// a--b--c on line
		return 0;				// a--c--b(or a--c=b) on line 
	}
	Point crosspoint(Line l, Line m) {
		if(isParallel(l, m)){
			throw new IllegalArgumentException("parallel");
		}
		  double A = extp(sub(l.t, l.s), sub(m.t, m.s));
		  double B = extp(sub(l.t, l.s), sub(l.t, m.s));
		  if (Math.abs(A) < EPS && Math.abs(B) < EPS) return m.s; // same line
		  if (Math.abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
		  Point tp = sub(m.t, m.s);
		  return new Point(m.s.x + B/A*tp.x, m.s.y + B/A*tp.y);
	}

	boolean isParallel(Line l, Line m){
		Point a = new Point(l.t.x - l.s.x, l.t.y - l.s.y);
		Point b = new Point(m.t.x - m.s.x, m.t.y - m.s.y);
		if(Math.abs(Math.abs((a.x*b.x + a.y*b.y)/(Math.hypot(a.x, a.y)*Math.hypot(b.x, b.y)) - 1)) < EPS){
			return true;
		}
		return false;
	}
	double area(Point[] p) {
		double s = 0;
		for(int i=0; i<p.length; i++) {
			int j = (i+1)%p.length;
			s += extp(p[i], p[j]);
		}
		return Math.abs(s);
	}
	Point[] convexCut(Point[] p, Line l) {
		List<Point> q = new ArrayList<Point>();
		for (int i = 0; i < p.length; ++i) {
			Point a= p[i], b = p[(i+1)%p.length];
			if (ccw(l.s, l.t, a) != -1) q.add(a);
		    if (ccw(l.s, l.t, a)*ccw(l.s, l.t, b) < 0)
		      q.add(crosspoint(new Line(a, b), l));
		}
		return q.toArray(new Point[q.size()]);
	}

	class Point {
		double x;
		double y;
		public Point(double x_, double y_) {
			x = x_; y=y_;
		}
	}
	class Line {
		Point s,t;
		Line(Point s_, Point t_) {
			s = s_; t = t_;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			Point[] p = new Point[n];
			for(int i=0;i<n;i++)p[i]=new Point(sc.nextDouble(), sc.nextDouble());
			Point[] c = new Point[4];
			c[0] = new Point(0, 0);
			c[1] = new Point(10000, 0);
			c[2] = new Point(10000, 10000);
			c[3] = new Point(0, 10000);
			for(int i=0;i<n;i++){
				Line l = new Line(p[i], p[(i+1)%n]);
				c = convexCut(c, l);
				if(area(c)<EPS)break;
			}
			System.out.println(area(c)<EPS?0:1);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    // Your code here!
    int x,y;
    
    while(1){
        scanf("%d %d" , &x,&y);
        if ( x == 0  && y == 0 )
        break;
        
        if ( x > y ){
            printf("%d %d\n",y,x);}
        else{
            printf("%d %d\n",x,y);}
        }
        return 0;
}



Measured memory_bytes: 2032
#include <iostream>

using namespace std;
#define MAX (int)2e5

int box[MAX+1];
int cond[MAX+1];
int main(void){
  int N;
  cin >> N;
  for(int i=1;i<=N;i++){
    int ai;
    cin >> ai;
    cond[i] = ai;
  }

  for(int n=N;0<n;n--){
    int num = 2;
    int sum = 0;
    // 2以上の倍数の玉の数をたす
    while(num*n <= N){
      sum = (sum + box[num*n])%2;
      num++;
    }
    if(cond[n] == 1){
      if(sum == 1){
	box[n] = 0;
      }else{
	box[n] = 1;
      }
    }else{
      if(sum == 1){
	box[n] = 1;
      }else{
	box[n] = 0;
      }
    }
  }
  int ball = 0;
  for(int i=1;i<=N;i++){
    ball = ball + box[i];
  }
  cout << ball << endl;
  bool flag = false;
  for(int i=0;i<=N;i++){
    if(box[i] == 1){
      flag = true;
      cout << i << " ";
    }
  }
  if(flag)
    cout << endl;
  return 0;
}


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

int a[9], n, k;

int main() {
  for(int j=0; j<9; j++){
    cin>>a[j];
  }
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>k;
    for(int q=0; q<9; q++){
      if(a[q]==k){
        a[q]= 0;
      }
    }
  }
  if((a[0]==0&&a[3]==0&&a[6]==0)||(a[1]==0&&a[4]==0&&a[7]==0)||(a[2]==0&&a[5]==0&&a[8]==0)||(a[0]==0&&a[4]==0&&a[8]==0)||(a[2]==0&&a[4]==0&&a[6]==0)||(a[0]==0&&a[1]==0&&a[2]==0)||(a[3]==0&&a[4]==0&&a[5]==0)||(a[6]==0&&a[7]==0&&a[8]==0)){
    cout<<"Yes\n";
  } 
  else{
    cout<<"No\n";
  }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i=0;i<m;i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());

    vector<int> diffs(m);
    for(int i=1;i<m;i++){
        diffs.push_back(x[i]-x[i-1]);
    }
    sort(diffs.begin(),diffs.end(),greater<int>());
    
    int ans = x[m-1]-x[0];
    for(int i=0;i<min((int)diffs.size(),n-1);i++){
        ans -= diffs[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a , b , c , d , w , x , y , z;
  cin >> a >> b >> c >> d;
  w = a*c;
  x = a*d;
  y = b*c;
  z = b*d;
  cout << max(w , max(x , max(y,z))) << endl;
}

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

int main()
{
  ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
  int k, s, ans = 0;
  cin >> k >> s;
  
  for(int x = 0; x <= k; x++)
  {
    for(int y = 0; y <= k; y++)
    {
      int z =  s-x-y;
      if(z >= 0 and z <= k)
        ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for l in range(c+1):
            sums = 500*i + 100*j + 50*l
            if sums==x:
                count += 1
print(count)

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

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

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            var ab = cin.ReadIntArray(2);


            WriteLine(ab[0]*ab[1]%2==0?"Even":"Odd");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
def main():
    mod=998244353
    n,m,k=map(int,input().split())
    inv=lambda x: pow(x,mod-2,mod)
    Fact=[1] #階乗
    l=max(n,m)
    for i in range(1,l+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(l+1) #階乗の逆元
    Finv[-1]=inv(Fact[-1])
    for i in range(l-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    ans=0
    for i in range(k+1):
        c=comb(n-1,i)
        p=m*pow(m-1,n-i-1,mod)
        #print(i,c,p)
        ans+=c*p
        ans%=mod
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 82428
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n; cin >> n;
    vector<int> v0(n/2), v1(n/2);
    rep(i, n/2) {
        cin >> v0[i] >> v1[i];
    }
    // v0、v1それぞれで、最大要素と、次に大きい要素の数を数える
    map<int, int> v0m, v1m;
    rep(i, n/2) {
        if (!v0m.count(v0[i])) {
            v0m[v0[i]] = 1;
        } else {
            v0m[v0[i]] += 1;
        }
        if (!v1m.count(v1[i])) {
            v1m[v1[i]] = 1;
        } else {
            v1m[v1[i]] += 1;
        }
    }
    P v0f, v0s, v1f, v1s;
    for (auto x: v0m) {
        if (v0f.second <= x.second) {
            // 一番より大きい場合
            v0s = v0f;
            v0f = x;
        } else if (v0s.second <= x.second) {
            // 二番より大きい場合
            v0s = x;
        }
    }
    for (auto x: v1m) {
        if (v1f.second <= x.second) {
            // 一番より大きい場合
            v1s = v1f;
            v1f = x;
        } else if (v1s.second <= x.second) {
            // 二番より大きい場合
            v1s = x;
        }
    }

    int ans = 0;
    if (v0f.first == v1f.first) {
        /*
        // 同じ要素がマックスの場合
        if (v0f.second + v1s.second >= v1f.second + v0s.second) {
            // v1fを2個目に変更
            v1f = v1s;
        } else {
            // v0fを2個目に変更
            v0f = v0s;
        }*/
        ans = min(n-v0f.second-v1s.second, n-v0s.second-v1f.second);
    } else {
        ans = n - v0f.second - v1f.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
#define all(v) (v).begin(),(v).end()
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=100000000000000000;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
ll n;
cin>>n;
vector<ll> a(n),sum(n+1,0);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n;i++)sum.at(i+1)=a.at(i)+sum.at(i);
ll ans=0,res=0,tmp=0;
//vector<ll> sum=sums;
for(int i=1;i<n+1;i++){
   if(i%2==1&&sum.at(i)+tmp<=0){
      ans+=1-(sum.at(i)+tmp);
      tmp+=(1-(sum.at(i)+tmp));
   } 
   else if(i%2==0&&sum.at(i)+tmp>=0){
       ans+=1+sum.at(i)+tmp;
       tmp-=(1+sum.at(i)+tmp);
   } 
}
tmp=0;
for(int i=1;i<n+1;i++){
   if(i%2==0&&sum.at(i)+tmp<=0){
      res+=1-(sum.at(i)+tmp);
      tmp+=(1-(sum.at(i)+tmp));
   } 
   else if(i%2==1&&sum.at(i)+tmp>=0){
       res+=1+sum.at(i)+tmp;
       tmp-=(1+sum.at(i)+tmp);
   } 
}
cout<<min(ans,res)<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a+b==c)||(a+c==b)||(b+c==a))
    printf("Yes");
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int A[5],x=-1;
  	for(int i=0;i<5;i++)
    {
    	cin>>A[i];
    }
  	for(int i=0;i<5;i++)
    {
    	if(A[i]==0)
          x=i+1;
    }
  	cout<<x;
  return 0;
}

Measured memory_bytes: 3616
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

void main() {
    string n;
    scan(n);

    writeln("ABC" ~ n);
}




void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#define MYDEBUG
/*
 * A.cpp
 *
 *  Created on: 2018/07/10 14:18
 *      Author: jln
 */

#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	out << endl;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
	out << "{" << p.first << "," << p.second << "}";
	return out;
}
struct edge {
	int from, to, cost;
	edge(int f, int t, int c) {
		from = f;
		to = t;
		cost = c;
	}
	edge() {
		from = -1;
		to = -1;
		cost = -1;
	}
	bool operator<(const edge& e) const {
		return cost < e.cost;
	}
};
struct vertex {
	int id, val1, val2;
	vertex(int id_, int val1_, int val2_) {
		id = id_;
		val1 = val1_;
		val2 = val2_;
	}
	vertex() {
		id = 0;
		val1 = val2 = 0;
	}
};
ostream& operator<<(ostream& out, const edge& e) {
	out << "(";
	out << e.from << "->" << e.to << ": ";
	out << e.cost;
	out << ")";
	return out;
}
ostream& operator<<(ostream& out, const vertex& v) {
	out << "<";
	out << v.id << ": ";
	out << v.val1 << ", "; //なにかの要素，値
	out << v.val2; //なにかの要素，値
	out << ">";
	return out;
}
typedef struct edge edge;
typedef struct vertex vertex;
void solve() {
	int n;
	cin >> n;
	cout << (n % 2 == 0 ? n : n * 2) << endl;
}
int main() {
	solve();
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a+b==c||a+c==b||b+c==a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())

tot = 0

for i in range(N):
    res = 0
    temp = i+1
    while temp >= 10000:
        res += 1
        temp -= 10000
    while temp >= 1000:
        res += 1
        temp -= 1000
    while temp >= 100:
        res += 1
        temp -= 100
    while temp >= 10:
        res += 1
        temp -= 10
    res += temp

    if (A <= res) & (res <= B):
        tot += i+1


print(tot)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
int trump[4][13] = {{}};  
int n;
cin>>n;
int b;
char a;
for(int i = 0;i <= n;i++){
    cin >> a >> b;
    switch(a){
    case'S':
    trump[0][b-1]=1;
    break;
    case'H':
    trump[1][b-1]=1;
    break;
    case'C':
    trump[2][b-1]=1;
    break;
    case'D':
    trump[3][b-1]=1; 
    break;     }
    }
    for(int i=0;i<=52;i++) {
        switch(i/13){  
            case 0: 
            if(trump[0][i%13]==0) 
            cout<<"S"<<" "<<i%13+1<<endl;
            break;
            case 1:  
            if(trump[1][i%13]==0) 
            cout<<"H"<<" "<<i%13+1<<endl; 
            break;
            case 2: 
            if(trump[2][i%13]==0) 
            cout<<"C"<<" "<<i%13+1<<endl;
            break;
            case 3:    
            if(trump[3][i%13]==0) 
            cout<<"D"<<" "<<i%13+1<<endl;
            break;  }
            }
    
}



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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

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

    ll x1 = floor(a/0.08);
    ll x2 = floor(b/0.10);

    // cout<<x1<<" "<<x2<<endl;

    bool found = false;

    ll l,r;
    if (x1<x2)
    {
        l = x1-100;
        r = x2+100;
    }
    else
    {
        l = x2-100;
        r = x1+100;
    }
    
    int i = l;
    for (; i<=r; i++)
    {
        // cout<<floor(i*0.08)<<" "<<floor(i*0.10)<<endl;
        if (floor(i*0.08) == a && floor(i*0.10) == b)
        {
            found = true;
            break;
        }
    }

    if (found)
    {
        cout<<i<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <functional>
using namespace std;
#define P pair<int, int>

priority_queue<P, vector<P>, greater<P> > pq;
bool f[100];
vector<P> v[100];

int prim()
{
	int cost = 0;
	f[0] = 1;
	for (int i = 0; i < v[0].size(); i++) {
		pq.push(v[0][i]);
	}
	P p;
	while (!pq.empty()) {
		p = pq.top(); pq.pop();
		if (f[p.second]) continue;
		f[p.second] = 1;
		cost += p.first;
		for (int i = 0; i < v[p.second].size(); i++) {
			pq.push(v[p.second][i]);
		}
	}
	
	return cost;
}

int main()
{	
	int n, m;
	while (cin >> n, n) {
		cin >> m;
		for (int i = 0; i < n; i++) {
			v[i].clear();
			f[i] = 0;
		}
		for (int i = 0; i < m; i++) {
			int from, to, cost;
			scanf("%d,%d,%d", &from, &to, &cost);
			cost = cost / 100 - 1;
			v[from].push_back(P(cost, to));
			v[to].push_back(P(cost, from));
		}
		cout << prim() << endl;
	}
		
	return 0;
}

Measured memory_bytes: 1548
#include <stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  if((a==b && b!=c)||(a!=b && b==c)||(a==c && c!=b)) {printf("Yes");return 0;}
  printf("No");
  return 0;
}

Measured memory_bytes: 128
n, k = map(int,input().split())
List = []
List2 = []
list3 = []
for i in range(k):
    d = int(input())
    List.append(list(map(int,input().split())))
for i in range(len(List)):
    List2.extend(List[i])
for i in range(1,n+1):
    list3.append(i)
print(len(list(set(list3)-set(List2))))

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

 int main() {
   int N, D;
   cin >> N >> D;
   if ( N % (1 + 2*D) == 0) {
     cout << N / (1 + 2*D) << '\n';
   }else cout << (N / (1 + 2*D)) + 1  << '\n';

 }


Measured memory_bytes: 256
n,m = map(int,input().split());

A = [];
for i in range(0,n):
    A += list(map(int, input().split()));

        
B = [];
for k in range(0,m):
    b = int(input());
    B.append(b);

q = 0;
for j in range(0,n):
    x = 0;
    for i in range(0,m):
        x += A[q]*B[i];
        q += 1;
    print(x);


Measured memory_bytes: 6012