akhauriyash/Code-Regression huggingface dataset:
def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    heaviest_baggage = max(baggage)
    left = 0
    right = heaviest_baggage * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P)

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

int main(){
 int x,y,w,h,r;
 
 cin >> w >> h >> x >> y >> r;

 if( x<r || x>w-r || y<r || y>h-r ){
  cout << "No" << endl;
 }
 else{
  cout << "Yes" << endl;
 }

 return 0;
}

Measured memory_bytes: 3084
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int A[] = new int[N];
    double tmp = 0;
    for(int i=0; i<N; i++){
      A[i] = sc.nextInt();
      tmp += (double)1 / A[i];
    }
    double ans = (double)1 / tmp;
    out.println(ans);
  }
}

Measured memory_bytes: 22484
import java.util.Scanner;

 


public class Main {
        public static void main(String[] args) {
         
          Scanner sc = new Scanner(System.in);
         
          String s = sc.next(); 
          String t = sc.next(); 
          
      
         String T1 = t.substring(s.length() - 0); 
 

           if(t.equals(s+T1)) 
           {
             System.out.println("Yes");
           }
        else{
           System.out.println("No");
            }
         }
      }

Measured memory_bytes: 39196
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int n, maxi = -1;

    cin >> n;

    int arr[n];

    for (int i = 0; i < n; i++) cin >> arr[i];

    for (int i = 0; i < n; i++) {

        if (arr[i] >= maxi) maxi = arr[i];
        else if (maxi-arr[i] > 1) {

        	cout << "No";
        	return 0;
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	//入力
	int ans=0,a,b;
	cin >> a >> b;
	//処理
	if (a >= 13) ans = b;
	else if (a <= 5) ans = 0;
	else ans = b / 2;
	//出力
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    string s,s1,s3;
    cin>>s>>s1;
    cin>>a>>b;
    cin>>s3;

    if(s3==s)
    {
        cout<<a-1<<" "<<b<<endl;
    }
    else
    {
        cout<<a<<" "<<b-1<<endl;
    }



    return 0;
}


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

ans = 0

for i in range(N+1):
    if  i % 2 == 1:
        num = 0
        for j in range(1,201):
            if  i % j == 0:
                num += 1
                if  num == 8:
                    ans += 1
        
print(ans)


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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for ( int i = 0; i < N; i++ )
        cin >> x.at(i) >> y.at(i) >> h.at(i);

    long long ans_H = -1;
    int cx, cy;
    for ( cx = 0; cx <= 100; cx++ ) {
        for ( cy = 0; cy <= 100; cy++ ) {
            bool is_ans = true;
            int i = 0;
            while ( h.at(i) == 0 )
                i++;
            long long H = h.at(i) + abs(x.at(i) - cx) + abs(y.at(i) - cy);
            for ( i = 0; i < N; i++ ) {
                if ( h.at(i) != max(H - abs(x.at(i) - cx) - abs(y.at(i) - cy), 0LL) ) {
                    is_ans = false;
                    break;
                }
            }
            if ( is_ans ) {
                ans_H = H;
                goto END;
            }
        }
    }
END:
    assert(ans_H >= 0);
    cout << cx << " " << cy << " " << ans_H << endl;
    return 0;
}


Measured memory_bytes: 3548
import sys

N = int(input())
H = list(map(int,input().split()))
n = len(H)
ans = "Yes"
if n == 1 :
    ans = "Yes"

for i in reversed(range(n-1)) :
    if H[i] <= H[i+1] :
        pass
    elif H[i] - H[i+1] == 1 :
        H[i] = H[i] - 1
    else : ans = "No"

print(ans)

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    string s;
    cin>>s;
    if(s=="RRR")
        cout<<3;
    else if(s=="SSS")
        cout<<0;
    else if(s=="RRS"||s=="SRR")
        cout<<2;
    else
        cout<<1;
    return 0;
}


Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int N = in.nextInt();
            int X[] = new int[N];
            for (int i = 0; i < N; i++) {
                X[i] = in.nextInt();
            }
            int ans = Integer.MAX_VALUE;
            for (int i = 1; i <= 100; i++) {
                int current = 0;
                for (int j = 0; j < N; j++) {
                    current += Math.pow(X[j] - i, 2);
                }
                ans = Math.min(ans, current);
            }
            out.printLine(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(in.readLine());
                }
                return tokenizer.nextToken();
            } catch (IOException e) {
                return null;
            }
        }

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

    }

    static class OutputWriter {
        PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

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

signed main()
{
	int n; cin >> n;
	auto m = p_factor(n);

	if (n == 1){
		puts("0");
		return 0;
	}

	int ans = 0;

	for (pii a : m) {
		//printf("%lld^%lld\n", a.fst,a.scd);
		//continue;
		int k = a.scd;

		int s = 0;
		int i = 1;
		int add = 0;
		while (s + i <= k) {
			s += i;
			i++;
			add++;
		}

		ans += add;
		//printf("ans+=%lld\n",add);
	}

	printf("%lld\n", ans);
}




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

int main(){
  ll n, x; cin >> n >> x;
  vector<ll> a(n);
  for(int i=0; i<n; ++i) cin >> a[i];
  
  ll res = 0;
  for(int i=0; i<n-1; ++i){
    if(a[i] + a[i+1] > x){
      ll y = a[i] + a[i+1] - x;
      if(a[i+1] - y >= 0){
        a[i+1] -= y;
        res += y;
      }
      else{
        res += a[i+1];
        y -= a[i+1];
        a[i+1] = 0;
        a[i] -= y;
        res += y;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  vector<int> n;
  for(int i=0;i<5;i++){
    int p;
    cin>>p;
    n.push_back(p);
  }
  int ans,ch=0;
  for(int i=0;i<4;i++){
    ch=0;
    int tmp=0,m=n[0]%10;
    if(m==0){
      ans+=n[0];
      n.erase(n.begin()+0);
      continue;
    }
    for(int j=1;j<n.size();j++){
      if(n[j]%10==0){
        ans+=n[j];
        n.erase(n.begin()+j);
        ch=1;
        break;
      }
      if(m<n[j]%10){
        tmp=j;
        m=n[j]%10;
      }
    }
    if(ch==1) continue;
    ans+=n[tmp]+(10-m);
    n.erase(n.begin()+tmp);
  }
  ans+=n[0];
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main()
{
    int a,b,h,m;
    long double rad1,rad2,rad,d;
    cin>>a>>b>>h>>m;
    rad2 = 2.0*PI*(long double)m * 6.0/360.0;
    rad1 = 2.0*PI*((long double)h * 30.0 + 0.5*(long double)m)/360.0;
    /*
    if(rad2>rad1)
    {
        if(rad2 - rad1 > PI)
        {
            rad = PI*2.0 - (rad2 - rad1);
        }else{
            rad = rad2 - rad1;
        }
    }else{
        if(rad1 - rad2 > PI)
        {
            rad = PI*2.0 - (rad1 - rad2);
        }else{
            rad = rad1 - rad2;
        }
    }
    if(rad == 0.0)
    {
        if(a>b)
        {
            d = (long double)(a-b);
        }else{
            d = (long double)(b-a);
        }
    }else if(rad == PI)
    {
        d = (long double)(a+b);
    }else{
        d = sqrt((long double)(a*a)+(long double)(b*b)-2.0*(long double)(a)*(long double)(b)*cosl(rad));
    }
    */
    rad = rad1 - rad2;
    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
    b) * cosl(rad);

    // d = (long double)(a*a+b*b)-2.0*(long double)(2*a*b*cosl(rad));
    printf("%20.20Lf\n", sqrtl(rsq));
    // cout<<sqrt(d)<<endl;
}

Measured memory_bytes: 4096
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll n;
vector<string> s(100001);

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	map<string,ll> mp;
	rep(i,0,n){
		string t;
		cin >> t;
		sort(all(t));
		mp[t]++;
	}
	ll ans=0;
	itit(it,mp){
		ans+=((*it).S-1)*((*it).S)/2;
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 12032
n, m = map(int, input().split())
ans = [0] * n
e = []
for i in range(m):
    si, ci = map(int, input().split())
    e += [[si, ci]]
    for j in range(len(e)):
        if e[j][0] == si and e[j][1] != ci:
            print(-1)
            exit()
    if si == 1 and ci == 0 and n != 1:
        print(-1)
        exit()
    ans[si - 1] = ci
if len(ans) == 1 and ans[0] == 0:
    print(0)
    exit()
elif len(ans) != 1 and ans[0] == 0:
    ans[0] = 1
ans = map(str, ans)
print("".join(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll m,f,r;
    while(true){
        cin >> m >> f >> r;
        if(m == f and f == r and r == -1){
            break;
        }
        if(m == -1 or f == -1){
            cout << "F" << endl;
            continue;
        }
        if(m+f >= 80){
            cout << "A" << endl;
            continue;
        }
        if(m+f >= 65){
            cout << "B" << endl;
            continue;
        }
        if(m+f >= 50){
            cout << "C" << endl;
            continue;
        }
        if(m+f >= 30){
            if(r >= 50){
                cout << "C" << endl;
            }else{
                cout << "D" << endl;
            }
            continue;
        }else{
            cout << "F" << endl;
        }
    }


}





Measured memory_bytes: 3092
# https://atcoder.jp/contests/abc051/tasks/abc051_b

K, S = map(int, input().split())


answer = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            answer += 1

print(answer)


Measured memory_bytes: 2940
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        a:i64,b:i64,c:i64,
    }
    let mut a = a;
    let mut b = b;
    let mut c = c;

    let mut ans = 0;
    while a % 2 == 0 && b % 2 == 0 && c % 2 == 0 {
        if a == b && b == c {
            println!("{}", -1);
            return;
        }
        let na = b / 2 + c / 2;
        let nb = a / 2 + c / 2;
        let nc = a / 2 + b / 2;
        a = na;
        b = nb;
        c = nc;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include <sstream>
 
using namespace std;
 
bool is_prime(int n){
 
  for(int i=2; i*i<=n; i++)
    if(n%i==0)return false;
  return true;
}
 
string toString(int a){
  ostringstream oss;
  oss << a;
  return oss.str();
}
 
int toInt(string s){
  istringstream iss(s);
  int a;
  iss >> a;
  return a;
}
 
int main(void){
  int n,c;
  string str="",C="";
 
  cin >> n >> c;
 
  for(int i=0;i<n;i++)str+="9";
   
  C=c+'0';
 
  if(c<0 && n>1){
    cout << str << str << endl;
    return 0;
  }

  while(true){
    string rstr=str;
    reverse(rstr.begin(),rstr.end());
     
    string res=str+C+rstr;
    int ans=toInt(res);
 
    if(is_prime(ans)){
      cout << ans << endl;
      return 0;
    }
    int tmp=toInt(str);
    tmp--;
    str=toString(tmp);
  }
  return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> d(n);
    rep(i, n) {
      cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[n - 1] - d[0] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   string s;
   cin >> s;
   stack<int> S;
   for(int i = 0; i < s.size(); i++){
       if(s[i] == '0') S.push(0);
       else if(s[i] == '1') S.push(1);
       else if(s[i] == 'B' && S.size() > 0) S.pop();
   }
   int N = S.size();
   vector<int> V(N);
   for(int i = 0; i < N; i++){
       V[i] = S.top();
       S.pop();
   }
   reverse(V.begin(),V.end());
   for(int i = 0; i < N; i++) cout << V[i];
   cout << endl;
}


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

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

class modint {
	static constexpr std::int_fast64_t Modulus = 998244353;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr operator u64() const { return a; }
};

int main() {
	ll n;
	cin >> n;
	map<ll, ll> ms;
	rep(i, n) {
		ll d;
		cin >> d;
		ms[d]++;
	}
	ll m;
	cin >> m;
	vector<ll> ps(m);
	for (int i = 0; i < m; i++) {
		cin >> ps[i];
	}
	for (auto p : ps) {
		if (ms[p] <= 0) {
			cout << "NO" << endl;
			return 0;
		}
		ms[p]--;
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 17004
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  
  int X;
  
  X=max(A, B);
  
  if(X==A){
    A=A-1;}
  else{
    B=B-1;}
  
  X+=max(A,B);
  
  cout << X << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    int ans=c-(a-b);
    if(ans>=0)
    cout<<ans;
    else
    {
      cout<<0;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int a;
  cin >> a;
  string str;
  map<string, int> string_map;
  for(int i = 0; i < a; i++)
  {
    cin >> str;
    string_map[str]++;
  }
  cout << string_map.size() << endl;
  return 0;
}


Measured memory_bytes: 19200
using System;
using System.Linq;

namespace ABC067
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            int[] l = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();

            int res = 0;

            for (int i = 0; i < K; i++)
            {
                res += l[i];
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,R[1000000]={},miv=10000000000,mav=-1000000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>R[i];
    }
    miv=R[0];
    for(int j=1;j<n;j++){
        mav=max(mav,R[j]-miv);
        miv=min(miv,R[j]);
    }
    cout<<mav<<endl;
    return 0;
}


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<class T> class Dijkstra {
public:
	int N;
	T inf;
	vector<T> cost;
	vector<vector<pair<T, int>>> edge;

	Dijkstra(const int N, T inf) : N(N), inf(inf),cost(N), edge(N) {
	}

	void make_edge(int from, int to, T w) {
		edge[from].push_back({ w,to });
	}

	void solve(int start) {
		for(int i = 0; i < N; ++i) cost[i] = inf;

		priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
		cost[start] = 0;
		pq.push({ 0,start });

		while (!pq.empty()) {
			T v = pq.top().first;
			int from = pq.top().second;
			pq.pop();
			for (auto u : edge[from]) {
				T w = v + u.first;
				int to = u.second;
				if (w < cost[to]) {
					cost[to] = w;
					pq.push({ w,to });
				}
			}
		}
		return;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;
    Dijkstra<int> d(N, INF);
    d.make_edge(X, Y, 1);
    d.make_edge(Y, X, 1);
    REP(i,N-1){
        d.make_edge(i, i+1, 1);
        d.make_edge(i+1, i, 1);
    }
    vector<int> ans(N);
    REP(i,N-1){
        d.solve(i);
        for(int j=i+1;j<N;j++) ans[d.cost[j]]++;
    }
    for(int i=1;i<N;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 1; i <= n; i += 2) {
        cout << s[i-1];
    }
    cout << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

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

        int[] p = cin.ArrayInt(n);

        int[] x = new int[m];
        int[] y = new int[m];

        var unionFind = new UnionFindTree(n);

        for (int i = 0; i < m; ++i)
        {
            x[i] = cin.nextInt();
            y[i] = cin.nextInt();

            unionFind.Unite(x[i], y[i]);
        }

        int count = 0;

        for (int i = 0; i < n; ++i)
        {
            if (i+1 != p[i])
            {
                if (unionFind.Same(i + 1, p[i])) { ++count; }
            }
            else
            {
                ++count;
            }
        }

        Console.WriteLine(count);
    }
}

class UnionFindTree
{
    int[] parent;

    public UnionFindTree(int n)
    {
        parent = new int[n+1];

        for (int i = 0; i <= n; ++i)
        {
            parent[i] = i;
        }
    }

    public int Root(int x)
    {
        if (parent[x] == x) { return x; }
        return parent[x] = Root(parent[x]);
#if false
        int root = x;
        while(parent[root] != root)
        {
            root = parent[root];
        }

        return root;
#endif
    }

    public void Unite(int x, int y)
    {
        int rootX = Root(x);
        int rootY = Root(y);
        if (rootX != rootY)
        {
            parent[rootX] = rootY;
        }
    }

    public bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 27360
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <string>
#include <iostream>

using namespace std;

int main(){
        int N,M,X,Y;
        int *x, *y;
        cin >> N >> M >> X >> Y;
        x = new int[N];
        y = new int[M];
        for(int i = 0; i<N; i++){
               cin >> x[i];
        }
        for(int j = 0; j<M; j++){
               cin >> y[j];
        }
        sort(x,x+N);
        sort(y,y+M);
        if(max(x[N-1],X) < min(y[0],Y)) printf("No War\n");
        else printf("War\n");
        return 0;
}



Measured memory_bytes: 256
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: isize,
        m: usize,
        a: [isize; m],
    }

    let ans = max(-1, n - a.iter().sum::<isize>());
    println!("{}", ans);
}


Measured memory_bytes: 2192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.parseInt;

/**
 * Problem 05: Split Up!
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			int[] a = new int[n];
			int sum = 0;

			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < n; i++) {
				sum += a[i] = parseInt(st.nextToken());
			}

			int min = MAX_VALUE;

			for (int i = 0; i < 1 << n; i++) {
				int A = 0;
				for (int j = 0; j < n; j++) {
					if ((i & 1 << j) != 0) A += a[j];
				}
				min = Math.min(min, Math.abs(sum - A - A));
			}

			System.out.println(min);
		}
	}
}

Measured memory_bytes: 25428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

    void run() {
        FastReader sc = new FastReader();
        String s = sc.next();
        System.out.println(s.substring(0, 1) + (s.length() - 2) + s.substring(s.length() - 1, s.length()));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


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

int main() {
  
  int n;
  cin >> n;
  int x = 0;
  
  for(int i = 1; i < 10; i++){
    
    if (n % i == 0){
      if (n / i < 10){
       x = x + 1;
      }
    }
  }
  
  if (x > 0){
    cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll X;
ll A5[2000];

int main()
{
    cin >> X;
    ll cnt = 0;
    for (ll i = -999; i <= 999; i++) {
        A5[cnt] = i * i * i * i * i;
        cnt++;
    }

    for (ll i = -999; i <= 999; i++) {
        for (ll j = -999; j <= 999; j++) {
            if (A5[i + 999] - A5[j + 999] == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void fun(db h[],lli n)
{
	lli i,j;
	db ans=0;
	vector<db>dp(n+1,0);
	dp[0]=1-h[1];dp[1]=h[1];
	for(i=2;i<=n;i++){
		vector<db>tdp=dp;
		dp[0]=tdp[0]*(1-h[i]);
		for(j=1;j<=i;j++){
			dp[j]=tdp[j]*(1-h[i])+tdp[j-1]*h[i];
		}
	}
	lli nn=(n+1)/2;
	for(i=nn;i<=n;i++)	ans+=dp[i];
	cout << fixed << setprecision(10);
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	//char ch;
	db aa,bb,cc;
	string s1,s2,s3,str;
    lli i,j,k,a,b,n,m,sum=0,temp,t;
    cin >> n >> m;
    char v[n+1][m+1];
    lli ans[n+1][m+1];
    rep(i,1,n+1){
    	rep(j,1,m+1){
    		cin >> v[i][j];
    		ans[i][j]=0;
		}
	}
	for(i=1;i<=m;i++){
		if(v[1][i]=='.')	ans[1][i]=1;
		else break;
	}
	for(i=1;i<=n;i++){
		if(v[i][1]=='.')	ans[i][1]=1;
		else	break;
	}
	for(i=2;i<=n;i++){
		for(j=2;j<=m;j++){
			if(v[i][j]=='#')	ans[i][j]=0;
			else{
				ans[i][j]=(ans[i-1][j]+ans[i][j-1])%M;
			}
		}
	}
	cout << (ans[n][m])%M << endl;
    
    return 0;
}

















/* UJJWAL KESHRI */

Measured memory_bytes: 9088
import sys

n, m = map(int, input().split())

conds = []
for _ in range(m):
  conds.append((input().split()))

for x in range(10 ** 3):
  xs = str(x)
  if len(xs) < n:
    continue

  found = True
  for cond in conds:
    s = int(cond[0]) - 1
    c = cond[1]
    if s >= len(xs):
      found = False
      break

    if xs[s] != c:
      found = False
      break

  if found:
    print(x)
    sys.exit()

print('-1')


Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void   ){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    long long ans=0;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    for(int i=0;i<n;i++){
        if((a[i]+ans)%b[i]!=0)ans+=b[i]-((a[i]+ans)%b[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
n,m = map(int, input().split())
P = [0]+list(map(int, input().split()))
XY = list(list(map(int, input().split())) for _ in range(m))
G = [[] for _ in range(n+1)]
for x, y in XY:
    G[x].append(y)
    G[y].append(x)

# print(n,m)
# print(P)
# print(XY)
# print(G)
# for i in range(len(G)):#########
#     print(i, G[i])###############

from collections import deque
q = deque()
vis = [False]*(n+1)
ans = 0
for i in range(1,len(G)):
    # print('i',i, 'G[i]',G[i])
    inc_x = set()
    inc_px = set()
    q.append(i)
    while q:
        # print(q)
        x = q.popleft()
        if vis[x]: continue
        vis[x] = True
        inc_x.add(x)
        inc_px.add(P[x])
        # print('x',x,'P[x]',P[x],'G[x]',G[x])
        for y in G[x]:
            # print('y',y)
            if vis[y]: continue
            q.append(y)
    # print('inc_x',inc_x)
    # print('inc_px',inc_px)
    # print('inc_x&inc_px',inc_x&inc_px)
    # print('len(inc_x&inc_px)',len(inc_x&inc_px))
    ans += len(inc_x & inc_px)

print(ans)


Measured memory_bytes: 54848
s = gets.chomp.to_s

len = s.length
las = len - 1
count = 0

len.times do |l|
  if len%2==0
    if s[l] != s[las]
      count +=1
    end
    las -=1
    if las == l
      break
    end
  else
    if s[l] != s[las]
      count +=1
    end
    if las == l
      break
    end
    las -=1
  end
end

puts count

Measured memory_bytes: 1916
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  myout(N.toString(K).length);
}


Measured memory_bytes: 30952
#include<stdio.h>
#include<math.h>
int range(double p,double q,double r){
  return (q<r?q:r)<p&&p<(q<r?r:q);
}
int rangea(double p,double q,double r){
  if(q*r<0&&fabs(q)+fabs(r)>M_PI){
    p+=2*M_PI*(p<0);
    q+=2*M_PI*(q<0);
    r+=2*M_PI*(r<0);
  }
  return range(p,q,r);
}
int cube(double x[],double y[]){
  if(rangea(atan2(y[1]-y[0],x[1]-x[0]),atan2(y[1]-y[2],x[1]-x[2]),atan2(y[1]-y[3],x[1]-x[3])))
    if(rangea(atan2(y[2]-y[0],x[2]-x[0]),atan2(y[2]-y[1],x[2]-x[1]),atan2(y[2]-y[3],x[2]-x[3])))
      return 1;
  return 0;
}
int main(){
  int i;
  double x[4],y[4],s;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=-1){
    for(i=0;;){
      if(cube(x,y))
	break;
      i++;
      if(i>3)
	break;
      s=x[0];
      x[0]=x[i];
      x[i]=s;
      s=y[0];
      y[0]=y[i];
      y[i]=s;
    }
    if(i==4)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    ll cnt_odd=0;
    ll cnt_2=0;
    ll cnt_4=0;
    rep(i,n){
        ll a;
        cin >> a;
        if(a%4==0) cnt_4++;
        else if(a%2==0) cnt_2++;
        else cnt_odd++;
    }
    if(cnt_2) cnt_odd++;
    if(cnt_4>=cnt_odd-1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

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

int N,i,dp[100001];

int main(void){
  cin >> N;
  for(i=0;i<=N;i++){
    dp[i]=0;
  }
  int q=6,w=9;
  for(i=1;i<=N;i++){
    if(i>=6*q){
      q = q * 6;
    }
    if(i>=9*w){
      w = w * 9;
    }
    if(i<6){
      dp[i]=i;
    }else if(i<9){
      dp[i] = min(dp[i-1]+1,dp[i-q]+1);
    }else if(i>=9){
      dp[i] = min(dp[i-1]+1,dp[i-q]+1);
      dp[i] = min(dp[i],dp[i-w]+1);
    }
  }
  printf("%d\n",dp[N]);
  return 0;
}


Measured memory_bytes: 3948
n = int(input())

ans = 0
if len(str(n)) == 1:
    ans = n
elif len(str(n)) == 2:
    ans = 9
elif len(str(n)) == 3:
    ans = 9 + (n-99)
elif len(str(n)) == 4:
    ans = 909
elif len(str(n)) == 5:
    ans = 909 + (n-9999)
else:
    ans = 90909
print(ans)

Measured memory_bytes: 8920
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = Arrays.asList(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);
        int K = sc.nextInt();
        System.out.println(list.get(K-1));
    }
}

Measured memory_bytes: 22356
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  int H, W;
  std::cin >> H >> W;
  char inMap[H][W];
  char calcMap[H][W];
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      std::cin >> inMap[y][x];
      calcMap[y][x] = 0;
    }
  }
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (inMap[y][x] != '#') continue;
      if (y > 0) calcMap[y - 1][x]++;
      if (x > 0) calcMap[y][x - 1]++;
      if (x < W - 1) calcMap[y][x + 1]++;
      if (y < H - 1) calcMap[y + 1][x]++;
      if (y > 0 && x > 0) calcMap[y - 1][x - 1]++;
      if (y > 0 && x < W - 1) calcMap[y - 1][x + 1]++;
      if (y < H - 1 && x > 0) calcMap[y + 1][x - 1]++;
      if (y < H - 1 && x < W - 1) calcMap[y + 1][x + 1]++;
    }
  }
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (inMap[y][x] == '#')
        std::cout << "#";
      else
        std::cout << (int)calcMap[y][x];
    }
    std::cout << std::endl;
  }
  return 0;
}


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

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

  while(1){
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    else if(a<=0){
      cout << "No" << endl;
      return 0;
    }
    else{
      a -= d;
      c -= b;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
char A[6],B[6];
int main(){
	scanf("%s%s",A+1,B+1);
	int cnt=0;
	for(int i=1;i<=3;i++)if(A[i]==B[i])cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
using System;

class PrintTestCases{
        static void Main(string[] args){
          int i = 1;
          while(true){
	    int x = int.Parse(Console.ReadLine());
	    if(x == 0) break;
	    Console.WriteLine("Case {0}: {1}",i,x);
	    i++;
	  }
	}
}

Measured memory_bytes: 9316