akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int dp[4001][4001];

int a[200001],b[200001];

long long int fac[8001],inv[8001];

long long int power(long long int x,long long int c){
	x%=mod;
	long long int res=1;
	while(c){
		if(c&1)
			res=res*x%mod;
		x=x*x%mod;
		c>>=1;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		dp[2000-a[i]][2000-b[i]]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++){
			if(i>0)
				dp[i][j]+=dp[i-1][j];
			if(j>0)
				dp[i][j]+=dp[i][j-1];
			dp[i][j]%=mod;
		}
	long long int ans=0;
	for(int i=1;i<=n;i++)
		ans+=dp[2000+a[i]][2000+b[i]];
	fac[0]=1;
	for(int i=1;i<=8000;i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=power(fac[i],mod-2);
	}
	for(int i=1;i<=n;i++)
		ans-=fac[a[i]+a[i]+b[i]+b[i]]*inv[a[i]+a[i]]%mod*inv[b[i]+b[i]]%mod;	ans=(ans%mod+mod)%mod;
	ans=ans*power(2,mod-2)%mod;
	cout<<ans<<endl;
	
}


Measured memory_bytes: 64512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	bool a[1010] = {};
	a[1] = true;
	for (int i = 2; i <= 33; i++) {
		for (int j = 2;; j++) {
			int p = i;
			for (int k = 1; k < j; k++)p *= i;
			if (p <= 1000)a[p] = true;
			else goto heaven;
		}
	heaven:;
	}
	int x; cin >> x;
	for (int i = x; i >= 1; i--) {
		if (a[i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 200006
#define inf 1000000000000000LL
using namespace std;
int n,m,x,y,a[N];long long s[N<<2][3],f[N<<2];
void build(int i,int l,int r)
{
	if(l==r){
		s[i][0]=inf;
		if(l==x)s[i][0]=abs(y-a[1]);
		if(l==y)s[i][0]=abs(x-a[1]);
		s[i][1]=s[i][0]-l;s[i][2]=s[i][0]+l;
		return;
	}
	int mid=(l+r)>>1;
	build(i<<1,l,mid);build(i<<1|1,mid+1,r);
	for(int T=0;T<3;T++)s[i][T]=min(s[i<<1][T],s[i<<1|1][T]);
}
void down(int i,int l,int r)
{
	if(f[i]){
		if(l!=r)f[i<<1]+=f[i],f[i<<1|1]+=f[i];
		for(int T=0;T<3;T++)s[i][T]+=f[i];f[i]=0;
	}
}
void change(int i,int l,int r,int x,long long y)
{
	down(i,l,r);if(l==r){
		s[i][0]=min(s[i][0],y);
		s[i][1]=s[i][0]-l;s[i][2]=s[i][0]+l;
		return;
	}
	int mid=(l+r)>>1;
	if(x<=mid)change(i<<1,l,mid,x,y);
	else change(i<<1|1,mid+1,r,x,y);
	down(i<<1,l,mid);down(i<<1|1,mid+1,r);
	for(int T=0;T<3;T++)s[i][T]=min(s[i<<1][T],s[i<<1|1][T]);
}
long long query(int i,int l,int r,int x,int y,int T)
{
	down(i,l,r);if(x<=l&&r<=y)return s[i][T];
	int mid=(l+r)>>1;long long t=inf;
	if(x<=mid)t=query(i<<1,l,mid,x,y,T);
	if(y>mid)t=min(t,query(i<<1|1,mid+1,r,x,y,T));return t;
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for(int i=1;i<=m;i++)scanf("%d",a+i);
	build(1,1,n);
	for(int i=2;i<=m;i++){
		long long tmp=min(query(1,1,n,1,a[i],1)+a[i],query(1,1,n,a[i],n,2)-a[i]);
		f[1]+=1LL*abs(a[i]-a[i-1]);change(1,1,n,a[i-1],tmp);
	}
	printf("%lld\n",query(1,1,n,1,n,0));
}

Measured memory_bytes: 21504
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int w, h, n;
	cin >> w >> h >> n;
	int xmi = 0, xma = w, ymi = 0, yma = h;
	int x, y, a;
	REP(i, n){
		cin >> x>>y >> a;
		if(a == 1) xmi = max(xmi, x);
		if(a == 2) xma = min(xma, x);
		if(a == 3) ymi = max(ymi, y);
		if(a == 4) yma = min(yma, y);
	}
	cout << max(0,yma-ymi)*max(0,xma-xmi) << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/
int main(){
    vector<int> a(3);
    rep(i,3) cin>>a[i];
    SORT(a);
    if(a[0]+a[1]==a[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input=lambda:sys.stdin.readline().rstrip()
r,c,k=map(int,input().split())
dp=[[(c+1)*[0]for _ in range(r+1)]for _ in range(4)]
p=[c*[0]for _ in range(r)]
for _ in range(k):
  rr,cc,u=map(int,input().split())
  rr-=1
  cc-=1
  p[rr][cc]=u
ans=0
for j in range(1,r+1):
  for k in range(1,c+1):
    dp[0][j][k]=max(dp[0][j-1][k],dp[0][j][k-1])
    t=max(dp[0][j-1][k],dp[1][j-1][k],dp[2][j-1][k],dp[3][j-1][k])
    for i in range(1,4):
      dp[i][j][k]=max(dp[i][j][k],t,dp[i][j][k-1])
      if p[j-1][k-1]:
        dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-1]+p[j-1][k-1],t+p[j-1][k-1])
      ans=max(ans,dp[i][j][k])
print(ans)


Measured memory_bytes: 429740
#include <bits/stdc++.h>
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++)
typedef long long ll;

vector<int> to[200005];
vector<int> counter;

void dfs(int v, int p){
	for(auto next: to[v]){
		if(next == p) continue;
		counter[next] += counter[v];
		dfs(next, v);
	}
	return;
}
int main(){
	int n,q;
	cin >> n >> q;
	counter.resize(n,0);
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i,q){
		int x,y;
		cin >> x >> y;
		x--;
		counter[x] += y;
	}
	dfs(0,-1);
	rep(i,n){
		cout << counter[i] << " ";
	}
	cout << endl;
    return 0;
}



Measured memory_bytes: 23424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
		if(a > b + c) {
			System.out.println("0");
		}
		else{
			System.out.println((b + c) -a  );		}


	}

}



Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
int main(){
string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u){
    cout<<a-1<<" "<<b<<endl;
  }
  else if(t==u){
    cout<<a<<" "<<b-1<<endl;
  }
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int k;
    cin >> k;
    rep(i,k) cout << "ACL";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld h,w;
	char a[100][100];

	cin >> h >> w;

	for(int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> a[i][j];
		}
	}

	lld al[26] = {};

	for(int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			al[a[i][j] - 'a']++;
		}
	}

	lld x = min(h,w);
	lld y = max(h,w);  

	h = x;
	w = y;   //h <= w

	if (h == 1 && w == 1)
	{
		cout << "Yes" << endl;
	}else
	{
		if (w % 2 == 1 && h % 2 == 1)
		{
			lld ev = 0;

			for(int i = 0; i < 26; i++)
			{
				if (al[i] >= 4)
				{
					ev += al[i] / 4;
					al[i] %= 4;
				}
			}

			if (ev <  ((w-1) / 2 ) * ((h-1) / 2) && h != 1)
			{
				cout << "No" << endl;
				return 0;
			}

			int odd = 0;
			for(int i = 0; i < 26; i++)
			{
				if (al[i] % 2 == 1)
				{
					odd++;
				}
			}

			if (odd != 1)
			{
				cout << "No" << endl;
			}else
			{
				cout << "Yes" << endl;
			}
		}else if(w % 2 == 1 || h % 2 == 1)
		{

			lld ev = 0;

			if (w %2 == 0)
			{
				ev = w;
			}else
			{
				ev = h;
			}

			//cout << "oddeven" << endl;
			for(int i = 0; i < 26; i++)
			{
				if (al[i] >= 4)
				{
					al[i] %= 4;
				}
			}

			int two = 0;

			for(int i = 0; i < 26; i++)
			{
				if (al[i] % 2 != 0)
				{
					cout << "No" << endl;
					break;
				}
				if (al[i] == 2)
				{
					two++;
					if (two > ev / 2)
					{
						cout << "No" << endl;
						break;
					}

				}

				if (i == 25)
				{
					cout << "Yes" << endl;
				}
			}
		}else
		{
			//cout << "eveneven" << endl;
			for(int i = 0; i < 26; i++)
			{
				if (al[i] >= 4)
				{
					al[i] %= 4;
				}
			}

			int red = 0;
			for(int i = 0; i < 26; i++)
			{
				if (al[i] > 0)
				{
					red++;
				}
			}

			//cout << "red = " << red << endl;

			if (red > 0)
			{
				cout << "No" << endl;
			}else
			{
				cout << "Yes" << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5]){
	cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
  return(0);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=998244353;


map<string,int>m;
int solve(string s){
    if(m.find(s)!=m.end())return m[s];

    if(s.size()==1)return s[0]-'0'+1;
    if(s.size()==0)return 1;

    int ret=(s[0]-'0'+1)*solve(s.substr(1))%mod;
    for(int i=1;i<=s.size();i++){
        string ss=s.substr(i);
        int sum=0;
        for(int j=1;j<i;j++){
            if(i%j)continue;
            string t(j,'1');
            int m=i/j;
            for(int k=0;k<m;k++){
                for(int l=0;l<j;l++){
                    if(s[k*j+l]=='0')t[l]='0';
                }
            }
            sum+=solve(t);
            if(sum>=mod)sum-=mod;
        }
        ret+=sum*solve(ss)%mod;if(ret>=mod)ret-=mod;
    }
    return m[s]=ret;
}

signed main(){
    string S;cin>>S;
    cout<<solve(S)<<endl;
    return 0;
}


Measured memory_bytes: 5632
let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    proc(inputString[1].split(' ').map(str => Number(str)));
});

let count = 0;

const proc = (nums) => {
  mergeSort(nums, 0, nums.length);
  console.log(nums.join(' '));
  console.log(count);
};

const mergeSort = (nums, leftIndex, rightIndex) => {
  if (leftIndex + 1 < rightIndex) {
    const sum = leftIndex + rightIndex;
    const mid = (sum - sum % 2) / 2;
    mergeSort(nums, leftIndex, mid);
    mergeSort(nums, mid, rightIndex);
    merge(nums, leftIndex, mid, rightIndex);
  }
};

const merge = (nums, leftIndex, midIndex, rightIndex) => {
  const leftArr = Array.from({ length: (midIndex - leftIndex + 1) }, (_, i) => nums[leftIndex + i]);
  leftArr[leftArr.length - 1] = Infinity;
  const rightArr = Array.from({ length: (rightIndex - midIndex + 1) }, (_, i) => nums[midIndex + i]);
  rightArr[rightArr.length - 1] = Infinity;

  let i = 0;
  let j = 0;
  for (let k=leftIndex; k<rightIndex; k++) {
    if (leftArr[i] <= rightArr[j]) {
      nums[k] = leftArr[i];
      i++;
    } else {
      nums[k] = rightArr[j];
      j++;
    }
    count++;
  }
};


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

int main(){
	int a[10];
	int out[3] = {0, 0, 0};
	for (int i = 0; i < 10; ++i)	cin >> a[i];
	
	for (int i = 0; i < 10; ++i){
		if (a[i] >= out[0]){
			out[2] = out[1];
			out[1] = out[0];
			out[0] = a[i];
		}
		else if (a[i] >= out[1]){
			out[2] = out[1];
			out[1] = a[i];
		}
		else if (a[i] >= out[2]){
			out[2] = a[i];
		}
	}

	for (int i = 0; i < 3; ++i)	cout << out[i] << endl;

	return 0;
}

Measured memory_bytes: 1164
# -*- coding: utf-8 -*-
from itertools import groupby
import sys

n, A, B, C, D = map(int, input().split())
s = input()
if D < C:
    a = [[k, len(list(g))] for k, g in groupby(s[B-2:D+1])]
    for i in range(len(a)):
        if a[i][0] == "." and a[i][1] >= 3:
            break
        if i == len(a)-1:
            print("No")
            sys.exit()
b = [[k, len(list(g))] for k, g in groupby(s[A-1:max(C, D)])]
for i in range(len(b)):
        if b[i][0] == "#" and b[i][1] >= 2:
            break
        if i == len(b)-1:
            print("Yes")
            sys.exit()
print("No")


Measured memory_bytes: 25268
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var ls = new List<int>();
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();

            ls.Add(0);
            ls.AddRange(s);
            ls.Add(0);

            int sum = 0;
            for (int j = 1; j <= n+1; j++)
            {
                sum += Abs(ls[j] - ls[j - 1]);
            }

            //省くAiの選別
            for (int i = 1; i <= n; i++)
            {
                WriteLine(sum - Abs(ls[i] - ls[i - 1]) - Abs(ls[i + 1] - ls[i])
                    + Abs(ls[i + 1] - ls[i - 1]));
            }


        }
    }
}


Measured memory_bytes: 27612
N = int(input())
a = []
for i in range(N):
    s = input().split()
    a.append((i + 1, s[0], int(s[1])))
a.sort(key=lambda x: x[2], reverse=True)
a.sort(key=lambda x: x[1])
for c in a:
    print(c[0])

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

class AtCoderCS {
    static void Main(string[] args) {
        string N = Console.ReadLine();

        switch (N.Last()) {
            case '2':
            case '4':
            case '5':
            case '7':
            case '9': Console.WriteLine("hon"); break;
            case '0':
            case '1':
            case '6':
            case '8': Console.WriteLine("pon"); break;
            case '3': Console.WriteLine("bon"); break;
        }
    }
}

Measured memory_bytes: 26248
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
long long int solve(int n,vector<int> v,int k)
{
    long int dp[n+1];
    int i;
    dp[n]=0;
    long int mi=0;
    dp[n-1]=abs(v[n-1]-v[n-2]);
    for(int i=n-2;i>0;i--)
    {
mi=dp[i+1]+abs(v[i-1]-v[i+1-1]);
for(int j=1;j<=k;j++)
{
    if(i+j>n)
    break;
mi=min(mi,dp[i+j]+abs(v[i-1]-v[i+j-1]));
}
dp[i]=mi;
    }
    
    // for(int i=1;i<n+1;i++)
    // cout<<dp[i]<<endl;
return dp[1];
}
int main()
{
    int n,k;
    cin >>n>>k;
    int i;
    int input;
    vector<int> v;
    f(i,0,n)
    {
cin >>input;
v.push_back(input);
    }
    long long int ans=solve(n,v,k);
    cout<<ans;
}

Measured memory_bytes: 1912
N,M,X = map(int,input().split())
C = []
A = []
for i in range(N):
    ls = list(map(int,input().split()))
    C.append(ls[0])
    A.append(ls[1:])

INF = 10**9
ans = INF
for i in range(2**N):
    skill = [0]*M
    yen = 0
    for j in range(N):
        if i >> j & 1:
            for k in range(M):
                skill[k] += A[j][k]
            yen += C[j]
    ok = True
    for j in skill:
        if j < X:
            ok = False

    if ok:
        ans = min(ans,yen)
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9144
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
int main() {
  int A, B;
  cin >> A >> B;
  int ans;
  if(A >= 13) ans = B;
  else if(A <= 5) ans = 0;
  else ans = B /2;
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<stdio.h>
#define N 100004
using namespace std;
struct node{
    int parent=-1;
    int lchild=-1;
    int rbro=-1;
    int cnum=0;
};

int getDep(node A[],int node){
    int ans=0;
    while(A[node].parent!=-1){
        ans++;
        node=A[node].parent;
    }
    return ans;
}
void showchild(vector<int> &C){
    int i;
    cout<<"[";
    for(i=0;i<C.size();i++){
        if(i) cout<<", ";
        cout<<C[i];
    }
    cout<<"]"<<endl;
}
void show(node A[],int n){
    vector<int> childs;
    for(int i=0;i<n;i++){
        int lc=A[i].lchild;
        while(lc!=-1){
            childs.push_back(lc);
            lc=A[lc].rbro;
        }
        printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,getDep(A,i));
        if(A[i].parent==-1){
            cout<<"root, ";
        }else if(A[i].cnum==0){
            cout<<"leaf, ";
        }else{
            cout<<"internal node, ";
        }
        showchild(childs);

        childs.clear();
    }
}

int main(){
    node A[N];
    int n,i;
    int k,num,c;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k>>num;
        A[k].cnum=num;
        if(num==0) continue;
        if(num>=1){
            cin>>c;
            A[k].lchild=c;
            A[c].parent=k;
            if(num>1){
                int tempc=c;
                A[tempc].parent=k;
                for(int j=1;j<num;j++){
                    cin>>c;
                    A[c].parent=k;
                    A[tempc].rbro=c;
                    tempc=c;
                }
            }
        }
    }

    show(A,n);

    return 0;
}



Measured memory_bytes: 4904
import os
import sys
from io import BytesIO, IOBase


def main():
    a,b = input().rstrip().split()
    b = int(b[:-3]+b[-2:])
    a = int(a)
    res = str(a* b)
    if len(res) <= 2:
        print(0)
        return
    res = int(res[:-2])
    print(res)





#.........................................FAST INPUT OUTPUT.......................................
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#....................................END OF FAST I/O............................................

if __name__ == "__main__":
    main()

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

using namespace std;

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

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

string expr;
int idx;
int p, q, r;

int form();

int paren() {
    int left = form();
    char op = expr[idx++];
    int right = form();
    idx++; // ')'

    if (left == right) {
        return left;
    }
    if (op == '+') {
        return (left + right >= 2) ? 2 : 1;
    } else {
        return (left * right > 0) ? 1 : 0;
    }
}

int form() {
    char c = expr[idx++];
    switch (c) {
    case '0':
    case '1':
    case '2':
        return c - '0';
    case 'P': return p;
    case 'Q': return q;
    case 'R': return r;
    case '-':
        return 2 - form();
    case '(':
        return paren();
    }
}

int main() {
    while (cin >> expr, expr != ".") {
        int cnt = 0;
        REP(i, 27) {
            idx = 0;
            int w = i;
            p = w % 3; w /= 3;
            q = w % 3; w /= 3;
            r = w % 3; w /= 3;
            int n = form();
            if (n == 2) cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
                  
using namespace std;
          
typedef long long ll;
#define mp make_pair
#define pub push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

struct vert{
	int to[2];
	int stop;
	vert() { to[0] = -1; to[1] = -1; }
};

int n;
ll len;

/*int dp[1111];

int calc(int len){
	if (dp[len] != -1) return dp[len];
	vector<int> was;
	set<int> se;
	se.insert(0);
	int tmp = 0;
	for (int i = 2; i <= len; i++){
		tmp ^= calc(len - i + 1);
		se.insert(tmp);
	}
	for (int i = 0; ; i++) if (se.find(i) == se.end()) return dp[len] = i;
}*/

vert t[100007];
int sz = 1;

void add(string s){
	int v = 0;
	for (char c : s){
		int to = c - '0';
		if (t[v].to[to] == -1) t[v].to[to] = sz++;
		v = t[v].to[to];
	}
	t[v].stop = 1;
}

ll getFunc(ll x){
	if (x == 0) return 0;
	if (x % 2 == 1) return 1;
	for (int i = 0; ; i++){
		if ((x >> i) & (ll)1) return (ll)1 << i;
	}
	assert(0);
}

ll ans = 0;

void dfs(int v, ll ost){
	if (t[v].stop == 1) return ;
	for (int i = 0; i < 2; i++) if (t[v].to[i] != -1) dfs(t[v].to[i], ost - 1); else ans ^= getFunc(ost);
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    //for (int i = 0; i < 1111; i++) dp[i] = -1;
    //dp[0] = 0;
    //for (int i = 2; i < 100; i += 2) cout << i << ' ' << calc(i) << ' ' << (-i & i) << endl;
    cin >> n >> len;
    for (int i = 0; i < n; i++){
    	string s;
    	cin >> s;
    	add(s);
    }
    dfs(0, len);
    //cout << getFunc((ll)1 << 62);
    //cout << ans << endl;
    if (ans == 0) cout << "Bob";
    else cout << "Alice";
}

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

const int INF = 1000000000;

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

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

        for(int l=0;l<m;l++){
            for(int i=0;i<m;i++){
                for(int j=0;j<m;j++){
                    if(C[i][j]>C[i][l]+C[l][j]){
                        C[i][j]=C[i][l]+C[l][j];
                    }
                        if(T[i][j]>T[i][l]+T[l][j]){
                        T[i][j]=T[i][l]+T[l][j];
                    }
                }
            }
        }
        
        int k;
        cin>>k;
        for(int i=0; i<k; i++){
            int p,q,r;
            cin>>p>>q>>r;
            if(r==0){
                cout<<C[p-1][q-1]<<endl;
            }else{
                cout<<T[p-1][q-1]<<endl;
            }
        }








	}

	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int k,a[40],f;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		if(a[x]!=y&&a[x]||n>1&&x==1&&y==0)
		{
			f=1;
		}
		a[x]=y;
	}
	if(f)
	{
		cout<<-1;
		return 0;
	}
	int i=1;
    if(a[1]==0&&n>1)
     cout<<1,i++;
	for(;i<=n;i++)
	 cout<<a[i];
	  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 1000000
#define LL long long
int T,F;
int n,cnt;LL a[MAXN+5];
LL read(){
   	LL x=0,F=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
   	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*F;
}
struct edge{
	int u,v;
}e[MAXN+5];
int main()
{
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	n=read();
	if((n)==(n&(-n))){printf("No\n");return 0;}
	for(int i=2;i+1<=n;i+=2){
		e[++cnt]=(edge){i,i+1};
		e[++cnt]=(edge){n+i,n+i+1};
		e[++cnt]=(edge){1,i};
		e[++cnt]=(edge){1,n+i+1};
	}
	e[++cnt]=(edge){n+1,3};
	if(n%2==0){
		int tmp=n,bit=-1;
		while(tmp){
			bit++;tmp>>=1;
		}
		int a=(1<<bit),b=n-a;
		e[++cnt]=(edge){n*2,b};
		e[++cnt]=(edge){n,n+a+1};
	}
	printf("Yes\n");
	for(int i=1;i<=cnt;i++)
	printf("%d %d\n",e[i].u,e[i].v);
}

Measured memory_bytes: 3840
n = int(input())
dp = [[0]*3 for i in range(n)]
li = [list(map(int, input().split())) for i in range(n)]
dp[0] = li[0]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1]+li[i][0], dp[i-1][2]+li[i][0])
    dp[i][1] = max(dp[i-1][0]+li[i][1], dp[i-1][2]+li[i][1])
    dp[i][2] = max(dp[i-1][0]+li[i][2], dp[i-1][1]+li[i][2])

print(max(dp[-1][0], dp[-1][1], dp[-1][2]))

Measured memory_bytes: 50204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  int count=0;
  cin>>x>>y;
  for(int t=0;t<=x;t++){
    int ans=4*x-2*t;
    if(ans==y){
      count++;
    }
  }if(count==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string j="NG";
  int k,a,b;
  cin>>k>>a>>b;
  for(int c=0; c<=1000; c++){
    if(a<=k*c&&k*c<=b){
      j="OK";
    }
  }
  cout<<j<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

struct UnionFind {
    vector<int> p;
    vector<int> r;

    UnionFind(int n){
        p.resize(n, -1);
        r.resize(n, 1);
    }

    int find(int x){
        if(p[x] == -1) return x;
        else return p[x] = find(p[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        
        if(x == y) return;
        if(r[x] > r[y]) swap(x, y);
        if(r[x] == r[y]) ++r[y];

        p[x] = y;
    }
};

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

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        uf.unite(a, b);
    }

    vector<int> cnt(n, 0);
    rep(i, n){
        ++cnt[uf.find(i)];
    }

    int res = 0;
    rep(i, n) res = max(res, cnt[i]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String tmp = br.readLine();
		
		int numbers[] = new int[4];
		
		for(int i = 0; i < 4; i++){
			numbers[i] = tmp.charAt(i) - '0';
		}
		
		String[] op = {"+","-"};
		//全探索
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2; j++){
				for(int k = 0; k < 2; k++){
					int result = numbers[0];
					
					if(i == 0){
						result += numbers[1];
					}
					else {
						result -= numbers[1];
					}
					
					if(j == 0){
						result += numbers[2];
					}
					else {
						result -= numbers[2];
					}
					
					if(k == 0){
						result += numbers[3];
					}
					else {
						result -= numbers[3];
					}
					
//					System.out.println(result);
					if(result == 7){
						System.out.println(numbers[0] + op[i] + numbers[1] + op[j] + numbers[2] + op[k] + numbers[3] + "=7");
						return;
					}
				}
			}
		}
		
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = k; i <= (n + 1); i++)
    {
        ans += (i * (n - i + 1));
        ans++;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
//ABC074C
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


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

    double MAX = -1,Sugar,Water;
    int  Sugar_Water,Sugar_ans;

    for(int a=0;a<31;++a){
        for(int b=0;b<31;++b){
            Water = 100*a*A+100*b*B;
            for(int c=0;C*c<=F;++c){
                for(int d=0;D*d<=F;++d){
                    Sugar = C*c+D*d;
                    if(Sugar > Water/100*E) break;
                    if(Water+Sugar>F) break;
                    if(MAX < 100*Sugar/(Water+Sugar)){
                        Sugar_Water = Water+Sugar;
                        Sugar_ans = Sugar;
                        MAX = 100*Sugar/Sugar_Water;
                    }
                }
            }
        }
    }

    cout<<Sugar_Water<<" "<<Sugar_ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
int main()
{

    //fopen();
    fastio;
    int n,p;
    cin>>n;
    rep(i,n)
    {
        cin>>p;
        if(p%2==0)
        {
            if(p%3==0 || p%5==0)
                {continue;}
            cout<<"DENIED";
            return 0;
        }
    }  
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

d = {}

for a in A :
    d.setdefault(a,0)
    d[a] += 1

# print(d)
for i in range(N) :
    if i+1 in d :
        print(d[i+1])
    else :
        print(0)

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(n);i<end;++i)
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v,n) rep(i,n) cin >> v[i]

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x) (+ 1 2)) => [](int x) -> int { return 1+2; }

int main(){
  int a,b,c,d,e,k;cin >> a >> b >> c >> d >> e >> k;
  if(e-a<=k) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return 0;
}


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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (0 < x + r && x + r <= W && 0 < y + r && y + r <= H)cout << "Yes" << endl;
	else cout << "No"<<endl;
	
    return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
int main () {
  int n;
  int i;
  int num;

  scanf ("%d", &n);

  int a[n];
  int ans[n];

  for (i = 0; i < n; i++) {
    scanf ("%d", &a[i]);
  }

  for (i = 0; i < n; i++) {
    num = a[i];
    ans[num - 1] = i + 1;
  }

  for (i = 0; i < n; i++) {
    printf ("%d ", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 1536
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 998244353;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) { for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n) {for (int i = 0; i < n; i++)cin >> a[i];}
//continue break deque stack queue sort reverse accumulate  count lower_bound upper_bound
// next_permutation copy_n __builtin_popcount

signed  main() {
  SPD_emergency

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  //int t; cin >> t; int tt = 1; while (t--)
  {
   int r;
   cin >> r;
   double ans = 2 * 3.141592653589 * r;
   cout<<ans<<endl; 
   
  }
  return 0;
}

Measured memory_bytes: 3788
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

bool solve(long long X) {
    for (long long a = 0; a < 5000; a++) {
        for (long long b = -100; b <= a; b++) {
            if (X == (a*a*a*a*a - b*b*b*b*b)) {
                cout << a << " " << b;
                return true;
            }
        }
    }
    return false;
}

int main() {
    long long X;
    cin >> X;
    solve(X);
    return 0;
}

Measured memory_bytes: 3584
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[200010][4];
int main() {
    string s; cin >> s;
    int N = s.size();

    memset(dp, -1, sizeof(dp));
    for(int i=1; i<=min(N, 3); i++) dp[i][i] = 1;

    for(int i=0; i<N; i++) {
        for(int j=1; j<=3; j++) {
            if(dp[i][j] < 0) continue;
            string x = s.substr(i-j, j);
            for(int k=1; k<=3; k++) {
                if(i + k > N) continue;
                string y = s.substr(i, k);
                if(x != y) chmax(dp[i+k][k], dp[i][j] + 1);
            }
        }
    }

    int ans = -1;
    for(int i=1; i<=3; i++) chmax(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000003
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17

using namespace __gnu_pbds ;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int a[maxn] , b[maxn] ;

const int bitMax = 300002 ;

int bit[bitMax] ;

void update( int y, int val ) // update the value of 1 <= y <= bitMax
{
    int temp = y;

    while( y < bitMax )
    {
        bit[y] += val;
        y += (y&(-y));
    }
}

int query( int y ) //sum of all numbers from 1 to y (inclusive)
{
    int  sum = 0;

    while( y > 0 )
    {
        sum += bit[y];
        y -= (y&(-y));
    }
    return sum;
}

i64 f(int m, int n)
{
    memset(bit, 0 , sizeof(bit)) ;
    int i , j , k ;
    int offset = 100010 ;

    for(i=1 ; i<=n ;i++)
    {
        if( a[i]<=m ) b[i] = 1 ;
        else b[i] = -1 ;
    }
    i64 ans = 0LL ;
    for(i=1 ; i<=n ; i++)
    {
        offset -= b[i] ;
        update( b[i]+offset , 1 ) ;
        ans += (i - query( offset ) ) ;
    }
    return ans ;
}

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d",&n) ;

    for(i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;

    int lo = 0 , hi = 2000000000 , mid ;

 //   printf("%lld\n",f(25,n)) ;

    while(lo<hi)
    {
        mid = (lo+hi)/2 ;

        i64 tot = f(mid,n) ;

        if( tot >= (1LL*n*(n+1))/4 + 1LL ) hi = mid ;
        else lo = mid+1 ;
    }

    printf("%d\n",lo) ;

    return 0 ;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) ++count;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

ll d[60][200200];
const ll inf=1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //reopen("input.txt", "r", stdin);
    ll n,k; cin >> n >> k;
    k*=n;
    vector<int> a(n);
    map<int,vector<int>> mp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]].push_back(i);
    }
    for(auto p:mp){
        int sz=p.second.size();
        p.second.push_back(p.second[0]+n);
        for(int i=0;i<sz;i++){
            d[0][p.second[i]]=p.second[i+1]-p.second[i]+1;
        }
    }
    for(int i=0;i<59;i++){
        for(int j=0;j<n;j++){
            d[i+1][j]=min(inf,d[i][j]+d[i][(j+d[i][j])%n]);
        }
    }
    ll cur=0;
    for(int i=59;i>=0;i--){
        if(cur+d[i][cur%n]<=k){
            cur+=d[i][cur%n];
        }
    }
    if(cur==k){
        return 0;
    }
    vector<int> res;
    set<int> s;
    for(ll i=cur%n;i<n;i++){
        if(s.find(a[i])==s.end()){
            res.push_back(a[i]);
            s.insert(a[i]);
        }
        else{
            while(1){
                int v=res.back();
                res.pop_back();
                s.erase(v);
                if(v==a[i])break;
            }
        }
    }
    for(int i=0;i<res.size();i++){
        if(i)printf(" ");
        printf("%d",res[i]);
    }
    printf("\n");
}


Measured memory_bytes: 129920
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll k,x,i,j;
	cin>>k>>x;
	for(i=x-k+1;i<x+k;i++)
		cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
double add(double a,double b){
	if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{
	double x,y;
	int id;
	P() {}
	P(double x,double y):x(x),y(y){}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(d*x,d*y);
	}
	double dot(P p){
		return add(x*p.x,y*p.y);
	}
	double det(P p){
		return add(x*p.y,-y*p.x);
	}
	double norm(){
		return sqrt(sq(x)+sq(y));
	}
	bool operator < (const P& p) const{
		if(x!=p.x)return x<p.x;
		else return y<p.y;
	}
};
vector<P> convex_hull(P* ps,int n)
{
	sort(ps,ps+n);
	int k=0;
	vector<P> qs(2*n);
	for(int i=0;i<n;i++)
	{
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--)
	{
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}
P normal(P a){
	return P(a.y,-a.x);
}
double calc(P a,P b){
	return acos(a.dot(b)/a.norm()/b.norm())/2.0/M_PI;
}
int N;
P v[105];
double ans[105];
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		scanf("%lf %lf",&v[i].x,&v[i].y);
		v[i].id=i;
	}
	if(N==2){
		printf("0.5\n0.5\n");
		return 0;
	}
	vector<P> cv = convex_hull(v,N);
	int M = cv.size();
	for(int i=0;i<M;i++){
		int idx = cv[i].id;
		if(M==2)ans[idx]=0.5;
		else ans[idx] = calc(normal(cv[i]-cv[(i+M-1)%M]),normal(cv[(i+1)%M]-cv[i]));
	}
	for(int i=0;i<N;i++)printf("%.16f\n",ans[i]);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int i,n,a[45];

  a[0] = 1;
  a[1] = 1;
  
  scanf("%d",&n);

  for(i = 2; i <= n; i++)
    a[i] = a[i-1] + a[i-2];
  printf("%d\n",a[n]);
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

vector<bool> b_sta(1e5+10,false);

ll gcd(ll m, ll n){
  return n ? gcd(n,m%n) : m;
}

ll lcm(ll m,ll n){
  return m / gcd(m,n) * n;
}
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  //割り切れるものの数
  a--;
  ll div_a = (a/c) + (a/d);
  ll div_b = (b/c) + (b/d);
  ll g_a = (ll)(a/lcm(c,d));
  ll g_b = (ll)(b/lcm(c,d));
 
  div_a -= g_a;
  div_b -= g_b;
  ll ans = (b-a) - (div_b - div_a);
  //cout << div_b << " " << div_a << " " << b-a << endl;
  
  cout << ans << endl; 
}

Measured memory_bytes: 256
# -*- coding : utf-8 -*-

def maximum_profit(price_list):
    max = price_list[1] - price_list[0]
    min = price_list[0]
    for i in range(1, len(price_list)):
        if max < price_list[i] - min:
            max = price_list[i] - min
        if min > price_list[i]:
            min = price_list[i]
    return max

input_num = int(input())
price_list = list()
for i in range(input_num):
    input_price = int(input())
    price_list.append(input_price)
print(maximum_profit(price_list))

Measured memory_bytes: 15640
#include <iostream>

using namespace std;

#define MAX 10000

/*****************************************
* these methods show the node idx in array
* as example i = 2
* parent = 1 in array A[1]
* left = 2
* right = 3
*****************************************/
int parent(int i) { return i / 2; }

int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

void print(int H, int A[]) {
    for (int i = 1; i <= H; i++) cout << A[i] << " ";
    cout << endl;
}


int main()
{
    int H, i, A[MAX+1];

    cin >> H;

        //upload data to array
    for (i = 1; i<= H; i++) cin >> A[i];
    //print(H, A);
    //cout << "**********************************" << endl;
    for (i = 1; i <= H; i++) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3128
//#define NDEBUG
 
#include <bits/stdc++.h>
 
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
 
//#define TEST
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
 
const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << "\n";

    return 0;
}

Measured memory_bytes: 256