akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return 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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n), b(n);
    cin >> a >> b;
    ll sum_plus = 0, sum_minus = 0;
    int ans = 0;
    priority_queue<ll> Q;
    rep(i, n) {
        if(a[i] > b[i]) {
            sum_plus += a[i] - b[i];
            Q.push(a[i] - b[i]);
        }else if(a[i] < b[i]) {
            sum_minus += b[i] - a[i];
            ans++;
        }
    }
    if(sum_minus == 0) {
        puts("0");
        return 0;
    }else if(sum_plus < sum_minus) {
        puts("-1");
        return 0;
    }
    while(!Q.empty()) {
        ll p = Q.top();
        Q.pop();
        ans++;
        sum_minus -= p;
        if(sum_minus <= 0) {
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4672
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    a.sort(reverse=True)
    res = []
    k = a[0]
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if k&1:
        if a[-1] <= k//2:
            print("Impossible")
            exit()
        if d[k//2+1] != 2:
            print("Impossible")
            exit()
        for i in range(k//2+2,k+1):
            if d[i] < 2:
                print("Impossible")
                exit()
    else:
        if a[-1] < k//2:
            print("Impossible")
            exit()
        if d[k//2] != 1:
            print("Impossible")
            exit()
        for i in range(k//2+1,k+1):
            if d[i] < 2:
                print("Impossible")
                exit()
    print("Possible")



    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 39916
def solve(n):
    a, b, c, m = 1, 1, 1, 1
    mod = 1000000007
    while n > 0:
        if n & 1:
            a = (a * 10 ** m) % mod
            b = (b * 9 ** m) % mod
            c = (c * 8 ** m) % mod
        n >>= 1
        m *= 2
    print((a - 2*b + c) % mod)

solve(int(input()))

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


int main()
{
	int N;
	cin>>N;
	vector<int> A(N);
	int neg_cnt=0;
	ll ans=0;
	int min_v=1e9+1;
	rep(i,N)
	{
		cin>>A[i];
		neg_cnt+=A[i]<0;
		ans+=abs(A[i]);
		min_v=min(min_v,abs(A[i]));
	}
	if(neg_cnt%2==0)
	{
		cout<<ans<<endl;
	}
	else
	{
		cout<<ans-2*min_v<<endl;
	}
	return 0;
}


Measured memory_bytes: 3776
#include<iostream>

using namespace std;

int main(){

	int  a, b,c, counter= 1, sum=1;

	while(cin >> a>>b){ 
		sum=a+b;
		
		while(sum/10!=0){
			sum=sum/10;
			counter++;
		}
		
		cout<<counter<<endl;

		counter=1;
		
		

	}

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
 using namespace std;
 int main(int argc, char const *argv[])
 {
 	int a,b;
 	string str;
    cin>>a>>b;
    cin.ignore();
    getline(cin,str);
    if( str.at(a) == '-' && str.size() == a+b+1){

    int cpt=0;
    for(int i=0;i<str.size();i++)
    	if(i!=a)
		if ( isdigit(str.at(i)) !=0 )
    		{ cpt++; continue;}
        else
        	{  cout<<"No";
               break;}
    if(cpt+1 == str.size()) cout<<"Yes";
    }
    else
    	cout<<"No";
 	return 0;
 }

Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int,input().split()))
x = 1
if 0 in a:
    print(0)
    sys.exit()
for num in range(n):
    x  *= a[num]
    if x > 10**18:
        print(-1)
        sys.exit()
print(x)

Measured memory_bytes: 21708
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 500010 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int maxn[N<<2];
int n,k;
int p[N],ans[N],vis[N];
priority_queue<int,vector<int>,less<int> >Q;
inline void pushup(int x){maxn[x]=p[maxn[x<<1]]>p[maxn[x<<1|1]]?maxn[x<<1]:maxn[x<<1|1];}
void build(int l,int r,int x)
{
	if(l==r){maxn[x]=l;return ;}
	int mid=(l+r)>>1;
	build(l,mid,x<<1);build(mid+1,r,x<<1|1);
	pushup(x);
}
void update(int l,int r,int pos,int x)
{
	if(l==r){maxn[x]=0;return ;}
	int mid=(l+r)>>1;
	if(pos<=mid)update(l,mid,pos,x<<1);
	else update(mid+1,r,pos,x<<1|1);
	pushup(x);
}
int query(int l,int r,int x,int left,int right)
{
	left=max(left,1);right=min(right,n);if(left>right)return 0;
//	if(x)cout<<"WTF:"<<l<<" "<<r<<" "<<x<<" "<<left<<" "<<right<<endl;
	if(l==left&&right==r)return maxn[x];
	int mid=(l+r)>>1;
	if(right<=mid)return query(l,mid,x<<1,left,right);
	else if(left>mid)return query(mid+1,r,x<<1|1,left,right);
	else 
	{
		int ls=query(l,mid,x<<1,left,mid),rs=query(mid+1,r,x<<1|1,mid+1,right);
		return p[ls]>p[rs]?ls:rs;
	}
}
inline int check(int x)
{
	if(vis[x])return 0;
	return query(1,n,1,x-k+1,x+k-1)==x;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),k=read();
	for(register int i=1;i<=n;i++)p[i]=read();
	build(1,n,1);
	for(register int i=1;i<=n;i++)if(check(i))Q.push(i),vis[i]=1;
	for(register int i=n;i>=1;i--)
	{
		int x=Q.top();Q.pop();ans[x]=i;int y;
		update(1,n,x,1);
		if(check(y=query(1,n,1,x-k+1,x-1)))Q.push(y),vis[y]=1;
		if(check(y=query(1,n,1,x+1,x+k-1)))Q.push(y),vis[y]=1;
	}
	for(register int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 15900
/******************************************************************************
 
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
 
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define ee endl
#define re return 
//Author Rahul Sannigrahi
 
int countdigit(int n)
{
    return floor(log10(n)+1);
}
 
int power(int x,int y)
{
    int res=1;
    
    while(y>0)
    {
       if(y&1)
       res=res*x;
       
       y=y>>1;
       x*=x;
    }
    re res;
}    
    
bool isprime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<n; i=i+6) 
        if ((n%i==0)|| n%(i+2)==0) 
           return false; 
  
    return true; 
} 
 
 
int solve()
{
   int x,y,i,j,k;
   cin>>x>>y;
   if(y%2!=0)
   {
       cout<<"No"<<ee;
       re 0;
   }
   if(y/x>=2&&y<=4*x)
   {
       cout<<"Yes"<<ee;
       re 0;
   }
   else
   {
       cout<<"No"<<ee;
       re 0;
   }
   
   
 return 0;
}
 
int32_t main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--)
    solve();
    return 0;
}
 


Measured memory_bytes: 3668
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] S = new String[N];
        int[] P = new int[N];
        Restaurant[] restaurants = new Restaurant[N];
        ArrayList<Restaurant> al = new ArrayList<Restaurant>();
        for(int i = 0; i < N; i++) {
            S[i] = sc.next();
            P[i] = sc.nextInt();
            restaurants[i] = new Restaurant(i+1, S[i], P[i]);
            al.add(restaurants[i]);
        }
        sc.close();

        Collections.sort(al, new RestaurantCompare());
        for (Restaurant restaurant : al) {
            System.out.println(restaurant.index);
        }
    }
}

class Restaurant {
    int index;
    String name;
    int score;
    Restaurant(int index_p, String name_p, int score_p) {
        index = index_p;
        name = name_p;
        score = score_p;
    }
    public int getIndex() {
        return index;
    }
}

class RestaurantCompare implements Comparator<Restaurant> {
    public int compare(Restaurant a, Restaurant b) {
        if (a.name.compareTo(b.name) < 0) {
            return -1;
        } else if (a.name.compareTo(b.name) == 0) {
            if (a.score > b.score) {
                return -1;
            }
            return 1;
        } else {
            return 1;
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define in(j,n) for(j=0;j<n;j++)
#define inp(j,n) for(j=1;j<=n;j++)
#define lo(i,st,n) for(i=st;i<n;i++)
#define pb push_back
#define csbits(n) __builtin_popcount(n)
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false)
int main()
{
	fastio;
	ll i,j,n,k;
	cin>>n>>k;
	ll h[n+1];
	h[0]=0;
	inp(j,n)
		cin>>h[j];
	ll dp[n+1];
	in(j,n+1)
		dp[j]=(ll)1e18;
	dp[0]=0;
	dp[1]=0;
	inp(i,n){
		inp(j,k){
			if(i+j>n)
				break;
			dp[i+j]=fmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long s,f=0,t=1;

int main()
{
	cin >> s;
	while(s) {
		f+=t;
		t*=2;
		s/=2;
	}
	cout << f ;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int n;
	vector<int> l;
	n = intinput();
	l = forintinput(n);
	int cnt = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			for(int k = 0;k < n;k++){
				if(l[i] < l[j] && l[j] < l[k]){
					if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
						cnt++;
					}
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3776
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,x;
    
    int a,b,c;
    
    int count;
    
    while(1){
        count=0;
        scanf("%d %d",&n,&x);
        
        if(n==0 && x==0){
            break;
        }
        
        for(a=1;a<n-1;a++){
            for(b=a+1;b<n;b++){
                for(c=b+1;c<n+1;c++){
                    if(a+b+c==x){
                        
                        count++;
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    
    
    return 0;
}


Measured memory_bytes: 2044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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


class CColon {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
    long double PI = 3.14159265358979323846264338327950L;

	void solve(std::istream& in, std::ostream& out) {
        long double A, B, H, M;
        in >> A >> B >> H >> M;
        long double degree = PI * ((M / 30.0L) - (H/ 6.0L + M / 360.0L));
        out << setprecision(64)  << sqrtl(A * A + B * B - 2L * A * B * cosl(degree)) << endl;
	}
};


int main() {
    ios::sync_with_stdio(false);
	CColon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4200
#D問題
A,B = map(int,input().split())
def f(n):
    if n%2 == 0:
        if (n//2)%2 == 0:
            return n
        else:
            return n+1
    else:
        if ((n-1)//2)%2 == 0:
            return 1
        else:
            return 0
        
FB = f(B)
FA = f(A-1)
print(FB^FA)
        
    

Measured memory_bytes: 3060
from bisect import bisect_left as bisect
N,Q = map(int,input().split())
event = [tuple(map(int,input().split())) for i in range(N)]
D = [int(input()) for i in range(Q)]

event.sort(key=lambda x:x[2])

ans = [-1]*Q
neg = [-1]*Q

for s,t,x in event:
    l = bisect(D,s-x)
    r = bisect(D,t-x)
    t = l
    while t < r:
        if neg[t] == -1:
            ans[t] = x
            neg[t] = r
            t += 1
        else:
            t = neg[t]

for i in range(Q):
    print(ans[i])

Measured memory_bytes: 54004
function main(lines) {
 const input = lines.split('\n').map(Number)
 
 var flag = false;
 for(var i=1; i<10; i++){
     if(input[0]%i === 0 && 1<= input[0]/i && input[0]/i <= 9 ){
         flag = true;
         break;
     }
 }
 
 flag ? console.log('Yes') : console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
def main():
    a, b = map(int, input().split())
    ans = -1
    for i in range(10000, -1, -1):
        tax1 = int(i*0.08)
        tax2 = int(i*0.10)
        if tax1 == a and tax2 == b:
            ans = i
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;

int main()
{
    ll N,X,res;
    cin >> N >> X;

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

    ll D = 0;

    ll cnt = 1;
    REP(i,N)
    {
        D += L[i];
        if( D <= X)cnt++;
    }
    cout << cnt << endl;

}



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


int main(){

    int N;
    scanf("%d",&N);

    int A[N];
    int i;

    for(i = 0; i < N; i++){
        A[i] = 0;
    }

    int tmp;
    for(i = 0; i < N-1; i++){
        scanf("%d",&tmp);
        A[tmp-1] += 1;
    }

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

   return 0;
}

Measured memory_bytes: 2512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100005],f[100005],nxt[100005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	a[n+1]=-1;
	for(int i=n;i;i--){
		nxt[i]=i;
		if(a[i]==a[i+1]) nxt[i]=nxt[i+1];
	}
	f[0]=1;
	for(int i=1,pre=0;i<=n;i++){
		if(a[i]!=a[i-1]) pre=a[i-1];
		else{
			f[i]=f[i-1];continue;
		}
		int w=a[i]+n-i;
		f[i]=!(w&1);
		if(f[i]){
			if(pre>n-i+1) f[i]=f[i-1];
			else if(n-nxt[i]>a[i]) f[i]=2;
		}else{
			if(pre>=n-i+1) f[i]=f[i-1];
			else if(n-nxt[i]>=a[i]) f[i]=2;
		}
	}
	f[n+1]=0;
	for(int i=n;i;i--){
		if(f[i]==2) f[i]=f[i+1];
		if(f[i]==1) return puts("First"),0;
	}
	puts("Second");
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll t, a, b, c, d;

ll gcd(ll _n1, ll _n2){
	if(_n1 < _n2){ll tmp = _n1; _n1 = _n2; _n2 = tmp;}
	if(_n1 == _n2 || _n2 == 0){return _n1;}
	return gcd(_n2, _n1%_n2);
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> t;
	rep(i, 1, t){
		cin >> a >> b >> c >> d;
		if(b > a || d < b){
			print("No")
		}
		else{
			if(c >= b){
				print("Yes")//no
			}
			else{
				ll syuki = gcd(b, d);
				ll table = a%b;
				ll grgr = (c-table)/syuki;
				//cout << syuki << table << grgr << endl;
				if(table > c || table+(grgr+1)*syuki < b){
					print("No")
				}
				else{
					print("Yes")
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

func lib_CopyInt8(values []int8) []int8 {
	dst := make([]int8, len(values))
	copy(dst, values)
	return dst
}
func lib_ReverseInt8(values []int8) []int8 {
	newValues := lib_CopyInt8(values)
	for i, j := 0, len(values)-1; i < j; i, j = i+1, j-1 {
		newValues[i], newValues[j] = values[j], values[i]
	}
	return newValues
}
func lib_ToDigitSliceInt(n int) (digits []int8) {
	nn := int64(n)
	for {
		if nn <= 0 {
			return lib_ReverseInt8(digits)
		}
		digit := int8(nn % 10)
		digits = append(digits, digit)
		nn /= 10
	}
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	fmt.Println(solve(N))
}
func solve(N int) string {
	digits := lib_ToDigitSliceInt(N)
	switch digits[len(digits)-1] {
	case 2, 4, 5, 7, 9:
		return "hon"
	case 0, 1, 6, 8:
		return "pon"
	case 3:
		return "bon"
	}
	return ""
}


Measured memory_bytes: 1760
import string
   
count = {x: 0 for x in string.ascii_lowercase}
lines = ""
   
while True:
    try:
        lines += input().lower()
    except EOFError:
        break
           
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
           
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 7996
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x;
    cin, x;
    int sz = 5010;
    for (ll a : Range(sz)) {
        for (ll b : Range(sz)) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                print(a, b);
                return 0;
            }
            if (a * a * a * a * a + b * b * b * b * b == x) {
                print(a, -b);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3640
/* March 28 2020 */

#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>

#define ll long long

int main(void) {
    char st[7];
    scanf("%s", st);
    if (st[2] == st[3] && st[4] == st[5]) puts("Yes");
    else puts("No");
    return 0;
}



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

using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 7 && b == 5 && c == 5 )||	(a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7)){
		cout << "YES" << endl;
		
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

char m[100][100] = {};
int s = 100;
int main() {
	ll a, b; cin >> a >> b;
	rep(i, 0, s) {
		rep(j, 0, s) {
			m[i][j] = ((i < s / 2) ? '#' : '.');
		}
	}

	a--; b--;
	int i = 0, j = 0;

	rep(i, 0, s) {
		if (a == 0)break;
		rep(j, 0, s) {
			if (a == 0)break;
			if (i % 2 == 0 && j % 2 == 0) {
				m[i][j] = '.';
				a--;
			}
		}
	}

	rep(i, s / 2 + 1, s) {
		if (b == 0)break;
		rep(j, 0, s) {
			if (b == 0)break;
			if (i % 2 == 0 && j % 2 == 0) {
				m[i][j] = '#';
				b--;
			}
		}
	}

	cout << 100 << " " << 100 << endl;
	rep(i, 0, s) {
		rep(j, 0, s) {
			cout << m[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1E9 + 7;
int power(int base, int exp) {
    int result = 1;
    while (exp > 0) {
        if (exp & 1)
            result = 1LL * result * base % P;
        base = 1LL * base * base % P;
        exp >>= 1;
    }
    return result;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    function<array<int, 2>(int, int, int)> calc = [&](int l, int r, int low) {
        if (l == r)
            return array<int, 2>{1, 0};
        int mn = 1E9;
        array<int, 2> dp {1, 1};
        for (int i = l; i < r; ++i)
            mn = min(mn, h[i]);
        int x = l, cnt = 0;
        for (int i = l; i < r; ++i) {
            if (h[i] == mn) {
                auto f = calc(x, i, mn);
                x = i + 1;
                ++cnt;
                dp[0] = 1LL * dp[0] * f[0] % P;
                dp[1] = 1LL * dp[1] * (f[0] + f[1]) % P;
            }
        }
        auto f = calc(x, r, mn);
        dp[0] = 1LL * dp[0] * f[0] % P;
        dp[1] = 1LL * dp[1] * (f[0] + f[1]) % P;
        int tmp = power(2, mn - low);
        dp[1] = (1LL * power(2, cnt) * dp[1] + 1LL * (tmp - 2 + P) * dp[0]) % P;
        dp[0] = 1LL * tmp * dp[0] % P;
        return dp;
    };
    cout << calc(0, n, 0)[1] << endl;
    return 0;
}

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

long getGCD(long x, long y) {
    while (x % y != 0) {
        long temp = x % y;
        x = y;
        y = temp;
    }
    return y;
}

int main() {
    long x, y;
    cin >> x >> y;

    long gcd = getGCD(x, y);
    cout << gcd << endl;
}



Measured memory_bytes: 3092
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int n;
  double a[104];
  double sum = 0;
  int i;

  scanf("%d", &n);

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

  printf("%f\n", 1.0/sum);
  return 0;
}


Measured memory_bytes: 256
open Str

module L =
  struct
    include List
  
    let rec take n = function
        [] -> []
      | h :: t when n > 0 -> h :: take (n - 1) t
      | _ -> []

    let sum ls =
      fold_left (+) 0 ls
  end
    
let flip f x y = f y x

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f

let () = 
  let n, k = match read_list int_of_string with
      a :: b :: _ -> (a, b)
    | _ -> failwith "read_list" in
  let ls = read_list int_of_string in
  L.sort (flip compare) ls |> L.take k |> L.sum |> string_of_int |> print_endline


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

using namespace std;

int binary(int a){
    int count = 0 ;
    while(a % 2 == 0){
        a = a / 2;
        count++;
    }
    return count;
}

int main(){
    int n; cin >> n;
    
    vector<int> a(n);
    for(int i = 0 ; i < n ;i++) cin >> a[i];
    
    vector<int> b(n);
    
    for(int k = 0 ; k < n ; k++)
        b[k] = binary(a[k]);
    
    sort(b.begin(),b.end());
    
    cout << b[0] << endl;
}

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

#define pb push_back
#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i <= n; i++)

#define dbg(x) cout << #x << " = " << x << endl
#define all(x) x.begin(),x.end()
#define ms(x, i) memset(x, i, sizeof(x))

#define p(x) cout << x << "\n"
#define pv(x) fr(i, x.size()) cout << x[i] << " \n"[i==x.size()-1]

#define f first
#define s second

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f;

#define maxn 2123

vi adj[maxn];
int ans[maxn], vis[maxn];

int main() {
    fastio;
    int n, x, y;
    cin >> n >> x >> y;

    frr(i, n-1) {
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }

    adj[x].pb(y);
    adj[y].pb(x);

    frr(i, n) {
        ms(vis, 0);

        queue<pii> q;
        q.push({0, i});
        while (!q.empty()) {
            int u = q.front().s;
            int d = q.front().f;
            q.pop();

            if (vis[u]) continue;
            vis[u] = 1;

            if (u > i) ans[d]++;
            for (auto v: adj[u]) q.push({d+1, v});
        }
    }

    frr(i, n-1) p(ans[i]);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i;
    string str;
    cin>>str;
    for(i=0; i<str.length(); i++){
        if(str[i]==','){
            cout<<" ";
        }else{
            cout<<str[i];
        }
    }
    cout<<endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int Fcount = 0, Scount = 0;
  char First;
  char Second;
  
  for (int i = 0; i < S.size(); i++){
    if (i == 0){
      First = S[i];
      Fcount ++;
      continue;
    }
    if (S[i] == First){
      Fcount ++;
    }else{
      if (Scount == 0){
        Second = S[i];
        Scount ++;
      }else if (S[i] == Second){
        Scount ++;
      }
    }
  }
  
  if (Fcount == 2 && Scount == 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
#include <thread>
#include <fstream>

using namespace std;

//const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 1050; //       e5
//const int SZ = 122;

int a[2];

int main()
{
    //epic(); return 0;
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n;
    cin >> n;
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    b -= a;
    n --;
    //cerr << b << endl;
    for(int x = 0; x <= n; x++){
        long long y = n - x;
        long long min_value = x * c - y * d;
        if(min_value > b) continue;
        long long add = (d - c) * n;
        if(min_value + add < b) continue;
        //cerr << min_value + add << ' '  << b << endl;
        //cerr << x << ' ' << y << endl;
        cout << "YES" << endl; return 0;
        // FUUUUUUUUUUUUUUCK
        long long need = b - min_value;
        long long add_to_all = need / n;
        long long cnt_add = need % n;
        for(int i = 0; i < n; i++){
            long long value;
            if(i < x){
                value = c;
                value += add_to_all;
                if(i < cnt_add) value++;
            }else{
                value = d;
                value -= add_to_all;
                if(i < cnt_add) value--;
            }
            cout << value << ' ';
        }
        cout << endl; return 0;

    }
    cout << "NO" << endl;
    return 0;
}
// 5 4 5 5
// 1 6 10 5 0


// x * c - y * d < b
// xc - (n - x)d < b;
// x(c - d) < b + nd
// x > (b + nd) / (d - c)


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	int N, M, K;

	cin >> N >> M;
	if (N == M) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}







}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i=9,x,t=0;
    cin>>x;
    while(1)
    {
        if(x%i==0 && (x/i)<=9 && 1<=(x/i))
        {
            cout<<"Yes"<<endl;
            t=0;
            break;
        }
        else
            t=1;
        i--;
        if(i==0)
            break;

    }
    if(t==1)
        cout<<"No"<<endl;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d,e,k;
    cin >>a>>b>>c>>d>>e>>k;
    if ((max({a,b,c,d,e}) - min({a,b,c,d,e})) <= k)
        cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int sum = Integer.parseInt(buf);
				int m = 0;
				for (int i=0;i<12;i++) {
					StringTokenizer st = new StringTokenizer(br.readLine());
					if (sum>0) {
						sum -= (Integer.parseInt(st.nextToken())-Integer.parseInt(st.nextToken()));
						if (sum<=0) m = i+1;
					}
				}
				if (m==0) System.out.println("NA");
				else System.out.println(m);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 22956
class _Node {
  constructor(key, left = null, right = null) {
    this.key = key;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null);
      while (x !== null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 197812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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


  string s;int n;cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    // cout<<s.substr(i,2)<<endl;
    if(s.substr(i,3)=="ABC")ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N,M;
  int ans=0;
  cin>>N>>M;
  vector<int>A(M);
  for(int i=0;i<M;i++){
    cin>>A[i];
  }
  for(int i=0;i<M;i++){
    ans-=A[i];
  }
  if(N+ans>=0){
    cout<<N+ans<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 3604
n, k = map(int, input().split())
A = list(map(int, input().split()))

D = 60 #10**18は60桁なので2の59乗まで見る
MAX_N = 200005 #頂点番号
to = [[0 for _ in range(MAX_N)] for _ in range(D)]

#to[i][j]:jから2^i個先の頂点
for i in range(n):
    to[0][i] = A[i]
    to[0][i] -= 1

#ダブリングの表
for i in range(D-1):
    for j in range(n):
        to[i+1][j] = to[i][to[i][j]]

v = 0
for i in range(D-1, -1, -1):
    l = 1<<i #2^i個先を見る
    if l <= k:
        v = to[i][v]
        k -= l

print(v+1)

Measured memory_bytes: 218568
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

struct edge{
    ll to,k;
    edge(ll to,ll k):to(to),k(k){};
};

signed main(){
    ll n;
    cin >> n;
    vector<vector<edge> > G(n);
    queue<ll> que;
    bool is_visited[n] = {false};
    ll ans[n-1] = {};
    rep(i,0,n-1) ans[i] = -1;

    rep(i,0,n-1){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[b].push_back(edge(a,i));
        G[a].push_back(edge(b,i));
    }

    ll cnt = 0;
    que.push(0);
    while(!que.empty()){
        ll v = que.front();
        que.pop();

        map<ll,ll> m;
        rep(i,0,G[v].size()){
            if(ans[G[v][i].k] == -1) continue;
            if(m.count(ans[G[v][i].k]) == 0){
                m[ans[G[v][i].k]] = 1;
            }
        }

        ll num = 1;
        rep(i,0,G[v].size()){
            
            while(m.count(num) == 1){
                num++;
            }

            if(ans[G[v][i].k] == -1) ans[G[v][i].k] = num++;
            
            if(!is_visited[G[v][i].to]){
                is_visited[G[v][i].to] = true;
                que.push(G[v][i].to);
            }
        }
    }

    rep(i,0,n-1) cnt = max(cnt,ans[i]);
    cout << cnt << endl;
    
    rep(i,0,n-1){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main(){
	int a,b,c,k;
	
	cin>>a>>b>>c>>k;
	
	if(k==a)
	   cout<<a;
	else if(k>a&&k<=a+b)
	   cout<<a; 
	else if(k<a)
	   cout<<k;
	else
	   cout<<a-(k-a-b);
	
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int R,G;
    cin >> R >> G;
    cout << 2*G-R << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A4
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int len = Integer.parseInt(sc.nextLine());
        int[] store = new int[len]; 
        int[] min = new int[len];
        for(int i=0; i<len; i++){
            store[i] = sc.nextInt();
            if(i==0 || min[i-1] > store[i]){
                min[i] = store[i];
            }
            else{
                min[i] = min[i-1];
            }
        }
        sc.close();
        int currentMax=0;
        int resultMax = (int) -Math.pow(10, 9);
        for(int i=len-1; i>0; i--){
            if(currentMax<store[i]){
                currentMax = store[i];
            }
            if(resultMax < (currentMax-min[i-1])){
                resultMax = (currentMax-min[i-1]);
            }
        }
        System.out.println(resultMax);
    }
}


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

const long long LLINF = LLONG_MAX;
int main()
{
	int N, K;
	pair < long long , long long > point[55];

	long long minv = LLINF;

	cin >> N >> K;
	
	for ( int i = 0; i < N; i++ ) {
		cin >> point[i].first >> point[i].second;
	}

	sort(point, point + N);

	for ( int a = 0; a < N - 1; a++ ) {
		for ( int b = a + 1; b < N; b++ ) {
			long long x_max = point[b].first, x_min = point[a].first;
			vector < long long > vec;
			for ( int i = 0; i < N; i++ ) {
				if ( x_min <= point[i].first && point[i].first <= x_max ) {
					vec.push_back(point[i].second);
				}
			}
			sort(begin(vec), end(vec));
			if ( vec.size() >= K ) {
				long long y_range = LLINF;
				for ( int i = 0; i <= vec.size() - K; i++ ) {
					y_range = min(y_range, vec[i + K - 1] - vec[i]);
				}
				minv = min(minv, (long long)y_range * (x_max - x_min));
			}
		}
	}
	cout << minv << endl;
	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  string S;
  cin >> S;
  S += '?';
  ll N = S.size();

  ll ans = 0, cnt0 = 1, cnt1 = 1;
  for (ll i = 0; i < N - 1; i++)
  {
    if (S.at(i) == '<' && S.at(i + 1) == '<')
      cnt0++;
    else if (S.at(i) == '<' && S.at(i + 1) == '>')
      cnt1 = 1;
    else if (S.at(i) == '>' && S.at(i + 1) == '>')
      cnt1++;
    else
    {
      ll x = max(cnt0, cnt1), y = min(cnt0, cnt1);
      ans += x * (x + 1) / 2 + (y - 1) * y / 2;
      cnt0 = 1, cnt1 = 1;
      //cerr << x << " " << y << " " << ans << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define f1 first
#define s2 second
using namespace std;

long double ans,ans1;
int n;
int x,y;
long double dist(pair<int,int>p1,pair<int,int>p2){
    return sqrt((abs(p1.f1-p2.f1)*abs(p1.f1-p2.f1)+abs(p1.s2-p2.s2)*abs(p1.s2-p2.s2)));
}

int main(){
    cin>>n;
    vector<int>v;
    pair<int,int>p[10];
    for(int i=1;i<=n;i++){
        v.push_back(i);
        cin>>x>>y;
        p[i]={x,y};
    }
    do{
        ans1++;
        for(int i=0;i<n-1;i++){
            //cout<<dist(p[v[i]],p[v[i+1]])<<endl;
            ans+=dist(p[v[i]],p[v[i+1]]);
        }
    }
    while(next_permutation(v.begin(),v.end()));
    cout.precision(8);
    cout<<ans/ans1<<endl;
return 0;
}


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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
	int t;
	t=1;
	while(t--){
		int n;
		cin>>n;
		int arr[n],i,j,k;
		for(i=0;i<n;i++){
			cin>>arr[i];
		}
		
		int sum=0;
		k=arr[n-1];
		for(i=n-2;i>=0;i--){
			j = (k*arr[i])%mod;
			sum = (sum+j)%mod;
			k+=arr[i];
			k = k%mod;
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 5152
N, M = map(int, input().split())
P = list(map(int, input().split()))
par = list(range(N))

def find(x):
    if par[x] == x:
        return x
    par[x] = find(par[x])
    return par[x]

def unite(x, y):
    x, y = find(x), find(y)
    if x != y:
        par[y] = x

for _ in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)

place = {v - 1: i for i, v in enumerate(P)}
ans = 0
for i, v in enumerate(P):
    if find(i) == find(place[i]):
        ans += 1
print(ans)

Measured memory_bytes: 123756
n=int(input())
s=list(str(input()))
if n%2!=0:
            print('No')
elif len(set(s[:n//2]))!=len(set(s[n//2:])):
            print('No')
elif s[:n//2]!=s[n//2:]:
            print('No')
else:
            print('Yes')
            

                        
                        


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

ll lucas(int n) {
  ll l_i2 = -1;
  ll l_i1 = 2;
  rep(i, n) {
    l_i1 = l_i1 + l_i2;
    l_i2 = l_i1 - l_i2;
  }
  return l_i1;
}

int main() {
  int N;
  cin >> N;
  cout << lucas(N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int n,i;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    int m=A[0];
    long long ans=0;
    for(i=1;i<n;i++)
    {
        ans=ans+max(0,m-A[i]);
        m=max(m,A[i]);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 4604
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let a = R int
    let b = R int 
    6-a-b
    |>stdout.WriteLine
    0


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
	map<pair<int,int>,int> m;
	int h,w,n,a,b;
	long long ans[10]={};
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				m[make_pair(a-j,b-k)]++;
			}
		}
	}
	ans[0]=1LL*(h-2)*(w-2);
	for(auto it=m.begin();it!=m.end();++it){
		int x=it->first.first,y=it->first.second,z=it->second;
		if(x>=1&&x+2<=h&&y>=1&&y+2<=w) ans[z]++,ans[0]--;
	}
	for(int i=0;i<10;i++){
		printf("%lld\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 56448
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N, K = inputIntList()
    h = inputIntList()
    h.extend([0] * K)
    dp = [float("inf") for _ in range(N + K)]
    dp[0] = 0
    for i in range(N):
        for k in range(1, K + 1):
            if abs(h[i] - h[i + k]) + dp[i] < dp[i + k]:
                dp[i + k] = abs(h[i] - h[i + k]) + dp[i]
        # print(dp)
    return dp[N - 1]


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 55580
N = int(input())
A = list(map(int, input().split()))
A.sort()
MA = max(A)
dp = [True for _ in range(MA+1)]
flag = [False for _ in range(MA+1)]

for i in range(N):
    a = A[i]
    if not flag[a]:
        flag[a] = True
        t = a*2
        while t <= MA:
            dp[t] = False
            t += a
    elif flag[a] == 1:
        dp[a] = False
res = 0
for a in A:
    if dp[a]:
        res += 1
print(res)


Measured memory_bytes: 218036
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,d = list(map(int, input().split()))
a = [None]*h
n = h*w
dd = [None]*(n)
for i in range(h):
    a[i] = list(map(int, input().split()))
    for j,num in enumerate(a[i]):
        dd[num-1] = (i,j)
vals = [[] for _ in range(d)]
for i in range(d):
    l = []
    prev = i
    s = 0
    for j in range(i, n, d):
        v = abs(dd[j][0]-dd[prev][0]) + abs(dd[j][1]-dd[prev][1])
        s += v
        l.append(s)
        prev = j
    vals[i] = l
q = int(input())
ans = [None]*q
for i in range(q):
    ll,rr = map(lambda x: int(x)-1, input().split())
    ans[i] = vals[rr%d][rr//d] - vals[ll%d][ll//d]
write("\n".join(map(str, ans)))

Measured memory_bytes: 99476