akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define vec2 vector<vector<int>>
#define set setprecision
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	int n;
	cin >> n;
	vec a(n);
	int k;
	rip(i, n)cin >> a[i];
	if (n < 1000) {
		int maxxx = 0;
		rip(i, n) {
			if (i != 0) k = a[0];
			else  k = a[1];
			rip(j, n) {
				if (j != i)k = gcd(k, a[j]);
			}
			maxxx = max(maxxx, k);
		}
		cout << maxxx << endl;
	}
	else {
		int p[100009], r[100009];
		int l = a[0];//subetenosaidaikouyakusuu
		rip(i, n) {
			l = gcd(l, a[i]);
			p[i] = l;
		}
		int k = a[n - 1];
		rip(i, n) {
			int j = n - 1 - i;
			k = gcd(k, a[j]);
			r[j] = k;
		}
		p[-1] = l;
		r[n] = l;
		int maxx = 0;
		rip(i, n) {
			maxx = max(maxx, gcd(p[i - 1], r[i + 1]));
		}
		cout << maxx << endl;
	}
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<math.h>
#include<string.h>

int main(void){

	int N,math1,math2,kuri,keta;
	int i,j,k,q,leng1,leng2;
	char fi[10000],se[10000],ans[10000];

	scanf("%d",&N);

	for(i=0;i<N;i++){

		for(j=0;j<1000;j++){
			ans[j]='\0';
			fi[j]='\0';
			se[j]='\0';
		}

		scanf("%s",&fi);
		scanf("%s",&se);

		for(j=0;fi[j]!='\0';j++){
		}
		leng1=j;
		for(j=0;se[j]!='\0';j++){
		}
		leng2=j;
		if(leng1<=80&&leng2<=80){
		for(j=leng1-1,k=leng2-1,keta=0,kuri=0;j>=0||k>=0;j--,k--,keta++){
			if(j<0) math1=0;
			else math1=fi[j]-'0';
			if(k<0) math2=0;
			else math2=se[k]-'0';
            ans[keta]=((math1+math2+kuri)%10)+'0';
			kuri=(math1+math2+kuri)/10;
		}
		q=0;
		if(kuri==1) ans[keta]='1',q=1;
		if(keta+q<=80){
			for(j=keta-1+q;j>=0;j--){
				printf("%c",ans[j]);
			}
		}
		else printf("overflow");
		}
		else printf("overflow");
		printf("\n");
		for(j=0;j<1000;j++){
			ans[j]='\0';
			fi[j]='\0';
			se[j]='\0';
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int A = min(a, b);
  int B;
  if (n > a + b) {
    B = 0;
  } else {
    B = a + b - n;
  }

  cout << A << ' ' << B << endl;
  return 0;
}


Measured memory_bytes: 256
import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  var getDecimalPointLength = function(number:any) {
    var numbers = String(number).split('.');
 
    return (numbers[1]) ? numbers[1].length : 0;
  };
  const o = new AtCoder();
  let  aa = BigInt(o.s())
  let  b = o.n()
  let bb = BigInt(String(b).replace('.',''));
  let s = (aa*bb).toString()
  let ans = s.slice(0, s.length-getDecimalPointLength(b))
  o.o(ans == '' ? 0 : ans)
}
m();

Measured memory_bytes: 29652
fun main(arg: Array<String>) {
    val N = nextInt()
    val T = listOfInt().map { it * 2 }
    val V = listOfLong().map { it * 2 }
    val R = T.sum()
    val M = LongArray(R + 1) { 1001001001L }
    M[0] = 0; M[R] = 0
    var m = 0
    for (n in 0 until N) {
        for (t in 0 .. T[n]) M[m + t] = Math.min(M[m + t], V[n])
        m += T[n]
    }
//System.err.println(M.joinToString())
    for (n in 1 .. R) M[n] = Math.min(M[n], M[n - 1] + 1)
    for (n in R - 1 downTo 0) M[n] = Math.min(M[n], M[n + 1] + 1)
//System.err.println(M.joinToString())
    var ans = M.sumByDouble { 0.0 + it } / 4.0
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { Integer.parseInt(it) + d }
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 40684
//2016/11/2

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	int i;
	int n, r[200000] = {0};
	int min, max;

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

	min = r[0];
	max = r[1] - r[0];

	for(i = 1; i < n; i++)
	{
		
		if (max < r[i] - min)
		{
			max = r[i] - min;
		}
		if (min > r[i])
		{
			min = r[i];
		}
	}

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

	return 0;
}

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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = 0;
	if (a + b > 2 * c) {
		int mi = min(x, y);
		x -= mi;
		y -= mi;
		ans += 2 * mi * c;
		if (x > 0 && a > 2 * c) {
			ans += 2 * c * x;
		}
		else if (y > 0 && b > 2 * c) {
			ans += 2 * c * y;
		}
		else {
			ans += a * x + b * y;
		}
	}
	else {
		ans += a * x + b * y;
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 100005
#define PI 3.1415926535897932384626433
#define gcd(a,b) __gcd(a,b)

using namespace std;

ll power(ll x,ll y,ll p)
{
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}



int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);

    ll T=1;
    //cin>>T;
    while(T--)
    {
        ull n;
        cin>>n;
        vector<ull> arr(n);
        forn(i,n) cin>>arr[i];
        forn(i,n) if(arr[i]==0){
        cout<<0;return 0;
        }
        sort(arr.begin(),arr.end());
        ll ans=1;
        forn(i,n){
            if(ans*arr[i]!=(long long int)(1e18) && ans>=ceil(1000000000000000000*1.0/arr[i]*1.0)){
                cout<<-1;
                return 0;
            }
            ans*=arr[i];

        }
        cout<<ans;

    }


    return 0;
}

Measured memory_bytes: 3996
v,e,r = map(int,input().split())
D = [float('inf')]*v
L = []
D[r] = 0
for i in range(e):
    s,t,d = map(int,input().split())
    L.append([s,t,d])
for i in range(v-1):
    update = False
    for j in range(e):
        a,b,c = L[j][0],L[j][1],L[j][2]
        if D[b] > D[a]+c:
            D[b] = D[a]+c
            update = True
    if not update:
        break
for i in range(v):
    if D[i] == float('inf'):
        print('INF')
    else:
        print(D[i])


Measured memory_bytes: 102476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (int i = 1 ; i <= n ; i++) {
        int x;  cin >> x;
        a[x]++;
    }
    bool ok = true;
    if (n & 1) {
        if (a[0] != 1) ok = false;
    }
    for (int i = 1 + (n & 1) ; i <= n ; i += 2){
        if (a[i] != 2) {
            ok = false;
        }
    }
    if (ok){
        ll ans = 1;
        for (int i = 1 ; i <= n / 2 ; i++) ans = ans * 2 % mod;
        cout << ans << endl;
    }else {
        cout << 0 <<endl;
    }
    return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    map<int,int> mp;
    rep(i,N) {
        int a;
        cin >> a;
        ++mp[a];
    }

    int ans = 0;
    for(auto e:mp){
        int f = e.first;
        int s = e.second;
        if(f>s) ans+=s;
        else if(f<s) ans+=(s-f);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

ll g(ll B) {
  ll ans = 0;
  ll k = log2(B) + 1;
  rep(j, k) {
    ll i = j;
    ll temp = 0;
    if (i == 0) {
      if (B % 4 == 1 || B % 4 == 2)
        temp = 1;
    } else {
      if (B % (ll)(pow(2, i + 1)) >= (ll)pow(2, i)) {
        if (B % 2 == 0)
          temp = 1;
      }
    }
    ans += (ll)pow(2, i) * temp;
  }
  return ans;
}

int main() {
  ll A, B;
  cin >> A >> B;

  ll ans = g(B) ^ g(A - 1);

  cout << ans << endl;
}

Measured memory_bytes: 384
from fractions import gcd

n = int(input())
aa = tuple(map(int, input().split()))

gcdl = [0] * n
gcdr = [0] * n

gcdl[0] = aa[0]
for i in range(1, n):
    gcdl[i] = gcd(gcdl[i - 1], aa[i])
gcdr[-1] = aa[-1]
for i in range(n - 2, -1, -1):
    gcdr[i] = gcd(gcdr[i + 1], aa[i])

ans = 1
for i in range(n):
    if i == 0:
        x = gcdr[1]
    elif i == n - 1:
        x = gcdl[n - 2]
    else:
        x = gcd(gcdl[i - 1], gcdr[i + 1])
    ans = max(ans, x)

print(ans)


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

int main() {
    int A, B;
    cin >> A >> B;
    int ans;
    ans = A - 2 * B;
    if (ans <= 0) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

struct Point {
   int x, y;
   Point(int x = 0, int y = 0) :
      x(x), y(y) {}
   bool operator < (const Point &p) const {
      return x < p.x || (x == p.x && y < p.y);
   }
   Point operator + (const Point &p) const {
      return Point(x + p.x, y + p.y);
   }
   Point operator - (const Point &p) const {
      return Point(x - p.x, y - p.y);
   }
   ll operator * (const Point &p) const {
      return (ll) x * p.y - (ll) y * p.x;
   }
   ll norm() {
      return (ll) x * x + (ll) y * y;
   }
};

vector<Point> minkowski(vector<vector<Point>> pss) {
   vector<Point> ans(1, Point());
   vector<Point> go;
   int cnt = 0;
   for (auto &ps : pss) {
      rotate(ps.begin(), min_element(ps.begin(), ps.end()), ps.end());
      ans[0] = ans[0] + ps[0];
      int sz = ps.size();
      for (int i = 0; i < sz; ++i) {
         go.emplace_back(ps[(i + 1) % sz] - ps[i]);
      }
   }
   sort(go.begin(), go.end(), [&](Point p, Point q) {
      bool fp = p < Point();
      bool fq = q < Point();
      if (fp ^ fq) {
         return fq;
      } else {
         return p * q > 0;
      }
   });
   for (auto p : go) {
      ans.emplace_back(ans.back() + p);
   }
   return ans;
}

int main() {
   ios_base::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<vector<Point>> pss;
   while (n--) {
      int x, y;
      cin >> x >> y;
      if (!x && !y) continue;
      pss.emplace_back(vector<Point> {{0, 0}, {x, y}});
   }
   vector<Point> ps = minkowski(pss);
   ll ans = 0;
   for (auto p : ps) {
      // cerr << p.x << " " << p.y << "\n";
      ans = max(ans, p.norm());
   }
   cout << fixed << setprecision(10) << sqrt(ans) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  vector<int> ans(n+1,0);
  rep(i,1,101){
    rep(j,1,101){
      rep(k,1,101){
        int num= i*i+j*j+k*k+i*j+j*k+k*i;
        if(num<=n)ans[num]++;
      }
    }
  }
  rep(i,1,n+1) cout<<ans[i]<<"\n";
  // cout<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3692
#include <iostream>
#include<cstdlib>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int map[8][8];

void bomb(int x, int y) {
	map[x][y] = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 1; j <= 3; j++) {
			int nextX = x + dx[i] * j;
			int nextY = y + dy[i] * j;
			if (0 <= nextX && nextX < 8 && 0 <= nextY && nextY < 8 && map[nextX][nextY]) {
				bomb(nextX, nextY);
			}
		}
	}
}

int main () {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 8; j++) {
			for (int k = 0; k < 8; k++) {
				char c;
				cin >> c;
				map[k][j] = c - '0';
			}
		}
		int x, y;
		cin >> x >> y;
		bomb(x - 1, y - 1);
		cout << "Data " << i + 1 << ":" << endl;
		for (int j = 0; j < 8; j++) {
			for (int k = 0; k < 8; k++) {
				cout << map[k][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
	int a, b, count=0;
	scanf("%d", &a);
	do{
		b = a/10;
		if(a-10*b==1)	count++;
		a = b;
	}while(a>=1);
	
	printf("%d", count);
	
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
D  = [list(map(int, s.split())) for s in open(0)]
bingo = D[0:3]
num = [d[0] for d in D[4:]]
n = []
cases = [
    [(0,0), (0, 1), (0, 2)], 
    [(1,0), (1, 1), (1, 2)], 
    [(2,0), (2, 1), (2, 2)], 
    [(0,0), (1, 0), (2, 0)],
    [(0,1), (1, 1), (2, 1)],  
    [(0,2), (1, 2), (2, 2)],  
    [(0,0), (1, 1), (2, 2)],  
    [(0,2), (1, 1), (2, 0)]]
for i in range(len(bingo)):
    for j in range(len(bingo[i])):
        if bingo[i][j] in num:
            n.append((i, j))
flag = 0
for c in cases:
    f = 0
    for l in c:
        if l in n:
            f += 1
    if f == 3:
        flag += 1
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	vector<ll>V(3,0);
	cin>>V[0]>>V[1]>>V[2];
	if(V[0]%2+V[1]%2+V[2]%2==0||V[0]%2+V[1]%2+V[2]%2==1||V[0]%2+V[1]%2+V[2]%2==2){
		cout<<"0"<<endl;
	}
	else{
		sort(V.begin(),V.end());
		cout<<V[0]*V[1]<<endl;
	}

}

Measured memory_bytes: 888
#include<iostream>

using namespace std;

int main()
{
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
	};

	int k;
	cin >> k;

	cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, m, t, p; cin >> n >> m >> t >> p;
    if (!n) break;
    VV<> a(n, V<>(m, 1));
    while (t--) {
      int d, c; cin >> d >> c;
      if (d == 1) {
        VV<> na(max(c, n - c), V<>(m));
        for (int j = 0; j < m; ++j) {
          for (int i = 0; i < n - c; ++i) na[i][j] += a[c + i][j];
          for (int i = 0; i < c; ++i) na[i][j] += a[c + ~i][j];
        }
        swap(a, na);
        n = a.size();
      } else {
        VV<> na(n, V<>(max(c, m - c)));
        for (int i = 0; i < n; ++i) {
          for (int j = 0; j < m - c; ++j) na[i][j] += a[i][c + j];
          for (int j = 0; j < c; ++j) na[i][j] += a[i][c + ~j];
        }
        swap(a, na);
        m = a[0].size();
      }
    }
    while (p--) {
      int x, y; cin >> x >> y;
      cout << a[x][y] << '\n';
    }
  }
}


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

int main()
{
  int N, T, A, H[1010];
  cin >> N >> T >> A;
  for (int i = 0; i < N; i++)
    cin >> H[i];
  
  double dmin = 1e9, ans = -1;
  for (int i = 0; i < N; i++)
  {
    double t = T - H[i] * 0.006;
  	double d = abs(A - t);
    if (d < dmin)
    {
      dmin = d;
      ans = i;
    }
  }
  cout << (ans + 1) << endl;
}

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

using i64 = long long;

const i64 inf_64 = (i64)1e18;

int main() {
  i64 H, N;
  cin >> H >> N;
  vector<i64> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  vector<i64> dp(H+1, inf_64);

  dp[H] = 0;

  for (int i = H; i > 0; i--) {
    for (int j = 0; j < N; j++) {
      i64 hp = max(i - A[j], (i64)0);
      dp[hp] = min(dp[hp], dp[i] + B[j]);
    }
  }
  cout << dp[0] << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define REP(i,x,n) for (int (i) = x; i < n; i++)
using namespace std;

int n;


int main(void){
    // Your code here!
    cin >> n;
    vector<int> x(n);
    vector<int> origin(n);
    REP(i,0,n) {
        cin >> x[i];
        origin[i] = x[i];
    }
    
    // cout << n - x << endl;
    int mid = n/2;
    sort(x.begin(),x.end());
    int mid1 = x[mid-1];
    int mid2 = x[mid];
    // cout << x[1] << endl;
    REP(i,0,n) {
        if (origin[i] <= mid1) cout << mid2 << endl;
        else cout << mid1 << endl;
    }
    
}


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

using namespace std;

int main()
{
    long long x,y;
    cin>>x>>y;
    bitset <32> a(x),b(y);
    cout<<(a&b)<<endl;
    cout<<(a|b)<<endl;
    cout<<(a^b)<<endl;
}



Measured memory_bytes: 3156
K = int(input())
S =input()

def cmb(n,r,p):
    if(r<0) or (n<r):
        return 0
    return fact[n]*factinv[r]*factinv[n-r]%p

p = 10 ** 9 + 7
N = 2 * 10**6+3
fact = [1] * ( N + 3)
factinv = [1] * (N + 3)
inv = [0]* (N + 3)
inv[1] = 1

for i in range(2,N+1):
    fact[i] = fact[i-1] * i % p
    inv[i] = p-inv[p % i] * (p//i) % p
    factinv[i] = factinv[i-1] * inv[i] % p

def powmod(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n>>=1
    return res

ss = len(S)
ans = 0
k = 1;
for i in range(K+1):
    ans += cmb(ss+K-i-1,ss-1,p) * k * powmod(25,K-i,p)
    ans %= p
    k = k * 26 % p

print(ans)

Measured memory_bytes: 136428
require 'complex'

# Complex * Complex -> Double                                                

def dot(c1, c2)
  (c1.conj * c2).real
end

def cross(c1, c2)
  (c1.conj * c2).imag
end

# Complex * Complex * Complex -> Complex                                     
# return the proj of vector p0p to vector p0p1                               
def proj(p0, p1, p)
  (p1 - p0) * dot(p1 - p0, p - p0) / ((p1 - p0).abs ** 2) + p0
end

# Complex * Complex * Complex -> Complex                                     
def reflect(p0, p1, p)
  t = proj(p0, p1, p)
  p + 2 * (t - p)
end

def main
  xp0, yp0, xp1, yp1 = gets.chomp.split(/\s/).collect { |x| x.to_f}
  q = gets.chomp.to_i
  (1..q).each do |ca|
    p0 = Complex(xp0, yp0)
    p1 = Complex(xp1, yp1)
    x, y = gets.chomp.split(/\s/).collect { |x| x.to_f}
    p = Complex(x, y)
    t = reflect(p0, p1, p)
    puts ("%.9f" % t.real) + " " + ("%.9f" % t.imag)
  end
end

main

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

void check(string s,string t)
{
    LL sl=s.length(),tl=t.length();
    //cout<<sl << " " << tl<<endl<<endl;
    LL res[sl+1][tl+1];

    for(LL i=0;i<=sl;i++)
        for(LL j=0;j<=tl;j++)
                res[i][j]=0;

    for(LL i=1;i<=sl;i++)
    {
        for(LL j=1;j<=tl;j++)
        {

            if(s[i-1]==t[j-1])
            {
                res[i][j]=res[i-1][j-1]+1;
            }
            else
            {
                res[i][j]=max(res[i][j-1],res[i-1][j]);
            }
        }
    }


    LL i=sl,j=tl;
    vector<char> tmp;
    while(i>=0 && j>=1)
    {
            if(s[i-1]==t[j-1]){
                i--;
                j--;
                //cout<<s[i]<<endl;
                tmp.push_back(s[i]);
            }
            else
            {
                if(res[i][j-1]>=res[i-1][j])
                    j--;
                else
                    i--;
            }
    }

    /*for(LL i=0;i<=sl;i++){
        for(LL j=0;j<=tl;j++)
        {
            cout<<res[i][j]<<" ";
        }cout<<endl;
    }*/


    if(tmp.size()==0)
        cout<<"";
    else{
    for( LL i = tmp.size() - 1 ; i >= 0 ; i -- )
        cout<<tmp[i];
    }
}


int main()
{
    string s,t;
    cin>>s>>t;

    if(s==t){
        cout<<s;
        return 0;
    }
    check(s,t);
}



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

int main(){
    char num[5];
    int A, B, C, D;
    int i, j;
    scanf("%s", num);
    A = atoi(&num[0]);
    B = atoi(&num[1]);
    C = atoi(&num[2]);
    D = atoi(&num[3]);
    A = (A - B) / 1000;
    B = (B - C) / 100;
    C = (C - D) / 10;

    if(A + B + C + D ==7) {
        printf("%d+%d+%d+%d=7\n", A, B, C, D);
        return 0;
    }
    if(A + B + C - D ==7) {
        printf("%d+%d+%d-%d=7\n", A, B, C, D);
        return 0;
    }
    if(A + B - C + D ==7) {
        printf("%d+%d-%d+%d=7\n", A, B, C, D);
        return 0;
    }
    if(A + B - C - D ==7) {
        printf("%d+%d-%d-%d=7\n", A, B, C, D);
        return 0;
    }
    if(A - B + C + D ==7) {
        printf("%d-%d+%d+%d=7\n", A, B, C, D);
        return 0;
    }
    if(A - B + C - D ==7) {
        printf("%d-%d+%d-%d=7\n", A, B, C, D);
        return 0;
    }
    if(A - B - C + D ==7) {
        printf("%d-%d-%d+%d=7\n", A, B, C, D);
        return 0;
    }
    if(A - B - C - D ==7) {
        printf("%d-%d-%d-%d=7\n", A, B, C, D);
        return 0;
    }
    return 0;
}

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

template <typename T>
class SparseTable {
	const int n, h;
	vector<vector<T>> t;
public:
	SparseTable(const vector<T>& b)
		: n(b.size()), h(31 - __builtin_clz(n)), t(h + 1, vector<T>(b.size())) {
		t[0] = b;
		for (int i = 0; i < h; i++)
			for (int k = 0; k + (1 << i) < n; k++)
				t[i + 1][k] = min(t[i][k], t[i][k + (1 << i)]);
	}
	T find(int l, int r) {
		int b = 31 - __builtin_clz(r - l);
		return min(t[b][l], t[b][r - (1 << b)]);
	}
};

class LCA {
	using pii = pair<int, int>;
	vector<int> depth, id;
	SparseTable<pii> st;
	void dfs(int v, int prev, const graph& G, vector<pii>& res) {
		depth[v] = prev != -1 ? depth[prev] + 1 : 0;
		id[v] = res.size();
		res.emplace_back(depth[v], v);
		for (auto to : G[v]) if (to != prev) {
			dfs(to, v, G, res);
			res.emplace_back(depth[v], v);
		}
	}
	vector<pii> init(const graph& G, int rt) {
		vector<pii> res;
		res.reserve(G.size() * 2 - 1);
		dfs(rt, -1, G, res);
		return res;
	}
public:
	LCA(const graph& G, int rt = 0) : depth(G.size()), id(G.size()), st(init(G, rt)) {}
	int calc(int a, int b) {
		if (id[a] > id[b]) swap(a, b);
		return st.find(id[a], id[b] + 1).second;
	}
	int dist(int a, int b) {
		return depth[a] + depth[b] - depth[calc(a, b)] * 2;
	}
};

template <typename T>
class FenwickTree {
	const int n;
	vector<T> data;
public:
	FenwickTree(int n_) : n(n_), data(n) {}
	T find(int p) const {
		T res = 0;
		while (p >= 0) {
			res += data[p];
			p = (p & (p + 1)) - 1;
		}
		return res;
	}
	void add(int p, T val) {
		while (p < n) {
			data[p] += val;
			p |= p + 1;
		}
	}
};

template <typename T>
class RARS {
	const int n;
	FenwickTree<T> bit0, bit1;
public:
	RARS(int n_) : n(n_), bit0(n), bit1(n) {}
	T find(int p) const {
		return bit1.find(p) * (p + 1) + bit0.find(p);
	}
	T find(int l, int r) const {
		return find(r - 1) - find(l - 1);
	}
	void add(int l, int r, T val) {
		bit0.add(l, -val * l);
		bit1.add(l, val);
		bit0.add(r, val * r);
		bit1.add(r, -val);
	}
};

const int MAX = 150000;

int acnt, scnt;
int la[MAX], ra[MAX], ls[MAX], rs[MAX];

void euler_tour(int v, int prev, const graph& G) {
	la[v] = acnt;
	ls[v] = scnt;
	for (auto to : G[v]) if (to != prev) {
		acnt++;
		euler_tour(to, v, G);
		scnt++;
	}
	ra[v] = acnt;
	rs[v] = scnt;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	cin >> N >> Q;
	graph G(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	euler_tour(0, -1, G);
	LCA lca(G, 0);
	RARS<ll> add(N - 1), sub(N - 1);
	while (Q--) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) {
			int p = lca.calc(u, v);
			printf("%lld\n", (add.find(la[p], la[u]) + sub.find(ls[p], ls[u])) + (add.find(la[p], la[v]) + sub.find(ls[p], ls[v])));
		}
		else {
			add.add(la[u], ra[u], v);
			sub.add(ls[u], rs[u], -v);
		}
	}
	return 0;
}


Measured memory_bytes: 73036
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

tensu = {
    'r': R,
    's': S,
    'p': P
}

win = {
    'r': 'p',
    's': 'r',
    'p': 's'
}

ans = [None] * N

sum_ = 0
for i, t in enumerate(T):
    if i < K or ans[i - K] != win[t]:
        ans[i] = win[t]
        sum_ += tensu[ans[i]]

print(sum_)


Measured memory_bytes: 4084
import java.util.*;

public class Main {    
    public static void main(String[] args){
        
           Scanner sc = new Scanner(System.in);          
           
           int N = sc.nextInt();
           
           int y = N/15;
                              
           System.out.println(800*N - y*200);
                
    }            
}
        
        
        

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long INF=1e18,MOD=1e9+7;
int main(){
    vector<int>a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<a[0]+a[1]<<endl;

	
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string t; cin >> t;
  set<char> chars;
  rep(i,t.size()) chars.insert(t[i]);
  if (chars.size()==1){
    cout << 0 << endl;
    return 0;
  }
  
  int retval = 1000;
  for (char c : chars){
    int cnt = 0;
    string tt = t;
    rep(j,t.size()){
      
      rep(i,tt.size()-1){
        char ap;
        if (tt[i]==c || tt[i+1]==c) tt[i] = c;
        else tt[i] = t[i];
      }
      tt.erase(tt.size()-1);
      cnt++;
      bool all_same = true;
      rep(i,tt.size()) if (tt[i]!=tt[0]) all_same = false;
      if (all_same) break;

            
    }

    retval = min(retval, cnt);
  }
  cout << retval << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}



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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const int MAX = 111;
char cbuf[MAX];
inline string next() {scanf("%s", cbuf); return cbuf;}
string a[MAX], b[MAX], ganma, delta;

bool solve() {
  int n;
  scanf("%d", &n);
  if (n == 0) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    a[i] = next();
    b[i] = next();
  }
  ganma = next();
  delta = next();
  queue<pair<string, int>> q;
  q.push(make_pair(ganma, 0));
  int ans = -1;
  while (!q.empty()) {
    string now;
    int cnt;
    tie(now, cnt) = q.front();
    q.pop();
    if (now == delta) {
      ans = cnt;
      break;
    }
    for (int i = 0; i < n; i++) {
      string next = "";
      for (int j = 0; j < now.length(); j++) {
        if (now.substr(j, a[i].length()) == a[i]) {
          next += b[i];
          j += a[i].length() - 1;
        } else {
          next += now[j];
        }
      }
      if (now != next && next.length() <= delta.length()) {
        q.push(make_pair(next, cnt + 1));
      }
    }
  }
  printf("%d\n", ans);
  return true;
}

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

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

int main(){
  int N,K,A,count=0;
  cin>>N>>K;
  vector<int> m(K);
  vector<int> n(N);
  
  for(int i=0; i<K; i++){
    cin>>m.at(i);
    for(int j=0; j<m.at(i); j++){
      cin>>A;
      n.at(A-1)++;
    }
  }
  for(int i=0; i<N; i++){
    if(n.at(i)==0){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3612
a,b = gets.split.map {|x| x.to_i}

def f(v)
  if v % 4 == 0
    return v
  elsif v % 4 == 1
    return 1
  elsif v % 4 == 2
    return 1 + v
  else
    return 0
  end
end

if a == 0
  puts f(b)
else
  puts f(b) ^ f(a-1)
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>

#define SQ(X) ((X)*(X))

typedef struct{
    char name[8];
    int r,g,b;
} Color;

double getDist2(Color col1, Color col2);
void GetCol(Color *cp, char *st);
int getHex(char c);

int main(){
    Color col[8];
    Color inCol;
    double dist2;
    int nearest, nearestId;
    char buf[16];
    
    // init color table
    col[0].r=0x00; col[0].g=0x00; col[0].b=0x00; strcpy(col[0].name, "black");
    col[1].r=0x00; col[1].g=0x00; col[1].b=0xff; strcpy(col[1].name, "blue");
    col[2].r=0x00; col[2].g=0xff; col[2].b=0x00; strcpy(col[2].name, "lime");
    col[3].r=0x00; col[3].g=0xff; col[3].b=0xff; strcpy(col[3].name, "aqua");
    col[4].r=0xff; col[4].g=0x00; col[4].b=0x00; strcpy(col[4].name, "red");
    col[5].r=0xff; col[5].g=0x00; col[5].b=0xff; strcpy(col[5].name, "fuchsia");
    col[6].r=0xff; col[6].g=0xff; col[6].b=0x00; strcpy(col[6].name, "yellow");
    col[7].r=0xff; col[7].g=0xff; col[7].b=0xff; strcpy(col[7].name, "white");
    
    while (scanf("%s",buf), buf[0]!='0'){
        GetCol(&inCol, buf);
        nearest = 65536*4;
        for (int i=0; i<8; i++){
            dist2 = getDist2(col[i], inCol);
            if (dist2 < nearest) nearest=dist2, nearestId=i;
        }
        printf("%s\n", col[nearestId].name);
    }    
    return 0;
}

double getDist2(Color col1, Color col2){
    return SQ(col1.r-col2.r)+SQ(col1.g-col2.g)+SQ(col1.b-col2.b);
}

void GetCol(Color *cp, char *st){
    cp->r = getHex(st[1])*0x10 + getHex(st[2]);
    cp->g = getHex(st[3])*0x10 + getHex(st[4]);
    cp->b = getHex(st[5])*0x10 + getHex(st[6]);
}

int getHex(char c){
    if ('0'<=c && c<='9') return c-'0';
    else return c-'a'+10;
}

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

int main() {
  int n;
  cin >> n;
  
  int count=0;
  int b=n;
  
  while (b>0) {
    count+=b%10;
    b/=10;
  }
  
  if (n%count == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}


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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;



int main()
{
    int N, tmp_A = 0, tmp_B = 0;
    cin >> N;
    vector <int> P(N), Q(N), X(N+1), tmp(N+1, 0), tmp2(N+1, 0);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    X[1] = 1;
    for (int i = 2; i <= N; i++) {
        X[i] = i * X[i-1];
    }

    for (int i = 0; i < N; i++) {
        int k = 0;
        for (int j = 1; j < P[i]; j++) {
            k += tmp[j];
        }
        tmp[P[i]]++;
        tmp_A += (P[i] - k - 1) * X[N-i-1];
    }

    for (int i = 0; i < N; i++) {
        int k = 0;
        for (int j = 1; j < Q[i]; j++) {
            k += tmp2[j];
        }
        tmp2[Q[i]]++;
        tmp_B += (Q[i]- k - 1) * X[N-i-1];
    }
    cout << abs(tmp_A - tmp_B) << endl;

    return 0;
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N; cin >>N;
    ll A, B;
    int ans = INT_MAX;

    for (A = 1; A*A <= N; A++) {
        if (N%A==0) {
            B = N/A;
            int n = 1;
            while((B/=10)) n++;
            chmin(ans, n);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int N;
    cin >> N;
    set<string> keihin;
    for (int i=0; i<N; i++) {
        string s;
        cin >> s;
        keihin.insert(s);
    }
    cout << keihin.size() << endl;
}

Measured memory_bytes: 19100
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  ll ans = 0, h = 0;

  ll sum = 0;
  REP(i, n) {
    int a;
    cin >> a;
    if(a > 0) sum += a;
    else ans += sum / 2, sum = 0;
  }
  ans += sum / 2;

  cout << ans << endl;
}


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

int main(void)
{
  int m,n;
  int all=0;
  int cnt=0;
  int a[1000];
  
  cin >> n >> m;
  for(int i=0; i<n; i++){
    cin >> a[i];
    all += a[i];
  }
  
  
  for(int i=0; i<n; i++){
    if(a[i] >= ((double)all/(4*m))){
      cnt += 1;
    }
  }
  
  if(cnt >= m){
  	cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    ll A, B;
    cin >> A >> B;

    ll ans;
    if (A >= 13) ans = B;
    else if (A >= 6) ans = B/2;
    else ans = 0;

    cout << ans << "\n";
}

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

#include <iomanip>

int main() {
    const double pi = 3.14159265358979323846;
    double r;
    cin >> r;
    cout << fixed << setprecision(6) << r*r*pi << " " << 2*pi*r << endl;

    return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int n,m;
    cin >> n >> m;
    int x,y;
    cin >> x >> y;
    
    vector<int> xi(n);
    for (int i = 0; i < n; i++) {
        cin >> xi[i];
    }
    vector<int> yi(m);
    for (int i = 0; i < m; i++) {
        cin >> yi[i];
    }

    SORT(xi);
    SORT(yi);
    
    if(x < yi[0] && yi[0] < y && xi[xi.size()-1] < yi[0]){
        pr("No War");
    }else{
        pr("War");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  string s;
  cin>>s;
  cout<<(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]?"Bad":"Good");}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $sum = array_sum($a);
  $min = PHP_INT_MAX;
  $sunk = 0;
  for($i=0; $i<$n-1; $i++){
      $sum -= $a[$i];
      $sunk += $a[$i];
      $min = min($min, abs($sum-$sunk));
  }
  echo $min;
  

Measured memory_bytes: 20980
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

//解説参考.
int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	sort(ALL(a),greater<int>());
	
	llong ans=0;
	REP(i,n){
		if(i==0){}
		else ans+=a[i/2];
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int ans = X;
    REP(i, N){
        for(int x=0; x*A[i]+1 <= D; x++){
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int A, B, ans = 0;

main()
{
    cin >> A >> B;
    for (int i = A; i <= B; i++) {
        string s = to_string(i);
        string s_r = s;
        reverse(s_r.begin(), s_r.end());
        if (s == s_r) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

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

	if(a<3200){
		cout << "red" << endl;
	}else{
		cout << s << endl;
	}
}

Measured memory_bytes: 256
// In the name the Allah the Most Merciful.

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

typedef long long ll;

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    ll a, b , c , ans = 0;
    cin >> a >> b >> c;

    ll temp = min(b , c);

    ans+=2*temp;
    b-=temp;
    c-=temp;

    ans+=b;

    temp = min(a , c);
    ans+=temp;
    c-=temp;
    a-=temp;

    if(c>0)ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
class Graph():  #non-directed
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.edge = edge
        self.indexed = indexed
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.graph[e[1] - indexed].append((e[0] - indexed, e[2]))

    def kruskal(self):  #UnionFind
        edgemap = {self.edge[i]: i for i in range(len(self.edge))}
        sortedge = sorted(self.edge, key=lambda x: x[2])
        #sortedge = reversed(sortedge) コストの最大化
        uf = UnionFind(self.n)
        res = 0
        restored = []
        for e in sortedge:
            if uf.find(e[0] - self.indexed) != uf.find(e[1] - self.indexed):
                res += e[2]
                restored.append(edgemap[e])
                uf.unite(e[0] - self.indexed, e[1] - self.indexed)
        return res, restored

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root

    def unite(self, x, y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot: return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
            self.size[yroot] += self.size[xroot]
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
            self.size[xroot] += self.size[yroot]
        else:
            self.parents[yroot] = xroot
            self.size[xroot] += self.size[yroot]

import sys
input = sys.stdin.readline

N = int(input())
T = []

for i in range(N):
    x, y = map(int, input().split())
    T.append((x, y, i))

sort_by_x = sorted(T, key=lambda x: x[0])
sort_by_y = sorted(T, key=lambda x: x[1])

E = []

for i in range(N - 1):
    x1, y1, id1 = sort_by_x[i]
    x2, y2 ,id2 = sort_by_x[i + 1]
    E.append((id1, id2, min(abs(x1 - x2), abs(y1 - y2))))
    x1, y1, id1 = sort_by_y[i]
    x2, y2 ,id2 = sort_by_y[i + 1]
    E.append((id1, id2, min(abs(x1 - x2), abs(y1 - y2))))

g = Graph(N, E)

print(g.kruskal()[0])

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int digit = N % 10;
    switch(digit) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        printf("hon\n");
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        printf("pon\n");
        break;
        case 3:
        printf("bon\n");
        break;
    }

    return 0;
}


Measured memory_bytes: 3656