akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    while(n--){
        string s;
        cin >> s;
        ++m[s];
    }
    cout << "AC x " << m["AC"] << "\n";
    cout << "WA x " << m["WA"] << "\n";
    cout << "TLE x " << m["TLE"] << "\n";
    cout << "RE x " << m["RE"];
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        long N = sc.nextInt();
                        long minv = 100000001L, maxv = -1000000000L, sumv = 0;
                        for (int i = 0; i < N; i++) {
                                long x = sc.nextInt();
                                minv = Math.min(x, minv);
                                maxv = Math.max(x, maxv);
                                sumv += x;
                        }
                        System.out.println(minv + " " + maxv + " " + sumv);
                }
        }
}

Measured memory_bytes: 41344
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		double debt = 100000;
		for (int i = 0; i < n; i++) {
			debt += debt / 20;
			double r = debt % 1000;
			int v = (int)debt / 1000;
			debt = 1000 * v ;
			debt = r>0?debt+1000:debt;
		}
		System.out.println((int)debt);
	}
}



Measured memory_bytes: 25908
#include <stdio.h>
int main(void){
   int h, w, i, j;
   
   while(1){
       scanf("%d %d",&h,&w);
       if(h == 0 && w == 0){
           break;
       }
       for(i = 0; i < h; i++){
           for(j = 0; j < w; j++){
               if(j % 2 == 1){
                   if(i % 2 == 1){
                       printf("#");
                   }
                   else{
                       printf(".");
                   }
               }else{
                   if(i % 2 == 1){
                       printf(".");
                   }
                   else{
                       printf("#");
                   }
               }
           }printf("\n");
       }printf("\n");
   }return 0;
}


Measured memory_bytes: 2084
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void solve(int A, int B) {
  if (A == B) {
    printf("0\n");
  } else if ((A + B) % 2 == 0) {
    printf("%d\n", (A + B) / 2);
  } else {
    printf("IMPOSSIBLE\n");
  }
}

int main() {
  int A, B;
  cin >> A >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 888
from operator import add
from functools import reduce

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(input())
for i in range(N - K):
    s1 = T[i]
    s2 = T[i + K]
    if s1 == s2:
        T[i + K] = "0"
score = T.count("r") * P + T.count("s") * R + T.count("p") * S
print(score)


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

int main(void) {
	char s[51] = { 0 };
	int len;

	scanf("%s", &s);
	len = strlen(s);

	for (int i = 0; i < len - 8; i++) {
		printf("%c", s[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <math.h>

using namespace std;
typedef long long LL;
const int maxn = 505;

int cnt[maxn],p[maxn],n,m,deg[maxn],usd[maxn];
int findp(int u) {return p[u]?p[u]=findp(p[u]):u;}
void no() {puts("NO");exit(0);}
int main()
{
	#ifdef Amberframe
		freopen("agc017e.in","r",stdin);
		freopen("agc017e.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);m=m<<1|1;
	for (int x,y,a,b,c,d,i=1;i<=n;i++) {
		scanf("%d %d %d %d",&a,&b,&c,&d);
		c!=0?x=c<<1|1:x=a<<1;
		d!=0?y=d<<1:y=b<<1|1;
		deg[x]++;deg[y]--;usd[x]=usd[y]=1;
		x=findp(x);y=findp(y);x!=y?p[x]=y:0;
	}
	for (int i=1;i<=m;i++)
	if (deg[i]) {
		if (deg[i]>0&&(i&1)) no();
		if (deg[i]<0&&!(i&1)) no();
	}
	for (int i=1;i<=m;i++)
		if (deg[i]>0) cnt[findp(i)]++;
	for (int i=1;i<=m;i++)
		if (usd[i]&&!p[i]&&!cnt[i]) no();
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.3"

int main() {
  int R, G, B, N;
  int r, g, b, n, nn, m;

#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif

  cin >> R >> G >> B >> N;

  m = 0;
  for (r = 0; r <= N / R; r++) {
    n = N - r * R;
    for (g = 0; g <= N / G; g++) {
      nn = n - g * G;
      if (nn < 0) continue;
      if (nn == 0) {
        // cout << r << ' ' << g << ' ' << b << endl;
        m++;
        continue;
      }
      if (nn % B != 0)
        continue;
      else {
        // cout << r << ' ' << g << ' ' << b << endl;
        m++;
      }
    }
  }
  cout << m << endl;
  return 0;
}

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

signed main () {
    string s;
    cin >> s;
    int n = s.size();
    int64_t sum = 0;
    for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
        int64_t here = 0, last = int64_t(s[0] - '0');
        for (int i = 0; i < n - 1; ++i) {
            if (mask & (1 << i)) {
                here += last;
                last = int64_t(s[i + 1] - '0');
            }
            else {
                last *= 10;
                last += int64_t(s[i + 1] - '0');
            }
        }
        if (last)
            here += last;
        sum += here;
    }
    cout << sum << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll N, M;
string s;

ll check(){
    ll ok = 0;
    for(ll i = 0; i <= N; i++){
        if(s[i] == '1')continue;
        if(ok < i)return 1;
        chmax(ok, i + M);
    }
    return 0;
}


ll step[101010];
ll calc_step(){
    rep(i, 101010)step[i] = INF;
    step[0] = 0;
    ll done = 0;
    for(ll i = 0; i <= N; i++){
        if(s[i] == '1')continue;
        for(;done + 1 <= N && done + 1 <= i + M; done++)chmin(step[done + 1], step[i] + 1);
    }
    return step[N];
}

ll rv[101010];
void solve(){
    rep(i, 101010)rv[i] = INF;
    rv[N] = 0;
    ll done = N;
    for(ll i = N; i >= 0; i--){
        if(s[i] == '1')continue;
        for(;done - 1 >= 0 && done - 1 >= i - M; done--)chmin(rv[done - 1], rv[i] + 1);
    }
    // for(ll i = 0; i <= N; i++)cout << rv[i];
    // cout << endl;
    ll lst = 0;
    queue<ll>ans;
    for(ll i = 0; i <= N; i++){
        if(s[i] == '1')continue;
        if(rv[i] != rv[lst]){
            ans.push(i - lst);
            lst = i;
        }
    }
    while(!ans.empty()){
        ll x = ans.front();
        ans.pop();
        cout << x;
        if(!ans.empty())cout << " ";
        else cout << endl;
    }
}

int main(){

    cin >> N >> M;
    cin >> s;
    if(check()){
        cout << -1 << endl;
        return 0;
    }
    calc_step();
    solve();

    return 0;
}

Measured memory_bytes: 2944
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var pi = new long[N];
            for (var i = 0; i < N; ++i)
                pi[i] = Sarray()[0];
            WriteLine(pi.Sum() - pi.Max() + pi.Max() / 2);
        }

        static long Mod = (long)1e9 + 7;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28240
N,M = map(int,input().split())
INF = 10**13
edge = []
for i in range(M):
	a,b,c = map(int,input().split())
	a -= 1
	b -= 1
	edge.append((a, b, -c))

dist = [INF for i in range(N)]
dist[0] = 0

neg_cycle = False
for i in range(N+1):
	update = False
	N_update = False
	for (a,b,c) in edge:
		if dist[a] == INF:
			continue

		if dist[a] + c < dist[b]:
			dist[b] = dist[a] + c
			update = True
			if b == N-1:
				N_update = True

	if not update:
		break
	if i >= N - 1 and N_update:
		neg_cycle = True

if neg_cycle:
	print("inf")
else:
	print(-dist[N-1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){

  int amo,tmp,n;

  cin>>n;
  int a[100]={0};
  cin>>amo;
  for(int i=0;i<amo;i++){
    cin>>tmp;
    a[tmp-1]=2;
  }
  cin>>amo;
  for(int i=0;i<amo;i++){
    cin>>tmp;
    if(a[tmp-1]==2) a[tmp-1]=1;
  }
  cin>>amo;
  int result=0;
  for(int i=0;i<amo;i++){
    cin>>tmp;
    if(a[tmp-1]!=2) result++;
  }

  cout<<result<<endl;
  
  return 0;
}

Measured memory_bytes: 3100
//
//  main.cpp

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int TARO = 0;
const int HANAKO = 1;
vector<int> card[2];
int n;
int now=-1;
int turn = TARO;
//int hanakopoint,taropoint;

void search(){
	int Min = 10000;
	for(int i=0;i<card[turn].size();i++){
		if(now < card[turn][i]){
			Min = min(card[turn][i],Min);
		}
	}
	
	if(Min == 10000){
		now = -1;
	}else{
		now = Min;
		for(int i=0;i<card[turn].size();i++){
			if(card[turn][i] == now){
				card[turn].erase(card[turn].begin() + i);
				break;
			}
		}
	}
}

int main(){	
	while(1){
		bool check[201];
		
		for(int i=0;i<201;i++){
			check[i] = true;
		}
		card[TARO].clear();
		card[HANAKO].clear();

		cin >> n;
		if(n==0)break;
		int input;
		for(int i=0;i<n;i++){
			cin >> input;
			card[TARO].push_back(input);
			check[input] = false;
		}
		for(int i=1;i<=2*n;i++){
			if(check[i]){
				card[HANAKO].push_back(i);
			}
		}
		
		sort(card[TARO].begin(),card[TARO].end());
		sort(card[HANAKO].begin(),card[HANAKO].end());
		now = -1;
		turn = TARO;
		
		while(card[TARO].size() != 0 && card[HANAKO].size() != 0){
			search();
			if(turn){
				turn = TARO;
			}else{
				turn = HANAKO;
			}
		}
		cout << card[HANAKO].size() << endl << card[TARO].size() << endl;//????????????
	}
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define MAX 10000000000
#define rep(i,n) for(int i = 0; i < n;i++)
ll v, n, e, k, ans = 0,sum,d[50];
int main(void) {
	int n, p[50];cin >> n;
	rep(i, n) {
		cin >> p[i];
		d[i] = p[i];
	}
	sort(p, p + n);
	rep(i, n) {
		if (p[i] != d[i]) {
			ans++;
		}
	}
	if (ans > 2) cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/09/07
//ms,
/*
*/

int main(void){
  int64_t x;
  cin >>x;
  vector<pair<int, int>> factor;
  int64_t ans_a, ans_b;

  for(int i=1;i*i<=x;i++){
    if(x%i==0) factor.push_back({i, x/i});
  }

  for(pair p:factor){
    int64_t A=p.first;
    int64_t B=p.second;
    for(long int i=0;i*i<=4*x;i++){
      int64_t a=i;
      int64_t b=i-A;
      if(a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b==B) {
        ans_a=a;
        ans_b=b;
        goto OUT;
      }
    }
  }

  OUT:cout <<ans_a <<" " <<ans_b <<endl;
  return 0;
}
/*
Aだけは正の数に固定していい。というのも
A<0, B>0 then x<0
A<0, B<0 then A=absB, B=absAでいい。
全探索しようにも範囲がわからない。グラフへの置き換えも多分悪手。

これは整数問題だ。
因数分解したら場合の数を削減できる。
さらにaの上側の制約を見つけたら、探索ができる。bはaとAが決まれば決まる。
aの上側の制約だけど、2Aより大きいとどう考えてもアウト。そこまで試せばいい。
*/


Measured memory_bytes: 3604
number = gets.to_i
line = gets.chomp.split(" ").map(&:to_i)
linear = []
for i in 0..number - 1
  linear[i] = line[i] - i - 1
end
result = linear.sort
inst = 0
i = number / 2
if number % 2 == 0
  inst = result[i] + result[i - 1]
  inst /= 2
else
  inst = result[i]
end
answer = 0
for i in 0..number - 1
  answer += (line[i] - inst - i - 1).abs
end

print answer


Measured memory_bytes: 22664
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	var total int

	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}

	for i := 0; i < n - 1; i++ {
		for j := i + 1; j < n; j++ {
			total += d[i] * d[j]
		}
	}

	fmt.Println(total)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll x,y;
    cin >> x >> y;
    ll ans;
    if(x >= 0) {
        if(y > 0) {
            if(y >= x) ans = y - x;
            else ans = y + x;
        } else {
            if(y >= -x) ans = y+x+1;
            else ans += -y-x+1; 
        }
    } else {
        if(y > 0) {
            if(y >= -x) ans = y+x+1;
            else ans = -y-x+1;
        } else {
            if(y >= x) ans = -x+y;
            else ans = 1 + -y+x + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int n,count=0;
  ll a[200000],ans[2]={0,0};
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n,greater<ll>());
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      ans[count]=a[i];
      count++;
      i++;
    }
  }
  if(ans[1]==0) cout<<0<<endl;
  else cout<<ans[0]*ans[1]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if ((a == c) && (c != b)) {
        cout << "Yes" << endl;
    }else if((a == b) && (b != c)){
        cout << "Yes" << endl;
    }else if((b == c) && (c != a)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>

using namespace std;
using namespace boost::multiprecision;

void solve() {
	int N;
	cin >> N;
	cout << (N >= 1000 ? "ABD" : "ABC") << endl;
	return;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}

fn dfs(i: i32, nums: &Vec<i32>, sum: i32, opes: &mut Vec<String>) -> bool {
  if i == nums.len() as i32{
    if sum == 7 {
      println!("{}{}{}{}{}{}{}=7", nums[0], opes[1], nums[1], opes[2], nums[2], opes[3], nums[3]);
      return true;
    } else {
      return false;
    }
  }
  opes[i as usize] = String::from("+");
  if dfs(i+1, nums, sum + nums[i as usize], opes){
    return true;
  }
  opes[i as usize] = String::from("-");
  if dfs(i+1, nums, sum - nums[i as usize], opes) {
    return true;
  }
  return false;
}

fn main() {
  let s: String = input();
  let mut nums: Vec<i32> = Vec::new();
  for c in s.chars() {
    nums.push(c as i32 - 48);
  }

  dfs(1, &nums, nums[0], &mut vec![String::from(""); 4]);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  ll n, sum = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll half = sum;
  rep(i, n) {
    half -= a[i];
    if (sum / 2 >= half) {
      cout << min(sum - 2 * half, abs(sum - (half + a[i]) * 2)) << endl;
      return 0;
    }
  }
  return 0;
}

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

int n, ans;

int max_n(double t){
    if(t < 5) return t;
    t = sqrt(t);
    return t;
}
int main(){
    cin >> n;
    rep2(i, 1, n+1){
        double mn = max_n(i);

        ans = 0;
        rep2(x, 1, mn) rep2(y, x, mn) rep2(z, y, mn){
            if(x*x + y*y + z*z + x*y + y*z + z*x == i){
                if(x != y && y != z) ans += 6;
                else if(x == y && y == z) ans += 1;
                else ans += 3;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3608
<?php

fscanf(STDIN, '%s', $s);

$array = str_split($s);

$ans = 0;
$count = 0;
foreach ($array as $char) {
    if (in_array($char, ['A', 'C', 'G', 'T'])) {
        $count++;
        if ($ans < $count) {
            $ans = $count;
        }
    } else {
        $count = 0;
    }
}

echo $ans . PHP_EOL;

Measured memory_bytes: 4732
import sys


def gcd(a, b):
    """Euclidean Algorithm"""
    a, b = max(a, b), min(a, b)
    while b != 0:
        a, b = b, a % b
    return a


def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    L = [0 for _ in range(N+1)]
    for i in range(1, N+1):
        L[i] = gcd(L[i-1], A[i-1])

    R = [0 for _ in range(N+1)]
    for i in range(N-1, -1, -1):
        R[i] = gcd(R[i+1], A[i])

    M = [0 for _ in range(N)]
    for i in range(N):
        M[i] = gcd(L[i], R[i+1])

    return max(M)


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


Measured memory_bytes: 14256
#include<iostream>
#include<algorithm>
using namespace std;
int l[50];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	  cin>>l[i];
	sort(l,l+n,greater<int>());
	int ans=0;
	for(int i=0;i<k;i++)
	  ans+=l[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string s;
    if(sx==tx && sy==ty){
        cout<<"";
        return 0;
    }
    for(int i=0;i<abs(sx-tx);i++){
        s.push_back('R');
    }
    for(int i=0;i<abs(sy-ty);i++){
        s.push_back('U');
    }
    for(int i=0;i<abs(sx-tx);i++){
        s.push_back('L');
    }
    for(int i=0;i<abs(sy-ty);i++){
        s.push_back('D');
    }
    s.push_back('D');
    for(int i=0;i<abs(sx-tx)+1;i++){
        s.push_back('R');
    }
    for(int i=0;i<abs(sy-ty)+1;i++){
        s.push_back('U');
    }
    s.push_back('L');
    s.push_back('U');
    for(int i=0;i<abs(sx-tx)+1;i++){
        s.push_back('L');
    }
    for(int i=0;i<abs(sy-ty)+1;i++){
        s.push_back('D');
    }
    s.push_back('R');
    // for(int i=0;i<abs(sx-t))
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
//sort(y,y+j, greater<int>());
ll x[1000000];
int main()
{
    ll a,b,c,d,e,i,j,mul,xx,yy,k;
    char s[10000];
    in>>a>>b>>c;
    if((b*c)>=a)
    {
        out<<"Yes"<<nl;
    }
    else
    {
        out<<"No"<<nl;
    }
    
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from collections import Counter
import math

def main():
    N = int(input())
    A = [int(a) - i for i, a in enumerate(input().split(), 1)]
    A.sort()

    b = A[N//2]
    print(sum(abs(a - b) for a in A))

    
main()

Measured memory_bytes: 26756
#include <bits/stdc++.h>
#define MAX 1007
#define INF 100000007

using namespace std;

typedef pair<int,int> di;
typedef pair<int, di> pii;

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 main(){
    int n; cin >> n;
    cout << a[n-1] << endl;
    return 0;
}

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

all_set = set(list(range(1, n+1)))
food_set = set()
for _ in range(k):
    t = input()
    lst = list(map(int, input().split()))
    for num in lst:
        food_set.add(num)
print(len(all_set - food_set))

Measured memory_bytes: 9164
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut br = BufReader::new(std_in.lock());
    let mut bw = BufWriter::new(std_out.lock());
    
    let tmp = rvn::<usize>(&mut br);
    let (n, d) = (tmp[0], tmp[1]);
    let mut ps = Vec::new();
    for _ in 0..n {
        ps.push(rvn::<i32>(&mut br));
    }
    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n {
            let mut sq = 0;
            for k in 0..d {
                sq += (ps[i][k] - ps[j][k]) * (ps[i][k] - ps[j][k]);
            }
            for k in 1..401 {
                if k * k == sq {
                    ans += 1;
                }
            }
        }
    }
    writeln!(&mut bw, "{}", ans);
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
print(n * 800 - n // 15 * 200)

Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double lb;
typedef unsigned int ui;
typedef unsigned long ul;
typedef pair<int,int> pi;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int>> pqq;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

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

int n;
cin>>n;

int temp=n%10;

if(temp==3) cout<<"bon";
else if(temp==0 || temp==1 || temp==6 || temp==8) cout<<"pon";
else cout<<"hon";

}
 
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/


Measured memory_bytes: 3592
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = [int(s) for s in input().split()]
A.sort(reverse = True)

dp = [0]*(N+1);
MIN = -10**9
for i in range(1, N+1):
    mx = MIN
    for a in A:
        k = i-num[a]
        if k >= 0:
            mx = max(mx, dp[k] + 1)
    dp[i] = mx

d = dp[N]
n = N
s = []
for i in range(0, d):
    for a in A:
        tmp = n-num[a]
        if tmp >= 0 and dp[tmp] == dp[n]-1:
            s.append(str(a))
            n -= num[a]
            break
print("".join(s))

Measured memory_bytes: 3696
package main

import (
	"fmt"
	"sort"
)

const (
	mod = int64(1000000007)
)

var (
	n    int
	k    int
	a    []int
	f    []int64
	finv []int64
	inv  []int64
)

func prepare() {
	f = make([]int64, n+1)
	finv = make([]int64, n+1)
	inv = make([]int64, n+1)
	f[0] = 1
	finv[0] = 1
	inv[1] = 1
	for i := 2; i <= n; i++ {
		inv[i] = (mod - mod/int64(i)) * inv[mod%int64(i)] % mod
	}
	for i := 1; i <= n; i++ {
		f[i] = int64(i) * f[i-1] % mod
	}
	for i := 1; i <= n; i++ {
		finv[i] = inv[i] * finv[i-1] % mod
	}
}

func comb(n, m int) int64 {
	if n < 0 || n < m {
		return 0
	}
	return f[n] * finv[m] % mod * finv[n-m] % mod
}

func main() {
	fmt.Scanln(&n, &k)
	prepare()
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	sort.Ints(a)
	ans := int64(0)
	for i := k - 1; i < n; i++ {
		ans += int64(a[i]) * comb(i, k-1)
		ans %= mod
	}
	for i := 0; i+k <= n; i++ {
		ans -= int64(a[i]) * comb(n-i-1, k-1)
		ans %= mod
	}
	if(ans < 0) {
		ans += mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}
int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;

int main() {
    IOS;
    int a, b, c, k;

    cin >> a >> b >> c >> k;
    int sum=a+b+c;
    int ans=a+b+c;
    for (int i = 0; i < k; ++i) {
        ans+=Max(a,b,c);
        a=Min(a,b,c);
        b=Max(a,b,c);
        c=sum-a-b;
        b*=2;
        sum=a+b+c;
    }
    cout<<ans;

    cout << endl;

    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    while (true) {

        c-=b;
        if (c<=0){
            cout << "Yes" << endl;
            break;
        }

        a-=d;
        if (a<=0){
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    import heapq
    from copy import deepcopy

    INFTY = 2**21
    WHITE = 0
    GRAY = 1
    BLACK = 2

    n = int(input())

    M = [[INFTY]*n for _ in range(n)]

    for _ in range(n):
        u, k, *vc = map(int, input().split())
        cv = [0]*k
        for v, c in zip(vc[::2], vc[1::2]):
            M[u][v] = c
            
    def dijkstra():
        d = [INFTY]*n
        color = [WHITE]*n

        d[0] = 0
        color[0] = GRAY
        while True:
            minv = INFTY
            u = -1
            for i in range(n):
                if minv > d[i] and color[i] != BLACK:
                    u = i
                    minv = d[i]

            if u == -1:
                break
            color[u] = BLACK
            for v in range(n):
                if color[v] != BLACK and M[u][v] != INFTY:
                    if d[v] > d[u]+M[u][v]:
                        d[v] = d[u] + M[u][v]
                        color[v] = GRAY

        for i in range(n):
            print(str(i) + ' ' + str(-1 if d[i] == INFTY else d[i]))

    dijkstra()

    """

    nodes = [[] for _ in range(n)]

    for _ in range(n):
        u, k, *vc = map(int, input().split())
        cv = [0]*k
        for i, (v, c) in enumerate(zip(vc[::2], vc[1::2])):
            cv[i] = (c, v)
        nodes[u] = cv

    d = [INFTY]*n
    d[0] = 0

    d_node = nodes[0]
    heapq.heapify(d_node)

    visited = [False]*n
    visited[0] = True

    while d_node:
        min_c, min_v = heapq.heappop(d_node)
        if visited[min_v]:
            continue
        visited[min_v] = True
        d[min_v] = min_c
        for c, v in nodes[min_v]:
            heapq.heappush(d_node, (min_c+c, v))

    for u, dist in enumerate(d):
        print(str(u) + ' ' + str(dist))
    """



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

int main() {
        int N, A, temp,
            count = 0,
            x = 0;
        int i;
        cin >> N;

        cin >> A;
        for (i = A; i % 2 == 0; i /= 2) {
                count++;
        }

        for (i = 0; i < N - 1; i++) {
                temp = i;
                cin >> A;
                for (i = A; i % 2 == 0; i /= 2) {
                        x++;
                }
                if (count > x) {
                        count = x;
                }
                x = 0;
                i = temp;
        }
        cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {



	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);

	        while(true){
	        	int a=scan.nextInt();
	        	int b = scan.nextInt();
	        	if((a|b)==0)break;
	        	int f=0;
	        	int t =0;
	        	int h=0;
	        	int c=b-a;
	        	if(c!=0){
	        		t=c/1000;
	        		c%=1000;
	        		f = c/500;
	        		c%=500;
	        		h=c/100;
	        	}
	        	System.out.println(h+" "+f+" "+t);
	        		
	        	}

	        }
	    
	}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)

ll n,w,weight[105],value[105],t=0;
ll dp[105][100005];

ll solve()
{
    ll m=0,i,j;

    for(j=0;j<=n;j++)dp[j][0]=w;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=t;j++)
        {
            if(weight[i]<=w&&value[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j-value[i]]-weight[i],dp[i-1][j]);
            }
            else dp[i][j]=dp[i-1][j];

            if(dp[i][j]>=0)m=max(m,j);
        }
    }

    return m;
}

int main()
{
    fastio;

    cin >> n >> w;
    for(int i=1;i<=n;i++)
    {
        cin >> weight[i] >> value[i];
        t=t+value[i];
    }
    memset(dp,-1,sizeof(dp));
    cout << solve();

    return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> > ord;

    int l=-1,r=10000000;
    int a,b;
    rep(i,m){
        cin>>a>>b;
        if(a>=l)l=a;
        if(b<=r)r=b;
    }
    if(l==r)cout<<1<<endl;
    else if(l>r)cout<<0<<endl;
    else cout<<r-l+1<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma region alias
#define inf LONG_MAX
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repr(i,n) for(int i=(int)(n-1);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define sz(v) ((int)(v).size())
#define rz resize
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vec vector
using vi=vec<int>;
using vs=vec<string>;
using ii=pair<int,int>;
#pragma endregion
// define variables here
int k;
int ans;
int gcd(int a, int b) {
    return (a < b) ? gcd(b, a) : (b > 0) ? gcd(b, a % b) : a;
}
void solve(){
  // write code here
  cin>>k;
  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(i, gcd(j,l));
      }
  cout<<ans<<endl;        
}

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

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n;
	vector<ll>	a(n+1,INFL);	
	for(i=1;i<=n;i++) {
		cin >> a[i];
	}
	j = 1;
	for(i=1;i<=n;i++) {
		j=a[j];
		if (j==2) break;
	}

	if (j==2) {
		cout << i << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    ll ans=0,ex=0;
    for(int i=n-1;i>=0;i--)
    {
        ll x=a[i]+ans;
        ll y=b[i];
        if(x%y==0)
        {
            ;
        }
        else
        {
            ll d=((x/y)+1)*y;
            ans+=d-x;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 1792
n,y=map(int,input().split())
for p in range(n+1):
  for q in range(n+1-p):
    if 10000*p+5000*q+1000*(n-p-q)==y:
      print(p,q,n-p-q)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')

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

using namespace std;

#define ll long long
#define up(i,j,n)	for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)

const ll mod=1e9+7;
const ll LIM=1e5+1;
const ll MAXN=1e5+5;

ll fac[MAXN],inv[MAXN],pos1,pos2,vis[MAXN],a[MAXN],val,N;

namespace solution{
	ll C(ll a,ll b){
		if(b>a||a<0||b<0)return 0;
		return fac[a]*inv[b]%mod*inv[a-b]%mod;
	}
	void Prepare(){
		fac[0]=1;inv[1]=1;inv[0]=1;
		up(i,1,LIM)fac[i]=fac[i-1]*i%mod;
		up(i,2,LIM)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		up(i,1,LIM)(inv[i]*=inv[i-1])%=mod;
		scanf("%lld",&N);
		up(i,1,N+1){
			scanf("%lld",&a[i]);
			if(vis[a[i]])val=a[i];
			vis[a[i]]=1;
		}
		up(i,1,N+1){
			if(a[i]==val){
				if(!pos1)pos1=i;
				else pos2=i;
			}
		}
	}
	void Solve(){
		ll sum=pos1-1+(N+1-pos2);
		up(i,1,N+1){
			ll ans=C(N+1,i);
			ans=(ans+mod-C(sum,i-1))%mod;
			printf("%lld\n",ans);
		}
	}
}

int main(){
//	freopen("input.in","r",stdin);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// 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(void){
  int a,b,c; cin >> a >> b >> c;
  int ans = 0;
  if(a==b) ++ans;
  if(b==c) ++ans;
  if(c==a) ++ans;

  if(ans==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] a = new int[m];

        for(int i = 0; i < m; i++)
            a[i] = sc.nextInt();

        int ans = n;
        for(int i = 0; i < m; i++)
            ans = ans - a[i];

        if(ans < 0){
            System.out.println(-1);
        }else{
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 39564
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n, m;
	cin >> n >> m;
	vi a(n);
	rep(i, n) cin >> a[i];
	int sa = 0;
	rep(i, n) sa += a[i];
	sort(a.begin(), a.end(), greater<int>());
	string ans;
	if(a[m-1] * 4 * m < sa) ans = "No";
	else ans = "Yes";
	cout << ans << endl;
}


Measured memory_bytes: 256
def minkowski_dist(x, y, pn)
	n = x.length
	z = Array.new(n)
	for i in 0..n-1
		z[i] = (x[i] - y[i]).abs()
	end
	case pn
	when 0 
		return z.max
	else 
		# notice: () of (1/pn.to_f) is important
		return (z.reduce(0.0){|sum, zi| sum += zi**pn}) ** (1/pn.to_f)
	end
end

n = gets.to_i
x = gets.strip.split(" ").map{|i| i.to_f}
y = gets.strip.split(" ").map{|i| i.to_f}

for pn in 1..3
	puts minkowski_dist(x, y, pn).floor(5)
end
puts minkowski_dist(x, y, 0).floor(5)



Measured memory_bytes: 8992
#include <stdio.h>
#define maxn 10000+10
int main(){
	int n;
	int a[maxn];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int s=0,sum=0;
	for(int i=0;i<n;i++){
		s=a[i]-1;
		sum+=s;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
    int a, b, c, d, area1, area2;
    cin >>a >>b >>c >>d;
    area1 = a * b;
    area2 = c * d;
    if(area1 >= area2){
        cout << area1 << endl;
    }else{
        cout << area2 << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val min = min(n%k, k-(n%k))
    println(min)
}

fun min(a: Long, b: Long): Long{
    if(a < b) return a
    else return b
}


Measured memory_bytes: 37920
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using PD = pair<double, double>;

double dist(PD p, PD q) {
    double a, b, c, d;
    tie(a, b) = p;
    tie(c, d) = q;
    return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int main() {
    ll N;
    cin >> N;
    V<PD> coors(N);
    for(auto &&ele : coors) cin >> ele.first >> ele.second;
    V<ll> ord(N);
    iota(ALL(ord), 0ll);
    double ans = 0;
    ll cnt = 0;
    do {
        cnt++;
        for(ll i = 0; i < N - 1; i++) ans += dist(coors[ord[i]], coors[ord[i + 1]]);
    } while(next_permutation(ALL(ord)));

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


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

print (math.ceil(N / (2*D+1)))

Measured memory_bytes: 77532
n = int(input())
a = list(map(int,input().split()))

from collections import deque

Q=deque([])

if n%2==0:
    for i in range(n):
        if i%2==0:
            Q.append(a[i])
        else:
            Q.appendleft(a[i])
else:
    for i in range(n):
        if i%2==0:
            Q.appendleft(a[i])
        else:
            Q.append(a[i])

ans = []

for i in range(n):
    ans.append(Q.popleft())

print(*ans)

Measured memory_bytes: 111828
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var NT = ReadSplitInt();
            var min = int.MaxValue;
            for (int i = 0; i < NT[0]; i++)
            {
                var ct = ReadSplitInt();
                if (NT[1] >= ct[1])
                {
                    min = Min(ct[0], min);
                }
            }

            if (min != int.MaxValue)
                Println(min);
            else
                Println("TLE");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268