akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
map <long long,int> w;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    long long ans=0,sum=0;
    cin>>n,w[0]=1;
    for(int i=1;i<=n;i++)
	sum+=gi(),ans+=w[sum],++w[sum];
    cout<<ans;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s.at(i);
  sort(s.begin(), s.end());
  int most = 0, present = 1;
  for (int i = 1; i < n; i++) {
    if (s.at(i) == s.at(i - 1)) {
      present++;
    } else {
      most = max(most, present);
      present = 1;
    }
  }
  most = max(most, present);
  present = 1;
  for (int i = 1; i < n; i++) {
    if (present == most) cout << s.at(i - 1) << "\n";
    if (s.at(i) == s.at(i - 1)) {
      present++;
    } else {
      present = 1;
    }
  }
  if (present == most) cout << s.at(n - 1) << "\n";
}


Measured memory_bytes: 14208
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long int a,b,ans=0;
int main( )
{
	cin>>a>>b;
	ans=a*b;
	if(ans%2==0)
	{
		cout<<"Even"<<endl;
	}
	else
	{
		cout<<"Odd"<<endl;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,q=map(int, input().split())
l=[[] for i in range(n+1)]
ans=[0]*(n+1)

for i in range(n-1):
    a,b=[int(j) for j in input().split()]
    l[a].append(b)
    l[b].append(a)
for i in range(q):
    p,x=[int(j) for j in input().split()]
    ans[p]+=x

que=deque()
que.append(1)
ll=[0]*(n+1)
while que:
    y=que.popleft()
    ll[y]=1
    for i in l[y]:
        if ll[i]==1:
            continue
        ans[i]+=ans[y]
        que.append(i)
print(*ans[1:])

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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
// #define int long long
// const int MAX=1e9;

signed main(){

	int a,b;
	cin>>a>>b;

	cout<<a*a-b<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        //??£?¨?
        int n;          //?????????????????°
        int a[100];     //?????????????????°???
        int i,k;        //????????????
        int count=0;
        int tmp;
        //??°????????\???
        cin>>n;
        for(i=0;i<n;i++){
                cin>>a[i];
        }
        //??????
        for(i=0;i<n;i++){
                for(k=0;k<n-1;k++){
                        if(a[k]>a[k+1]){
                                tmp=a[k];
                                a[k]=a[k+1];
                                a[k+1]=tmp;
                                count++;
                        }
                }
        }
        //??????
        for(i=0;i<n-1;i++){
                cout<<a[i]<<" ";
        }
        cout<<a[n-1];
        cout<<endl<<count<<endl;
        return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=998244353;
const int INF = 1001001001;

int main(){
    int N; cin>>N;
    int i,j,max;
    vector<int> a(N);
    rep(i,N) cin>>a[i];
    int ans = INF;
    rep(i,100){
        int M = 0;
        rep(j,N) M += (a[j]-i-1)*(a[j]-i-1);
        ans = min(ans,M);
    }
    AA(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  int main(){
   char x[1001];
      int i=0;
	  
	  while(scanf("%c",&x[i]) != EOF){
	if(x[i]=='A'){
		x[i]='X';
	}
	else if(x[i]=='B'){
		x[i]='Y';
	}
	else if(x[i]=='C'){
		x[i]='Z';
	}
     else if('D'<=x[i] && 'Z'>=x[i]){
		 x[i] -= 3;
	 }
	 printf("%c",x[i]);
		  i++;
	}
	  
return 0;
}
       

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

int main() {
  int r, b, g;
  cin >> r >> b >> g;
 
  int rbg = r*100 + b*10 + g;
  
  if(rbg%4 != 0){
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
//int a,b,ab;
ll n,sum=0;
int main() {
    cin>>n;
    //cout<<sqrt(n)<<endl;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i!=0)
            continue;
        if(n/i-1LL>=1)
        {   ll k=n/i-1;
            if(n/k==n%k)
            sum+=n/i-1LL;
        }
    }
    cout<<sum;
   return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
from heapq import heappop,heappush,heapify
N,M,S=map(int,input().split())
graph=[[]for _ in range(N)]
for _ in range(M):
  u,v,a,b=map(int,input().split())
  graph[u-1].append((v-1,a,b))
  graph[v-1].append((u-1,a,b))
cd=[tuple(map(int,input().split())) for _ in range(N)]
INF=1e18
S=min(S,2500)
time=[[INF]*2501 for _ in range(N)]
q=[(0,0,S)]
heapify(q)
while q:
  now_time,cur_city,cur_coin=heappop(q)
  for nxt_city,cost,dt in graph[cur_city]:
    if cur_coin>=cost and time[nxt_city][cur_coin-cost]>now_time+dt:
      time[nxt_city][cur_coin-cost]=now_time+dt
      heappush(q,(now_time+dt,nxt_city,cur_coin-cost))
  c,d=cd[cur_city]
  new_coin=min(2500,cur_coin+c)
  nxt_time=now_time+d
  if nxt_time<time[cur_city][new_coin]:
    time[cur_city][new_coin]=nxt_time
    heappush(q,(nxt_time,cur_city,new_coin))
for i in range(1,N):
  print(min(time[i]))

Measured memory_bytes: 26300
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
   
    int main() {
     int a,b;
     cin >> a >> b;
     
     printf("%d %d\n",a*b,(a*2)+(2*b));
     	
     return 0;
    }


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

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long sum[n];
  sum[0] = a[0];
  for (long i = 1; i < n; i++) {
    sum[i] = sum[i-1]+a[i];
  }
  long all = sum[n-1];
  long min = -1;
  for (long i = 0; i < n-1; i++) {
    if (min == -1 || labs(sum[i]*2-all) < min) {
      min = labs(sum[i]*2-all);
    }
  }
  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 3328
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

int main()
{

	ll i, j, k, l, m, flag, N, M, K, H, W, X, P;
	cin >> N;
	int ansst, ansla;
	ansst = 0;
	ansla = 0;
	char S[101];
	cin >> S;
	int right; //right=(
	int left;//left=)
	i = 0;
	right = left = 0;
	k = 0;
	while (i < N) {
		if (S[i] == '(') {
			right++;
		}
		else {
			left++;
		}
		if (i + 1 == N) {
			if (right > left) {
				ansla += right - left;
              
			}
			else {
				ansst += left - right;

			}
          break;
		}
		if (S[i + 1] == '('&&S[i] == ')') {
			if (right > left) {
				//ansla += right - left
              ;
			}
			else {
				ansst += left - right;
              right = 0;
			left = 0;

			}
			
		}
		i++;
	}
	REP(i, 0, ansst) {
		cout << "(";
	}
	REP(i, 0, N) {
		cout << S[i];
	}
	REP(i, 0, ansla) {
		cout << ")";
	}
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector <int> v(3);
	for (int i=0; i<3; i++)
		cin>>v[i];
	sort(v.begin(),v.end());
	if (v[0]+v[1]==v[2]) cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
}


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

int main(){
  long long l[90];
  l[1] = 1;
  l[0] = 2;
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++){
    l[i] = l[i-1] + l[i-2];
  }
  cout << l[n] << "\n";
  return 0;
}


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

int main()
{
    int h;
    int w;
    while(1)
    {
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(int i=0;i<h; i++)
        {
            for(int s=0; s<w; s++)
            {
               if((i+s)%2==0)
                   cout<<"#";
                else
                    cout<<".";
                
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}

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

int main() {
	int a, b, c;
	char ans;
	while (true) {
		cin >> a >> b >> c;
		if (a == -1 && b == -1 && c == -1) break;
		if (a == -1 || b == -1) ans = 'F';
		else if (a + b >= 80) ans = 'A';
		else if (a + b >= 65) ans = 'B';
		else if (a + b >= 50) ans = 'C';
		else if (a + b >= 30 && c >= 50) ans = 'C';
		else if (a + b >= 30) ans = 'D';
		else ans = 'F';
		cout << ans << endl;
	}
}



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

int main() {
	constexpr int INF = 1<<30;
	constexpr int dx[4] = {1, 0, -1, 0};
	constexpr int dy[4] = {0, 1, 0, -1};

	int H, W;
	cin >> H >> W;
	vector<string> S(H, "");
	for(int i=0; i<H; i++) cin >> S[i];
	
	auto bfs = [&](int x, int y){
		int ans = 0;
		vector<vector<int>> dis(H, vector<int>(W, INF));
		queue<pair<int,int>> que;
		que.push({x, y});
		dis[x][y] = 0;
		while(!que.empty()) {
			pair<int,int> v = que.front();
			que.pop();
			for(int k=0; k<4; k++) {
				int nx = dx[k] + v.first;
				int ny = dy[k] + v.second;
				if(nx <= -1 || ny <= -1 || nx >= H || ny >= W || S[nx][ny] == '#') continue;
				if(dis[nx][ny] == INF){
					dis[nx][ny] = dis[v.first][v.second] + 1;
					ans = max(ans, dis[nx][ny]);
					que.push({nx, ny});
				}
			}
		}
		return ans;
	};

	int ans = 0;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(S[i][j] == '#')continue;
			ans = max(ans, bfs(i,j));
		}
	}

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


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    // 逆から考える
    A.reverse();
    
    let answer = [];
    let list = [];
    
    for(let i in A) {
        // 大きい順から考えているので、(N - i)の倍数は(N - i)のみしか存在しない
        // (N - i)の倍数の総和が偶数ということは、何も入れないということ
        let alreadyIn = 0;
        
        for(let j=i-(N - i); j>=0; j -= (N - i)) {
            if(list[j] === 1) {
                alreadyIn++;
            }
        }

        // (N - i)の倍数で既に入れてる総和 % 2が偶数の場合
        if(alreadyIn % 2 === 0) {
            if(A[i] !== 0) {
				answer.push(N - i);
				list.push(1);
            } else {
                list.push(0);
            }
        } else {
            if(A[i] === 0) {
                answer.push(N - i);
                list.push(1);
            } else {
                list.push(0);
            }
        }
    }

    const cnt = answer.length;
    answer.sort((a,b)=>a-b);

    console.log(cnt);
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{

 int k,n;
 cin>>k;
  string s;
  cin>>s;
  n=s.length();
  
  if(n<=k)
    cout<<s<<"\n";
  else
    cout<<s.substr(0,k)+"...\n";
}


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

#define ll long long
#define mod 1000000007


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

    int be=0, en=s.size()-1;

    int re=0;

    while(be<=en)
    {
        if(s[be]!=s[en])re++;
        be++;
        en--;
    }

    cout<<re<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		int sum = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				sum += D[i] * D[j];
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 21716
using System;

namespace abc159_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = s.Length;

            Program p = new Program();
            if (!p.isKaibun(s))
            {
                Console.WriteLine("No");
                return;
            }

            int nFront = (n - 1) / 2;
            string sFront = s.Substring(0, nFront);
            if (!p.isKaibun(sFront))
            {
                Console.WriteLine("No");
                return;
            }

            int nBack = (n + 3) / 2;
            string sBack = s.Substring(nBack - 1);
            if (!p.isKaibun(sBack))
            {
                Console.WriteLine("No");
                return;
            }

            if (sFront == sBack)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        private bool isKaibun(string s)
        {
            bool kaibunHantei = true;
            int sKaibunHanteiLength = s.Length / 2;

            for (int i = 0;i < sKaibunHanteiLength; i++)
            {
                string sFront = s.Substring(i, 1);
                string sBack = s.Substring((s.Length-i-1),1);
                if(sFront == sBack)
                {
                    continue;
                }
                else
                {
                    kaibunHantei = false;
                }
            }

            return kaibunHantei;
        }
    }
}


Measured memory_bytes: 25880
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int x, y;
	int a, b;
	cin >> x >> y;
	if ((2 * x - y) % 3 != 0 || (2 * x - y) / 3 < 0) {
		cout << 0 << endl;
		return 0;
	}
	b = (2 * x - y) / 3;
	if ((x - 2 * b) < 0) {
		cout << 0 << endl;
		return 0;
	}
	a = x - 2 * b;
	int c = a + b;
	int sum = 1, div = 1;
	for (int i = a; i < c; i++) {
		sum *= i + 1;
		sum %= MOD;
	}
	rep(i, b) {
		div *= i + 1;
		div %= MOD;
	}
	cout << sum * mod_pow(div,MOD-2,MOD)%MOD << endl;

	return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

int main() {

	FAST;

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	cout << ((s[0] == s[2]) ? "No\n" : "Yes\n");
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> red(MAX, 0);
    vector<int> white(MAX, 1);
    red[0] = 1;

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (red[x]) red[y] = 1;
        white[x] -= 1;
        white[y] += 1;
        if (white[x] == 0) red[x] = 0;
    }

    int ans = 0;
    rep(i, MAX) if (red[i] == 1) ans++;

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


Measured memory_bytes: 3960
#include <iostream>
using namespace std;
int main() {
  long long a, b, c, d, GCD, LCM;
  while(cin >> a >> b) {
    c = a;
    d = b;
    if((a==0) && (b==0)) cout << a << " ";
    else {
      while(a!=b) {
	if(a>b) a=a-b;
	else b=b-a;
      } 
      GCD = a;  
      cout << GCD << " ";
    }  
    c/=GCD;  
    LCM = c*d;   
    cout << LCM << endl; 
  } 
  return 0;
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int H,W,i,j;
  cin >> H >> W;
  char pix;
  for(i = 0; i < W + 2; i++){
  	cout << "#";
  }
  for(i = 0; i < H; i++){
    cout << endl << "#";
    for(j = 0; j < W; j++){
      cin >> pix;
      cout << pix;
      
    }
    cout << "#";  
  } 
  cout << endl;
  for(i = 0; i < W + 2; i++){
  	cout << "#";
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main() {
	ll N, X;
	cin >> N >> X;
	ll i, j;
	vll L(N);
	for (auto& e : L)cin >> e;
	ll pos = 0;
	ll ans = 0;
	for (i = 0; i < N; i++) {
		if (pos <= X) {
			ans++;
		}
		pos += L[i];
	}
	if (pos <= X) {
		ans++;
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
char order[110];
int main(){
    char odd[55];//奇数
    char even[55];//偶数
    int len1, len2;
    scanf("%s %s",odd + 1,even + 1);
    len1 = strlen(odd);
    len2 = strlen(even);
    int len = max(len1,len2);
    for(int i = 1,j = 1;j <= len;i = i + 2,j++){
            order[i] = odd[j];
            order[i + 1] = even[j];
    }
    printf("%s",order + 1);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
int a[N],b[N],c[N];
long long s[N],t[N];
int main()
{
    int n,i,j,k,p1,p2,flag;
    long long ans=0,s1,s2;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    scanf("%d",&b[i]);
    for(i=1;i<=n;i++)
    scanf("%d",&c[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);
    p1=n;
    p2=n;
    s1=0;
    for(i=n;i>=1;i--)
    {
        while(b[p1]>a[i]&&p1>=1)
        {
            s1=s[p1+1]+(n-p2);
            while(c[p2]>b[p1]&&p2>=1)
            {
                s1++;
                t[p2]=s1;
                p2--;
            }
            s[p1]=s1;
            p1--;
        }
        ans=ans+s1;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
    ll x;
    cin >> x;
    int i=0;
    ll ans=100;
    while(1){
        i++;
        ans=ans*1.01;
        if(ans>=x){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3624
while True:
    n=int(input())
    if n==0:
        break
    ans=0
    s=1
    e=1
    sam=0
    while s<=n:
        if sam<n:
            sam+=e
            e+=1
        elif sam==n:
            ans+=1
            s+=1
            sam=0
            e=s
        else:
            s+=1
            sam=0
            e=s
    print(ans-1)


Measured memory_bytes: 5588
a,b,c = map(int,input().split(' '))
if c-a-b>0 and c**2+b**2+a**2-2*b*c-2*a*c+2*a*b-4*a*b>0:
    x = c**2+b**2+a**2-2*b*c-2*a*c+2*a*b-4*a*b
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
dish = []
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)

sum = 0
max_kiriage = 0
max_kiriage_index = 10
5.times do |i|
  if dish[i] % 10 == 0
    kiriage = 0
  else
    kiriage = 10 - dish[i] % 10
  end
  if max_kiriage <= kiriage
    max_kiriage = kiriage
    max_kiriage_index = i
  end
end

5.times do |i|
  if i == max_kiriage_index
    next
  elsif dish[i] % 10 != 0
    sum += dish[i] + 10 - dish[i] % 10  
  else
    sum += dish[i]
  end
end

puts sum + dish[max_kiriage_index]
  

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <queue>
#include <cassert>

using namespace std;

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

    long long ans = 0;

    vector<set<int>> st(26);
    string tmp = s+s;

    for( int i=0; i<tmp.size(); ++i ){
        int idx = tmp[i]-'a';
        st[idx].insert( i+1 );
    }

    queue<char> que;
    for( auto ch: t ){
        que.push( ch );
    }

    int pos = 0;
    for( int i=0; i<t.size(); ++i ){
        assert( que.size() );
        char tgt = que.front();
        que.pop();

        auto it = st[tgt-'a'].upper_bound( pos );

        if( it == st[tgt-'a'].end() ){
            cout << -1 << endl;
            return 0;
        }
        ans += *it - pos;
        pos = *it % (s.size());
    }
    cout << ans << endl;
}

Measured memory_bytes: 10112
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;


public class Main {


    static void solve() {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int n = scan.nextInt();
        boolean[] arr = new boolean[102];
        for(int i=0;i<n;i++) {
            int val = scan.nextInt();
            arr[val] = true;
        }


        int i = x;
        int min = 0;
        while(i>=0) {
            if(!arr[i]) {
                min = i;
                break;
            }
            i--;
        }
        i=x+1;
        while(true) {
            if(!arr[i]) {
                int diff = i-x;
                int minDiff = x-min;
                if(diff < minDiff) {
                    min = i;
                }
                break;
            }
            i++;
        }

        System.out.println(min);

//        int x1 = scan.nextInt();
//        int x2 = scan.nextInt();
//        int x3 = scan.nextInt();
//        int x4 = scan.nextInt();
//        int x5 = scan.nextInt();




//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
//
//            scase();
//        }
    }


//    static void solveCase(int t, int x, String s) {
//
//    }

    static void scase() {

    }




    public static void main(String[] args) {
        solve();
        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


//
//    class Counter extends HashMap<Integer, Integer> {
//        public int get(int k) {
//            return containsKey(k) ? super.get(k) : 0;
//        }
//
//        public void add(int k, int v) {
//            put(k, get(k) + v);
//        }
//    }


//    static class TreeNode {
//        int val;
//        TreeNode left;
//        TreeNode right;
//
//        TreeNode(int x) {
//            val = x;
//        }
//    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

}

Measured memory_bytes: 27232
#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)

using ll = long long;
#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  REP(i, N){
    cin >> A[i];
    B[i] = A[i];
  }
  sort(A.begin(), A.end());
  REP(i, N){
    if(B[i] == A[N-1]){
      cout << A[N-2] << endl;
    }
    else{
      cout << A[N-1] << endl;
    }
  }






  return 0;
}


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

using namespace std;

#define ll long long

#define DEBUG (0)

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

  if(S == "ABC"){
    cout << "ARC" << "\n";
  }else{
    cout << "ABC" << "\n";
  }
#if DEBUG
  cout << "K:" << K << ", A:" << A << ", B:" << B << endl;
#endif
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
const ll inf = 1e9;

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

  int a[1000],b[1000],c[1000],dist[1000][1000];

  fr(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--,b[i]--;
  }
  fr(i,n){
    fr(j,n){
      if(i==j)dist[i][j] = 0;
      else dist[i][j] = inf;
    }
  }
  fr(i,m){
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]],c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]],c[i]);
  }

  fr(k,n){
    fr(i,n){
      fr(j,n)dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
    }
  }

  int ans = m;
  fr(i,m){
    bool t = false;
    fr(j,n){
      if(dist[j][a[i]] + c[i] == dist[j][b[i]])t = true;
    }
    if(t) ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n+1),b(n),c;
	rep(i,n+1)
	{
		cin >> a[i];
	}
	c = a;
	rep(i,n)
	{
		cin >> b[i];
	}

	rep(i,n)
	{
		if(a[i]-b[i]<0)
		{
			int foo = a[i];
			a[i]=0;
			b[i]-=foo;
		}
		else
		{
			int foo = a[i];
			a[i]-=b[i];
			b[i]=0;
		}
		if(a[i+1]-b[i]<0)
		{
			b[i]-=a[i+1];
			a[i+1]=0;
		}
		else
		{
			a[i+1]-=b[i];
			b[i]=0;
		}
	}
	rep(i,n+1)
	{
		//cout<<a[i]<<endl;
	}
	ll ans = 0;
	rep(i,n+1)ans = ans + c[i] - a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.x = sc.nextInt();
			o.y = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		double sum = permutation(arr, new LinkedHashSet<>());
		int i = 1;
		for (int j = 1; j <= n; j++) {
			i *= j;
		}
		System.out.println(sum / i);
	}

	static double permutation(Obj[] target, LinkedHashSet<Integer> set) {
		if (set.size() == target.length) {
			double val = 0;
			Integer[] arr = set.toArray(new Integer[0]);
			for (int i = 1; i < arr.length; i++) {
				int dx = target[arr[i]].x - target[arr[i - 1]].x;
				int dy = target[arr[i]].y - target[arr[i - 1]].y;
				val += Math.hypot(dx, dy);
			}
			return val;
		}

		double sum = 0;
		for (int i = 0; i < target.length; i++) {
			if (!set.contains(i)) {
				set.add(i);
				sum += permutation(target, set);
				set.remove(i);
			}
		}
		return sum;
	}

	static class Obj {
		int x, y;
	}
}


Measured memory_bytes: 34092
#include <iostream>

using namespace std;

int n, m;
int fa[100005];
int siz[100005], rt[100005];

inline int find(int x) {
    return (x == fa[x] ? x : fa[x] = find(fa[x]));
}

inline void merge(int x, int y) {
    int xx = find(x), yy = find(y);
    if (xx == yy)
        return;
    if (siz[yy] < siz[xx])
        fa[yy] = xx, siz[xx] += siz[yy];
    else
        fa[xx] = yy, siz[yy] += siz[xx];
}

inline int block(int x) {
    int ans = 0;
    for (int i = 1; i <= x; i++) {
        rt[find(i)] = 1;
    }
    for (int i = 1; i <= x; i++) {
        ans += rt[i];
    }
    return ans;
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) fa[i] = i;
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        merge(a, b);
    }
    cout << block(n) - 1;
    return 0;
}


Measured memory_bytes: 4804
import sys
n=int(input())
s=input()

def test(dp,n,a,b):
    dp[0]=a
    dp[-1]=b
    flag=0
    if n%2==0:
        for i in range(n):
            if not ((s[i]=='o') ^ (dp[i]==0)):
                if dp[(i+1)%n]==-1 or dp[(i+1)%n]==dp[i-1]:
                    dp[(i+1)%n]=dp[i-1]
                else:
                    flag=-1
            else:
                if dp[(i+1)%n]==-1 or dp[(i+1)%n]!=dp[i-1]:
                    dp[(i+1)%n]=1-dp[i-1]
                else:
                    flag=-1
    else:
        for i in range(n):
            if not ((s[i]=='o') ^ (dp[i]==0)):
                if dp[(i+1)%n]==-1 or dp[(i+1)%n]==dp[i-1]:
                    dp[(i+1)%n]=dp[i-1]
                else:
                    flag=-1
            else:
                if dp[(i+1)%n]==-1 or dp[(i+1)%n]!=dp[i-1]:
                    dp[(i+1)%n]=1-dp[i-1]
                else:
                    flag=-1
    return flag

for i in range(4):
    flag=0
    dp=[-1]*n
    flag=test(dp,n,i&1,i>>1)
    if flag!=-1:
        break
    
if flag==-1:
    print(-1)
    sys.exit()
for i in range(n):
    if dp[i]==0:
        print('S',end='')
    else:
        print('W',end='')
print('\n')

Measured memory_bytes: 56780
unittest
{
	assert( [ "3", "10 40 70", "20 50 80", "30 60 90" ].parse.expand.solve == 210 );
	assert( [ "1", "100 10 1" ].parse.expand.solve == 100 );
	assert( [ "7", "6 7 8", "8 8 3", "2 5 2", "7 8 6", "4 6 8", "2 3 4", "7 5 1" ].parse.expand.solve == 46 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abcs = new long[ 3 ][ n ];
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
	}
	return tuple( abcs );
}

auto solve( long[ 3 ][] abcs )
{
	auto dp = new long[ 3 ][ abcs.length ];
	
	dp[ 0 ][] = abcs[ 0 ][];
	for( auto h = 1L; h < abcs.length; h++ )
	{
		for( auto w = 0L; w < 3; w++ )
		{
			auto m = 0L;
			for( auto i = 0L; i < 3; i++ )
			{
				if( i != w ) m = max( m, dp[ h - 1 ][ i ] );		// 前日の違う活動のうち、一番幸福度が大きいものを選ぶ
			}
			dp[ h ][ w ] = m + abcs[ h ][ w ];
		}
	}
	
	return dp[ $ - 1 ].reduce!( max );
}


Measured memory_bytes: 8060
#include <bits/stdc++.h>
using namespace std;
int dp[100003];
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    int h[100003];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 1; i < n; i++) dp[i] = 1e9;
    for (int i = 0; i <= n - 1; i++) {
        dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i]);
        dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i]);
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

int main() {
  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve() {
  ini(N);

  vll a(N);
  rep(i, N) cin >> a[i];

  sort(a.begin(), a.end());

  out(a.back() - a[0]);
}


Measured memory_bytes: 3572
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> h(N);
  REP(i, N) { cin >> h[i]; }

  vector<ll> dp(N, 0);
  dp[0] = 0;
  dp[1] = dp[0] + abs(h[0] - h[1]);
  FOR(i, 2, N) {
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int m;
	cin >> m;
	cout << 48 - m << endl;
}


Measured memory_bytes: 256
class Dice():
    def __init__(self, a, b, c, d, e, f):
        self.s = [0, a, b, c, d, e, f]

    def rotate(self, dir):
        if dir == "N":
            self.s[0] = self.s[1] 
            self.s[1] = self.s[2] 
            self.s[2] = self.s[6]
            self.s[6] = self.s[5]
            self.s[5] = self.s[0]
            return

        elif dir == "W":
            self.s[0] = self.s[1]
            self.s[1] = self.s[3] 
            self.s[3] = self.s[6]
            self.s[6] = self.s[4]
            self.s[4] = self.s[0]
            return

        elif dir == "S":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5] 
            self.s[5] = self.s[6]
            self.s[6] = self.s[2]
            self.s[2] = self.s[0]
            return

        elif dir == "E":
            self.s[0] = self.s[1]
            self.s[1] = self.s[4] 
            self.s[4] = self.s[6]
            self.s[6] = self.s[3]
            self.s[3] = self.s[0]
            return

        else:
            return

dice = Dice(*list(map(int, input().split())))

for order in input():
    dice.rotate(order)

print(dice.s[1])


Measured memory_bytes: 5612
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n =I()
    print(-n%1000)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65428
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[200],ans=0;
  cin >> n;
  for(int i=0; i<2*n; i++) {
    cin >> a[i];
  }
  sort(a,a+2*n);
  for(int i=0; i<2*n; i+=2) {
    ans+=a[i];
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IN_OUT(n) ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) , cout << fixed << setprecision(n)
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
typedef long long ll;
const int MOD = 1e9 + 7;
const int MAX = 1e5;
const int INF = 2e9;
int MA = -INF , MI = INF;

int32_t main()
{
	IN_OUT(10);
	string s;
	cin>>s;

	for(int i=0 ; i<2 ; i++)
	{
		if( s[i] == s[i+1] && s[i] == s[i+2] )
			return cout<<"Yes" , 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
def main():
    K = int(input())
    ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    count = 9
    if K <= count:
        print(ans[K-1])
    else:
        for x in ans:
            mod = x % 10
            base = 10*x + mod

            if mod != 0:
                ans.append(base-1)
                count += 1

            ans.append(base)
            count += 1

            if mod != 9:
                ans.append(base+1)
                count += 1

            if count >= K:
                break
        print(ans[K-1])


if __name__ == "__main__":
    main()

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin >> n >> k;
    vector<int> dp(1000000,INF);
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    dp.at(0) = 0;
    for(int i = 0;i < n; ++i){
        for(int j = 1;j <= k;++j){
            if(i+j > n-1) break;
            dp.at(i+j) = min(dp.at(i+j),dp.at(i)+abs(a.at(i)-a.at(i+j)));
        }
    }
    cout << dp.at(n-1) << endl;

    cout << endl;
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	vector<vector<int>> c(3,vector<int>(3,0));
	int l;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> l;
			c[i][j] = l;
		}
	}
	int flag;
	int b[3];
	int a[3];
	for(int i = 0; i <= 100; i++) {
		for(int j = 0; j <= 100; j++) {
			for(int k = 0; k <= 100; k++) {
				a[0] = i;
				a[1] = j;
				a[2] = k;
				b[0] = c[0][0]- i;
				b[1] = c[1][1]- j;
				b[2]= c[2][2]- k;
				flag = 1;
				for(int l = 0; l < 3; l++) {
					for(int m = 0; m < 3; m++) {
						// cout << c[l][m] << a[l] << b[m] << endl;
						if(c[l][m] != a[l] + b[m]){
							flag = 0;
						}
					}
				}
				if (flag == 1){
					break;
				}
			}
			if (flag == 1){
				break;
			}
		}
		if (flag == 1){
			break;
		}
	}
	if (flag == 1){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
 ll d,t,s;
cin>>d>>t>>s;
   ll result=s*t;
   if(result>=d)
     cout<<"Yes"<<endl; 
   else
     cout<<"No"<<endl;
return 0;
}

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

typedef long long ll;

ll n;
ll arr[101010];
ll tree[202020];

void update(int x){
	while(x < 202020){
		tree[x]++;
		x += x & -x;
	}
}

int query(int x){
	int ret = 0;
	while(x){
		ret += tree[x];
		x -= x & -x;
	}
	return ret;
}

bool chk(int m){
	memset(tree, 0, sizeof tree);
	ll res = 0, t = n + 1;
	update(t);
	for(int i=1; i<=n; i++){
		t += arr[i] >= m ? 1 : -1;
		res += query(t);
		update(t);
	}
	return res >= ((n*n+n)/2+1)/2;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
	for(int i=1; i<=n; i++) cin >> arr[i];
	
    int l = 0, r = 1e9;
	while(l < r){
		int m = l + r + 1 >> 1;
		if(chk(m)) l = m;
		else r = m - 1;
	}
	cout << l;
}

Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String s = in.nextLine();
        final String t = in.nextLine();
        int diff = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                diff++;
            }
        }
        System.out.println(diff);
    }
}


Measured memory_bytes: 42276
n,q=map(int,input().split())
s=input()
dp=[0]*n
count=0
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    dp[i]=1+count
    count+=1
  else:
    dp[i]=count

#print(dp)
for i in range(q):
  l,r=map(int,input().split())
  print(dp[r-2]-dp[l-2])
  

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

int main(){
    int n,k;
    cin >> n >> k;
    int a[n],Min = 10000000;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = 1;
    n -= k;
    k --;
    while(n > 0){
        n -= k;
        ans += 1;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 640
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#include<bits/stdc++.h>
#define fr first
#define sc second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
const int inf = 1e9+7;
const int nmax = 500005;
const ll linf = LLONG_MAX;
const int mod = 998244353;

char ch[1005][1005];
int dp[1005][1005] , n , m;
int main(){
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++)
    for(int j = 1; j <= m ; j++){
        cin >> ch[i][j];
    }
    for(int i = n ; i > 0 ; i--)
    for(int j = m ; j > 0 ; j--){
        dp[i][j] = inf;
        if(i<n){
            dp[i][j] = min(dp[i][j] , dp[i+1][j] + ((ch[i][j] == '.' && ch[i+1][j] == '#') ? 1 : 0));
        }
        if(j<m){
            dp[i][j] = min(dp[i][j] , dp[i][j+1] + ((ch[i][j] == '.' && ch[i][j+1] == '#') ? 1 : 0));
        }
        if(j == m && i == n)dp[i][j] = 0;
    }
    cout << dp[1][1] + (ch[1][1] == '#');

}


Measured memory_bytes: 2688
def solve(n,x):
	out = 0
	for i in range(1,n-1):
		for j in range(i+1, n):
			for k in range(j+1,n+1):
				if i+j+k == x:
					out += 1

	return out

ans = []
while True:
	N, X = map(int,input().split())
	if N == 0 and X == 0:
		break

	ans.append(solve(N,X))

for a in ans:
	print(a)


Measured memory_bytes: 5600
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	t <- readInts
	m <- readInt
	px <- replicateM m readInts
	let
		s = sum t
	mapM_ print $ map ( \[ p, x ] -> s - ( t !! ( p - 1 ) ) + x ) px


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
#define ll long long 
 
int main()
{
    int n;
    cin>>n;
    ll pre[n];
    for (int i=0; i<n; ++i){
        ll val;
        cin >> val;
        if (i > 0) {
            pre[i] = val + pre[i-1];
        }
        else {
            pre[i] = val;
        }
    }
    ll dp[n][n];
    fill(*dp, *dp + n*n, 0);
    
    for (int L = n-1; L>=0; --L) {
        for(int R = L; R<n; ++R) {
            if (L < R) {
                dp[L][R] = 1e15;
                for (int K=L; K<R; ++K){
                    ll rsum = pre[R];
                    if (L!=0) {
                        rsum = pre[R] - pre[L-1];
                    }
                    dp[L][R] = min(dp[L][R], dp[L][K] + dp[K+1][R] + rsum);
                }
            }
        }
    }
    // for (int i=0; i<n; ++i) { 
    //     for (int j=0; j<n; ++j)    
    //         cout << dp[i][j] << "  ";
    //     cout << endl;
    // }
    cout << dp[0][n-1];
    return 0;
}


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

using namespace std;

string a , b , c;


bitset < 27 > fr;

int n;

int main()
{
    int ans = 0;
    cin >> n;
    cin >> a >> b >> c;
    for(int i = 0 ; i < a.size() ; i++)
    {
        fr[a[i] - 'a' + 1] = 1;
        fr[b[i] - 'a' + 1] = 1;
        fr[c[i] - 'a' + 1] = 1;
        ans += (fr.count() - 1);
        fr.reset();
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    string res = "";
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            res += s[i];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=llabs(x);
    if(x/d>k){
        cout<<x-k*d<<endl;
        return 0;
    }
    ll noko=k;
    noko-=x/d;
    ll mini=x%d;
    if(noko%2==0){
        cout<<mini<<endl;
    }else{
        cout<<llabs(mini-d)<<endl;
    }
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a, b;
    cin >> a >> b;
    if (a <= b) {
        cout << a << endl;
    }else{
        cout << a-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256