akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
void P(int x,int y){printf("%d %d\n",x,y);}
int main(){
	int n;
	scanf("%d",&n);
	int N=n;
	while(N%2==0)N/=2;
	if(N==1){printf("No");return 0;}
	printf("Yes\n");
	P(1,2);P(2,3);P(3,1+n);P(1+n,2+n);P(2+n,3+n);
	if(n==3)return 0;
	for(int i=4,ls=1;i<=n;i+=4){
		if(i+4>n+1)break;
		if(n&3)P(i,i-ls);
		P(i,i+1);P(i+1,i+2);P(i+2,i+3);
		P(i+3,i+n);P(i+n,i+n+1);P(i+n+1,i+n+2);P(i+n+2,i+n+3);
		ls=i;
	}
	if(n%4==0){
		int ls=0;
		for(int t=4,i=4;i<n;i+=4){
			if(t+t==i)t=t+t;
			if(i==t&&(n&t)){
				if(ls)P(i,ls);else{
					P(i,n);P(i,i==4?1:i-4);
				}
				ls=t;
			}else P(i,i==4?1:i-4);
		}P(ls,n+n);
	}else
	if(n%4==1){
		P(1,n);P(n,n-1);
		P(1,n+n-1);P(n+n-1,n+n);
	}else
	if(n%4==2){
		P(3,n);P(n,n-1);
		P(3,n+n-1);P(n+n-1,n+n);
		P(1+n,n-2);P(n,n+n-2);
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
 
typedef pair<int, int> state;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    const int INF = 1.0e9;
    for(int N, M; cin >> N >> M && N;) {
        vector<vector<tuple<int, int, int>>> G(N);
        rep(i, M) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            --u; --v;
            G[u].emplace_back(v, d, c);
            G[v].emplace_back(u, d, c);
        }
        vector<int> mdist(N, INF), preEcos(N, INF);
        mdist[0] = preEcos[0] = 0;
        priority_queue<state, vector<state>, greater<state>> que;
        que.emplace(0, 0);
        while(!que.empty()) {
            int dis, cur;
            tie(dis, cur) = que.top(); que.pop();
            if(mdist[cur] < dis) continue;
            for(const auto& e : G[cur]) {
                int nv, ndis, ncos;
                tie(nv, ndis, ncos) = e;
                if(mdist[nv] > dis + ndis || (mdist[nv] == dis + ndis && preEcos[nv] > ncos)) {
                    mdist[nv] = dis + ndis;
                    preEcos[nv] = ncos;
                    que.emplace(mdist[nv], nv);
                }
            }
        }
        cout << accumulate(preEcos.begin(), preEcos.end(), 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
int p[10][10];
bool f[10][10];
using namespace std;

void ck(int x, int y){
  rep(i, 9){
    if(i != x && p[i][y] == p[x][y]) f[i][y] = f[x][y] = 1;
    if(i != y && p[x][i] == p[x][y]) f[x][i] = f[x][y] = 1;
  }
  FOR(i, 3 * (x / 3), 3 * ((x / 3) + 1)) FOR(j, 3 * (y / 3), 3 * ((y / 3)+1)){
    if(i == x && j == y) continue;
    if(p[i][j] == p[x][y])
      f[i][j] = f[x][y] = 1;
  }
} 
				       
int main(){
  int n;
  scanf("%d", &n);
  rep(i, n){
    if(i != 0) puts("");
    rep(i, 9) rep(j, 9) f[j][i] = 0;
    rep(i, 9) rep(j, 9)
      scanf("%d", &p[i][j]);

    rep(i, 9){
      rep(j, 9){
	ck(i, j);
	printf(f[i][j] ? "*":" ");
	printf("%d", p[i][j]);
      }
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e6)

int main(){
	ll x;
	cin >> x;
	ll ans=2*x/11;
	if(x%11==0) cout << 2*(x/11) << endl;
	else if(x%11<=6) cout << 2*(x/11)+1 << endl;
	else cout << 2*(x/11)+2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	string s;
	cin >> s;

	ll p = 0;
	ll g = 0;
	ll num = 0;

	REP(i, s.size()) {
		if (s[i] == 'g') {
			if (g >= p+1) {
				num++;
				p++;
			}
			else {
				g++;
			}
		}
		else {
			if (g >= p + 1) {
				p++;
			}
			else {
				num--;
				g++;
			}
		}
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	int A = 0;
	int B = 0;
	int C = 0;
	int K = 0;

	cin >> A >> B >> C;
	cin >> K;

	int a[3];
	a[0] = A;
	a[1] = B;
	a[2] = C;

	sort(a, a + 3);
	
	for (int i=0; i < K; i++) {
		a[2] = 2 * a[2];
	}

	int Ans = a[0] + a[1] + a[2];

	cout << Ans;

	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int a[n];//ソートするやつ
    int b[n];//ソートしないやつ
    REP(i,n){
        int t;
        cin >> t;
        a[i] = t;
        b[i] = t;
    }
    sort(a,a+n);
    int num1 = a[(n-1)/2];
    int num2 = a[n/2];
    for(int i:b){
        if(i<=num1)COUT(num2);
        else if(num2<=i)COUT(num1);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  int a0 = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a < a0) {
      ans += a0 - a;
      a = a0;
    }
    a0 = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut n: usize,
        k: usize
    }

    let mut cnt = 0;
    while n > 0 {
        n /= k;
        cnt += 1;
    }

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


Measured memory_bytes: 4352
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    bool ok=true;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0)ok=false;
    }
    if(ok)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    return 0;
}

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

using Matrix = vector< vector<int> >;
const int INF = 1 << 30;
int W, H, ans = 0;

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

// 0:何もない, 1:障害物, 2:スタート位置, 3: ゴール位置
void dfs(Matrix &mat, int turn, int pos_x, int pos_y) {
   if (turn > 10) return;
   for (int i = 0; i < 4; i++) {
      int nx = pos_x, ny = pos_y;
      int px = nx + dx[i], py = ny + dy[i];
      if (px < 0 || px >= H || py < 0 || py >= W) continue;
      if (mat[px][py] == 1) continue;

      while (1) {
         nx += dx[i], ny += dy[i];
         if (nx < 0 || nx >= H || ny < 0 || ny >= W) {
            // out of range
            break;
         } else if (mat[nx][ny] == 3) {
            // goal
            ans = min(ans, turn);
            break;
         } else if (mat[nx][ny] == 1) {
            // obstacle
            mat[nx][ny] = 0;
            dfs(mat, turn+1, nx-dx[i], ny-dy[i]);
            mat[nx][ny] = 1;
            break;
         }
      }
   }
}

int main() {
   while (cin >> W >> H, W) {
      ans = INF;
      Matrix mat(H, vector<int>(W));

      int x = 0, y = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            cin >> mat[i][j];
            if (mat[i][j] == 2) {
               x = i, y = j;
            }
         }
      }

      dfs(mat, 1, x, y);
      cout << (ans == INF ? -1 : ans) << endl;
   }

   return 0;
}


Measured memory_bytes: 3104
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
 int N,M;
 cin>>N>>M;
 ll ans=1<<M;
 cout<<ans*(1900*M+100*(N-M))<<endl;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  int vec[n][m];
  rep(i,n,0){
    rep(j,m,0){
      cin >> vec[i][j];
    }
  }
  int ans = 0;
  rep(i,n-1,0){
    rep(j,n,i+1){
      long long int sum = 0;
      rep(k,m,0){
        sum += (vec[i][k]-vec[j][k]) * (vec[i][k]-vec[j][k]);
      }
      int fl = sqrt(sum);
      if(fl*fl == sum) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main() {
  int r,D,x,n_x;
  cin>>r>>D>>x;
  n_x=x;
  for(int i=0;i<10;i++){
    n_x=(r*n_x)-D;
    cout<<n_x<<endl;
  }
return 0 ;  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

using System.IO;

class _Class
{
	
	void _Do()
  {
    int N = _int()[0];
    int[] a = _int();

    Array.Sort(a);
    Array.Reverse(a);

    int m = a.Length / 3 * 2;

    long l = 0;
    for (int i=0;i<m;i++)
    {
      if (i%2==0)
        continue;
      l +=a[i];
    }
    Console.WriteLine(l);
	}



	static void Main(string[] args)
  {
    new _Class()._Do();
  }

#region

  string _string()
  {
    return Console.ReadLine();
  }

	//
	string[] _strings()
  {
    return Console.ReadLine().Split();
  }

  int[] _int(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

	//
	int[] _int()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }

	long[] _long()
	{
		var ss = Console.ReadLine().Split();

		var x = new long[ss.Length];
		for (var i = 0; i < ss.Length; i++)
			x[i] = long.Parse(ss[i]);

		return x;
	}
#endregion

}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		long a[] = new long[n];

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int bit = 0; bit < (1 << n); bit++) {
			long b[] = a.clone();
			boolean flag[] = new boolean[n];
			flag[0] = true;

			int count = 0;
			for (int i = 0; i < n; i++) {
				if ((bit & (1 << i)) != 0) {
					flag[i] = true;
					count++;
				}
			}

			if (count < k)
				continue;

			long sum = 0;
			for (int i = 0; i < n; i++) {
				long height = 0;
				if (flag[i]) {
					for (int j = 0; j < i; j++) {
						height = Math.max(b[j], height);
					}
					if (height >= b[i]) {
						sum += height + 1 - b[i];
						b[i] += height + 1 - b[i];
					}
				}
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 28796
#include<stdio.h>

#define MAX_N 100001

int main(void){

    long int H,N,total_power = 0;
    int A[MAX_N],i;

    scanf("%ld %ld",&H,&N);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
        total_power += A[i];
    }

    if(H <= total_power){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;

    bool b = true;
    REP(i, S.length()) {
        if (i % 2 == 0) {
            if (S[i] == 'L')b = false;
        }
        else {
            if (S[i] == 'R')b = false;
        }
    }

    YESNO(b, "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
const int INF = 1145141919;
    vector <vector<int>> to(2600);
    vector <vector<int>> ot(2600);
bool cone1[2600];
bool conen[2600];
bool ok[2600];
vector <vector<int>> cost(2600,vector <int>(2600));
void dfs(int now){
    if(cone1[now]) return ;
    else cone1[now] = true;
    for(int i=0;i<to[now].size();i++){
        dfs(to[now][i]);
    }
}
void rdfs(int now){
    if(conen[now]) return ;
    else conen[now] = true;
    for(int i=0;i<ot[now].size();i++){
        rdfs(ot[now][i]);
    }
}
signed main(void){
    int n,m,p; cin>>n>>m>>p;
    vector <tuple <int,int,int> > edges;

    rep(i,m){
        int a,b,c; cin>>a>>b>>c; a--; b--;
        cost[a][b] = -c+p;
        to[a].push_back(b);
        ot[b].push_back(a);
        edges.push_back(make_tuple(a,b,cost[a][b]));
    }
    dfs(0);
    rdfs(n-1);
    rep(i,n) ok[i] = cone1[i]&conen[i];
    /////
    vector <int> d(n,INF); 
    d[0] = 0;
    int step = 0;
    bool upd = true;
    while(upd){
        upd = false;
        int a,b,c; 
        rep(j,m){
        tie(a,b,c) = edges[j];
            if(!ok[a] || !ok[b]) continue;
            int nd = d[a] + c;
            if(d[b] > nd){
                upd = true;
                d[b] = nd;
            }
        }
        step++;
        if(step > n+10){
            puts("-1");
            return 0;
        }
    }
    int ans = -d[n-1];
    cout<<max(ans, 0LL)<<endl;
    return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	ll n; cin >> n;
	vector<ll> t(n);
	forn(i, n) cin >> t[i];
	ll m; cin >> m;
	ll sum = accumulate(all(t), 0LL);
	forn(i, m)
	{
		ll x, y; cin >> x >> y;
		cout << sum - (t[x - 1] - y) << endl;
	}
}

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


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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int count = 0;
    for(int i=0; i <= A; i++) {
        for(int j=0; j<= B; j++) {
            for(int k=0; k<=C; k++) {
                if(500 * i + 100 * j + 50 * k == X) count++;
            }
        }
    }
    cout << count << endl;
}

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

int main() {
  int a1, a2, a3; 
  cin >> a1 >> a2 >> a3;
  
  int ans = min(min(abs(a1-a2)+abs(a2-a3), abs(a1-a3)+abs(a2-a3)), abs(a1-a3)+abs(a1-a2));
  
  cout << ans << endl;
}


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

int main() {
    long t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    long p = t1 * (b1 - a1), q = t2 * (b2 - a2);
    if(p > 0 && q > 0 || p < 0 && q < 0 || abs(p) > abs(q)) {
        cout << 0 << endl;
        return 0;
    }
    p = abs(p), q = abs(q);
    if(p == q) {
        cout << "infinity" << endl;
        return 0;
    }
    cout << p / (q - p) * 2 + !!(p % (q - p)) << endl;
    return 0;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;

  int a[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> a[i];

  sort (a + 1, a + n + 1);

  ll pref[n + 1] = {0};
  for (int i = 1; i <= n; i++)
    pref[i] = pref[i - 1] + a[i];

  for (int i = n-1; i >= 1; i--) {
    if (2*pref[i] < a[i + 1]) {
      cout << n - i;
      return 0;
    }
  }
  cout << n;

  return 0;
}






// Coded by Z..

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

const int N = 100054, M = N * 2;

int n, V, E = 0, diam;
int to[M], first[N], next[M];
int deg[N], que[N], p[N], f[N];
bool ban[N], val[N];
char c[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E, ++deg[u];
	to[++E] = u, next[E] = first[v], first[v] = E, ++deg[v];
}

void dfs(int x, int px = 0) {
	int i, y; f[x] = val[x];
	for (i = first[x]; i; i = next[i])
		if (!ban[y = to[i]] && y != px)
			dfs(y, x), up(diam, f[x] + f[y]), up(f[x], f[y] + val[x]);
}

int main() {
	int i, u, v, h, t = 0, ans, root; bool flag = false;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	for (scanf("%s", c + 1), i = 1; i <= n; ++i) flag |= c[i] &= 1;
	if (!flag) return putchar(48), putchar(10), 0;
	for (i = 1; i <= n; ++i) if (!c[i] && deg[i] == 1) que[t++] = i;
	for (h = 0; h < t; ++h)
		for (ban[u = que[h]] = true, i = first[u]; i; i = next[i])
			if (--deg[v = to[i]] == 1 && !c[v]) que[t++] = v;
	V = n - t, ans = 2 * (V - 1);
	for (i = 1; i <= n; ++i) if (!ban[i]) ans += val[i] = (deg[i] ^ c[i]) & 1, root = i;
	assert(root), dfs(root);
	printf("%d\n", ans - diam * 2);
	return 0;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define hell (int)(1e9+7)
#define int long long int
#define inf 1000000000000

using namespace std;

void solve(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }
    int n;
    cin>>n;
    unordered_set <int> mp;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp.insert(x);
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(mp.count(a[i][j]))
                a[i][j]=-1;
        }
    }
    for(int i=0;i<3;i++){
        bool f1,f2;
        f1=f2=true;
        for(int j=0;j<3;j++){
            if(a[i][j]!=-1)
                f1=false;
            if(a[j][i]!=-1)
                f2=false;
        }
        if(f1||f2){
            cout<<"Yes";
            return;
        }
    }
    if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]&&a[0][0]==-1||(a[0][2]==a[1][1]&&a[1][1]==a[2][0]&&a[1][1]==-1))
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cerr<<v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N);
    REP(i, N){
        cin >> C[i];
        REP(j, M){
            ll tmp;
            cin >> tmp;
            A[i].push_back(tmp);
        }
    }

    const ll INF = (1ll<<60);
    ll res = INF;

    REP(mask, (1<<N)){
        vector<ll> P(M, 0);
        ll tot = 0;
        REP(i, N){
            if(mask>>i & 1){
                tot += C[i];
                REP(j, M){
                    P[j] += A[i][j];
                }
            }
        }

        bool ok = true;
        REP(j, M){
            if(P[j]<X) ok = false;
        }
        if(ok) chmin(res, tot);
    }
    cout << (res==INF ? -1 : res) << endl;
    return 0;
}

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

int best[3000], a[3000], n, x;
long long ans = (1LL<<60), cur;

int main() {
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> a[i], best[i] = (1<<30);
    for (int k = 0; k < n; k++) {
        cur = 1LL * k * x; 
        for (int i = 0; i < n; i++) {
            best[i] = min(best[i],a[(n+i-k)%n]);
            cur += 1LL * best[i];
        }
        ans = min(ans,cur);
    }
    cout << ans;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;
ll N, Q;
string S;
char t[19191919];
char d[19191919];

ll check(ll mid){
    //midにいる位置のゴーレムは左に飛び出して消滅するか？
    for(ll i = 0; i < Q; i++){
        if(S[mid] == t[i]){
            if(d[i] == 'L'){
                mid--;
            }else{
                mid++;
            }
        }
        if(mid < 0){
            return 1;
        }
        if(mid > N - 1){
            return 2;
        }
    }
    return 3;
}

int main() {
        
    cin >> N >> Q >> S;
    for(ll i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    
    //左にはみ出て消滅するようなゴレームの中で最小の位置を探す
    ll ok = -1; ll ng = N;
    while(ok + 1 < ng){
        ll mid = (ok + ng) / 2;
        if(check(mid) == 1){
            ok = mid;
        }else{
            ng = mid;
        }
        //cout << mid << endl;
    }

    //左にはみ出ないようなゴーレムの位置の最小
    ll left = ok;
    //cout << left << endl;

    //右にはみ出て消滅するようなゴレームの中で最大の位置を探す
    ng = -1; ok = N;
    while(ng + 1 < ok){
        ll mid = (ok + ng) / 2;
        if(check(mid) == 2){
            ok = mid;
        }else{
            ng = mid;
        }
        //cout << mid << endl;
    }
    ll right = ok;
    //cout << right << endl;

    cout << max(0LL, right - left - 1) << endl;

}

Measured memory_bytes: 2948
n,k = gets.chomp.split(" ").map(&:to_i)
d_arr = gets.chomp.split(" ").map(&:to_i)

arr = ((0..9).to_a - d_arr).map(&:to_s)

1.upto(6) do |d|
  arr.repeated_permutation(d).each do |tmp_arr|
    m = tmp_arr.join.to_i
    if m >= n
      puts m
      exit
    end
  end
end


Measured memory_bytes: 14352
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

class Combination {
public:
  static const long long MOD = 1e9 + 7;
  static const long long MAX = 100100;

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

  long long max;
  long long mod;

public:
  // テーブルを作る前処理
  Combination(int aMax = MAX, int aMod = MOD) : max(aMax), mod(aMod) {
    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 combi(int n, int k) const {
    if(n < k)
      return 0;
    if(n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

ll solve_comb(int num, const Combination& comb) {
  ll ans = 0;
  int m2m = num / 2;
  for(int n2 = m2m; n2 >= 0; --n2) {
    int n1 = num - n2 * 2;
    ll r = comb.combi(n1 + n2, n1);
    // cout << "r : " << r << endl;
    ans += r;
    ans %= Combination::MOD;
  }
  return ans;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ss(M + 1);
  for(int i = 0; i < M; ++i) {
    cin >> ss[i];
  }
  ss[M] = N + 1;
  Combination CC;
  int crnt = 0;
  ll ans = 1;
  for(int i = 0; i <= M; ++i) {
    if(ss[i] == crnt) {
      // 穴の場所に立っているので無理
      cout << 0 << endl;
      return 0;
    }
    if(ss[i] - crnt == 1) {
      crnt = ss[i] + 1;
      continue;
    }
    int num = ss[i] - 1 - crnt;
    ll r = solve_comb(num, CC);
    // cout << crnt << "->" << ss[i] - 1 << "(" << num << ") = " << r << endl;
    ans *= r;
    ans %= Combination::MOD;
    crnt = ss[i] + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
int main(){
    int n;cin>>n;
    int dp[n][3];
    int mat[n][3];
    for (int i=0;i<n;i++)
        cin>>mat[i][0]>>mat[i][1]>>mat[i][2];
    for (int i=0;i<3;i++)dp[0][i]=mat[0][i];
    for (int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+mat[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+mat[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+mat[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i,a[100],m,ans=1;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	m=a[0];
	for (i=1;i<n;i++){
		if (a[i]>=m){
			ans++;
			m=a[i];
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  const int mod = 998244353;
  long long DP[c+1][d+1] = {};
  DP[a][b] = 1;
  for(int i=a;i<c+1;i++){
    for(int j=b;j<d+1;j++){
      DP[i][j] += DP[i][j-1]*i+DP[i-1][j]*j-DP[i-1][j-1]*(i-1)*(j-1);
      DP[i][j] %= mod;
      if (DP[i][j] < 0){
        DP[i][j] += mod;
      }
    }
  }
  cout << DP[c][d] << endl;
}


Measured memory_bytes: 73952
#include <iostream>
#include<string>
#include<list>
#include<algorithm>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long

int main() {
	int q,x;
	string command;

	
	//?¨?????????????????????????list????????¨
	list<int> value;
	cin>>q;
	REP(i, q) {
		cin>>command;
		if (command == "insert") {
			cin>>x;
			value.push_front(x);
		}
		else if (command == "deleteLast")
			value.pop_back();
		else if (command == "deleteFirst")
			value.pop_front();
		else if (command == "delete") {
			cin>>x;
			for (list<int>::iterator it = value.begin(); it != value.end(); it++) {
				if (*it == x) {
					value.erase(it);
					break;
				}
			}
		}	
	}
	//??????
	int i=0;
	for (list<int>::iterator it = value.begin(); it != value.end(); it++) {
		if(i++)cout<<" ";
		cout<<*it;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 34364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    io;
    string s;
    cin>>s;
    stack <char> x;
    for(ll i=0;i<s.size();i++){
        if(s[i]!='B'){
            x.push(s[i]);
        }
        else{
            if(!x.empty()){
                x.pop();
            }
        }
    }
    std::vector<char> v ;
    while(!x.empty()){
        v.push_back(x.top());
        x.pop();
    }
    
    reverse(v.begin(),v.end());
    for(auto z : v){
        cout<<z;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(ll j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll pre[25],a[25];
int main(){FAST;
cin>>n;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
ll ans=0;
for(ll i=0;i<n;i++){
	ll ok=1;
	for(ll j=0;j<i;j++){
		if(a[j]>a[i]){
			ok=0;
			break;
		}
	}
	ans+=ok;
}
cout<<ans;
return 0;
}




Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	T := nextInt()
	c := make([]int, N)
	t := make([]int, N)
	if T > 1000 {
		fmt.Println("制約")
	}
	for i := 0; i < N; i++ {
		c[i] = nextInt()
		t[i] = nextInt()
	}
	mincost := int(1e9)
	find := false
	for i := 0; i < N; i++ {
		if t[i] <= T && c[i] < mincost {
			mincost = c[i]
			find = true
		}
	}
	if !find {
		fmt.Println("TLE")
		return
	}
	fmt.Println(mincost)
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
#define maxn 1010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn][maxn];
int n,m,A,B;
int main()
{
	n=read(); m=read(); A=read(); B=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=(i<=B)^(j<=A);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			write(a[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 5120
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/******Old_school_@163******/
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back 
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          string s; cin>>s;
          lld n=sz(s);
          if(s[n-1]=='s')  cout<<s<<"es";
          else  cout<<s<<"s";
      }
}



Measured memory_bytes: 3648
unittest
{
	assert( [ "1 2020" ].parse.expand.solve == 0 );
	assert( [ "2020 2040" ].parse.expand.solve == 2 );
	assert( [ "4 5" ].parse.expand.solve == 20 );
	
	assert( [ "2 1999999999" ].parse.expand.solve == 0 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto lr = input.front.split.to!( long[] );
	return tuple( lr[ 0 ], lr[ 1 ] );
}

auto solve( long l, long r )
{
	auto MOD = 2019L;
	
	if( MOD < r - l ) r = l + MOD;
	
	auto ans = long.max;
	foreach( a; l .. r )
	{
		auto mf = a * ( a + 1 ) % MOD;
		ans = min( ans, mf );
		foreach( b; a + 2 .. r + 1 )
		{
			auto m = a * b % MOD;
			if( m == mf ) break;
			ans = min( ans, a * b % MOD );
		}
	}
	return ans;
}


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

int main(){
    int n,h,w; cin>>n>>h>>w;
    vector<int>a(n),b(n);
    cinf(n,a,b);
    int cnt=0;
    for(int i=0;i<n;i++){
    	if(a[i]>=h && b[i]>=w)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s="ACL",ans="";
  ll k;cin>>k;
  rep(i,0,k)ans+=s;
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

int main()
{
  int i=1, j=1, x[100000];
  x[0]=-1;


  while(x[i-1] != 0)
  {
    cin >> x[i];
    i=i+1;
  }

  while(x[j] != 0)
  {
    cout <<"Case " <<j <<": " <<x[j] <<endl;
    j=j+1;
  }

  return 0;
}

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

int main(void){
    ll n, k;
    cin >> n >> k;

    ll h[n];
    rep(i, n){
        cin >> h[i];
    }

    ll dp[n];
    rep(i, n){
        dp[i] = 10000000000;
        if(i == 0){
            dp[i] = 0;
        }else{
            for(int j = 1; j <= k; j++){
                if(i - j < 0) break;
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

int inp[100005];
ll comb[1005][1005];
int main() {
	int N; scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", inp + i);
	}
	sort(inp + 1, inp + N + 1);
	int n = inp[N], r;
	int gap = 2e9;
	for (int i = 1; i <= N; i++) {
		if (gap > abs((n + 1)/ 2 - inp[i])) {
			gap = abs((n + 1)/ 2 - inp[i]);
			r = inp[i];
		}
	}
	printf("%d %d", n, r);
}

Measured memory_bytes: 2304
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;
template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

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

main(){
    int n=in<int>(),c=0;
    string s=in<string>();
    for (int i=2;i<n;i++) {
        if (s[i-2]=='A' && s[i-1]=='B' && s[i]=='C')c++;
    }
    out(c);
}

Measured memory_bytes: 256