akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
#define rip(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int r, d, x;
	int ans = 0;
	cin >> r >> d >> x;
	ans = x;
	rep(i, 9) {
		ans = ans * r - d;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine("Case {0}:", i + 1);
            var s = int.Parse(Console.ReadLine().Trim());
            for (int j = 0; j < 10; j++)
            {
                var s2 = (s * s).ToString();
                var s2z = new string('0', 8 - s2.Length) + s2;
                s = int.Parse(s2z.Substring(2, 4));
                Console.WriteLine(s);
            }
        }
    }
}

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

using namespace std;

int main()
{
    int n,m,x,y;
    vector <int> X,Y;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++){int d;cin>>d;X.push_back(d);}
    for(int i=0;i<m;i++){int d;cin>>d;Y.push_back(d);}
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    if(Y[0]>X.back() && x<y && x<Y[0] && y>X.back())cout<<"No War"<<endl;else cout<<"War"<<endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val Array(w, h) = readLine.trim.split(' ').map(_.toInt)
  val n = readLine.trim.toInt
  val order = readLine.trim.split(' ').map(_.toInt == 0)
  var outside = 2 * w + h - 2
  var inside = outside - 4
  var count = 0
  for (isOutside ← order){
    if (isOutside) outside -= 1
    else inside -= 1
    if (isNeighbor(inside, outside)) count += 1
  }
  println(count)
  def isNeighbor(inside:Int, outside: Int): Boolean = {
    if (outside.isOutsideBottom && inside.isInsideBottom) outside.outsideBottomPosition == inside.insideBottomPosition
    else if (outside.isOutsideRight && inside.isInsideRight) outside.outsideRightPosition == inside.insideRightPosition
    else if (outside.isOutsideUp && inside.isInsideUp) outside.outsideUpPosition == inside.insideUpPosition
    else false
  }
  implicit class INT(val value: Int){
    def isOutsideBottom: Boolean = (1 until w).contains(value)
    def outsideBottomPosition: Int = value - 0
    def isOutsideRight: Boolean = (w + 1 to (w + h - 2)).contains(value)
    def outsideRightPosition: Int = value - w
    def isOutsideUp: Boolean = ((w + h) to (2 * w + h - 2)).contains(value)
    def outsideUpPosition: Int = value - w - h + 1
    def isInsideBottom: Boolean = (1 to w - 1).contains(value)
    def insideBottomPosition: Int = value - 0
    def isInsideRight: Boolean = (w - 1 to (w + h - 4)).contains(value)
    def insideRightPosition: Int = value - w + 2
    def isInsideUp: Boolean = (w + h - 4 to 2 * w + h - 6).contains(value)
    def insideUpPosition: Int = value - w - h + 5
  }

  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44360
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  vector<int> a;
  int n,num;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    a.push_back(num);
    //cout << num << endl;
  }

  int q,k;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> k;
    cout << binary_search(a.begin(), a.end(), k) << endl;
  }
  return 0;
}



Measured memory_bytes: 3476
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] h = new int[N];
		sc.fill(h);

		Arrays.sort(h);
		for (int i = 0; i < h.length / 2; i++) {
			int tmp = h[h.length - i - 1];
			h[h.length - i - 1] = h[i];
			h[i] = tmp;
		}

		double diff = A - B;
		long left = 0;
		long right = h[0];
		do {
			long T = (right - left) / 2 + left;

			long sum = 0;
			boolean success = true;
			for (int i = 0; i < h.length; i++) {
				long leftover = h[i] - B * T;
				if (leftover > 0) {
					sum += (long) Math.ceil(leftover / diff);

					if (T < sum) {
						success = false;
						break;
					}
				}
			}

			if (success) {
				right = T;
			} else {
				left = T;
			}
		} while (left < right - 1);

		System.out.println(right);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 24956
#include <bits/stdc++.h>
using namespace std;
 
map<long long, long long> cnt;
long long arr[100050];
bool isPrime[3060];
vector<long long> prime;
long long Slove(long long n)
{
    for(vector<long long>::size_type i = 0; i < prime.size(); ++i)
    {
        while(n % prime[i] == 0)
            n /= prime[i];
    }
    return n;
}
int main()
{
    memset(isPrime, true, sizeof(isPrime));
    for(long long i = 2; i <= 3000; ++i)
    {
        if(!isPrime[i])
            continue;
        prime.push_back(i * i * i);
        for(long long j = i + i; j <= 3000; j += i)
            isPrime[j] = false;
    }
    long long n;
    scanf("%lld", &n);
    for(long long i = 1; i <= n; ++i)
        scanf("%lld", &arr[i]);
    for(long long i = 1; i <= n; ++i)
        ++cnt[ Slove(arr[i]) ];
    long long ans;
    if(cnt.find(1) != cnt.end())
        ans = 1;
    else
        ans = 0;
    for(auto it = cnt.begin(); it != cnt.end(); ++it)
    {
        if(it->first == 1)
            continue;
        long long a = it->first;
        long long b = Slove(a * a);
        ans += max(cnt[a], cnt[b]);
        cnt[a] = 0;
        cnt[b] = 0;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull getLCM(ull a, ull b){
    ull  x = a * b;
 
    /* 自然数 a > b を確認・入替 */
    if(a<b){
        ull tmp = a;
        a = b;
        b = tmp;
    }
    /* ユークリッドの互除法 */
    ull r = a % b;
    while(r>0){
        a = b;
        b = r;
        r = a % b;
    }
    return x/b;
}
int main(void){
    ull a,b,c,d;
    cin>>a>>b>>c>>d;
    ull lcm = getLCM(c,d);
    ull all = b-(a-1);
    ull cmul = b/c - (a-1)/c;
    ull dmul = b/d - (a-1)/d;
    ull cdmul = b/(lcm) - (a-1)/(lcm);
    ull ans = all - cmul - dmul + cdmul;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ls = s.length();
	int lt = t.length();

	if (lt > ls) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	
	int lastindex = -1;
	for (int i = ls - lt; i >= 0; i--) {

		bool f = true;
		for (int j = 0; j < lt; j++) {
			if (!(s[i + j] == t[j] || s[i+j]=='?')) {
				f = false;
			}
		}

		if (f) {
			lastindex = i;
			break;
		}
	}

	if (lastindex == -1) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		for (int i = lastindex; i < lt+lastindex; i++) {
			s[i] = t[i - lastindex];
		}

		for (int i = 0; i < ls; i++) {
			if (s[i] == '?') {
				cout << 'a';
			}
			else {
				cout << s[i];
			}
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n;
string s;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	int ans = 0;
	cin >> n >> s;
	REP(i, n) {
		int j = i;
		if (s[j] == 'A') {
			j++;
			if (j >= n)break;
			if (s[j] == 'B') {
				j++;
				if (j >= n)break;
				if (s[j] == 'C')ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h) rep(j, w) cin >> a[i][j];
    int ans = 0;
    vector<vector<int>> ope;
    rep(i, h-1) rep(j, w){
        if (a[i][j] % 2 == 0) continue;
        a[i][j]--;
        a[i+1][j]++;
        ans++;
        ope.push_back({i,j, i+1, j});
    }
    rep(j, w-1){
        if (a[h-1][j] % 2 == 0) continue;
        a[h-1][j]--;
        a[h-1][j+1]++;
        ans++;
        ope.push_back({h-1,j, h-1, j+1});
    }
    cout << ans << endl;
    rep(i, ope.size()){
        printf("%d %d %d %d\n", ope[i][0]+1, ope[i][1]+1, ope[i][2]+1, ope[i][3]+1);
    }
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    string s;
    ll k;
    std::cin >> s;
    std::cin >> k;
    string ss=s;
    int n=s.size();
    reverse(all(s));
    
    if(s[0]==ss[0]){
        int c1=0,c2=0,c=0;
        rep(i,n){
            if(s[i]==s[0])c1++;
            else break;
        }
        rep(i,n){
            if(ss[i]==s[0])c2++;
            else break;
        }
        
        string sss=s.substr(c1,n-c1-c2);
        if(sss.size()==0){
            std::cout << (n*k)/2 << std::endl;
            exit(0);
        }
        ll ans=0;
        ll cnt=0;
        rep(i,sss.size()-1){
            if(sss[i]==sss[i+1]){
                sss[i+1]='.';
                cnt++;
            }
        }
        
        ans=cnt*k+c1/2+c2/2;
        ans+=(c1+c2)/2*(k-1);
        std::cout << ans << std::endl;
    }
    else{
        ll ans=0;
        rep(i,s.size()-1){
            if(s[i]==s[i+1]){
                s[i+1]='.';
                ans++;
            }
        }
        std::cout << ans*k << std::endl;
    }
}

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

ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

ll lcm(ll a, ll b){
    return a*b / gcd(a, b);
}


int main() {

    ll a,b,c,d,m; cin >> a >> b >> c >> d;
    m = lcm(c,d);
    ll n[3];


    n[0] = (b/c)-((a-1)/c); //3
    n[1] = (b/d)-((a-1)/d); //2
    n[2] = (b/m)-((a-1)/m); //1

    cout << (b-a+1-n[0]-n[1]+n[2]);
    return 0;
}











Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ta = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var t = ta[0];
            var a = ta[1];
            Console.WriteLine(Console.ReadLine().Split(' ')
                .Select((num, i) => (i, t - double.Parse(num) * 0.006))
                .OrderBy(tpl => Math.Abs(a - tpl.Item2))
                .First().i + 1);
        }
    }
}

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

int main() {
    int N; cin >> N;
    vector<long long> B(N-1);
    for (int i = 0; i < N-1; ++i) cin >> B[i];

    long long res = B[0] + B.back();
    for (int i = 0; i + 1 < B.size(); ++i) {
        res += min(B[i], B[i+1]);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	var mySum = 0;
	for (var i = 0; i < line0.length; i++) {
		var a = line0.substr(i, 1);
		mySum += parseInt(a, 10);
	}

	console.log(mySum%9 === 0 ? "Yes" : "No");

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


Measured memory_bytes: 32660
#include <iostream>

#define maxn 1000000
 
using namespace std;
 
int paint[110][110];
int main()
{
    int h,w,n,x=0;
    cin>>h>>w>>n;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        for(int j=0; j<a[i]; j++)
        {
            if((x/w)%2==0) paint[x/w][x%w]=i+1;
            else paint[x/w][w-(x%w)-1]=i+1;
            x++;
        }
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(j==w-1) printf("%d\n",paint[i][j]);
            else printf("%d ",paint[i][j]);
        }
    }
    return 0;
} 

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
    int d = ri();
    int x = ri();
    int a[n];
    INPUT(a);
    
    FOR(i,n) x+=((d-1)/a[i]+1);
    cout << x << endl;
 return 0;
}


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

int n ;
string a ;

int init = 0 ;

int lft[ 3 ] ;

int fastpow ( int x , int pw , int md ) {
    int ret = 1 ;
    while ( pw > 0 ) {
        if ( ( pw % 2 ) == 0 ) {
            x = ( 1LL * x * x ) % md ;
            pw /= 2 ;
        }
        else {
            ret = ( 1LL * ret * x ) % md ;
            -- pw ;
        }
    }
    ret %= md ;
    return ret ;
}

int f ( int x ) {
    int ret = 0 ;
    while ( x > 0 ) {
        ++ ret ;
        x = ( x % __builtin_popcount ( x ) ) ;
    }
    return ret ;
}

void input ( ) {
    cin >> n ;
    cin >> a ;
    for ( int i = 0 ; i < n ; ++ i ) {
        init += ( a[ i ] - '0' ) ;
    }
}

void solve ( ) {
    for ( int add = -1 ; add <= 1 ; ++ add ) {
        if ( add + init <= 0 ) { continue ; }
        int h = 0 ;
        for ( int i = 0 ; i < n ; ++ i ) {
            h = h * 2 + ( a[ i ] - '0' ) ;
            h %= ( init + add ) ;
        }
        lft[ add + 1 ] = h ;
    }
    for ( int i = 0 ; i < n ; ++ i ) {
        int ans = 0 ;
        if ( a[ i ] == '0' ) {
            int aux = fastpow ( 2 , n - i - 1 , init + 1 ) ;
            int hh = ( lft[ 2 ] + aux ) % ( init + 1 ) ;
            ++ ans ;
            ans += f ( hh ) ;
        }
        else {
            if ( init == 1 ) {
                cout << "0\n" ;
                continue ;
            }
            int aux = fastpow ( 2 , n - i - 1 , init - 1 ) ;
            int hh = ( lft[ 0 ] - aux + init - 1 ) % ( init - 1 ) ;
            ++ ans ;
            ans += f ( hh ) ;
        }
        cout << ans << "\n" ;
    }
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3760
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int x[] = new int[N];
        int y[] = new int[N];
        for (int i=0; i<N; i++) {
            x[i] =  Integer.parseInt(sc.next());
            y[i] =  Integer.parseInt(sc.next());
        }
        sc.close();

        double sum = 0.0;
        for (int i=0; i<N; i++) {
            for (int j=0; j<N; j++) {
                if (j==i)
                    continue;
                sum += Math.pow(Math.pow(x[i]-x[j], 2) + Math.pow(y[i]-y[j], 2), 0.5);
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(sum/N);
        out.flush();
    }
}

Measured memory_bytes: 22356
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  vector<int> v {0, 0, 0, 0};
  for (auto &i : v) { cin >> i; }
  sort(v.begin(), v.end());
  if ( v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) { cout << "YES"; }
  else { cout << "NO"; }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

const int MAXN=100000+10;
vector<int> edge[MAXN];
int n,cnt[3];
int tree[MAXN];

void bfs()
{
	queue<int> q;
	q.push(1),q.push(n);
	while(!q.empty())
	{
		int temp=q.front();
		q.pop();
		cnt[tree[temp]]++;
		for(int i=0;i<edge[temp].size();++i)
		{
			int v=edge[temp][i];
			//cnt[tree[v]]++;
			if(tree[v])continue;
			else tree[v]=tree[temp];
			q.push(v);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;++i)
	{
		int x,y;
		cin>>x>>y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	tree[1]=1,tree[n]=2;
	bfs();
	if(cnt[2]>=cnt[1])
		cout<<"Snuke"<<endl;
	else
		cout<<"Fennec"<<endl;
	return 0;
}

Measured memory_bytes: 6272
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = 'APPROVED'
no = 'DENIED'

def main():
    n = ii()
    s = []
    for i in range(n):
        tmp = input()
        s.append(tmp)
    
    s = sorted(s)

    anslist = []

    cnt = 0
    cntmax = 0
    tmp = ""
    for i in range(n):
        if cntmax == 0:
            anslist.append(s[i])
        if s[i] == tmp:
            cnt+=1
            if cntmax == cnt:
                anslist.append(s[i])
            if cntmax < cnt:
                cntmax = cnt
                anslist = [s[i]]
        else:
            cnt = 0
            tmp = s[i]
    for i in range(len(anslist)):
        print(anslist[i])



main()



Measured memory_bytes: 22208
n,m,x=map(int,input().split())
N=[int(i) for i in range(n+1)]
a=[int(i) for i in input().split()]
min1=0
min2=0
for i in N[x:]:
    for j in a:
        if i==j:
            min1+=1
for k in N[:x]:
    for l in a:
        if k==l:
            min2+=1
print(min(min1,min2))

Measured memory_bytes: 3064
# 2020/02/16
# AtCoder Beginner Contest 155 - C

from operator import itemgetter

# ans = chr(ord(a) + 1)

# Input
n = int(input())
s = list()
for i in range(n):
    s.append(input())

s.sort()

# Init
wks = s[0]
cnt = 1
strmap = list()
for i in range(1, n):
    # Different word
    if wks != s[i]:
        wklist = list()
        wklist.append(wks)
        wklist.append(cnt)
        strmap.append(wklist)

        # Init next String
        wks = s[i]
        cnt = 1
    else:
        cnt = cnt + 1

wklist = list()
wklist.append(wks)
wklist.append(cnt)
strmap.append(wklist)

strmap.sort(key=itemgetter(1), reverse=True)

# Output
for i in range(len(strmap)):
    if strmap[i][1] == strmap[0][1]:
        print(strmap[i][0])
    else:
        break


Measured memory_bytes: 42276
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	vector< vector<int> > c(8,vector<int>(8));
	c[0][0]=4;	c[0][1]=1;	c[0][2]=4;	c[0][3]=1;
	c[0][4]=2;	c[0][5]=1;	c[0][6]=2;	c[0][7]=1;
	for(int i=1;i<8;i++)for(int j=0;j<8;j++)c[i][j]=c[i-1][(j+1)%8];
	sort(c.begin(),c.end());

	int p[8];
	for(;~scanf("%d%d%d%d%d%d%d%d",p,p+1,p+2,p+3,p+4,p+5,p+6,p+7);){
		int cntmin=1e9,pos;
		for(int i=0;i<8;i++){
			int cnt=0;
			for(int j=0;j<8;j++)	cnt+=max(p[j]-c[i][j],0);
			if(cntmin>cnt)	cntmin=cnt,pos=i;
		}
		printf("%d %d %d %d %d %d %d %d\n",
			c[pos][0],c[pos][1],c[pos][2],c[pos][3],
			c[pos][4],c[pos][5],c[pos][6],c[pos][7]);
	}

	return 0;
}

Measured memory_bytes: 0
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])


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

int main(){
  vector<int> vec(3);
  for(int i=0; i<3; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(vec.at(0)==5&&vec.at(1)==5&&vec.at(2)==7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

const int AMAX = 100010;
ll bk[AMAX];

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

    int n;
    ll k;
    cin >> n >> k;

    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        bk[a] += b;
    }

    ll cur = 0;
    rep(i, 0, AMAX) {
        cur += bk[i];
        if (cur >= k) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  
  int l = 0, r = 0;
  rep(i,x) {
    rep(j,m) if (a[j]==i) l++;
  }
  
  for (int i=x+1; i<n; i++) {
    rep(j,m) if (a[j]==i) r++;
  }
  
  cout << min(l,r) << endl;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < (1 << 3); i++) {
        int cur = s[0] - '0';
        string v;
        v += s[0];
        for(int j = 1; j < 4; j++) {
            if((i >> (j - 1)) & 1) {
                cur += s[j] - '0';
                v += "+";
                v += s[j];
            } else {
                cur -= s[j] - '0';
                v += "-";
                v += s[j];
            }
        }
        if(cur == 7) {
            cout << v << "=7" << endl;
            return 0;
        }
    }

    return 0;

}


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

int cnt[200010];
int main(){
  int N, K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    cnt[a-1]++;
  }
  sort(cnt, cnt+N);
  
  int ans = 0;
  for(int i = 0; i < N-K; i++) ans += cnt[i];

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
double  dp[310][310][310];
int n;
double f(int i,int j,int k)
    {if(i+j+k==0){return (double)0;}
    if(dp[i][j][k]>-0.2){return dp[i][j][k];}
    double sumi=0;
    if(i)
        {sumi=sumi+i*(1+f(i-1,j,k));
        }
    if(j)
        {sumi=sumi+j*(1+f(i+1,j-1,k));
        }
    if(k)
        {sumi=sumi+k*(1+f(i,j+1,k-1));
        }
    sumi+=n-i-j-k;
    sumi=(double)sumi/(double)(i+j+k);
    dp[i][j][k]=sumi;
    return sumi;
    }
int main()
    {ios::sync_with_stdio(0);
    cin.tie(0);
    int count1=0;
    int count2=0;
    int count3=0;
    cin>>n;
    int dummy;
    for(int i=0;i<n;i++){cin>>dummy;
    if(dummy==1){count1++;}
    if(dummy==2){count2++;}
    if(dummy==3){count3++;}
    }
    for(int i=0;i<310;i++)
        {for(int j=0;j<310;j++)
            {for(int k=0;k<310;k++)
            {dp[i][j][k]=-1;}
            }
        }
    cout<<setprecision(12)<<f(count1,count2,count3);
    }


Measured memory_bytes: 233088
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();

    if n == 1 {
        println!("Hello World")
    } else if n == 2 {
        let x: i32 = sc.read();
        let y: i32 = sc.read();
        let _res = x + y;
        println!("{}", _res);
    }
}


Measured memory_bytes: 4352
import sys

def solve(A,B,K):
    ab = [A,B]
    for i in range(K):
        if ab[0]%2!=0:
            ab[0]-=1
        ab[1]+=ab[0]//2
        ab[0]-=ab[0]//2
        ab.reverse()
    if K%2!=0:
        print(ab[1],ab[0])
        return
    print(ab[0],ab[1])


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    A = int(ws[0])
    B = int(ws[1])
    C = int(ws[2])
    return (A, B, C)

def main():
    solve(*readQuestion())
    

# Uncomment before submission
main()

Measured memory_bytes: 3192
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	AtCoder::Ans* ans = new AtCoder::Ans();

	const int a = s[0], b = s[1];

	if (1 == b) {
		ans->showResult();
		delete(ans);
		return 0;
	}

	if (a >= b) {
		ans->increment(1);
		ans->showResult();
		delete(ans);
		return 0;
	}

	int c = 0;
	for (int i = 0; i < 20; i++) {
		c = i + 1;
		ans->increment(a);
		if (b <= ans->getResult()) {
			break;
		} else {
			ans->decrement();
		}
	}
	ans->decrement(ans->getResult());
	ans->increment(c);

	ans->showResult();

	delete(ans);

	return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    D, N = il()
    if N == 100:
        N += 1
    print(100 ** D * N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10220
#include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0]){
    int hit =0,blow = 0;
    for(int i=1;i<4;i++)
      cin >> a[i];
    for(int i=0;i<4;i++)
      cin >> b[i];
      for(int k=0;k<4;k++){
        for(int j=0;j<4;j++){
      if(a[k]==b[j]){
        if(k==j) hit++; 
        else blow++;
      }
    }
      }
      cout << hit <<" "<< blow <<endl;
  }
}
        

Measured memory_bytes: 2972
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	rep(i, n){
		if(a[i]%2 == 0){
			if(a[i]%3 && a[i]%5){
				puts("DENIED");
				return 0;
			}
		}
	}

	puts("APPROVED");
	return 0;
}


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

signed main(void)
{
	int n, mini;
	cin >> n;
	int a[n];
	long long cnt, sum;

	mini = 1e9;
	sum = cnt = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum += abs(a[i]);
		mini = min(abs(a[i]), mini);
		if (a[i] < 0)
			cnt++;
	}
	if (cnt % 2 == 0)
		cout << sum << endl;
	else
		cout << sum - 2 * mini << endl;
	return 0;
}


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

int main(){
    char x; cin >> x;
    if(x=='A') cout << 'T' << endl;
    else if(x=='T') cout << 'A' << endl;
    else if(x=='C') cout << 'G' << endl;
    else cout << 'C' << endl;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i, n) cin >> x.at(i);
  vector<int> minus;
  vector<int> plus;
  rep(i, n) {
    int xx = x.at(i);
    if (xx >= 0) {
      plus.push_back(xx);
    } else {
      minus.push_back(-xx);
    }
  }
  reverse(minus.begin(), minus.end());
  ll res = 1L << 30;
  // マイナスから折り返す
  rep(i, min((int) minus.size(), k)) {
    ll tmp = 0;
    tmp += 2 * minus.at(i);
    int plusCnt = k - 1 - i;
    if (plusCnt > (int) plus.size()) {
      continue;
    }
    if (plusCnt > 0) {
      tmp += plus.at(plusCnt - 1);
    }
    res = min(res, tmp);
  }
  // プラスから折り返す
  rep(i, min((int) plus.size(), k)) {
    ll tmp = 0;
    tmp += 2 * plus.at(i);
    int minusCnt = k - 1 - i;
    if (minusCnt > (int) minus.size()) {
      continue;
    }
    if (minusCnt > 0) {
      tmp += minus.at(minusCnt - 1);
    }
    res = min(res, tmp);
  }
  // 全部どちらかの場合
  if ((int) minus.size() >= k) {
    res = min(res, (ll) minus.at(k - 1));
  }
  if ((int) plus.size() >= k) {
    res = min(res, (ll) plus.at(k - 1));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4344
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
const int inf = 1000000007;
int a[105], b[105], c[105];
signed main() {
	int n;
	cin >> n;
	int wa = 0;
	rep(i, n) { cin >> a[i]; wa += a[i]; }
	int m;
	cin >> m;
	rep(i, m) {
		cin >> b[i] >> c[i];
	}
	rep(i, m) {
		cout << wa - (a[b[i]] - c[i]) << endl;
	}
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
	let input = {
		let mut buf = vec![];
		stdin().read_to_end(&mut buf);
		unsafe { String::from_utf8_unchecked(buf) }
	};
	let mut lines = input.split('\n');

	let n = lines.next().unwrap().parse().unwrap();

	for line in lines.take(n) {
		let (k, p) = {
			let mut iter = line.split(' ').map(|s| s.parse::<u32>().unwrap());
			(iter.next().unwrap(), iter.next().unwrap())
		};

		println!("{}", (k - 1) % p + 1);
	}
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll powmod(ll a, ll b, ll mod = 1e9+7) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}


vector<ll> f;
void cominit(ll n = 210000, ll mod = 1e9+7) {
    f.resize(n + 1);
    f[0] = 1;
    REP(i, n)f[i + 1] = f[i] * (i + 1) % mod;
}

ll nCr(ll n, ll r, ll mod = 1e9+7) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return f[n] * powmod(f[r] * f[n - r], mod - 2, mod) % mod;
}

ll nPr(ll n, ll r, ll mod = 1e9+7) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return f[n] * powmod(f[n - r], mod - 2, mod) % mod;
}

ll nHr(ll n, ll r, ll mod = 1e9+7) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return nCr(n + r - 1, r, mod);
}

ll k, ans;
string s;
int main() {
    cominit(2100000);
    cin >> k >> s;
    ll sz = s.size();
    ll n = k + sz;
    ans = powmod(26, n);
    REP(i, sz){
        ans -= nCr(n, i) * powmod(25, n - i) % MOD;
        ans = (ans + MOD * 2) % MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 21596
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

long long gcd(long long a, long long b) {
    for(;;) {
        if(a == 0)
            return b;
        b %= a;
        if(b == 0)
            return a;
        a %= b;
    }
}

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}
// シミュレーション
// https://ykmaku.hatenablog.com/entry/2018/06/28/155635
int main() {
    int N;
    cin >> N;
    vector<int> t(N), a(N);
    REP(i, N) { cin >> t[i] >> a[i]; }
    ll A = 1;
    ll T = 1;
    for(int i = 0; i < N; i++) {
        ll x = (T + t[i] - 1) / t[i];
        ll y = (A + a[i] - 1) / a[i];
        ll n = max(x, y);
        T = n * t[i];
        A = n * a[i];
    }
    cout << T + A << endl;
}

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

int main(){
    vector<int> prime_table;
    bool find[105000];
    for(int i=2; i<105000; i++){
        find[i] = false;
    }
    for(int i=2; i*i<105000; i++){
        if(find[i]) continue;
        for(int j=i*2; j<105000; j+=i){
            if(!find[j]) find[j] = true;
        }
    }
    prime_table.push_back(2);
    for(int i=3; i<105000; i+=2){
        if(!find[i]) prime_table.push_back(i);
    }

    int n;

    while(cin >> n, n != 0){
        int sum = 0;
        for(int i=0; i<n; i++){
            sum += prime_table[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
using namespace std;

void A();

int main() {
	A();
}

void A() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}

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

int main(void)
{
	double s[1000],t1,t2;
	int n,i;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		t1=0;
		for(i=0;i<n;i++){
			scanf("%lf",&s[i]);
			t1+=s[i];
		}
		t1/=n;
		t2=0;
		for(i=0;i<n;i++)t2+=pow(s[i]-t1,2);
		printf("%.5f\n",sqrt(t2/n));
	}
	return 0;
}


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

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

    vector<int> v;
    for(int i = 0; i < k; ++i){
        int tmp; cin >> tmp;
        v.push_back(tmp);
    }

    int ans = 0;

    for(int i = n; i < 100000; ++i) {
        int current_num = i;
        bool find = true;
        while(current_num != 0) {
            int cur = current_num % 10;
            for(int j = 0; j < v.size(); ++j) {
                if(cur == v[j]) {
                    find = false;
                    break;
                }
            }
            if(!find){break;}
            current_num /= 10;
        }
        if(find) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#include <math.h>
#include <stdlib.h>


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



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;

    int i = k;
    int ans = 1;

    while(true){
        if(i > n) break;
        ans++;
        i*=k;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

    int w, h, n;
    cin >> w >> h >> n;

    vector<int> x(n), y(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> x[i] >> y[i];
    }

    int ans = 0;
    for(int i = 0 ; i < n - 1 ; ++i){
        int dx = abs(x[i] - x[i + 1]);
        int dy = abs(y[i] - y[i + 1]);
        ans += dx + dy;
        if((x[i] <= x[i + 1] && y[i] <= y[i + 1]) || (x[i] >= x[i + 1] && y[i] >= y[i + 1])){
            ans -= min(dx, dy);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3212
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};


int main(){
  string S;
  cin >>S;
  int cnt =0;
  int cntmax=0;
  Rep(i,S.size()){
    if(S.at(i) == 'A' ||S.at(i) == 'T'||S.at(i) == 'G'||S.at(i) == 'C'){
      cnt ++;
    }else{
      cntmax = max(cntmax,cnt);
      cnt =0;
    }
  }
  cntmax = max(cntmax,cnt);
  cout << cntmax;
}
  

Measured memory_bytes: 256