akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

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

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool hdp[2][8010], vdp[2][8010];

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

	vector<int> hvec, vvec;
	string S;
	int x, y;
	int nxt = 0;
	int cnt = 0;
	cin >> S >> x >> y;
	int p = 0;
	while (p < SZ(S) && S[p] == 'F')p++;
	x -= p;
	x = abs(x), y = abs(y);

	rep(i, p, SZ(S))
	{
		if (S[i] == 'T')
		{
			if (cnt != 0)
			{
				if (nxt == 0)
				{
					hvec.push_back(cnt);
				}
				else
				{
					vvec.push_back(cnt);
				}
			}
			cnt = 0;
			nxt ^= 1;
		}
		else
		{
			cnt++;
			if (i == SZ(S) - 1)
			{
				if (cnt != 0)
				{
					if (nxt == 0)
					{
						hvec.push_back(cnt);
					}
					else
					{
						vvec.push_back(cnt);
					}
				}
			}
		}
	}

	hdp[0][0] = vdp[0][0] = true;
	nxt = 1;
	for (auto v : hvec)
	{
		rep(i, 0, 8010)
		{
			hdp[nxt][i] = false;
		}
		rep(i, 0, 8010)
		{
			if (hdp[nxt ^ 1][i])
			{
				hdp[nxt][i + v] = true;
				hdp[nxt][abs(i - v)] = true;
			}
		}
		nxt ^= 1;
	}

	bool ok = hdp[nxt ^ 1][x];

	nxt = 1;
	for (auto v : vvec)
	{
		rep(i, 0, 8010)
		{
			vdp[nxt][i] = false;
		}
		rep(i, 0, 8010)
		{
			if (vdp[nxt ^ 1][i])
			{
				vdp[nxt][i + v] = true;
				vdp[nxt][abs(i - v)] = true;
			}
		}
		nxt ^= 1;
	}

	if (ok && vdp[nxt ^ 1][y])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
int def(ll a){
  string c = to_string(a);
  ll bc = c.length();
  ll n = bc/2ll;
  rep(i,n){
    if(c[i] != c[bc-i-1]) return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  for(ll i = n;i<=m;i++){
    ans+=def(i);
  }
  pri(ans);
  return 0;
}


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

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int A, B, C, X;
	scanf("%d%d%d%d", &A, &B, &C, &X);

	int tmp = 0, ans = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				tmp = 500 * i + 100 * j + 50 * k;
				if (tmp == X) {
					ans++;
				}
			}
		}
	}
	printf("%d\n", ans);






#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;

double calc(pii a, pii b) {
  double ans = pow(a.first - b.first, 2) + pow(a.second - b.second, 2);

  return sqrt(ans);
}

int fact(int a) {
  if (a == 0) return 1;

  return a * fact(a - 1);
}
int main() {
  int n;
  cin >> n;
  vector<pii> coord(n);

  for (int i = 0; i < n; i++) {
    cin >> coord[i].first >> coord[i].second;
  }

  double ans = 0;

  vector<int> permu;

  for (int i = 0; i < n; i++) {
    permu.push_back(i);
  }

  do {
    for (int i = 0; i < n - 1; i++) {
      ans += calc(coord[permu[i]], coord[permu[i + 1]]);
    }

  } while (next_permutation(permu.begin(), permu.end()));

  printf("%.11lf", ans / fact(n));
  cout << endl;

  // cout << fact(n) << endl;
}


Measured memory_bytes: 3820
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int a, b, c;
        a = input.nextInt();
        b = input.nextInt();
        c = input.nextInt();
        if (a < b && b < c) System.out.println("Yes");
        else System.out.println("No");
    }         
}

Measured memory_bytes: 17216
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type Input struct {
	n int
	i int
}

func ReadInput(reader io.Reader) (*Input, error) {
	input := Input{}
	fmt.Fscan(reader, &input.n, &input.i)
	return &input, nil
}

func main() {
	reader := bufio.NewReader(os.Stdin)

	input, err := ReadInput(reader)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	result := input.n - input.i + 1
	fmt.Println(result)
}


Measured memory_bytes: 640
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String ans = "WA";
    int cnt = 0;
    int cnt2 = 0;
    if (S.charAt(0) == 'A') {
      for (int i = 2; i < S.length() - 1; i++) {
        if (S.charAt(i) == 'C') {
          cnt++;
        }
      }
      String str1 = S.replace("A", "a");
      String str2 = str1.replace("C", "c");
      if (cnt == 1) {
        for (int i = 0; i < str2.length(); i++) {
          if (!Character.isLowerCase(str2.charAt(i))) {
            break;
          } else {
            cnt2++;
          }
        }
        if (cnt2 == str2.length()) {
          ans = "AC";
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main()
{
    int n;
    int h,m,s;
    cin>>n;
    h=((n/60)/60);
    n=(n-h*60*60);
    m=n/60;
    s=n-(m*60);
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}



Measured memory_bytes: 3112
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N,Q = map(int, input().split())

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

stack = [0]
while stack:
    s = stack.pop()
    color[s] = 1
    for t in edge[s]:
        if color[t]==0:
            stack.append(t)
            node[t] += node[s]
    color[s]=2

for n in node:
    print(n)

Measured memory_bytes: 52824
while True:
    n=int(input())
    
    if n==0:
        break
    else:
        x=[]
        for i in range(n):
            a=int(input())
            x.append(a)
        x1=sorted(x)
            
        b=0
        for j in range(0,10):
            s=x1.count(b)
                
            if s==0:
                print('-')
            else:
                print('*'*s)
            b+=1


Measured memory_bytes: 5764
import numpy as np
A, B, H, M= map(float,input().split())

thOne=-1.*np.pi/6.
thTwo=-1.*np.pi/30.

Hx=np.cos(thOne*H+thOne/60*M)*A
Hy=np.sin(thOne*H+thOne/60*M)*A
Mx=np.cos(thTwo*M)*B
My=np.sin(thTwo*M)*B

#print(A,B,H,M)
#print(Hx,Hy,Mx,My)
print(np.sqrt((Hx-Mx)**2+(Hy-My)**2))

Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,pos,arr[1005];
   double t,a,sum,m=10000000.0,res[1005];
   cin>>n>>t>>a;
   for(int i=1;i<=n;i++)
   {
      cin>>arr[i];
      sum=t-(arr[i]*0.006);
       res[i]=abs(a-sum);
       if(res[i]<=m)
       {
          m=res[i];
          pos=i;

       }
   }
  cout<<pos<<endl;



    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
AB = [[int(j) for j in input().split()] for i in range(n)]
AB.sort()
res = 0
for a,b in AB:
    m -= b
    if m >= 0:
        res += a*b
    else:
        m += b
        res += a*m
        break
print(res)

Measured memory_bytes: 21608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
    cerr<<a<<" "<<b<<endl;
    return a/gcd(a,b)*b;
}
int main(){
    int n;
    cin>>n;
    vl vec(n);
    ll ans=0;
    REP(i,n){
        cin>>vec[i];
        ans+=vec[i]-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;
Node find(Node u,int k){
  if(u==NIL||u->key==k)
    return u;
  if(u->key > k)
    return find(u->left,k);
  else
    return find(u->right,k);
}
void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;
   
   z =malloc(sizeof(struct node));
   z->key = k;
   z->left = NIL;
   z->right = NIL;
   while(x!=NIL){
     y=x;
     if(z->key < x->key)x=x->left;
     else x=x->right;
   }
   z->parent=y;
   if(y==NIL)root=z;
   else if(z->key <y->key)
   y->left=z;
   else
     y->right=z;
}

void inorder(Node u){
  if(u->left!=NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)
    inorder(u->right);
}

void preorder(Node u){
  if(u!=NIL)
    printf(" %d",u->key);
  if(u->left!=NIL)
    preorder(u->left);
  if(u->right!=NIL)
    preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
     Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include <stdio.h>
int main (void){
int a;
int b;
int c;
int d;
scanf ("%d",&a);
b=a/3600;
c=(a-b*3600)/60;
d=(a-b*3600-c*60);

printf ("%d:%d:%d\n",b,c,d);



return 0 ;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, q; cin >> n >> k >> q;
    vector<int> a(q); rep (i, q) cin >> a[i];
    vector<int> b(n);
    rep (i, q) b[a[i] - 1]++;
    rep (i, n) {
        eprintf("%d ", q - b[i]);
        if (q - b[i] < k) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define PI acosl(-1)//3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int main() {
    long A, B, H, M;
    long double angle, dsq;
    scanf("%ld %ld %ld %ld", &A, &B, &H, &M);
    angle = 2.0L * PI * (H / 12.0L - 11.0L * M / 720.0L);
    dsq = (long double)(A * A + B * B) - (long double)(2 * A * B) * cosl(angle);
    printf("%.20llf\n", sqrtl(dsq));
    return 0;
}

void print_log() {
    printf("===finish!===\n");
}

void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}

Measured memory_bytes: 2580
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	if (a == b)
		cout << c << endl;
	else if (b == c)
		cout << a << endl;
	else
		cout << b << endl;
	return 0;
}

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

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
int main() {

    int a, b, c;
    cin >> a >> b >> c;

    string ans = "Yes";
    if ( (a==b && b==c && a==c) || (a!=b && b!=c && a!=c) ) {
        ans = "No";
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
n=int(input())
k=n
dic={}
import math
for i in range(2,math.floor(math.sqrt(n))):
  for j in range(10**10):
    if n%i==0:
      if i in dic:
        dic[i]+=1
      else:
        dic[i]=1
      n=n//i
    else:
      break

count=0
if k!=1:
  if not dic or n!=1:
    count+=1

while dic:
  keep=1
  x=dic.popitem()
  num=x[1]
  for i in range(1000):
    if num>=keep:
      num-=keep
      count+=1
      keep+=1
    else:
      break
print(count)


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  int N, M;
  cin >> N >> M;
  vector<LL> A(N);
  for(auto& i: A) cin >> i;
  priority_queue<LL> q;
  for(auto i: A) q.emplace(i);
  for(auto i=0; i<M; ++i) {
    auto x = q.top(); q.pop();
    q.emplace(x/2);
  }
  LL s=0;
  while(!q.empty()) {s+=q.top(); q.pop();}
  cout << s << endl;
}


Measured memory_bytes: 5092
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

long long mod = 1e9+7;

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    long long sum = 0;
    for(long long i = 0; i < n; i++) cin >> a[i], sum += a[i];

    long long ans = 0;
    for(long long i = 0; i < n; i++){
        sum -= a[i];
        ans += a[i] * (sum%mod);
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

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

int max_index(const vector<int> &xs) {
  vector<int> ys(xs);
  vector<int>::iterator iter = max_element(ys.begin(), ys.end());
  return distance(ys.begin(), iter);
}

int change_count(int n, const vector<int> &xs, const vector<int> &ys) {
  int x_max_idx = max_index(xs);
  int y_max_idx = max_index(ys);

  int result = 0;
  if (x_max_idx != y_max_idx) {
    result += n / 2 - xs[x_max_idx];
    result += n / 2 - ys[y_max_idx];
  } else {
    vector<int> txs(xs);
    txs[x_max_idx] = 0;
    vector<int> tys(ys);
    tys[y_max_idx] = 0;

    result = min(
      change_count(n, txs, ys),
      change_count(n, xs, tys));
  }

  return result;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> vs(n / 2);
  vector<int> ws(n / 2);
  for (int i = 0; i < n / 2; i++) {
    cin >> vs[i] >> ws[i];
  }

  // 数値と出現数のペアを取得しなきゃいけないので
  vector<int> v_count(100001);
  vector<int> w_count(100001);
  for (const int &v : vs) v_count[v]++;
  for (const int &w : ws) w_count[w]++;

  int result = change_count(n, v_count, w_count);
  
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int dp[20][10], tr[20][10];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    if (k < 10) return cout << k, 0;

    k -= 9;
    FOR(i, 1, 10) dp[1][i] = tr[1][i] = 1;
    tr[1][0] = 1;
    FOR(d, 2, 20) {
        FOR(i, 0, 10) FOR(j, max(0, i - 1), min(10, i + 2)) {
            dp[d][i] += dp[d - 1][j];
            tr[d][i] += tr[d - 1][j];
        }

        int tot = accumulate(dp[d], dp[d] + 10, 0);
        if (k <= tot) {
            int cd = d, prv = 1, nxt = 10;
            while (cd && k) {
                FOR(i, prv, nxt) {
                    if (tr[cd][i] < k) k -= tr[cd][i];
                    else {
                        cout << i;
                        prv = max(0, i - 1), nxt = min(10, i + 2);
                        break;
                    }
                }
                cd--;
            }
            break;
        } else k -= tot;
    }
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,a[5],mn; cin>>n; 
    for (int i=0;i<5;i++) cin>>a[i];
    sort(a,a+5);
    mn=a[0];
    int ans = 4+(n+mn-1)/mn;
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

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

int main()
{
  int H, W;
  while (~scanf("%d %d", &H, &W)) {
    if ((H|W) == 0)
      break;

    vector<string> orc(H);
    for (int i = 0; i < H; ++i)
      cin >> orc[i];

    int ans = 0;
    vector< vector<int> > visited(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
	if (visited[i][j])
	  continue;

	++ans;
	char fruit = orc[i][j];
	queue< pair<int, int> > que;
	que.push(pair<int, int>(i, j));
	while (!que.empty()) {
	  const pair<int, int> p = que.front();
	  que.pop();

	  if (visited[p.first][p.second])
	    continue;

	  visited[p.first][p.second] = 1;
	  for (int d = 0; d < 4; ++d) {
	    pair<int, int> pp = p;
	    pp.first += dy[d];
	    pp.second += dx[d];
	    if (pp.first < 0 || H <= pp.first ||
		pp.second < 0 || W <= pp.second ||
		visited[pp.first][pp.second] ||
		orc[pp.first][pp.second] != fruit)
	      continue;
	    que.push(pp);
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h, w;
	while(cin >> h >> w){
		if(h==0 && w==0)
			break;
		for(int i=1; i<=h; i++){
			if(i%2==1){
				for(int j=1; j<=w; j++){
					if(j%2==1)
						cout << '#';
					else
						cout << '.';
				}
				cout << endl;
			}else{
				for(int j=1; j<=w; j++){
					if(j%2==0)
						cout << '#';
					else
						cout << '.';
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
} 


Measured memory_bytes: 3100
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()

count = 0
for i in range(n):
    if s[i] == '(':
        count += 1
    else:
        count = max(0, count-1)

s += ')'*count
        
count = 0
for i in range(n-1, -1, -1):
    if s[i] == ')':
        count += 1
    else:
        count = max(0, count-1)

s = '('*count + s
print(s)

Measured memory_bytes: 10288
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			int q = sc.nextInt();

			for(int i = 0; i < q; i++) {
				int head = 0;
				int foot = n - 1;
				int k = sc.nextInt();
				int j = -1;
				while(head <= foot) {
					int mid = (head + foot) / 2;
					if(a[mid] == k) {
						j = mid;
						break;
					}
					else if(a[mid] < k) {
						head = mid + 1;
					}
					else {
						foot = mid - 1;
					}
				}
				if(j != -1) {
					System.out.println(1);
				}
				else {
					System.out.println(0);
				}
			}
		}
	}
}


Measured memory_bytes: 104124
#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>;
 
int main(){
    int n, in;
    cin >> n;
    int sum = 0;
    int max = 0;
    rep(i, n){
        cin >> in;
        sum += in;
        if(max < in) max = in;
    }
    cout << sum - max/2 << endl;
    return 0;
}

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

using namespace std;

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

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

  int x;
  cin >> x;

  if(x >= 30) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3644
import collections

N = int(input())
A = list(map(int , input().split()))

# N = 32
# A = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5]

# N = 6
# A = [2, 3, 3, 1, 3, 1]

i = [k for k in range(1,N+1)]
j = [k for k in range(1,N+1)]

Li = [i[k]+A[k] for k in range(N)]
Rj = [j[k]-A[k] for k in range(N)]

Li = collections.Counter(Li)

counter = 0
for r in Rj:
    counter += Li[r]
print(counter)

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  string a,b; cin >> a >> b;
  if(a.size() > b.size()) cout << "GREATER";
  else if(a.size() < b.size()) cout << "LESS";
  else{
    if(a > b) cout << "GREATER";
    else if(a < b) cout << "LESS";
    else cout << "EQUAL";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  vector<int> v(4);
    
  scanf("%c%c%c%c",&v[0],&v[1],&v[2],&v[3]);
  rep(i,4){
    v[i]-=48;
  }

  string s;
  ll temp=0;
  rep(i,8){
    s=bitset<3>(i).to_string();
    temp=v[0];
    rep(j,3){
      if(s[j]=='1'){
        temp+=v[j+1];
      }else{
        temp-=v[j+1];
      }
    }
    if(temp==7){
      cout<<v[0];
      rep(j,3){
        if(s[j]=='1'){
          cout<<'+';
          cout<<v[j+1];
        }else{
          cout<<'-';
          cout<<v[j+1];
        }
      }
      cout<<"=7";
      cout<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;
}


Measured memory_bytes: 3628
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	string a;
	cin >> a;
	std::reverse(a.begin(), a.end());
	cout << a << endl;
	return 0;
}

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

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	if(s.back() == 's') cout << s << "es\n";
	else cout << s << "s\n";
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdc++.h>
#include<cstdio>
#define ll long long int
#define mod 1000000007
#define pi 3.141592653589793
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define vfind(a, e) find(a.begin(), a.end(), e)
#define forr(i, n) for (ll i = 0; i < n; i++)
#define rfor(i, n) for (ll i = n - 1; i >= 0; i--)
#define fors(i, b, e, steps) for(ll i = b; i < e; i += steps)
#define rfors(i, e, b, steps) for(ll i = e; i > b; i -= steps)
#define mp make_pair
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}

bool isLower(char c){
    return 97 <= c && c <= 122;
}

void mul(ll a[2][2], ll b[2][2]) {
    ll p = a[0][0] * b[0][0] + a[0][1] * b[1][0];
    ll q = a[0][0] * b[0][1] + a[0][1] * b[1][1];
    ll r = a[1][0] * b[0][0] + a[1][1] * b[1][0];
    ll s = a[1][0] * b[0][1] + a[1][1] * b[1][1];

    a[0][0] = p % mod;
    a[0][1] = q % mod;
    a[1][0] = r % mod;
    a[1][1] = s % mod;
}



int main() {
    // cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n;
    cin >> n;
    ll a[n];
    forr(i, n) {
        cin >> a[i];
    }
    ll m = *max_element(a, a + n) + 1;

    ll d[m], pre[m];
    fill (d, d + m, 0);
    fill (pre, pre + m, 0);
    pre[a[0]] = 1;
    d[a[0]] = 1;
    ll dp[n];
    dp[0] = 1;

    fors (i, 1, n, 1) {
        if (a[i] == a[i - 1]) {
            dp[i] = dp[i - 1];
        }

        else if (d[a[i]] == 0) {
            dp[i] = dp[i - 1];
        }

        else {
            dp[i] = (dp[i - 1] + pre[a[i]]) % mod;
        }

        d[a[i]]++;
        if (a[i] != a[i - 1]) {
            pre[a[i]] += dp[i - 1];
            pre[a[i]] %= mod;
        }

    }

    cout << dp[n - 1];
}



//1 2 1 2 2


Measured memory_bytes: 6528
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string s;
    cin >> s;
    if (s[0] >= 'a' && s[0] <= 'z')
        cout << "a" << endl;
    else
        cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>

int main(void) {
    int n;
    int min, max;
    long long sum = 0;
    std::cin >> n;
    for(int i=0; i<n; i++){
        int v;
        std::cin >> v;
        if(i == 0) {
            min = v;
            max = v;
        }else{
            if(min > v) min = v;
            if(max < v) max = v;
        }
        sum += v;
    }

    std::cout << min << ' ' << max << ' ' << sum << std::endl;

    return 0;
}



Measured memory_bytes: 3124
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = 0;
		int b = 0;
		int c = 0;
		
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();

		if ( a < b && b < c && a < c ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int X;
  cin>>X;

  if(X>=30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3648
MOD=10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
n = len(a)
li = [0] * 2001
t1 = 0
for i in range(n):
  for j in range(i + 1, n):
    if a[i] > a[j]:
      t1 += 1
for x in a:
  li[x] += 1
t2 = 0
for i in range(2000):
  t2 += li[i + 1] * li[i]
  li[i + 1] += li[i]
print((t1 * k + t2 * k * (k - 1) // 2) % MOD)

Measured memory_bytes: 41196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<ll, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<ldouble, ldouble> pdd;

int n, m;
int A[200020];
int p[200020];
int Find(int x) { return p[x] == x ? x : p[x] = Find(p[x]); }
int Z[200020];
int ok[200020];

void solve() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) scanf("%d", A+i);
	for(int i=1;i<=n;i++) Z[i] = i;
	for(int i=1;i<=n;i++) p[i] = i;
	rep(i, m) {
		int x, y; scanf("%d%d", &x, &y); ++x; ++y;
		p[Find(x)] = Find(y);
	}
	for(int i=1;i<=n;i++) if(p[i] != i) {
		int pi = Find(i);
		if(A[Z[pi]] > A[i]) Z[pi] = i;
	}
	int com = 0;
	for(int i=1;i<=n;i++) com += (p[i] == i);
	if(2 * com - 2 > n) {
		puts("Impossible");
	}
	else if(com == 1) {
		puts("0");
	}
	else {
		ll ans = 0;
		for(int i=1;i<=n;i++) if(p[i] == i) ans += A[Z[i]], ok[Z[i]] = 1;
		vector <int> r;
		for(int i=1;i<=n;i++) if(ok[i] == 0) r.pb(A[i]);
		sort(all(r));
		for(int i=0;i<com- 2; i++) ans += r[i];
		printf("%lld\n", ans);
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




Measured memory_bytes: 2428
#include <stdio.h>

int main(void) {
	int a, b, t;
	
	while(scanf("%d %d", &a, &b)!=EOF){
		t=a+b;
		int sum=0;
		
		while(t>0){
			sum++;
			t/=10;
		}
		
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	long long int n;
	cin>>n;
	long long int a[100010],b[100010];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	reverse(a,a+n);
	reverse(b,b+n);
	long long int cnt=0;
	for(int i=0;i<n;i++){
		long long int cc=(a[i]+cnt);
		cc=(cc%b[i]==0)?0:b[i]-(cc%b[i]);
		cnt=cnt+cc;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;

void cycle(vector<int> &v) {
    vector<int> ret(v.begin() + 1, v.end());
    ret.push_back(v[0]);
    v = ret;
}

int main() {
    vector<int> gowland = {1,4,1,4,1,2,1,2};
    vector<int> p(8);
    while (cin >> p[0]) {
        for (int i=1; i<8; ++i) {
            cin >> p[i];
        }
        vector<int> ans;
        int mn = INT_MAX;
        for (int k=0; k<8; ++k) {
            int cnt = 0;
            for (int i=0; i<8; ++i) {
                cnt += max(0, p[i] - gowland[i]);
            }
            if (cnt < mn || (cnt == mn && gowland < ans)) {
                ans = gowland;
                mn = cnt;
            }
            cycle(gowland);
        }
        for (int i=0; i<(int)ans.size(); ++i) {
            cout << (i == 0 ? "" : " ") << ans[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-

import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        n = int(input())
        ts = list(map(int, input().split()))
        s = sum(ts)
        m = int(input())
        for i in range(m):
            p, x = map(int, input().split())
            print(s + (x - ts[p-1]))
        
        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> ju(n, true);
    FOR(i,0,n) cin >> h.at(i);
    FOR(i,0,m){
        int a,b;
        cin >> a >> b;
        --a, --b;
        if(h.at(a) >= h.at(b)) ju.at(b) = false;
        if(h.at(a) <= h.at(b)) ju.at(a) = false;
    }
    int ans = 0;
    FOR(i,0,n) if(ju.at(i)) ans++;
    cout << ans << endl;
    return 0;
    }





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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 073_abc_d / Link: https://abc073.contest.atcoder.jp/tasks/abc073_d?lang=en  ----- */
/* ------問題------

Atcoder国には N 個の町があり、M 本の双方向に移動可能な道で結ばれています。
また、 i 本目の道は町 Ai と町 Bi の間を距離 Ci で結んでいます。
joisinoお姉ちゃんは、この国の R 個の町 r1,r2..rR を訪れることとなりました。
最初に訪れる町までの移動と、最後に訪れる町からの移動は空路で行うが、それ以外は道を使わなければなりません。
町を訪れる順番を、道での移動距離が最小となるように決めた時の移動距離を答えてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M, R;

LL ans = 0LL;

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

	cin >> N >> M >> R;
	VI r(R);
	FOR(i, 0, R) {
		cin >> r[i];
		r[i]--;
	}

	VI a(M), c(M), b(M);
	VVL dist(N, VL(N, LINF));

	FOR(i, 0, M) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		dist[a[i]][b[i]] = dist[b[i]][a[i]] = min((LL)c[i], dist[a[i]][b[i]]);
	}
	FOR(i, 0, N)dist[i][i] = 0;
	FOR(k, 0, N) {
		FOR(i, 0, N) {
			FOR(j, 0, N) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	VVL d(1 << R, VL(R, LINF));
	FOR(i, 0, R) {
		d[1 << i][i] = 0;
	}

	FOR(state, 0, 1 << R) {
		FOR(k, 0, R) {
			if(state&(1<<k))
			FOR(i, 0, R) {
				if (!(state&(1 << i)))
					d[state | 1 << i][i] = min(d[state | 1 << i][i], d[state][k] + dist[r[k]][r[i]]);
			}
		}
	}
	ans = LINF;
	FOR(i, 0, R) {
		ans = min(ans, d[(1 << R) - 1][i]);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[1'005];
vector<int> revG[1'005];
bool reachableFrom1[1'005];
bool reachableToN[1'005];

void dfs1(int v){
  if(reachableFrom1[v]){
    return;
  }
  reachableFrom1[v] = true;
  for(int next_:G[v]){
    dfs1(next_);
  }
  return;
}

void dfsN(int v){
  if(reachableToN[v]){
    return;
  }
  reachableToN[v] = true;
  for(int next_:revG[v]){
    dfsN(next_);
  }
  return;
}

int main(){
  
  int n,m;
  cin>>n>>m;
  int a[m],b[m],c[m];
  REP(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    revG[b[i]].push_back(a[i]);
  }
  
  bool usable[n]={};
  dfs1(0);
  dfsN(n-1);
  REP(i,n){
    usable[i] = reachableFrom1[i] && reachableToN[i];
  }
  
  vector<long long> dist(n,-INF);
  dist[0] = 0;
  REP(_,m){
    REP(i,m){
      if(usable[a[i]] && usable[b[i]]){
        dist[b[i]] = max(dist[b[i]], dist[a[i]] + c[i]);
      }
    }
  }
  bool cycle_ = false;
  REP(i,m){
    if(usable[a[i]] && usable[b[i]]){
      if(dist[b[i]]<dist[a[i]] + c[i]){
        cycle_ = true;
        break;
      }
    }
  }
  
  if(cycle_){
    cout<<"inf"<<endl;
  }else{
    cout<<dist[n-1]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int N,K;
int POW[30];
int main(){

	POW[0] = 1;
	for(int i = 1; i < 30; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d",&N,&K);

	vector<int> ans;
	for(int state = 0; state < POW[N]; state++){
		int count = 0,sum = 0;
		for(int i = 0; i < N; i++){
			if(state & POW[i]){
				count++;
				sum += POW[i];
			}
		}
		if(count != K)continue;
		ans.push_back(sum);
	}

	for(int i = 0; i < ans.size(); i++){

		printf("%d:",ans[i]);
		for(int k = 0; k < N; k++){
			if(ans[i]&POW[k]){

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

	return 0;
}



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

enum MARK
{
	S = 0, H, C, D, NUM
};

int main()
{
	string mark_str[4] = { "S","H","C","D" };
	bool cards[NUM][13];
	for (int i = 0; i < NUM; ++i)
		for (int j = 0; j < 13; ++j)
			cards[i][j] = false;
	int n;
	cin >> n;
	string s;
	int markid,number;
	for (int i = 0; i < n; ++i) {
		cin >> s >> number;
		if (s == "S")
			markid = S;
		else if (s == "H")
			markid = H;
		else if (s == "C")
			markid = C;
		else if (s == "D")
			markid = D;
		else
			cout << "error"<<endl;
		cards[markid][number-1] = true;
	}
	for (int i = 0; i < NUM; ++i) {
		string s = mark_str[i];
		for (int j = 0; j < 13; ++j)
			if (cards[i][j] == false) {
				cout << s << " " << j+1 << endl;
			}
	}

	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    a[i] += ans;
    ans += (b[i] - (a[i] % b[i])) % b[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int n;
int a[100005];
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  int ans=0;
  for(int i=1;i<=n;i++)
    if(a[i]==i)
    {
      ans++;
      i++;
    }
  cout<<ans<<endl;
  system("pause");
  return 0;
}


Measured memory_bytes: 888
import math

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

total_distance = 0
count = 0

for i in range(n):
    for j in range(n):
        if i != j:
            total_distance += math.sqrt( (xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2 )
            count += 1

print(total_distance / n)

Measured memory_bytes: 3064