akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import static java.lang.Math.min;

/**
 * Created by shoya on 2017/04/11.
 */
public class Main {
    final int INF = 100_000_000;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        PriRMQ rmq = new PriRMQ(n);
        for (int i = 0; i < q; i++){
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (com == 0)
                rmq.update(x, y);
            else
                System.out.println(rmq.find(x, y + 1, 0, 0, rmq.size));

            //System.out.printf("%d %d %d\n", com, x, y);
            //rmq.print();
            //System.out.println("\n");
        }
    }

    private static class PriRMQ {
        final long INF = (1 << 31) - 1;
        long nodes[];
        int size;

        PriRMQ(int n){
            int c = 1;
            while (n >= c) c *= 2;
            nodes = new long[2 * c - 1];
            size = c;
            for (int i = 0; i < 2 * c - 1; i++)
                nodes[i] = INF;
        }

        void update(int node, int val){
            int child = node + size - 1;
            nodes[child] = val;
            while (child != 0){
                child = (child - 1) / 2;
                nodes[child] = min(nodes[child * 2 + 1], nodes[child * 2 + 2]);
            }
        }

        long find(int queryl, int queryr, int root, int left, int right){
            //System.out.printf("%d <--> %d - %d <--> %d - Val %d\n", queryl, queryr, left, right, root);
            if (right <= queryl || queryr <= left)
                return INF;
            if (queryl <= left && right <= queryr)
                return nodes[root];

            long vl = find(queryl, queryr, root * 2 + 1, left, (left + right) / 2);
            long vr = find(queryl, queryr, root * 2 + 2, (left + right) / 2, right);
            return min(vl, vr);
        }

        void print(){
            int tmp = 1;
            for (int i = 0; i < 2 * size - 1; i++){
                if (i == tmp) {
                    System.out.println();
                    tmp += ((tmp + 1) / 2) * 2;
                }
                System.out.printf("%d ", nodes[i]);
            }
        }

    }
}

Measured memory_bytes: 107336
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cstring>
#include <string>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	int sum = 0;
	for (int i = 0; i < n - 1; i++)sum += a[i];
	sum += a[n - 1] / 2;
	cout << sum;
}

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

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

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g*b;
}

int main(){
    int N;
    cin >> N;
    ll ans = 1LL;
    for(int i=0;i<N;i++){
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
coord_student = [list(map(int,input().split())) for i in range(n)]
coord_check =  [list(map(int,input().split())) for i in range(m)]

for stu in range(n):
  ans = float("inf")
  for che in range(m):
    tmp_ans = abs(coord_student[stu][0]-coord_check[che][0])+abs(coord_student[stu][1]-coord_check[che][1])
    if tmp_ans < ans:
      ans = tmp_ans
      index = che
  print(index+1)
    

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


int main(){
    int N, H, W; cin >> H >> W >> N;
    cout << (N + max(H,W) - 1) / max(H, W) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef uint64_t u64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void set_at (u64 *a, i32 x) {
  i32 q = x / 64;
  i32 r = x % 64;
  a[q] |= (u64)1 << r;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  u64 **win = ALLOC (n, u64 *);
  u64 **dp = ALLOC (n, u64 *);
  i32 len = (n + 63) / 64;
  u64 *buf = ALLOC (2 * len * n, u64);
  for (i32 i = 0; i < n; ++i) {
    win[i] = buf;
    buf += len;
    dp[i] = buf;
    buf += len;
    set_at(dp[i], i);
  }
  char *s = ALLOC (n + 1, char);
  for (i32 i = 1; i < n; ++i) {
    scanf ("%s", s);
    for (i32 j = 0; j < i; ++j) {
      if (s[j] == '1') {
        set_at(win[i], j);
      } else {
        set_at(win[j], i);
      }
    }
  }
  for (i32 len = 2; len <= n; ++len) {
    for (i32 l = 0; l <= n - len; ++l) {
      i32 r = l + len - 1;
      i32 s = l / 64;
      i32 t = r / 64 + 1;
      for (i32 i = s; i < t; ++i) {
        if (win[l][i] & dp[l + 1][i] & dp[r][i]) {
          set_at(dp[r], l);
          break;
        }
      }
      for (i32 i = s; i < t; ++i) {
        if (win[r][i] & dp[l][i] & dp[r - 1][i]) {
          set_at(dp[l], r);
          break;
        }
      }
    }
  }
  i32 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 q = i / 64;
    i32 r = i % 64;
    ans += (dp[n - 1][q] >> r) & (dp[0][q] >> r) & 1;
  }
  printf("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1152
// 2:21
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
using ll = long long;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 0
#if DEBUG
    #define dump(var) dump2(STRING(var), var)
#else
    #define dump(var)
#endif

template <typename T>
void dump2(const string& name, const T& value)
{
    cerr << name << ": " << value << endl;
}
void dump2(const string& name, const tuple<ll,ll,ll>& value)
{
    ll a,b,c;
    tie(a,b,c) = value;
    cerr << name << ": (" << a << ", " << b << ", " << c << ")" << endl;
}

template <typename T>
void print(const T& value)
{
    cout << value << endl;
}


void solve()
{
    char s[1000] = {0};
    scanf("AtCoder %s Contest", s);
    printf("A%cC\n", s[0]);
}

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


Measured memory_bytes: 256
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;

int n,a;
int cnt[250] = {0};
int q1[250] = {0},q2[250] = {0},h1 = 0,h2 = 0;
int q[250] = {0},h = 0;
int ans,maxn = 0;

int main(){
	scanf("%d",&n); cnt[0] = 1;
	for(int i = 1;i <= n;i ++){
		scanf("%d",&a);
		cnt[a] ++;
	}
	for(int i = 0;i <= 12;i ++){
		if(cnt[i] >= 3){
			printf("0\n");
			return 0;
		}
		if(cnt[i] == 1) q1[++ h1] = i;
		if(cnt[i] == 2){
			q2[++ h2] = i;
			q2[++ h2] = 24 - i;
		}
	}
	for(int i = 0;i < (1 << (h1 + 1));i += 2){
		h = 0; ans = 25;
		for(int j = 1;j <= h1;j ++){
			if(i & (1 << j)) q[++ h] = q1[j];
			else q[++ h] = 24 - q1[j];
		}
		for(int j = 1;j <= h2;j ++) q[++ h] = q2[j];
		q[++ h] = 24;
		sort(q + 1,q + 1 + h);
		for(int i = 2;i <= h;i ++) ans = min(ans,q[i] - q[i - 1]);
		maxn = max(maxn,ans);
	}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
SP = [list((input().split())) for i in range(N)]
for i in range(len(SP)):
  SP[i][1] = int(SP[i][1])
  SP[i].append(i+1)

tmp = sorted(SP, key=lambda x:(x[0], x[1]), reverse=True)
tmp2 = sorted(tmp, key=lambda x:x[0])
for j in tmp2:
  print(j[2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int ans[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b,k,t=0;
	cin>>a>>b>>k;
	int d=0;
	for(int i=1;i<=10000;i++)
	{
		if(a%i==0&&b%i==0)
			ans[d++]=i;

	}
	cout<<ans[d-k];
	return 0;
}


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

int main(){
  int k;
  string s;
  cin >> k >> s;
  int l = s.size();
  if(l<=k){
    cout << s;
    return 0;
  }
  for(int i=0;i<k;i++) cout << s[i];
  cout << "...";
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
h = list(map(int, input().split()))
ok =[True] * n
for i in range(m):
    a, b = list(map(int,input().split()))
    if h[a-1] > h[b-1]:
        ok[b-1] = False
    elif h[b-1] > h[a-1]: 
        ok[a-1] = False
    else:
        ok[a-1] = False
        ok[b-1] = False
print(ok.count(True))

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005



int32_t main(){
sp;
    string s,t;
    int ans=0;
    cin>>s>>t;
    for(int i=0; i<s.size(); ++i)
        ans+=(s[i]==t[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    
    int n;
    while(cin>>n,n){
        char c;
        vc v; vc v2;
        map<char,int>m;
        pair<char, int>ans; ans.second=-INF;
        rep(i,n){
            cin>>c;
            auto itr=m.find(c);
            if(itr==m.end()){v.push_back(c);}
            m[c]++;
            ans.second=max(ans.second,m[c]);
            v2.push_back(c);
        }
        rep(i,v.size()){if(m[v[i]]==ans.second)ans.first=v[i];}
        bool flag=true;
        rep(i,v.size())if(v[i]!=ans.first&&ans.second==m[v[i]]){cout<<"TIE"<<endl;flag=false; break;}
        if(v.size()==1){cout<<v[0]<<" "<<n/2+1<<endl; flag=false;}
        if(flag){
            int cnt=0; int n2=(int)v2.size(); int hoge=1;
            map<char,int>temp;
            rep(i,v2.size()){
                bool check=true;
                if(ans.first==v2[i])cnt++;
                else temp[v2[i]]++;
                n2--;
                rep(j,v.size())if(temp[v[j]]+n2>=cnt&&v[j]!=ans.first)check=false;
                if(check) break;
                hoge++;
                
            }
            cout<<ans.first<<" "<<hoge<<endl;
        }
    }
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const int N=2e5+5;
int cnt[N];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        int x;
        mem(cnt,0);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            cnt[x]++;
        }
        sort(cnt,cnt+N,cmp);
        int ans=0;
        for(int i=k;cnt[i];i++) ans+=cnt[i];
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
S = [int(x) for x in list(map(int, input().split()))]
q = int(input())
T = [int(x) for x in list(map(int, input().split()))]

def search(S, n, key):
  i = 0
  S[n] = key
  while (S[i] != key):
    i += 1
  return i != n

S.append(0)
count = 0
for a in T:
  if (search(S, n, a)):
    count += 1

print (count)


Measured memory_bytes: 6556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final FastIn in = new FastIn();
	private static final PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		Solver sol = new Solver();
		sol.solve();
		out.close();
	}

	private static final class Solver {
		public void solve() {
			int n = in.nextInt(), k = in.nextInt(), x = in.nextInt(), y = in.nextInt();
			if (n - k < 0) {
				out.println(n * x);
			} else {
				int ans = k * x + (n - k) * y;
				out.println(ans);
			}
		}
	}

	private static final class FastIn {
		private BufferedReader br;
		private StringTokenizer st;

		public FastIn() {
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
			st = null;
		}

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

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


Measured memory_bytes: 34660
#include <stdio.h>
int main(){  
  int n,i,j,count=0,s,k;
  scanf("%d", &n);
  int A[n];
  
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  for (i = 0;i < n-1; i++){
    for (j = n - 1; j > i; j--){
      if (A[j - 1] > A[j]){
	  s = A[j];
	  A[j] = A[j - 1];
	  A[j - 1] = s;
	  count++;
	}
      }
    }
  
     for(k=0; k<n; k++){
      printf("%d",A[k]);
      if ( k != n - 1)printf(" ");
    }
     printf("\n%d\n",count);
     return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> count(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  sort(s.begin(), s.end());
  
  for(int i = 0; i < n; i++){
    if(i == 0){
      count[i] = 1;
    }
    else if(s[i-1] == s[i]){
      count[i] = count[i-1] + 1;
    }
    else{
      count[i] = 1;
    }
  }
  
  int m = 0;
  for(int i = 0; i < n; i++){
    m = max(m, count[i]);
  }
  
  for(int i = 0; i < n; i++){
    if(count[i] == m){
      cout << s[i] << endl;
    }
  }
}

Measured memory_bytes: 15104
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
set<string> st;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    string si;
    cin >> si;
    st.insert(si);
  }

  int ans = st.size();
  cout << ans << endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> A(N);
	REP(i, N) cin >> A[i];
	map<int64, int64> mp;
	REP(i, N) mp[A[i]]++;
	vector<int64> B;
	B.push_back(0);
	for (auto x : mp) {
	  B.push_back(x.sc);
	}
	vector<int64> cnt;
	sort(all(B));
	REP(i, B.size()-1) {
	  if (B[i+1]-B[i] > 0) {
	    REP(j, B[i+1]-B[i]) {
        cnt.emplace_back(B.size() - i - 1);
      }
    }
	}
	while (cnt.size() < N) cnt.emplace_back(0);
	vector<int64> res(N, 0);
	int64 idx = 0, rest = 0;
	for (int64 i = N; i >= 1; i--) {
	  while (idx < cnt.size() && cnt[idx] > i) {
	    idx++;
	  }
	  rest += idx;
	  while (idx < cnt.size() && cnt[idx] == i) idx++;
	  if (cnt[idx] < i) {
	    if (rest <= 0) {
      } else {
	      while (idx < cnt.size() && rest > 0) {
          int64 sub = min(i - cnt[idx], rest);
          rest -= sub;
          cnt[idx] += sub;
          if (cnt[idx] == i) idx++;
        }
	    }
	  }
	  res[i-1] = idx + (cnt[idx] == i);
	}
	REP(i, N) {
	  cout << res[i] << endl;
	}
}


Measured memory_bytes: 32236
n=int(input())
line=[list(map(int,input().split())) for i in range(2)]
#print(line)
j=0
for i in range(1,n+1):
    a=line[0][0:i]
    b=line[1][i-1:]
    k=(sum(a)+sum(b))
    j=max(j,k)
print(j)

Measured memory_bytes: 3060
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

total = a.sum
next_eda = 1

ans = 0
(n+1).times do |i|
  eda = next_eda

  ans += eda

  aa = a[i]

  if eda < aa
    p -1
    exit
  end

  if eda == aa
    if i == n
      p ans
    else
      p -1
    end
    exit
  end

  eda -= aa
  total -= aa

  next_eda = [eda * 2, total].min
end


Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = INF;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> H >> W >> K;
    vvi s(H, vi(W, 0));
    REP(h, H) {
        cin >> S;
        REP(w, W) {
            if (S[w] == '1')
                s[h][w] = 1;
            else
                s[h][w] = 0;
        }
    }
    if (H == 1) {
        int k = 0;
        REP(w, W) {
            if (s[0][w]) {
                k++;
            }
            if (k > K) {
                k = 0;
                w = w - 1;
                ans++;
            }
        }
        cout << ans << endl;
        return 0;
    }
    for (int bit = 0; bit < (1 << (H - 1)); bit++) {
        vi mem;
        mem.push_back(0);
        REP(i, H - 1) {
            if ((bit >> i) & 1) {
                mem.push_back(i + 1);
            }
        }
        mem.push_back(H);
        dump(mem);
        int n = mem.size() - 2;
        vi k(mem.size() - 1, 0);
        int prev = 0;
        REP(w, W) {
            for (int i = 0; i < mem.size() - 1; i++) {
                for (int h = mem[i]; h < mem[i + 1]; h++) {
                    if (s[h][w]) {
                        k[i]++;
                    }
                }
                if (k[i] > K) {
                    if (prev == w) {
                        goto CONTINUE;
                    }
                    prev = w;
                    REP(j, k.size())
                    k[j] = 0;
                    w = w - 1;
                    n++;
                    break;
                }
            }
        }
        ans = min(n, (int)ans);
    CONTINUE:
        continue;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int x;
    cin>>x;
    if(x >= 400 && x < 600){
        cout<<8<<endl;
    }else if(x >= 600 && x < 800){
        cout<<7<<endl;
    }else if(x >= 800 && x < 1000){
        cout<<6<<endl;
    }else if(x >= 1000 && x < 1200){
        cout<<5<<endl;
    }else if(x >= 1200 && x < 1400){
        cout<<4<<endl;
    }else if(x >= 1400 && x < 1600){
        cout<<3<<endl;
    }else if(x >= 1600 && x < 1800){
        cout<<2<<endl;
    }else if(x >= 1800 && x < 2000){
        cout<<1<<endl;
    }
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cctype>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
int n,a[200005]={-1};
int main(){
	n=read<int>();reg ll ans=0;
	for(reg int i=1;i<=n;i++)
		if((a[i]=read<int>())-a[i-1]>1)return 0*puts("-1");
	for(reg int i=2;i<=n;i++)
		if(a[i]>a[i-1])ans++;
		else ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
# 153_b
# B - Common Raccoon vs Monster
import random

H, N = map(int, input().split())
A = input().split()
for i in range(N):
    A[i] = int(A[i])

if (1 <= H, H <= 10 ** 9) and (1 <= N, N <= 10 ** 5):
    for j in range(len(A)):
        H -= A[j]
    if H <= 0:
        print('Yes')
    if H > 0:
        print('No')

Measured memory_bytes: 17404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    UnionFind d(n);
    rep(i, q) {
        ll t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        }
        else {
            cout << (d.is_same(u, v) ? 1 : 0) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3932
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n;

	cin >> n;

	vector<ll> v(n);

	REP(i, n) {
		ll a;
		cin >> a;
		v[a - 1] = i;
	}

	v.push_back(-INF);

	ll ans = 0;
	ll count = 0;

	REP(i, n) {
		if (v[i] < v[i + 1]) {
			count++;
		}
		else {
			count++;
			if (count > ans) {
				ans = count;
			}
			count = 0;
		}
	}

	cout << n - ans << endl;
}

Measured memory_bytes: 4864
var
    a,b,c,t:longint;
begin
    read(a,b,c);
    if a<b then
    begin
        t:=a; a:=b; b:=t;
    end;
    if a<c then
    begin
        t:=a; a:=c; c:=t;
    end;
    if (a=7) and (b=5) and (c=5) then writeln('YES')
    else writeln('NO');
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
const int MOD = int(1e9) + 7;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vec64 arr (n + 1);
    for (int i = 1; i <= n; i++){
        cin >> arr[i];
    }
    vec64 p (n + 1, 0);
    for (int i = 1; i <= n; i++){
        p[i] = (arr[i] + p[i-1]) % MOD;
    }
    vec64 d (n+1, 0);
    for (int i = 1; i < n; i++){
        d[i] = p[n] - p[i];
    }
    int64 rs = 0;
    for (int i = 1; i < n; i++){
        // db(arr[i]);
        rs = (rs + (arr[i] * ((d[i] + MOD) % MOD))) %MOD;
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 7912
while True:
    n = int(raw_input())
    if n == 0:
        break
    li = []

    for i in xrange(n):
        p = int(raw_input())
        if i == 0:
            li.append([p, 1])
            continue
        # odd
        if i % 2 == 0:
            if li[-1][0] == p:
                li[-1][1] += 1
            else:
                li.append([p, 1])
        else:
            if li[-1][0] == p:
                li[-1][1] += 1
            else:
                li[-1][0] = p
                li[-1][1] += 1
                if len(li) >= 2 and li[-2][0] == li[-1][0]:
                    li[-2][1] += li[-1][1]
                    del li[-1]

    print sum(t[1] for t in li if t[0] == 0)

Measured memory_bytes: 4260
import sys


def r(n, x, al):
    al.sort()
    for i in range(n):
        if x < al[i]:
            break
        elif x >= al[i]:
            x -= al[i]
        if x == 0:
            i += 1
            break

    return i


def main():
    input = sys.stdin.readline
    n, x = list(map(int, input().split()))
    al = list(map(int, input().split()))
    print(r(n, x, al))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<list>

using namespace std;

int main() {
	int N, K;
	int x, sum = 0;
	list<int> p;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> x;
		p.push_back(x);
	}
	p.sort();
	auto itr = p.begin();
	for (int i = 0; i < K;i++) {
		sum += *itr;
		++itr;
	}
	cout << sum << endl;

	return 0;
}

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

typedef long long ll;

const int MAXN = 2e5 + 5;

const ll P = ((ll)1e9) + 7;

int n;
ll a, b, c, A, B;
ll pw[3][MAXN];

ll inv(ll x) {
	ll ret = 1;
	for(int p = P - 2; p; p >>= 1) {
		if(p & 1) {
			ret *= x;
			ret %= P;
		}
		x *= x;
		x %= P;
	}
	if(ret < 0) ret += P;
	return ret;
}

int main() {
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	cin >> a >> b >> c;
	
	A = a * inv(100) % P;
	B = b * inv(100) % P;
	c *= inv(100);
	c %= P;
	
	ll ans = 0;
	
	ll cnk = 1;
	
	pw[0][0] = pw[1][0] = pw[2][0] = 1;
	for(int i = 1; i < 2*n; i++) {
		pw[0][i] = (pw[0][i-1] * A) % P;
		pw[1][i] = (pw[1][i-1] * B) % P;
		pw[2][i] = (pw[2][i-1] * (A+B)) % P;
	}
	
	for(int m = n; m < 2*n; m++) {
		ll add = m * inv(1 - c);
		add %= P;
		
		ll prob = (cnk * inv(pw[2][m])) % P;
		ll s1 = ((pw[0][n-1] * pw[1][m-n]) % P * A) % P;
		ll s2 = ((pw[1][n-1] * pw[0][m-n]) % P * B) % P;
		prob *= (s1 + s2) % P;
		prob %= P;
		ans += (prob * add) % P;
		ans %= P;
		
		cnk *= m;
		cnk %= P;
		cnk *= inv(m+1-n);
		cnk %= P;
	}
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cnt = 100;
		char[][] g = new char[cnt][cnt];
		for(int i = 0; i < cnt/2; i++) {
			for(int j = 0; j < cnt; j++) {
				g[i][j] = '#';
			}
		}
		for(int i = cnt/2; i < cnt; i++) {
			for(int j = 0; j < cnt; j++) {
				g[i][j] = '.';
			}
		}

		int anum = 1;
		int bnum = 1;

		if(a != 1) {
			for(int i = 0; i < cnt/2; i+=2) {
				for(int j = 0; j < cnt; j+=2) {
					g[i][j] = '.';
					anum++;
					if(anum == a)
						break;
				}
				if(anum == a)
					break;
			}
		}
		if(b != 1) {
			for(int i = cnt-1; i > cnt/2+1; i-=2) {
				for(int j = 0; j < cnt; j+=2) {
					g[i][j] = '#';
					bnum++;
					if(bnum == b)
						break;
				}
				if(bnum == b)
					break;
			}
		}
		
		System.out.println(cnt + " " + cnt);
		for(int i = 0; i < cnt; i++) {
			for(int j = 0; j < cnt; j++) {
				System.out.print(g[i][j]);
			}
			System.out.println("");
		}
	}
}


Measured memory_bytes: 26708
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
vector<int> V[100010];
bool used[100010];

int all_used(int v) {
  for (auto x : V[v]) {
    if (!used[x]) return x;
  }
  return -1;
}

int main () {
  cin >> N >> M;
  for (auto i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  deque<int> Q;
  Q.push_back(0);
  fill(used, used+100010, false);
  used[0] = true;
  int v;
  while ((v = all_used(Q.back())) != -1) {
    // cerr << v << endl;
    Q.push_back(v);
    used[v] = true;
  }
  while ((v = all_used(Q.front())) != -1) {
    Q.push_front(v);
    used[v] = true;
  }
  cout << Q.size() << endl;
  for (auto it = Q.begin(); it != Q.end(); ++it) {
    cout << (*it) + 1;
    if (it+1 == Q.end()) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}


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


typedef long long ll;

int main() {
  ll a, b, n; cin >> a >> b >> n;
  if (n >= b-1) cout << a*(b-1)/b << endl;
  else cout << a*n/b << endl;
}


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

using namespace std;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
//s = char []
#define ss(s) scanf("%s",&s)
//s = string to read with spaces
#define read(s) getline(cin,s)

using namespace std;

int main()
{
    int n,x;
    si(n);
    int arr[100001] = {0};
    for(int i=0;i<n;i++){
        si(x);
        arr[x]++;
    }
    int i=1,j=100000,ans = 0;
    for(;i<=j;){
        while(i<= j && (arr[i] == 1 || arr[i] == 0)){
            if(arr[i] == 1)
                ans++;
            i++;
        }
        while(j>=i && (arr[j] == 1 || arr[j] == 0)){
            if(arr[j] == 1)
                ans++;
            j--;

        }
        if(i<= j)arr[i]--;
        if(j>= i)arr[j]--;
    }
    cout << ans;
    return 0;
}


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


int main()
{

    string str ;
    cin >> str;

    if(str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I')
        cout << "Yes\n";
    else
        cout << "No\n" ;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int n;
char c;
ll a[200001];
ll num[2][2020];
int main()
{
    int n=0;
    while (1)
    {
        scanf("%c",&c);
        if (c>='1' && c<='9')
            a[n]=c-'0';
        else 
            break;
        n++;
    }
    ll res=0;
    for (int i=0; i<n; ++i)
    {
        if (i>0)
            for (int j=0; j<2019; ++j)
                num[1][(j*10+a[i])%2019]=num[0][j];
        num[1][a[i]]+=1;
        res+=num[1][0];
        for (int j=0; j<2019; ++j)
            num[0][j]=num[1][j];
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 5108
require 'set'

def main
    k = gets.to_i
    a,b = gets.chomp.split(" ").map(&:to_i)

    if (b-a)>=k || b%k < a%k || a%k == 0
        puts "OK"
    else 
        puts "NG"
    end
end

main

## イディオムなど
# until s.empty? do
#
## 配列のインデックス
# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
#
## 全探索
# [0, 1].repeated_permutation(n) do |combination| # bit全探索
# array.combination(i) do |selected| # array から要素が i 個である部分列を全部抽出
#
## 無向グラフの幅優先探索(BFS)
# to = Array.new(n).map{Array.new()} # ある頂点と繋がる頂点のリスト
# m.times do
#     a,b = gets.chomp.split(" ").map(&:to_i)
#     to[a].push b
#     to[b].push a
# end
# q = Queue.new # BFS は queue
# ds = Array.new(n, -1)
# pre = Array.new(n, -1)
#
## その他
# a1 = Marshal.load(Marshal.dump(a2)) # 深いコピー
# matrix = Array.new(n).map{Array.new()} # 二次元配列の初期化
# 

Measured memory_bytes: 14472
import sys

def main2():
    n,y=map(int,input().split())
    for i in range(n+1):
        for j in range(n+1-i):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                print("{} {} {}".format(i,j,n-i-j))
                sys.exit()
    print(-1,-1,-1)

if __name__=="__main__":
    main2()

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

const double pi = 3.141592653589;

int32_t main()
{
    IOS;

    int tt=1;
	//cin >> tt;
	while (tt--)
	{
		cout << fixed << setprecision(12);
		int r; cin >> r;
		cout << 2 * pi * r << endl;
	}
    return 0;
}


Measured memory_bytes: 3788
n = int(input())
p = list(map(int, input().split()))

L=[]
for i in range(n):
    if i+1 !=p[i]:
        L.append([i, p[i]])
    if len(L)==2:
        break


if len(L)<=1:
    print('YES')
else:
    p[L[0][0]] = L[1][1]
    p[L[1][0]] = L[0][1]
    if p == sorted(p):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 10000

struct node{
  struct node *r,*l,*p;
  int key;
};

typedef struct node * Node;

#define NIL NULL

int t[MAX];
Node root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }else{
      x=x->r;
    }
  }
  z->p=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->l=z;
    }else{
      y->r=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}
  
int main(){
  int n,i,x;
  char s[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(strcmp(s,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
  
  



Measured memory_bytes: 25128
package main

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

func main() {
	scn := newScanner()
	N := scn.nextInt()
	C := scn.nextInt()
	K := scn.nextInt()
	T := make([]int, N)
	for i := 0; i < N; i++ {
		T[i] = scn.nextInt()
	}
	sort.Ints(T)
	var i int
	bas := make([]int, 0)
	for i < N {
		bas = append(bas, T[i]+K)
		j := i
		cnt := 0
		for i < N && j < N && T[i]+K >= T[j] {
			j++
			cnt++
			if cnt == C {
				break
			}
		}
		i = j
	}
	// log.Println(K)
	// log.Println(bas)
	fmt.Println(len(bas))
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextInt64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
int cnt[SIZE];
int main(){
    DRI(N);
    REP(i,N){
        DRI(x);
        cnt[x]++;
    }
    int an=0;
    REPP(i,1,SIZE-1){
        an=max(an,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    printf("%d\n",an);
    return 0;
}


Measured memory_bytes: 640
N,x,*a = map(int, open(0).read().split())
cnt = 0
for i, a_ in enumerate(sorted(a)):
  x -= a_
  if not i == len(a)-1:
    if 0 <= x:
      cnt += 1
    else:
      break
  else:
    if x == 0:
      cnt += 1
    else:
      break
print(cnt)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
    long int k;
    string s;

    cin>>k>>s;

    if(s.size() > k)
      cout<<s.substr(0,k)<<"...";
    else
      cout<<s;
   return 0;
}


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

# define ll long long 
# define VI vector<int>
# define VL vector<ll>
# define PII pair<int,int> 
# define VII vector<PII>
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
# define FOR(i,a,b) for(int i = a ; i < b ; ++i) 
const ll inf = 1e18 ; 
const int MxN = 200000 ; 

int n ; 



void solve() {
	cin >> n ; 
	VI a(n+1) ; 
	VI copy = a; 
	FOR(i,1,n+1) 
		cin >> a[i] ; 
	int ans = 0 ; 
	FOR(i,1,n) {
		if(a[i] == i && a[i+1] == i+1 ) {
			ans++; 
			swap(a[i],a[i+1]) ; 
			i++;
		}
		if(a[i] == i && a[i+1] != i+1) {
			ans++;
			swap(a[i],a[i+1]) ; 
			i++;
		}
	}
	if(a[n] == n)
		ans++;
	

	cout << ans ; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int  t =1; 
	//cin >> t ; 
	while(t--)
		solve() ; 
	return 0 ; 
}



Measured memory_bytes: 3976
s = list(input())
n = len(s)
s.reverse()
m = 10**9 + 7
p = 10
dp = [[0 for i in range(13)] for j in range(n)]
if s[0] == "?":
    for i in range(10):
        dp[0][i] = dp[0][i] + 1
else:
    s0 = int(s[0])
    dp[0][s0] = dp[0][s0] + 1
for i in range(1,n):
    if s[i] != "?":
        s1 = int(s[i])
        k = (s1*p)%13
        for j in range(13):
            dp[i][(j+k)%13] = dp[i-1][j]
    else:
        for x in range(10):
            k = (x*p)%13
            for j in range(13):
                dp[i][(j+k)%13] += dp[i-1][j]
                dp[i][(j+k)%13] %= m
    p = (p * 10) % 13
print(dp[n-1][5])

Measured memory_bytes: 69768
fun main() {
    var num = 0
    next().forEach {
        if (it == '+') {
            num++
        } else {
            num--
        }
    }
    println(num)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 34536
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<int> v(N);
    iota(all(v), 1);
    vector<int> p(N), q(N);
    scan(p);
    scan(q);

    int a, b;
    int i = 1;
    do {
        if (v == p)
            a = i;
        if (v == q)
            b = i;
        i++;
    } while (next_permutation(all(v)));
    print(abs(a - b));

    return 0;
}

Measured memory_bytes: 256