akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

    int lines, i, j, arrayKeep;
    int[] sqnc;

    public void sort(){
        for(i = 1; i < lines; i++){
            int key = sqnc[i];
            j = i-1;
            while(j>=0 && sqnc[j] > key){
                sqnc[j+1] = sqnc[j];
                j--;
                sqnc[j+1] = key;
            }
            System.out.println(stringOut(sqnc));
        }
    }

    public String stringOut(int[] input){
        String out = "";
        for(arrayKeep = 0; arrayKeep <lines-1;arrayKeep++){
            out = out + input[arrayKeep]+" ";
        }
        out += input[lines-1];
        return out;
    }

    public void run(){

        Scanner sc = new Scanner(System.in);
        lines = sc.nextInt();
        sqnc = new int[lines];
        for(i=0;i<lines;i++){
            sqnc[i] = sc.nextInt();
        }
        System.out.println(stringOut(sqnc));
        sort();
    }

    public static void main(String[] args){
        new Main().run();
    }
}


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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
const double pi = acos(-1.0);

// servetime T-0.5
// cannot same order!!!!!!!!!!!!!!!!!!!!11
// A[i] minutes, B[i] deliciousness

int n;
int t;
pair<int,int>ab[3010];
ll dp[3010]; // ={cost}

// [0->idx] last start < t

int main(){
  cin>>n>>t;
  rep(i,0,n){
    scanf("%d %d",&ab[i].first,&ab[i].second);
  }
  // sort by time
  sort(ab,ab+n);
  ll ans = 0;
  ll maxlast = 0;
  rep(idx,0,n){
    ans=max(ans,maxlast+ab[idx].second);
    per(i,1,t){
      if(ab[idx].first > i)continue;
      dp[i]=max(dp[i],dp[i-ab[idx].first]+ab[idx].second);
      maxlast=max(maxlast,dp[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest
{
    class ABC_096_C_GridSearch
    {
        static int whiteNo = 0;
        static int blackNo = -1;

        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int h = int.Parse(input[0]);
            int w = int.Parse(input[1]);
            int[,] array = new int[h, w];

            for (int i = 0; i < h; i++)
            {
                string input2 = Console.ReadLine();
                for (int j = 0; j < w; j++)
                {
                    if (input2[j] == '.')
                    {
                        array[i, j] = whiteNo;
                    }
                    else
                    {
                        array[i, j] = blackNo;
                    }
                }
            }

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    if (array[y, x] != blackNo) continue;
                    if (!CanWrite(x, y, w, h, array))
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
        //十字探索
        static bool CanWrite(int x, int y, int w, int h, int[,] array)
        {
            for (int nY = y - 1; nY <= y + 1; nY += 2)
            {
                if (nY < 0 || h <= nY) continue;
                if (array[nY, x] == blackNo) return true;

            }
            for (int nX = x - 1; nX <= x + 1; nX += 2)
            {
                if (nX < 0 || w <= nX) continue;
                if (array[y, nX] == blackNo) return true;
            }
            return false;
        }
    }
}

Measured memory_bytes: 11092
def iroha(n):
    flag = False
    tmp = list(map(int, list(set(list(str(n))))))
    for i in tmp:
        if D.count(i) != 0:
            return flag
    flag = True
    return flag


N, K = map(int, input().split())
D = list(map(int, input().split()))
while True:
    if iroha(N):
        break
    N += 1
print(N)


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

int main(){
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b) cout << "0" << '\n';
	else if (a == b) cout << "1" << '\n';
	else{
		if (n == 1) cout << "0" << '\n';
		else cout << (n - 2) * (b - a) + 1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-a-b < 0) cout << "No\n";
  else if(4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}



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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;

int w, h;
vvi field;
vvi memo;

int solve(int y, int x)
{
	if(memo[y][x] != -1)
		return memo[y][x];
	
	memo[y][x] = 0;
	if(field[y][x] == 1)
		return 0;
	if(y == 0)
		return memo[y][x] = 1;
	
	const int dx[] = {-1, 0, 1};
	rep(i, 3){
		int px = x + dx[i];
		if(px<0 || w<=px || field[y-1][px]!=0 || (field[y][x]==2 && dx[i]!=0))
			continue;
		memo[y][x] += solve(y-1, px);
	}
	
	if(y>=2 && field[y-2][x] == 2)
		memo[y][x] += solve(y-2, x);
	return memo[y][x];
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		field.assign(h, vi(w));
		memo.assign(h, vi(w, -1));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);

		int sum = 0;
		rep(i, w){
			sum += solve(h-1, i);
			if(h>=2 && field[h-2][i] == 2)
				sum += solve(h-2, i);
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int sumDigit(int n);

int main()
{
  int N, A, B;
  std::cin >> N >> A >> B;
  
  int ans = 0;
  for (int n = 1; n <= N; n++)
  {
    int sum = sumDigit(n);
    if (A <= sum && sum <= B)
      ans += n;
  }
  
  std::cout << ans;
  
  return 0;
}

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

Measured memory_bytes: 3200
import numpy as np

I=np.array(input().split(),dtype=np.int32)

M=I[0]
D=I[1]

count=0

def check(d,m):
    d10=int(d[0])
    d1=int(d[1])
    if(d10>=2 and d1>=2 and m==d10*d1):
        return True
    return False

for m in range(1,M+1):
    for d in range(22,D+1):
        if(check(str(d),m)):
            count+=1

print(count)

Measured memory_bytes: 21648
#include <iostream>
#include <cstdint>
#include <vector>

int main() {
	int64_t n;
	std::cin >> n;

	std::vector<int64_t> a(n);
	for (auto&& e : a)
		std::cin >> e;

	int64_t manipSum = 0;
	int64_t count = 0;
	do {
		manipSum = 0;
		for (auto&& e : a)
			manipSum += e / n;

		for (auto&& e : a) {
			auto tmp = manipSum - e / n;

			e %= n;
			e += tmp;
		}
		
		count += manipSum;
	} while (manipSum != 0);

	std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  uintmax_t res = 0;
  int cur = 0;
  for (size_t il = 0, ir = 0; il < n; ++il) {
    while (ir < n && (cur & a[ir]) == 0) {
      cur |= a[ir++];
    }
    res += ir-il;
    if (il+1 < n) {
      if (il == ir) ++ir;
      cur ^= a[il];
    }
  }

  printf("%ju\n", res);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <queue>

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

using namespace std;

typedef pair<long long, int> P;

struct E{
	int b, d;
};

int n, m, c;
vector<E> g[(int)1e5];
long long h[(int)1e5];
long long t[(int)1e5];

int main(){
	scanf("%d%d%d", &n, &m, &c);

	rep(i, m){
		int a, b, d;
		scanf("%d%d%d", &a, &b, &d);
		--a;
		--b;
		g[a].push_back(E{b, d});
		g[b].push_back(E{a, d});
	}

	fill(h, h + n, 3e10);

	priority_queue<P, vector<P>, greater<P>> q;
	h[0] = 0;
	q.push(P(0, 0));
	while(!q.empty()){
		auto v = q.top();
		q.pop();
		if(v.first > h[v.second]){
			continue;
		}
		for(auto& x: g[v.second]){
			if(h[v.second] + x.d < h[x.b]){
				h[x.b] = h[v.second] + x.d;
				q.push(P(h[x.b], x.b));
			}
		}
	}

	long long s = 0;
	rep(i, n){
		for(auto& x: g[i]){
			if(i < x.b){
				if(h[i] >= h[x.b]){
					t[i] += x.d;
				}
				else{
					t[x.b] += x.d;
				}
				s += x.d;
			}
		}
	}

	std::vector<pair<long long, long long>> v;
	rep(i, n){
		v.push_back({h[i], t[i]});
	}
	stable_sort(v.begin(), v.end());

	rep(i, n){
		if(i != 0){
			v[i].second += v[i - 1].second;
		}
	}

	long long result;
	rep(i, n){
		if(i == 0 || result > v[i].first * c + s - v[i].second){
			result = v[i].first * c + s - v[i].second;
		}
	}
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 16500
#include <iostream>
#include <map>

using namespace std;

int main() {
  int N;
  cin >> N;
  int result[10000+10];
  for (int i = 0; i < 10010; i++) result[i] = 0;
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int n = x*x + y*y + z*z + x*y + y*z + z*x;
        if (n < 10010) result[n]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << result[i] << endl;
  }
}


Measured memory_bytes: 3536
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  string S[N];
  rep(i, N){
    cin >> S[i];
  }
  bool can = true;
  rep(i, N){
    for(int j=i+1; j<N; j++){
      if(S[i]==S[j]) {can = false;}
    }
  }
  rep(i, N-1){
    int T = S[i].size();
    if(S[i][T-1] != S[i+1][0]) {can = false; }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
  int N,i,all_xor_flag,sum=0;
  scanf("%d", &N);
  int a[N];
  for(i = 0; i < N; i++){
    scanf("%d", &a[i]);
    sum = sum^a[i];
  }
  if(!sum){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  /*
  std::sort(a, a+N);

  do{
    all_xor_flag = 1;
    for(i = 0; i < N; i++){
      if((a[(N+i-1)%N]^a[(N+i+1)%N])!=a[i]){
	all_xor_flag = 0;
	break;
      }
    }
    if(all_xor_flag){
      printf("Yes\n");
      return 0;
    }
  }while(next_permutation(a+1, a+N));
  
  printf("No\n");
  */
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin>>N;
	vector<int> dams(N);
	ll sum = 0, mids = 0;
	rep(i,N){
		cin>>dams[i];
		sum += dams[i];
		if(i % 2 == 0 && i != N-1)mids += dams[i];
	}
	vector<ll> ans(N,-1);
	ans[N-1] = sum-2*mids;
	for(int i = N-1; i>0; --i){
		ans[i-1] = (dams[i-1] - ans[i]/2)*2;
	}
	show(ans);
	return 0;
}

Measured memory_bytes: 2432
n = int(input())
a = list(map(int, input().split()))

s = a[0]
t = sum(a) - a[0]

ans = abs(s - t)
for i in range(1, n - 2):
    s += a[i]
    t -= a[i]
    ans = min(ans, abs(s - t))

print(ans)

Measured memory_bytes: 23800
#https://atcoder.jp/contests/abc144/tasks/abc144_d
import math
a, b, x = list(map(int,input().split()))
s = x/a
if s <= b*a/2:
    y = 2*s/b
    l = y**2/(math.sqrt(y**2 + b**2))
    print(math.degrees(math.acos(l/y)))
elif b*a/2 < s <= a*b:
    #(b+y)*a/2 = s
    y = (2*s)/a-b
    c = (s-a*y)*2/a
    print(math.degrees(math.atan(c/a)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string n;
    string as="+";
    string bs="+";
    string cs="+";
    cin >> n;
    vector<int> num(4);
    vector<int> a(2);
    vector<int> b(2);
    vector<int> c(2);
    for(int i=0;i<4;i++){
        num[i]=stoi(n.substr(i,1));
    }
    a[0]=num[1];
    a[1]=num[1]*(-1);
    b[0]=num[2];
    b[1]=num[2]*(-1);
    c[0]=num[3];
    c[1]=num[3]*(-1);
    int ansa;
    int ansb;
    int ansc;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                if(num[0]+a[i]+b[j]+c[k]==7){
                    ansa = a[i];
                    ansb = b[j];
                    ansc = c[k];
                }
            }
        }
    }
    if(ansa<0){
        as="";
    }
    if(ansb<0){
        bs="";
    }
    if(ansc<0){
        cs="";
    }
    cout << num[0] << as << ansa << bs << ansb << cs << ansc << "=7" <<endl;
}

Measured memory_bytes: 256
import math
import itertools
N=int(input())
s = [list(map(int, input().split())) for _ in range(N)]
x=[]
y=[]
for i in s:
    x.append(i[0])
    y.append(i[1])

r_sum=[]
for i in range(N):
    r_=[]
    for j in range(N):
        r=0
        r=math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
        r_.append(r)
    r_sum.append(r_)
#print('---')
#print(r_sum)

r_1 = list(itertools.permutations(range(N)))
r_1_cnt = len(r_1)
#print('---')
#print(r_1)

result=0
for i in r_1:
    for j in range(N-1):
        result+=r_sum[i[j]][i[j+1]]
print(result/r_1_cnt)

Measured memory_bytes: 8052
import numpy as np
s=input()
n=len(s)
MOD=1000000007
wayA=np.array([0,0,0,0],dtype=np.int64)
wayB=np.array([0,0,0,0],dtype=np.int64)
wayC=np.array([0,0,0,0],dtype=np.int64)
MOD2=np.array([MOD,MOD,MOD,MOD],dtype=np.int32)
hatena=0
for c in s:
	if c=="A":
		wayA[0]+=1
	if c=="B":
		wayB+=wayA
	if c=='C':
		wayC+=wayB
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena+=1
	wayA%=MOD2
	wayB%=MOD2
	wayC%=MOD2
ans=0
for i in range(0,4):
	p3=1
	for k in range(0,hatena-i):
		p3=p3*3
		p3=p3%MOD
	ans=ans+p3*wayC[i]
	ans=ans%MOD
print(int(ans))

Measured memory_bytes: 21408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  int h, w, hh, ww, ans = 0;

  if(scanf("%d %d %d %d", &h, &w, &hh, &ww) == 1);


  printf("%d", (h - hh) * (w - ww));

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

ll x[1000000],n;
vector<vector<ll>> vec(200007);

void dfs(ll a) {
	for (int i = 0; i < vec[a].size(); i++) {
		ll b = vec[a][i];
		x[b] += x[a];
		dfs(b);
	}
	return;
}

int main() {
	ll q,a,b;
	cin >> n>>q;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		vec[a].push_back(b);
	}
	for (int i = 0; i < q; i++) {
		cin >>a >> b;
		x[a] += b;
	}
	dfs(1);
	for (int i = 1; i <= n; i++) {
		cout << x[i] << endl;
	}
}




Measured memory_bytes: 21120
#include <iostream>
#include <cstring>
using namespace std;
int main() {
    char s[201], p[101];
    cin >> s >> p;
    int slen = strlen(s);
    for(int i = 0; i < strlen(p) - 1; ++i) {
        s[slen + i] = s[i];
    }
    s[slen + strlen(p) - 1] = '\0';
    if(strstr(s, p)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string S;
ll N,Q;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

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

    cin >> N >> S >> Q;

    vector<BIT> ls;
    for (int i = 0;i < 26;i++){
        BIT tmp(N+5);
        ls.push_back(tmp);
    }

    for (int i = 0;i < N;i++){
        ls[S[i]-'a'].add(i+1,1);
    }

    for (int q = 0;q < Q;q++){
        ll typ; cin >> typ;
        if(typ == 1){
            ll idx; cin >> idx;
            char c; cin >> c;
            ls[S[idx-1]-'a'].add(idx,-1);
            ls[c-'a'].add(idx,1);
            S[idx-1] = c;
        }else{
            ll l,r; cin >> l >> r;
            ll cnt = 0;
            for (int i = 0;i < 26;i++){
                if(ls[i].sum(r)-ls[i].sum(l-1) > 0) cnt++;
            }
            cout << cnt << endl;
        }
    }

    return 0;

}

Measured memory_bytes: 53624
from collections import Counter
N, K = map(int,input().split())
A = list(map(int,input().split()))
i = k = 0
B = [1]
while k <= N:
    i = A[i] - 1
    B.append(i + 1)
    k += 1
S = Counter(B)
idx = S.most_common(1)[0][0]
i = k = cnt = 0
k_s = None
while k < N:
    if B[k] == idx and cnt == 1:
        k_s = k
        break
    elif B[k] == idx:
        k_f = k
        cnt += 1
    k += 1
if k_s and k_s < K:
    k_max = (K - B.index(idx)) % (k_s - k_f) + B.index(idx)
else:
    k_max = K
i = k = 0
while k < k_max:
    i = A[i] - 1
    k += 1
print(i + 1) 

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

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

int main(){
  int h,w;
  while(1){
    cin >> h >> w;
    if(h==0 && w==0)break;
    rep1(i,h){
      rep1(j,w){
        if((i%2==1 && j%2==1)||(i%2==0 && j%2==0))cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

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

  while(A >= 0 && C >= 0) {
    C -= B;
    if(C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3132
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

x,y = Mi()
if y%2 == 1:
  print('No')
  exit(0)
  
y = y//2

if x <= y <= 2*x:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9124
// BuildStairs
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;

#define ll long long int

int main() {
	//fastIO

	ll n;
	cin >> n;

	ll arr[n];
	for (int i = 0 ; i < n ; i++)
	{
		cin >> arr[i];
	}


	for (int i = n - 1; i >= 1; i--)
	{

		if (arr[i] < arr[i - 1])
		{
			if (arr[i] < arr[i - 1] - 1)
			{
				cout << "No";
				return 0;
			} else
			{
				arr[i - 1] = arr[i - 1] - 1;
			}
		}
	}
	cout << "Yes";


	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i, n) for (ll i = 0; i < n; i++)

using namespace std;

int main()
{
  int r, d, x;
  cin >> r >> d >> x;

  REP(i, 10)
  {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
const int N=2e5+5;
int n,ans,ab=1,a[N*5][26],b[N*5];
vector<int> v[N];
string s[N];
void add(string t,int k){
	int x=0;
	for(int i=0;i<t.size();i++){
		v[k].push_back(x);
		if(a[x][t[i]-'a']==0)
			a[x][t[i]-'a']=ab++;
		x=a[x][t[i]-'a'];
	}
	b[x]++;
}
int main(){
	n=read();
	for(int i=0;i<n;i++)
		cin >> s[i];
	for(int i=0;i<n;i++){
		reverse(s[i].begin(),s[i].end());
		add(s[i],i);
	}
	for(int i=0;i<n;i++){
		set<int> st;
		for(int j=s[i].size()-1;j>=0;j--){
			int x=v[i][j];
			st.insert(s[i][j]-'a');
			for(int c=0;c<26;c++)
				if(st.find(c)!=st.end() and b[a[x][c]])
					ans++;
		}
	}
	cout << ans-n;
	return 0;
}

Measured memory_bytes: 126028
open Big_int;;

let () =
  let n = read_int () in
  let rec read = function
      0 -> ()
     | i -> let first = read_line () |> String.trim and
                second = read_line () |> String.trim in
            let result =
              if String.length first > 80 || String.length second > 80 then
                "overflow"
              else
                let first_int = big_int_of_string first and
                    second_int = big_int_of_string second in
                let sum = add_big_int first_int second_int |> string_of_big_int in
                if String.length sum > 80 then "overflow" else sum
            in
            print_endline result; read (i-1)
  in read n;;

Measured memory_bytes: 2228
#include <iostream>
#include <queue>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    priority_queue<int> pq;
    while(N--) {
        int A;
        cin >> A;
        pq.emplace(A);
    }
    while(M--) {
        int tmp = pq.top();
        pq.pop();
        pq.emplace(tmp/2);
    }

    int64_t ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

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


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

int main(){
	int n,a[25];
	while(cin >> n,n){
		memset(a,0,sizeof(a));
		for(int i = 0;i < n;i++){
			cin >> a[i];
		}
		//ツ暗ェツ郎ツづ個づつォツづ控RUEツ，ツ篠淞郎ツづ個づつォツづ孝ALSE
		bool turn = true;
		int i = 0,sum = 32;;
		while(sum != 0){
			if(turn)sum -= ((sum - 1) % 5);
			else{sum -= a[i++ % n];}
			if(sum < 0)sum = 0;
			cout << sum << endl;
			turn = !turn;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#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;}

using pi = pair<int,int>;

const int INF = 1000000010;

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

    set<pi> s;
    s.insert({0,0});
    rep(i,n){
        int x;
        scanf(" %d", &x);

        // printf(" ---- %d\n", i);
        // for(const auto p:s) dbg(p);

        auto itr = s.lower_bound({x,INF});
        if(itr == s.begin()){
            printf("No\n");
        }
        else{
            printf("Yes\n");

            --itr;
            pi range = *itr;
            s.erase(itr);

            int l,r;
            if(range.fi<=x && x<=range.se){
                l = range.fi;
                r = x-1;
                if(l<=r) s.insert({l,r});

                l = x+1;
                r = range.se;
                if(l<=r) s.insert({l,r});
            }
            else{
                assert(range.se<x);

                l = range.fi;
                r = range.se-1;
                if(l<=r) s.insert({l,r});

                l = range.se+1;
                r = x;
                if(l<=r) s.insert({l,r});
            }
        }
    }
    return 0;
}



Measured memory_bytes: 10728
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));
$cArray = explode(" ", trim(fgets(STDIN)));
$sum = 0;
for($i = 0; $i < $n; $i++){
    $sum += max($vArray[$i] - $cArray[$i], 0);
}
echo $sum;


Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[2][1200][1200];
int main(){
  memset(dp,-1,sizeof(dp));
  int x,y,n;
  cin>>n>>x>>y;
  dp[0][x+600][y+600]=0;
  r(i,n){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    r(A,1200)r(B,1200){
      if(~dp[i%2][A][B]){
        dp[(i+1)%2][A][B]=max(dp[(i+1)%2][A][B],dp[i%2][A][B]);
        dp[(i+1)%2][A-a][B+b]=max(dp[(i+1)%2][A-a][B+b],dp[i%2][A][B]);
        dp[(i+1)%2][A][B-c]=max(dp[(i+1)%2][A][B-c],dp[i%2][A][B]+d);
      }
    }
    r(j,1200)r(k,1200)dp[i%2][j][k]=-1;
  }
  int ans=0;
  r(i,1200)r(j,1200){
    if(i>=600&&j>=600){
      ans=max(ans,dp[n%2][i][j]);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 14356
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [i64; n],
    }

    let s: i64 = aa.iter().sum();
    let mut left = 0;
    let mut ans: i64 = 1<< 60;
    for i in 0..n {
        left += aa[i];
        let right = s - left;
        ans = min(ans, (right - left).abs())
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 80; 
const ll MOD = 1e9 + 7;
struct matrix{
	int n;
	ll v[MAXN][MAXN];
	matrix(int _n = 0){
		n = _n;
		memset(v, 0, sizeof(v));
	}
	matrix operator * (matrix m){
		matrix ans = matrix(n);
		for(int i = 1; i <= n; i++){
			for(int j = 1;  j <= n; j++){
				for(int k = 1; k <= n; k++){
					ans.v[i][j] += v[i][k]*m.v[k][j];
					ans.v[i][j] %= MOD;
				}
			}
		}
		return ans;
	}
};

matrix T;
int n;
matrix fexp(ll k){
	matrix ans = matrix(n);
	for(int i = 1; i <= n; i++) ans.v[i][i] = 1;
	for(int i = 62; i >= 0; i--){
		ans = ans*ans;
		if(k&(1LL<<i)){ 
			// for(int i = 1; i <= n; i++){
			// 	for(int j = 1; j <= n; j++){
			// 		printf("%lld ", ans.v[i][j]);
			// 	}
			// 	printf("\n");
			// }
			ans = ans*T;
			
		}
	}
	return ans;
}
ll k;
int main(){
	scanf("%d %lld", &n, &k);
	T = matrix(n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			scanf("%lld", &T.v[i][j]);
		}
	}
	matrix a = fexp(k);
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			//printf("%lld ", a.v[i][j]);
			ans += a.v[i][j];
			ans%=MOD;
		}
		//printf("\n");
	}
	printf("%lld\n", ans);
}

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

int main(){
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    for(int i=a; i<=b; ++i){
        if(i%k==0){
            cout << "OK" << "\n";
            return 0;
        }
    }
    cout << "NG" << "\n";
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;


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

	string s;
	cin >> s;
	bool bad = false;

	for(int i = 0; i < 3; i++){
		if(s[i] == s[i + 1]){
			bad = true;
			break;
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		int tmp=sqrt((long long)a*b);
		if((long long)tmp*(tmp+1)<(long long)a*b)
		{
			cout<<tmp*2-1<<endl;
			continue;
		}
		int ans=(tmp-1)*2;
		if((long long)tmp*tmp==(long long)a*b&&a!=b)
			--ans;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,l[3000],cnt[2010] = {};
	cin >> n;
	for(int i = 0;i < n;i++) cin >> l[i];
	int ans = 0;
	for(int i = n - 1;i >= 0;i--){
		for(int j = 0;j < i;j++){
			ans += cnt[l[i] + l[j] - 1] - cnt[abs(l[i] - l[j])];
		}
		for(int j = l[i];j < 2010;j++) cnt[j]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# 写経
N, M = map(int, input().split())


sw = []
for i in range(M):
    k, *s = map(int, input().split())
    sw.append(s)


p = list(map(int, input().split()))


ans = 0
# スイッチの状態を N bit の二進数で表現する
for bit in range(2 ** N):
    flag = False
    # 電球につながってるスイッチを調べる
    for m in range(M):
        cnt = 0
        for s in sw[m]:
            if (1 << (s - 1)) & bit:
                cnt += 1
        if cnt % 2 == p[m]:
            continue
        else:
            flag = True
            break
    if not flag:
        ans += 1


print(ans)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


inline int popCount(unsigned int x) {
	x = x - ((x >> 1) & 0x55555555);
	x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
	x = (x + (x >> 4)) & 0x0F0F0F0F;
	x = x + (x >> 8);
	x = x + (x >> 16);
	return x & 0x0000003F;
}

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

	string s;
	cin>>s;

	int st=0;
	int last=-1;
	unordered_map<int,int> mp;
	mp.reserve(s.size());
	mp[0] = 0;

	for (char c : s){
		int minv=INF;
		st ^= 1 << (c-'a');

		auto it = mp.find(st);
		if (it != mp.end())minv = min(minv, it->second + 1);
		rep(i,26){
			it = mp.find(st ^ (1<<i));
			if (it != mp.end())
				minv = min(minv, it->second + 1);
		}

		
		if (minv != INF){
			it = mp.emplace(st, minv).first;
			it->second = min(it->second, minv);
		}
		last = minv;
	}

	cout<<last<<endl;


	return 0;
}

Measured memory_bytes: 8340
main :: IO ()
main = do
  n <- getLine
  hn <- map (read :: String -> Int) . words <$> getLine
  print $ ans hn

ans :: [Int] -> Int
ans (x:xs) = (\(a,b,_) -> max a b) $ foldl func (0,0,x) xs where
  func (m,n,e) k = if e >= k then (m,n+1,k)
    else if m >= n then (m,0,k) else (n,0,k)

Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
ll const MOD=1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<pair<int,int>>W(N);
    int a,b;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        W[i]=make_pair(b,a);
    }
    sort(ALL(W));
    ll count=0;
    for(int i=0;i<N;i++){
        count+=W[i].second;
        if(W[i].first<count){cout<<"No"<<endl;exit(0);}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int n[26] = {}, i, t;
	char c;

	do
	{
		t = 0;
		while( cin.get(c) )
		{
			if( c == '\n' )
				break;

			if( 'a' <= c && c <= 'z')		++n[c - 'a'];
			else if( 'A' <= c && c <= 'Z')	++n[c - 'A'];
			++t;
		}
	}while( 0 != t );

	for(i = 0; i < 26; ++i)
		cout << char(i + 'a') << " : " << n[i] << "\n";

	return 0;
}

Measured memory_bytes: 1128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int n;
	char str1[5] = { '.', ',', '!', '?', ' '};
	char strtop[8] = { 'a', 'd', 'g', 'j', 'm', 'p', 't', 'w' };
	cin >> n;

	REP(i, 0, n) {
		string str;
		cin >> str;
		int cnt = 0;
		char prev = '0';
		REP(j, 0, str.size()) {
			char sub = str[j];
			if (sub == prev && sub == '0') {
				continue;
			}
			else if (sub == prev) {
				cnt++;
			}
			else if (sub == '0') {
				if (prev == '1') cout << str1[cnt % 5];
				else if (prev == '7' || prev == '9') cout << (char)(strtop[(prev - '0')-2] + (cnt % 4));
				else cout << (char)(strtop[(prev - '0') - 2] + (cnt % 3));
				cnt = 0;
			}

			prev = sub;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3144
N,M,X=map(int,input().split())
A=list(map(int,input().split()))

A_=[0]*(N+1)
for a in A:
    A_[a]=1
ans1=0
for a in A_[X+1:]:
    if a==1:
        ans1+=1
ans2=0
for a in reversed(A_[:X]):
    if a==1:
        ans2+=1

print(min(ans1,ans2))

Measured memory_bytes: 3064
//
//  ALDS1_1_D.cpp
//  
//
//  Created by mk on 2015/11/22.
//
//

#include <stdio.h>
#include <iostream>
using namespace::std;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    
    long min_value = 10000000000;
    long max_benefit = -1;
    long min_benefit = -10000000000;
    long value;
    long benefit;
    int plus_flg = 0;
    for (int i=0; i<n; i++) {
        cin >> value;
        if (value < min_value) {
            
            if (min_benefit < value - min_value) {
                min_benefit = value - min_value;
            }
            min_value = value;
        }else{
            benefit = value - min_value;
            if (benefit > max_benefit) {
                max_benefit = benefit;
            }
            plus_flg = 1;
        }
    }
    if (plus_flg == 0) {
        max_benefit = min_benefit;
    }
    cout << max_benefit <<endl;
    return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int( 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong


signed main(){
    int n,m;
    cin >> n >> m;
    int num[MAX],red[MAX];
    REP(i,n+1) num[i] = 1;
    red[1] = 1;
    int in,out;
    REP(i,m){
        scanf("%lld%lld",&out,&in);

        if(red[out]){
            red[in] = 1;
            if(num[out] == 1){
                red[out] = 0;
            }
        }

        num[out]--;
        num[in]++;
    }
    int res = 0;
    FOR(i,1,n+1) if(red[i]) res ++;
    cout << res << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
int des(const void* a, const void* b) { return *(int*)b - *(int*)a;}
int main(){
 int n,a[100009]={0},md=1e9;
 scanf("%d",&n);
 rep(i,n)scanf("%d",a+i);
 qsort(a,n,sizeof(int),des);
 if(n==2)md=a[1];
 else rep(i,n)if(a[0]/2>a[i]){md=(a[i-1]-a[0]/2<=a[0]/2-a[i]?a[i-1]:a[i]);break;}
 printf("%d %d",a[0],md);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
int main(){
  double n;
  cin>>n;
  set<double>ss;
  vector<pair<double,P> >v;
  for(double a=1;a<=3500;a++){
    for(double b=a;b<=3500;b++){
      double t=1.0/a+1.0/b;
        v.push_back(mk(t,mk(a,b)));
    }
  }
  sort(v.begin(),v.end());
  //cout<<v.size()<<endl;
  //cout<<v[v.size()-2].first<<endl;
  for(double a=1;a<=3500;a++){
    int l=0,r=v.size();
    while(l<r){
      int mid=(l+r)/2;
      if(abs((4.0/n)-(v[mid].first+1.0/a))<0.00000000000001){
        cout<<a<<' '<<v[mid].second.first<<' '<<v[mid].second.second<<endl;
         return 0;
      }
      if(v[mid].first+1.0/a>(4.0/n))r=mid;
      else l=mid+1;
    }
  }
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int T, X;
    cin >> T >> X;

    double ans = double(T) / double(X);
    printf("%.5f\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	var N int
	fmt.Scan(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	h := make([]int, N)
	x := make([]int, N)
	for i := range h {
		sc.Scan()
		h[i], _ = strconv.Atoi(sc.Text())
		x[i] = h[i]
	}
	sort.Ints(h)
	for i := 0; i < N; i++ {
		if h[N/2] > x[i] {
			fmt.Println(h[N/2])
		} else {
			fmt.Println(h[N/2-1])
		}
	}
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include<string>
#define llI long long int
using namespace std;

 int main()
 {
   long long int N,sum=0,max;
   cin>>N;
   vector<long long int> ques(N);
  
  max=ques[0];
   for(long long int i=0;i<N;i++)
   {
       cin>>ques[i];
   } 
   for(int i=0;i<N;i++)
   {
       if(ques[i]>=max)
       {
           max=ques[i];
           continue;
       }
       else
       {
           sum=sum+(max-ques[i]);
       }
   }
 
  
  cout<<sum;
   return 0;
   
 }

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


int main()
{
  string s;
  cin >> s;
  int ans = 0, l = 0, r = s.length() - 1;
  while (l < r)
  {
    if (s[l] != s[r])
      ans++;
    l++;
    r--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int N = scanner.nextInt();
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += scanner.nextInt();
    }
    if (sum >= H) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 49144
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll ans = 0;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	ll mini = arr[0];
	for (int z=0;z<n;z++){
		if (arr[z] > mini) continue;
		ans ++;
		mini = arr[z];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 500002
 
typedef struct{
  int p;
  int l;
  int r;
  int k;
}Node;
 
Node node[N],ex;
int n,i;
 
void maxHeapify(int i){
  int l = 2*i, r = 2*i+1, largest;
  
  if(l <= n && node[l].k > node[i].k){
    largest = l;
  }else{
    largest = i;
  }
  if(r <= n && node[r].k > node[largest].k){
    largest = r;
  }
  if(largest != i){
    ex = node[i];
    node[i] = node[largest];
    node[largest] = ex;
    maxHeapify(largest);
  }
}
 
void buildMaxHeap(){
  for(i = n/2; i > 0; i--){
    maxHeapify(i);
  }
}
 
int main(){
  scanf("%d",&n);
  
  for(i = 1; i < n+1; i++){
    scanf("%d",&node[i].k);
  }
  
  for(i = 1; i < n+1; i++){
    if(i == 1){
      node[i].p = -1;
    }else{
      node[i].p = i/2;
    }
    if(2*i > n){
      node[i].l = node[i].r = -1;
    }else{
      node[i].l = 2*1;
    }
    if(2*i+1 > n){
      node[i].r = -1;
    }else{
      node[i].r = 2*i+1;
    }
  }
  
  buildMaxHeap();
  
  for(i = 1; i < n+1; i++){
    printf(" %d", node[i].k);
  } 
  printf("\n");
  return 0;
}

Measured memory_bytes: 8412
#include<stdio.h>
#include<stdlib.h>
int main(void){
	long long n;
	char *s;
	long long x = 0;
	long long r = 0;
	long long g = 0;
	long long b = 0;
	scanf("%lld", &n);
	s = (char *)malloc(sizeof(char) * (n+1));
	scanf("%s", s);
	for(int i=0; i<n; i++){
		if(s[i] == 'R'){
			r++;
		}
		else if(s[i] == 'G'){
			g++;
		}
		else if(s[i] == 'B'){
			b++;
		}
	}
	x += r*g*b;
	for(int j=0; j<n-2; j++){
		for(int k=1; k<n; k++){
			if(j+k+k < n){
				if(s[j] != s[j+k] && s[j] != s[j+k+k] && s[j+k] != s[j+k+k]){
					x--;
				}
			}
		}
	}
	printf("%lld\n", x);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	for(long long i=sqrt(n);i>=1;i--){
		if(n%i==0){
			printf("%lld\n",i+n/i-2);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char a[100],b[100];
int main(){
	cin>>a>>b;
	if(strlen(a)>strlen(b)){
		for(int i=0;a[i]!=0;i++){
			cout<<a[i];
			if(b[i]) cout<<b[i];
		}
	}else {
		for(int i=0;b[i]!=0;i++){
			if(a[i]) cout<<a[i];
			cout<<b[i];	
		}
	}
	cout<<endl; 
}

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

using namespace std;

int main(){
    int count=0;
    char S[20];
    scanf("%s",S);
    int l=strlen(S);
    for(int i=0;i<=l-1;i++){
        if(S[i]=='x') count++;
    }
    if(count>=8) printf("NO");
    else printf("YES");
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define loop(i,a,b) for(int i=a;i<(int)b;i++)
int main() 
{
    char ch1,ch2;
    cin>>ch1>>ch2;
    if(ch1=='H' && ch2=='H')
     cout<<'H';
    else
    {
       if(ch1=='H' && ch2=='D')
        cout<<'D';
       else
       {
             if(ch1=='D' && ch2=='H')
               cout<<'D';
             else
             {
                if(ch1=='D' && ch2=='D')
                 cout<<'H';
             }
       }
    }
	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    let mut dec = 0;
    for i in s {
        match i {
            'a' => dec+=1,
            'b' => dec+=10,
            'c' => dec+=100,
             _ => return,
        }
    }

    if dec==111 {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    set<int> dic;
    int N; cin >> N;
    while (N--) {
        int a; cin >> a;
        dic.emplace(a);
    }
    int M; cin >> M;
    while (M--) {
        int b; cin >> b;
        dic.emplace(b);
    }
    for (auto i : dic) cout << i << ln;
}


Measured memory_bytes: 21812
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

#define int long long int

constexpr int INF = std::numeric_limits<int>::max();

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

    double ans = 0;
    while(N--) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000;
        }
    }

    printf("%lf\n", ans);
}

Measured memory_bytes: 256