akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
// #define pb push_back
#define ll long long
#define endl "\n"
using namespace std;

void solve(){
	string s1,s2;
	cin>>s1>>s2;
	ll m=s1.length(),n=s2.length();
	ll ans=LLONG_MAX;
	for(ll i=0;i<m-n+1;i++){
		ll j=i,k=0;
		ll cnt=0;
		while(k<n){
			if(s1[j]==s2[k]){
				cnt++;
			}
			j++,k++;
		}
		ans=min(ans,n-cnt);
	}
	cout<<ans<<endl;
}

int main() {
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}




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

int dp[50];

int fib(int n)
{
  if (n == 0 || n == 1)
  {
    return dp[n] = 1;
  }

  if (dp[n] != -1)
  {
    return dp[n];
  }
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main()
{
  for (int i = 0; i < 50; i++)
  {
    dp[i] = -1;
  }

  int n;
  cin >> n;

  cout << fib(n) << endl;

  return 0;
}


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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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


const int mod = 1e9 + 7;

const int N = 1005;

ll L, R;
ll a[N], b[N];
ll dp[70][2][2][2];

ll calc(ll pos, int is_l, int is_r, int ch = 0) {
    if(pos < 0) return 1;
    if(dp[pos][is_l][is_r][ch] != -1) return dp[pos][is_l][is_r][ch];
    ll &res = dp[pos][is_l][is_r][ch];
    res = 0;
    // 1 1
    if(!is_r or b[pos])
        (res += calc(pos - 1, is_l && a[pos], is_r, 1)) %= mod;

    // 0 1
    if((!is_r or b[pos]) and (!is_l or !a[pos]) and ch)
        (res += calc(pos - 1, is_l && !a[pos], is_r, 1)) %= mod;
    // 0 0
    if(!is_l or !a[pos])
        (res += calc(pos - 1, is_l && !a[pos], is_r and !b[pos], ch)) %= mod;
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> L >> R;
    for(int i = 61; i >= 0; --i) {
        a[i] = (L >> i) & 1;
        b[i] = (R >> i) & 1;
    }
    memset(dp, -1, sizeof dp);
    cout << calc(61, 1, 1);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  
 int main(void){
 	int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(0>x-r||W<x+r){
	printf("No\n");
}else if(H<y+r||0>y-r){
	printf("No\n");
}else{
	printf("Yes\n");
}
return 0; 
}

 


Measured memory_bytes: 2696
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

int gcd(int a,int b){
    if (a==0) return b;
    else return gcd(b%a,a);
}
int inf=1001001001;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) {
        int a;
        cin>>a;
        v[i]=a;
    }
    sort(v.begin(),v.end());
    int tmp=gcd(v[0],v[1]);
    //cout<<tmp<<endl;
    //int ans=inf;
    for (int i=2;i<n;i++){
        tmp=gcd(tmp,v[i]);
    }
    cout<<tmp;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

vector<ll> s;
vector<ll> p;

void solve(){
    ll a,b; cin>>a>>b;

    ll x = __gcd(a,b),ans = 0;
    for(ll i=2;i*i<=x;i++){
        bool c = 0;
        while(x%i == 0){
            c = 1;
            x = x/i;
        }
        if(c) ans++;
    }   

    if(x > 1) ans++;
    cout<<ans+1<<endl;
}
 
signed main(){
 
   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
x=[]
z=[]
A,b=map(int,input().split())
for i in range(0,A):
 a=list(map(int,input().split()))
 x.append(a)
for s in range(0,b):
    q=int(input())
    z.append(q)
    
for i in range(A):
  l=0
  for s in range(b):
    l += x[i][s]*z[s]
  print(l)

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

int function(int n, int a, int b[]){
    int start = 0; int end = n;
    while(end-start>=1){
        int i = (start+end)/2;
        if(b[i]==a)
            return i;
        else if(b[i]<a)
            start = i;
        else
            end = i;
    }
}

int main(void){
    int n;
     cin >> n;
    int num[n];
    int fake[n];
    int ans[n];
    for(int i = 0; i < n; i++){
        cin >> num[i];
        fake[i]=num[i];
    }
    
    sort(num, num+n);
    int check = n/2;
    int mid = num[check];
    int now;
    for(int i = 0; i < n; i++){
        now = function(n, fake[i], num);
        if(now>=check)
            ans[i] = num[check-1];
        else if(now<check)
            ans[i] = num[check];
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4480
N, M = gets.chomp.split(" ").map(&:to_i)
H = gets.chomp.split(" ").map(&:to_i)

P = {}
M.times do
  a, b = gets.chomp.split(" ").map(&:to_i)
  P[a] = [] if P[a] == nil
  P[a] << b
  P[b] = [] if P[b] == nil
  P[b] << a
end

cnt = 0
N.times do |i|
  path = P[i + 1]
  cnt += 1 if path == nil || path.all? {|n| H[n-1] < H[i]}
end

puts cnt

Measured memory_bytes: 32504
M, D = map(int, input().split())

count = 0

d = [ m for m in range(22, D+1) if int(str(m)[1])>=2 ]

m = list(range(1, M+1))

for x in d:
    if int(str(x)[0])*int(str(x)[1]) in m:
        count += 1

print(count)

Measured memory_bytes: 38256
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2018-11-6 21:45:02
# Powered by Visual Studio Code
#

a, b, x = gets.chomp.split(" ").map{|i| i.to_i}
if a <= x && x <= a + b
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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 <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
VVI g;

VI A;
int ans = -1;
void dfs_aoki(int v, int acc, int pre){
    A[v] = acc;
    //dump(v)
    //dump(A[v])
    for(int u : g[v]){
        if(u == pre) continue;
        dfs_aoki(u,acc+1,v);
    }
}

void dfs_taka(int v, int acc, int pre, int rev){
    if(A[v] <= acc){
        chmax(ans,A[v]);
        return;
    }

    if(rev){
        dfs_taka(pre,acc+1,v,0);
    }else{

        for(int u : g[v]){
            if(u == pre){
                if(SZ(g[v]) != 1) continue;
                dfs_taka(u,acc+1,v,1);
            }else{
                dfs_taka(u,acc+1,v,0);
            }

        }
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    g.resize(N);
    A.resize(N);
    int S,T; cin >> S >> T;
    S--; T--;
    REP(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].eb(b);
        g[b].eb(a);
    }
    dfs_aoki(T,0,-1);
    if(SZ(g[S]) == 1){
        dfs_taka(g[S][0],1,-1,0);
    }
    dfs_taka(S,0,-1,0);
    cout << ans << endl;

}


Measured memory_bytes: 10752
n,t = map(int,input().split())
tt=list(map(int,input().split()))
count=0
i=1
while(i<n):
	if tt[i]-tt[i-1]>=t:
		count+=t
	else:
		count+=tt[i]-tt[i-1]
	i+=1
print(count+t)
		

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> TandF(100,vector<int>(100,0));
  string s;
  for(int i=0; i<n; ++i){
    cin >> s;
    ll num = 0, keta = 0;
    bool frag = false;
    for(int j=0; j<(s.size()); ++j){
      if(s[j] == '.'){frag = true; continue;}
      if(frag) ++keta;
      num = num*10 + (s[j]-'0');
    }
    int two = 0, five = 0;
    while(num%2 == 0){
      num /= 2;
      ++two;
    }
    while(num%5 == 0){
      num /= 5;
      ++five;
    }
    if(25 +two -keta < 0)continue;
    if(25 +five -keta < 0)continue;
    ++TandF[25 +two -keta][25 +five -keta];
  }
  ll ans = 0;
  for(int i1=0; i1<51; ++i1) for(int i2=0; i2<51; ++i2){
    for(int j1=50-i1; j1<51; ++j1) for(int j2=50-i2; j2<51; ++j2){
      ans += (ll)TandF[i1][i2] * TandF[j1][j2];
      if(i1 == j1 && i2 == j2) ans -= TandF[i1][i2];
    }
  }
  ans /= 2;
  cout << ans << endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------


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

	string s,t;
	cin>>s>>t;
	reverse(ALL(t));
	cout<<(s==t?"YES":"NO")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};


void slove(int n){
	vpint num(200);//num[??????]
	num[0].fi = 0; num[0].se = 0;//fi???x??§?¨? sey??§?¨?
	reps(i, 1, n){//?\\??°???????????????i
		int s, t;//s?????£??\????????¨?????????t???????????????????????????
		scanf("%d %d", &s, &t);
		if (t == 0){//????????????
			num[i].fi = num[s].fi - 1;
			num[i].se = num[s].se;
		}else if(t == 1){//????????????
			num[i].fi = num[s].fi;
			num[i].se = num[s].se - 1;
		}else if(t == 2){//????????????
			num[i].fi = num[s].fi + 1;
			num[i].se = num[s].se;
		}else if(t == 3){//????????????
			num[i].fi = num[s].fi;
			num[i].se = num[s].se + 1;
		}
	}
	int mx_x = 0, mi_x = 0, mx_y = 0, mi_y = 0;
	reps(i, 1, n){
		mx_x = max(num[i].fi, mx_x);//x??????????????§????????¢???
		mi_x = min(num[i].fi, mi_x);//x?????????????°?????????¢???
		mx_y = max(num[i].se, mx_y);
		mi_y = min(num[i].se, mi_y);
	}
	/*
	rep(i, n) printf("%d : %d %d\n", i, num[i].fi, num[i].se);
	printf("????????????%d %d %d %d\n", mx_x, mi_x, mx_y, mi_y);
	*/
	printf("%d %d\n", mx_x - mi_x + 1, mx_y - mi_y + 1);
	return;
}

int main(void){
	int n;
	rep(i, 1000){
		cin >> n;
		if (n == 0) break;
		slove(n);
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
 
int main(){
    int n;
    ll k;
    scanf("%d%llu", &n, &k);
    vector<int> v(n+1);
    for(int i = 1; i <= n ; ++i){
        scanf("%d", &v[i]);
    }
    int pos = 1, ntimes = 0;
    vector<int> freq(n+1, -1);
    while(k > 0){
        pos = v[pos];
        k--, ntimes++;
        if(freq[pos] != -1) k = (k % (ntimes-freq[pos]));
        freq[pos] = ntimes;
    }
    printf("%d\n", pos);
    return 0;
}

Measured memory_bytes: 4856
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }

// bool sorter(lld a, lld b)
// {
//     vector<lld> v2;
//     vector<lld> w;
//     // cout<<"A == " <<a<<"  B== "<<b;
//     while(a>=1)
//     {
//         v2.pb(a%10);
//         a/=10;
//     }
//     while(b>=1)
//     {
//         w.pb(b%10);
//         b/=10;
//     }   
       
//     reverse(all(v2));
//     reverse(all(w));
//     lld l1 = v2.size();
//     lld l2 = w.size();
//     lld  l = (l1*l2)/__gcd(l1,l2);
//     // cout<<l1<< " "<<l2<< " "<<l<< " ";
//     for(int i=0;i<l;i++)
//     {
//         if(v2[i%l1]!=w[i%l2])
//         {
//             // cout<< "   "<< (v2[i%l1] > w[i%l2])<<"\n";
//             return v2[i%l1] > w[i%l2];
//         }
//     }
//     // printf("false\n");
//     return false;
// }


lld p1=1e8 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;


void solve()
{
    cin>>n>>k;
    vector<lld> v;
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(l);
    }
    for(i=k;i<n;i++)
    {
        if(v[i]>v[i-k])
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    // cin>>t;
    // cout<<t;
     // getfac(p1);
    //check the value by which modulo is to be taken
    // lld ans=0;
    // precompute();
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 5324
import numpy as np

bingo = []

for i in range(3):
    bingo.append(list(map(int,input().split())))
n = int(input())

bingo = np.array(bingo)
for i in range(n):
    
    x = int(input())
    
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == x:
                bingo[j][k] = 0

ct = 0
sum1 = 0
for i in range(3):
    sum1 += bingo[i][i]
sum2 = 0
for i in range(3):
    sum2 += bingo[i][2-i]

if sum1 == 0 or sum2 == 0:
    ct += 1
if (sum(bingo.sum(axis=0)==0) >= 1) or (sum(bingo.sum(axis=1)==0) >= 1):
    ct += 1
    
if ct > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21400
n,k = map(int,input().split())

x = list(map(int,input().split()))
res = 10**16
for i in range(len(x)-k+1):
    res = min(res,abs(x[i])+abs(x[i+k-1]-x[i]),abs(x[i+k-1])+abs(x[i+k-1]-x[i]))
print(res) 


Measured memory_bytes: 14224
#include <iostream>
using namespace std;
void swap(int *a, int *b)
{
    int t= *a;
    *a = *b;
    *b = t;
}
int partition(int arr[], int low, int high)
{
    int pivot=arr[high];
    int i=low-1;
    for (int j=low; j<= high-1; j++)
    {
        if (arr[j] <= pivot)
        {
            i++;
            swap(&arr[j],&arr[i]);
        }
    }
    swap(&arr[i+1] , &arr[high]);
    return (i+1);
}
void quickSort(int arr[], int low, int high)
{
    if (low < high )
    {
        int pi=partition(arr, low, high);
        quickSort(arr, low, pi-1);
        quickSort(arr, pi+1, high);
    }
}
int main()
{
    int N,K;
    cin>>N>>K;
    if (N>=1 && N<=1000 && K>=1 && K<=N)
    {
        int total=0;
        int *price=new int[N];
        for (int i=0; i<N; i++)
            cin>>price[i];
        quickSort(price, 0, N-1);
        for (int i=0; i<K; i++)
            total+=price[i];
        cout<<total;
    }
    return 0;
}

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

int main() {
    string S;
    string T;
    cin >> S >> T;

    const int INF = 1000000;
    int ans = INF;

    for (int s = 0; s + T.size() <= S.size(); ++s) {
        int res = 0;
        for (int i = 0; i < T.size(); ++i) {
            if (T[i] != S[s+i]) {
                ++res;
            }
        }

        ans = min(ans, res);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <bits/stdc++.h>
#define ld long double
using namespace std;
int main()
{
	int n;
	cin>>n;
	ld h[n];
	ld t[n];
	for (int i=0; i<n; i++)
	{    
	    cin>>h[i];
	    t[i]=1-h[i];
	}
	ld dp[n+1][n];
	dp[0][0]=t[0];
	dp[1][0]=h[0];
	for (int i=1; i<n; i++)
	    dp[0][i]=dp[0][i-1]*t[i];
	for (int i=1; i<=n; i++)
	    for (int j=1; j<=n; j++)
	        dp[i][j]=0;
	cout.precision(10);
	for (int i=1; i<=n; i++)
	{
	    for (int j=1; j<n; j++)
	    {
	        dp[i][j]=dp[i][j-1]*t[j]+dp[i-1][j-1]*h[j];
	        //cout<<dp[i][j]<<" ";
	    }
	    //cout<<endl;
	}    
	ld ans=0;
	for (int i=n; i>n/2; i--)
	    ans=ans+dp[i][n-1];
	cout<<fixed<<ans<<endl;
}

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

using namespace std ; 

int main () { 
	int  t ; 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
	 
	int n ; 
	cin >> n;  
	vector < int > vect ;
	for ( int i = 0 ; i < n ; i ++ ){
		int x; 
		cin >> x; 
		vect.push_back(x); 
	}
	sort(vect.begin(), vect.end() );
	int max = 1e9;
	int sum ;
	for ( int i = vect[0] ; i <= vect[n-1] ; i ++) {
		sum = 0 ; 
		for ( int j = 0 ; j < n ; j ++ ) { 
			sum+= abs(i-vect[j])*abs(i-vect[j]);
		}
	
		max = sum < max ? sum : max ;  
	}
	cout << max << endl ; 
}


Measured memory_bytes: 256
"use strict"
String.prototype.add=function(b){
  var a=this;
  var L=Math.max(a.length,b.length);
  while(a.length<L){
    a='0'+a;
  }
  while(b.length<L){
    b='0'+b;
  }
  a=a.split('').reverse().join('');
  b=b.split('').reverse().join('');
  var c=[];
  for(let i=0;i<L;i++){
    c[i]=parseInt(a[i],10)+parseInt(b[i],10);
  }
  c[L]=0;
  for(let i=0;i<L+1;i++){
    c[i+1]+=(c[i]-c[i]%10)/10;
    c[i]=c[i]%10;
  }
  while(c[c.length-1]===0||c[c.length-1]!==c[c.length-1]){
    c.pop();
  }
  var str=c.reverse().join('');
  return str;
}

String.prototype.times=function(b){
  var a=this;
  var L=Math.max(a.length,b.length);
  while(a.length<2*L){//while1
    a='0'+a;
  }
  while(b.length<2*L){//while2
    b='0'+b;
  }
  
  a=a.split('').reverse().join('');
  b=b.split('').reverse().join('');
  var c=[];
  for(let i=0;i<2*L;i++){
    c[i]=0;
    for(let j=0;j<i+1;j++){
      c[i]+=parseInt(a[j],10)*parseInt(b[i-j],10);
    }
  }
  for(let i=0;i<2*L;i++){
    c[i+1]+=(c[i]-(c[i]%10))/10;
    c[i]=(c[i]%10);
  }
  while(c[c.length-1]===0||c[c.length-1]!==c[c.length-1]){
    c.pop();
  }
  var str=c.reverse().join('');
  return str;
}

String.prototype.isLargerThan=function(b){
  var a=this;
  if(a.length>b.length)return true;
  if(a.length<b.length)return false;
  for(let i=0;i<a.length;i++){
    var A=parseInt(a[i]),B=parseInt(b[i]);
    if(A>B)return true;
    if(A<B)return false;
  }
  return false;
}

function Main(input){
  var I=[],i=0;
  var checkNum=/^\d+/;
  var checkSpace=/ |\n/;
  while(input.length>0){
    if(input.match(checkNum)!==null){
      I[i]=input.match(checkNum)[0];
      input=input.replace(checkNum,"");    
      i++;
      continue;
    }
    input=input.replace(checkSpace,"");
    continue;
  }
  input=I;
  var N=parseInt(input[0]);
  var K=parseInt(input[1]);
  input.shift();
  input.shift();
  var A=[];
  for(let i=0;i<N;i++){
    A[i]=parseInt(input[i]);
  }
  var binaryA=[];
  for(let i=0;i<N;i++){
    binaryA[i]=A[i].toString(2);
    while(binaryA[i].length<41){
      binaryA[i]="0"+binaryA[i];
    }
  }//binaryA[i]は0詰め41桁の二進数
  var binaryKplusOne=(K+1).toString(2);
    while(binaryKplusOne.length<41){
      binaryKplusOne="0"+binaryKplusOne;
  }//binaryKplusOneは0詰め41桁の二進数

  var K_=[];
  var k=0;
  K_[0]=binaryKplusOne.indexOf("1");
  while(true){
    K_[k+1]=binaryKplusOne.indexOf("1",K_[k]+1);
    if(K_[k+1]===-1)break;
    k++;
  }
  K_.pop();
  
  var digSum=[];
  for(let i=0;i<41;i++){
    digSum[i]=0;
    for(let j=0;j<N;j++){
      digSum[i]+=(binaryA[j][i]==="1")?1:0;
    }
  }
  
  var X="";
  var counterMax='0';
  for(let i=0;i<K_.length;i++){
    X="";
    for(let j=0;j<K_[i];j++){
      X=X+""+binaryKplusOne[j];
    }
    X=X+"0";
    for(let j=K_[i]+1;j<41;j++){
      X=X+((digSum[j]>N-digSum[j])?"0":"1");
    }
    var counter='0';
    for(let j=0;j<41;j++){
      counter = counter.add(((X[40-j]==="0")?(digSum[40-j].toString(10)):(N-digSum[40-j]).toString(10)).times(Math.pow(2,j).toString(10)));
    }
    if(counter.isLargerThan(counterMax))counterMax=counter;
  }
  console.log(counterMax);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n;
    vector<P> edges(n-1);
    vector<vector<int>> G(n,vector<int>(n,100));
    for (int i = 0;i < n-1;++i) {
        cin >> edges[i].first >> edges[i].second;
        edges[i].first--;edges[i].second--;
        G[edges[i].first][edges[i].second] = 1;
        G[edges[i].second][edges[i].first] = 1;
    }
    for (int i = 0;i < n;++i) G[i][i] = 0;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) for (int k = 0;k < n;++k) G[j][k] = min(G[j][k],G[j][i]+G[i][k]);
    cin >> m;
    vector<ll> s(m,0);
    for (int i = 0;i < m;++i) {
        int p,q;
        cin >> p >> q;
        p--;q--;
        for (int j = 0;j < n-1;++j) if (G[p][q] == G[p][edges[j].first]+G[edges[j].first][q] && G[p][q] == G[p][edges[j].second]+G[edges[j].second][q]) s[i] |= (1LL<<j);
    }
    ll ans = 0;
    for (int i = 0;i < (1<<m);++i) {
        ll mask = 0;
        bool p = true;
        for (int j = 0;j < m;++j) if ((i>>j)&1) mask |= s[j],p = !p;
        int cnt = 0;
        for (int j = 0;j < n-1;++j) if ((mask>>j)&1) cnt++;
        ans += (1LL<<(n-1-cnt))*(p ? 1 : -1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Contest156_B.cpp
 *
 *  Created on: 2020/02/22
 *      Author: black
 */


#include <iostream>

using namespace std;

int main(){
	int n, k;

	cin >> n >> k;
	int count = 0;
	while(1){
		if (n < k){
			count++;
			break;
		}
		n = n/k;
		count++;
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
cnt = 0
for a in C:
    if C[a]<a:
        cnt += C[a]
    else:
        cnt += C[a]-a
print(cnt)

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

int main()
{
	int a,b,i;
	cin >> a >> b;
	if( a > b )
	{
		i = a;
		a = a - 1;
	}else{
		i = b;
		b = b - 1;
	}

	if( a > b )
	{
		i = i + a;
	}else{
		i = i + b;
	}

	cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define pb push_back
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
template<class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<class T>inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

bool is_parindrome(string s)
{
	string t = s;
	reverse(ALL(t));
	if (t == s)return true;
	else return false;
}

int main()
{
	string s; cin >> s;
	string s_x = s;
	ERASE(s_x, 'x');

	if (!is_parindrome(s_x))
	{
		co(-1);
		return 0;
	}
	else
	{
		s += "y";
		int n = s.size();
		vector<int>a;
		int tmp = 0;
		rep(i, n)
		{
			if (s[i]=='x')tmp++;
			else 
			{
				a.push_back(tmp);
				tmp = 0;
			}
		}
		int m = SZ(a);
		int ans = 0;
		for (int i = 0; i <= m-1-i; i++)
		{
			ans += abs(a[i] - a[m - 1 - i]);
		}
		co(ans);
	}
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 1000010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 100000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int cnt[110];
int pr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int main()
{
	//freopen("input.txt","r",stdin);
   	//freopen("output.txt","w",stdout);
   	int n;
 	cin >> n;
 	int ans = 0;
 	int siz = 25;
 	for(int i = 2; i <= n; i++)
 	{
 		int cpy = i;
 		for(int j = 0; j < 25; j++)
 		{
 			if(cpy % pr[j] == 0)
 			{
 				int ctr = 0;
 				while(cpy % pr[j] == 0)
 				{
 					ctr++;
 					cpy/=pr[j];
 				}
 				cnt[pr[j]] += ctr;
 			}
 		}
 	}
 	for(int i = 0; i < 25; i++)
 		if(cnt[pr[i]] >= 74)
 			++ans;
 	for(int i = 0; i < 25; i++)
 	{
 		for(int j = 0; j < 25; j++)
 		{
 			for(int k = 0 ; k <25; k++)
 			{
 				if(i !=j && j != k && i != k && k > j)
 				{
 					if(cnt[pr[i]] >= 2 && cnt[pr[j]] >= 4 && cnt[pr[k]] >= 4)
 						++ans;
 				}
 			}
 		}
 	}
 	for(int i = 0; i < 25 ; i++)
 	{
 		for(int j = 0; j < 25; j++)
 		{
 			if(i != j && cnt[pr[i]] >= 14 && cnt[pr[j]] >= 4)
 				++ans;
 			if(i != j && cnt[pr[i]] >= 24 && cnt[pr[j]] >= 2)
 				++ans;
 		}
 	}
 	cout << ans << '\n';
	return 0;
}


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

int main()
{
  int a, b, c, d, e, f, g, h, i;
  cin >> a >> b >> c
      >> d >> e >> f
      >> g >> h >> i;

  int n;
  cin >> n;

  vector<bool> bn(101);
  for (int j = 0; j < n; j++) {
    int t;
    cin >> t;
    bn[t] = true;
  }

  bool bingo =
    (bn[a] && bn[b] && bn[c]) || (bn[d] && bn[e] && bn[f]) || (bn[g] && bn[h] && bn[i]) ||
    (bn[a] && bn[d] && bn[g]) || (bn[b] && bn[e] && bn[h]) || (bn[c] && bn[f] && bn[i]) ||
    (bn[a] && bn[e] && bn[i]) || (bn[c] && bn[e] && bn[g]);

  cout << (bingo ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string a;
	cin >> a;
	int ma =0;
	int count =0;
	for (int i=0;i<a.size();i++) {
		if (a[i] != 'A' && a[i] != 'T' &&a[i] != 'G' && a[i] != 'C') {
			count =0;
			continue;
		}
		count++;
		ma = max(ma,count);
	}
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  char *S, *T;

  S = malloc(sizeof(char) * 200001);
  T = malloc(sizeof(char) * 200001);

  scanf("%s", S);
  scanf("%s", T);

  unsigned long count = 0;
  size_t i = 0;
  while (S[i] != '\0') {
    if (S[i] != T[i]) {
      count++;
    }
    i++;
  }

  printf("%lu\n", count);

  return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int x,h;
  while(1){
    cin>>x;
    cin>>h;
    if(x==0 && h==0)break;
    double sum=x*x;
    double len=sqrt(h*h+sum/4);
    sum+=len*x*2;
    printf("%f\n",sum);
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[11000];
int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  ll cnt=0;
  while(n>0){
    n/=k;
    cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
def cin(): # To take limited number of inputs
	return map(int,input().split())

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # to print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino(True)
    a = list(a)
    a = a[len(a)-1]
    if a=='2' or a=='4' or a=='5' or a=='7' or a=='9':
        print("hon")
    elif a=='0' or a=='1' or a=='6' or a=='8':
        print("pon")
    else:
        print("bon")
   

if __name__=="__main__":
    main()

Measured memory_bytes: 9156
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> a(X);
	for (int i = 0;i < X;i++)
		cin >> a[i];
	vector<ll> b(Y);
	for (int i = 0;i < Y;i++)
		cin >> b[i];
	vector<ll> c(Z);
	for (int i = 0;i < Z;i++)
		cin >> c[i];
	vector<ll> bc;
	for (int i = 0;i < Y;i++)
		for (int j = 0;j < Z;j++)
			bc.push_back(b[i] + c[j]);
	sort(bc.begin(), bc.end(), greater<ll>());
	priority_queue<T> que;
	for (int i = 0;i < X;i++)
		que.push(T(a[i] + bc[0], i, 0));
	vector<ll> ans;
	for (int i = 0;i < K;i++) {
		ll now, n, m;
		tie(now, n, m) = que.top();
		que.pop();
		ans.push_back(now);
		if (m + 1 < Y*Z)
			que.push(T(a[n] + bc[m + 1], n, m + 1));
	}
	for (int i = 0;i < K;i++)
		cout << ans[i] << endl;
	return 0;
}


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

using namespace std;

typedef struct edge
{
    int to,cost;
    edge(int t,int c)
    {
        to=t;cost=c;
    }
}edge;

const int N=1e5+10;
vector<edge> G[N];

void add(int s,int t,int c)
{
    G[s].push_back(edge(t,c));
    G[t].push_back(edge(s,c));
}

int Max,d[N];
void dfs(int v,int p=-1)
{
    if(p==-1)
    {
        d[v]=0;Max=v;
    }
    for(int i=0;i<G[v].size();i++)
    {
        edge e=G[v][i];
        if(e.to!=p)
        {
            d[e.to]=d[v]+e.cost;
            if(d[e.to]>d[Max])
            {
                Max=e.to;
            }
            dfs(e.to,v);
        }
    }
}

void solve(int v)
{
    memset(d,0,sizeof(d));
    dfs(v);
}

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

    for(int i=1;i<n;i++)
    {
        int s,t,c;
        cin>>s>>t>>c;
        add(s,t,c);
    }

    solve(0);
    solve(Max);
    cout<<d[Max]<<endl;

    return 0;
}



Measured memory_bytes: 13544
#include<bits/stdc++.h>
using namespace std;
void solve(int a,int b,int m,int v[])
{
    int n = __builtin_popcount(m);
    if (n == 1) {
        v[0] = a;
        v[1] = b;
        return;
    }
    int x = __lg(a ^ b);
    bool f = a>>x&1;
    a ^= f << x;
    b ^= (!f) << x;
    m ^= 1 << x;
    int c = a ^ (m & -m);
    solve(a,c,m,v);
    solve(c,b,m,v+(1<<(n-1)));
    for (int i = 0; i < (1<<(n-1)); ++i)
        v[i] ^= f<<x;
    for (int i = (1<<(n-1)); i < (1<<n); ++i)
        v[i] ^= (!f)<<x;
}
int main()
{
    int n,a,b,v[1<<17];
    cin >> n >> a >> b;
    if (__builtin_popcount(a^b)&1) {
        solve(a,b,(1<<n)-1,v);
        cout << "YES\n";
        for (int i = 0; i < (1<<n); ++i)
            cout << v[i] << " \n"[i+1==(1<<n)];
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	ll k;
    	cin>>k;
    	ll x=100;
    	ll count=0;
    	while(x<k)
    	{
    		x+=(x/100);
    		count++;
    	}
    	cout<<count<<endl;
    	
    	
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int N, T[100], M, P[100], X[100];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += T[i];
  }
  for (int i = 0; i < M; i++) {
    cout << sum - T[P[i] - 1] + X[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(){
    ll n;
    cin>>n;
    ll a[n],i;
    ll d[200002],e[200002];
    fill_n(d,200002,0);
    fill_n(e,200002,0);
    for(i=0;i<n;i++){
        cin>>a[i];
        d[a[i]]++;
    }
    ll s=0;
    for(i=0;i<n;i++){
        if(!e[a[i]]){
            ll r=d[a[i]];
            e[a[i]]=(r*(r-1)/2);
            s+=e[a[i]];
        }
    }
    for(i=0;i<n;i++){
        ll o=s-e[a[i]];
        ll r=d[a[i]]-1;
        o+=(r*(r-1)/2);
        cout<<o<<endl;
    }
    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
	char S[200],T[200];bool flag=false;
	scanf("%s%s",S,T);
	int l=strlen(S);
	if(l!=strlen(T)){
		printf("No\n");
		return 0;
	}
	for(int i=0;i<l;i++){
		if(S[i]==T[0]){
			int j=(i+1)%l;
			int k=1;
			while(j!=i&&S[j]==T[k]){
				j=(j+1)%l;
				k=(k+1)%l;
			}
			if(j==i){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[10];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    if(a[0]==a[1]&&a[1]!=a[2]||a[1]==a[2]&&a[1]!=a[0])
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(li[1] - li[0])
for i in range(2,n):
    dp[i] = min(abs(dp[i-1] + abs(li[i] - li[i-1])), dp[i-2] + abs(li[i] - li[i-2]))
print(dp[-1])

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

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

    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == ',')
        {
            s[i] = ' ';
        }
        
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret


import math

def get_primenumber(number):#エラトステネスの篩
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list

p=get_primenumber(79000)

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if amin!=1:
    bp=enum_div(amin)+[amin]
    bp=bp[1:]
    for bpi in bp:
        yn=""
        for ai in ap:
            if ai%bpi!=0:
                yn="coprime"
                break
        if yn=="":
            print("not coprime")
            sys.exit()

if n>=78500 :
    print("setwise coprime")
    sys.exit()

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1
    
for pp in range(2,amax+1):
#for pp in p:
    psum=0
    for pi in range(pp,amax+1,pp):
#    for pi in range(pp,amax+pp-1,pp):
        psum+=aa[pi]
#    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


Measured memory_bytes: 201532
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22)cout<<"bust"<<endl;
  else cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 3636
// -*- coding:utf-8; tab-width:4 -*-
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

// ティツァツ」テァツュツ?
namespace solution {
    using namespace std;
   
    typedef istringstream ISS;
    typedef ostringstream OSS;
    typedef vector<string> VS;
    typedef long long LL;
    typedef int INT;
    typedef vector<INT> VI;
    typedef vector<VI> VVI;
    typedef pair<INT, INT> II;

    const int SIZE = 10001;
    int n, m;
    int A[SIZE], B[SIZE];

    struct Solution {
        void init() {
        }
   
        bool input() {
            if ( ! ( cin >> n >> m ) )
                return false;
            for ( int i = 0; i < n; ++ i )
                cin >> A[i] >> B[i];
            return true;
        }

        int solve() {
            int res = 0;
            int s = m;
            res = max( res, s );
            for ( int i = 0; i < n; ++ i ) {
                s += A[i] - B[i];
                res = max( res, s );
                if ( s < 0 )
                    return 0;
            }
            return res;
        }

        void output( int result ) {
            cout << result << endl;
        }
      
        int run() {
            while ( init(), input() ) {
                output(solve());
            }
            return 0;
        }
    };
}

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 1236
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: Java8 (OpenJDK 1.8.0)
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n;
		Scanner sc = new Scanner(System.in);
      
		n = sc.nextInt();
		out.printf("%.8f",(double)(n - n / 2) / (double)n);
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll k, a, b;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(k);
	qread(a);
	qread(b);
	if(b / k * k >= a){
		puts("OK");
	} else {
		puts("NG");
	}
	return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int x, t;
   cin >> x >> t;

   cout << max(x - t, 0) << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
vi dist;
vector<vii> AdjList;
const int inf=1e18+7;
void dijkstra(int s) {
    dist[s]=0;
    priority_queue<ii,vii,greater<ii>> pq;
    pq.push(ii(0,s));
    while (!pq.empty()) {
    ii front=pq.top();
	pq.pop();
    int d=front.first;
	int u=front.second;
    if(d==dist[u]) {
        for(int j=0 ; j<(int)AdjList[u].size() ; j++) {
            ii v=AdjList[u][j];
            if(dist[u]+v.second<dist[v.first]) {
                dist[v.first]=dist[u]+v.second;
                pq.push(ii(dist[v.first],v.first));
                }
            }
        }
    }
}
signed main() {
	int n,m;
	cin>>n>>m;
	AdjList.assign(n,vii());
	dist.assign(n,inf);
	for(int i=1 ; i<n ; i++) {
		AdjList[i].push_back(ii(i-1,0));
	}
	for(int i=0 ; i<m ; i++) {
		int u,v,w;
		cin>>u>>v>>w;
		u--; v--;
		AdjList[u].push_back(ii(v,w));
	}
	dijkstra(0);
	if(dist[n-1]==inf) cout<<-1;
	else cout<<dist[n-1];
}

Measured memory_bytes: 10104