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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


inline li fl(li n, li b) {
	return n / b;
}

inline li calc(li b, li n) {
	if (b <= 1)return 0;
	if (n < b)return n;
	return n % b  + calc(b, fl(n, b));
}

inline li solve_(li n, li s) {
	repp(b, 2, n) {
		if (calc(b, n) == s)return b;
	}
	return -1;
}


inline li solve(li n, li s) {
	repp(b, 2, sqrt(n) + 1) {
		if (calc(b, n) == s)return b;
	}

	// 2桁の場合
	// n(10) = pb+q(b)
	// b = (n-q)/p = (n-s+p)/p=1+(n-s)/p
	for (li p = sqrt(n); p > 0; --p) {
		li b = 1 + (n - s) / p;
		if (calc(b, n) == s)return b;
	}
	return -1;
}

int main() {
	li n, s;
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}
	if (n < s) {
		puts("-1");
		return 0;
	}
	if (n == 1) {
		if (s == 1)puts("2");
		else puts("-1");
		return 0;
	}
	cout << solve(n, s) << endl;

	return 0;
}

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

#define ll long long

using namespace std;

int n;

int a[100005], dp[100005];

int main () {
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }
    dp[1] = 0;
    dp[2] = abs (a[1] - a[2]);
    for (int i = 3;i <= n;i ++) {
        dp[i] = min (dp[i - 1] + abs (a[i] - a[i - 1]), dp[i - 2] + abs (a[i] - a[i - 2]));
    }cout << dp[n];
}


Measured memory_bytes: 1024
import collections
n = int(input())

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

b = collections.Counter(a)
l = []

for k,v in b.items():
    if v >= 2:
        l.append((k,v))

l = sorted(l,reverse = True)
if not l:
    print(0)
else:
    if l[0][1] >= 4:
        print(l[0][0]**2)
    else:
        print(l[0][0]*l[1][0])

Measured memory_bytes: 18600
import sys
import heapq
readline = sys.stdin.readline


X, Y, A, B, C = map(int, readline().split())
P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))
R = list(map(int, readline().split()))

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]

heapq.heapify(P)
heapq.heapify(Q)
R.sort()

for r in R:
    X = P if P[0] < Q[0] else Q

    if X[0] < r:
        heapq.heappushpop(X, r)

print(sum(P) + sum(Q))

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

int main()
{
	fast;
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vector<long double> a(n + 1);
	FOR(n)
	{
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	long double ans = 0;
	for (int i = k; i <= n; i++)
		chmax(ans, a[i] - a[i - k]);
	cout << (ans + k) / 2;
}

Measured memory_bytes: 6328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M, X;
    cin >> N >> M >> X;
    int front = 0, back = 0;
    rep(i, 0, M)
    {
        int A;
        cin >> A;
        if (A <= X) ++front;
        else ++back;
    }
    cout << min(front, back) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

typedef long long ll;

ll count_rooms_lesseq_than(ll newRoomNo)
{
	int t[10], d;
	for (d = 0; newRoomNo; ++d, newRoomNo /= 10)
		t[d] = newRoomNo % 10;
	for (int i = d-1; i > 0; --i)
	{
		if (t[i] == 4 || t[i] == 6)
		{
			--t[i];
			for (int j = 0; j < i; ++j)
				t[j] = 9;
			break;
		}
	}

	ll res = 0;
	for (int i = 0; i < d; ++i)
	{
		ll a = 1;
		for (int j = 0; j < i; ++j)
			a *= 8;
		res += (t[i] - (t[i] >= 6 ? 2 : t[i] >= 4 ? 1 : 0)) * a;
	}
	return res;
}
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		ll l, u;
		l = 1;
		u = n * 10LL;
		while (l < u)
		{
			ll m = (l + u) / 2;
			ll t = count_rooms_lesseq_than(m);
			if (t < n)
				l = m + 1;
			else
				u = m;
		}
		printf("%lld\n", l);
	}

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, i;
    
    cin>>n;
    vector<int> v(n);
    for(i=0;i<n;i++){
    	cin>>v[i];
    }
    int x = 0, max_x = 0;
    if(n==1){
        cout<<0;
        return 0;
    }
    for(i = n-2; i>-1;i-- ){
    	if(v[i]>=v[i+1]){
    		x++;
    	}
    	else{
    		//cout<<v[i]<<' '<<v[i+1]<<' '<<x<<'\n';
    		
    		if(x>max_x){
    			max_x = x;
    		}
    		x = 0;
    	}
    	
    }
    //cout<<v[i+1]<<' '<<x<<'\n';
    if(x>max_x){
			max_x = x;
			x = 0;
    }
    cout<<max_x;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  vector<int> b[m+2],c[m+2];
  for(int i=0;i<n-1;i++){
    b[a[i]].push_back(a[i+1]);
  }
  for(int i=1;i<n;i++){
    c[a[i]].push_back(a[i-1]);
  }
  priority_queue<int,vector<int>,greater<int> > q;
  int tmp=0;
  for(int i=0;i<n-1;i++){
    if(a[i]<a[i+1]) tmp+=a[i+1]-a[i];
    else{
      tmp+=a[i+1];
      q.push(a[i+1]);
    }
  }
  //cout<<tmp<<endl;
  int ans=tmp;
  for(int i=1;i<=m;i++){
    
    for(int j=0;j<(int)c[i].size();j++){
      //cout<<i<<":"<<c[i][j]<<endl;
      if(i>c[i][j]) tmp+=(i-c[i][j])-1;
      else tmp+=((m-c[i][j])+i)-1;
    }
    
    while(!q.empty()&&q.top()<=i) q.pop();
    tmp-=q.size();
    //cout<<"qs:"<<q.size()<<endl;
    
    for(int j=0;j<(int)b[i].size();j++){
      if(i<b[i][j]) q.push(b[i][j]);
      else q.push(b[i][j]+m);
    }
    
    //cout<<tmp<<endl;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11512
#include<stdio.h>

int count[100];

int main(void)
{
	int i = 0;
	int j;
	int n[100];
	int mc;
	
	while(scanf("%d", &n[i]) != EOF){
		count[n[i]]++;
		i++;
	}
	mc = count[0];
	for(j = 1;j < 100;j++){
		if(count[j] > mc){
			mc = count[j];
		}
	}
	for(i = 0;i < 100;i++){
		if(mc == count[i]){
			printf("%d\n",i);
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
using namespace std;
int main(){

    long long int n,ans=0,i,j,k;
    cin>>n;
    long long int a[n+1][n+1];
    bool p[n+1][n+1];
    memset(p,0,sizeof(p));
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>a[i][j];

    for(k=1;k<=n;k++)      
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++){
                if(k!=j&&k!=i&&i!=j){
                    if(a[i][j]==a[i][k]+a[k][j])
                        p[i][j]=1; 
                    if(a[i][j]>a[i][k]+a[k][j]){
                        cout<<"-1"<<endl;  
                        return 0;
                    }
                }
            }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(p[i][j]==0)
                ans+=a[i][j];
    cout<<ans/2<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int h[N];
  rep(i,N) cin >> h[i];
  int ans=0;
  bool f=false;
  rep(i,100){
      rep(k,N){
        if(f==false and h[k]>0) {f=true;ans++;}
        if(h[k]>0) h[k]--;
        else if(h[k]==0) f=false;
      }
    f=false;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

char s[200001];

int main() {
    int n, ans = 0, x = 0, i;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n; i++) {
        if (s[i] == 'S') {
            x++;
        } else {
            if (x > 0) {
                x--;
            } else {
                ans++;
            }
        }
    }
    
    printf("%d\n", ans + x);
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c,d=0;
    cin>>a>>b>>c;
    a-=c;
    while(a>=b+c)
    {
        a-=b;
        a-=c;
        d++;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3628
import Control.Monad
import Data.List

main = do
  [r, c] <- return . map (\x -> read x :: Int) . words =<< getLine
  a <- replicateM r $ getLine >>= return . map (\x -> read x :: Int) . words 
  mapM_ (\x -> do
    putStr $ unwords . map show $ x
    putChar ' '
    putStrLn $ show $ sum x ) a
  let csum = map sum $ transpose a
  putStr $ unwords . map show $ csum
  putChar ' '
  putStrLn $ show $ sum csum

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

int main(void)
{
    int n, m ,l, i,j,k, sum;
    cin >>n>>m>>l;
    long long int a[n][m], b[m][l], c[n][l];

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            c[i][j] = 0;
        }
    }

    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j!=l-1) printf("%lld ", c[i][j]);
            else printf("%lld\n", c[i][j]);
        }
    }
}


Measured memory_bytes: 3376
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

long long n,a,b;

signed main(){
	read(n,a,b);
	if(b-a&1) write(min(a-1,n-b)+1+(b-a>>1));
	else write(b-a>>1);
}

Measured memory_bytes: 3556
N = int(input())
l = []
for i in range(N):
    a,b = map(int,input().split())
    l.append((a+b,a,b))
l.sort(reverse=True)
A,B = 0,0
for i in range(N):
    if i%2 == 0:
        A += l[i][1]
    else:
        B += l[i][2]
print(A-B)

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long h, a;
	cin >> h;
	cin >> a;
	cout << h / a + bool(h % a);

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n+1, 0);
    rep(i, 0, k)
    {
        int d;
        cin >> d;
        rep(i, 0, d)
        {
            int a;
            cin >> a;
            v[a]++;
        }
    }
    int res = 0;
    rep(i, 1, n+1)
        if (v[i] == 0)
            res++;
    cout << res;
    return 0;
}

Measured memory_bytes: 3628
import numpy as np
import itertools as ittr

def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        n_on = np.sum(sw[e_ball - 1])
        
        if p[i] != (n_on % 2):
            return False
    
    return True

N, M = map(int, input().split())

e_balls = []

for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(np.asarray(s))

p = [int(pi) for pi in input().split()]

cnt = 0

for sw in ittr.product([0, 1], repeat = N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1

print(cnt)

Measured memory_bytes: 12428
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[200000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int x=unique(a,a+n)-a;
    if(x%2)
    {
        cout<<x;
    }
    else
    {
        cout<<x-1;
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;


int n , k;
int a[110];
int dp[100010];

int32_t main(){   

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

cin>>n>>k;
for(int i =1; i<=n ; i++)cin>>a[i];

for(int i =1 ; i<=k ; i++){

	for(int j =1; j<=n ; j++){
		if(i>=a[j])
		if(dp[i-a[j]]==0)dp[i]=1;
	}
}

if(dp[k])cout<<"First\n";
else cout<<"Second\n";


return 0;
}


Measured memory_bytes: 4432
n=int(input())
s=input()
a=b=0
k=0
for i in range(n):
	if s[i]=="(":
		a+=1
	else:
		b+=1
	if a<b:
		k+=1
		a+=1
s=k*("(")+s
if a>b:
	s+=")"*(a-b)
print(s)

Measured memory_bytes: 3064
def height_to_temp(t, x)
  t - x * 0.006
end

n = gets.to_i
t, a = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

p hs.map.with_index.min_by { |h, _i| (height_to_temp(t, h) - a).abs }.last + 1


Measured memory_bytes: 1916
#include <bits/stdc++.h>
/**
 *    author:  dattrinh
 *    created:    Codeforces Round #635
**/
#define pb push_back
#define fi first
#define ss second
#define tp(x) fixed<<setprecision(x)
using namespace std;
using ll = int64_t;
const int N = 1000003;
ll t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2+ (m*(m-1)/2));
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	ll ans=0;
	for(ll i=0;i<min(s.size(),t.size());i++)
	{
		if(s[i]!=t[i])
		{
			ans++;
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3892
use std::io::*;
use std::str::*;
use std::collections::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if s.is_empty() {
        None
    } else {
        s.parse::<T>().ok()
    }
}

fn main(){
    while let Some(n) = read() {
        let mut mp = BTreeMap::<u64, usize>::new();
        let mut v: Vec<u64> = (0..n).map(|_| read().unwrap()).collect();
        v.sort();
        for &x in &v {
            *mp.entry(x).or_insert(0) += 1;
        }
        let mut e = Vec::<u64>::new();
        v.dedup();
        for &x in &v {
            for _ in 0..mp[&x]/2 {
                e.push(x);
            }
        }
        e.sort();
        let ans = if e.len() < 2 {
            0
        } else {
            let l = e.len();
            e[l - 1] * e[l - 2]
        };
        println!("{}", ans);
    }
}


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

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

  vector<ll> a(n), b(n);
  for (auto& ai : a)
    cin >> ai;

  b[0] = a[0];
  for (int i = 1; i < n; ++i)
    b[i] = a[i] + b[i - 1];

  ll sum = b[n - 1], ans = sum;
  for (int i = 0; i < n - 1; ++i) {
    ans = min(ans, abs(b[i] - (sum - b[i])));
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[400];
ll dp[400][400];
ll Cost(ll i,ll j)
{
	ll sum=0;
	for(ll idx=i;idx<=j;idx++)
		sum+=arr[idx];
	return sum;
}
ll MinCost(ll i,ll j)
{
	if(i>=j)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll mincost=1e18;
	for(ll k=i;k<j;k++)
		mincost=min(mincost,MinCost(i,k)+MinCost(k+1,j)+Cost(i,j));
	return dp[i][j] = mincost;
}
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	memset(dp,-1,sizeof(dp));
	cout<<MinCost(0,n-1);
}

Measured memory_bytes: 4900
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int r,c,k;
  cin >> r >> c >> k;

  static ll g[4000][4000] = {0};
  rep(i,k){
    int y,x;
    ll v;
    cin >> y >> x >> v;
    y--; x--;//start from (0,0)
    g[y][x] = v;
  }

  static ll dp[4000][4000][4];
  if(g[0][0] != 0) dp[0][0][1] = g[0][0];
  dp[0][0][0] = 0;

  // filling dp map
  rep(i,r){
    rep(j,c){
      
      //move in a row
      // not get
      dp[i][j+1][0] = max(dp[i][j+1][0], dp[i][j][0]);
      dp[i][j+1][1] = max(dp[i][j+1][1], dp[i][j][1]);
      dp[i][j+1][2] = max(dp[i][j+1][2], dp[i][j][2]);
      dp[i][j+1][3] = max(dp[i][j+1][3], dp[i][j][3]);
      // get
      if(g[i][j+1] != 0){
        dp[i][j+1][1] = max(dp[i][j+1][1], dp[i][j][0]+g[i][j+1]);
        dp[i][j+1][2] = max(dp[i][j+1][2], dp[i][j][1]+g[i][j+1]);
        dp[i][j+1][3] = max(dp[i][j+1][3], dp[i][j][2]+g[i][j+1]);
      }

      //move in a column
      //not get
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][0]);
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][1]);
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][2]);
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][3]);
      //get
      if(g[i+1][j] != 0){
        dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][0]+g[i+1][j]);
        dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][1]+g[i+1][j]);
        dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][2]+g[i+1][j]); 
        dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][3]+g[i+1][j]);
      }
    }
  }

  
  ll ans = 0;
  rep(i,4) ans = max(ans, dp[r-1][c-1][i]);
  cout << ans << endl;
  

}


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

int main() {
  int N,num=1;
  cin >> N;
  while(num<N) {
    num*=2;
  }
  if(num<=N) {
    cout << num << endl;
  }
  else {
    cout << num/2 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string.h>
#include <stdio.h>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	ll ans = 0;

	if (n>0) {
		if (m>=2) {
			ll tmp = min(n, m/2);
			ans += tmp;
			m = m - 2 * tmp;
		}
	}

	if (m >= 4) {
		ans += m/4;
	}

	cout << ans << endl;

}


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

int main() {
  int x, n;
  cin >> x >> n;
  unordered_set<int> p;
  int tmp;
  rep(i, n) {
    cin >> tmp;
    p.insert(tmp);
  };
  bool flag = false;
  int diff = 0;

  while (!flag) {
    if (p.find(x - diff) == p.end() & p.find(x + diff) == p.end()) {
      cout << min(x - diff, x + diff) << endl;
      flag = true;
      return 0;
    } else if (p.find(x - diff) == p.end()) {
      cout << x - diff << endl;
      flag = true;
      return 0;
    } else if (p.find(x + diff) == p.end()) {
      cout << x + diff << endl;
      flag = true;
      return 0;
    }
    diff++;
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define nl endl
#define dbg(a) cout << #a << "=" << a << endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define md 1000000007

using namespace std;

int solve()
{
    ll n;
    cin>>n;
    ll ct=0;
    for(ll i=1;i<n;i++)
    {
        ct+=(n-1)/i;
    }
    cout<<ct<<endl;
    return 0;
}

int main()
{
    fast;
    solve();
    return 0;
}

Measured memory_bytes: 3648
from numpy.linalg import solve
 
a,b,c = [int(input()) for _ in range(3)] 
  
left = [[1,0,0,0,0,0,-1],
        [0,1,1,0,0,0,-1],
        [0,0,0,1,1,1,-1],
        [0,1,0,1,0,0,-1],
        [0,0,0,0,1,0,-1],
        [0,0,0,0,0,1,-1],
        [1,0,0,1,0,0,-1]]
 
right = [-a-b,-c,0,-a,-b-c,-a-c,-c]
 
l = solve(left, right)
u,v,w,x,y,z,s = map(int,l)
print(a,b,u)
print(v,c,w)
print(x,y,z)


Measured memory_bytes: 14520
#include <iostream>
using namespace std;
int main(){
	long long N;
	int ans = 0;
	cin >> N;
	if(N == 2){
		cout << 1 << endl;
		return 0;
	}
	for(long long i=2; i*i<=N; i++)
		if((N-1) % i == 0)
			ans += (i*i == N-1)? 1:2;
		else if(N % i == 0){
			long long n = N;
			while(n % i == 0)
				n /= i;
			if(n % i == 1)
				ans ++;
		}
	cout << ans+2 << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  int suma = 0;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
    suma += a[i];
  }
  pair<int, int> mina = make_pair(INT32_MAX, 0);
  rep(i, N)
  {
    int dist = abs(N * a[i] - suma);
    if (dist < mina.first)
      mina = make_pair(dist, i);
  }
  int ans = mina.second;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
		
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		System.out.println(Math.min(c,b/a));
	}

	
	
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  string s;
  cin>>s;
  int c[3]={};
  for(int i=0;i<s.size();i++){
    c[s[i]-'a']++;
  }
  int m=min({c[0],c[1],c[2]});
  c[0]-=m,c[1]-=m,c[2]-=m;
  if(max({c[0],c[1],c[2]})<2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
  int h, w ;
  while(1){
  cin >> h >> w ;
  if(h==0 && w==0) return 0;
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          if(((i%2)== 0  && (j%2)==0)||((i%2)== 1  && (j%2)==1)){
          cout << "#" ;
          }else{
          cout << "." ;
          }
      }
        cout << "\n" ;
  }
        cout << "\n" ;
  }
 return 0;  

}



Measured memory_bytes: 3096
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <atcoder/all>
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using namespace atcoder;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, q;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> q;
    dsu Dsu(n);
    while (q--) {
        int ch, u, v;
        cin >> ch >> u >> v;
        if (ch == 0) {
            Dsu.merge(u, v);
        } else {
            cout << Dsu.same(u, v) << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3928
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
typedef struct edge_ { ll to; ll cost; } edge;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



int main()
{
	int N, M;
	cin >> N >> M;
	vi X(M);
	cin >> X;

	sortall(X);
	
	vi L(M - 1);
	for (int i = 1; i < M; i++)
		L[i - 1] = X[i] - X[i - 1];

	sortall(L);

	int ans = 0;
	for (int i = 0; i < M - N; i++)
		ans += L[i];

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine()) + 360;
        int b = int.Parse(Console.ReadLine()) + 360;
        double c = (a + b) / 2.0;
        if (Math.Abs(a - b) > 180) c -= 180;
        while (c > 359.9999)
        {
            c -= 360;
        }
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)     {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p)   {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
ll mod_inv(ll a,ll m)     {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n;
	ll max_px_py=-inf,min_px_py=inf,max_px_ny=-inf,min_px_ny=inf;
	forn(i,0,n)
	{
		ll x,y;
		cin>>x>>y;
		max_px_py=max(max_px_py,x+y);
		max_px_ny=max(max_px_ny,x-y);
		min_px_py=min(min_px_py,x+y);
		min_px_ny=min(min_px_ny,x-y);
	}
	cout<<max(max_px_py-min_px_py,max_px_ny-min_px_ny)<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


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

const int MOD=1000000007;
char str[2][100];
long long ans;

main()
{
    int n;
    scanf("%d",&n);
    scanf("%s %s",str[0],str[1]);
    int start=0,nw_ty=-1;
    if(str[0][0]==str[1][0])
    {
        start=1;
        nw_ty=1;
        ans=3;
    }
    else
    {
        start=2;
        nw_ty=2;
        ans=6;
    }
    for(int i=start;i<n;i++)
    {
        if(str[0][i]==str[1][i])
        {
            if(nw_ty==1)
            {
                ans*=2;
                ans%=MOD;
                nw_ty=1;
            }
            else
            {
                ans*=1;
                ans%=MOD;
                nw_ty=1;
            }
        }
        else
        {
            if(nw_ty==1)
            {
                ans*=2;
                ans%=MOD;
                nw_ty=2;
            }
            else
            {
                ans*=3;
                ans%=MOD;
                nw_ty=2;
            }
            i++;
        }
        //printf("%lld\n",ans);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
def prime_table(n):
    memo = [True for _ in range(n + 1)]
    i = 2
    while i * i <= n:
        if memo[i]:
            j = i + i
            while j <= n:
                memo[j] = False
                j += i
        i += 1
    return memo

memo = prime_table(10 ** 5)
A = [0 for _ in range(10 ** 5 + 1)]
for i in range(3, 10 ** 5 + 1, 2):
    if memo[i] and memo[(i + 1) // 2]:
        A[i] += 1
for i in range(3, 10 ** 5 + 1):
    A[i] += A[i - 1]

Q = int(input())
for _ in range(Q):
    l, r = [int(i) for i in input().split()]
    print(A[r] - A[l - 1])


Measured memory_bytes: 7192
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

struct union_find {
    std::vector<int> parent;
    int __size;
    union_find(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

int n, k, l;

int main() {
    cin >> n >> k >> l;
    union_find uf_r(n), uf_l(n);
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf_r.unite(a, b);
    }
    for (int i = 0; i < l; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf_l.unite(a, b);
    }
    unordered_map<ll, int> mp;
    for (int i = 0; i < n; i++) {
        ++mp[uf_l.find(i) * 1000000LL + uf_r.find(i)];
    }
    for (int i = 0; i < n; i++) {
        cout << mp[uf_l.find(i) * 1000000LL + uf_r.find(i)] << (i == n - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 9928
#include <bits/stdc++.h>
#include <iostream>
#include <string> 
using namespace std;
int main(){
  int W,H,X,Y,R;
  cin >> W >> H >> X >> Y >> R;
  if(X-R >= 0 && X+R <= W && Y-R >= 0 && Y+R <= H){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] _n_m = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = _n_m[0];
            int m = _n_m[1];

            int[,] matrix_a = new int[n,m];
            int[] row_a;
            int[] vector_b = new int[m];
            int[] vector_c = new int[n];


            for (int i = 0; i < n; i++)
            {
                row_a = new int[m];
                row_a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                for (int j = 0; j < m; j++)
                {
                    matrix_a[i, j] = row_a[j];
                }
            }

            for (int j = 0; j < m; j++)
            {
                vector_b[j] = int.Parse(Console.ReadLine());
            }

            for (int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    vector_c[i] += matrix_a[i,j]*vector_b[j];
                }
            }            

            foreach (int item in vector_c)
                Console.WriteLine(item);

        }
    }
}


Measured memory_bytes: 18436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

map<ll, ll> primeFactor(ll n) {
  map<ll, ll> res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;
  auto pf = primeFactor(p);
  ll ans = 1;
  for(auto v : pf) ans *= pow(v.first, v.second / n);
  cout << ans << endl;
}

Measured memory_bytes: 3980
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

struct Loc {
    int x;
    int y;
};

const int MAX_SIZE = 900;
int H, W, K;

int d[4][2];
char A[MAX_SIZE][MAX_SIZE];
int dist[MAX_SIZE][MAX_SIZE];

int main(int argc, char **argv) {
    std::cin >> H >> W >> K;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            std::cin >> A[i][j];
        }
    }

    d[0][0] =  1; d[0][1] =  0;
    d[1][0] =  0; d[1][1] =  1;
    d[2][0] = -1; d[2][1] =  0;
    d[3][0] =  0; d[3][1] = -1;

    Loc loc_start;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (A[i][j] == 'S') {
                loc_start.x = i;
                loc_start.y = j;
            }
            dist[i][j] = MAX_SIZE * MAX_SIZE;
        }
    }

    std::queue<std::pair<Loc, int>> que;
    que.push(std::pair<Loc, int>({loc_start, 0}));

    while (!que.empty()) {
        std::pair<Loc, int> p = que.front(); que.pop();
        if (p.second < dist[p.first.x][p.first.y] && p.second <= K) {
            dist[p.first.x][p.first.y] = p.second;

            for (int i = 0; i < 4; i++) {
                Loc next = p.first;
                next.x += d[i][0];
                next.y += d[i][1];
                if (1 <= next.x && next.x <= H && 1 <= next.y && next.y <= W && A[next.x][next.y] == '.') {
                    que.push(std::pair<Loc, int>({next, p.second + 1}));
                }
            }
        }
    }

    int ret = MAX_SIZE * MAX_SIZE;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (dist[i][j] < MAX_SIZE) {
                int tmp1 = (i - 1) % K == 0 ? (i - 1) / K : (i - 1) / K + 1;
                int tmp2 = (j - 1) % K == 0 ? (j - 1) / K : (j - 1) / K + 1;
                int tmp3 = (H - i) % K == 0 ? (H - i) / K : (H - i) / K + 1;
                int tmp4 = (W - j) % K == 0 ? (W - j) / K : (W - j) / K + 1;
                int tmp = std::min(std::min(tmp1, tmp2), std::min(tmp3, tmp4));
                ret = std::min(ret, tmp + 1);
            }
        }
    }

    std::cout << ret << std::endl;
    return 0;
}


Measured memory_bytes: 3840
import sys
input = sys.stdin.readline
n, m, p = map(int, input().split())
edges = []
forward_edges = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a, b, p-c))
    forward_edges[a].append(b)


can_reach = [0]*n
stack = [0]
while stack:
    v = stack.pop()
    if can_reach[v]:
        continue
    can_reach[v] = 1
    for v2 in forward_edges[v]:
        if can_reach[v2]:
            continue
        stack.append(v2)


INF = 10**10
dist = [INF]*n
dist[0] = 0
for i in range(n):
    for v, v2, c in edges:
        if dist[v2] <= dist[v]+c:
            continue
        dist[v2] = dist[v]+c

negative = [0]*n
for i in range(n):
    for v, v2, c in edges:
        if dist[v2] <= dist[v]+c:
            continue
        if not can_reach[v2]:
            continue
        dist[v2] = -INF
        negative[v2] = 1

if negative[-1]:
    print(-1)
else:
    print(max(0, -dist[-1]))

Measured memory_bytes: 43632
#include <stdio.h>

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

int main(void){
  int n, a, b, i;
  int sum = 0;
  scanf("%d%d%d", &n, &a, &b);
  for(i = 1; i <= n; i++){
    if(a <= sumDigit(i) && sumDigit(i) <= b){
      sum += i;
    }
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N;
ll a,b;
int main(){
    cin>>N;
    ll ans=0;
    for(int i=1;i<=N;i+=2){
        ll cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt==8){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, pw[20], s[600100], p[600100], l[600100], lp[600100];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  int ln = (n + 1) / 2;
  pw[0] = 1;
  for (int i = 1; i <= n; i++)
    pw[i] = pw[i - 1] * 3;
  for (int i = 0; i < pw[ln]; i++) {
    int si = 0;
    for (int j = 0; j < ln; j++) {
      int dj = (i / pw[j]) % 3;
      if (dj == 1)
        si += 2 * pw[j];
      else if (dj == 2)
        si += pw[j];
    }
    s[i] = si;
  }
  for (int i = 0; i < pw[n]; i++)
    p[i] = i / pw[ln], l[i] = 0;
  for (int i = 0; i < pw[ln]; i++)
    lp[i] = i;
  char c;
  int cs = 0;
  while (cin >> c) {
    if (c == 'S') {
      cs++;
      for (int i = 0; i < pw[ln]; i++)
        lp[i] = s[lp[i]];
    } else {
      int sv = 0;
      for (int i = 0; i < pw[ln]; i++) {
        lp[i]++;
        if (lp[i] >= pw[ln])
          lp[i] = 0, sv = i;
      }
      for (int i = sv; i < pw[n]; i += pw[ln]) {
        if ((cs - l[i]) & 1)
          p[i] = s[p[i]];
        l[i] = cs;
        p[i]++;
        if (p[i] >= pw[n - ln])
          p[i] = 0;
      }
    }
  }
  for (int i = 0; i < pw[n]; i++)
    if ((cs - l[i]) & 1)
      p[i] = s[p[i]];
  for (int i = 0; i < pw[n]; i++)
    cout << lp[i % pw[ln]] + pw[ln] * p[i] << " ";
  cout << "\n";
}


Measured memory_bytes: 8176
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
ll convert(ll x,ll kt){
  ll res=0;
  for(int i=18;i>kt;i--){
    res+=(((x>>i)&1)<<(i-1));
  }
  for(int i=kt-1;i>=0;i--){
    res+=(((x>>i)&1))<<i;
  }
  return res;
}
ll g_convert(ll x,ll kt,ll bt){
  ll res=0;
  for(int i=18;i>=kt;i--){
    res+=(((x>>i)&1)<<(i+1));
  }
  for(int i=kt-1;i>=0;i--){
    res+=(((x>>i)&1)<<i);
  }
  res+=(bt<<kt);
  return res;
}
vector<ll> f(ll a,ll b,ll n){
  vector<ll> res;
  if(n==1) {
    res.push_back(a);
    res.push_back(b);
    return res;
  }
  ll N=(1<<n);
  ll kt=0;
  for(int i=0;i<=17;i++){
    if((((a^b)>>i)&1)==1){
      kt=i;
      break;
    }
  }

  ll a_kt=(a>>kt)&1,b_kt=(a_kt+1)%2;
  ll na=convert(a,kt),nb=convert(b,kt);
  ll nc=na^1;

  vector<ll> L=f(na,nc,n-1),R=f(nc,nb,n-1);
  for(int i=0;i<N/2;i++){
    res.push_back(g_convert(L[i],kt,a_kt));
  }
  for(int i=N/2;i<N;i++){
    res.push_back(g_convert(R[i-N/2],kt,b_kt));
  }
  return res;
}
int main(){
  ll n,a,b; cin>>n>>a>>b;
  vector<ll> ans=f(a,b,n);
  int cnt=0;
  for(int i=0;i<18;i++) if((((a^b)>>i)&1)==1) cnt++;
  if(cnt%2==0) {cout<<"NO"<<endl; return 0;}
  cout<<"YES"<<endl;
  for(int i=0;i<(1<<n);i++) cout<<ans[i]<<" ";
  cout<<endl;
}


Measured memory_bytes: 2400
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)

const long long INF = 1145140721;
ll n, t;
vector<ll> a(114514, 0);

int main(){
    cin >> n >> t;
    rep(i,n) scanf("%lld", &a[i]);

    ll mdiff = 0;
    ll mi = INF;
    rep(i,n){
        if(a[i] < mi) mi = a[i];
        if(a[i] - mi > mdiff) mdiff = a[i] - mi;
    }

    mi = INF;
    ll ans = 0;
    rep(i,n){
        if(a[i] < mi) mi = a[i];
        if(a[i] - mi == mdiff) ++ans;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1152