akhauriyash/Code-Regression huggingface dataset:
N = input()
a = []
f = True
for i in range(N):
  a.append(raw_input())
    
for x in range(N-1):
  if a[x][-1:] != a[x+1][:1]:
    f = False
    
if len(a) != len(set(a)):
  f = False

if f:
  print "Yes"
else:
  print "No"

Measured memory_bytes: 2568
<?php
fscanf(STDIN, '%s %s', $S, $T);
fscanf(STDIN, '%d %d', $A, $B);
fscanf(STDIN, '%s', $U);

$balls = [
    $S => $A,
    $T => $B,
];

$balls[$U]--;

echo $balls[$S] . ' ' . $balls[$T];

echo PHP_EOL;


Measured memory_bytes: 16224
#include <stdio.h>

int gcd(int a, int b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	
	int g = gcd(A, B);
	if (C % g == 0) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	ll a[n];
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	ll ans = a[n - 1];
	multiset<pair<int, int>, greater<pair<int, int>>> st;
	st.insert(MP(a[n - 2], a[n - 1]));
	st.insert(MP(a[n - 2], a[n - 1]));
	for (int i = n - 3; i >= 0; --i) {
		auto it = st.begin();
		ll f = (*it).first;
		ll s = (*it).second;
		ans += min(f, s);
		st.insert(MP(min(f, a[i]), max(f, a[i])));
		st.insert(MP(min(s, a[i]), max(s, a[i])));
		st.erase(st.find(*it));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 14552
n,m=map(int,input().split())
xyz=[list(map(int,input().split()))for _ in range(n)]
dp=[[[0,0,0,0]for _ in range(n+1)]for _ in range(n+1)]
t=[[1,1,1],[-1,-1,-1],[-1,-1,1],[-1,1,-1],[-1,1,1],[1,-1,-1],[1,-1,1],[1,1,-1]]
ma=0
for i in range(8):
    x=[(xyz[j][0]*t[i][0]+xyz[j][1]*t[i][1]+xyz[j][2]*t[i][2]) for j in range(n)]
    x.sort()
    x.reverse()
    s=0
    for j in range(m):
        s+=x[j]
    ma=max(s,ma)
print(ma)

Measured memory_bytes: 122996
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<random>
using namespace std;

int n;
void init()
{
    scanf("%d",&n);
}

void work()
{
    int a,b;
    if (n==1)
    {
        printf("Hello World\n");
    }else
    {
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);
    }
}


int main()
{
    init();
    work();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
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 << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;j++j) {}
bool comp(pair<int,int> &a,pair<int,int> &b) {
  return a.first < b.first;
}

int main(void) {
  int N;cin>>N;
  map<string,vector<pair<int,int>>> M;
  string s;
  int p;
  REP(i,N) {
    cin>>s>>p;
    M[s].push_back(make_pair(p,i+1));
  }
  
  for( auto i = M.begin(); i != M.end() ; ++i ) {
    vector<i_i> v = i->second;
    sort(v.begin(), v.end(),greater<i_i>());
    REP(i,v.size()) pr(v[i].second);
  }

  // for (auto const& [k, v] : M) {
  //   sort(v.begin(), v.end());
  //   REP(i,v.size()) pr(v[i].second);
  // }
  return 0;
}


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

char A1[33] = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char B1[33] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

string A2[32] = {
	"101",
	"000000",
	"000011",
	"10010001",
	"010001",
	"000001",
	"100101",
	"10011010",
	"0101",
	"0001",
	"110",
	"01001",
	"10011011",
	"010000",
	"0111",
	"10011000",
	"0110",
	"00100",
	"10011001",
	"10011110",
	"00101",
	"111",
	"10011111",
	"1000",
	"00110",
	"00111",
	"10011100",
	"10011101",
	"000010",
	"10010010",
	"10010011",
	"10010000"
};

string B2[32] = {
	"00000",
	"00001",
	"00010",
	"00011",
	"00100",
	"00101",
	"00110",
	"00111",
	"01000",
	"01001",
	"01010",
	"01011",
	"01100",
	"01101",
	"01110",
	"01111",
	"10000",
	"10001",
	"10010",
	"10011",
	"10100",
	"10101",
	"10110",
	"10111",
	"11000",
	"11001",
	"11010",
	"11011",
	"11100",
	"11101",
	"11110",
	"11111"
};

string U;
string V;

int main() {
	while (getline(cin, U)) {
		V = "";
		for (int i = 0; i < U.size(); i++) {
			for (int j = 0; j < 32; j++) {
				if (A1[j] == U[i]) {
					V += A2[j];
				}
			}
		}
		while (V.size() % 5 != 0) {
			V += '0';
		}
		U = "";
		for (int i = 0; i < V.size(); i += 5) {
			for (int j = 0; j < 32; j++) {
				if (B2[j] == V.substr(i, 5)) {
					U += B1[j];
				}
			}
		}
		cout << U << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSkip solver = new CSkip();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSkip {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int ans = Math.abs(in.nextInt() - x);
            for (int i = 1; i < n; i++) {
                ans = gcd(ans, Math.abs(in.nextInt() - x));
            }
            out.print(ans);
        }

        static int gcd(int u, int v) {
            int r;
            while (0 != v) {
                r = u % v;
                u = v;
                v = r;
            }
            return u;
        }

    }
}



Measured memory_bytes: 46660
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    ll x;
    cin >> x;

    for(ll i = -1000; i <= 1000; i++){
        for(ll j = -1000; j <= 1000; j++){
            ll ii = i * i * i * i * i;
            ll jj = j * j * j * j * j;
          
            if(ii - jj == x){
                cout << i << " " <<  j << endl;
                return 0;
            }
        }
    }
}



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

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

using namespace std;

int main(){
  int w,h;cin>>w>>h;
  map<char, int> m;
  rep(i,w)rep(j,h){
    char t;cin>>t;
    m[t]++;
  }

  bool f=true;
  if(h%2==0 && w%2==0){
    for(auto p:m){
      if(p.second%4){f=false;break;}
    }
  }else if(h%2 && w%2){
    map<int,int> c;
    for(auto p:m)c[p.second%4]++;
    if(c[1]+c[3]!=1)f=false;
    if(c[2] > w/2+h/2)f=false;
  }else{
    int even = w;
    if(h%2==0)even=h;

    map<int,int> c;
    for(auto p:m)c[p.second%4]++;

    if(c[1] || c[3] || c[2]>even/2)f=false;
  }
  
  if(f)cout<<"Yes";
  else cout<<"No";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   
    int n;
    cin>>n;
    unsigned long long int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(i%3 && i%5 )
            ans += i;
    }
    cout<<ans<<"\n";
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(AB[0]%2!=0 && AB[1]%2!=0 ? "Yes":"No");
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int X;
  cin >> X;
  if(X >= 30){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
def main():
    n = int(input())
    A = list(map(int, input().split()))

    res = 1
    inc = 0
    dec = 0

    for i in range(n - 1):
        if A[i] < A[i+1]:
            inc += 1
        elif A[i] > A[i+1]:
            dec += 1
        
        if inc and dec:
            res += 1
            inc, dec = 0, 0
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<list>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define first fi
#define second se
const int MAX=100000;
const int inf=1e9;
vi G[MAX];
list<int> out;
bool V[MAX];
int indeg[MAX];
int v,e;
void bfs(int s)
{
  queue<int> q;
  q.push(s);
  V[s]=true;
  while(!q.empty())
  {
    int u=q.front();q.pop();
    out.push_back(u);
    for(int i=0;i<G[u].size();i++)
    {
      int v=G[u][i];
      indeg[v]--;
      if(indeg[v]==0 && !V[v])
      {
        V[v]=true;
        q.push(v);
      }
    }
  }
}
void tsort()
{
  for(int i=0;i<v;i++)
  {
    indeg[i]=0;
  }
  for(int u=0;u<v;u++)
  {
    for(int i=0;i<G[u].size();i++)
    {
      int v=G[u][i];
      indeg[v]++;
    }
  }
  for(int u=0;u<v;u++)
  {
    if(indeg[u]==0 && !V[u]) bfs(u);
  }
  for(list<int>::iterator it=out.begin();it!=out.end();it++)
  {
    cout << *it << endl;
  }
}
int main(void)
{
  cin >> v >> e;
  for(int i=0;i<v;i++)
  {
    V[i]=false;
  }
  for(int i=0;i<e;i++)
  {
    int s,t;
    cin >> s>> t;
    G[s].push_back(t);
  }
  tsort();
}



Measured memory_bytes: 6236
#include<bits/stdc++.h>
#include <cmath>
#define ll long long
#define ull unsigned long long
using namespace std;
vector<vector<int>> g;
vector<int> len;
vector<vector<int>> col(2);
vector<int> ans;
vector<int> s;
void yn(bool a){
    if(a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

int main(){
 

        int n;
        cin>>n;
        int arr[n];
        int ans=0;
        bool f;
        unordered_map<int,int> us;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            us[arr[i]]++;
        }
        
        for(int i=0;i<n;i++){
            
            f=true;
            if(us[arr[i]]>1||us[1]){
                continue;
            }
            for(int j=2;j<=sqrt(arr[i]);j++){
                if(arr[i]%j==0){
                    if(us[j]||us[arr[i]/j]){
                        f=false;
                        break;
                    }
                }
            }
            
            if(f){
                ans++;
            }
        }
        if(us[1]==1){
            ans++;
        }
        
        cout<<ans<<endl;
    
}


Measured memory_bytes: 32464
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s=="SUN") cout<<7;
    else if(s=="MON") cout<<6;
    else if(s=="TUE") cout<<5;
    else if(s=="WED") cout<<4;
    else if(s=="THU") cout<<3;
    else if(s=="FRI") cout<<2;
    else if(s=="SAT") cout<<1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		arr[i]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<n;j++)
		{
			for(int k=1;k<n;k++)
			{
				int p = i*i+j*j+k*k+i*j+j*k+k*i;
				if(p>n)
					break;
				else
					arr[p-1]++;
			}
		}
	}
	for(int i=0;i<n;i++)
		printf("%d\n",arr[i]);
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int N;

int main()
{

    cin >> N;
    int amari;
    amari = N % 10;

    if (amari == 3)
    {
        cout << "bon";
    }
    else if (amari == 0 || amari == 1 || amari == 6 || amari == 8)
    {
        cout << "pon";
    }
    else
    {
        cout << "hon";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
#define mp(a,b) make_pair(a,b)
int main(){
    int64_t n;
    cin>>n;
    int64_t ans=0;
    set<int64_t> s;
    //O(√N)で約数列挙
    s.insert(1);
    s.insert(n);
    for(int64_t i=2;i*i<=n;i++){
        if(n%i==0){
            s.insert(i);
            s.insert(n/i);
        }
    }
    //m = N/x-1;
    for(auto c:s){
        int64_t x = c;
        int64_t m = n/c-1;
        if(m>x) ans += m;
        //cout<<"x:"<<c<<" m:"<<n/c-1<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3864
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main(void)
{
    int n, m;
    
    printf("\n");
    scanf("%d%d", &n, &m);

        if(n==m)
            {
                printf("Yes\n");
            }
            else
            {
                printf("No\n");
            }
 
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

const int mod = 1e9+7;
#define ll long long int
const double epsilon = 1e-7;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
char s[101];
char t[101];
int main(void){
    scanf("%s", &s);
    int len = 0;
    while(s[len] != '\0')len++;
    int ans = mod;
    
    for(int i = 97;i <= 122;i++){
        for(int j = 0;j < len;j++){
            t[j] = s[j];
        }
        for(int j = 1;j <= len;j++){
            int flag = 1;
            if(t[0] != i)flag = 0;
            for(int k = 0;k < len - j;k++){
                if(t[k+1] != i)flag = 0;
                if(t[k] == i || t[k+1] == i)t[k] = i;
            }
            if(flag){
                ans = mi(ans, j-1);
                break;
            }
        }
        //printf("%s, %d\n", t, ans);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
  lli n;
  char c;
  cin>>n;
  unordered_map<char, lli> mp;
  for(lli i=0;i<n;i++)
  {
    cin>>c;
    mp[c]++;
  }
  if(mp['R']>mp['B']) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3600
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

alist=([a]+[b]+[c]+[d]+[e])

rem=[a%10 for a in alist]
remlist=[r for r in rem if r>0]
minrem=0
if remlist:
    minrem=min(remlist)-10
div=[(1+(a//10))*10 for a in alist]
times=[]
for i in range(5):
    if rem[i]==0:
        times.append(alist[i])
    else:
        times.append(div[i])
print(sum(times)+minrem)

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

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var n = io.I;
        var a = io.Ls(n);

        Array.Sort(a, (x, y) => y.CompareTo(x));

        var g = a.GroupBy(x => x).Where(x => x.Count() >= 2);

        if (g.Count() == 0)
        {
            io.Write(0);
        }
        else if (g.First().Count() >= 4)
        {
            var l = g.First().First();
            io.Write(l * l);
        }
        else
        {
            var l1 = g.ElementAt(0).First();
            var l2 = g.ElementAt(1).First();
            io.Write(l1 * l2);
        }
    }
}

Measured memory_bytes: 55052
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
    if(n==m)
    {
        cout<<n*2;
        return 0;
    }
    y=max(n,m);
    cout<<(2*y)-1<<endl;
}


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

using namespace std;

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

    vector<int> a(3);
    for(int i = 0; i < 3; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    if(a[0] + a[1] == a[2])
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
def f(n):
    if n%2==0: return n//2
    else: return 3*n+1

s=int(input())
l=[s]
if s==2 or s==1:
    print("4")
    exit()

ans=0
while l[ans]!=4:
    l.append(f(l[ans]))
    ans+=1
print(ans+4)



Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first 
#define s second 
using namespace std;
const int mod=1e9+7;
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
bool isprime(int n){ if(n==1) return false; for(int i=2;i<=sqrt(n);i++)	if(n%i==0) return false; return true;}
vector<vector<int>> adj(2e5);
vi visited(2e5,0);
/*

*/

int solve()
{
	int x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	int dist=x/d;
	if(k<=dist)
	{
		x=x-(d*k);
		return cout<<x,0;
	}
	else
	{
		x=x-(dist*d);
		k=k-dist;
		if(k%2==0) return cout<<x,0;
		else
		{
			int ans=min(abs(x-d),(abs(x+d)));
			return cout<<ans,0;
		}
	}
	return 0;
}
int32_t main() {
/*#ifndef ONLINE_JUDGE
	//for getting input from input.txt
	freopen("input.txt","r",stdin);
	//for writing output to output.txt
	freopen("output.txt","w",stdout);
#endif*/
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 9440
def base10to(base, target, conv_list):
    if target <= base:
        conv_list.insert(0, target)
        return conv_list
    elif target % base == 0:
        conv_list.insert(0, base)
        return base10to(base, target // base - 1, conv_list)
    else:
        conv_list.insert(0, target % base)
        return base10to(base, target // base, conv_list)


def ret_alpha(target):
    return chr(96 + target)


def main():
    num = int(input())
    base = 26
    result_list = list()
    result_list = base10to(base, num, result_list)

    result = ''
    for i in result_list:
        result = result + ret_alpha(i)
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
import sys
input = sys.stdin.readline
from bisect import *

def judge(x):
    cnt = 0
    
    for i in range(N):
        idx = bisect_left(A, x-A[i])
        cnt += N-idx
    
    return cnt>=M
    
def binary_search():
    l, r = 0, 10**11
    
    while l<=r:
        mid = (l+r)//2
        
        if judge(mid):
            l = mid+1
        else:
            r = mid-1
    
    return r

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
border = binary_search()
acc = [0]

for Ai in A:
    acc.append(acc[-1]+Ai)

ans = 0
cnt = 0

for i in range(N):
    idx = bisect_left(A, border-A[i]+1)
    ans += A[i]*(N-idx)+acc[N]-acc[idx]
    cnt += N-idx

ans += (M-cnt)*border

print(ans)

Measured memory_bytes: 58204
n =int(input())
w = []

for i in range(n):
    w.append(input())

for i in range(n - 1):
    for j in range(i + 1, n):
        if w[i] == w[j]:
            print("No")
            exit()

for i in range(n - 1):
    if w[i][-1] != w[i + 1][0]:
        print("No")
        exit()

print("Yes")

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

long long n, a, b;

int main() {
  cin >> n >> a >> b;
  if (n == 1) {
   if (a == b) 
    		return cout << 1 << '\n', 0;
   else
     return cout << 0 << '\n', 0;
  }
  if (a > b)
    return cout << 0 << '\n', 0;
  cout << ((n - 1) * b + a) - ((n - 1) * a + b) + 1 << '\n';
 return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  for(int i=0;i<str.length();i++){
    if(str[i] >= 'a' && str[i] <= 'z'){
      str[i] -= 32;
    }
  }
    cout << str << endl;
  
}
  

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define yn(x) puts((x ? "YES" : "NO"))
using namespace std;
string S;

void input() {
  cin>>S;
}
void solve() {
  // a,b,c
  
  /*
  ２文字 -> (1,1,0) のみ
  ３文字 -> (1,1,1) のみ
  ４文字 -> (2,1,1) のみ
  ５文字 -> (2,2,1) のみ
  ...
  a,b,cが決まっていると、a,b,c,a,b,c,a,b,c,... の並びしかない(?)
  */

 map<int,int> mp;
 vector<int> cnt(3);
 for(auto c : S){
   cnt[c-'a']++;
 }
 sort(all(cnt));
 yn(cnt[2]-cnt[0] <= 1);


}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

void solve() {

	int n;
	cin >> n;

	vector<int> arr(n);
	for (int i = 0; i < n; i++) cin >> arr[i];
	sort(arr.begin(), arr.end());

	int ans = *arr.rbegin() - *arr.begin();
	cout << ans;
}

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

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();
}

Measured memory_bytes: 256
H,W=map(int,input().split())
A=[[False]*(W+2)]+\
  [[i=="." for i in "#"+input()+"#"] for _ in range(H)] + \
  [[False]*(W+2)]

q=[[(i,j) for i in range(1,H+1) for j in range(1,W+1) if not A[i][j]]]

for k in range(2000):
    q.append([])
    f=True
    for i,j in q[k]:
        if A[i-1][j]:
            A[i-1][j]=False
            q[k+1].append((i-1,j))
            f=False
        if A[i+1][j]:
            A[i+1][j]=False
            q[k+1].append((i+1,j))
            f=False
        if A[i][j-1]:
            A[i][j-1]=False
            q[k+1].append((i,j-1))
            f=False
        if A[i][j+1]:
            A[i][j+1]=False
            q[k+1].append((i,j+1))
            f=False
    if f:
        break
print(k)

Measured memory_bytes: 109216
#include<iostream>
using namespace std;
int main(){
    int i, j, k, r, c, b;
    cin >> r >> c;
    int rsum[100]={};
    int csum[100]={};
    int sum=0;
    for(i=0;i<r;i++){
        cin >> b;
        cout << b;
        rsum[i]+=b;
        csum[0]+=b; 
        for(j=1;j<c;j++){
            cin >> b;
            cout <<" " << b;
            rsum[i]+=b;
            csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
    }
    cout << csum[0];
    for(j=1;j<c;j++){
        cout << " " << csum[j];    
    }
    cout << " " << sum <<  endl;
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include<algorithm>
using  namespace std;
#define ll      long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define vs      vector<string>
#define vp      vector< pair <string,int> >
#define mpi     map<int,int>
#define mps     map<char,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define forn(i,n)    for (int i = 0; i < n; i++)
#define fork(i,k,n)  for (int i = k; i <= n; i++)
#define forkr(i,k,n) for (int i = k; i >= n; i--)

 int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 ll n,k;
 cin>>n>>k;
int v[n];
 forn(i,n){
 cin>>v[i];
 }
 sort(v,v+n);
 ll t=0;
 forn(i,k){
 t+=v[i];
 }
 cout<<t<<endl;
}






Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std; 

int main(){
	char c;
	cin>>c;

	cout<<(char)((c+1))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int N;
  cin>>N;
  if(N==3){
    cout<<"2 5 63"<<endl;
  }else if(N%2==0){
    VE V;
    V.PB(2);
    V.PB(10);
    V.PB(3);
    V.PB(9);
    V.PB(4);
    V.PB(8);
    V.PB(6);
    V.PB(12);
    FOR(i,0,N){
      cout<<V[i%8]+(i/8)*12<<" ";
    }
    cout<<endl;
  }else{
    VE V;
    V.PB(6);
    V.PB(2);
    V.PB(10);
    V.PB(3);
    V.PB(9);
    V.PB(4);
    V.PB(8);
    V.PB(12);
    FOR(i,0,N){
      cout<<V[i%8]+(i/8)*12<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
using System;
class hogehoge
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int t = int.Parse(input[1]);
		int[] c = new int[n];
		int[] u = new int[n];
		for (int i = 0; i < n; i++)
		{
			string[] s = Console.ReadLine().Split(' ');
			c[i] = int.Parse(s[0]);
			u[i] = int.Parse(s[1]);
		}
		int index = -1;
		for (int i = 0; i < n; i++)
		{
			if (u[i] > t) continue;
			if (index == -1) index = i;
			else if (c[i] < c[index]) index = i;
		}
		if (index == -1) Console.WriteLine("TLE");
		else Console.WriteLine(c[index]);
	}
}

Measured memory_bytes: 13140
#include <iostream>//Lucas模板
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
void ex_gcd(ll a, ll b, ll &d, ll &x, ll &y) { if (!b) { x = 1; y = 0; d = a; } else { ex_gcd(b, a%b, d, y, x); y -= x * (a / b); }; }
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;}//ÏÈ³ýºó³Ë·ÀÒç³ö
ll inv_exgcd(ll a, ll m) { ll d, x, y;ex_gcd(a, m, d, x, y);return d == 1 ? (x + m) % m : -1; }

const int maxn=1e6;

ll fac[maxn];
ll a,b,mod,N;
ll C(ll n,ll m,ll mod)
{
    if(m>n)return 0;
    ll ans=1;
    for(int i=1;i<=m;++i)
    {
        ll a=(n+i-m)%mod,b=i%mod;
        ans=ans*(a*inv_exgcd(b,mod)%mod)%mod;
    }
//    ll ans=fac[n];
//    ans*=inv_exgcd((fac[m]*fac[n-m])%mod,mod);
    return ans;
}
ll Lucas(ll n,ll m,ll mod)
{
    if(m==0)return 1ll;
    return C(n%mod,m%mod,mod)*Lucas(n/mod,m/mod,mod)%mod;
}
ll qpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2) res=res*a%mod;
        a=a*a%mod;
        b=b/2;
    }
    return res%mod;
}
int main()
{
    ll t;
    mod=1e9+7;

    scanf("%lld%lld%lld",&N,&a,&b);
    //cout<<qpow(2,N)<<endl;
    ll ans1=Lucas(N,b,mod),ans2=Lucas(N,a,mod);
   //cout<<ans1<<" "<<ans2<<endl;

    printf("%lld\n",(qpow(2,N)-1-ans1-ans2+10ll*mod)%mod);
    return 0;
}


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

using namespace std;

const int MaxN = 2e5 + 15;
const int MOD = 1e9 + 7;
const long long INF = 1e18;

int f[MaxN];

int get(int pos)
{
    int res = 0;
    for(int x = pos; x >= 0; x &= x + 1, --x)
        res = max(res, f[x]);
    return res;
}

void up(int pos, int y)
{
    for(int x = pos; x < MaxN; x |= x + 1)
        f[x] = max(f[x], y);
}

int main()
{
//    freopen("output.txt", "r", stdin);

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    int ans = 0;

    for(int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        int y = 1 + f[x - 1];
        f[x] = y;

        ans = max(ans, y);
    }

    cout << n - ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++)ans+=s[i]!=t[i];
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int div,a,b,count;
    while(cin>>div>>a>>b)
    {
        count=0;
        for(int i=a;i<=b;i++)
        {
            if(i%div==0)
            {
                count++;
                 break;
            }
        }
        if(count!=0)
        {
            cout<<"OK"<<endl;
        }
        else
        {
            cout<<"NG"<<endl;
        }
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String []args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        int[] a = new int[n];

        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        boolean []dp = new boolean[k + 1];

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

        if(dp[k]) {
            System.out.println("First");
        }
        else {
            System.out.println("Second");
        }
    }
}

Measured memory_bytes: 37148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int N,M,K;
vector<ll> A,B;

bool isOK(int index) {
    int A_index=min(index,N);
    while (A_index>=0)
    {
        if(index-A_index>M)return false;
        if(A[A_index]+B[index-A_index]<=K)return true;
        A_index--;
    }
    return false;
}

int binary_search(){
    int ng = N+M+1;
    int ok = 0; 
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin>>N>>M>>K;
    A.resize(N+1);B.resize(M+1);
    A[0]=0;B[0]=0;
    for (int i = 1; i <= N; i++){
        int a;
        cin>>a;
        A[i]=A[i-1]+a;
    }
    for (int i = 1; i <= M; i++){
        int a;
        cin>>a;
        B[i]=B[i-1]+a;
    }
    cout<<binary_search()<<endl;
}

Measured memory_bytes: 6328
#include<stdio.h>
int main(void)
{
	int n,a,max=0,min=1000,i;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &a);
		if(max<a)
		max=a;
		if(min>a)
		min=a;
	}
	printf("%d\n", max-min);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;



int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int num = 0;
    int buf;
    int buf2;

    for(int i=0;i<10;i++){
        buf = s.find("0");
        if(buf != -1 && buf < n-2){
            buf2 = s.find("0", buf+1);
            if(buf2 != -1 && buf2 < n-1){
                if(s.find(to_string(i), buf2+1) != -1){
                    num++;
                }
            }
        }
    }
    for(int i=10;i<100;i++){
        buf = s.find("0");
        if(buf != -1 && buf < n-2){
            buf2 = s.find(to_string(i / 10), buf+1);
            if(buf2 != -1 && buf2 < n-1){
                if(s.find(to_string(i % 10), buf2+1) != -1){
                    num++;
                }
            }
        }
    }
    for(int i=100;i<1000;i++){
        buf = s.find(to_string(i / 100));
        if(buf != -1 && buf < n-2){
            buf2 = s.find(to_string((i / 10) % 10), buf+1);
            if(buf2 != -1 && buf2 < n-1){
                if(s.find(to_string(i % 10), buf2+1) != -1){
                    num++;
                }
            }
        }
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  long long Ans1=A*X+B*Y;
  long long Ans2;
  if(X<=Y){
    Ans2=(Y-X)*B+C*2*X;
  }
  else{
    Ans2=(X-Y)*A+C*2*Y;
  }
  long long Ans3=C*max(X,Y)*2;
  cout<<min(Ans1,min(Ans2,Ans3))<<endl;
}
  


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n%2 == 0 {
		fmt.Println(n / 2)
	} else {
		fmt.Println((n + 1) / 2)
	}
}


Measured memory_bytes: 1772
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m==0:
    return True
  if i>=n or m>sum(A):
    return False
  res=solve(i+1,m) or solve(i+1,m-A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print"yes"
  else:
    print"no"

Measured memory_bytes: 6448
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//_____________________________________________________________
#define MAX_NODE 200002

struct tree{
  ll number;
  std::vector<int> c;
  std::vector<int> child;
  ll point=0;
};

std::vector<tree> T(MAX_NODE+1);
std::vector<int> check_init(MAX_NODE+1,0);

void tree_(int num){
  if(check_init[num]==0){
    check_init[num]=1;
    for(int i=0;i<T[num].c.size();i++) {
      if(check_init[T[num].c[i]]==0)T[num].child.push_back(T[num].c[i]);
      tree_(T[num].c[i]);
    }
  }
}
std::vector<ll> ans;
void tree_init(ll N){
  for(int i=1;i<=MAX_NODE;i++) {
    T[i].number=i;
    T[i].point=0;
  }
  for(int i=0;i<N+1;i++) ans.push_back(0);
  tree_(1);
}

void check(ll s, ll P){
  P+=T[s].point;
  ans[s]=P;
  for(int i=0;i<T[s].child.size();i++){
    check(T[s].child[i], P);
  }
}
int main(int argc, char const *argv[]) {
  ll N, Q, a, b, p, x;
  std::cin >> N >> Q;
  for(int i=0;i<N-1;i++){
    std::cin >> a >> b;
    T[a].c.push_back(b);
    T[b].c.push_back(a);
  }
  tree_init(N);
  for(int i=0;i<Q;i++){
    std::cin >> p >> x;
    T[p].point+=x;
  }
  check(1, 0);
  for(int i=1;i<=N;i++) std::cout << ans[i] << (i==N?"\n":" ");
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a * b >= c * d) {
    cout << a * b << endl;
  } else {
    cout << c * d << endl;
  }

  return 0;
}

Measured memory_bytes: 256
fn main() {
    let (n, m): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let a: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let sum: usize = a.iter().sum();
    let mut count = 0;
    for i in 0..n {
        if sum <= 4 * m * a[i] {
            count += 1;
        }
    }
    println!("{}", if count >= m { "Yes" } else { "No" });
}

Measured memory_bytes: 2148
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans, cur = 0, 0
if(sum(a) <= x):
    if(sum(a) != x): N -= 1
    print(N)
    exit(0)

for i in range(N):
    cur += a[i]
    if(cur > x): break
    ans += 1
print(ans)


Measured memory_bytes: 3064
N,x=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
for i in range(N):
  cnt+=max(A[i]-x,0)
  A[i]=min(A[i],x)
for i in range(1,N):
  d=max(A[i]+A[i-1]-x,0)
  A[i]-=d
  cnt+=d
print(cnt)

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

typedef long long ll;

struct Edge {
    int s;
    int t;
    bool operator < (const Edge& tgt) const {
	if( s == tgt.s )
	    return t < tgt.t;
	return s < tgt.s;
    }
};



int Bridges_dfs(const vector<vector<Edge>>& g, vector<int>& order,
		vector<Edge>& ans, int u, int& cnt_v, Edge pre) {
    if( order[u] != -1 ) { //?¨????????????¨?????????
	return order[u];
    }
    // ??????????¨???????
    order[u] = cnt_v; cnt_v++;
    // ??£??\???????????????
    int min_v = order[u];
    for(auto e : g[u]) { // u ?????????????????????????????????????????????
	if( e.t == pre.s and e.s == pre.t ) continue; 
	min_v = min(Bridges_dfs(g, order, ans, e.t, cnt_v, e), min_v);
    }
    if( min_v == order[u] and pre.s != -1 ) {
	if(pre.s > pre.t) pre = Edge{pre.t,pre.s};
	ans.push_back(pre);
    }
    return min_v;
}

vector<Edge> Bridges(const vector<vector<Edge>>& g) {
    vector<Edge> ans;
    const int V = g.size();
    vector<int> order(V,-1);
    
    // 0??????DFS
    int cnt_v = 0;
    Edge tmp{-1,-1};
    Bridges_dfs(g, order, ans, 0, cnt_v, tmp);
    assert(cnt_v == V); // ??£???????????°?????????????????????
    return ans;
}

int main () {
    int V,E;
    cin >> V >> E;
    vector<vector<Edge>> g(V);
    for (int i=0; i<E; ++i) {
	int s,t;
	cin >> s >> t; 
	g[s].push_back(Edge{s,t});
	g[t].push_back(Edge{t,s});
    }
    vector<Edge> ans = Bridges(g);
    sort(ans.begin(), ans.end());
    for(auto& e : ans) {
	cout << e.s << " "<< e.t << endl;
    }

    return 0;
}

Measured memory_bytes: 5200
N = int(input())
S = list(map(int,list(input())))
all = []
ilist = []
for i in range(N-2):
    if S[i] in ilist:
        pass
    else:
        ilist.append(S[i])
        jlist = []
        for j in range(N-i-1):
            if S[i+j+1] in jlist:
                pass
            else:
                jlist.append(S[i+j+1])
                klist = []
                for k in range(N-i-j-2):
                    if S[i+j+k+2] in klist:
                        pass
                    else:
                        klist.append(S[i+j+k+2])
                        all.append([S[i],S[i+j+1],S[i+j+k+2]])
print(len(all))

Measured memory_bytes: 3700
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: usize = read();
    let mut h: Vec<usize> = (0..n).map(|_| read()).collect(); 
    h[0] -= 1;
    let mut ans = "Yes";
    for i in 1..n {
        if h[i - 1] > h[i]{
            ans = "No";
        }else if h[i - 1] < h[i]{
            h[i] -= 1;
        }
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
int n,a[maxn],b[maxn];
ll ans;
set<pair<int,int> > s;
set<pair<int,int> >::iterator it;
int pre(int i) {
	if (i==1) return n;
	return i-1;
}
int nxt(int i) {
	if (i==n) return 1;
	return i+1;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++) {
		read(b[i]);
		s.insert(make_pair(b[i],i));
	}
	while (s.size()) {
		it=s.end(); it--;
		int i=(*it).second;
		s.erase(it);
		if (b[i]==a[i]) continue;
		int S=b[pre(i)]+b[nxt(i)];
		if (b[i]<=S) { printf("-1\n"); return 0; }
		if (a[i]>=S) {
			if ((b[i]-a[i])%S==0) {
				ans+=(b[i]-a[i])/S; b[i]=a[i]; continue;
			} else { printf("-1\n"); return 0; }
		}
		ans+=b[i]/S; b[i]%=S;
		s.insert(make_pair(b[i],i));
	}
	for (int i=1;i<=n;i++)
		if (a[i]!=b[i]) { printf("-1\n"); return 0; }
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#define N 100010
using namespace std;
int a[N];
int main()
{
    int n, i, ans;
    scanf("%d", &n);
    for(i = 1; i <= n; ++i) scanf("%d", &a[i]);
    ans = 0;
    for(i = 1; i < n; ++i)
    {
        if(a[i] == i)
        {
            ans++;
            swap(a[i], a[i + 1]);
        }
    }
    if(a[n] == n) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
int A[100001];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int L, R;
		cin >> L >> R; L--; R--;
		A[L]++;
		A[R + 1]--;
	}
	for (int i = 1; i < N; i++) A[i] += A[i - 1];
	int ans = 0;
	for (int i = 0; i < N; i++) if (A[i] == M) ans++;
	cout << ans << endl;
}

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

  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c ==  'i' || c ==  'o' || c ==  'u'){
  cout << "vowel" << endl;
  }
  
  else{
  cout << "consonant" << endl;
  }
    
}

Measured memory_bytes: 3560
#include<iostream>
#include<set>
#include<vector>

const int MOD = 1e9 + 7;

int main(void){
    int n, m;
    std::cin >> n >> m;
    std::vector<int> b(n+1);
    std::set<int> a;
    for(int i = 0; i < m; i++){
        int tmp;
        std::cin >> tmp;
        a.insert(tmp);
    }
    b[0] = 1;
    if(a.find(1) != a.end()) b[1] = 0;
    else b[1] = 1;
    for(int i = 2; i <= n; i++){
        if(a.find(i) != a.end()) b[i] = 0;
        else b[i] = (b[i-1] + b[i-2]) % MOD;
    }
    std::cout << b[n] << std::endl;
    return 0;
}

Measured memory_bytes: 8160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  int k,x;
  cin >> k >> x;
  k--;
  for(int i=k;i>=0;i--){
    cout << x - i << endl;
  }
  for(int i=1;i<=k;i++){
    cout << x + i << endl;
  }
}









































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}



Measured memory_bytes: 256