akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 0
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

mi g;
mi viz;

bool acc (int h, int w)
{
    if (h < 0 || sz (g) <= h) return false;
    if (w < 0 || sz (g[0]) <= w) return false;
    return g[h][w];
}

void dfs (int h, int w)
{
    if (!acc (h, w)) return;
    dd printf ("Enter % 3d % 3d, viz[% 3d][% 3d]:% 3d\n", h, w, h, w, viz[h][w]);
    if (acc (h, w - 1))
        if (viz[h][w] + 1 < viz[h][w - 1])
        {
            viz[h][w - 1] = viz[h][w] + 1;
            dfs (h, w - 1);
        }
    if (acc (h, w + 1))
        if (viz[h][w] + 1 < viz[h][w + 1])
        {
            viz[h][w + 1] = viz[h][w] + 1;
            dfs (h, w + 1);
        }
    if (acc (h - 1, w))
        if (viz[h][w] + 1 < viz[h - 1][w])
        {
            viz[h - 1][w] = viz[h][w] + 1;
            dfs (h - 1, w);
        }
    if (acc (h + 1, w))
        if (viz[h][w] + 1 < viz[h + 1][w])
        {
            viz[h + 1][w] = viz[h][w] + 1;
            dfs (h + 1, w);
        }
}

int main ()
{
    FASTIO;
    int i, j, n, h, w, mx, mn, k, l;
    string s;
    cin >> h >> w;
    getline (cin, s);
    g = mi (h, vi (w));
    viz = mi (h, vi (w));
    for (i = 0; i < h; ++i)
    {
        getline (cin, s);
        for (j = 0; j < szl (s); ++j)
        {
            if (s[j] == '.') g[i][j] = 1;
            else g[i][j] = 0;
        }
    }
    dd trav (v, g)
    {
        trav (a, v)
            printf ("% 3d", a);
        printf ("\n");
    }
    dd printf ("-------------------------\n");

    mx = -1;
    for (i = 0; i < h; ++i)
    {
        for (j = 0; j < w; ++j)
        {
            trav (v, viz)
                trav (a, v)
                    a = INFi;
            viz[i][j] = 0;
            dfs (i, j);
            dd trav (v, viz)
            {
                trav (a, v)
                    printf ("% 3d", a);
                printf ("\n");
            }
            dd printf ("-------------------------\n");
            for (k = 0; k < h; ++k)
                for (l = 0; l < w; ++l)
                    if (acc (k, l) && viz[k][l] != INFi) mx = max (mx, viz[k][l]);
        }
    }
    cout << mx << '\n';

    return 0;
}




Measured memory_bytes: 256
use std::io::{self, Read, Write};
use std::str::{self, FromStr};

pub struct IO<R: Read, W: Write>(R, io::BufWriter<W>);

impl<R: Read, W: Write> IO<R, W> {
    pub fn new(reader: R, writer: W) -> Self {
        Self(reader, io::BufWriter::new(writer))
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
        .0
        .by_ref()
        .bytes()
        .map(|b| b.unwrap())
        .skip_while(|&b| (b as char).is_whitespace())
        .take_while(|&b| !(b as char).is_whitespace())
        .collect::<Vec<u8>>();

        unsafe { str::from_utf8_unchecked(token.as_slice()) }
        .parse()
        .ok()
        .expect("Can't parse it.")
    }

    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }

    pub fn write<S: ToString>(&mut self, s: S) {
        self
        .1
        .write_all(s.to_string().as_bytes())
        .unwrap();
    }

    pub fn flush(&mut self) {
        self
        .1
        .flush()
        .unwrap();
    }
}


fn main() {
    let (r, w) = (io::stdin(), io::stdout());
    let mut rw = IO::new(r.lock(), w.lock());

    let (A, B, C, X): (u32, u32, u32, u32) = (rw.read(), rw.read(), rw.read(), rw.read());

    let mut ans = 0;
    for a in 0..=A {
        for b in 0..=B {
            for c in 0..=C {
                ans += if 500 * a + 100 * b + 50 * c == X {1} else {0};
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int MAX = 2010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void Main()
{
    COMinit();
    int N, K; cin >> N >> K;
    rep(i, K)
    {
        cout << (COM(N - K + 1, i + 1) * COM(K - 1, i) % MOD) << endl;
    }
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 256
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]

# print(f)
# print(p)
ans=-2**(31-1)

for i in range(1,2**10):
    list=[0]*n
    earn=0
    for j in range(10):
        for k in range(n):
            if i&(1<<j) and f[k][j]==1:
                list[k]+=1
    
    for k in range(n):
        earn+=p[k][list[k]]
    
    ans=max(ans, earn)
print(ans)

Measured memory_bytes: 42348
import sys

def resolve():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    cnt = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                if 500*i + 100*j + 50*k == X:
                    cnt += 1
    print(cnt)



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 39024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] answers = new int[N + 1];
			for(long x = 1; x <= 100; x++) {
				for(long y = 1; y <= 100; y++) {
					for(long z = 1; z <= 100; z++) {
						final long p = x * x + y * y + z * z + x * y + y * z + z * x;
						
						if(p > N) { continue; }
						
						answers[(int)(p)]++;
					}
				}
			}
			
			for(int i = 1; i <= N; i++) {
				System.out.println(answers[i]);
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 36076
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

#define debug(x) cout << #x << ": " << (x) << endl;

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

vector<vector<bool>> G;
vector<bool> visited;
int node_counter = 0;
int N, M;

void dfs(int n) {
  if (visited[n])
    return;

  visited[n] = true;
  node_counter++;

  rep(i, N) {
    if (n == i || !G[n][i]) continue;
    dfs(i);
  }
}

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

  cin >> N >> M;
  G.assign(N, vector<bool>(N, false));
  visited.assign(N, false);

  int a, b;
  rep(i, M) {
    cin >> a >> b;
    G[a-1][b-1] = true;
    G[b-1][a-1] = true;
  }

  int ans = 0;
  rep(i, N) REP(j, i + 1, N) {
    if (!G[i][j]) continue;
    G[i][j] = G[j][i] = false;

    dfs(0);

    ans += (node_counter != N);
    node_counter = 0;

    rep(k, N) visited[k] = false;
    G[i][j] = G[j][i] = true;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

    int n;cin>>n;
    vector<string> v;
    v.push_back("");v.push_back(".,!? ");v.push_back("abc");
    v.push_back("def");v.push_back("ghi");v.push_back("jkl");
    v.push_back("mno");v.push_back("pqrs");v.push_back("tuv");
    v.push_back("wxyz");
    for(int i=0;i<n;i++){
        string s;cin>>s;
        s+='0';
        string res="";
        int cnt=0,idx=0;
        for(int j=0;j<(int)s.length();j++){
            if(s[j]-'0' ==0){
                if(cnt==0) continue;
                res+=v[idx][(cnt-1)%(v[idx].length())];
                cnt=0;
            }
            else{
                idx=s[j]-'0';
                cnt++;
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 3192
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


class FenwickTree {
    public:
        FenwickTree(int n) : N(n), data(n, 0) {

        }

        void put(int x, long long v) {
            for (; x < N; x |= x + 1) {
                data[x] += v;
            }
        }

        long long get(int x) {
            long long res = 0;
            for (; x >= 0; x = (x & (x + 1)) - 1) {
                res += data[x];
            }
            return res;
        }

        int kthElement(long long K) {
            int res = 0;
            int h = 0;
            while (1 << (h + 1) <= N) {
                ++h;
            }

            for (int i = h; i >= 0; --i) {
                if (res + (1 << i) > N) {
                    continue;
                }
                if (data[res + (1 << i) - 1] < K) {
                    K -= data[res + (1 << i) - 1];
                    res |= 1 << i;
                }
            }

            return res;
        }

    private:
        int N;
        vector<long long> data;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

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

    vector<int> X(A);
    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    auto index = [&](int x) {
        auto it = lower_bound(X.begin(), X.end(), x);
        assert(*it == x);
        return it - X.begin();
    };

    for (auto& x : A) {
        x = index(x);
    }

    FenwickTree ft(n);

    for (int i = 1; i < n; ++i) {
        ft.put(A[i], 1);
    }

    int K = (n - 1) / 2 + 1;
    cout << X[ft.kthElement(K)] << '\n';

    for (int i = 1; i < n; ++i) {
        ft.put(A[i - 1], 1);
        ft.put(A[i], -1);
        cout << X[ft.kthElement(K)] << '\n';
    }

    return 0;
}

Measured memory_bytes: 5376
n = int(input())
a = [1]
for i in range(2,32):
	a.append(i**2)
for i in range(2,11):
	a.append(i**3)
for i in range(2,6):
	a.append(i**4)
for i in [2,3]:
	a.append(i**5)
	a.append(i**6)
for i in [7,8,9]:
	a.append(2**i)

b = set(a)
a = sorted(list(b), reverse=True)
for i in range(len(a)):
	if a[i] <= n:
		print(a[i])
		break

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main()
{
    long long x;
    cin >> x;
    for (long long a = 0; a <= 200; a++) {
        for (long long b = -200; b <= a; b++) {
            long long y = a * a * a * a * a - b * b * b * b * b;
            if (x == y) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
int h,n;
int dp[1001];
int v[4000],cost[4000];
int ans = 1e-9;
/*
int go(int i,int sum){

        if(dp[i][sum]!=-1) return dp[i][sum];

       dp[i][sum] =min(val[i]+go(i+1,W-a[i]),go(i+1,W));
       return dp[i][sum];
}
*/
void go(int i,int x, int y ){

     ans = max(ans,x-y);
    if(i>n){
      return ;
    }
    go(i+1,v[i]+x,cost[i]+y);
    go(i+1,x,y);
    return;
}
 int main()
{
   // fast;

    int n;
    cin >> n;
    int a[n+10];
    for(int i = 1; i<=n; i++) cin >> a[i];
    int ans = 0,mx = 0;
    for(int i = 1; i<=n; i++){
        mx = max(a[i],mx);
        if(mx<=a[i]) ans++;
    }
    cout << ans << '\n';

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	int N;
	cin >> N;
	int res = 0;
	for(int i = 1; i < N; i++) {
		if(i < N-i) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int C[6] = {500, 100, 50, 10, 5, 1};
int main(void){
	int n;
	while(cin >> n, n){
	n = 1000-n;
	int cnt = 0;
	int val = 0;
	while(n != 0){
		if(n - C[val] < 0){
			val++;
		}else{
			n -= C[val];
			cnt++;
		}
	}
	FIN(cnt);
	}
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll N;

int main(){
    cin>>N;

    ll ans=0;
    repn(k,sqrt(N)){
        if(N%k==0){
            ll m=N/k;
            if(k<m-1) ans+=m-1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    int64_t sum = 0;
    int64_t count = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'B')
        {
            count++;
        }
        else
        {
            sum += count;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 644
N = int(input())
A = list(map(int,input().split()))
if N==1:
    if A[0]==0:
        print(1)
    else:
        print(0)
else:
    C = {}
    for i in range(N):
        a = A[i]
        if a not in C:
            C[a]=0
        C[a] += 1
    flag = 0
    if N%2==0:
        for i in range(1,N,2):
            if i in C and C[i]==2:continue
            flag=1
            break
    else:
        for i in range(2,N,2):
            if i in C and C[i]==2:continue
            flag = 1
            break
        if 0 not in C or C[0]!=1:
            flag = 1
    if flag==1:
        print(0)
    else:
        p = 10**9+7
        k = N//2
        ans = 1
        cnt = 1
        while cnt<=k:
            ans = (ans*2)%p
            cnt += 1
        print(ans)

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

using namespace std;
int main()
{

    int n,arr[205];
    cin >> n;
    int k = 2*n;
    for(int i =0;i<k;++i)
    {

        cin >> arr[i];
    }
    sort(arr, arr+k);
    int sum =0;
    for(int i =0;i<k;i = i +2)
    {
         sum = sum + min(arr[i], arr[i+1]);
    }
    cout << sum;
}


Measured memory_bytes: 256
import sys,collections as cl
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[i]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a

n = int(input())

a = l()
aa = [a[0]]

for i in range(n-1):
	aa.append(aa[-1] + a[i+1])

ans = Max
l = 0
r = 2
s = aa[1]
su = aa[-1]-s
for i in range(1,n-1):
	while(l < i and (s >= abs(2*aa[l] - aa[i]))):
		s =  abs(2*aa[l] - aa[i])
		l += 1

	while(r < n and (su >= abs(aa[-1]-aa[r]-(aa[r] - aa[i])))):
		su = abs(aa[-1]-aa[r]-(aa[r] - aa[i]))
		r += 1
	ans = min(ans,(max(aa[l-1],aa[i]-aa[l-1],aa[r-1]-aa[i],aa[-1]-aa[r-1]) - min(aa[l-1],aa[i]-aa[l-1],aa[r-1]-aa[i],aa[-1]-aa[r-1])))
	s = abs(2*aa[l-1] - aa[i+1])
	su = abs(aa[-1]-aa[r-1]-(aa[r-1] - aa[i+1]))


print(ans)


Measured memory_bytes: 25920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		sb.append(a).insert(4,' ');
		System.out.println(sb);
	}
}

Measured memory_bytes: 8148
#include <stdio.h>

int hap[100001][3];
int dp[100001][3];

int max1(int a, int b) {
    if (a > b)
        return a;
    else
        return b;
}

int main(void)
{
	int N,i;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d%d%d",&hap[i][0],&hap[i][1],&hap[i][2]);
		dp[i][0]=dp[i][1]=dp[i][2]=0;
	}
	
	for(i=1;i<=N;i++){
		dp[i][0]=max1(dp[i-1][1]+hap[i-1][0],dp[i-1][2]+hap[i-1][0]);
		dp[i][1]=max1(dp[i-1][0]+hap[i-1][1],dp[i-1][2]+hap[i-1][1]);
		dp[i][2]=max1(dp[i-1][0]+hap[i-1][2],dp[i-1][1]+hap[i-1][2]);
		//printf("%d:%d\n",i+1,max1(dp[i][0],max1(dp[i][1],dp[i][2])));
	}
	printf("%d\n",max1(dp[N][0],max1(dp[N][1],dp[N][2])));
	return 0;
}


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

int block;

// Structure to represent a query range
struct Query
{
    int L, R,ID;
};

// Function used to sort all queries so that all queries
// of the same block are arranged together and within a block,
// queries are sorted in increasing order of R values.
bool compare(Query x, Query y)
{
    // Different blocks, sort by block.
    if (x.L/block != y.L/block)
        return x.L/block < y.L/block;

    // Same block, sort by R value
    return x.R < y.R;
}

    int a[500005];
    Query q[500005];
// Prints sum of all query ranges. m is number of queries
// n is size of array a[].
void queryResults(int n, int m)
{
    // Find block size
    block = (int)sqrt(n);

    // Sort all queries so that queries of same blocks
    // are arranged together.
    sort(q, q + m, compare);

    // Initialize current L, current R and current sum
    int currL = 0, currR = 0;
    int diffValues = 0;
    int mas[500000];
    for(int i=0; i<=n; i++) mas[i]=0;
    vector<pair<int,int> > ans;
    // Traverse through all queries
    for (int i=0; i<m; i++)
    {
        // L and R values of current range
        int L = q[i].L, R = q[i].R;

        // Remove extra elements of previous range. For
        // example if previous range is [0, 3] and current
        // range is [2, 5], then a[0] and a[1] are subtracted
        while (currL < L)
        {
            mas[a[currL]]--;
            if(mas[a[currL]]==0) diffValues--;
            currL++;
        }

        // Add Elements of current Range
        while (currL > L)
        {
            mas[a[currL-1]]++;
            if(mas[a[currL-1]]==1) diffValues++;
            currL--;
        }
        while (currR <= R)
        {
            mas[a[currR]]++;
            if(mas[a[currR]]==1) diffValues++;
            currR++;
        }

        // Remove elements of previous range.  For example
        // when previous range is [0, 10] and current range
        // is [3, 8], then a[9] and a[10] are subtracted
        while (currR > R+1)
        {
            mas[a[currR-1]]--;
            if(mas[a[currR-1]]==0) diffValues--;
            currR--;
        }

        // Print sum of current range
        ans.push_back({q[i].ID,diffValues});
    }
    sort(ans.begin(),ans.end());
    for(auto u:ans){
        cout<<u.second<<"\n";
    }
}

// Driver program
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<m; i++){
        q[i].ID=i;
        cin>>q[i].L>>q[i].R;
        q[i].L--;
        q[i].R--;
    }
    queryResults(n,m);
    return 0;
}


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

int main(){
    int X,Y;
    cin >> X >> Y;
    bool flag=0;
    rep(i,X){
        if(4*X-2*i==Y){
            int K=X-i;
            if(i+K==X){
                flag=1;
            }
        } 
    }
    if(flag){
        cout <<  "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(P a,P b) {
  return imag(conj(a)*b);
}

double dot(P a,P b) {
  return real(conj(a)*b);
}

int ccw(P a,P b,P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(P a1,P a2,P b1,P b2){
	return
		ccw(a1,a2,b1)*ccw(a1,a2,b2) <= 0 &&
		ccw(b1,b2,a1)*ccw(b1,b2,a2) <= 0;
}

bool intersectSP(P a1,P a2,P p) {
	return abs(a1-p)+abs(a2-p)-abs(a1-a2) < EPS; // triangle inequality
}

vector<P> convex_hull(vector<P> ps) {
	if(ps.size() == 1) return ps;

  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);

  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int convex_contains(vector<P> ps,P p) {
  int n = ps.size();
  P g = (ps[0] + ps[n/3] + ps[2*n/3]) / 3.0;
  int a = 0, b = n;
  while (a+1 < b) {
    int c = (a + b) / 2;
    if (cross(ps[a]-g, ps[c]-g) > 0) {
      if (cross(ps[a]-g, p-g) > 0 && cross(ps[c]-g, p-g) < 0)
				b = c;
      else
				a = c;
    } else {
      if (cross(ps[a]-g, p-g) < 0 && cross(ps[c]-g, p-g) > 0)
				a = c;
      else
				b = c;
    }
  }
  b %= n;
  if (cross(ps[a] - p, ps[b] - p) < 0) return 0;
  if (cross(ps[a] - p, ps[b] - p) > 0) return 2;
  return 1;
}

int main(void){
	int n,m;

	while(cin>>n>>m,n||m){
		vector<P> a(n);
		for(int i=0;i<n;i++) cin>>a[i].real()>>a[i].imag();
		vector<P> b(m);
		for(int i=0;i<m;i++) cin>>b[i].real()>>b[i].imag();

		a = convex_hull(a);
		b = convex_hull(b);

		bool flg = true;

		if(a.size() == 2 && b.size() == 2){
			flg = !intersectSS(a[0],a[1],b[0],b[1]);
		}
		else if(a.size() == 1 && b.size() == 2){
			flg = !intersectSP(b[0],b[1],a[0]);
		}
		else if(a.size() == 2 && b.size() == 1){
			flg = !intersectSP(a[0],a[1],b[0]);
		}

		if(b.size() >= 3){
			for(int i=0;i<n;i++){
				if(convex_contains(b,a[i])){
					flg = false;
					break;
				}
			}
		}
		if(a.size() >= 3){
			for(int i=0;flg && i<m;i++){
				if(convex_contains(a,b[i])){
					flg = false;
					break;
				}
			}
		}

		cout<<(flg?"YES":"NO")<<endl;
	}

	return 0;
}

Measured memory_bytes: 976
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int X = Integer.parseInt(sc.get());
		System.out.println(10 - X / 200);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32868
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int max = a;
    int others = b + c;
    if(max < b){
        max = b;
        others = a + c;
    }
    if(max < c){
        max = c;
        others = a + b;
    }
    int mul = max;
    for(int i = 0; i < k; i++){
        mul *= 2;
    }

    cout << others + mul << endl;
}

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

using namespace std; 

int n,m,a[105],b[105]; 

int main(){
	int odd,p1,p2,ma,mb; 
	cin>>n>>m; 
	for(int i=1; i<=m; ++i) cin>>a[i]; 
	odd=p1=p2=0; 
	for(int i=1; i<=m; ++i)
		if(a[i]&1){
			++odd;
			if(!p1) p1=i; 
			else if(!p2) p2=i; 
		}
 	if(odd>2) {
		puts("Impossible"); 
		return 0;
	}
	ma=mb=m; 
	if(ma>1){
		if(p1&&p2&&a[p1]<a[p2]) swap(a[p1],a[p2]); 
		if(p1) swap(a[1],a[p1]); 
		if(p2) swap(a[ma],a[p2]); 
		for(int i=2; i<ma; ++i) b[i]=a[i]; 
		b[1]=a[1]+1; 
		b[mb]=a[ma]-1; 
		if(!b[mb]) --mb; 	
	}
	if(ma==1){
		mb=2;
		b[1]=1; 
		b[2]=n-1;
		if(!b[mb]) --mb; 
	}
	for(int i=1; i<=ma; ++i) { cout<<a[i]; putchar(i==ma?'\n':' '); }	 
	cout<<mb<<endl; 
	for(int i=1; i<=mb; ++i) { cout<<b[i]; putchar(i==mb?'\n':' '); }  
	return 0; 
} 

Measured memory_bytes: 256
function main(input) {
  const args = input.split(' ');
  
  const A = args[0];
  const B = args[1];
  
  if (A <= 8 && B <= 8) {
    console.log('Yay!');
  } else {
    console.log(':(');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30560
n,a,b=map(int,input().split())
ctr=0
for i in range(n+1):
    tl1=list(str(i))
    tl2=[int(tl1[j]) for j in range(len(tl1))]
    if a<=sum(tl2)<=b:
        ctr+=i

print(ctr)


Measured memory_bytes: 2940
from collections import Counter
while True:
    N = int(input())
    if not N:
        break
    C = input().split()
    for i in range(N):
        cnt = Counter(C[:i+1]).most_common()
        if (len(cnt) == 1 and cnt[0][1] * 2 > N) or (len(cnt) > 1 and cnt[0][1] > cnt[1][1] + N - i - 1):
            print(cnt[0][0], i + 1)
            break
    else:
        print("TIE")

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

using namespace std;

int t,n;
int a[1000000];

int main() {
  cin >> n >> t;
  int res = 0;
  int to = -1;
  for (int i =0 ; i < n; i++) {
    int x;
    cin >> x;
    res += x + t - max(x, to);
    to = x + t;
  }
  cout << res << "\n";
}

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

int f(long long n){
    long long sum = 0;
    long long cnt = 1, res = 0;
    while(n >= cnt){
        n -= cnt;
        cnt++;
        res++;
        //cout << n << ' ' << cnt << endl;
    }
    return res;
}
 
int main()
{
    long long n, res = 0;
    cin >> n;
    for( long long i = 2; i * i <= n; i++ )
        if(n % i == 0){
            int cnt = 0;
            while(n % i == 0){
                n /= i;
                cnt++;
            }
            res += f(cnt);
        }
    if(n > 1)
        res += f(1);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
a, b, k = map(int, input().split())
ll = []
for i in range(k):
    if a+i <= b:
        ll.append(a+i)
for j in range(k):
    if not b-k+j+1 in ll and b-k+j+1>=a:
        ll.append(b-k+j+1)
for k in ll:
    print(k)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#define NMAX 2000001

int C[NMAX],n;

void CountingSort(int *, int *, int);

int main(){

  int i,*A,*B,k=0;

  scanf("%d",&n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]) k = A[i];
  }

  CountingSort(A, B, k);

  for(i=1;i<=n;i++){
    if(i == n) printf("%d\n",B[i]);
    else printf("%d ",B[i]);
  }
  return 0;
}

void CountingSort(int *A, int *B, int k){

  int i,j;
  for(i=0;i<=k;i++) C[i] = 0;
  for(j=1;j<=n;j++) C[A[j]]++;
  for(i=1;i<=k;i++) C[i] = C[i] + C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 17400
x,y = map(int,input().split())
if x <= y:
  a = y - x
else:
  a = 10 ** 10
if -x <= y:
  b = y + x + 1
else:
  b = 10 ** 10
if x <= -y:
  c = - y - x + 1
else:
  c = 10 ** 10
if -x <= -y:
  d = - y + x + 2
else:
  d = 10 ** 10
print(min(a,b,c,d))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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 = 1001001001;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vi l(n), r(n);
  REP(i, n-1) {
    l[i+1] = l[i];
    if(s[i]=='W') l[i+1]++;
  }
  rREPe(i, n-1) {
    r[i-1] = r[i];
    if(s[i]=='E') r[i-1]++;
  }
  int ans = INF;
  REP(i, n) chmin(ans, l[i]+r[i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    vector<int> a(6);
    vector<int>A(4);
    rep(i, 6) {
        cin >> a[i];
        if (a[i] == 1)A[0]++;
        else if (a[i] == 2)A[1]++;
        else if (a[i] == 3)A[2]++;
        else A[3]++;
    }
    sort(A.begin(), A.end());
    rep(i, 2) {
        if (A[i] != 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    req(i, 2, 4) {
        if (A[i] != 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3572
#include"bits/stdc++.h"
using namespace std;
int main() {
	int n, r; 
	cin >> n >> r;
	int mi = r;
	cin >> r;
	int ma = r - mi;
	mi = min(mi, r);
	for (int i = 2; i < n; i++) {
		cin >> r;
		ma = max(r - mi, ma);
		mi = min(mi, r);
	}
	cout << ma << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 200010;
const int MOD = 1000000007;
const int oo = 1e9;


int n , m, c[1010],ca,cb,cnt;
set<int> g[1010];
pii all[1010];
int dp[1010][1010];

void dfs(int u) {
	for (auto v : g[u]) {
		if (c[v] == c[u]) {
			puts("-1");
			exit(0);
		}
		if (c[v] == 0) {
			c[v] = (c[u] == 1 ? 2 : 1);
			if(c[v]==1)ca++;
			else cb++;
			dfs(v);
		}
	}
}
int calc(int idx , int rem){
	if(idx == cnt){
		return (rem * (rem-1))/2 + ((n-rem)*(n-rem-1))/2;
	}
	int &ret = dp[idx][rem];
	if(ret != -1)return ret;
	ret = min(calc(idx+1,rem+all[idx].first),calc(idx+1,rem+all[idx].second));
	return ret;
}
int main() {
	memset(dp,-1,sizeof dp);
	cin >> n >>  m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1 ; j <= n ; ++j) {
			if (i == j)continue;
			g[i].insert(j);
		}
	}
	for (int u, v, i = 0; i < m; ++i) {
		scanf("%d%d", &u, &v);
		g[u].erase(v);
		g[v].erase(u);
	}
	for (int i = 1; i <= n; i++) {
		if (c[i] == 0) {
			c[i] = 1;
			ca = 1;
			cb = 0;
			dfs(i);
			all[cnt] = make_pair(ca,cb);
			cnt++;
		}
	}
	printf("%d\n",calc(0,0));

	return 0;
}

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

using namespace std;

//#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()

const int maxn = 1010;
const int p = 1e9 + 7;

int dp[maxn][maxn];

int add(int a, int b) {
    return (a + b) % p;
}

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

    int n, m;
    cin >> n >> m;
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) continue;
            if (s[j - 1] == '.') {
                dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    cout << dp[n][m] << "\n";

    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  ll N;cin>>N;
  vector<ll> b(N);
  rep(i,N)cin>>b[i],b[i]=b[i]-(i+1);
  sort(b.begin(),b.end());
  ll m = (b.size()%2==0 ? (b[(N-1)/2+1]+b[(N-1)/2])/2 : b[(N-1)/2]);
  ll ans = 0;
  rep(i,N){
    ans += abs(m-b[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int N;int K=0;
vector<int> g[size];
map<pair<int,int>,int> edge;
vector<int> color(size,-1);
void dfs(int p,int v){
	int temp=1;
	K=max(K,(int)g[v].size());
	for(int u:g[v]){
		if(u==p) continue;
		if(color[edge[{p,v}]]==temp) temp++;
		color[edge[{v,u}]]=temp;
		temp++;
		dfs(v,u);
	}return;
}
int main(){
	cin>>N;
	int a,b;
	rep(i,0,N-1){
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		edge[{a,b}]=i;
		edge[{b,a}]=i;
	}
	edge[{-1,0}]=N-1;
    edge[{0,-1}]=N-1;
	color[N-1]=0;
	dfs(-1,0);
	cout<<K<<endl;
	rep(i,0,N-1){
		cout<<color[i]<<endl;
	}
}

Measured memory_bytes: 18944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String data;
		int[] nums = new int[101];
		while ((data = reader.readLine()) != null) {
			if (data.isEmpty())
				break;
			int num = Integer.parseInt(data);
			nums[num]++;
		}
		int max = 0;
		for (int i = 0; i < 101; i++) {
			max = Math.max(max, nums[i]);
		}
		for (int i = 0; i < 101; i++) {
			if (nums[i] == max) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  rep(i, N)
  {
    cin >> T[i];
    sum += T[i];
  }
  int M;
  cin >> M;
  vector<int> P(M), X(M);
  rep(i, M)
  {
    cin >> P[i] >> X[i];
  }
  rep(i, M)
  {
    cout << sum - (T[P[i] - 1] - X[i]) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) begin(V), end(V)
#define ALLR(V) rbegin(V), rend(V)
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec

#ifdef DEBUGGING
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using namespace std;

using namespace std;

ll solve() {
    ll N, K;
    cin >> K >> N;
    if (10 <= K) return N;
    return N + 100 * (10 - K);
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  
  cout << max(a[n/2]-a[n/2 -1], 0LL) << "\n";
}

Measured memory_bytes: 1024
N,M=map(int,input().split())
X=[]
for i in range(N):
  a,b=map(int,input().split())
  X +=[[a,b]]
X.sort()
answer=0
i=0
while M>0:
  if X[i][1]<=M:
    answer +=X[i][0]*X[i][1]
  elif X[i][1]>M:
    answer +=M*X[i][0]
  M -=X[i][1]
  i+=1
print(answer)

Measured memory_bytes: 19996
#include<bits/stdc++.h>
#define fill(arr,c) memset(arr,c,sizeof(arr))
#define perm(r) next_permutation(all(r))
//it gives bool value ans permute the string lexoggraphically
#define sortdesc greater<int>()
#define ll long long int 
//std::setfill('0') << std::setw(5) << 25; it adds leaing zeroes;
#define f(i,a) for(int i=0;i<a;i++)
#define fo(i,a) for(int i=1;i<=a;i++)
#define foo(i,x,n,c) for(ll i=x;i<n;i+=c)
#define foi(i,x,n,c) for(ll i=x;i>=n;i+=c)
#define fauto(i,m) for(auto i:m)
#define forall(a) for( auto itr=a.begin();itr!=a.end();itr++)
#define ld long double
#define in push_back
#define mll map<ll,ll>
#define mcl map<char,ll>
#define msl map<string,ll>
#define vi vector<int >
#define vl vector<ll >
#define vp vector< pair<int,int> >
#define vs vector <string> 
#define vc vector <char> 
#define o(a) cout<<a
#define os(a) cout<<a<<" "
#define en cout<<"\n";
#define testcase ll t ;cin>>t; while(t--)
#define ff first
#define ss second
#define pl pair<ll,ll>
#define pi pair<int,int>
#define all(a) (a).begin(), (a).end()

#define sz(a)  (a).size()
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
#define bitcount  __builtin_popcountll
#define imin o("imin");en;
using namespace std;
bool comp(const pair<int,int> &a , const pair<int,int> &b){
    if(a.first == b.first)  return a.second < b.second;
     return a.first < b.first;
}
bool comps(const pair<int,int> &a , const pair<int,int> &b){
    if(a.second == b.second)  return a.first< b.first;
     return a.second < b.second;
}
//ll pi=acos(0.0)*2;
void fastio()
{
    	ios::sync_with_stdio(0);
cin.tie(0);

}
void inout()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

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

int main()
{

string s;
cin>>s;
if(s[sz(s)-1]=='s')
s+="es";
else
s+="s";
o(s);
en;
return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <strings.h>
#include <cstring>
#include <algorithm>

using namespace std;
 
int main(){
    string mi;
    string me;
    int mya;
    int a,b;
    string p;
    cin >> mi;
    cin >> mya;
    for(int i = 0; i < mya; i++){
        cin >> me >> a >> b;
        if(me == "replace"){
            cin >> p;
            mi.replace(a, b - a + 1, p);
        }else if(me == "reverse"){
            reverse(mi.begin() + a, mi.begin() + b + 1);
        }else if(me == "print"){
            p = mi.substr(a, b - a + 1);
            cout << p << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main(){
  int n, S[10000], q, T[500], i, j, cnt = 0;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);
 
  scanf("%d", &q);
  for(j = 0; j < q; j++)
    scanf("%d", &T[j]);
   
 
   
  for(i = 0; i < q; i++)
    for(j = 0; j < n; j++)
      if(T[i] == S[j])   {
    cnt++;
    break;
      }
 
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  int n;
  cin >> n;
  cout << (n==5||n==7||n==3?"YES":"NO") << endl;
  return 0;
}

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

base=sum(A)

from collections import Counter
ad=Counter(A)
for _ in range(Q):
    b, c=map(int, input().split())
    if ad[b]!=0:
        base+=(c-b)*ad[b]
        ad[c]+=ad[b]
        ad[b]=0
    print(base)


Measured memory_bytes: 20868
local h, w, n = io.read("*n", "*n", "*n")
local t = {}

local function add(i_h, i_w)
  if not t[i_h] then t[i_h] = {} end
  local v = t[i_h][i_w]
  if v then t[i_h][i_w] = v + 1 else t[i_h][i_w] = 1 end
end

local function subtask(ah, bw)
  if 3 <= bw then add(ah, bw - 2) end
  if 2 <= bw and bw < w then add(ah, bw - 1) end
  if bw < w - 1 then add(ah, bw) end
end

for i = 1, n do
  local ah, bw = io.read("*n", "*n")
  if 3 <= ah then subtask(ah - 2, bw) end
  if 2 <= ah and ah  < h then subtask(ah - 1, bw) end
  if ah < h - 1 then subtask(ah, bw) end
end

local sum = 0
local tbl = {}
for i = 1, 9 do tbl[i] = 0 end
for k, v in pairs(t) do
  for k2, v2 in pairs(v) do
    tbl[v2] = tbl[v2] + 1
    sum = sum + 1
  end
end
local rem = (h - 2LL) * (w - 2LL) - sum
local str = tostring(rem):gsub("LL", "")
print(str)
for i = 1, 9 do print(tbl[i]) end


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

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

  for (int i = 0; i < s.length(); i++)
    s.at(i) = (s.at(i) - 'A' + n) % 26 + 'A';
  cout << s;
}

Measured memory_bytes: 256