akhauriyash/Code-Regression huggingface dataset:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=I()
A=LI()
# A=[I() for i in range(N)]
# ignore %2==0 numbers
f=[]
odds=[]
t=[]
for n in A:
    if n%4==0:
        f.append(n)
    elif n%2!=0:
        odds.append(n)
    else:
        t.append(n)
if len(odds)==0:
    print('Yes')
elif len(f) < len(odds)-1:
    print('No')
else:
    if len(odds) - 1 == len(f):
        if len(t)> 0:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

Measured memory_bytes: 16640
<?php
fscanf(STDIN, '%d', $num);
fscanf(STDIN, '%d %d', $a, $b);
$pArr = explode(' ', trim(fgets(STDIN)));
list($e, $m, $h) = [0, 0, 0];
for ($i=0; $i < $num; $i++) { 
    if ($pArr[$i] <= $a) {
        $e++;
    } elseif ($pArr[$i] <= $b) {
        $m++;
    } else {
        $h++;
    }
}

echo min($e, $m, $h)."\n";

Measured memory_bytes: 4728
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
changer=[]
cl=0
flag=0
for i in range(m):
  b=list(map(int,input().split()))
  changer.append(b)
changer.sort(key=lambda x:x[1],reverse=True)
for i in range(m):
  if flag==1:
    break
  for j in range(cl,min(cl+changer[i][0],n)):
    if a[j]<changer[i][1]:
      a[j]=changer[i][1]
    else:
      flag=1
      break
  cl+=changer[i][0]
print(sum(a))


Measured memory_bytes: 32980
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

tmp = []
for i in range(N):
    tmp.append(V[i] - C[i])

res = 0
for i in range(N):
    if(tmp[i] > 0):
        res += tmp[i]
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin>>str;
    long long int sum = 0;
    for(int i=0; i<str.length(); i++){
        sum+=(str[i]-'0');
    }

    if(sum%9 > 0){
        cout<<"No"<<'\n';
    }
    else{
        cout<<"Yes"<<'\n';
    }

    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> ax(n), ay(n);
  vector<int> cx(m), cy(m);
  for (int i = 0; i < n; i++) {
    cin >> ax[i] >> ay[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> cx[i] >> cy[i];
  }
  const int inf = (int) 1e9;
  for (int i = 0; i < n; i++) {
    int dist = inf;
    int idx = -1; 
    for (int j = 0; j < m; j++) {
      int now = abs(cx[j] - ax[i]) + abs(cy[j] - ay[i]);
      if (now < dist) {
        dist = now;
        idx = j + 1;
      }
    }
    cout << idx << '\n';
  }
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1000*1000*1000;
const ll LINF = (ll)1e18;

void REC(vector<vector<pair<int,ll>>> &G, int v, int p, ll sum, vector<ll> &dist){
    dist[v] = sum;
    for(auto e: G[v]){
        if(e.first == p) continue;
        REC(G, e.first, v, sum+e.second, dist);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<vector<pair<int, ll>>> G(N);
    vector<ll> dist(N,0);
    REP(i, N-1){
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }
    
    int Q, K;
    cin >> Q >> K;
    K--;
    REC(G, K, -1, 0, dist);
    REP(i, Q){
        int x, y;
        cin >> x >> y;
        x--;y--;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


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

int main() {
   int a,b;
   cin >> a >> b;
   if(a != 1 && b != 1){
      cout<< ((a==b) ? "Draw" : (a>b) ? "Alice" : "Bob"); 
   }else{
      if(a==b)cout<<"Draw";
      else cout << ((a==1) ? "Alice" : "Bob");
   }
   return 0;
}


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

int main()
{
    int A, B, C, D;
    int count = 0, cou = 0;
    cin >> A >> B >> C >> D;

    while (A > 0)
    {
        count ++;
        A -= D;
    }

    while (C > 0)
    {
        cou ++;
        C -= B;
    }

    if (count >= cou)
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }
    
    
    
    
    
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include <vector>
#include <map>

using namespace std;
int main( )
{
	long long L, R;
	cin >> L >> R;
	vector< int > v;
	for( long long i = L; i <= R; ++ i )
	{
		v.push_back( i % 2019 );
		if( v.size( ) >= 2010 * 2 )
			break;
	}
	int ans = 2019;
	for( int i = 0; i < v.size( ); ++ i )
	{
		for( int j = i + 1; j < v.size( ); ++ j )
		{
			ans = min( ans, ( v[i] * v[j] ) % 2019 );
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#include<string.h>
#define pi acos(-1.0)
using namespace std;
int n,m;
const int maxn=2e5+10;
vector<int>vec[maxn];
int sum[maxn];int pre[maxn];
void bfs()
{
	queue<int>q;q.push(1);
	sum[1]=0;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=0;i<vec[u].size();i++)
		{
			int v=vec[u][i];
			//cout<<v<<endl;
			if(sum[v]>sum[u]+1)
			{
				pre[v]=u;
				sum[v]=sum[u]+1;
			//	cout<<sum[v]<<endl;
				q.push(v);
			}
		}
	}
	
}
int main()
{
  int n,m;cin>>n>>m;
  memset(sum,inf,sizeof(sum));
  for(int i=1;i<=m;i++)
  {
  	int x,y;cin>>x>>y;
  	vec[x].push_back(y);
	vec[y].push_back(x); 
  }
  bfs();bool f=true;
   /*for(int i=1;i<=n;i++)
   {
   	cout<<sum[i]<<endl;
   	if(sum[i]==inf)f=false;
   }*/
  if(!f)cout<<"No"<<endl;
  else
  {
  	   cout<<"Yes"<<endl;
  	    for(int i=2;i<=n;i++)
  	    cout<<pre[i]<<endl;
  }
	return 0;
 } 

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 805;

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};

char g[MAXN][MAXN];

int dis[MAXN][MAXN];
int used[MAXN][MAXN];

int h, w, lim;

int get_dis(int i, int j) {
	return (min(min(i, j), min(h - 1 - i, w - 1 - j)) + lim - 1) / lim;
}

queue<pii> qq1;

void bfs1() {
	int i0, j0;
	REP(i, 0, h) {
		REP(j, 0, w) {
			if (g[i][j] == 'S') {
				i0 = i;
				j0 = j;
			}
		}
	}
	qq1.push(mp(i0, j0));
	used[i0][j0] = 1;
	while(!qq1.empty()) {
		i0 = qq1.front()._1, j0 = qq1.front()._2;
		qq1.pop();
		if (dis[i0][j0] != lim) {
			REP(k, 0, 4) {
				int i1 = i0 + di[k], j1 = j0 + dj[k];
				if (i1 >= 0 && i1 < h && j1 >= 0 && j1 < w && g[i1][j1] == '.' && !used[i1][j1]) {
					used[i1][j1] = 1;
					dis[i1][j1] = dis[i0][j0] + 1;
					qq1.push(mp(i1, j1));
				}
			}
		}
	}
}

void solve(){
	scanf("%d%d%d", &h, &w, &lim);
	REP(i, 0, h) {
		scanf("%s", &g[i][0]);
	}
	bfs1();
	int mn = INF;
	REP(i, 0, h) {
		REP(j, 0, w) {
			if (used[i][j]) {
				//printf("%d %d\n", i, j);
				mn = min(mn, 1 + get_dis(i, j));
			}
		}
	}
	printf("%d\n", mn);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, A;
    cin >> N >> A;

    cout << N*N-A << endl;

    
    return 0;
}

Measured memory_bytes: 256
import sys

n = int(input().strip())
a = [int(x) for x in input().strip().split(' ')]
a = sorted(a, reverse=True)

if n == 2:
    print(a[0])
    exit(0)

sum = a[0] + a[1]
for i in range(n-3):
    if i % 2 == 0:
        sum += a[int(i/2+1)]
    else:
        sum += a[int(i/2+2)]

print(sum)


Measured memory_bytes: 31716
#include <iostream>

using namespace std;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        ans += h <= a && w <= b;
    }
    cout << ans << "\n";
}

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

using namespace std;

int main() {
    int N,M,Q;
    cin >> N >> M >> Q;

    vector<int> L(M), R(M);

    for(int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        L[i]--, R[i]--;
    }

    vector<vector<int>> train(N, vector<int>(N, 0));
    vector<vector<int>> train_cum(N+1, vector<int>(N+1, 0));

    for(int i = 0; i < M; i++) {
        train[L[i]][R[i]] += 1;
    }

    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            train_cum[i+1][j+1] = train_cum[i][j+1] + train_cum[i+1][j] - train_cum[i][j] + train[i][j];
        }
    }
    
    int p, q;
    vector<int> answer;

    for(int k = 0; k < Q; k++) {
        cin >> p >> q;

        answer.push_back(train_cum[q][q] - train_cum[p-1][q] - train_cum[q][p-1] + train_cum[p-1][p-1]);
    }

    for(auto i : answer) {
        cout << i << endl;
    }

	return 0;
}

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

int main () {
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort (a,a+N);
    cout << a[N-1]-a[0];
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextInt();
        int b = sc.nextInt();
        double t = sc.nextInt();
        int total = 0;
        double sum = 0;

        for (int i = 1; sum < t + 0.5; i++) {
            sum = i * a;
            if (sum < t + 0.5)
                total += b;
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 23764
#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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	int cu = 1;
	rep(i, 0, N) if (A[i] == cu) cu++;
	
	if (cu == 1) cout << -1 << endl;
	else cout << N - cu + 1 << endl;
}







Measured memory_bytes: 1024
#include <bits/stdc++.h>
     
        using namespace std;
        #define sd(x) scanf("%d",&x);
        #define sdl(x) scanf("%lld",&x);
        #define pr(x) printf("%d\n",x);
        #define prl(x) printf("%lld\n",x);

    void solve()
    {
        int n;
        cin >> n;
        unordered_map<string,bool>maps;
        int tot=0;
        for (int c=0;c<n;c++)
            {
                string a;
                cin >> a;
                if (maps[a]==false)
                    maps[a]=true,tot++;
            }
            cout << tot << endl;
    }

    int main ()
    {
      
     int t;
     //cin >> t;
     t=1;

     for (int tt=1;tt<=t;tt++)
     {
         solve();
     }

    return 0;
     
     
     
     
        }


Measured memory_bytes: 17792
import math

def Koch(Px, Py, Qx, Qy, n) :
    if n == 0 :
        return
    else :
        Ax = (2 * Px + Qx) / 3
        Ay = (2 * Py + Qy) / 3
        Bx = (Px + 2 * Qx) / 3
        By = (Py + 2 * Qy) / 3
        Cx = Ax + (Bx - Ax) * math.cos(math.pi/3) - (By - Ay) * math.sin(math.pi/3) 
        Cy = Ay + (Bx - Ax) * math.sin(math.pi/3) + (By - Ay) * math.cos(math.pi/3)
        
        Koch(Px, Py, Ax, Ay, n-1)
        print(Ax, Ay)
        Koch(Ax, Ay, Cx, Cy, n-1)
        print(Cx, Cy)
        Koch(Cx, Cy, Bx, By, n-1)
        print(Bx, By)
        Koch(Bx, By, Qx, Qy, n-1)

n = int(input())
print(0, 0.00000000)
Koch(0.00000000, 0.00000000, 100.00000000, 0.00000000, n)
print(100.00000000, 0.00000000)

    


Measured memory_bytes: 5784
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char S[] = new char[n];
		S = sc.next().toCharArray();

		int a[] = new int[n];
		for(int i=0; i<n; i++) a[i] = -1;
		//0=羊 1=狼
		for(int i=0; i<2; i++) {
			for(int j=0; j<2; j++) {
				a[n-1]=i;
				a[0]=j;
				for(int k=0; k<n-1; k++) {
					char c = S[k];
					if(c=='o') {
						if(a[k]==0) {
							a[k+1]=a[(k-1+n)%n];
						}else {
							a[k+1]=(a[(k-1+n)%n]+1)%2;
						}
					}else {
						if(a[k]==0) {
							a[k+1]=(a[(k-1+n)%n]+1)%2;
						}else {
							a[k+1]=a[(k-1+n)%n];
						}
					}
				}
				boolean ok = true;
				for(int k=0; k<n; k++) {
					if(S[k]=='o') {
						if(a[k]==0 && a[(k-1+n)%n]!=a[(k+1)%n]) ok=false;
						if(a[k]==1 && a[(k-1+n)%n]==a[(k+1)%n]) ok=false;
					}else {
						if(a[k]==0 && a[(k-1+n)%n]==a[(k+1)%n]) ok=false;
						if(a[k]==1 && a[(k-1+n)%n]!=a[(k+1)%n]) ok=false;
					}
				}
				if(ok) {
					p(a);
					sc.close();
					return;
				}
			}
		}
		System.out.println(-1);
		sc.close();
	}

	private void p(int a[]) {
		for(int i=0; i<a.length; i++) {
			if(a[i]==0) {
				System.out.print('S');
			}else {
				System.out.print('W');
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 51744
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

  int N,M;
  cin >> N >> M;
  int asum=N;
  for (int i=0;i<M; i++){
	int a;
    cin >> a;
    asum -=  a;
  }
  
  if (asum>=0) cout << asum;
  else cout << -1;
  

	
}

Measured memory_bytes: 3636
from operator import add, sub
from operator import mul, floordiv
class Two_pointer:
    def __init__(self, cond, init=0, right=add, left=sub):
        self.cond = cond
        self.init = init
        self.next_right = right
        self.next_left = left
        
    def __call__(self, A):
        cond = self.cond
        next_right, next_left = self.next_right, self.next_left
        s = init = self.init
        n = len(A)
        X = {}
        r = 0
        for l in range(n):
            X[l] = r
            while r < n and cond(s, A[r]):
                s = next_right(s, A[r])
                r += 1
                X[l] = r
            if l == r:
                r += 1
            else:
                s = next_left(s, A[l]) if l+1 != r else init
        return list(X.items())

n, *A = map(int, open(0).read().split())
X = Two_pointer(lambda s, n: s + n == s ^ n)(A)
print(sum(r-l for l, r in X))

Measured memory_bytes: 55768
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,m;
vvi a;

string f(int x){
	string s(n,'0');
	for(int i=0;i<n;i++) if(x&1<<i) s[i]='1';
	return s;
}

int main(){
	cin>>n>>m;
	a=vvi(n,vi(n));
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		a[s-1][t-1]++;
	}
	int S=1<<n;
	vl dp(S),two(n+1);
	two[0]=1;
	for(int i=1;i<=n;i++) two[i]=two[i-1]*2%mod;
	for(int i=0;i<S;i++) if((i&3)==3){
		int T=i;
		do{
			if(T&3){
				ll res=1;
				bool B=((T&3)==3?1:0);
				for(int j=0;j<n;j++) if(i&1<<j){
					int X=0,Y=0;
					for(int k=j+1;k<n;k++) if(i&1<<k&&a[j][k]){
						if(T&1<<k) X++;
						else Y++;
					}
					if(T&1<<j) (res*=(two[Y]-1)*(B?1:two[X])%mod)%=mod;
					else (res*=two[X])%=mod;
				}
				if(B) (res*=dp[T])%=mod;
				(dp[i]+=res)%=mod;
			}
			T=(T-1)&i;
		}while(T!=i);
	}
	cout<<dp[S-1]<<endl;
}

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

using namespace std;

int main()
{
  int n = 0;

  cin >> n;
  
  for(int k = 3; k <= n;k++)
    {
      if(k % 3 == 0)
	{
	  cout << " " << k;
	}
      else if(k % 10 == 3)
	{
	  cout << " " << k;
	}
      else if((k % 100)/10 == 3)
	{
	  cout << " " << k;
	}
      else if((k % 1000)/100 == 3)
	{
	  cout << " " << k;
	}
      else if(k /1000 == 3)
	{
	  cout << " " << k;
	}
    }
  cout << endl;
}




Measured memory_bytes: 3088
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        balls: [(isize, isize);n]
    }

    if n == 1 {
        println!("1");
        return;
    }

    let mut diffs: HashMap<(isize, isize), usize> = HashMap::new();

    for (&(x1, y1), &(x2, y2)) in balls.iter().tuple_combinations() {
        let mut diff = (x2 - x1, y2 - y1);
        if diff.0 < 0 || diff.0 == 0 && diff.1 < 0 {
            diff = (-diff.0, -diff.1);
        }

        *diffs.entry(diff).or_insert(0) += 1;
    }

    dbg!(&diffs);
    let max_count = diffs.values().max().unwrap();
    let ans = n - max_count;
    println!("{}", ans);
}


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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] data = S.toCharArray();
        data[3] = '8';
        System.out.println(String.valueOf(data));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define vvll vector <vll>
#define vvii vector <vii>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll mod = 1000000007;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
  	ll a, b;
  	cin >> a >> b;
  	cout << max(a*b,max(a+b,a-b));
	return 0;
}

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

using namespace std;

int main()
{
    int i=1;
    int x = -1;
    while (true)
    {
        cin >> x;
        if(x==0)
        {
            break;
        }
        cout << "Case " << i << ": " << x << endl;
        i++;
    }
}



Measured memory_bytes: 3028
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
//#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    long int R,C,K;
    cin>>R>>C>>K;
    long int r[K],c[K],v[K];
    vector<vector<long int> > w(R,vector<long int>(C,0));
    for(long int i=0;i<K;i++){
        cin>>r[i]>>c[i]>>v[i];
        r[i]--;
        c[i]--;
        w[r[i]][c[i]]=v[i];
    }
    vector<vector<vector<long long> > > sum(R,vector<vector<long long> >(C,vector<long long>(4,0)));
    if (w[0][0]>0) sum[0][0][1]=w[0][0];
    for (int j=1;j<C;j++){
        for (int k=1;k<4;k++){
            sum[0][j][k]=sum[0][j-1][k];
            if (w[0][j]>0) sum[0][j][k]=max(sum[0][j][k],sum[0][j-1][k-1]+w[0][j]);
        }
    }
    for (int i=1;i<R;i++){
        sum[i][0][0]=max(sum[i-1][0][1],sum[i-1][0][0]);
        if (w[i][0]>0) sum[i][0][1]=sum[i][0][0]+w[i][0];
    }

    for (int i=1;i<R;i++){
        for (int j=1;j<C;j++){
            for (int k=0;k<4;k++){
                sum[i][j][k]=sum[i][j-1][k];
            }
            for (int k=0;k<4;k++) sum[i][j][0]=max(sum[i][j][0],sum[i-1][j][k]);
            if (w[i][j]>0){
                for (int k=0;k<4;k++)  sum[i][j][1]=max(sum[i][j][1],sum[i-1][j][k]+w[i][j]);
                for (int k=1;k<4;k++)  sum[i][j][k]=max(sum[i][j][k],sum[i][j-1][k-1]+w[i][j]);
            }
        }
    }
    long long ans=0;
    for (int k=0;k<4;k++){
        ans=max(ans,sum[R-1][C-1][k]);
        //cout<<sum[0][C-1][k]<<" ";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 711516
#include <iostream>
#include <time.h>
#define INF 10000000
using namespace std;

int main(){
  clock_t start=clock();
  int n,x[302][302]={},y[302][302]={};
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>y[i][j],x[i][j]=y[i][j];


  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
    }
  
  int ans=y[0][n-1],sum,K[302][302]={},t=0,f=1;
  while(f){
    t++,f=0;
    for(int i=0;i<n;i++) //yoko
      for(int j=i+1;j<n;j++) {//yoko
	int a=K[i][j],nk=a;
	sum=-INF;
	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum<=X+Y)sum=X+Y,nk=k;
	}
	ans=max(ans,sum);
	
	if(nk<n-1)f=1;
	for(int k=a+1;k<nk;k++){//tate
	  sum+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum);
	}
	K[i][j]=nk+(nk==a+1);
      }
  }
  clock_t end=clock();
  //  cout << (double)(end-start)/CLOCKS_PER_SEC <<endl;
  cout <<ans<<endl;
	  
  return 0; 
}

Measured memory_bytes: 2244
#include<iostream>
#include<string>
using namespace std;
string s;
int n;
int main()
{
	cin>>n;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(int(s[i]+n)>='A'+26)
			s[i]=char(int(s[i])-26);
		s[i]=char(s[i]+n);	
	}					
	cout<<s<<endl;	
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  string T;
  for (int i = 0; i < N; i += 2) {
    T += S[i];
  }
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50005, P = 1e9, M = 200000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    if (y % 2 == 0 and y >= 2 * x and y <= 4 * x) {
        cout << "Yes\n";
    }
    else  cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n < 1200) cout << "ABC" << endl;
	else if (n < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int x;
    cin >> x;
    cout << 10 - (x / 200) << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;
typedef long double ll;
ll dist(ll x1 , ll y1 , ll x2 , ll y2)
{
    ll ans1 = (y1-y2)*(y1-y2);
    ll ans2 = (x1-x2)*(x1-x2);
    ans1+=ans2;
    ans2=sqrt(ans1);
    return ans2;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll x[n], y[n];
    vector<int>v;
    for(int i = 0 ; i < n;i++)
    {
        v.push_back(i);
        cin >> x[i]>>y[i];
    }
    ll disss[n][n];
    ll ans=0.0000000000;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = i+1 ; j < n ;j++ )
        {
            disss[i][j]=dist(x[i], y[i] , x[j], y[j]);
        }
    }
    do
    {
        for(int i = 0 ; i < n-1 ;i++)
        {
            ans+=disss[min(v[i],v[i+1])][max(v[i],v[i+1])];
        }
    }
    while(next_permutation(v.begin(),v.end()));
    ll fct=1.0000000000;
    for(int i = 1 ; i <=n ;i++)
    {
        fct*=i;
    }
    ll lastans=0.0000000000;
    lastans += (ans/fct) ;
    cout << setprecision(10) <<  lastans << "\n";
    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T x; cin >> x; return x; }

signed main()
{
	int N = in(), T = in();
	int min_c = 2000;
	REP(i, N) {
		int c = in(), t = in();
		if (t <= T)min_c = min(min_c, c);
	}
	if (min_c == 2000) {
		cout << "TLE" << endl;
	} else {
		cout << min_c << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, m, x, y;
    cin>>n>>m>>x>>y;
    int a[n], b[m];
    f(i, n) cin>>a[i];
    f(i, m) cin>>b[i];
    sort(a, a + n);
    sort(b, b + m);
    int l = a[n - 1] + 1, r = b[0];
    int l2 = x + 1, r2 = y;
    int L = max(l, l2), R = min(r, r2);
    if(L <= R){
        cout<<"No War\n";
    }
    else cout<<"War\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

LL x;

int main()
{
	scanf("%lld", &x);
	LL temp = (x / 11) * 2 + ((x % 11) > 6 ? 2 : 1);
	if (x % 11 == 0) temp--;
	printf("%lld\n", temp);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(snip_i, n) cin >> h.at(snip_i);
  sort(h.begin(), h.end());
  int ans = 1001001001;
  rep(i, n-k+1){
    int add = h.at(i+k-1) - h.at(i);
    ans = min(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int k;cin>>k;
    long long int ans = 0;
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++)
            for(int l=1;l<=k;l++)
                ans+=__gcd(__gcd(i,j),l);
    cout<<ans<<"\n";            
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 3648
// ※※※ 解答不能 ※※※
// 以下のソースを勉強する.
// yutaka1999氏.
// https://atcoder.jp/contests/jsc2019-qual/submissions/7117252
#include <bits/stdc++.h>
using namespace std;
#define SIZE 600005
#define MOD 1000000007
using LL = long long;
using P = pair<int, int>;

LL inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < SIZE; i++){
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fac[i] = fac[i - 1] * (LL)i % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

LL C(int a,int b){
    if(a < b) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

LL solve(int n, int m, int L){
    LL ret=C(n + L, n);
    for(int t = 0; (t + 1) * m <= L; t++){
        int zan = L - (t + 1) * m;
        int a = n - m, b = m;
        for(int k = 0; k * t <= L && k <= a; k++){
            if(zan < 0) break;
            LL vl = C(zan + n, n) * C(a, k) % MOD * C(n, a) % MOD;
            if(k % 2 == 1) ret += vl;
            else           ret += MOD - vl;
            ret %= MOD;
            zan -= t + 1;
        }
        zan = L - (t + 2) * m;
        for(int k = 0; k * t <= L && k <= a; k++){
            if(zan < 0) break;
            LL vl = C(zan + n, n) * C(a, k) % MOD * C(n, a) % MOD;
            if(k % 2 == 0) ret += vl;
            else           ret += MOD - vl;
            ret %= MOD;
            zan -= t + 1;
        }
    }
    return ret;
}
int main(){
    make();
    int n, m, l, r;
    scanf("%d %d %d %d",&n, &m, &l, &r);
    printf("%lld\n",(solve(n, m, r) - solve(n, m, l - 1) + MOD) % MOD);
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll res=0;
    ll a,b;

    cin >> b;
    REAP(i,1,n){
        cin >> a;
        if(b>a)swap(a,b);
        ll g=gcd(a,b);
        b=(a/g)*b;
    }
    cout << b << endl;
}


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

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

    vector<pair<pair<string, int>, int>> sp(n);
    for (int i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        sp[i] = make_pair(make_pair(s, -p), i + 1);
    }
    
    sort(sp.begin(), sp.end());
    for (int i = 0; i < n; i++)
    {
        cout << sp[i].second << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int cnt = 0, cnt2 = 0;
		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(",");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
			int c = Integer.parseInt(str[2]);
			if (a * a + b * b == c * c) cnt++;
			if (a == b) cnt2++;
		}
		System.out.println(cnt + "\n" + cnt2);

	}

}

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

#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define sz(a) (int) a.size()
#define bitcount(a) __builtin_popcount(a)

using namespace std;
// using namespace __gnu_pbds;


typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll oo = 1e15;
const int N = (int) 1010;
const int M = 1e4 + 10;

struct item {
    int w, s, v;
    item(int w, int s, int v): w(w), s(s), v(v) {}
    bool operator<(const item& o) const {
        return s - o.w < o.s - w;
    }
};

void solve() {
    int n; cin >> n;
    vector<item> a;
    for(int i = 0; i < n; ++i) {
        int w, s, v; cin >> w >> s >> v;
        a.eb(w, s, v);
    }
    sort(all(a)); a.insert(a.begin(), item(-1, -1, -1));
    vector<vector<ll>> dp(n + 1, vector<ll>(2 * M, -oo));
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i) {
        for(int w = 0; w < 2 * M; ++w) {
            dp[i][w] = dp[i - 1][w];
        }
        for(int pw = 0; pw <= M && pw <= a[i].s; ++pw) {
            dp[i][pw + a[i].w] = max(dp[i][pw + a[i].w], dp[i - 1][pw] + a[i].v);
        }
    }
    cout << *max_element(all(dp[n])) << '\n';
}

int main() {
    // freopen("input.in", "r", stdin);
    // freopen("input.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    // int t; cin >> t; while(t--)
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 163724
#include <stdio.h>

#define ll long long

ll gcd(ll t, ll a)
{
  if (a == 0) return t;
  return gcd(a, t%a);
}


ll lcm(ll t, ll a){ return t / gcd(t, a) * a; }
  

int main()
{
  ll a = 1LL, t;
  int n, i;

  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%lld", &t);
    a = lcm(t, a);
  }
  printf("%lld\n", a);

  return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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 main () {
  string S; cin >> S;

  REP(b,1<<3) {
    int num = S[0]-'0';
    string ans;
    ans += S[0];
    REP(i,3) {
      if (b&(1<<i)) {
        num += S[i+1]-'0';
        ans += '+';
        ans += S[i+1];
      }
      else {
        num -= S[i+1]-'0';
        ans += '-';
        ans += S[i+1];
      }
    }

    if (num == 7) {
      ans += "=7";
      cout << ans << endl;
      return 0;
    }
  }
}

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

int main() {
	
	int N,M;
	cin>>N>>M;
	
	int A[N],i,tot=0,temp=0;
	for(i=0;i<N;++i)
	{
		cin>>A[i];
		
		tot+=A[i];
	}
	
    
	int c=0;
	for(i=0;i<N;++i)
	{
		if((4*M)*A[i]<tot)
		{
			continue;
		}
		else
		{
			c++;
		}
	}
	
	
	if(c>=M)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}


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

int main()
{
  int l;
  cin >> l;
  vector<double> v;
  for(int i=0;i<3;i++) v.push_back(l/3.0);
  cout << fixed << setprecision(12) << v[0]*v[1]*v[2] << endl;
  return 0;
}

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

// first: cost, second: key
typedef pair<int, int> vert;

static const int MAX   = 10000;
static const int INFTY = 1 << 20;
static const int WHITE = 0;
static const int BLACK = 2;

vector<vert> adjs[MAX];

void dijkstra(int n_v, int v_start) {
    priority_queue< vert, vector<vert>, greater<vert> > visitings;
    int color[MAX];
    int costs[MAX];

    for (int i = 0; i < n_v; i++) {
        costs[i] = INFTY;
        color[i] = WHITE;
    }

    costs[v_start] = 0;
    visitings.push( make_pair(0, v_start) );

    while (! visitings.empty()) {
        vert nearest = visitings.top();
        visitings.pop();

        int next_id = nearest.second;
        color[next_id] = BLACK;

        if ( costs[next_id] < nearest.first )
            continue;

        for (int i = 0; i < adjs[next_id].size(); i++) {
            int adj  = adjs[next_id][i].first;
            int cost = adjs[next_id][i].second;

            if (color[adj] == BLACK)
                continue;

            if (costs[next_id] + cost < costs[adj]) {
                costs[adj] = costs[next_id] + cost;
                visitings.push( make_pair(costs[adj], adj) );
            }
        }
    }

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

int main() {
    int n_v;
    scanf("%d", &n_v);

    for (int i = 0; i < n_v; i++) {
        int vert_id, n_adjs;
        scanf("%d %d", &vert_id, &n_adjs);

        for (int j = 0; j < n_adjs; j++) {
            int adj, cost;
            scanf("%d %d", &adj, &cost);
            adjs[vert_id].push_back( make_pair(adj, cost) );
        }
    }

    dijkstra(n_v, 0);
}

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

int mon[4] = {10, 50, 100, 500};
int c[4] = {0};
int ans[4] = {0};
int n, sum, cnt;
bool ch = 0;

int main() {
  int i, j;
  while(1) {
    cin >> n;
    if(n == 0) break;
    if(ch)
      cout << endl;
    else
      ch = 1;

    sum = 0;
    cnt = 0;
    for(i = 0; i < 4; ++i) {
      cin >> c[i];
      sum += c[i] * mon[i];
      ans[i] = 0;
    }
    sum -= n;
    for(i = 0; i < 4; ++i) {
      int x = c[3 - i] - sum / mon[3 - i];
      sum %= mon[3 - i];
      if(x) ans[3 - i] = x;
    }
    for(i = 0; i < 4; ++i)
      if(ans[i] > 0) cout << mon[i] << " " << ans[i] << endl;
  }
  return 0;
}


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

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

    long long r = 0;
    long long g = 0;
    long long b = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }

    long long ans = r * g * b;
    for(int i = 0; i < n - 2; i++) {
        for(int j = 1; i + 2*j < n; j++) {
            if(s[i] != s[i + j] && s[i + j] != s[i + 2*j] && s[i + 2*j] != s[i]) {
                ans--;
            }
        }
    }

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

Measured memory_bytes: 3628
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=[int(input()) for i in range(n)]
        x=max(a)
        y=min(a)
        a.remove(x)
        a.remove(y)
        ave = sum(a)//len(a)
        print(ave)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}

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

int main() {
	int N,K;
	cin >> N >> K;
		
	if (K == 1) {
		cout << "YES";
	} else 	if (K >= N || K >50) {
		cout << "NO";
	} else if (K <= (int)N / 2 + 1) {
		cout << "YES";
	} else {
		cout << "NO";
	}
}




Measured memory_bytes: 384
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

template<class T> struct Edge{

	int to;
	T cost;

	Edge(int t = 0,T c = 1):to(t),cost(c){}

};
template<class T> struct Graph{
	
	int N,M;
	vector<vector<Edge<T> > > g;

	Graph(int N,int M):N(N),M(M),g(N,vector<Edge<T> >(0)){}

	void add_edge(int a,int b,T c = 1){
		g[a].emplace_back(b,c);
	}

};

template<class T> struct Bipartite{

	Graph<T> G;
	bool is_bipartite = true;
	vector<int> col;
	long long cnt[2] = {0,0};

	Bipartite(Graph<T>& G):G(G),col(G.N, -1){}

	void dfs(int x,int c = 0){
		col[x] = c;
		cnt[c]++;
		for(auto e : G.g[x]){
			if(col[e.to] >= 0){
				if(col[e.to] == c){
					is_bipartite = false;
					return;
				}
			}else{
				dfs(e.to,c^1);
			}
		}
	}
	bool solve(){
		dfs(0);	
		return is_bipartite;
	}
};


int main(int argc, char const *argv[])
{
	ll n,m;cin >> n >> m;

	Graph<int> G(n,m);
	rep(i,m){
		int a,b;cin >> a >> b;
		a--,b--;
		G.add_edge(a,b);
		G.add_edge(b,a);
	}

	Bipartite<int> B(G);

	B.solve();

	if(B.is_bipartite){
		cout << B.cnt[0]*B.cnt[1] - m << '\n';
	}else{
		cout << n*(n-1)/2 - m << '\n';
	}

}


Measured memory_bytes: 12544
#include<bits/stdc++.h>
#define int long long
using namespace std;

int dp[20001]{},d[20000];signed main() {int a, b, c;cin >> a >> b >> c;fill(dp + 1,dp + a + 1, LLONG_MAX/3);for (int e = 0; e < a; e++)scanf("%lld", &d[e]);for (int f = 0; f <a; f++) {int MIN = LLONG_MAX/3, MAX = 0;for (int g = f + 1,sum=0; g <=a&&sum<b; g++,sum++) {MIN = min(MIN, d[g-1]);MAX = max(MAX, d[g-1]);dp[g] = min(dp[g], dp[f] + c + (g - f)*(MAX - MIN));}}cout << dp[a] << endl;}

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

using namespace std;
const int maxn = 1000050;
typedef long long ll;
ll a[maxn];
ll dp[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j+i-1<=n;j++){
			dp[j]=max(a[j]-dp[j+1],a[j+i-1]-dp[j]);
		}
	}
	cout<<dp[1]<<endl;
	return 0;
}

Measured memory_bytes: 2304
object Main extends App {
  class Node(val key: Int, var prev: Node, var next: Node) {
    def insert(key: Int): Unit = {
      val n = new Node(key, this, this.next)
      this.next.prev = n
      this.next = n
    }

    def listSearch(key: Int): Node =
      Stream
        .iterate(this.next)(_.next)
        .takeWhile(_.key != -1)
        .find(_.key == key)
        .getOrElse(null)

    def deleteNode(n: Node): Unit =
      if (n != null) {
        n.prev.next = n.next
        n.next.prev = n.prev
      }

    def deleteFirst(): Unit    = deleteNode(this.next)
    def deleteLast(): Unit     = deleteNode(this.prev)
    def delete(key: Int): Unit = deleteNode(listSearch(key))

    def show: String =
      Stream
        .iterate(this.next)(_.next)
        .takeWhile(_.key != -1)
        .map(_.key)
        .mkString(" ")

    def action(line: String): Unit = line match {
      case "deleteFirst"                  => this.deleteFirst()
      case "deleteLast"                   => this.deleteLast()
      case _ if line.startsWith("insert") => this.insert(line.replaceFirst("insert ", "").toInt)
      case _                              => this.delete(line.replaceFirst("delete ", "").toInt)
    }
  }

  def init(): Node = {
    val n: Node = new Node(-1, null, null)
    n.next = n
    n.prev = n
    n
  }

  val a = init()

  (1 to readInt)
    .foreach(_ => a.action(readLine))

  println(a.show)
}



Measured memory_bytes: 479432