akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 1005;

int inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - (ll)inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = (ll)fac[i-1] * i % MOD;
		finv[i] = (ll)finv[i-1] * inv[i] % MOD;
	}
}

int mod_pow(int a, int b)
{
    int res = 1;
    while(b){
        if(b & 1){
            res = (ll)res * a % MOD;
        }
        a = (ll)a * a % MOD;
        b >>= 1;
    }
    return res;
}

int add(int x,int y)
{
    return (x + y)%MOD;
}

int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int dp[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    make();
    int m = b-a+1;
    dp[0][n] = 1;
    rep(i,m){
        rep(j,n+1){
            dp[i+1][j] = dp[i][j];
            for(int k = c; k <= d; k++){
                int rem = j-(i+a)*k;
                if(rem < 0) break;
                dp[i+1][rem] = add(dp[i+1][rem],mul(dp[i][j],mul(mul(fac[j],finv[k]),mul(mod_pow(finv[i+a],k),finv[rem]))));
            }
        }
    }
    cout << dp[m][0] << "\n";
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
typedef long long ll;
const int maxn=4e6+7;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;

ll quick(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
ll inv(ll x) {return quick(x,mod-2);}
ll fac[maxn],invfac[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;++i) fac[i]=(fac[i-1]*i)%mod;
    invfac[maxn-1]=inv(fac[maxn-1]);
    for(int i=maxn-2;i>=0;--i) invfac[i]=(invfac[i+1]*(i+1))%mod;
}

ll C(int n,int m)
{
    return fac[n]*invfac[m]%mod*invfac[n-m]%mod;
}

ll dp[2007][2007];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    int n,k;
    cin>>n>>k;
    if(k==1) cout<<1<<endl;
    else
    {
        dp[0][0]=1;
        for(int i=1;i<=n;++i)
        {
            for(int j=0;j<=i;++j)
            {
                if(j==0) dp[i][j]=1;
                else
                {
                    assert(n*k-i-(j-1)*(k-1)-1>=k-2);
                    dp[i][j]=(dp[i-1][j]+1ll*dp[i][j-1]*(n-j+1)%mod*C(n*k-i-(j-1)*(k-1)-1,k-2)%mod)%mod;
                }
            }
        }
        cout<<dp[n][n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 92800
#include <stdio.h>

int main(){
  int a,b,i;
  scanf("%d %d",&a,&b);
  while(a!=b){
    if(a>=b){
      a = a-b;
    }else{
      b = b-a;
    }
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int x[110] = {};
int y[110] = {};
int h[110] = {};

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

  int N;
  cin >> N;

  REP(i, N) {
    cin >> x[i] >> y[i] >> h[i];
  }
  int ht = 0;
  int hi = 0;
  for (int i = 0; i < N; i++) {
    if (h[i] > 0) {
      hi = i;
    }
  }

  REP(cx, 101) {
    REP(cy, 101) {
      ht = h[hi] + abs(x[hi] - cx) + abs(y[hi] - cy);
      for (int i = 0; i < N; i++) {
        if (h[i] != max(ht - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
          break;
        }
        if (i == N - 1) {
          cout << cx << " " << cy << " " << ht << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int a , b;
        cin >> a >> b;
        if( a >= 13 ) return cout << b << endl,0;
        if( a >= 6 && a <= 12 ) return cout << b/2 << endl,0;
        cout << 0 << endl;
        return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());

        int w = Integer.parseInt(tokenizer.nextToken());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());

        int min = Math.min(a, b);

        int max = Math.max(a, b);

        if (max - min <= w){
            System.out.println(0);
        }else{
            System.out.println(max - (min + w));
        }
    }


}


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

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  1e6+5;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test=1, n, m, k, x1, x2, Y1, y2;
string s[N];

void bfs(){
    map <pll,int> ct;
    queue <pll> q;
    q.push({x1,Y1});
    ct[{x1,Y1}] = 1;
    while(q.size()){
        pll x = q.front(); q.pop();
        int c = k;
        for(int i = x.f-1; i >= 0; i--){
            if(s[i][x.s] == '@') break;
            if(ct[{i,x.s}] == 0){
                q.push({i,x.s});
                ct[{i,x.s}] = ct[x]+1;
            }
            if(ct[{i,x.s}] < ct[x]+1) break;
            c--;
            if(c == 0) break;
        }
        c = k;
        for(int i = x.f+1; i < n; i++){
            if(s[i][x.s] == '@') break;
            if(ct[{i,x.s}] == 0){
                q.push({i,x.s});
                ct[{i,x.s}] = ct[x]+1;
            }
            if(ct[{i,x.s}] < ct[x]+1) break;
            c--;
            if(c == 0) break;
        }
        c = k;
        for(int i = x.s-1; i >= 0; i--){
            if(s[x.f][i] == '@') break;
            if(ct[{x.f,i}] == 0){
                q.push({x.f,i});
                ct[{x.f,i}] = ct[x]+1;
            }
            if(ct[{x.f,i}] < ct[x]+1) break;
            c--;
            if(c == 0) break;
        }
        c = k;
        for(int i = x.s+1; i < m; i++){
            if(s[x.f][i] == '@') break;
            if(ct[{x.f,i}] == 0){
                q.push({x.f,i});
                ct[{x.f,i}] = ct[x]+1;
            }
            if(ct[{x.f,i}] < ct[x]+1) break;
            c--;
            if(c == 0) break;
        }
    }
    cout<<ct[{x2,y2}]-1<<endl;
}

void solve(){
    cin>>n>>m>>k;
    cin>>x1>>Y1>>x2>>y2;
    x1--,Y1--,x2--,y2--;
    for(int i = 0; i < n; i++) cin>>s[i];
    bfs();
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 83700
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int n;
	cin >> n;
	int ans = 0,tmp = 1,pos = 0;
	for(int i = 0;i < n;i++){
		int x;
		scanf("%d",&x);
		if(x == tmp){
			tmp++;
		}
	}
	if(tmp == 1)
		printf("-1\n");
	else
		cout << n - tmp + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    string fw = "";
    string bk = "";
    bool isf = false;
    rep(i,q) {
        int t; cin >> t;
        if (t==1) isf = !isf;
        else {
            int f; cin >> f;
            char c; cin >> c;
            if (isf) {
                if (f==1) bk.pb(c);
                else fw.pb(c);
            }
            else {
                if (f == 1) fw.push_back(c);
                else bk.pb(c);
            }
        }
    
    }
    if (!isf) {
        reverse(all(fw));
        cout << fw + s + bk << endl;
    }
    else {
        reverse(all(bk));
        reverse(all(s));
        cout << bk + s + fw << endl;
    }
    return 0;
}
























Measured memory_bytes: 1348
#include <limits.h>
#include <stdio.h>

int
main()
{
	int n;
	scanf("%d", &n);

	long long int i, a;
	long long int min = LLONG_MAX;
	long long int max = LLONG_MIN;
	long long int sum = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a);

		sum += a;
		if (a > max)
			max = a;
		if (a < min)
			min = a;
	}
	printf("%lld %lld %lld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 1024

int st[MAX], top;

int isFull();
int isEmpty();
void push(int);
int pop();

int main(){
  char symbol[MAX];
  int i, num1, num2;
  top = 1;

  while(scanf("%s", symbol) != EOF){
    if(symbol[0] == '+'){
      num1 = pop();
      num2 = pop();
      push(num1 + num2);
    }else if(symbol[0] == '-'){
      num2 = pop();
      num1 = pop();
      push(num1 - num2);
    }else if(symbol[0] == '*'){
      num1 = pop();
      num2 = pop();
      push(num1 * num2);
    }else{
      push(atoi(symbol));
    }

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

  return 0;
}

int isFull(){
  if(top == MAX - 1)return 1;
  else return 0;
}

int isEmpty(){
  if(top == 0)return 1;
  else return 0;
}

void push(int num){
  if(isFull() == 1)exit(1);
  else{
    ++top;
    st[top] = num;
  }
}

int pop(){
  if(isEmpty() == 1)exit(2);
  else{
    --top;
    return st[top + 1];
  }
}



Measured memory_bytes: 2100
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int MOD = 1000000007;
int i, j, k, m, n, l;
int ans;

int x[100001];
int y[100001];

int main() {
//	freopen("x.in", "r", stdin);
	cin >> n;
	F0(i, n) cin >> x[i];

	ans = 1;
	int k = n;
	int at = -1;
	F0(i, n) {
		y[i] = k;
		if (x[i] >= at + 2) {
			at += 2;
		}
		else {
			k--;
		}
	}
	k = 0;
	for (int i = n - 1; i >= 0; i--) {
		ans = (1LL * ans * (y[i] - k)) % MOD;
		k++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int current = a;

	while (current <= b){
		if (current <= a + k - 1 || current >= b - k + 1){
			cout << current << endl;
		}
		current++;
	}

}


Measured memory_bytes: 256
n, m = map(int, input().split())
num = [None] * n
a = [tuple(map(int, input().split())) for _ in range(m)]
for pos, val in a:
    if num[pos - 1] != None and num[pos - 1] != val:
        print(-1)
        exit()
    num[pos - 1] = val
if n == 1 and num[0] == None:
    num[0] = 0
canBeZero = False
for i in range(n):
    if num[i] == None:
        num[i] = 0 if canBeZero else 1
    if num[i]:
        canBeZero = True
ret = str(int(''.join(map(str, num))))
print(ret if len(ret) == n else -1)

Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int n;

int binarysearch(int x){
	int mid;
	int left=0;
	int right=n;
	while(left<right){
		mid=(right+left)/2;
		if(x==a[mid])return 1;
		else if(x>a[mid])left=mid+1;
		else right=mid; 
	}
	return 0;
}

int main(){
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++)cin>>a[i];
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		if(binarysearch(x))sum++;
	}
	cout<<sum<<endl;
}


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

int num[128] = {};
int main(){
	string s;
	cin >> s;
	for(int i = 0 ; i < s.size() ; i++){
		num[s[i]]++;
	}
	int c = 0;
	int K = 0;
	for(int i = 0 ; i < 128 ; i++){
		if( num[i] % 2 != 0 ){
			c++;
		}
		num[i] /= 2;
		K += num[i];
	}
	if( c >= 2 ){
		cout << 0 << endl;
		return 0;
	}
	unsigned long long f[21] = {};
	f[0] = 1;
	for(int i = 1 ; i < 21 ; i++) f[i] = i * f[i-1];
	unsigned long long ans = f[K];
	for(int i = 0 ; i < 128 ; i++){
		ans /= f[num[i]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    vector<int> T(5);
    rep(i,5) cin >> T.at(i);
    sort(begin(T), end(T), [](int L, int R){
        int L1 = L % 10;
        int R1 = R % 10;
        if (L1 == 0) return true;
        if (R1 == 0) return false;
        return L1 > R1;
    });
    int sum = 0;
    rep(i, 4) {
        sum += (int)ceil(T[i] / 10.0) * 10;
    }
    cout << sum + T[4] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i <= 25; i++) {
            for (int j = 0; j <= 14; j++) {
                if (n == (4 * i + 7 * j)) {
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");
    }
}

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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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;
}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class CGoodSequence {
public:
    int N;
    map<int, int> m;

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        REP(i, N) {
            int num;
            in >> num;
            m[num]++;
        }

        ll ans = 0;

        FOREACH(e, m) {
            e.second < e.first ? ans += e.second : ans += e.second - e.first;
        }

        OUT(ans);
    }
};


int main() {
    CGoodSequence solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;


        for (int i = n; i >= 1; i -= 2) {
                cout << a[i - 1] << ' ';
        }

        for (int i = 1 + n % 2; i <= n; i += 2) {
                cout << a[i - 1] << ' ';
        }


        //1 2 3
        //3 1 2

}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,ct=0,d,i,j,k;
    cin>>a>>b;
    vector<long long >vc;
   // vector<long long >tc;
   // vector<long long >tv;
    for(i=0;i<a;i++)
    {
    cin>>j>>k;
    if(k<=b)
    {
    vc.push_back(j);
   // tc.push_back(k);
    //tv.push_back(k*j);
    }
    }
    if(vc.size()==0)
    cout<<"TLE";
    else
    {

    sort(vc.begin(),vc.end());
    cout<<vc[0];}



}


Measured memory_bytes: 256
def is_case_possible(case):
    for i, flag in enumerate(case):
        if flag == '1':
            for x, y in XY[i]:
                x -= 1
                if case[x] != str(y):
                    return False
    return True

N = int(input())
XY = []
for _ in range(N):
    A = int(input())
    xy = [list(map(int, input().split())) for _ in range(A)]
    XY.append(xy)

ans = 0
for i in range(2**N):
    case = bin(i)[2:].zfill(N)
    if is_case_possible(case):
        ans = max(ans, case.count('1'))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 1000000001
void mergesort(int *,int ,int );
void merge(int *,int ,int ,int );
int count=0,n,Left[250001],Right[250001],i,n1,n2;

int main(void){
  int S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}
void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);
  }
}
void merge(int *S,int left,int mid,int right){
  int j,k;
  n1=mid-left;n2=right-mid;
  for(i=0;i<n1;i++)
    Left[i]=S[left+i];//not include mid
  for(i=0;i<n2;i++)
    Right[i]=S[mid+i];//include mid
  Left[n1]=MAX;
  Right[n2]=MAX;
  for(i=0,j=0,k=left;k<right;k++){
    if(Left[j]>Right[i])S[k]=Right[i++];
    else S[k]=Left[j++];
  }
  count+=right-left;
}


Measured memory_bytes: 5600
#include<stdio.h>

int main(void)
{
   int i,x,y;

   for(;;){
   scanf("%d %d",&x,&y);
   if(x==0 && y==0){
      break;
   }else if(x<y){
      printf("%d %d\n",x,y);
   }else{
      printf("%d %d\n",y,x);
   }
   }

   return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int, ll>> yp;
  vector<int> data;


  rep(i,m) {
    ll t,s; cin >> t >> s;
    pair<int,ll> p = make_pair(s,i);
    yp.pb(p);
    data.pb(t);
  }

  sorti(yp);

  vector<int> sum(n+1,1);
  vector<pair<int,string>> ans;

  for (auto itr : yp) {
    int a,index;
    index = itr.second;

    // a:ken, t: junnbann
    a = data[index];
    int t = sum[a];
    sum[a]++;

    string str = "000000";
    string str1, str2;
    str1 = str + to_string(a);
    str2 = str + to_string(t);

    str1 = str1.substr(str1.size()-6,str1.size()-1);
    str2 = str2.substr(str2.size()-6,str2.size()-1);
    // string res = str1 + str2;

    ans.pb({index,str1+str2});
  }

  sorti(ans);

  for (auto itr : ans) {
    cout << itr.second << endl;
  }
}


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

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

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) {
			ans += 1;
		}
	}

	if (ans >= K) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t L,R;
  cin >> L>>R;
  
  int64_t ans=2018;
  for(int64_t i=L;i<R;i++){
    if(R-L>=2019){
      ans=0;
      break;
    }
    for(int64_t j=i;j<R;j++){
      ans=min(ans,(i*(j+1))%2019);
      if(ans==0)break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	double wareru,takasa,kai;
	int i;
	
	while(scanf("%lf",&wareru) != EOF){
		takasa = 4.9* ((wareru*wareru)/(9.8*9.8));
		kai = (takasa+5.0)/5.0;
		for(i=1;i < kai;i++);
		printf("%d\n",i);
	}
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    int n;
    cin >> n;
    int b[n];
    rep (i, n-1) cin >> b[i];

    ll res = b[0];
    rep(i, n-2){
        res += min(b[i], b[i+1]);
    }
    res += b[n-2];

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef complex<double> Point;
#define X real()
#define Y imag()
const double EPS = 0;

double dot(Point a, Point b) {
	return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
	return a.X*b.Y - a.Y*b.X;
}

string ccw(Point a, Point b, Point c) {
	b -= a;  c -= a;
	if (cross(b,c) >  EPS) return "COUNTER_CLOCKWISE";
	if (cross(b,c) < -EPS) return "CLOCKWISE";
	if (dot(b,c)   < -EPS) return "ONLINE_BACK";  // c--a--b on line
	if (norm(b) < norm(c)) return "ONLINE_FRONT"; // a--b--c on line or a==b
	return "ON_SEGMENT";                          // a--c--b on line or a==c or b==c
}

int main(void){
	double x1,y1,x2,y2,x,y;
	int q;
	cin>>x1>>y1>>x2>>y2>>q;
	rep(i,q){
		cin>>x>>y;
		cout<<ccw({x1,y1},{x2,y2},{x,y})<<endl;
	}
	return 0;
}

Measured memory_bytes: 3312
use std::io::{BufRead, Write};
use std::io;
use std::cmp::Ordering;

fn binary_search_by<F>(mut f: F) -> usize
    where
        F: FnMut(usize) -> Ordering,
{
    use std::cmp::Ordering::*;
    let mut size = std::usize::MAX;
    let mut base = 0usize;
    while size > 1 {
        let half = size / 2;
        let mid = base + half;
        let cmp = f(mid);
        base = if cmp == Greater { base } else { mid };
        size -= half;
    }
    let cmp = f(base);
    base + (cmp == Less) as usize
}

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let a: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let eval = |x| a.iter().fold(x, |acc, &x| acc / x * x);
    let lo = binary_search_by(|x| if eval(x) >= 2 { Ordering::Greater } else { Ordering::Less });
    let up = binary_search_by(|x| if eval(x) > 2 { Ordering::Greater } else { Ordering::Less });
    if lo == up {
        writeln!(output, "-1").unwrap();
    } else {
        writeln!(output, "{} {}", lo, up - 1).unwrap();
    }
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "4
3 4 3 2
",
            "6 8\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "5
3 4 100 3 2
",
            "-1\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "10
2 2 2 2 2 2 2 2 2 2
",
            "2 3\n",
        );
    }
}

Measured memory_bytes: 8444
N = int(input())
s = input()

def count(x, y):
   l= []
   result = 0
   for i in range(len(x + y)):
      l.append((x + y)[i])
   for letter in set(l):
      if (letter in x) and (letter in y):
         result += 1
   return result

lst = []
for i in range(1, N):
   lst.append(count(s[:i], s[i:]))

print(max(lst))

Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
struct Point{double x,y;};
double dist(Point a,Point b) {return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));}
#define eps 0.0001

int main(void){
    int N;
    while(cin>>N,N){
        vector<Point> p(N);
        int maxcnt=1;
        rep(i,N)cin>>p[i].x>>p[i].y;
        rep(i,N){
            for(int j=i+1;j<N;j++){
                double d = dist(p[i],p[j]);
                if(d>2.0)continue;
                int sign[]={-1,1};
                rep(s,2){
                    Point C;
                    C.x = p[i].x + cos(atan2(p[j].y-p[i].y,p[j].x-p[i].x) + sign[s]*acos(d/2.0));
                    C.y = p[i].y + sin(atan2(p[j].y-p[i].y,p[j].x-p[i].x) + sign[s]*acos(d/2.0));
                    int cnt=0;
                    rep(k,N) cnt += (pow(C.x-p[k].x,2) + pow(C.y-p[k].y,2) <= 1.0+eps);
                    if(maxcnt<cnt)maxcnt=cnt;
                }
            }
        }
        cout<<maxcnt<<endl;
    }

    return 0;
}

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

using namespace std;
#define ll long long

int main()
{
  ll n,m,k;cin>>n>>m>>k;
  ll a[n],b[m],sum=0,ans1=0;
  for(ll i=0;i<n;i++)cin>>a[i];
  for(ll i=0;i<m;i++)cin>>b[i];
vector<ll>suma(n+1),sumb(m+1);
suma[0]=sumb[0]=0;
for(ll i=1;i<=n;i++)
suma[i]=suma[i-1]+a[i-1];
  for(ll i=1;i<=m;i++)sumb[i]=sumb[i-1]+b[i-1];
  for(ll i=0;i<=n;i++){
      ll temp=k-suma[i];
      if(temp<0)continue;
      ll l=lower_bound(sumb.begin(),sumb.end(),temp)-sumb.begin();
      if(l>m||sumb[l]>temp)l--;
      ans1=max(ans1,i+l);
  }
   cout<<ans1<<endl;
   return 0;
}

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

vector <int> graph[100005];
bool memo[100005];

void dfs (int u) {
	memo[u] = 1;
	for (int i=0; i<graph[u].size(); i++) {
		int v = graph[u][i];
		if (memo[v] == 0) {
			memo[v] = 1;
			dfs(v);
		}
	}
}

int main () {
	
	int n=0, m=0, x=0, y=0, w=0, i=0;

	cin >> n >> m;

	for (i=0; i<m; i++) {
		cin >> x >> y >> w;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}

	int tam=0;
	for (i=1; i<=n; i++) {
		if (memo[i] == 0) {
			tam++;
			dfs(i);
		}
	}

	cout << tam << endl;

	return 0;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t

inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
lli ans[1000];

void solve2(lli n)
{
	//lli n;
	lli b[n];
	if(n==1)
		cout<<"0";
	else if(n==2)
		cout<<"1";
	else
	{
		b[0]=n-1;
		b[n-1]=n;
		lli l=1,j=1;
		while(l<n-1)
		{
			b[l]=j;
			l++;
			j++;	
		}
		lli ctr=0;
		rep(i,0,n)
		{
			ctr+=(b[i]%(i+1));
		}
			cout<<ctr;
		
		//cout<<"\n";
	}
	//cout<<"\n";
}

lli sieve(lli n)
{
	ans[0]=0;
	ans[1]=0;
	ans[2]=1;
	ans[3]=3;
	lli d=1,m;
	if(n<=3)
		return ans[n];
	
	n=n+1;
	m=(n-3)+1;
		return(m*(m+1)/2);

}

	
int main()
{
	fast();
	lli t=1,n,m;
	//cin>>t;
	//sieve();
	while(t--)
	{
		cin>>n;
		cout<<sieve(n)<<" ";
		
	}
	return 0;
}

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

const int MOD = 1000000007;

int p[100010];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

  p[1] = 1; for(int i = 2; i <= N; i++) p[i] = min(p[i], p[i - 1] + 2);

  int ans = 1; bool prev = false; int rem = 0;

  for(int i = 1; i < N; i++){
    if(p[i] + 1 == p[i + 1]){
      if(prev) prev = false;
      else{
        ans = 1LL * ans * (i + 1 - rem) % MOD;
        rem++; prev = true;
      }
    }
  }

  for(int i = 1; i <= N - rem; i++){
    ans = 1LL * ans * i % MOD;
  }

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


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

vector<ll> divisor(ll N) {
    vector<ll> RES;
    for (ll I = 1; I*I <= N; I++) {
        if (N%I == 0) {
            RES.push_back(I);
            if (I != N/I) RES.push_back(N/I);
        }
    }
    return RES;
}

int main() {
    int a,b,x; cin >> a >> b >> x;
    double pi = 2.0 * asin(1.0); 
    double unit_r = 180.0 / pi;
    if (a*a*b < 2*x) {
        double kata = (double) (a*a*b-x)*2/(a*a*a);
        double ans = atan(kata) * unit_r;
        cout << setprecision(15) << ans << endl;

    } else {
        double kata = (double) a*b*b/(2*x);
        double ans = atan(kata) * unit_r;
        cout << setprecision(15) << ans << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int f = 0, j = 1; 
  while(N >= (j / 10)){
      j *= 10;
      f += N % j / (j / 10);
  }
  if (N % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
ll get(ll a,ll k)
{
	//if(a==0)return 1;
	return a/k;
}
void solve()
{
	ll a,b,k;
	cin>>a>>b>>k;
	if(a==0)
	{
		cout<<b/k+1<<endl;
		return;
	}
	ll x=max(a-1,0LL);
	cout<<get(b,k)-get(x,k)<<endl;
}

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


Measured memory_bytes: 3648
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    vector<int> a;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        for (int j = 0; j < x; j++) {
            a.push_back(i + 1);
        }
    }

    vector<vector<int>> b(h, vector<int>(w));

    int k = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i % 2 == 0) {
                b[i][j] = a[k++];
            } else {
                b[i][w - 1 - j] = a[k++];
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w - 1; j++) {
            cout << b[i][j] << " ";
        }
        cout << b[i][w - 1] << endl;
    }

    return 0;
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int a;
    int first = true;
    while (cin >> a, a) {
        int b[4], ans[4];
        int kind[4] = {10, 50, 100, 500};
        cin >> b[0] >> b[1] >> b[2] >> b[3];

        int total = 0;
        loop(4, i) total += b[i] * kind[i];
        int oturi = total - a;
        for (int i = 3; i >= 0; i--) {
            int tmp = oturi / kind[i];
            ans[i] = b[i] - tmp;
            oturi -= tmp * kind[i];
        }

        if (!first) cout << endl;
        loop(4, i) if(ans[i] > 0) cout << kind[i] << ' ' << ans[i] << endl;
        first = false;
    }
}

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

int main() {
	long long int a,b,c,k,count=0;
	cin>>a>>b>>c>>k;
	
	if(a>=k){
		cout<<k;
		return 0;
	}
	count += a;
	k=k-a;
	
	if(b>=k){
		cout<<count;
		return 0;
	}
	
	k=k-b;
	
	cout<<count-k<<endl;
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    ll b;
    cin >> b;
    if (b == 0) return 0;
    
    for (ll i = 1e5; i > 0; i--) {
      ll keep = b;
      keep -= i * (i - 1) / 2;
      if (keep > 0 && keep % i == 0) {
        cout << keep / i << " " << i << '\n';
        break;
      }
    }
  }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

template<class T>
void show_2d_vector(const vector<vector<T>> &v){
    for (auto v1: v) {
        for(auto v2: v1) {
            cout << v2 << " ";
        }
        cout << endl;
    }
}

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

    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(h+1,1LL<<60));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < h+1; j++){
            if(j-a[i]>=0){
                dp[i+1][j] = min(dp[i][j-a[i]]+b[i] ,dp[i][j]);
                dp[i+1][j] = min(dp[i+1][j-a[i]]+b[i], dp[i+1][j]);

            }else{
                dp[i+1][j] = min(dp[i][0]+b[i] ,dp[i][j]);
                dp[i+1][j] = min(dp[i+1][0]+b[i], dp[i+1][j]);
            }
        }
    }
    cout << dp[n][h] << endl;

    return 0;

}


Measured memory_bytes: 78592
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
 
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
 
int main(void) {
  string s;
  cin >> s;
  int m_1 = ((int)s.length()-1)/2;
  int m_2 = ((int)s.length()+3)/2;
  
  for(int i=0;i<(int)s.length()/2;i++) {
    if(s[i]==s[(int)s.length()-1-i]) continue;
    cout << "No" << endl;
    return 0;
  }
  int a;
  if(m_1%2==0) {
    a = (m_1-1)/2+1;
  } else {
    a = (m_1-1)/2;
  }
  for(int i=0;i<a;i++) {
  	if(s[i]==s[m_1-1-i]) continue;
  	cout << "No" << endl;
  	return 0;
  }
  for(int i=m_2-1;i<a;i++) {
  	if(s[i]==s[(int)s.length()-1-i]) continue;
  	cout << "No" << endl;
  	return 0;
  }

  cout << "Yes" << endl;
}

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

t = list(map(int, input().split()))
total_time = sum(t)

m = int(input())

pxs = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    p, x = pxs[i]
    print(total_time - t[p - 1] + x)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
// Pyだと想定回厳しいのでコピペ（飛ばし）
using namespace std;
vector<int> rad[605];
long double bf[605],rl[605],tcnt[605];
int n,m;

long double gl(int now)
{
    //bf[now]+=g;
    if(rl[now]) return rl[now];
    long double trl = 0;
    for(int i=0;i<rad[now].size();++i)
    {
        trl+=gl(rad[now][i])+1;
    }
//    if(rad[now].size()==0) {
//        if(now==n) return rl[now] = 0;
//        return rl[now] = 1000;
//    }
    if(now==n) return 0;
    return rl[now] = trl/rad[now].size();
}

//void ggl(int now,long double g)
//{
//    bf[now]+=g;
//    if(--tcnt[now]>0) return;
//    for(int i=0;i<rad[now].size();++i)
//        ggl(rad[now][i],bf[now]/rad[now].size());
//}


int main()
{
    scanf("%d%d",&n,&m);
    int s,t;
    for(int i=0;i<m;++i)
    {
        scanf("%d%d",&s,&t);
        rad[s].push_back(t);
    }

    gl(1);
    bf[1] = 1;

    for(int i=1;i<n;++i)
    {
        long double tv = bf[i]/rad[i].size();
        for(int j=0;j<rad[i].size();++j)
            bf[rad[i][j]]+=tv;
    }

    long double ans = 0;
    for(int i=0;i<rad[1].size();++i){
        ans += (1+rl[rad[1][i]]);
    }
    ans/=rad[1].size();


    long double df = 0;
    for(int i=1;i<=n;++i){
        if(rad[i].size()==1) continue;
        long double tsm = rl[i]*rad[i].size();
        for(int j=0;j<rad[i].size();++j){
            long double sdf = ((tsm-rl[rad[i][j]]-1)/(rad[i].size()-1)-tsm/rad[i].size())*bf[i];
            if(sdf<df) df = sdf;
        }
    }
    cout << setprecision(25) <<std::fixed<<ans+df<< endl;
    return 0;
}


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

int main(){
  int n,m,c; cin>>n >>m >>c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  
  for(int i=0;i<m;i++){
    cin>>b.at(i);
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a.at(i).at(j);
    }
  }
  int sum = 0;
  int count=0;
  
  for(int i=0;i<n;i++){
    sum = 0;
    for(int j=0;j<m;j++){
      sum += a.at(i).at(j) * b.at(j);
    }
    if(sum + c > 0){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>

#define ll long long

using namespace std;

const int N = 2e5 + 10;

bool pali(string &s)
{
    int n = s.length();
    for (int i = 0; i < n >> 1; ++i) if (s[i] != s[n - i - 1]) return 0;
    return 1;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    string s;
    cin >> s;
    bool a = 1, b = 1, c = 1;
    int n = s.length();
    string p = s.substr(0, (n - 1) >> 1);
    string q = s.substr(((n + 3) >> 1) - 1);
    if (pali(s) && pali(p) && pali(q)) cout << "Yes";
    else cout << "No";
    return 0;
}


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

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

  if (s.at(0) == 'A') {
    if (s.at(1) == 'B' || s.at(2) == 'B') {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if (s.at(1) == 'A' || s.at(2) == 'A') {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

int main()
{
  int64_t k, a, b;
  cin >> k >> a >> b;
  int64_t biscuit;
  if (k < a - 1 || a + 2 >= b) {
    biscuit = k + 1;
  } else {
    k -= a - 1;
    biscuit = a;
    biscuit += (b - a) * (k / 2);
    biscuit += k % 2;
  }
  cout << biscuit << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long n,div,i;
    bool possible=false;
    cin>>n;
    for(i=1;i<=sqrt(n);i++){
        if(n%i==0){
            div=n/i;
        }
    }
    long long d;
    d=n/div;
    long long res=d-1+div-1;
    cout<<res;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

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 T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    while(cin >> n) {
        map<ll, ll> d;
        ll sum = 0;
        REP(i, n) {
            int x;
            cin >> x;
            d[x] ++;
            sum += x;
        }
        cin >> m;
        REP(_, m) {
            int a, b;
            cin >> a >> b;
            d[b] += d[a];
            sum += d[a] * (b - a);
            d[a] = 0;
            cout << sum << endl;
        }
    }
}


Measured memory_bytes: 9452
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define rep(i,a) for(int i = 0 ; i < a ; i++) 

char maze[21][21];
int dx[4] = { 0, 0,-1, 1};
int dy[4] = {-1, 1, 0, 0};
int H,W;
bool inmaze(int x,int y){
  return (0<=x && x<H) && (0<=y && y<W);
}

int dfs(int x,int y){
  if(!inmaze(x,y))return 0;
  maze[x][y] = '#';
  int res = 1;
  rep(i,4){
    if(maze[x+dx[i]][y+dy[i]] == '.'){
      res += dfs(x+dx[i],y+dy[i]);
    }
  }
  return res;
}
int main(void){
  while(cin>>W>>H,H+W){
    int sx,sy;
    rep(i,H){
      string s;
      cin>>s;
      rep(j,W){
	maze[i][j] = s[j];
	if(s[j] == '@'){
	  sx = i;sy = j;
	}
      }
    }
    maze[sx][sy] = '.';
    cout<<dfs(sx,sy)<<endl;
  }
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool IsPrime(ll n)
{
    for (ll i = 2; i * i <= n; ++i)
    {
        if (n % i == 0) return false;
    }
    return true;
}

int main()
{
    ll x;
    cin >> x;
    while(1)
    {
        if (IsPrime(x)) break;
        ++x;
    }
    cout << x << endl;
}


Measured memory_bytes: 384
a, b, c, d, e = map(int, input().split())
if a == 0:
    print(1)
    exit()
if b == 0:
    print(2)
    exit()
if c == 0:
    print(3)
    exit()
if d == 0:
    print(4)
    exit()
if e == 0:
    print(5)


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	for (auto &&a : as)
	{
		a--;
	}

	vector<int64_t> sum(n + 1, 0);
	for (int i = 0; i < n; i++)
	{
		sum[i + 1] = sum[i] + as[i];
	}

	int64_t ans = 0;

	map<int64_t, int64_t> mp;

	for (int i = 0; i <= n; i++)
	{
		if (k <= i)
		{
			mp[sum[i - k] % k]--;
		}
		ans += mp[sum[i] % k]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
/*************************
author : coldbeer
2019-05-25 05:30:51 PM IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b; cin >> a >> b;
	if(a <= 5)
		cout << "0" << endl;
	else if(a >=6 && a <= 12)
		cout << (b / 2) << endl;
	else
		cout << b << endl;
	return 0;
}


Measured memory_bytes: 256