akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];

	map<int, int> ma;
	rep(i, N) ma[a[i]]++;
	ll ans = 0;
	for(auto u : ma) {
		if(u.fi < u.se) {
			ans += u.se - u.fi;
		}else if(u.fi > u.se) {
			ans += u.se;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5120
import math

a,b,h,m = map(int,input().split())
tan_sin = math.pi * (h + m/60) / 6
ji_sin = math.pi * m/30
theta = tan_sin - ji_sin
c = math.cos(theta)

ans = math.sqrt(a**2 + b**2 - 2*a*b*c)

print(ans)

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

typedef long long ll;

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

	ll t=1;
	//cin >> t;

	for(ll i=1;i<=t;i++){
		ll k;
		cin >> k;

		if(k%7==0)
			k=k/7;

		if(k%10==1 || k%10==3 || k%10==9){
			ll ans=1;
			ll rem=1%k;
			while(rem!=0){
				ans++;
				rem=rem*10+1;
				rem=rem%k;
			}

			cout << ans << "\n";
		}
		else
			cout << -1 << "\n";
	}
}

Measured memory_bytes: 3620
import sys

N = int(input())

print (0)
l = 0
ln = input()

if ln == "Vacant":
    sys.exit()

print (N-1)
r = N-1
rn = input()

if rn == "Vacant":
    sys.exit()


while True:

    mid = (l + r) // 2
    print (mid)
    mn = input()

    if mn == "Vacant":
        sys.exit()

    if (mid - l) % 2 == 0:

        if ln == mn:
            l = mid
            ln = mn

        else:
            r = mid
            rn = mn

    else:

        if ln == mn:
            r = mid
            rn = mn

        else:
            l = mid
            ln = mn


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;

int main()
{
  int N;
  cin >> N;
  
  string S[200010];
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  
  unordered_map<string, int> map;
  for(int i = 0; i< N; i++){
    map[S[i]] = 1;
  }
  
  cout << map.size() << endl;
}

Measured memory_bytes: 23972
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int N=0;
    cin >> N;
    for(int a=1; a<=9; a++){
        if(N%a==0 && N/a<=9){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

const int maxn = 4e5 + 5;
const int mod = 1e9 + 7;
int F[maxn + 5], Finv[maxn + 5], inv[maxn + 5];
void init()
{
    inv[1] = 1;
    for (int i = 2; i < maxn; i++) {
        inv[i] = (mod - mod / i) * (LL)1 * inv[mod % i] % mod;
    }
    F[0] = Finv[0] = 1;
    for (int i = 1; i < maxn; i++) {
        F[i] = F[i - 1] * LL(1) * i % mod;
        Finv[i] = Finv[i - 1] * LL(1) * inv[i] % mod;
    }
}
int comb(int n, int m)
{ //comb(n, m)就是C(n, m)
    if (m < 0 || m > n)
        return 0;
    return F[n] * LL(1) * Finv[n - m] % mod * Finv[m] % mod;
}

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

    // if (k >= n) {
    //     printf("%lld\n", (LL)comb(n + n - 1, n - 1));
    //     return 0;
    // }
    k = min(k, n - 1);

    LL ans = 0;
    for (int i = 0; i <= k; i++) {
        //cout << i << ' ' << comb(n, i) * comb(i + n - i - 1, n - i - 1) << '\n';
        ans = (ans + LL(comb(n, i)) * comb(i + n - i - 1, n - i - 1) % mod) % mod;
    }

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

Measured memory_bytes: 4992
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring> 
using namespace std;
int n,m,x,y;
string a,b,c,d;
char zx[30];
char zy[30];
int gg[30];
int zz[30];
int main()
{
	cin>>a>>b;
	for(int i=0;i<a.length();i++)
	{
		if(zz[a[i]-96])
		{
			a[i] = zx[a[i]-96];
			continue;
		}
		if(gg[b[i]-96])
		{
			a[i] = zy[b[i]-96];
			continue;
		}
		if(a[i]!=b[i])
		{
			zx[a[i]-96] = b[i];
			zz[a[i]-96] = 1;
			zy[b[i]-96] = a[i];
			gg[b[i]-96] = 1;
			a[i] = b[i];
		}
	}
	if(a==b)
	{
		cout<<"Yes";
	}
	else cout<<"No";
}

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

#define f first
#define s second

using namespace std;

bool valid(int arr[], int x, int m) {
	for(int i=0; i<m; i++) {
		if(arr[i] < x) return 0;
	}

	return 1;
}

int main() {
	int n,m,x; scanf("%d %d %d", &n, &m, &x);
	pair<int,vector<int>> ca[n];
	int minMoney = 0;
	bool found = false;

	for(int i=0; i<n; i++) {
		int c; vector<int> a(m);
		scanf("%d", &c);
		for(int j=0; j<m; j++) {
			scanf("%d", &a[j]);
		}

		ca[i] = pair<int, vector<int>>(c, a);
		minMoney += c;
	}

	for(int mask=0; mask<pow(2,n); mask++) {
		int totExp[m] = {0}, money = 0;

		for(int i=0; i<n; i++) {
			if(mask & (1<<i)) {
				money += ca[i].f;
				for(int j=0; j<m; j++)
					totExp[j] += ca[i].s[j];
			}
		}

		if(valid(totExp, x, m)) {
			found = true;
			minMoney = min(minMoney, money);
		}
	}

	if(!found)
		cout<<"-1\n";
	else cout<<minMoney<<endl;

	return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
char ltoc(ll x){
    return 'a' + x;
}

int main() {
    ll N;
    cin >> N; N--;

    vector<ll> dig;

    while(N != -1){
        ll q = N / 26;
        ll r = N % 26;
        dig.push_back(r);
        N = q;
        N--;
    }

    int d = dig.size();
    REPr(i,d){
        cout << ltoc(dig[i]);
    }
    cout << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
  int x,a,b,c;
  int amari;
  int cnt=0;
  
  scanf("%d", &x);
  scanf("%d", &a);
  scanf("%d", &b);
  
  c = x - a;
  
  while(cnt==0){
    if(c>=b){
      c-=b;
    }
    else{
      amari=c;
      cnt++;
    }
  }
  
  printf("%d\n",amari);
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	for {
		h, w := nextInt(), nextInt()

		if h == 0 && w == 0 {
			break
		}
		for i := 0; i < h; i++ {
			fmt.Println(strings.Repeat("#", w))
		}
		fmt.Println("")
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1252
import sys;print"\n".join("%d %d"%(lambda x:(x[2],x[0]/x[2]*x[1]))((lambda f,x:(x[0],x[1],f(f,x[0],x[1])))(lambda f,a,b:a%b==0 and b or f(f,b,a%b),map(int,s.split(' '))))for s in sys.stdin)

Measured memory_bytes: 4236
#include<algorithm>
#include<iostream>

using namespace std;
const int N = 10e5 + 1;
int a[N];

int main(){
  int n;
  cin >> n;
  for(int i = 1; i <=n; ++i){
    cin >> a[i];
  }

  for (int i = n; i >=1; --i){
    if (i != n){
      if (a[i] > a[i+1] + 1){
        cout << "No" << endl;
        return 0;
      }
      else if(a[i] == a[i+1] + 1){
        a[i]-=1;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	vector<Pl> dat(N);

	for (auto &v : dat) cin >> v.second >> v.first;
	sort(begin(dat), end(dat));
	
	ll sum = 0;
	for (auto &v : dat) {
		sum += v.second;
		if (sum > v.first) {
			cout << "No" << el; return;
		}
	}
	cout << "Yes" << el;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, cnt[3];
char C[3] = {'R', 'G', 'B'}; 
string S;

int main(){
  cin >> N >> S;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 3; j++){
      if (S[i] == C[j]) cnt[j]++;
    }
  }

  ll ans = cnt[0] * cnt[1] * cnt[2];

  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      int k = 2 * j - i;
      if (k >= N) break;
      if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string S; cin >> S;
	rep(i, S.length()) {
		if (i % 2 == 0 && S[i] == 'L') {
			cout << "No";
			return;
		}
		if (i % 2 == 1 && S[i] == 'R') {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int x, y;
    cin >> x >> y;
    if(abs(x - y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>

using namespace std;

typedef pair<int,int> P;

int h, w, c;
int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};


void paint(int t[8][8],int a){ // aは変更する色
	int y, x, b, i, j, f[8][8]; // bは元の色
	queue<P> que;
	que.push(P(0,0));
	b = t[0][0];
	t[0][0] = a;
	for(i = 0;i < h;i++){
		for(j = 0;j < w;j++)
			f[i][j] = 1;
	}
	f[0][0] = 0;
	while(que.size()){
		y = que.front().first, x = que.front().second;
		que.pop();
		for(i = 0;i < 4;i++){
			if(y + dy[i] >= 0 && y + dy[i] < h && x + dx[i] >= 0 && x + dx[i] < w && t[y + dy[i]][x + dx[i]] == b && f[y + dy[i]][x + dx[i]]){
				que.push(P(y + dy[i],x + dx[i]));
				t[y + dy[i]][x + dx[i]] = a;
				f[y + dy[i]][x + dx[i]] = 0;
			}
		}
	}
}

int countcolor(int t[8][8]){
	int a = t[0][0], i, j, ret = 1, f[8][8], y, x; // aは数えるべき色
	for(i = 0;i < h;i++){
		for(j = 0;j < w;j++)
			f[i][j] = 1;
	}
	queue<P> que;
	f[0][0] = 0;
	que.push(P(0,0));
	while(que.size()){
		y = que.front().first, x = que.front().second;
		que.pop();
		for(i = 0;i < 4;i++){
			if(y + dy[i] >= 0 && y + dy[i] < h && x + dx[i] >= 0 && x + dx[i] < w && t[y + dy[i]][x + dx[i]] == a && f[y + dy[i]][x + dx[i]]){
				f[y + dy[i]][x + dx[i]] = 0;
				ret++;
				que.push(P(y + dy[i],x + dx[i]));
			}
		}
	}
	return ret;
}

int solve(int d,int t[8][8]){
	int i, j, k, tt[8][8], ret = 0;
	if(d == 4){
		paint(t,c);
		return countcolor(t);
	}
	else{
		for(i = 1;i <= 6;i++){
			for(j = 0;j < h;j++){
				for(k = 0;k < w;k++){
					tt[j][k] = t[j][k];
				}
			}
			paint(tt,i);
			ret = max(ret,solve(d + 1,tt));
		}
	}
	return ret;
}




int main(void){
	int t[8][8], i, j;
	while(1){
		scanf("%d%d%d",&h,&w,&c);
		if(h + w + c == 0)
			break;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++)
				scanf("%d",&t[i][j]);
		}
		printf("%d\n",solve(0,t));
	}
	return 0;
}

Measured memory_bytes: 1036
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<map>

#define Rep(i,x,y) for (int i=x,_Lim=y;i<=_Lim;i++)
#define Dep(i,x,y) for (int i=x,_Lim=y;i>=_Lim;i--)

#define mk(a,b) make_pair(a,b)

using namespace std;

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

int Stv[1<<8];

inline int read(){
	int f=1,res=0,ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;ch=getchar();
	}
	while (ch>='0' && ch<='9') res=res*10+ch-48,ch=getchar();
	return f*res;
}
int n,A,B,P[300005],f[300005];
int main(){
	n=read(),A=read(),B=read();
	if (A+B>n+1 || 1ll*A*B<n){
		puts("-1");return 0;
	}
	Rep(len,0,n){
		int kes=(n-len-1)/A+1;
		if (kes+len==B){
//			printf("kes=%d len=%d\n",kes,len);
			Rep(i,1,kes){
				int lim=(i==kes)?(n-len-(kes-1)*A):A;
				Rep(j,1,lim){
					P[++*P]=n-(i-1)*A-lim+j;
					printf("%d ",n-(i-1)*A-lim+j);
				}
			}
			Rep(i,1,len) printf("%d ",P[++*P]=(len-i+1));puts("");
			break;
		}
	}
	return 0;
	f[0]=0;
	int r1=0,r2=0;
	Rep(i,1,n){
		f[i]=0;
		Rep(j,1,i-1) if (P[i]>P[j]) f[i]=max(f[i],f[j]);
		f[i]++;
		r1=max(r1,f[i]);
	}
	f[0]=0;
	Rep(i,1,n){
		f[i]=0;
		Rep(j,1,i-1) if (P[i]<P[j]) f[i]=max(f[i],f[j]);
		f[i]++;
		r2=max(r2,f[i]);
	}
	printf("%d %d\n",r1,r2);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    ll n, k, one=-1, ans=0;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> a.at(i);
        if(a.at(i) == 1)one=i+1;
    }
    int now=0;
    while(now+1 < n){
        now+=k-1;
        ans++;        
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=210000;

int a[N],b[N],n;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);

    for(int i=0; i<n; i++)
        if(a[i]==b[n-1])cout<<b[n-2]<<endl;
        else cout<<b[n-1]<<endl;


    return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int r = sc.nextInt();
			if (r == 0) {
				sc.close();
				break;
			}

			int n = sc.nextInt();

			int[] xl = new int[n];
			int[] xr = new int[n];
			int[] h = new int[n];
			for (int i = 0; i < n; i++) {
				xl[i] = sc.nextInt();
				xr[i] = sc.nextInt();
				h[i] = sc.nextInt();
			}
			int[] cover = new int[2 * r];
			for (int i = 0; i < n; i++) {
				xl[i] += r;
				xr[i] += r;
				xl[i] = Math.max(0, xl[i]);
				xr[i] = Math.max(0, xr[i]);

				int ll = Math.min(xl[i], xr[i]);
				int rr = Math.min(r * 2, Math.max(xl[i], xr[i]));

				int c = h[i];
				for (int j = ll; j < rr; j++) {
					cover[j] = Math.max(cover[j], c);
				}
			}

			// System.out.println(Arrays.toString(cover));
			double res = 100000.0;
			for (int i = 0; i < cover.length; i++) {
				int xx = i - r > 0 ? i - r + 1 : r - i - 1;
				double t1 = cover[i]
						+ r
						* (1 - Math
								.sin(Math.acos((double) Math.abs(r - i) / r)));
				double t2 = cover[i] + r
						* (1 - Math.sin(Math.acos((double) xx / r)));
				res = Math.min(res, Math.min(t1, t2));
			}

			System.out.println(String.format("%.4f", res));
		}
	}
}

Measured memory_bytes: 26376
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

	int a[n];
	rep(i,0,n)
		cin >> a[i];

	long long ans = 0;
	
	rep(i,1,n){
		if(a[i] + a[i-1] > x ){
			ans += a[i]+a[i-1]-x;
			a[i] -=a[i]+a[i-1]-x;
			if(a[i]<0)
				a[i] = 0;
		}
	}

	P(ans);
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int a,b;
int main() {
	cin>>a>>b;

	if(a*b%2==0)cout<<"Even"<<endl;
	else cout<<"Odd"<<endl;
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<ll> divisor(ll n){
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i!=n/i) ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

ll solve(ll N, ll K){

  while(N>=K){
    if(N%K==0) N = N/K;
    else N = N - K;
  }

  return N;
}


int main(){
  ll N;
  cin >> N;

  
  set<ll> ret;
  
  vector<ll> div1 = divisor(N-1);
  rep(i,div1.size()){
    if(div1[i] == 1) continue;
    if(N%div1[i] == 1){
      ret.insert(div1[i]);
    }
  }
  
  vector<ll> div2 = divisor(N);
  rep(i,div2.size()){
    if(div2[i] == 1) continue;
    ll n = N;
    ll k = div2[i];
    while(n%k==0) n/=k;
    if(n%k==1) ret.insert(div2[i]);
  }
    
  cout << ret.size() << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {
    
    int n;
    cin>>n;
    map<string,int> m;
    rep(i,n){
        int q;
        cin>>q;
        if(q==0){
            int x;
            string k;
            cin>>k>>x;
            m[k]=x;
        } else if(q==1) {
            string k;
            cin>>k;
            fin(m[k]);
        } else if(q==2){
            string k;
            cin>>k;
            m.erase(k);
        } else {
            string a,b;
            cin>>a>>b;
            auto l=m.lower_bound(a),r=m.upper_bound(b);
            for(;l!=r;l++){
                if(l->second!=0){
                    cout << l->first<<" "<<l->second<<endl;
                }
            }
        }
    }
}


Measured memory_bytes: 27828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double EPS = 1e-9;
const double PI = acos(-1);

double f(int n, int d){
    double v = (double)n/d;
    return abs(v - PI);
}

int main(){
    double R;
    while(scanf(" %lf", &R)){
        if(R < EPS) break;

        int d = 1;
        while(1){
            int l=3*d, r=4*d;
            while(r-l>2){
                int m1 = (2*l+r)/3, m2 = (l+2*r)/3;
                if(f(m1,d) > f(m2,d)) l = m1;
                else r = m2;
            }

            int ans = -1;
            double mn = 1e9;
            for(int i=l; i<=r; ++i){
                double v = f(i,d);
                if(mn > v){
                    mn = v;
                    ans = i;
                }
            }

            if(mn < R+EPS){
                printf("%d/%d\n", ans, d);
                break;
            }
            ++d;
        }
    }
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  ll x,y;
  cin>>x>>y;
  int ans=0;
  for(ll s=x;s<=y;s*=2){
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            int N = nint(sc);
            long[] aList = longLine(sc, N);
            int count = 0;
            for (int i = 0; i < N; i++) {
                long num = aList[i];
                if(num%2==0){
                    while (num %2 ==0){
                        num /= 2;
                        count++;
                    }
                }
            }
            out.println(count);
        }
    }

    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return String.valueOf(sc.next());
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 30592
//package april2020;

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {
//	static long[] dp;
	static int n,k, a[];
	static long MOD = (long)1e9+7;
	static ArrayList<Integer>[] graph;
//	static HashSet<Integer> visited;
//	static long[][] dp;
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
		FastReader scn = new FastReader();
		OutputStream out = new BufferedOutputStream ( System.out );
		n = scn.nextInt();
		graph = new ArrayList[n+1];
//		visited = new HashSet<>();
		for(int i=1;i<=n;i++) {
			graph[i] = new ArrayList<>();
		}
		for(int i =0;i<n-1;i++) {
			int u = scn.nextInt();
			int v = scn.nextInt();
			graph[u].add(v);
			graph[v].add(u);
		}
		Pair res = dfs(1,-1);
		long answer = (res.first+res.second)%MOD;
		
		out.write((answer+"\n").getBytes());
		out.close();
	}
	static Pair dfs(int curr, int parent) {
		long all_white=1;
		long sth_is_black = 0;
		for(int b:graph[curr]) {
			if(b!=parent) {
				Pair p=dfs(b,curr);long maw = all_white;
				all_white = all_white*p.second%MOD;
				sth_is_black = (maw*p.first%MOD + sth_is_black*(p.first+p.second)%MOD)%MOD;
			}
		}
		return new Pair(all_white, (all_white+sth_is_black)%MOD);
	}
	static class Pair{
		long first;
		long second;
		public Pair(long first, long second) {
			this.first = first;
			this.second = second;
		}
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 78268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
 
    public static void main(String[] args) {
 
        double inta = 0;
        double intb = 0;
        double intd = 0;
        double intr = 0;
        double dbf = 0.0;
 
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String strInput = br.readLine();
 
            ArrayList<Double> NumList = new ArrayList<Double>();
 
            String[] strNumList = strInput.split(" ", 0);
 
            for (int i = 0; i < strNumList.length; i++) {
                NumList.add(Double.parseDouble(strNumList[i]));
            }
 
            inta = NumList.get(0);
            intb = NumList.get(1);
 
            intd = inta / intb;
            intr = inta % intb;
            dbf = (double)inta / (double)intb;
 
            System.out.println((int)intd + " " + intr + " " + String.format("%.5f", dbf));
        } catch (IOException e) {
            System.out.println(e);
        }catch (NumberFormatException e) {
            System.out.println(e);
        }
    }
}

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

int main(){
  int N,sum,vek; cin >> N;
  sum=0; vek=1;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
    
      for(int i=0; ;i++){
        if(sum<N){
          if(vek!=2){
            vek=vec.at(vek-1);
            sum++;
          }
          else{
            cout << sum << endl;
            break;
          }
        }
       else{
         cout << -1 << endl;
         break;
       }
     }
}
    
        
    


Measured memory_bytes: 640
// AOJ Volume 1 Problem 0101

#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[2001];
	int n;
	int i, j;

	scanf("%d", &n);
	fgets(str, 2001, stdin);

	for (j = 0; j < n; j++){
		fgets(str, 2001, stdin);
		if (str[strlen(str) - 1] == '\n'){
			str[strlen(str) - 1] = '\0';
		}
		i = 0;
		while (str[i] != '\0'){
			if (strncmp(&str[i], "Hoshino", 7) == 0){
				strncpy(&str[i], "Hoshina", 7);
			}
			i++;
		}
		printf("%s\n", str);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <cstdio>
#define maxn 200010
using namespace std;
int n,T;
long long t[maxn],start,end,ans;
int main() {
	scanf("%d %d",&n,&T);
	for (int i=1;i<=n;i++)
		scanf("%lld",&t[i]);
	start=t[1];
	end=t[1]+T;
	ans=0LL;
	for (int i=2;i<=n;i++) {
		if (t[i]>end) {
			ans+=end-start;
			start=t[i];
			end=t[i]+T;
		}
		else end=t[i]+T;
	}
	ans+=end-start;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner

val sc = Scanner(System.`in`)
val n = sc.nextInt()

fun main(args: Array<String>) {

    var vlist: MutableList<Int> = mutableListOf()
    for (i in 0 until n) {
        vlist.add(sc.nextInt())
    }

    var clist: MutableList<Int> = mutableListOf()
    for (i in 0 until n) {
        clist.add(sc.nextInt())
    }

    var total = 0
    for (i in 0 until n) {
        if (vlist[i] - clist[i] > 0) {
            total += vlist[i] - clist[i]
        }
    }
    print(total)
}

Measured memory_bytes: 29604
N = int(input())
S = input()

if len(S) % 2:
    print('No')
    exit()
flag = 0
for i in range(len(S)//2):
    if S[i] != S[i+len(S)//2]:
        flag = 1
if flag == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

const int D = 100;
vi a(D), b(D), c(D), d(D);

int n, m, q;
int ans = 0;
int cnt = 0;
void solve(int idx, vi& now) {
    if (idx == n) {
        int res = 0;
        rep (i, q) {
            if (now[b[i]] - now[a[i]] == c[i]) res += d[i];
        }
        chmax(ans, res);
        return;
    }

    int start;
    if (now.size() > 0) start = now.back();
    else start = 1;
    for (int j =start; j <= m; j++) {
        now.push_back(j);
        solve(idx + 1, now);
        now.pop_back();
    }
    return;
}

signed main() {
    fio();
    cin >> n >> m >> q;
    rep (i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    vi now;
    solve(0, now);
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K,N;
    cin >> K >> N;

    int x=0,y=0,sum=0,max=0,first,final;
    cin >> first;
    x = first;
    for (int i = 0; i < N-1; i++)
    {
        cin >> y;
        if(i == N-2){
            final = y;
        }
        sum += y - x;
        if(y-x > max){
            max = y - x;
        }
        x = y;
    }

    int d = first + K - final;

    if(d > max){
        cout << sum << endl;
    }else{
        cout << sum - max + d << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        long count = 0;

        if (k == 0)
            count = n * n;
        else {
            for (long b = k + 1; b <= n; b++) {
                count += (n / b) * (b - k);
                count += Math.max((n % b) - k + 1, 0);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a,b,c;
int main(){
    scanf("%d%d%d",&a,&b,&c);
    if(b-a==c-b)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val totalProblems = readLine()!!.toInt()
    val times = readLine()!!.split(' ').map { it.toInt() }
    val drinkNum = readLine()!!.toInt()
    var drinks = mutableMapOf<Int, Int>()
    for (i in 1..drinkNum) {
        val drinksTmp = readLine()!!.split(' ').map { it.toInt() }
        val sum = times
            .filterIndexed{index, value ->
                index != drinksTmp[0]-1 }
            .sum() + drinksTmp[1]
        println(sum)
    }
}

Measured memory_bytes: 38340
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int sum=0,N,T[101],M,P[101],X[101];
  cin >> N;
  REP(i,N)cin >> T[i];
  cin >> M;
  REP(i,M)cin >> P[i] >> X[i];
  REP(i,N)sum+=T[i];
  REP(i,M){
    cout << (sum-T[P[i]-1]+X[i]) << endl;
  }
  return 0;  
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int a = vs[1];
			int b = vs[2];

			long ans = ModPow(2, n, mod) - 1;
			// nCr = (n * (n-1) * ... * (n-(r-1))) / (r * r-1 * ... * 2 * 1)
			long c = 1; // n ～ n-a-1
			long d = 1; // a ～ 1
			long e = 1; // n ～ n-b-1
			long f = 1; // b ～ 1
			for (int i = 0; i < a; i++) {
				c = Mod(c * (n - i), mod);
				d = Mod(d * (i + 1), mod);
			}
			for (int i = 0; i < b; i++) {
				e = Mod(e * (n - i), mod);
				f = Mod(f * (i + 1), mod);
			}
			long x = Mod(c * ModInv(d, mod), mod);
			long y = Mod(e * ModInv(f, mod), mod);
			System.Diagnostics.Debug.WriteLine($"{ans} {x} {y}");

			ans = Mod(ans - x - y, mod);
			System.Diagnostics.Debug.WriteLine($"{ans}");
			Console.WriteLine(ans);
		}

		#region 逆元(拡張Euclidの互除法) long ModInv(long a, long mod)
		static long ModInv(long a, long m)
		{
			long b = m, x = 1, y = 0;
			while (b > 0) {
				long t = a / b;
				a = Mod(a, b);
				x = x - t * y;
				(a, b) = (b, a);
				(x, y) = (y, x);
			}
			x = Mod(x, m);
			return x;
		}
		#endregion

		#region 繰り返し二乗法 long ModPow(long x, long y, long mod)
		static long ModPow(long x, long y, long mod)
		{
			long result = 1;
			while (y > 0) {
				if (y % 2 != 0) {
					result = Mod(result * x, mod);
				}
				x = Mod(x * x, mod);
				y /= 2;
			}
			return result;
		}
		#endregion

	}
}


Measured memory_bytes: 28248
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    H, N = MI()
    A = LI()

    for i in range(N):
        H -= A[i]

    print(YN[H <= 0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 54352
# !/usr/bin python3
# -*- coding: UTF-8 -*-

s = input()
t = input()

s_asc = ''.join(sorted(s))
t_desc = ''.join(sorted(t, reverse=True))

# sorted()で辞書順に並べ替える。リスト型の結果が返るため、
# join()メソッドでつなぐ
 
if s_asc < t_desc:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, d, e, x;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    string s;
    cin >> n >> s;
    rep(i, 0, n) {
        if (s[i] == '(') d++;
        else {
            d--;
            if (d < 0) {
                d = 0;
                e++;
            }
        }
    }
    rep(i, 0, e) cout << "(";
    cout << s;
    rep(i, 0, d) cout << ")";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define prinrynl(a) printf(a ? "yes\n" : "no\n")
#define prinryn(a) printf(a ? "Yes\n" : "No\n")
#define prinrYN(a) printf(a ? "YES\n" : "NO\n")
#define prinrin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)
#define all(x) (x).begin(), (x).end()

using ll = long long;

const int INF = 2147483647;
const ll LINF = ll(9223372036854775807);
const ll MOD = 1000000007;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;

int ggd(int number1, int number2) {
	int m = number1;
	int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}

	while (m != n) {
		int temp = n;
		n = m - n;
		m = temp;
	}

	return m;
}

int lcm(int number1, int number2) {
	return number1 * number2 / ggd(number1, number2);
}

bool is_prime(int64_t x) {
	for (int64_t i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

/*-----------------------------------------ここまでライブラリとか-----------------------------------------*/



int main() {

	int a, b, c, x, ans = 0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	rep(i, a + 1){
	  rep(j, b + 1){
	    rep(l, c + 1){
	      if(x == 500 * i + 100 * j + 50 * l)++ans;
			}
		}
	}
printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256