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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i  = 0; i < N+1; i++) {
    double P = i * 1.08;
    if ((int)P == N) {
      cout << i <<endl;
      break;
    }
    ans++;
  }
  
  if (ans == N+1) {
    cout <<  ":(" <<endl;
  }
}


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

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

	int ans = 10000;
	int x;
	for (int i = 0; i <= (int)S.length() - 3; ++i) {
		x = (int)(S[i] - '0') * 100 + (int)(S[i + 1] - '0') * 10 + (int)(S[i + 2] - '0');
		x = abs(753 - x);
		ans = min(x, ans);
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
const   fi='';//B.inp';
        fo='';//B.out';
var     f:text;
        i,j,n,top,top1:longint;
        kq:int64;
        heap,heap1,a:array[0..5000000] of longint;
        l,g:array[0..5000000] of int64;
(*===================================*)
procedure inp;
Begin
assign(f,fi);
reset(f);
readln(f,n);
for i:=1 to 3*n do read(f,a[i]);
close(f);
End;
(*===================================*)
procedure swap(var a,b:longint);
var y:longint;
Begin
y:=a;
a:=b;
b:=y;
End;
(*===================================*)
procedure upheap(i:longint);
Begin
if (i=1) or (heap[i]<heap[i div 2]) then exit;
swap(heap[i],heap[i div 2]);
upheap(i div 2);
End;
(*===================================*)
procedure downheap(i:longint);
var j:longint;
Begin
j:=i*2;
if j>top then exit;
if (j<top) and (heap[j]<heap[j+1]) then inc(j);
if heap[i]<heap[j] then
 begin
  swap(heap[i],heap[j]);
  downheap(j);
 end;
End;
(*===================================*)
procedure push(x:longint);
Begin
inc(top);
heap[top]:=x;
upheap(top);
End;
(*===================================*)
function pop:longint;
Begin
pop:=heap[1];
heap[1]:=heap[top];
dec(top);
downheap(1);
End;
(*===================================*)
procedure upheap1(i:longint);
Begin
if (i=1) or (heap1[i]>heap1[i div 2]) then exit;
swap(heap1[i],heap1[i div 2]);
upheap1(i div 2);
End;
(*===================================*)
procedure downheap1(i:longint);
var j:longint;
Begin
j:=i*2;
if j>top1 then exit;
if (j<top1) and (heap1[j]>heap1[j+1]) then inc(j);
if heap1[i]>heap1[j] then
 begin
  swap(heap1[i],heap1[j]);
  downheap1(j);
 end;
End;
(*===================================*)
procedure push1(x:longint);
Begin
inc(top1);
heap1[top1]:=x;
upheap1(top1);
End;
(*===================================*)
function pop1:longint;
Begin
pop1:=heap1[1];
heap1[1]:=heap1[top1];
dec(top1);
downheap1(1);
End;
(*===============================*)
procedure trong;
Begin
for i:=1 to n do begin l[i]:=l[i-1]+a[i]; push1(a[i]); end;
for i:=n+1 to 3*n do
  begin
   l[i]:=l[i-1]+a[i];
   push1(a[i]);
   l[i]:=l[i]-pop1;
  end;

for i:=3*n downto 2*n+1 do begin g[i]:=g[i+1]+a[i]; push(a[i]); end;
for i:=2*n downto 1 do
 begin
  g[i]:=g[i+1]+a[i];
  push(a[i]);
  g[i]:=g[i]-pop;
 end;
End;
(*===============================*)
BEGIN
inp;
assign(f,fo);
rewrite(f);
trong;
kq:=-maxlongint*100000;
for i:=n to 2*n do
 if l[i]-g[i+1]>kq then kq:=l[i]-g[i+1];
writeln(f,kq);
close(f);
END.

Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = long.Parse(Console.ReadLine());
        var dict = new Dictionary<int, long>();

        for(var i = 0; i <input; i++)
        {
            var arr = Console.ReadLine().Split(' ');
            if (dict.ContainsKey(int.Parse(arr[1])))
            {
                dict[int.Parse(arr[1])] += long.Parse(arr[0]);
            }
            else
            {
                dict.Add(int.Parse(arr[1]), long.Parse(arr[0]));
            }
        }

        dict = dict.OrderBy(_ => _.Key).ToDictionary(_ => _.Key, _ => _.Value);

        long num = 0;
        var failed = false;
        foreach(var item in dict)
        {
            num += item.Value;
            if (num <= item.Key)
            {

            }
            else 
            {
                failed = true;
                break;
            }
        }

        if (failed)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }

        Console.ReadLine();

    }
}

Measured memory_bytes: 45260
#include<stdio.h>
int main(void){
int x, y;
int i;
int gcd, A;

while(1){
  scanf("%d %d",&x, &y);
  if(x>=1 && y<=1000000000)break;
}
if(x>y){
  while(1){
  A=x%y;
  if(A==0){gcd=y; break;}
  else{x=y; y=A;}
  }
}else if(x<y){
  while(1){
  A=y%x;
  if(A==0){gcd=x; break;}
  else{y=x; x=A;}
  }
}else gcd=x;
printf("%d\n",gcd);
return 0;
}



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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RI(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
LL a[60];

int main()
{
    LL K;
    RLL(K);
    LL d = K / 50 + 49;
    LL r = K % 50;
    REP(i, 50) {
        a[i] = d;
    }
    REP(i, r) {
        LL m = LLONG_MAX;
        int im = 0;
        REP(j, 50) {
            if(a[j] < m) {
                m = a[j];
                im = j;
            }
        }
        REP(j, 50) {
            if(j == im) {
                a[j] += 50;
            } else {
                a[j] -= 1;
            }
        }
    }
    printf("50\n");
    REP(i, 50) {
        printf("%lld ", a[i]);
    }
    PN();
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

readline = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, readline().split()))
    countA = collections.Counter(A)
    ans = 0
    for c in countA.items():
        if c[1] >= int(c[0]):
            ans += c[1] - c[0]
        else:
            ans += c[1]

    print(ans)    


if __name__ == "__main__":
    main()


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

int main(){
	string str;
	string key_1 = "the",key_2 = "this",key_3 = "that";
	
	while(getline(cin,str))
	{
		for(int i=0;i<26;i++)
		{
			for(int j=0;j<str.size();j++)
			{
				if(str[j]!=' ' && str[j]!='.')
				{
					str[j]++;
					if(str[j] > 'z')str[j] -= 26;
				}
			}
			if(str.find(key_1)!= -1) cout << str << endl;
			else if(str.find(key_2)!= -1) cout << str << endl;
			else if(str.find(key_3)!= -1) cout << str << endl;
		}
	}
}

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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  string pre, suf;
  int offset = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    if (s[i] == ')') {
      if (offset == 0) {
        pre.push_back('(');
      }
      else --offset;
    } else if (s[i] == '(') {
      ++offset;
    }
  }
  for (int i = 0; i < offset; ++i) {
    suf.push_back(')');
  }
  cout << pre << s << suf << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c));
	return 0;
}

//Ctrl+Aを使わない

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

int main(void)
{
    string s;
    cin >> s;
    int cnt[3] = {};
    for (size_t i = 0; i < 3; i++)
    {
        cnt[s[i] - 'a']++;
    }
    for (size_t i = 0; i < 3; i++)
    {
        if (cnt[i]!=1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int n;
    cin>>n;
    if(n%2==1) cout<<2*n<<endl;
    else cout<<n<<endl;
}


Measured memory_bytes: 256
/* ex7_1
   masaaki52	*/
#include <stdio.h>
#include <math.h>

typedef struct point{//xy座標の導入
  int x_elem;
  int y_elem;
}point;

point shift_point(point a,point b);//プロトタイプ宣言

int main(void){
  point vertice1,vertice2,vertice3,vertice4;
  scanf("%d %d ",&vertice1.x_elem,&vertice1.y_elem);
  scanf("%d %d",&vertice2.x_elem,&vertice2.y_elem);
  //vertice1,vertice2からvertice3の座標を求める
  vertice3 = shift_point(vertice1,vertice2);
  printf("%d %d ",vertice3.x_elem,vertice3.y_elem);
  //vertice2,vertice3からvertice4の座標を求める
  vertice4 = shift_point(vertice2,vertice3);
  printf("%d %d",vertice4.x_elem,vertice4.y_elem);
  return 0;
}
//正方形の点point1,point2の座標からpoint3の座標を求める
point shift_point(point point1,point point2){
  point point3;
  point3.x_elem = point2.x_elem - point2.y_elem + point1.y_elem;
  point3.y_elem = point2.y_elem + point2.x_elem - point1.x_elem;
  return(point3);
}

Measured memory_bytes: 1708
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int n, ans;
  cin >> n;

  for(int i=1; ; i++){
    ans=i*i;
    if(n<ans){
      ans=(i-1)*(i-1);
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:3
*Problem:Strings of Eternity
*Date:2019-7-28
*Algorithm:My KMP that is still WA
*Status:AC-ABC135F*/

bool debug=false;

string a,b,sa;

const int sz=3000005;

bool found[sz];


int fail[sz];

void build(string& model){
	int j=-1;
	fail[0]=-1;
	for(int i=1;i<=model.size();i++){
		while(j>=0 && model[j]!=model[i-1]){
			j=fail[j];
		}
		
		j++;
		fail[i]=j;
	}
}

void match(string& str,string& model){
	build(model);
	
	int j=0;
	for(int i=0;i<str.size();i++){
		while(j>=0 && str[i]!=model[j]){
			j=fail[j];
		}
		
		j++;
		if(j==model.size()){
			
			found[i-int(model.size())+1]=true;
			
//			cout<<i-model.size()+2<<endl;
		}
	}
}




int visit[sz]; //0=unvisit 1=visiting 2=visited

int dp[sz];

inline int dfs(int pos){
	if(found[pos]==0){
		return 0;
	}
	if(visit[pos]==1){
		cout<<"-1";
		exit(0);
	}
	if(dp[pos]!=-1){
		return dp[pos];
	}
	
	visit[pos]=1;
	
	int ans=dfs((pos+b.size())%sa.size());
	
	visit[pos]=2;
	return dp[pos]=ans+1;
}

char tmp1[500005],tmp2[500005];

int main(int argc,char* argv[]){
	
	scanf("%s%s",tmp1,tmp2);
	
	sa=tmp1;
	b=tmp2;
	
	a="";
	while(a.size()<b.size()+sa.size()){
		a+=sa;
	}
	
//	return 0;
	match(a,b);
	
//	return 0;
	memset(dp,-1,sizeof(dp));
	
	int ans=0;
	for(int i=0;i<sa.size();i++){
		if(!visit[i]){
			ans=max(ans,dfs(i));
		}
		
	}
	
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 35008
a=[0,0,0,0,0]
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
suma=0
Max=0
for i in range(5):
  if a[i]%10==0:
    suma+=a[i]
  else:
    suma+=a[i]//10*10+10
    if Max<(a[i]//10*10+10)-a[i]:
      Max=(a[i]//10*10+10)-a[i]  
print(suma-Max)  


Measured memory_bytes: 3064
def x(S):
	SS = ""
	for i in range(len(S)):

		SS += S[(i+1)*-1]
	return  SS == S

S1 = input()
N1 = len(S1)

N2 = (N1 - 1) // 2
N3 = (N1 + 3) // 2
S2 = S1[0:N1]
S3 =S1[N3-1:N1]
if x(S1) and x(S2) and x(S3):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	s := nextString()
	k := nextInt()

	subs := make([]string, k)

	for i := 0; i < len(s); i++ {
		for j := i + 1; j < len(s)+1; j++ {
			sub := s[i:j]

			for l := 0; l < k && l-j <= k; l++ {
				if sub == subs[l] {
					// dup
					break
				}
				if subs[l] == "" {
					subs[l] = sub
					break
				}
				if sub < subs[l] {
					if l != k-1 {
						copy(subs[l+1:], subs[l:])
					}
					subs[l] = sub
					break
				}
			}

		}
	}

	fmt.Println(subs[k-1])
}


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

int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {

            if (n / i == i)
                cnt++;

            else
                cnt = cnt + 2;
        }
    }
    return cnt;
}
 int main()
{
    int n; cin>>n;
    int tempc=0;
    for(int i=1;i<=n;i+=2){
    if(countDivisors(i)==8){tempc++;}
  }
  cout<<tempc;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int res;
    vector<int> nums;
    for (int i = 0; i < 3; i++) {
        int num;
        cin >> num;
        nums.push_back(num);
    }
    sort(nums.begin(), nums.end(), greater<int>());
    res = nums[0] * 10 + nums[1] + nums[2];
    cout << res << endl;
	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if ((a-b)*(b-c)*(c-a) != 0){
    cout << 3 << endl;
  }
  else if (a == b && b == c){
    cout << 1 << endl;
  }
  else {
    cout << 2 << endl;
  }
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint A,V,B,W,T;cin>>A>>V>>B>>W>>T;
	if(V>W&&abs(A-B)<=(V-W)*T){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	return 0;
}


Measured memory_bytes: 3040
import numpy as np

N = int(input())
XY = []
for i in range(N):
  XY.append([int(i) for i in input().split()])

XY = np.array(XY)
X = XY[:,0]
Y = XY[:,1]
pxpy = X + Y
pxmy = X - Y
mxpy =-X + Y
mxmy =-X - Y

candi = [np.argmax(pxpy),np.argmax(pxmy),np.argmax(mxpy),np.argmax(mxmy)]

cand = [XY[candi[i]] for i in range(4)]
manh = [abs(cand[0][0] - cand[3][0]) + abs(cand[0][1] - cand[3][1]), abs(cand[1][0] - cand[2][0]) + abs(cand[1][1] - cand[2][1])]
print(max(manh))

Measured memory_bytes: 63320
n = gets.to_i
as = gets.split.map(&:to_i)

sign = 1
sum = 0
ope1 = 0
as.each do |a|
    sum += a
    if sum * sign <= 0
        ope1 += (sign - sum).abs
        sum = sign
    end
    sign *= -1
end

sign = -1
sum = 0
ope2 = 0
as.each do |a|
    sum += a
    if sum * sign <= 0
        ope2 += (sign - sum).abs
        sum = sign
    end
    sign *= -1
end

puts [ope1, ope2].min

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

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3500, M = N;
//=======================

vi g[N];
double p[N];
double dp[N + 1][N + 1];

void solve() {
	int i, j, n, m;
	cin >> n;
	fo(i, n) cin >> p[i];
	dp[0][0] = 1;
	Fo(i, 1, n + 1) {
		fo(j, n + 1) {
			if (j > i) dp[i][j] = 0;
			if (j) dp[i][j] += dp[i - 1][j - 1] * (p[i - 1]);
			dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
		}
	}
	double ans = 0;
	fo(i, n + 1) {
		// deb2(i, dp[n][i]);
		if (i > n - i) ans += dp[n][i];
	}
	cout << setprecision(10) << fixed << ans << "\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 85944
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a, b, c, k; //入力
	int i = 0,flag=0; //内部で使用
	int ans = 0; //出力

	cin >> a >> b >> c >> k;

	for (i = 0; i < k; i++) {
		if (a > 0) {
			ans++;
			a--;
		}
		else if (b > 0) {
			b--;
		}
		else{
			flag = 1;
			break;
		}
	}
	if (i < k and flag==1) {
		while (i < k) {
			ans--;
			c--;
			i++;
		}	
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3648
MJD(y,m,d){
	if(m<3){
		y--;
		m+=12;
	}
	return 1461*y/4+y/400-y/100+3059*(m-2)/100+d-678912;
}
main(){
	int y1,m1,d1,y2,m2,d2;
	for(;scanf("%d%d%d%d%d%d",&y1,&m1,&d1,&y2,&m2,&d2),y1>=0&&m1>=0&&d1>=0&&y2>=0&&m2>=0&&d2>=0;){
		printf("%d\n",MJD(y2,m2,d2)-MJD(y1,m1,d1));
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long ans;
	ans=max(max(max(a*c,a*d),b*c),b*d);
    cout<<ans<<endl;
	return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#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 pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n,lt;
    veci c,t;
    cin >> n >> lt;
    REP(i,n){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        c.pb(tmp1);
        t.pb(tmp2);
    }
    int ans = 10000;
    REP(i,n){
        if(t[i] <= lt){
            ans = min(ans,c[i]);
        }
    }
    if(ans == 10000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
    long long N;
    const long long mod = 1000000007;
    cin >> N;
    long long res = 1;
    for (long long i = 1; i <= N; i++)
    {
        res = res*10%mod;
    }

    long long not_0_or_9 = 1;
    for (long long i = 1; i <= N; i++)
    {
        not_0_or_9 = not_0_or_9*9%mod;
    }

    long long both_0_9 = 1;
    for (long long i = 1; i <= N; i++)
    {
        both_0_9 = both_0_9*8%mod;
    }

    res = res - not_0_or_9 - not_0_or_9 + both_0_9;
    res %= mod;
    res = (res+mod)%mod;

    cout << res;
}

Measured memory_bytes: 3520
#include<stdio.h>
#define nil -1
typedef struct{
  int p;
  int left;
  int right;
  int sibling;
  int depth;
  int height;
  int degree;
  
}Node;

Node N[100000];
int A[100000];
int count=0;

void Preorder(int );
void Inorder(int);
void Postorder(int);

int main(){

  int i,j,n,c,left,right,degree,tmp,root;

  scanf("%d",&n);
  
   for(i=0;i<n;i++){
    N[i].p=N[i].left=N[i].right=N[i].sibling=nil;
    N[i].depth=N[i].height=N[i].degree=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d %d",&tmp,&left,&right);
    N[tmp].left=left;
    N[tmp].right=right;
    if(left!=-1&&right!=-1){
      N[right].p=tmp;
      N[right].sibling=left;
      N[left].sibling=right;
      N[left].p=tmp;
      N[tmp].degree=2;
    }
    else if(left!=-1&&right==-1){
      N[left].p=tmp;
      N[tmp].degree=1;
    }
    else if(left==-1&&right!=-1){
      N[right].p=tmp;
      N[tmp].degree=1;
    }
  }
 

  for(i=0;i<n;i++)if(N[i].p==nil)root=i;
  
  printf("Preorder\n");
  count=0;
  Preorder(root);
  for(i=0;i<n;i++)printf(" %d",A[i]);
  
  printf("\nInorder\n");
 
  count=0;
  Inorder(root);
  for(i=0;i<n;i++)printf(" %d",A[i]);
  
  printf("\nPostorder\n");
  count=0;
  Postorder(root);
  for(i=0;i<n;i++)printf(" %d",A[i]);
  printf("\n");
  
  return 0;
}


void Preorder(int p){

  if(p==nil) return;

  A[count++]=p;
  Preorder(N[p].left);
  Preorder(N[p].right);
}

void Inorder(int p){
 
 if(p==nil) return;

 Inorder(N[p].left);
 A[count++]=p;
 Inorder(N[p].right);

}

void Postorder(int p){

 if(p==nil) return;
 Postorder(N[p].left);
 Postorder(N[p].right);
 A[count++]=p;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
class Trees{
  vector<int> par;
  vector<int> rank;
  public:
  int root(int i){
    int rt;
    if(par[i]==i){rt=i;rank[i]=1;}
    else{rt=root(par[i]);par[i]=rt;rank[i]=2;}
    return rt;
  }
  void unite(int i,int j){
    int rki=rank[i];int rkj=rank[j];
    if(rki<rkj){par[root(i)]=root(j);rank[i]++;}
    else{par[root(j)]=root(i);rank[j]++;}
  }
  bool same(int i,int j){
    return root(i)==root(j);
  }
  bool allsame(){
    for(int i=1;i<par.size();i++)if(root(i)!=root(0))return false;
    return true;
  }
  Trees(int n){
    for(int i=0;i<n;i++) {par.push_back(i);rank.push_back(1);};
  }
};
int main(){
  long N,M;cin>>N>>M;
  vector<long>A(M),B(M);
  for(int i=0;i<M;i++){cin>>A[i]>>B[i];A[i]--;B[i]--;}
  long ans=0;
  for(int m=0;m<M;m++){
    Trees tree(N);
    for(int i=0;i<M;i++)if(i!=m)tree.unite(A[i],B[i]);
    ans+=1-tree.allsame();
  }
  cout<<ans;
}





Measured memory_bytes: 256
#!/usr/local/gnu/bin/bash
read k s
((s>2*k)) && xmin=$((s-2*k)) || xmin=0
((s<k)) && xmax=$s || xmax=$k
a=0
for x in `seq $xmin $xmax`
do
    yz=$((s-x))
    ((yz>k)) && ymin=$((yz-k)) || ymin=0
    ymax=$((yz-ymin))
    a=$((a+ymax-ymin+1))
done
echo $a


Measured memory_bytes: 700
//
// Created by Hideaki Imamura on 2020-03-15.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll N, M;
vector<ll> P, Y;

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        ll p, y;
        cin >> p >> y;
        P.push_back(p-1);
        Y.push_back(y);
    }

    vector<vector<ll>> vals(N);
    for (int i = 0; i < M; ++i) vals[P[i]].push_back(Y[i]);

    for (int v = 0; v < N; ++v) {
        sort(vals[v].begin(), vals[v].end());
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    for (int i = 0; i < M; ++i) {
        ll v = P[i];
        printf("%06d", v + 1);
        ll id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
    return 0;
}

Measured memory_bytes: 8556
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
#define debug(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int h, w, n;

bool visit[1001][1001];

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int bfs(vector<string> &v, P s, P g){
	memset(visit, 0, sizeof(visit));
	
	queue<pair<P, int> > q;
	q.push(MP(s, 0));

	while(!q.empty()){
		P p = q.front().first;
		int t = q.front().second;
		q.pop();

		if(visit[p.Y][p.X]) continue;
		visit[p.Y][p.X] = true;

		if(p == g) return t;

		rep(i, 4){
			int x = p.X + dx[i];
			int y = p.Y + dy[i];
			if(x < 0 || x >= w || y < 0 || y >= h) continue;
			if(v[y][x] == 'X') continue;
			q.push(MP(MP(x, y), t+1));
		}
	}

	return 1<<31;
}

int main(){
	cin >> h >> w >> n;
	vector<string> v(h);
	rep(i, h) cin >> v[i];

	vector<P> point(n+1);
	rep(i, h) rep(j, w){
		if(v[i][j] == 'S') point[0] = MP(j, i);
		if(v[i][j] >= '1' && v[i][j] <= '9'){
			point[v[i][j]-'0'] = MP(j, i);
		}
	}

	int ans = 0;
	rep(i, n){
		ans += bfs(v, point[i], point[i+1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef  long long                  ll;
typedef  unsigned long long        llu;
typedef  long double               ldo;
#define  mod                 1000000007
#define  pi              3.141592653589
#define  sz(c)             (ll)c.size()
#define  fr                       first 
#define  sc                      second
#define  pb                   push_back
#define  mp                   make_pair
#define  all(v)   (v).begin(),(v).end()
#define  rep(i,a,n) for(ll i=a;i<n;i++)
#define  endl                      '\n'
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef  vector <ll>               vll;
typedef  vector <string>           vss;
typedef  vector <pair <ll,ll>>    vpll; 
typedef  vector <vector <ll>>     vvll;
typedef  set <ll>                  sll;

class Solution{
  public:
 // vll v;

  //Solution():v(10, false){v[2]=6;}
  void SolutionFunc(){
    ll s=0,n,m;cin>>n>>m;
    rep(i,0,m){
    	ll x;
    	cin>>x;
    	s+=x;
    }
    ll x=n-s;
    if(x<0)x=-1;
    cout<<x;
    
    
  }
};

int main(){
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
  IOS;

  Solution obj;
  ll T=1;
  //cin>>T;
  rep(i,0,T){
    //cout<<"Case #"<<i+1<<": ";
    obj.SolutionFunc();
  }  
  return(0);
} 



Measured memory_bytes: 3600
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		
		int c = Integer.parseInt(a, 16);
		int d = Integer.parseInt(b, 16);
		
		if (c>d) {
			System.out.println(">");
		}else if (c==d) {
			System.out.println("=");
		}else{
			System.out.println("<");
		}
		
		scanner.close();
	}
	
}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <functional>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;


int main(){
	vector<Pii> v;
	int c1,c2;
	while(scanf("%d,%d",&c1,&c2),c1||c2) v.push_back(Pii(c2,c1));
	sort(v.begin(),v.end(),greater<Pii>());
	vector<int> v2((int)v.size());
	int last = INT_MAX,cnt = 0;
	for (int i = 0; i < (int)v.size(); i++){
		if(last != v[i].first) last = v[i].first,cnt++;
		v2[v[i].second - 1] = cnt;
	}
	int c;
	while(cin>>c) cout << v2[c - 1] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9+7;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<set<int>> d(n);
    int ans = 0;
    int zero;
    cin >> zero;
    if(zero != 1) ans++;
    for(int i = 1; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
        d[a[i]].insert(i);
    }
    d[0].insert(0);
    bitset<100010> bs;
    function<int(int)> dfs = [&](int v)
    {
        bs[v] = true;
        int m = 0;
        for(int nx : d[v])
        {
            if(bs[nx]) continue;
            m = max(m, dfs(nx));
        }
        if(d[0].find(v) == d[0].end() && m+1 == k)
        {
            ans++;
            return 0;
        }
        else return m+1;
    };
    bs[0] = true;
    dfs(0);
    cout << ans << endl;
}

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

int main() {
    string s;
    getline(cin, s);
    for (int i=0; i<(int)s.size(); ++i) {
        if (islower(s[i])) s[i] = toupper(s[i]);
        else if (isupper(s[i])) s[i] = tolower(s[i]);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3164
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
s = input()

score = [0]*n
for i in range(n-1):
    score[i+1] = score[i]
    if s[i]+s[i+1] == 'AC':
        score[i+1] += 1

for _ in range(q):
    l, r = map(int, input().split())
    print(score[r-1]-score[l-1])

Measured memory_bytes: 6428
#!/usr/bin/env python3
import math

a, b, h, m = map(int, input().split())

if 30*h > 5.5*m:
    theta = 30*h-5.5*m
else:
    theta = -(30*h-5.5*m)

if theta >= 180:
    theta = 360-theta

# radian
theta = theta*math.pi/180
tmp = a*a+b*b-2*a*b*math.cos(theta)
ans = math.sqrt(tmp)
print(ans)


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

int main() {
	int number[3];
	number[0] = number[1] = number[2] = -1;
	int n, m, s, c;
	cin >> n >> m;
	bool isValid = true;
	for(int i = 0; i < m; ++i) {
		cin >> s >> c;
		if(number[s-1] != -1 && number[s-1] != c) {
			isValid = false;
			break;
		}
		number[s-1] = c;
	}
	if(!isValid || (number[0] == 0 && n > 1)) cout << "-1" << endl;
	else {
		if(number[0] == -1) {
			if(n > 1) number[0] = 1;
			else number[0] = 0;
		}
		for(int i = 0; i < n; ++i) {
			cout << (number[i]==-1?0:number[i]);
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a[1010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		int ans=0;
		for(int i=l;i<r;i++)ans+=a[i]==k;
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 2112
import std.stdio,
       std.string,
       std.conv,
       std.range,
       std.algorithm;

void main() {
  int[] buf = readln.chomp.split.to!(int[]);
  int n = buf[0], m = buf[1], x = buf[2];
  int[] A = readln.chomp.split.to!(int[]);

  int count_left,
      count_right;
  for (int i = x - 1; i >= 1; i--) {
    if (canFind(A, i)) {
      count_left++;
    }
  }
  for (int i = x + 1; i <= n; i++) {
    if (canFind(A, i)) {
      count_right++;
    }
  }

  writeln(min(count_left, count_right));
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin >> A >> B ;
    if((A+B)%2==0){
    if(((A-B)>2||(B-A)>2)){
        cout << (A+B)/2 << endl;
    }
    else {
        cout <<"IMPOSSIBLE" << endl;
    }
    }
else{
    cout << "IMPOSSIBLE" <<endl;
}
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007
 
#define MAX_N 200005
 
ll inv[MAX_N], fact[MAX_N], ifact[MAX_N];
 
int C(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}
 
void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}
 
int main(){
  prepare();
  int h,w,a,b,x;
  cin>>h>>w>>a>>b;
  w--,h--;
  ll ans=C(w+h,w);
  for(int i=0;i<b;i++){
    ll tmp=C((h-a)+i,i);
    ll tmp2=C((w-i)+(a-1), a-1);
    ans-=tmp*tmp2%MOD;
    if(ans<0) ans+=MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;
using ll=long long;
using R=double;
// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
    for(int i=0;i<N+1;++i){
        for(int j=0;j<=i;++j){
            if(j==0||j==i){
                C[i][j]=1;
            }
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
            }
        }
    }
}

int main(void){
    int N,A,B;
cin>> N>>A>>B;
  const int NMAX=50;
    ll v[NMAX];
    for(int i=0;i<N;++i){
        cin >> v[i];
}
    comb_table(N);
    sort(v,v+N);
    reverse(v,v+N);
    R max_average=0.0;
    for(int i=0;i<A;++i){
        max_average+=v[i];
    }
    max_average/=A;
    int a_th_val_num=0,a_th_val_pos=0;
    for(int i=0;i<N;++i){
        if(v[i]==v[A-1]){
            a_th_val_num++;
            if(i<A){
                a_th_val_pos++;
} }
}
    ll cnt=0LL;
    if(a_th_val_pos==A){
        for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
            cnt+=C[a_th_val_num][a_th_val_pos];
} }else{
        cnt+=C[a_th_val_num][a_th_val_pos];
    }
    cout.precision(20);
    cout << fixed << max_average << endl;
    cout << cnt << endl;
return 0; }


Measured memory_bytes: 256
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(x>=y)System.out.println(Math.min(a*x+b*y,Math.min(2*c*x,2*c*y+(x-y)*a)));
      else System.out.println(Math.min(a*x+b*y,Math.min(2*c*y,2*c*x+(y-x)*b)));
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

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

int main()
{
	int W, H, C;
	int i;

	cin >> W >> H >> C;

	if (W < H)
	{
		for (i = H; i > 0; i--)
		{
			if (H % i == 0)
			{
				if(W % i == 0)
				{
					break;
				}
			}
		}
		cout << (H / i) * (W / i) * C << endl;
	}
	else if (W > H)
	{
		for (i = W; i > 0; i--)
		{
			if (W % i == 0)
			{
				if (H % i == 0)
				{
					break;
				}
			}
		}
		cout << (H / i) * (W / i) * C << endl;
	}
	else
	{
		cout << C << endl;
	}

	return 0;
}



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

bool check(int a){
	for(int i=0;i*i<=a;i++){
		if(i*i==a) return true;
	}
	return false;
}

int main() {
	int n, d; cin >> n >> d;
	int x[11][11];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin >> x[i][j];
		}
	}
	int ans = 0;
	int l = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=0;k<d;k++){
				l += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			if(check(l)) ans++;
			l = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

int n, m;
long long ans;
char map[401][401];
bool vis[401][401];
int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};
int sdx[200001], sdy[200001];

void bfs(int sx, int sy) {
	int head = 0, tail = 1, w = 0, h = 0;
	sdx[tail] = sx, sdy[tail] = sy;
	if (map[sx][sy] == '#') ++w;
	else ++h;
	while(head < tail) {
		++head;
		for (int i = 0; i <= 3; ++i) {
			int c = sdx[head] + dx[i], d = sdy[head] + dy[i];
			if (c > 0 && c <= n && d > 0 && d <= m && !vis[c][d] && map[sdx[head]][sdy[head]] != map[c][d]) {
				if (map[c][d] == '#') ++w;
				else ++h;
				vis[c][d] = 1, ++tail;
				sdx[tail] = c, sdy[tail] = d;
			}
		}
	}
	ans += 1ll * w * h;
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			std::cin >> map[i][j];
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (!vis[i][j]) vis[i][j] = 1, bfs(i, j);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5148
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
print('YES' if int(''.join(rs_())) % 4 == 0 else 'NO')

Measured memory_bytes: 62956
/*
  AUTHOR:SOURABH
  CREATED:21:08:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 100000000
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,i,ma,sum;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        vll a(n);
        fn(i,n)
        cin>>a[i];
        ma=a[0];
        sum=0;
        fs(i,1,n)
        {
            if(a[i]<ma)
                sum+=ma-a[i];
            ma=max(ma,a[i]);
        }
        cout<<sum;
    }
    return 0;
}













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

using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    vector<char> s1,s2;
    s1.clear(); s2.clear();
    int jun=1;
    string s;
    int q,r,f; char c;
    cin>>s>>q;
    REP(i,q){
        cin>>r;
        if(r==1){
            jun*=-1;
        }
        else{
            cin>>f>>c;
            if(f==1){
                if(jun==1)s1.push_back(c);
                else s2.push_back(c);
            }
            else if(f==2){
                if(jun==1)s2.push_back(c);
                else s1.push_back(c);
            }
        }
    }
    if(jun==-1){
        for(int i=s2.size()-1;i>=0;i--)cout<<s2[i];
        reverse(s.begin(), s.end());
        cout<<s;
        for(int i=0;i<s1.size();i++)cout<<s1[i];
    }
    else{
        for(int i=s1.size()-1;i>=0;i--)cout<<s1[i];
        cout<<s;
        for(int i=0;i<s2.size();i++)cout<<s2[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1152
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int m, k;
  cin >> m >> k;
  int mm = 1 << m;
  if(mm <= k) {
    cout << -1 << endl;
    return 0;
  }
  if(m == 0) {
    cout << "0 0" << endl;
    return 0;
  }
  if(m == 1) {
    if(k == 0) {
      cout << "0 0 1 1" << endl;
    } else {
      assert(k == 1);
      cout << -1 << endl;
    }
    return 0;
  }
  for(int i = 0; i < mm; i++) if(i != k) {
    cout << i << " ";
  }
  cout << k << " ";
  for(int i = mm - 1; i >= 0; i--) if(i != k) {
    cout << i << " ";
  }
  cout << k << endl;
  return 0;
}


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

int n,m;
int can[200200],cann[200200];

int main(){
	cin>>n>>m;
	memset(can,0,sizeof can);
	memset(cann,0,sizeof cann);
	for (int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		if (u>v){
			int t=u;
			u=v;
			v=t;
		}
		if (u==1){
			can[v]=1;
			if (cann[v]==1){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}
		}
		if (v==n){
			cann[u]=1;
			if (can[u]==1){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int x,y,a,b,c;
int p[100100];
int q[100100];

int main(){
    cin>>x>>y>>a>>b>>c;
    vector<int> v;
    REP(i,a)cin>>p[i];
    REP(i,b)cin>>q[i];
    REP(i,c){
        int r;
        cin>>r;
        v.push_back(r);
    }   
    sort(p,p+a,greater<int>());
    sort(q,q+b,greater<int>());
    REP(i,x)v.push_back(p[i]);
    REP(i,y)v.push_back(q[i]);
    sort(v.begin(),v.end(),greater<int>());
    ll ans=0;
    REP(i,x+y){
        ans+=(ll)v[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long int mod=1e9+9;
const int N=100000;
int t,i,j,cs=0,n,a,b;
string s;

int main()
{
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
    cout<<endl;
}




Measured memory_bytes: 256
from heapq import heappop, heappush
def main():
    def push(i, j, k):
        nonlocal A, B, C, ADD
        if i >= x or j >= y or k >= z: return
        if (i, j, k) not in ADD:
            heappush(H, (A[i] + B[j] + C[k], i, j, k))
            ADD.add((i, j, k))
    x, y, z, k = map(int, input().split())
    INF = 10 ** 11
    A = sorted(list(map(lambda x: -int(x), input().split())))
    B = sorted(list(map(lambda x: -int(x), input().split())))
    C = sorted(list(map(lambda x: -int(x), input().split())))
    H = []
    ADD = set()
    push(0, 0, 0)
    for _ in range(k):
        ans, i, j, k = heappop(H)
        push(i + 1, j, k)
        push(i, j + 1, k)
        push(i, j, k + 1)
        print(-ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10372
x1, y1, x2, y2 = map(int, input().split())

vec = (x2 - x1, y2 - y1)
# p3
vec = (-vec[1], vec[0])
x3 = x2 + vec[0]
y3 = y2 + vec[1]
# p4
vec = (-vec[1], vec[0])
x4 = x3 + vec[0]
y4 = y3 + vec[1]

print(x3, y3, x4, y4)


Measured memory_bytes: 3064