akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define DEBUG
#undef DEBUG

int N;
string S;

int main()
{
    cin >> N;
    cin >> S;

    int lparen = 0;
    int rparen = 0;
    int level = 0;
    for(char c : S) {
        if(level >= 0) {
            if(c == '(')
                ++level;
            else if(c == ')')
                --level;
        }
        else {
            if(c == '(') {
                lparen += -level;
                level = 1;
            }
            else if(c == ')') {
                --level;
            }
        }
    }
    if(level >= 0)
        rparen += level;
    else
        lparen += -level;

    cout << string(lparen, '(') << S << string(rparen, ')') << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, m;
    int l[105];
    cin >> n >> m;
    l[0] = 0;

    int d[105] = {0};

    for(int i = 0; i <n; ++i){
        cin >> l[i];
    }

    for(int i = 1; i <= n; i++){
        d[i] = d[i-1] + l[i-1];
    }

    int ans = 0;

    REP(i, n+1){
        if(d[i] <= m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 14
#define M 1000000

char G[M][N];
int top=0;


int getChar(char c){
  if(c=='A')return 1;
  else if(c == 'C')return 2;
  else if(c=='G')return 3;
  else if(c=='T')return 4;
  else return 0;
}

int getdata(char a[]){
  int sum=0;
  int p=1,i;
  for(i=0;i<strlen(a);i++){
    sum += p*(getChar(a[i]));
    p *= 5;
  }
  return sum;
}

int g1(int data){return data % M;}
int g2(int data){return 1+(data % (M-1));}

int finddata(char a[]){
  int key,i,g;
  key = getdata(a);
  i=0;
  while(1){
    g = (g1(key)+ i*g2(key))%M;
    if(strcmp(G[g],a)==0) return 1;
    else if(strlen(G[g])==0) return 0;
    i++;
  }
  return 0;
}

int insert(char a[]){
  int key,i,g;
  key = getdata(a);
  i=0;
  while(1){
    g = (g1(key) + i*g2(key))%M;
    if(strcmp(G[g],a)==0)return 1;
    else if(strlen(G[g])==0){
      strcpy(G[g],a);
      return 0;
    }
    i++;
  }
  return 0;
}



int main(){
  int i,j=0,b,k;
  char a[M][3],c[M],d[M];

  for(i=0;i<M;i++){
    G[i][0] = '\0';
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%s%s",a[i],c);
  if(a[i][0] == 'i'){
    insert(c);
  }
  else{
    if(finddata(c)){
      printf("yes\n");
     
    }
    else{
      printf("no\n");
     
    }
  }
}
return 0;
}

Measured memory_bytes: 17216
#include<bits/stdc++.h>
using namespace std;
int main()
{
//    freopen("in.txt","rt",stdin);
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int A,B,C,D,E;
    A=a,B=b,C=c,D=d,E=e;
    while(A>10){
        A%=10;
    }
    while(B>10){
        B%=10;
    }
    while(C>10){
        C%=10;
    }
    while(D>10){
        D%=10;
    }
    while(E>10){
        E%=10;
    }
    int arr[6];
//    cout<<A<<B<<C<<D<<E<<endl;
    arr[0]=A;
    arr[1]=B;
    arr[2]=C;
    arr[3]=D;
    arr[4]=E;
    int minm ,flag=0;
    for(int i=0;i<=4;i++){
        if(flag==0 and arr[i]!=0){minm=arr[i];flag=1;}
        else if(arr[i]!=0 and arr[i]<minm){minm=arr[i];}
    }
//    cout<<minm<<endl;
    int as,bs,cs,ds,es;
    if(A!=0)as=10-A;
    else as=0;
    if(B!=0)bs=10-B;
    else bs=0;
    if(C!=0)cs=10-C;
    else cs=0;
    if(D!=0)ds=10-D;else ds=0;
    if(E!=0)es=10-E;else es=0;
    int sum=0;
    if(minm==A){sum+=a+b+bs+c+cs+d+ds+e+es;cout<<sum<<endl;}
    else if(minm==B){sum+=a+as+b+c+cs+d+ds+e+es;cout<<sum<<endl;}
    else if(minm==C){sum+=a+as+b+bs+c+d+ds+e+es;cout<<sum<<endl;}
    else if(minm==D){sum+=a+as+b+bs+c+cs+d+e+es;cout<<sum<<endl;}
    else if(minm==E){sum+=a+as+b+bs+c+cs+d+ds+e;cout<<sum<<endl;}



}


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

int main(){
  int N;
  cin >> N;
  map<string,int> m;
  int max=-1e8;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(m.count(s)){
      m.at(s)++;
    }else{
      m[s]=1;
    }
    if(max<m.at(s)){
      max=m.at(s);
    }
  }
  for(auto p:m){
    if(p.second==max){
      cout << p.first << endl;
    }
  }
  return 0;
}


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


int main(){
  int n;
  cin >> n;

  for(int i=0; i<n; i++){
    double x1, y1, x2, y2, r1, r2;
    cin >> x1 >> y1 >> r1 >> x2 >>y2 >> r2;

    double d = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));

    if(d > r1 + r2){
      cout << 0 << endl;
    } else if(abs(r1-r2) <= d && d <= r1 + r2){
      cout << 1 << endl;
    } else if(d < abs(r1-r2)){
      if(r1 > r2){
        cout << 2 << endl;
      } else {
        cout << -2 << endl;
      }
    }
  }
}
  
  


Measured memory_bytes: 3208
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 100005
#define ll long long
int n,k,a[N][2];vector<int >v[1005];
int main()
{
	scanf("%d",&n);
	for(k=0;k*(k-1)<=n<<1;k++)if(n*2==(k-1)*k)break;
	if(k*(k-1)!=n<<1)return puts("No"),0;
	puts("Yes");
	printf("%d\n",k);
	for(int i=1,p=1,last=0,now=k-1;i<=n;i++)
	{
		// ch[i][0]=p;ch[i][1]=p+i-last;
		v[p].push_back(i),v[p+i-last].push_back(i);
		// printf("%d\n",p+i-last);
		if(i-last==now)now--,last=i,p++;
	}
	for(int i=1;i<=k;i++)
	{
		printf("%d",(int)v[i].size());
		for(int j=0;j<v[i].size();j++)printf(" %d",v[i][j]);puts("");
	}
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(3e3) + 17;

int n, m;
string s, t;
int dp[MAXN][MAXN];

bool read() {
    if (!(cin >> s >> t))
        return false;

    return true;
}

void solve() {
    n = sz(s);
    m = sz(t);

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

    int i = n, j = m;
    string res;

    for (; i > 0 && j > 0; ) {
        if (s[i - 1] == t[j - 1]) {
            res += s[i - 1];
            --i, --j;
        } else {
            if (dp[i][j] == dp[i - 1][j])
                --i;
            else
                --j;
        }
    }

    reverse(res.begin(), res.end());
    cout << res << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 35584
#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <cmath>
#include <cstdlib>
#include <set>
#include <time.h>
#include <iomanip>          //cout <<fixed<<setprecision(4) <<ans <<endl;
using namespace std;

const int M = 1000000000 +7;
typedef long long ll;
typedef unsigned long long ull;
#define  mem(a) memset(a,0,sizeof a)
#define pi acos(-1.0)
#define inf 0x3f3f3f3f //1.7e9

const double eps = 1e-10;
vector < int > v[200005];
int n,m;
bool judge(int i) {
    for(int j = 0 ; j < v[i].size() ; j++) {
        if(v[i][j] == n) return true;
    }
    return false;
}
int main()
{

    scanf("%d %d",&n,&m);
    int a,b;
    for(int i = 0 ; i < m ; i ++) {
        scanf("%d %d",&a,&b);
        v[a].push_back(b);
    }
    int f = 0;
    for(int i = 0 ; i < v[1].size() ; i ++) {
        if(judge(v[1][i])) {
            f = 1;
            break;
        }
    }
    if(f) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}



Measured memory_bytes: 8576
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var k = int.Parse(line[2]);
        var map = new int[h, w];
        for (int i = 0; i < k; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]) - 1;
            var y = int.Parse(line[1]) - 1;
            map[x, y] = int.Parse(line[2]);
        }
        getAns(h, w, map);
    }
    static void getAns(int h, int w, int[,] map)
    {
        var dp = new long[h+1, w+1, 4];
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
            {
                for (int k = 2 ; k >= 0; k--)
                    dp[i, j, k + 1] = Max(dp[i, j, k + 1], dp[i, j, k] + map[i, j]);
                for (int k = 0; k < 4; k++)
                {
                    dp[i + 1, j, 0] = Max(dp[i + 1, j, 0], dp[i, j, k]);
                    dp[i ,  j + 1, k] = Max(dp[i , j + 1, k], dp[i, j, k]);
                }
            }
        var ans = 0L;
        for (int i = 0; i < 4; i++)
            ans = Max(ans, dp[h - 1, w - 1, i]);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 362852
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
//大文字->小文字 tolower(),逆はtoupper()
using namespace std;

int dig(int N) {//桁数
	int dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}

int main() {
	int N, K; cin >> N >> K;
	string S; cin >> S;

	S[K-1] = tolower(S[K-1]);

	cout << S << endl;
}


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

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define LAST(i,n) if(i==n-1)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

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

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

    lint Asum = 0;
    vector<lint> A;
    REP(_, N) {
      lint a; cin >> a; A.push_back(a);
      Asum += a;
    }

    lint left=1;
    lint center=2;
    lint right=3;
    lint P = A[0]; //[0, left)
    lint Q = A[1]; //[left, center)
    lint R = A[2]; //[center, right)
    lint S = Asum - P - Q - R; //[right, N)

    lint res = Asum;
    
    while(center <= N-2) {
      lint PQ = abs(P-Q);
      while(true) {
        lint next_left = left + 1;
        
        if(next_left == center) {
          break;
        }
        
        lint next_P = P + A[next_left-1];
        lint next_Q = Q - A[next_left-1];
        lint next_PQ = abs(next_P - next_Q);

        if(next_PQ <= PQ) {
          left = next_left;
          P = next_P;
          Q = next_Q;
          PQ = next_PQ;
        }
        else {
          break;
        }
      }

      lint RS = abs(R-S);
      while(true) {
        lint next_right = right + 1;
        
        if(next_right == N) {
          
          break;
        }

        lint next_R = R + A[next_right-1];
        lint next_S = S - A[next_right-1];
        lint next_RS = abs(next_R - next_S);

        if(next_RS <= RS) {
          right = next_right;
          R = next_R;
          S = next_S;
          RS = next_RS;
        }
        else {
          break;
        }
      }

      lint M = max(max(P, Q), max(R, S));
      lint m = min(min(P, Q), min(R, S));

      res = min(res, M-m);

      Q += A[center];
      R -= A[center];
      center += 1;

            if(right == center) {
       R += A[right];
       S -= A[right];
       right += 1;
      }
        
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println((A - 1) * (B - 1));
    }
}

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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
   su;
   ll n,m,x,y,sum=0;
   cin>>n>>m;
   pll p[n];
   lo(i,0,n)
   {
     cin>>x>>y;
     p[i]={x,y};
   }
   sort(p,p+n);
   for(int i=0;i<n;i++)
   {
     if(m<=0)
      break;
     else if(p[i].S<=m)
     {
       sum+=p[i].F*p[i].S;
       m-=p[i].S;
     }
     else
     {
       sum+=m*p[i].F;
       m=0;
     }
   }
   cout<<sum<<nl;
   return 0;
}


Measured memory_bytes: 5220
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
//rep(i, v.size()) v[i]=i;
//#define int long long
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>

using namespace std;

signed main(){
  int N;
  cin >> N;
  int ans = 0;

  for(int i = 1; i <= N; i++){
    //string i;
    string stringi = to_string(i);
    if(stringi.length() % 2 == 1)ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
// C - Back and Forth
package main

import "fmt"

func main() {
	var sx, sy, tx, ty int
	fmt.Scanf("%d %d %d %d", &sx, &sy, &tx, &ty)

	fmt.Printf("%s", repeat('U', ty-sy))
	fmt.Printf("%s", repeat('R', tx-sx))
	fmt.Printf("%s", repeat('D', ty-sy))
	fmt.Printf("%s", repeat('L', tx-sx))

	fmt.Printf("%s", "L")
	fmt.Printf("%s", repeat('U', ty-sy+1))
	fmt.Printf("%s", repeat('R', tx-sx+1))
	fmt.Printf("%s", "D")

	fmt.Printf("%s", "R")
	fmt.Printf("%s", repeat('D', ty-sy+1))
	fmt.Printf("%s", repeat('L', tx-sx+1))
	fmt.Printf("%s", "U")
}

func repeat(c byte, n int) string {
	s := make([]byte, n)
	for i := range s {
		s[i] = c
	}
	return string(s)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = 1;
    rep(i, N) {
        if (N % 2 == 1 && A[i] % 2 == 1) {cout << 0 << endl; return 0;}
        if (A[i] != (N + 1) % 2 + ((i + N % 2) / 2) * 2) {cout << 0 << endl; return 0;}
    }
    rep(i, N/2) {
        ans = (ans * 2) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef pair<int,int> pii;

int main(){
  int n,m;
  while(cin >> n >> m, n){
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector< pair<int,pii> > t(n);//sagyou zikan
    rep(i,n){
      t[i].first = m/a[i] * a[i];
      t[i].second = pii(a[i],i);
    }
    sort(t.begin(),t.end());
    if(t[0].first < t[1].first){
      cout << t[0].second.second + 1 << endl;
    }else if(t[0].first == t[1].first && t[0].second.first < t[1].second.first){
      cout << t[0].second.second + 1 << endl;
    }else{
      cout << n << endl;
    }
  }
}


Measured memory_bytes: 3040
# -*- coding: utf-8 -*-                                                                              

N = int(input())

def count753(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) for c in "753") else 0
    for	c in "753":
        ret += count753(s + c)
    return ret

print(count753("0"))


Measured memory_bytes: 2940
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int Q = scanner.nextInt();
		for (int q = 0; q < Q; q++) {
			String query = scanner.next();
			int steps = 0;
			while (query.length() > 1) {
				int max = 0;
				for (int i = 1; i < query.length(); i++) {
					int a = Integer.parseInt(query.substring(0, i));
					int b = Integer
							.parseInt(query.substring(i, query.length()));
					max = Math.max(max, a * b);
				}
				query = String.valueOf(max);
				steps++;
			}
			System.out.println(steps);

		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 23080
#include<stdio.h>

int main() {
  int i, j;
  int n, k;
  scanf("%d %d", &n, &k);

  int k_max = n * (n - 1) / 2 - (n - 1);
  if(k > k_max) printf("-1\n");
  else {
    int m = (n - 1) + k_max - k;
    printf("%d\n", m);
    for(i = 2; i <= n; i++) printf("1 %d\n", i);
    int edge_count = n - 1;
    for(i = 2; i <= n; i++) {
      for(j = i + 1; j <= n; j++) {
        if(edge_count >= m) break;
        printf("%d %d\n", i, j);
        edge_count++;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  if (S.size() == 3) reverse(S.begin(), S.end());
  cout << S << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007

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

    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    B = abs(A - B);
    A = 0;

    A += V * T;
    B += W * T;

    if(A >= B) {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 3612
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
a_sum = 0
k = 0
for i in range(n-1):
    a_sum += a[i]
    if a_sum*2 < a[i+1]:
        k = i+1
    else:
        continue
print(n-k)

Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n, k;
  int ans = 0;

  cin >> n >> k;
  vi v(200001);
  set<int> s;
  REP(i, n) {
    int a;
    cin >> a;
    v[a]++;
    s.insert(a);
  }
  SORT(v);
  k = SZ(s) - k;
  EACH(i, v) {
    if(k < 1)break;
    if(i == 0)continue;
    k--;
    ans += i;
  }

  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 12032
H,W=map(int,input().split())
masu=[[None for i in range(W+2)] for j in range(H+2)]
score=[[None for i in range(W)] for j in range(H)]
for i in range(1,H+1):
    S=list(input())
    for j in range(len(S)):
        masu[i][j+1]=S[j]

for i in range(1,H+1):
    for j in range(1,W+1):
        if masu[i][j]=="#": 
            score[i-1][j-1]="#"
            continue
        count_score=0
        if masu[i-1][j-1]=="#":count_score+=1
        if masu[i-1][j]=="#":count_score+=1
        if masu[i-1][j+1]=="#":count_score+=1
        if masu[i][j-1]=="#":count_score+=1
        if masu[i][j+1]=="#":count_score+=1
        if masu[i+1][j-1]=="#":count_score+=1
        if masu[i+1][j]=="#":count_score+=1
        if masu[i+1][j+1]=="#":count_score+=1

        score[i-1][j-1]=count_score
for i in score:
    print("".join([str(_) for _ in i]))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <stdio.h>
using namespace std;

int main () {

    int n;
    char s[30];
    cin >> n;
    snprintf(s, sizeof(s), "%d", n);
    
    if (s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
    else cout << "No" <<endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <int> conn[5050];
vector <int> son[5050];
int sz[5050];
bool dchk[5050];
void DFS(int n) {
	dchk[n] = true;
	sz[n] = 1;
	for (auto it : conn[n]) {
		if (dchk[it]) continue;
		son[n].push_back(it);
		DFS(it);
		sz[n] += sz[it];
	}
}

ll C[5050][5050];
ll F[5050];

ll dp[5050];
ll tdp[5050];
int getans(vector<int> Vl) {
	int s = 0, i, j, k;
	for (i = 0; i <= 5000; i++) dp[i] = 0;
	dp[0] = 1;
	for (auto it : Vl) {
		for (i = 0; i <= s + it; i++) tdp[i] = 0;
		for (i = 0; i <= s; i++) {
			for (j = 0; j <= it; j++) {
				ll v = C[it][j] * C[it][j] % MOD;
				v = (v * F[j]) % MOD;
				tdp[i + j] += dp[i] * v % MOD;
			}
		}
		for (i = 0; i <= s + it; i++) dp[i] = tdp[i] % MOD;
		s += it;
	}

	ll rv = 0;
	for (i = 0; i <= s; i++) {
		ll v = dp[i];
		v = (v * F[s-i]) % MOD;
		if (i % 2 == 0) rv = (rv + v) % MOD;
		else rv = (rv - v + MOD) % MOD;
	}
	return (int)rv;
}
int main() {
	int N, i, j;

	F[0] = 1;
	for (i = 1; i <= 5000; i++) F[i] = F[i - 1] * i % MOD;
	for (i = 0; i <= 5000; i++) {
		C[i][0] = C[i][i] = 1;
		for (j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}

	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
	}
	DFS(1);

	int r = 1;
	while (1) {
		if (son[r].empty()) break;
		int mx = 0;
		for (i = 1; i < son[r].size(); i++) if (sz[son[r][mx]] < sz[son[r][i]]) mx = i;
		if (sz[son[r][mx]] * 2 <= N) break;
		r = son[r][mx];
	}
	for (i = 1; i <= N; i++) son[i].clear(), sz[i] = 0, dchk[i] = false;
	DFS(r);

	vector <int> Vu;
	for (auto it : son[r]) Vu.push_back(sz[it]);
	
	int ans = getans(Vu);
	Vu.push_back(1);
	ans = (ans + getans(Vu)) % MOD;
	return !printf("%d\n", ans);
}

Measured memory_bytes: 198016
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100005];
long long res=0;
int main()
{
	scanf("%d",&n);
	a[n]=0;
	for (int i=0;i<n;i++)
		scanf("%lld",a+i);
	for (int i=0;i<n;i++)
	{
		res+=a[i]/2;
		a[i]%=2;
		if (a[i]==1 && a[i+1]>0)
		{
			res++;
			a[i]=0;
			a[i+1]--;
		}
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 1024
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
vector<int> g[3005];
int ar[3005];
int perm[3005];

int ans[3005];
int main(){
  cin>>n;
  REP(i,n) cin>>ar[i],perm[i]=i;
  sort(perm,perm+n,[&](int a,int b){
    return ar[a]<ar[b];
  });
  REP(i,n-1){
    int a,b;cin>>a>>b;--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  REP(i,n){
    int v=perm[i];
    for(auto to:g[v]){
      if(ar[v]>ar[to] && ans[to]==0){
        ans[v]=1;
        break;
      }
    }
  }
  REP(i,n) if(ans[i]) printf("%d\n",i+1);
  return 0;
}





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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>         vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)            for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 998244353;

const int N = 3e5 + 1, T = 4 * N + 10;
vector<ii> st(T, {0, -1});

void update(int id, int l, int r, int pos, ii d) {
  if (l == r) st[id] = d;
  else {
    int mid = avg(l, r);
    if (pos <= mid) update(id << 1, l, mid, pos, d);
    if (pos > mid) update(id << 1 | 1, mid + 1, r, pos, d);
    st[id] = max(st[id << 1], st[id << 1 | 1]);
  }
}

ii query(int id, int l, int r, int a, int b) {
  if (r < a or l > b) return {0, -1};
  if (a <= l and r <= b) return st[id];
  int mid = avg(l, r);
  return max(query(id << 1, l, mid, a, b), query(id << 1 | 1, mid + 1, r, a, b));
}

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

  int n, k;
  cin >> n >> k;
  int x;
  loop(n) {
    cin >> x;
    auto [len, pos] = query(1, 0, N - 1, x - k, x + k);
    update(1, 0, N - 1, x, {len + 1, i});
  }
  cout << query(1, 0, N - 1, 0, N - 1).first << endl;
  return 0;
}



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

 using namespace std;

 int main() {
   string a, b;

   cin >> a >> b;

   if ((int)sqrt(stoi(a + b)) * (int)sqrt(stoi(a + b)) == stoi(a + b)) cout << "Yes" << endl;
   else cout << "No" << endl;
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a + b;
    int right = c + d;
    
    if(left > right)
    {
        cout << "Left" << endl;
        return 0;
    }
    else if(left < right)
    {
        cout << "Right" << endl;
        return 0;
    }
    cout << "Balanced" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 2e5 + 1;
int k;
string s = "ACL";
int main(){	
	cin >> k;
	while(k--) cout << s;
	puts("");
	

	
	
		
}	

Measured memory_bytes: 3616
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	H = nextInt()
	W = nextInt()
	s := nextGrid(H, W)
	//DBGprintGrid(s)

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == "#" {
				num := getBombnum(i, j, "#", s)
				if num == 0 {
					fmt.Println("No")
					return
				}
			}
		}
	}

	fmt.Println("Yes")
	return

}

// 周りからtargetを探す
func getBombnum(i, j int, target string, s [][]string) int {
	cnt := 0

	//* 検索方向設定
	// 12時から時計回り ８方向
	//dx := []int{+0, +1, +1, +1, +0, -1, -1, -1}
	//dy := []int{-1, -1, +0, +1, +1, +1, +0, -1}
	// 12時から時計回り ４方向
	dx := []int{+0, +1, +0, -1}
	dy := []int{-1, +0, +1, +0}

	dnum := len(dx)
	for d := 0; d < dnum; d++ {
		ni := i + dy[d]
		nj := j + dx[d]

		// 領域外なら探索せずにスルー
		if ni < 0 || H <= ni || nj < 0 || W <= nj {
			continue
		}
		if s[ni][nj] == target {
			// Bomb HIT
			//fmt.Println("DBG HIT") //! DBG
			cnt++
		}
	}

	//return fmt.Sprintf("%d", cnt)
	return cnt
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

// read func
func nextGrid(a int, b int) [][]string {
	mat := make([][]string, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]string, b)
		tmp := nextStr()
		mat[i] = strings.Split(tmp, "")
	}
	return mat
}

// H =height
var H int

// W =witdh
var W int

// DBGprintGrid print the grid
//! DBG
func DBGprintGrid(g [][]string) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Printf("\n")
	}
}


Measured memory_bytes: 1868
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, p;
    string s;
    cin >>n;
    vector<pair<pair<string, int>, int>> arr(n);
    for(int i = 0; i < n; i++){
        cin >>s >>p;
        arr[i] = {{s, -p}, i+1};
    }
    sort(arr.begin(), arr.end());
    for(int i = 0; i < n; i++)
        cout <<arr[i].second <<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        for (int i = 1; i < 10; i++) {
            if (i * 111 >= n) {
                out.println(i * 111);
                break;
            }
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22356
dic = {}

N = int(input())
for k in range(N):
  i = input()
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1

M = int(input())
for j in range(M):
  i = input()
  if i in dic:
    dic[i] -= 1

print(max(max(dic.values()), 0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char a,b,c; cin>>a>>b>>c;
  int count = 0;
  if (a == '1')
    count ++;
  if (b == '1')
    count++;
  if (c == '1')
    count++;
   
  cout << count << endl; 
}

Measured memory_bytes: 256
<?php 
$sc = new Scanner();
$a = $sc->nextInt(); // 高橋くんの試合数
$b = $sc->nextInt(); // 高橋くんの勝利数
 
if($b >= $a){
 echo $a . PHP_EOL;
} else {
 echo ($a-1). PHP_EOL;
}
 
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b;
  cin >> a >> b;

  cout << a - (b < a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
static const int MAXN = 55;
static const int MODULUS = 1e9 + 7;

int n;
char s[MAXN], t[MAXN];
std::vector<int> v;

int main()
{
    scanf("%d", &n);
    scanf("%s%s", s, t);

    for (int i = 0; i < n; ++i) {
        if (s[i] == t[i]) {
            v.push_back(0);
        } else {
            v.push_back(1); ++i;
        }
    }

    long long ans = 1;
    for (int i = 0; i < v.size(); ++i) {
        if (v[i] == 0) {    // vertical
            if (i == 0) ans = 3;
            else if (v[i - 1] == 1) ans = ans;
            else (ans *= 2) %= MODULUS;
        } else {            // horizontal
            if (i == 0) ans = 6;
            else if (v[i - 1] == 0) (ans *= 2) %= MODULUS;
            else (ans *= 3) %= MODULUS;
        }
    }

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


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

typedef long long ll;
 
int main(){
  char s[3];
  cin >> s;
  int ans = 0;
  for(int i=0; i<3; i++){
    if(s[i]=='1') ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

void INP();

void solve()
{
	int X, Y,Z;

	cin>>X>>Y>>Z;

	cout<<Z<<" "<<X<<" "<<Y<<endl;


}

int main()
{
	//INP();

	int t = 1;
	// cin>>t;

	while(t--) solve();

}





void INP()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

  int N;
  ll res = 1;
  while (true) {
    cin >> N;
    if (N == 0) {
      break;
    }
    res++;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int i = 0;
	while(N >= 2) {
		N = N / 2;
		i++;
	}
	int max = 1;
	for (int j = 0; j < i; j++)
		max = max * 2;
	cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll bit[200005];

void add(ll x) {
  while(x<200005) {
    bit[x]++;
    x += x&-x;
  }
}

ll sum(ll x) {
  ll ans = 0;
  while(x>0) {
    ans += bit[x];
    x -= x&-x;
  }
  return ans;
}

int main() {
  ll N, K;
  cin>>N>>K;
  ll A[N+1];
  for(int i=0;i<N;++i) {
    cin>>A[i+1];
    A[i+1] -= K;
  }
  A[0] = 0;
  for(int i=1;i<=N;++i) A[i] += A[i-1];
  vector<ll> arr;
  map<ll, int> amap;
  for(int i=0;i<=N;++i) {
    if(amap[A[i]]==0) arr.push_back(A[i]);
    amap[A[i]]++;
  }
  sort(arr.begin(), arr.end());
  map<ll, int> bmap;
  for(int i=0;i<arr.size();++i) {
    bmap[arr[i]] = i+1;
  }
  add(bmap[0]);
  ll ans = 0;
  for(int i=1;i<=N;++i) {
    ans += sum(bmap[A[i]]);
    add(bmap[A[i]]);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 32924
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static long[] primes = new long[1001];
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NH = Sarray();
            var N = NH[0];
            var H = NH[1];
            var AB = new List<Tuple<int, long, long>>();
            for (var i = 0; i < N; ++i)
            {
                var ab = Sarray();
                AB.Add(Tuple.Create(i, ab[0], ab[1]));
            }
            var maxA = AB.Max(m => m.Item2);
            // 投げたら最大A以上のもの
            AB = AB.Where(ab => ab.Item3 >= maxA).ToList();
            // 最大攻撃力のうち投げ攻撃力が最小のものを手持ちの武器にする
            var maxa = AB.Where(ab => ab.Item2 == maxA);
            var minb = maxa.First(ab => ab.Item3 == maxa.Min(m => m.Item3));
            AB.Remove(minb);
            AB = AB.OrderByDescending(ab => ab.Item3).ToList();
            var dmg = 0L;
            var ans = 0L;
            // 投げ攻撃力が高いものを投げる
            for (var i = 0; i < AB.Count; ++i)
            {
                dmg += AB[i].Item3;
                ++ans;
                if (H <= dmg)
                {
                    WriteLine(ans);
                    return;
                }
            }
            // 最後は投げる
            dmg += minb.Item3;
            ans++;
            // 投げても残ってる分は殴っておく
            if (dmg < H)
                ans += (H - dmg + minb.Item2 - 1) / minb.Item2;
            WriteLine(ans);
            //Out.Flush();
        }
    }
}


Measured memory_bytes: 31020
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define ll long long
#define int long long
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
    
const int N=200000+10,inf=1e18;
int n,q,pre,nw,tag[N<<2];
ll tr1[N<<2],tr2[N<<2];
 
il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
void pushdown(ri nw)
{
	if(!tag[nw])return;
	tag[nw<<1]+=tag[nw];tag[nw<<1|1]+=tag[nw];
	tr1[nw<<1]+=tag[nw];tr1[nw<<1|1]+=tag[nw];
	tr2[nw<<1]+=tag[nw];tr2[nw<<1|1]+=tag[nw];
	tag[nw]=0;
}
void modify(ri nw,ri l,ri r,ri to,ll dat)
{
	if(l==r){tr1[nw]=min(tr1[nw],dat-to),tr2[nw]=min(tr2[nw],dat+to);return;}
	pushdown(nw);ri mid=(l+r)>>1;to<=mid?modify(nw<<1,l,mid,to,dat):modify(nw<<1|1,mid+1,r,to,dat);
	tr1[nw]=min(tr1[nw<<1],tr1[nw<<1|1]);tr2[nw]=min(tr2[nw<<1],tr2[nw<<1|1]);
}
ll query1(ri nw,ri l,ri r,ri to_l,ri to_r)
{
	if(to_l<=l && r<=to_r)return tr1[nw];
	pushdown(nw);ri mid=(l+r)>>1;ll ret=inf;
	if(to_l<=mid)ret=query1(nw<<1,l,mid,to_l,to_r);
	if(mid<to_r)ret=min(ret,query1(nw<<1|1,mid+1,r,to_l,to_r));
	return ret;
}
ll query2(ri nw,ri l,ri r,ri to_l,ri to_r)
{
	if(to_l<=l && r<=to_r)return tr2[nw];
	pushdown(nw);ri mid=(l+r)>>1;ll ret=inf;
	if(to_l<=mid)ret=query2(nw<<1,l,mid,to_l,to_r);
	if(mid<to_r)ret=min(ret,query2(nw<<1|1,mid+1,r,to_l,to_r));
	return ret;
}
ll query(ri nw,ri l,ri r)
{
	if(l==r)return tr1[nw]+l;
	pushdown(nw);ri mid=(l+r)>>1;return min(query(nw<<1,l,mid),query(nw<<1|1,mid+1,r));
}

signed main()
{
//	freopen("2558.in","r",stdin);//freopen("2558.out","w",stdout);
	n=read();q=read();pre=read();memset(tr1,63,sizeof(tr1));memset(tr2,63,sizeof(tr2));modify(1,1,n,read(),0);
	while(q--)
	{
		nw=read();ll dat=min(query1(1,1,n,1,nw)+nw,query2(1,1,n,nw,n)-nw);
		tag[1]+=abs(nw-pre);tr1[1]+=abs(nw-pre);tr2[1]+=abs(nw-pre);modify(1,1,n,pre,dat);pre=nw;
	}
	printf("%lld\n",query(1,1,n));
	return 0;
}

Measured memory_bytes: 18688
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.trim().split( "\n" );
  var len = data.length;  
  var rc = data[0].split( " " ).map( Number );
  var r = rc[0];
  var c = rc[1]; 
  var t = Array( c+1 );
  for( var i=0; i<c+1; i++ ) { t[i] = 0; }
  var output = [];

  for( var index=1; index<len; index++ ) {
    var nums = data[index].split( ' ' ).map( Number );
    var sum = 0;
    for( var j=0; j<c; j++ ) {
      sum += nums[j];
      t[j] += nums[j];
    }
    t[c] += sum;
    nums.push( sum );
    output.push( nums.join( " " ) );
  }
  output.push( t.join( " " ) );
  console.log( output.join( "\n" ) );
});

Measured memory_bytes: 10320
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
pll a[100001];
int d[100001];
int n, k;
int Find(int x) {
	if (d[x] == x)return x;
	else return d[x] = Find(d[x]);
}
void Union(int x, int y) {
	x = Find(x);
	y = Find(y);
	d[y] = x;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	priority_queue<pll> q;
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
		q.push({ a[i].second,a[i].first });
	}
	int ans = 0;
	int cnt = 0;
	for (int i = 1; i <= k; i++)d[i] = i;

	while (!q.empty() && cnt < k) {
		pll tmp = q.top(); q.pop();
		int next = Find(tmp.second);
		if (next != 0 && next <= k) {
			ans += tmp.first; 
			cnt += 1;
			Union(next + 1, next);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 4468