akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, 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 1; } return 0; }

ll digit_sum(ll x){
    ll ret = 0;
    while (x > 9){
        ret += x%10;
        x /= 10;
    }
    ret += x%10;
    return ret;
}

int main() {
    ll N;
    ll A, B;
    cin >> N;
    cin >> A >> B;
    ll cnt = 0;

    for (ll i=1; i<=N; i++){
        if (digit_sum(i) >= A and digit_sum(i) <= B){
            cnt+= i;
            //cout << i << endl;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
struct aa {
	int now;
	long long int time;
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};

int main() {
	long long int N, M, K, S; cin >> N >> M >> K >> S;
	vector<vector<int>>edges(N);
	vector<long long int>prices(N);
	{
		long long int P, Q; cin >> P >> Q;
		queue<pair<int, int>>que;
		vector<int>diss(N, 1e9);
		for (int i = 0; i < K; ++i) {
			int c; cin >> c; c--; diss[c] = 0;
			que.emplace(c, 0);
		}
		for (int i = 0; i < M; ++i) {
			int a, b; cin >> a >> b; a--; b--;
			edges[a].push_back(b);
			edges[b].push_back(a);
		}

		while (!que.empty()) {
			auto p(que.front());
			que.pop();
			int ndis = p.second;
			int now = p.first;
			for (auto e : edges[now]) {
				if (ndis + 1 < diss[e]) {
					diss[e] = ndis + 1;
					que.emplace(e, ndis + 1);
				}
			}
		}
		for (int i = 0; i < N; ++i) {
			if (diss[i] == 0)prices[i] = 1e12;
			else if (diss[i] <= S)prices[i] = Q;
			else prices[i] = P;
		}
	}
	vector<long long int>costs(N,1e18);
	costs[0] = 0;
	priority_queue<aa, vector<aa>, Compare>que;
	que.push(aa{ 0,0 });
	while (!que.empty()) {
		auto p(que.top());
		que.pop();
		for (auto e : edges[p.now]) {
			if (costs[e] > p.time + prices[e]) {
				costs[e] = p.time + prices[e];
				que.push(aa{ e,p.time + prices[e] });
			}
		}
	}
	cout << costs[N - 1]-prices[N-1] << endl;
	return 0;
}

Measured memory_bytes: 10996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	double PI = acos(-1);
	int a, b, x;
	cin >> a >> b >> x;
	double h = (double)x / a / a;
	if (b < 2 * h) {
		double lim = b - h;
		cout << setprecision(64) << atan2(2 * lim, a) * 180 / PI << endl;
	}
	else {
		double wlim = 2.0 * h * a / b;
		cout << setprecision(64) << atan2(b, wlim) * 180 / PI << endl;
	}
}

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

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

  bool flag = false;

  for (int i = 0; i < 3; i++) {
    if (S[i] == S[i + 1]) {
      flag = true;
    }
  }

  if (flag) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int n, height[100001];
ll cost[100001];

ll findCost(int n){
	if(cost[n] != -1)
		return cost[n];
	ll a = findCost(n - 1) + abs(height[n] - height[n - 1]);
	ll b = findCost(n - 2) + abs(height[n] - height[n - 2]);
	return cost[n] = min(a, b);
}

ll solve(){
	mem(cost, -1);
	cost[1] = 0;
	cost[2] = abs(height[2] - height[1]);
	return findCost(n);
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> height[i];
	}

	cout << solve();
	return 0;
}

Measured memory_bytes: 9420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int X = ni();
        int T = ni();
 
        long ans = ((N+X-1)/X)*T;
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

using namespace std;

int main(){
    int n;
    cin>>n;vector<int> myres(26,0);
    string s;
    cin>>s;
    for(int j=0;j<s.length();j++)
        {
            myres[s[j]-'a']++;
        }
    for(int i=1;i<n;i++)
    {
        //string s;
        cin>>s;vector<int> myvec(26,0);
        for(int j=0;j<s.length();j++)
        {
            myvec[s[j]-'a']++;
        }
        for(int k=0;k<26;k++)
        if(myvec[k]<myres[k]) myres[k]=myvec[k];
    
    }
  //  for(int i=0;i<26;i++)
//    cout<<myres[i]<<endl;
    for(int a=0;a<26;a++)
    for(int p=0;p<myres[a];p++)
    cout<<char('a'+a);
    cout<<endl;
    
}


Measured memory_bytes: 256
s=input().rstrip()
for i in range(len(s)):
  if 1 <= i and (s[i-1] == s[i]):
    print(i,i+1)
    exit()
  if 2 <= i and (s[i-2] == s[i]):
    print(i-1,i+1)
    exit()
print(-1,-1)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		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 count4 = 0;
      	int count2 = 0;
      	int count1 = 0;
      	
      	for(int i=0; i<n; i++){
            if(a[i]%4==0) count4++;
            else if(a[i]%2==0) count2++;
            else count1++;
        }
      	
      	if(count1>count4+1 ){
      	    System.out.println("No");
      	    return;
      	    
      	}else if(count1==count4+1 && count2>0){
      	    System.out.println("No");
      	    return;
      	    
      	}
      	System.out.println("Yes");
      	
	}
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class APayment {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        if (n%1000)
        cout<<1000-(n%1000);
        else cout<<0;
	}
};


int main() {
	APayment solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int h, w, c;

int dfs(int cnt, vvi ce) {
	cnt++;
	queue<pair<int, int>> now;
	now.push(pair<int, int>(0, 0));
	set<pair<int, int>> visited;
	visited.insert(pair<int, int>(0, 0));
	int count=1;
	while (!now.empty()) {
		pair<int, int> q = now.front();now.pop();
		REP(i, 4) {
			if (0 <= q.first + dy[i] && q.first + dy[i] < h && 0 <= q.second + dx[i] && q.second + dx[i] < w) {
				if (visited.find(pair<int, int>(q.first + dy[i], q.second + dx[i])) == visited.end() &&
					ce[q.first + dy[i]][q.second + dx[i]]== ce[q.first][q.second]) {
					count++;
					now.push(pair<int, int>(q.first + dy[i], q.second + dx[i]));
					visited.insert(pair<int, int>(q.first + dy[i], q.second + dx[i]));
				}
			}
		}
	}
	
	if (cnt == 6)
		return count;
	if (cnt == 5) {
		vvi ce2 = ce;
		REP(i, h)
			REP(j, w)
			if (visited.find(pair<int, int>(i, j)) != visited.end())
				ce2[i][j] = c;
		return dfs(cnt,ce2);
	}
	int ma = 0;
	REP(k, 6) {
		vvi ce2 = ce;
			REP(i, h)
				REP(j, w)
				if (visited.find(pair<int, int>(i, j)) != visited.end())
					ce2[i][j] = (k + 1);
			ma = max(ma, dfs(cnt, ce2));
	}
	return ma;
}

int main() {
	while (cin >> h >> w >> c, h) {
		vvi cell(h, vi(w));
		REP(i, h)
			REP(j, w)
			cin >> cell[i][j];
		cout << dfs(0, cell) << endl;
	}
}

Measured memory_bytes: 3096
<?php
/**
 * ABC122
 * A - Double Helix
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

$b = trim(fgets(STDIN));
switch ($b) {
    case 'A':
        $result = 'T';
        break;
    case 'T':
        $result = 'A';
        break;
    case 'G':
        $result = 'C';
        break;
    case 'C':
        $result = 'G';
        break;
}

echo $result, PHP_EOL;


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x;
    cin>>x;
    ll ans;
    ans=(x/500)*1000;

    ll v=0,c;
    c=(x/500)*500;

    v=max(v,x-c);
    ans+=(v/5)*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<LL> a(n);
    REP(i,n) {
        cin >> a[i];
        a[i]-=i+1;
    }
    sort(ALL(a));
    LL b;
    if ( n%2 ) b=a[n/2];
    else b=(a[n/2-1]+a[n/2])/2;
    LL ans=0;
    for (int i=0; i<n; i++) {
        ans+=abs(a[i]-b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A;
  string B;
  cin>>A>>B;
  if(A>=3200)
    cout<<B<<endl;
  else
    cout<<"red"<<endl;

}


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

typedef long long ll;

const ll MAX = 1000010;
const ll MOD = 1000000007;
ll fac[MAX + 1], facinv[MAX + 1];
// fac[i] = i!;
// facinv[i] = (i!)^-1 (mod MOD)

ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  // ll d = extgcd(b, a % b, x, y);
  // ll temp = x;
  // x = y;
  // y = temp - (a / b) * x;
  ll d = extgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}

ll modinv(ll a, ll m) {
  // Need: gcd(a, m) = 1;
  // a^-1(mod. m)は
  // ax+my=gcd(a, m)=1;
  // を満たすxである。(それはそう,両辺をmodを法としてmodを考えてみよう)
  ll x, y;
  extgcd(a, m, x, y);
  return (x % m + m) % m;
}

void COMInit() {
  // O(MAX log MOD)
  fac[0] = 1;
  for (int i = 1; i <= MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  facinv[MAX] = modinv(fac[MAX], MOD);
  for (int i = MAX - 1; i >= 0; i--) {
    facinv[i] = facinv[i + 1] * (i + 1) % MOD;
  }
}

ll comb(ll n, ll r) {
  //           n!
  // nCr = -----------
  //        r!*(n-r)!
  return (fac[n] * facinv[r]) % MOD * facinv[n - r] % MOD;
}

int main() {
  COMInit();
  ll x, y;
  cin >> x >> y;
  if ((2 * x - y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (2 * y - x) / 3;
  if (a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  a %= MOD;
  b %= MOD;
  cout << comb((a + b) % MOD, a) << endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char ch;
    int i,x,m,n,l;
    int card[4][13]={};
    cin >>n;
    for(i = 0; i < n ; i++){
        cin >> ch >> x;
        if(ch=='S') card[0][x-1]=1;
        else if(ch=='H') card[1][x-1]=1;
        else if(ch=='C') card[2][x-1]=1;
        else if(ch=='D') card[3][x-1]=1;
    }
    for(m=0; m<4; m++){
        for(l=0; l<13; l++){
            if(card[m][l]==0){
                if(m==0)printf("S %d\n",l+1);
                else if(m==1)printf("H %d\n",l+1);
                else if(m==2)printf("C %d\n",l+1);
                else if(m==3)printf("D %d\n",l+1);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        string str[4];
        int num[4]={1000000,1000000,0,0};
        for(int i=0,sum;i<n;i++){
            string st;
            cin>>st;
            sum=0;
            for(int j=0,minute,second;j<4;j++){
                cin>>minute>>second;
                sum+=60*minute+second;
            }
            if(sum<num[1]){
                num[1]=sum;
                str[1]=st;
                if(num[1]<num[0]){
                    swap(num[0],num[1]);
                    swap(str[0],str[1]);
                }
            }
            if(sum>num[2]){
                num[2]=sum;
                str[2]=st;
                if(num[2]>num[3]){
                    swap(num[2],num[3]);
                    swap(str[2],str[3]);
                }
            }
        }
        for(int i=0;i<3;i++)cout<<str[i]<<endl;
    }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef vector<ll>vi;
typedef pair<ll,ll>pi;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
ll max(ll a,ll b){return (a>b?a:b);}
ll min(ll a,ll b){return (a<b?a:b);}
ll gcd(ll a,ll b)
{return (b?gcd(b,a%b):a);
}
void algo()
{
    ll n,k;
    cin>>n>>k;
    vi v(n+1);
    for(ll i=1;i<=n;i++)
    {
         cin>>v[i];
    }
    vector<ll>ans;
    ans.pb(v[1]);
    ll j=v[1];
    set<ll>s;
    s.insert(j);
    ll cnt=1;
    if(cnt==k)
    {
        cout<<ans[0];
        return;
    }
    while(s.find(v[j])==s.end())
    {
      //  cout<<j<<" ";
        cnt++;
        ans.pb(v[j]);
        s.insert(v[j]);
        if(cnt==k)
        {
            cout<<v[j];
            return;
        }
        j=v[j];
    }
    ll a=v[j];
    vi d;
    ll flg=0;
    cnt=0;
    for(auto it:ans)
    {
        if(flg==1)
        {
            d.pb(it);
        }
        if(flg==0)
            cnt++;
        if(it==a)
        {
         flg=1;
         d.pb(it);
        }
    }
    //for(auto it:d)
      //  cout<<it<<" ";
    k-=cnt;
    cout<<d[k%d.size()];

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(20);
    ll t=1;//cin>>t;
    while(t--)
    {
        algo();
	cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 15152
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc050_b.cpp
 * time   : Sat May  2 22:02:56 2020
 * quest  : B - Contest with Drinks Easy
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, arr_sum = 0;
  cin >> n;
  int * store = new int[n];
  for (int i = 0; i < n; ++i) {
    cin >> store[i];
    arr_sum += store[i];
  }
  cin >> m;
  int ** drinks = new int*[m];
  for (int i = 0; i < m; ++i) {
    drinks[i] = new int[2];
    cin >> drinks[i][0] >> drinks[i][1];
  }
  for (int i = 0; i < m; ++i) {
    cout << arr_sum - store[drinks[i][0] - 1] + drinks[i][1] << "\n";
  }
  return 0;
}


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

int main() {
	int a;
	while (cin >> a,a) {
		multimap<int, int>b;
		for (int c = 0; c < a; c++) {
			int d, e;
			cin >> d >> e;
			b.insert(pair<int, int>(e,d));
		}
		int s = 0;
		while (b.size()) {
			auto f = b.begin();
			s += (*f).second;
			if ((*f).first < s)break;
			b.erase(b.begin());
		}
		cout << ((b.size()) ? ("No") : ("Yes")) << endl;
	}
}

Measured memory_bytes: 3020
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

const MODULO: usize = 1_000_000_007;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    if n == 1 {
        println!("1");
        return;
    }
    let mut r = 0;
    while r * r <= n {
        r += 1;
    }
    r -= 1;
    let mut c: Vec<usize> = vec![1; 2 * r + 1];
    for i in 1..r {
        c[2 * r + 1 - i] = n / i - n / (i + 1);
    }
    c[r + 1] = n / r - r;
    let mut dp: Vec<Vec<usize>> = vec![vec![1; 2 * r + 1]; 2];
    for i in 2..k + 1 {
        dp[i & 1][2 * r] = dp[(i - 1) & 1][1] * c[1] % MODULO;
        for j in 2..2 * r + 1 {
            dp[i & 1][2 * r + 1 - j] =
                (dp[i & 1][2 * r + 1 - j + 1] + dp[(i - 1) & 1][j] * c[j]) % MODULO;
        }
    }
    let mut ans: usize = 0;
    for i in 1..2 * r + 1 {
        ans = (ans + dp[k & 1][i] * c[i]) % MODULO;
    }
    println!("{}", ans);
}


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

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  ll ax = a / x;
  ll bx = b / x;
  ll ans = bx - ax;
  if (a % x == 0)
    ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
v=[int(i) for i in input().split()]
ans=0
for i in range(1, len(v)-1):
    if (v[i]>v[i-1] and v[i]<v[i+1]) or (v[i]<v[i-1] and v[i]>v[i+1]):
        ans+=1
print(ans)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*p = map(int, read().split())


s = input()

L = len(s)
ans = 0
from itertools import product
for a in product(["+",""],repeat=L-1):
    t = s[0]
    for si,i in zip(s[1:],a):
        t += i + si
        
    #print(t)
    ans += eval(t)

print(ans)



Measured memory_bytes: 9076
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
A = []  # A[i] = A_iが2,5で各々何回割り切れるか
for _ in range(N):
    a = LS2()
    if not '.' in a:
        a = int(''.join(a))
        b,c = 0,0
        while a % 2 == 0:
            a //= 2
            b += 1
        while a % 5 == 0:
            a //= 5
            c += 1
        A.append((b,c))
    else:
        i = a.index('.')
        l = len(a)
        del a[i]
        a += ['0']*(9-l+1+i)
        a = int(''.join(a))  # 与えられた実数を10**9倍したもの
        b,c = 0,0
        while a % 2 == 0:
            a //= 2
            b += 1
        while a % 5 == 0:
            a //= 5
            c += 1
        A.append((b-9,c-9))

from collections import defaultdict
d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1

ans = 0
for a in d.keys():
    b,c = a
    x = 0
    for e in d.keys():
        f,g = e
        if f >= -b and g >= -c:  # 積が整数
            x += d[e]
    ans += d[a]*x

# 自分自身どうしの積が整数となるものを取り除く

for a in d.keys():
    b,c = a
    if b >= 0 and c >= 0:
        ans -= d[a]

print(ans//2)


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    string s; cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy\n";
    }else if(s == "Cloudy"){
        cout << "Rainy\n";
    }else{
        cout << "Sunny\n";
    }
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define dbprint(s) {cout<<"db:"<<s<<endl;}
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){

  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N+10,0);
  for (int i = 1; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 1; i < N; i++) {
    B[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << B[i] << endl;
  }
  

  return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define ll long long
using namespace std;

// int i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    int r;
    double ans=0;
    cin>>r;
    ans=r*6.28;

    
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 3800
a, b = map(int,input().split())

def gcd(x, y):
    ma = max(x, y)
    mi = min(x, y)
    while 0 != ma % mi:
        tmp = ma % mi
        ma, mi = mi, tmp
    return mi

def lcm(x, y):
    return int((x * y) / gcd(x, y))

print(lcm(a,b))

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

int main(){
	long long a;
	string s;
	cin>>a>>s;
	if(a%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0,j=s.size()/2;j<s.size();j++,i++){
		if(s[i]!=s[j]||i==j){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

string S;
int s[100001];
int n;
int color[] = {0, 1};
int result = 0;

int main() {
    cin >> S;
    n = S.length();
    REP (i, n) {
        if (color[i%2] == int(S[i] - '0')) {
            result++;
        }
    }
    cout << min(result, n - result) << endl;
}

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

string to_string(__int128_t a) {
    if (a == 0) return "0";
    if (a < 0) return "-"s + to_string(-a);
    string ret = "";
    while (a) {
        ret += '0' + a % 10;
        a /= 10;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

struct Rational {
    using Long = __int128_t;
    Long a, b;
    Rational() : a(0), b(1) {}
    Rational(Long a) : a(a), b(1) {}
    Rational(Long a, Long b) : a(a), b(b) { normalize(); }
    explicit operator double() const {
        return (double) a / b;
    }
    void normalize() {
        Long g = __gcd(a, b);
        a /= g, b /= g;
        if (b < 0) {
            a = -a, b = -b;
        }
    }
    Rational& operator+=(const Rational& rhs) {
        Long d = b * rhs.b;
        a = a * rhs.b + b * rhs.a;
        b = d;
        normalize();
        return *this;
    }
    Rational& operator-=(const Rational& rhs) {
        Long d = b * rhs.b;
        a = a * rhs.b - b * rhs.a;
        b = d;
        normalize();
        return *this;
    }
    Rational& operator*=(const Rational& rhs) {
        a *= rhs.a;
        b *= rhs.b;
        normalize();
        return *this;
    }
    Rational& operator/=(const Rational& rhs) {
        a *= rhs.b;
        b *= rhs.a;
        normalize();
        return *this;
    }
    Rational operator-() const {
        return Rational(-a, b);
    }
    Rational operator+(const Rational& rhs) const {
        return Rational(*this) += rhs;
    }
    Rational operator-(const Rational& rhs) const {
        return Rational(*this) -= rhs;
    }
    Rational operator*(const Rational& rhs) const {
        return Rational(*this) *= rhs;
    }
    Rational operator/(const Rational& rhs) const {
        return Rational(*this) /= rhs;
    }
    bool operator<(const Rational& rhs) const {
        return a * rhs.b < b * rhs.a;
    }
    bool operator>(const Rational& rhs) const {
        return rhs < *this;
    }
    bool operator<=(const Rational& rhs) const {
        return !(rhs < *this);
    }
    bool operator>=(const Rational& rhs) const {
        return !(*this > rhs);
    }
    bool operator==(const Rational& rhs) const {
        return !(*this < rhs) && !(rhs < *this);
    }
    bool operator!=(const Rational& rhs) const {
        return *this < rhs || rhs < *this;
    }
    friend ostream& operator<<(ostream& s, const Rational& f) {
        if (f.b == 1) {
            s << to_string(f.a);
        } else {
            s << to_string(f.a) << '/' << to_string(f.b);
        }
        return s;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    Rational ave = 0;
    for (int i = 0; i < n; i++) {
        ave += as[i];
    }
    ave /= n;
    vector<pair<Rational, int>> dif;
    for (int i = 0; i < n; i++) {
        Rational d = ave - as[i];
        dif.emplace_back(d < 0 ? -d : d, i);
    }
    sort(dif.begin(), dif.end());
    cout << dif.front().second << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(b: str):
    if(b == 'A'):
        print('T')
    elif(b == 'C'):
        print('G')
    elif(b == 'G'):
        print('C')
    elif(b == 'T'):
        print('A')
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    b = next(tokens)  # type: str
    solve(b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A <= C && C <= A+B) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
arr = list(input().split())
stack = []

for i in arr:
    if i == "+":
        stack.append(stack.pop()+stack.pop())
    elif i == "-":
        stack.append(-(stack.pop()-stack.pop()))
    elif i =="*":
        stack.append(stack.pop()*stack.pop())
    else:
        stack.append(int(i))
print(stack[-1])




Measured memory_bytes: 5600
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, m, x, y, cl[100007], dp[100007], ans;
vector<int> g[100007];

li dfs(int v) {
    if(dp[v]) return(dp[v]);
    cl[v]=1;
    dp[v]=0;
    for(int i : g[v]) {
        dp[v] = max(dp[v], dfs(i)+1);
    }
    return(dp[v]);
}

int main () {
    fastIO;
    cin >> n >> m;
    for(li i = 0; i < m; i ++) {
        cin >> x >> y;
        g[x].push_back(y);
    }
    ans = 0;
    for(li i = 1; i <= n; i ++){
        if(!cl[i]) ans = max(ans, dfs(i));
    }
    cout << ans;
}


Measured memory_bytes: 8576
using System;
using System.Linq;

namespace _3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = 0; int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int a = x[0]; a <= x[1]; a++)
            { int q = x[2];
                
                if (q % a == 0)
                {
                    w++;
                }
                else
                {
                   
                }
            }
            Console.WriteLine(w);
        }
    }
}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int sum = 0;
    rep(i,n) sum += p[i];
    int count = 0;
    rep(i,n) if(p[i]*4*m >= sum) count++;
    if(count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=4005;
char ch1[MAXN],ch2[MAXN];
int ri[MAXN],lf[MAXN];
int fx[MAXN],fy[MAXN],ln1,ln2;
bool cmp1(int n1,int n2){return lf[n1]<lf[n2];}
bool cmp2(int n1,int n2){return ri[n1]<ri[n2];}
int main()
{
	scanf("%s",ch1+1);scanf("%s",ch2+1);
	int len=strlen(ch1+1);int cnt=0;
	for(int i=1;i<=len;i++)cnt+=ch2[i]-'0';
	if(!cnt)
	{
		for(int i=1;i<=len;i++)if(ch1[i]-'0')return pr2(-1),0;
		return pr2(0),0;
	}
	for(int i=1;i<=len;i++)
	{
		int j=i,cnt=0;
		while(ch2[j]!='1'){j--;if(j==0)j=len;++cnt;}
		lf[i]=cnt;
		j=i;cnt=0;
		while(ch2[j]!='1'){j++;if(j==len+1)j=1;++cnt;}
		ri[i]=cnt;
	}
	for(int i=len+1;i<=2*len;i++)ch1[i]=ch1[i-len],lf[i]=lf[i-len],ri[i]=ri[i-len];
	int ans=(1<<31-1);
	for(int i=1;i<=len;i++)
	{
		int cnt=0;ln1=0;
		for(int j=1;j<=len;j++)if(ch1[i+j-1]!=ch2[j])
		{
			cnt++;
			if(lf[i+j-1]>i-1)fx[++ln1]=i+j-1;
		}sort(fx+1,fx+1+ln1,cmp1);int r=0;lf[0]=i-1;
		for(int j=ln1;j>=0;j--)
		{
			ans=min(ans,i-1+2*(lf[fx[j]]-(i-1))+cnt+2*r);
			r=max(r,ri[fx[j]]);
		}
		cnt=0;ln1=0;
		for(int j=1;j<=len;j++)if(ch1[i+j-1]!=ch2[j])
		{
			cnt++;
			if(ri[i+j-1]>len-i+1)fx[++ln1]=i+j-1;
		}sort(fx+1,fx+1+ln1,cmp2);int l=0;ri[0]=len-i+1;
		for(int j=ln1;j>=0;j--)
		{
			ans=min(ans,len-i+1+2*(ri[fx[j]]-(len-i+1))+cnt+2*l);
			l=max(l,lf[fx[j]]);
		}
	}pr2(ans);
	return 0;
}
/*
11110111111111101110101111111101111111111111010111000000000000000010111101110111010000000000000000
11110111111111101110101111111101111111111111010111000000000000000000000100000000000000000000000000
*/

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

bool compare_by_year(pair<int, int> i, pair<int, int> j) {
  return i.second < j.second;
}

bool compare_by_si(tuple<int, int, int> i, tuple<int, int, int> j) {
  return get<2>(i) < get<2>(j);
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector <pair<int, int> > > vv(N + 1);
  rep1(i, M) {
    int P, Y;
    cin >> P >> Y;
    vv[P].push_back(make_pair(i, Y));
  }
  rep1(i, N) {
    stable_sort(vv[i].begin(), vv[i].end(), compare_by_year);
  }
  vector<tuple<int, int, int> > ans;
  vector<int> count(N + 1);
  rep1(p, N) {
    int count = 1;
    for (auto it = vv[p].begin(); it != vv[p].end(); it++) {
      int i = (*it).first;
      ans.push_back(make_tuple(p, count, i));
      count++;
    }
  }
  sort(ans.begin(), ans.end(), compare_by_si);
  for (auto it = ans.begin(); it != ans.end(); it++) {
    int p = get<0>(*it), x = get<1>(*it);
    printf("%06d%06d\n", p, x);
  }
  return 0;
}


Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, a, b;
    cin >> n >> a >> b;

    if (a == 0){
        cout << 0 << endl;
        return 0;
    }
    if (b == 0){
        cout << n << endl;
        return 0;
    }
    
    long long x = n % (a+b);
    long long ans = n / (a + b) * a;
    if (x > a) {
        ans += a;
    }else{
        ans += x;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
// 2011/07/05 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int w;
		cin >> w;
		if(w==-1)
			break;

		int bil;
		if(w<=10)
			bil = 1150;
		else if(w<=20)
			bil = 1150+(w-10)*125;
		else if(w<=30)
			bil = 1150+10*125+(w-20)*140;
		else
			bil = 1150+10*125+10*140+(w-30)*160;

		cout << 4280-bil << endl;
	}

	return 0;
}

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

const int maxn = 2e5 + 12;
int n, cnt, p[maxn], fen[maxn];

void add(int idx) {
    for(; idx < maxn; idx += (idx & -idx)) {
	fen[idx]++;
    }
    return;
}

int get(int idx) {
    int ret = 0;
    for (; idx > 0; idx -= (idx & -idx)) {
	ret += fen[idx];
    }
    return ret;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
	if(get(p[i]) == 0) cnt++;
	add(p[i]);
    }
    cout << cnt;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//公約数列挙
void div(ll a, vll &n) {
  n.push_back(1);
  for (ll i = 2; i <= sqrt(a); i++)
    if (a % i == 0) n.push_back(i);
  if (n.at(n.size() - 1) == sqrt(a))
    for (ll i = n.size() - 2; i >= 0; i--)
      n.push_back(a / n.at(i));
  else
    for (ll i = n.size() - 1; i >= 0; i--)
      n.push_back(a / n.at(i));
  return;
}

void comdiv(ll a, ll b, vll &n) {
  if (a > b) swap(a, b);
  vll m(0);
  div(a, m);
  for (ll i = 0; i < m.size(); i++)
    if (b % m.at(i) == 0) n.push_back(m.at(i));
  return;
}

//素数判定．1:素数
ll is_prime(ll n) {
  if (n == 1) return 0;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (ll i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0) return 0;
  return 1;
}

int main() {
  long long a, b;
  cin >> a >> b;
  vector<long long> n(0), check(0);
  comdiv(a, b, n);
  for (long long i = 1; i < n.size(); i++) {
    for (long long j = 0; j < check.size(); j++)
      if (n.at(i) % check.at(j) == 0) continue;
    if (is_prime(n.at(i)) == 1) check.push_back(n.at(i));
  }
  cout << check.size() + 1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int check(int x,int y, vvi ch) {
  int flg = 1;
  REP(i,8) {
    if(ch[x][i]==1) {
      flg=0;
      break;
    }
    if(ch[i][y]==1)  {
      flg=0;
      break;
    }
    if(x+i<8&&y+i<8) {
      if(ch[x+i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y+i<8) {
      if(ch[x-i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x+i<8&&y-i>=0) {
      if(ch[x+i][y-i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y-i>=0) {
      if(ch[x-i][y-i]==1)  {
      flg=0;
      break;
    }
    }
  }
  return flg;
}

int solution(double t,double p) {
  double f=1.0-(1/1.5)*log(2)*p*pow(2,-t/1.5);
  if(f>=0) return 1;
  else if(f<0) return 0; 
}

int main() {
  int n,k;
  cin >> n >> k;
  int ans=k*pow(100,n);
  if(k==100) ans+=pow(100,n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;


int main() {
	int X;
	cin >> X;
	if (400 <= X && X <= 599)cout<<8<<endl;
	else if ( 600<= X && X <=799 )cout << 7 << endl;
	else if (800<= X && X <= 999)cout << 6 << endl;
	else if (1000<= X && X <= 1199)cout << 5 << endl;
	else if (1200<= X && X <= 1399)cout << 4 << endl;
	else if (1400<= X && X <= 1599)cout << 3 << endl;
	else if (1600<= X && X <= 1799)cout << 2 << endl;
	else if (1800<= X && X <= 1999)cout << 1 << endl;

	return 0;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n, k;
    cin >> n >> k;
    vector<int>v(n);
    for (auto &i : v) {
    	cin >> i;
    }
    int dp[n] = {};
    dp[n - 1] = 0;
    for (int i = n - 2 ; i >= 0 ; i--) {
    	int mi = INT_MAX;
    	for (int j = i + 1 ; j <= min(i + k, n - 1) ; j++) {
    		mi = min(mi, dp[j] + abs(v[i] - v[j]));
    	}
    	dp[i] = mi;
    }
    cout << dp[0] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 4024
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>
#include <cmath>
#include <iomanip>
#include <iterator>

using namespace std;

clock_t timeStart, timeFinish;

void timeBegin() {
    timeStart = clock();
}

void timeEnd() {
    timeFinish = clock();
}

void timeDuration() {
    double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC);
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " sec " << endl;
}

class InputReader {
public:
    InputReader() {
        input_file = stdin;
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    InputReader(const char *file_name) {
        input_file = fopen(file_name, "r");
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    inline InputReader &operator >>(int &n) {
        while((buffer[cursor] < '0' || buffer[cursor] > '9') && buffer[cursor] != '-') {
            advance();
        }
        int sign = 1;
        if (buffer[cursor] == '-') {
            sign = -1;
            advance();
        }
        n = 0;
        while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
            n = n * 10 + buffer[cursor] - '0';
            advance();
        }
        n *= sign;
        return *this;
    }
private:
    FILE *input_file;
    static const int SIZE = 1 << 17;
    int cursor;
    char buffer[SIZE];
    inline void advance() {
        ++ cursor;
        if(cursor == SIZE) {
            cursor = 0;
            fread(buffer, SIZE, 1, input_file);
        }
    }
};

const long long INF = 1000000000000000000LL;

map<long long, long long> dp;

long long p[3] = {2, 3, 5};
long long cost[3], d;

long long compute(long long n) {
    if (dp.count(n)) {
        return dp[n];
    }
    if (n == 0) {
        dp[n] = 0;
    } else if (n == 1) {
        dp[n] = d;
    } else {
        long long best = INF;
        if (n <= INF / d)
            best = n * d;
        for (int i = 0; i < 3; i++) {
            long long r1 = n % p[i];
            long long r2 = (p[i] - r1) % p[i];
            best = min(best, min(d * r1 + cost[i] + compute((n - r1) / p[i]), d * r2 + cost[i] + compute((n + r2) / p[i])));
        }
        dp[n] = best;
    }
    return dp[n];
}

int main() {
    timeBegin();
    //ifstream cin("input.in");
    //ofstream cout("ultrapoligon.out");
    int tests;
    cin >> tests;
    for (int test = 1; test <= tests; test++) {
        long long n;
        cin >> n >> cost[0] >> cost[1] >> cost[2] >> d;
        dp.clear();
        cout << compute(n) << "\n";
    }
    timeEnd();
    //timeDuration();
    return 0;
}





Measured memory_bytes: 4448
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K;cin>>K;
  cout << (K/2)*((K+1)/2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n;
ll a[100010];
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	ll ans = 0, tot = 0;
	for (int i = 1; i <= n; i ++) 
	{
		if(2 * tot >= a[i]) ans ++;
		else ans = 1;
		tot += a[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		char a[] = new char[3];
		String str = "";
		int price = 700;

		str = scan.next();

		for (int i=0; i<3; i++) {
			if (str.charAt(i) == 'o') {
				price += 100;
			}
		}

		System.out.println(price);

		scan.close();

	}

}


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

using namespace std;

using ll = long long;

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

    string s;
    for (int i = 0; i < 3; ++i) {
        cin >> s;
        cout << (char)(s.front() - 'a' + 'A');
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256