akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)

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

    int r, c;
    cin >> r >> c;

    int sheet[r + 1][c + 1];
    REP(i, r + 1) REP(j, c + 1) {
        sheet[i][j] = 0;
    }

    REP(i, r) REP(j, c) {
        cin >> sheet[i][j];
    }

    REP(i, r) REP(j, c) {
        sheet[i][c] += sheet[i][j];
    }

    REP(j, c + 1) REP(i, r) {
        sheet[r][j] += sheet[i][j];
    }

    REP(i, r + 1) {
        REP (j, c + 1) {
            cout << sheet[i][j];
            if (j != c) {
                cout << ' ';
            }
        }
        cout << '\n';
    }
    return 0;
}


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

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil -> next = nil;
  nil -> prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x -> key = key;
  //nil- > next???NULL?????????x -> next???nil????????§??°??¶????????£?????????
  x -> next = nil -> next;
  x -> prev = nil;

  nil -> next -> prev = x;
  nil -> next = x;
}

Node* listSearch(int key) {
  Node *cur = nil -> next;
  while(cur != nil && cur -> key != key) {
    cur = cur -> next;
  }
  return cur;
}


void deleteNode(Node *t) {
  if(t == nil) {
    return;
  }
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t); 
}

void deleteFirst() {
    deleteNode((nil -> next));
}

void deleteLast() {
    deleteNode(nil -> prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

int main(void) {
  init();

  int n;
  scanf("%d", &n);

  char op[10];
  int val;
  for(int i = 0; i < n; i++) {
    scanf("%s", op);
    if(op[0] == 'i') {
      scanf("%d", &val);
      insert(val);
    }
    else {
      if(strlen(op) == 6) {
        scanf("%d", &val);
        deleteKey(val);
      }
      else if(op[6] == 'F') {
        deleteFirst();
      }
      else {
        deleteLast();
      }
    }
  }

  Node *currentNode = nil -> next;
  int j = 0;
  while(true) {
    if(currentNode == nil){ 
      break;
    }
    if(j > 0) {
      cout << " ";
    }
    cout << currentNode -> key;
    j++;
    currentNode = currentNode -> next;
    deleteFirst(); 
  }
  deleteNode(nil);
  cout << endl;

  return 0;
}

Measured memory_bytes: 32364
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		A[i] -= i + 1
	}
	sort.Ints(A)
	mid := A[N/2]
	ans := 0
	for i := 0; i < N; i++ {
		sub := A[i] - mid
		if sub >= 0 {
			ans += sub
		} else {
			ans -= sub
		}
	}

	fmt.Printf("%d\n", ans)
	return
}


Measured memory_bytes: 5504
#include<stdio.h>
int main(void){
    char S[10];
    scanf("%s",&S);
    if(S[0]=='S'){
        printf("Cloudy");
    }else if(S[0]=='C'){
        printf("Rainy");
    }else if(S[0]=='R'){
        printf("Sunny");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = 1000000007;

ll pow_with_mod(ll x, ll n)
{
    if (n == 0){ return 1; }
    if (n == 1){ return x; }
    ll xx = pow_with_mod(x, n >> 1) % mod;
    return (((xx * xx) % mod) * (n & 1 ? x : 1)) % mod;
}

ll ncr_with_mod(ll n, ll r)
{
    ll x = 1, y = 1;
    for (ll i=n-r+1;i<=n;++i) { x *= i; x %= mod; }
    for (ll i=1;    i<=r;++i) { y *= i; y %= mod; }
    y = pow_with_mod(y, mod - 2);
    return ((x % mod) * y) % mod;
}


int main()
{
    ll n, k;
    cin >> n >> k;

    for (ll i=1;i<=k;++i)
    {
        const ll t = n - k + 1;
        if (t < i) { cout << 0 << endl; continue; }

        const ll c1 = ncr_with_mod(t, i);
        const ll c2 = i - 1 <= 0 ? 1 : ncr_with_mod(k - 1, i - 1);

        cout << (c1 * c2 % mod) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
trial = int(input())

for t in range(trial):
    targ = [int(n) for n in input().split(' ')]
    root = [[0 for n in range(targ[0] + 1)] for m in range(targ[1] + 1)]
    matanum = int(input())
    for m in range(matanum):
        matax,matay,secx,secy = (int(n) for n in input().split(' '))
        if matax == secx:
            if root[max(matay,secy)][matax] == 'x':
                root[max(matay,secy)][matax] = 'xy'
            else:
                root[max(matay,secy)][matax] = 'y'
        else:
            if root[matay][max(matax,secx)] == 'y':
                root[matay][max(matax,secx)] = 'xy'
            else:
                root[matay][max(matax,secx)] = 'x'
    for yaxis in range(targ[1] + 1):
        for xaxis in range(targ[0] + 1):
            if xaxis == 0:
                if root[yaxis][xaxis] == 'y' or root[yaxis][xaxis] == 'xy':
                    root[yaxis][xaxis] = 0
                else:
                    if yaxis == 0:
                        root[0][0] = 1
                    else:
                        root[yaxis][xaxis] = root[yaxis- 1][xaxis]
            elif yaxis == 0:
                if root[yaxis][xaxis] == 'x' or root[yaxis][xaxis] == 'xy':
                    root[yaxis][xaxis] = 0
                else:
                    root[yaxis][xaxis] = root[yaxis][xaxis-1]
            else:
                if root[yaxis][xaxis] == 'xy':
                    root[yaxis][xaxis] = 0
                elif root[yaxis][xaxis] == 'y':
                    root[yaxis][xaxis] = root[yaxis][xaxis - 1]
                elif root[yaxis][xaxis] == 'x':
                    root[yaxis][xaxis] = root[yaxis - 1][xaxis]
                else:
                    root[yaxis][xaxis] = root[yaxis - 1][xaxis] + root[yaxis][xaxis - 1]
    if root[targ[1]][targ[0]] == 0:
        print("Miserable Hokusai!")
    else:
        print(root[targ[1]][targ[0]])

Measured memory_bytes: 7752
package main

import (
    "fmt"
)

func main(){
  var s,ans string
  fmt.Scan(&s)
  
  if (s=="Sunny"){
    ans="Cloudy"
  }else if (s=="Cloudy"){
    ans="Rainy"
  }else if (s=="Rainy"){
    ans="Sunny"
  }
  fmt.Println(ans)
}

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

int main() {
	int s;
	cin >> s;
	int x = s;
	set<int> st;
	while(st.count(x) == 0){
		st.insert(x);
		if(x % 2 == 0){
			x /= 2;
		}
		else{
			x = 3 * x + 1;
		}
	}
	cout << st.size() + 1 << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.max

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()
private fun readLongs(): LongArray = readLn().map { it.toLong() }.toLongArray()

fun main() {
//    val (n, m) = readInts()
//    val a = readInts()
//
//    var sum = 0L;
//    for (i in a) sum += i
//    val r = n - sum
//
//    println(if (r < 0) -1 else r)

    val (n, m) = readInts()
    val a = readInts()

//    println(max(n - a.sum(), -1))
    println((n - a.sum()).takeIf { it >= 0 } ?: -1)
}

Measured memory_bytes: 41448
#!/usr/bin/env python3
import sys


def solve(K: int, T: int, a: "List[int]"):
    from heapq import heapify, heappop, heappush

    a = list(map(lambda x:x*(-1), a))
    heapify(a)
    while True:
        if len(a) <= 1:
            break

        x = -1*heappop(a)
        y = -1*heappop(a)
        x -= 1
        y -= 1
        if x > 0:
            heappush(a, -x)
        if y > 0:
            heappush(a, -y)

    if len(a) == 1:
        print(-1*a[0]-1)
    else:
        print(0)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(T) ]  # type: "List[int]"
    solve(K, T, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	string ss,tt;
	int i,j,k,res=0;
	cin>>ss>>tt;
	for(i=0;i<3;i++)
	{
	
			if(ss[i]==tt[i])
				res++;
		
	}
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int m;
    cin >> m;
    vector<ll> d(m);
    vector<ll> c(m);
    ll ans = 0;
    ll sum = 0;
    for(int i = 0; i < m; i++)
    {
        cin >> d[i] >> c[i];
        ans += c[i];
        sum += d[i] * c[i];
    }
    cout << ans - 1 + (sum-1) / 9 << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    int l,r,d;
    int sum = 0;
    cin >> l >> r >> d;
    for(int i = l; i <= r; i++){
        if(i%d == 0)sum++;
    }
    cout << sum << endl;
    return 0;
}

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

const int64_t MOD = 998244353;
const int MAX = 1e5*2;
int64_t ans[MAX];
int64_t sum[MAX];

int main(){
  int N, K;
  cin >> N >> K;
  vector<vector<int>> vec(K,vector<int>(2));
  for(int i=0; i<K; i++){
    for(int j=0; j<2; j++){
      cin >> vec[i][j];
    }
  }
  
  ans[1] = 1;
  sum[1] = 1;
  for(int i=1; i<N; i++){
    for(int j=0; j<K; j++){
      int l = vec[j][0];
      int r = vec[j][1];
      //ans[i-l]からans[i-r]を足したい
      //sum[i-l] - sum[i-r-1]
      //cout << i << " " << i+1-l << " " << i-r  << " " << sum[max(i+1-l,0)] - sum[max(i-r,0)]<< endl;
      ans[i+1] += sum[max(i+1-l,0)] - sum[max(i-r,0)];
      if(ans[i+1] < 0){
        ans[i+1] += MOD;
      }
      ans[i+1] %= MOD;
    }
    sum[i+1] = ans[i+1] + sum[i];
    sum[i+1] %= MOD;
  }
  
  /*for(int i=0; i<=N; i++){
    cout << ans[i] << endl;
  }*/
  cout << ans[N] << endl;
}

Measured memory_bytes: 6704
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    char al;
    io.read(al);
    if(al >= 'A' && al <= 'Z') cout << 'A';
    else cout << 'a';
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

    map<string, int> mp;
    vector<string> strv(N);
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        strv[i] = str;
        mp[str]++;
    }

    string s=strv[0];
    for (int i = 0; i < N-1; i++) {
        if (mp[strv[i]] <= 1 && strv[i][strv[i].length()-1] == strv[i+1][0]) {
            continue;
        }else{
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
ll N;
ll A[200010];
ll d[200010];
map<ll, ll> m;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
        d[i+1] = A[i];
    }

    m[d[0]]++;
    REP(i,1,N+1){
        d[i] += d[i-1];
        m[d[i]]++;
    }

    ll ans = 0LL;
    for(auto e : m){
        ans += e.second*(e.second-1LL)/2LL;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[] a = new int[n];
			for(int i=0;i<n;i++) a[i] = sc.nextInt();
			int p = sc.nextInt();
			
			int s = 0;
			int g = n-1;
			int m;
			int count = 0;
			
			while(s<=g){
				count++;
				m = (s+g)/2;
				if(a[m]==p) break;
				if(a[m]<p) s = m+1;
				else g = m-1;
			}
			System.out.println(count);
		}	
	}	
}

Measured memory_bytes: 20332
import sys

input = sys.stdin.readline

def main():
    W, H, N = map(int, input().split())
    X = [0, W]
    Y = [0, H]
    for i in range(N):
        x, y, a = map(int, input().split())
        if a == 1:
            X[0] = max(x, X[0])
        elif a == 2:
            X[1] = min(x, X[1])
        elif a == 3:
            Y[0] = max(y, Y[0])
        else:
            Y[1] = min(y, Y[1])
    if X[1] <= X[0] or Y[1] <= Y[0]:
        ans = 0
    else:
        ans = (X[1] - X[0]) * (Y[1] - Y[0])
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9260
def main():
	n = int(input())
	s = list(str(input()))
	# s.sort()
	ans = 1
	# print(s)
	for i in range(len(s)-1):
		if s[i] != s[i+1]:
			ans += 1
	print(ans)



if __name__ == '__main__':
	main()

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

product = 1
flag = 0

if 0 in A:
    print(0)
else:
    for i in range(N):
        product *= A[i]
        if product > 1000000000000000000:
            flag += 1
            break
    if flag == 0:
        print(product)
    else:
        print(-1)


Measured memory_bytes: 21712
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	string s; cin >> s;
	cout << 2018 << s.substr(4,s.size() - 4) << 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 L = A + B;
  int R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  } else if (R > L) {
  	cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define MAX_V 1000000
#define INF 1000000000000000
using namespace std;
ll d[MAX_V];
ll n;
struct edge{ll to,cost;};
vector<edge> G[MAX_V];
typedef pair<ll,ll> P;
void dij(ll s){
  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+n,INF);
  d[s]=0;
  que.push(make_pair(0,s));
  while(!que.empty()){
    P p=que.top();
    que.pop();
    ll v=p.second;
    if(d[v]<p.first) continue;
    for(ll i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;  
        que.push(make_pair(d[e.to],e.to));
      }
    }
  }
}
signed main(){
  ll q,k,a,b,c,x,y;
  cin >> n;
  for(ll i=0;i<n-1;i++){
    cin >> a >> b >> c;
    a--; b--;
    edge t0={b,c},t1={a,c};
    G[a].push_back(t0);
    G[b].push_back(t1);
  }
  cin >> q >> k;
  dij(k-1);
  for(ll i=0;i<q;i++){
    cin >> x >> y;
    cout << (d[x-1]+d[y-1])<<endl;
  }
}


Measured memory_bytes: 32624
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100009
#define mod 100000007
using namespace std;


int main(){//read(x);
//fast;
ll r,g,h,i,j,t,e,a,b,c,n,l,k,d,f,z=0;
    cin>>a;
    a=(a==1)?0:1;
    cout<<a<<endl;
}




















Measured memory_bytes: 3632
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		StringBuilder buf = new StringBuilder();
		StringBuilder buf2 = new StringBuilder();
		buf.append(str);
		int q = scan.nextInt();
		int invert = 1;
		for (int i = 0; i<q; i++) {
			int a = scan.nextInt();
			if (a == 1) {
				invert = invert * -1;
			} else {
				int b = scan.nextInt();
				str = scan.next();
				char[] c = str.toCharArray();
				if (b == 1) {
					if (invert == 1) {
						//buf.insert(0,substr[2] );
						buf2.append(c[0]);
					} else {
						buf.append(c[0]);
					}
				} else {
					if (invert == -1) {
						buf2.append(c[0]);
						//buf.insert(0,substr[2] );
					} else {
						buf.append(c[0]);
					}
				}
			}
		}
		if (invert == -1) {
			//System.out.println(buf.reverse().toString());
			System.out.println(new String(buf.reverse())+new String(buf2));
 		} else {
 			//System.out.println(buf.toString());
 			System.out.println(new String(buf2.reverse())+new String(buf));
 		}
	}
}


Measured memory_bytes: 129844
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;

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

  cin >> A >> B;
  if (A < 1 || A >9) {
    cout << -1 << "\n";
    return 0;
  }

  if (B < 1 || B >9) {
    cout << -1 << "\n";
    return 0;
  }
  cout << A*B << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

div = 0

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):

            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if div in [0, 2]:
                    H = h
                    div = 1
                else:
                    if (H != h):
                        div = 2
                        break

        if div == 2:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    div = 2
                    break

        if div == 2:
            continue

        print(Cx, Cy, H)
        break

    if div == 1:
        break


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	long long int n;
	long long int power = 1;
	
	cin >> n;
	
	for (long long int i = 1; i <= n; i++) {
		power *= i;
                power %= (1000000000 + 7);
	}
	
	cout << power << endl;
	
	return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 0; i < n; i++){
			sum += sc.nextInt();
		}
		System.out.println(h <= sum ? "Yes" : "No");
	}
}


Measured memory_bytes: 48936
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int[] A=new int[5];
        for (int i=0; i<5; i++) {
        	A[i]=gi();
        }
        
        int max=0;
        int t=0;
        for (int i=0; i<5; i++) {
        	int ta=A[i]%10==0 ? A[i]:A[i]+(10-(A[i]%10));
        	t+=ta;
        	if((A[i]%10 !=0) &&(10 - (A[i]%10) >max) ) {
        		max=10 - (A[i]%10);
        	}
        }
        


        System.out.print(t-max);

//        if (s>L[n-2]) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
  string s;
  cin >> s;
  ll l = (ll) s.length();
  map<char,ll> mp;
  for(auto c : s){
    mp[c]++;
  }
  ll minus=0;
  rep(i,26){
    char c = (char)(i+'a');
    if(mp[c]>1) minus += mp[c] * (mp[c]-1) /2;
  }
  cout << l * (l-1) /2 - minus+1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int a[100],n,c=0,b=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<n-1;i++)
    {
        if(a[i-1]>a[i] && a[i+1]>a[i])
        {
            b++;
        }
        else if(a[i-1]<a[i] && a[i+1]<a[i])
        {
            b++;
        }
        else
        {
            c++;
        }
    }
    printf("%d",c);


}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define MAX (1<<17)
using namespace std;
int n,q;
int data[MAX+1];
void add(int i,int v){
  while(i<=n){
    data[i]+=v;
    i+=i&-i;
  }
}
int sum(int i){
  int res=0;
  while(i>0){
    res+=data[i];
    i-=i&-i;
  }
  return res;
}
int main(){
  int c,x,y;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)cout<<sum(y)-sum(x-1)<<endl;
    else add(x,y);
  }
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
    int n, a;
    cin >> n;
    vector <int> b;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if ((n+i) % 2 == 0) {
            b.push_back(a);
        } else {
            b.insert(b.begin(), a);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << b.at(i) << " ";
    }

    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, h, w) for (int i = 0; i < h; i++, cout << endl) for (int j = 0; j < w; j++) cout << a[i][j] << ' ';
#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = 1e13;
const int mmod = 1000000007;

int32_t main()
{
	string ss[3] = {"Sunny", "Cloudy", "Rainy"};
	string s;
	cin >> s;
	
	for (int i = 0; i < 3; i++)
		if (s == ss[i]) cout << ss[(i+1)%3] << endl;
}



Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, co1, co2;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  rep(i, (Size(s) - 1) / 2) co1 += s[i];
  rrep(i, (Size(s) + 3) / 2 - 1, Size(s)) co2 += s[i];
  rep(i, Size(s) / 2) {
    if (s[i] == s[Size(s) - i - 1]) continue;
    Cout("No");
    return 0;
  }
  rep(i, Size(co1) / 2) {
    if (co1[i] == co1[Size(co1) - i - 1]) continue;
    Cout("No");
    return 0;
  }
  rep(i, Size(co2) / 2) {
    if (co2[i] == co2[Size(co2) - i - 1]) continue;
    Cout("No");
    return 0;
  }
  Cout("Yes");
  return 0;
}

Measured memory_bytes: 256
//median min 32 mins
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, M, correct = 0, penalty = 0;
    cin >> N >> M;
    vector<ll> P(M);
    vector<string> S(M);
    map<ll, string> AC;
    map<ll, ll> WA;
    repi(i, M, 0)
    {
        cin >> P[i] >> S[i];
    }
    repi(i, M, 0)
    {
        if (AC.count(P.at(i)) == 0)
        {
            AC.insert(make_pair(P.at(i), S.at(i)));
            if (AC.at(P.at(i)) == "AC")
            {
                correct++;
            }
            else
            {
                WA.insert(make_pair(P.at(i), 1));
            }
        }
        else if (AC.at(P.at(i)) == "AC")
        {
            continue;
        }
        else if (S.at(i) == "WA")
        {
            WA.at(P.at(i))++;
        }
        else
        {
            correct++;
            penalty += WA.at(P.at(i));
            AC.at(P.at(i)) = "AC";
        }
    }
    cout << correct << " " << penalty << endl;
    return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
#define MAX 100000
#define MIN -1

struct Node{ int parent, left, right;};
struct Node T[MAX];

int getDepth(int);
void print(int);
int  D[MAX];
int main(){
  int i,j,n,x,y,c,l,a;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    T[i].parent = T[i].left = T[i].right = MIN;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d%d",&x,&y);
    for ( j = 0; j < y; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[x].left = c;
      else T[l].right = c;
      l = c;
      T[c].parent =x;
    }
  }
  
  a=0;
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > a ){
      a = D[i];
    }
  }

  for ( i = 0; i < n; i++ ){
    print(i);
  }
  
  return 0;
}


int getDepth(int u){
  int d=0;
  while(T[u].parent!=MIN){
    u=T[u].parent;
    d++;
  }
  return d;
}


void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("depth = %d, ", D[u]);

  if ( T[u].parent == MIN) printf("root, [");
  else if ( T[u].left == MIN) printf("leaf, [");
  else printf("internal node, [");

  for(i = 0, c = T[u].left; c != MIN; i++, c = T[c].right){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read(){
	ll x=0,sign=1;char s=getchar();
	while(!isdigit(s)){if(s=='-')sign=-1;s=getchar();}
	while(isdigit(s))x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return x*sign;
}
double n,a[102],sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],sum+=1/a[i];
	printf("%.9lf",1/sum);
	return 0;
}


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

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

    int sum = 0;
    for (int i = 1; i <= N; i+=2) {
        int counter = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                counter++;
            }
        }
        if (counter >= 8) {
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	double N;
	long long int A,B,answer;
	cin>>N;
	A = sqrt(N);
	answer = 1 + N - 2;
	while( A != 1){
		if( (long long int)N % A == 0){
			B = N / A;
			answer = A + B - 2;
			break;
		}
		A--;
	}
	cout<<answer<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, j,H,W;
    while(scanf("%d %d",&H,&W)!=EOF){
     if(H==0&&W==0){
        break;
     }
    for ( i = 0; i < H; i++ ){
    for ( j = 0; j < W; j++ ){
        printf("#");
    }
    printf("\n");
   
    }
    printf("\n");
}
    

    return(0);// Your code 
    
}


Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){
	string s, p;
	bool flag=false;
	int i=0;
	
	cin >> s;
	cin >> p;
	
	int len=s.size();
	int len2=p.size();
	//printf("len=%d, %d\n", len, len2);
	
	while(i<len && !flag){
		if(s[i] == p[0]){
			for(int a=0; a<len2; ++a){
				if(s[ (i+a)%len ] != p[a]){
					flag = false; 
					break;
				}
				else flag = true;
			}
		}
	
		++i;
	}
	
	if(flag) printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int n; cin >> n;
    int a[100000];

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

    map<int,int> mp;

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

    int ans=0;
    for(auto p: mp){
        int key = p.first;
        int value = p.second;
        if ( value - key< 0) {
            ans += value;
        }else
            ans += value - key;

    }

    cout << ans << endl;
}

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

char str[105][16];

int main()
{
    int f = 0;
    
    int n;
    scanf("%d", &n);
    scanf("%s", str[0]);

    for (int i = 1; i < n; i++) {
        scanf("%s", str[i]);

        if (str[i - 1][strlen(str[i - 1]) - 1] !=
            str[i][0]) {
            f = 1;
        }

        int j = 0;
        while (j < i && strcmp(str[j], str[i])) {
            j++;
        }

        if (j < i) {
            f = 1;
        }
    }

    if (f) {
        puts("No");
    }
    else {
        puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string p,x;
//vector<int>v;
//map<int,int>mp;
set<int>s;
int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        s.insert(l);
    }
    l=s.size();
    if(n==l)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 100005
#define ll long long int
long long int MOD=998244353;
long long int mod=1e9+7;
long long int INF=1e18;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        cout<<"x";
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(n) fori(somethingStupid,1,(n))

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

bool tests = false;

void solve(){
    int n; cin >> n;
    cout << (-n % 1000+1000)%1000<< endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    rep(t) solve();
    return 0;
}


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 100000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define int long long 

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

  int N,C;
  cin>>N>>C;
  vector<ll>rx(N+1),rX(N+1),X(N+1),x(N+1),rv(N+1),v(N+1);
  x[0]=0,rx[0]=0,X[0]=0,v[0]=0,rX[0]=0,rv[0]=0;
  for(int i=1;i<=N;i++)cin>>X[i]>>v[i];
  for(int i=1;i<=N;i++)rX[i]=C-X[N-i+1];
  for(int i=1;i<=N;i++)x[i]=X[i]-X[i-1];
  for(int i=1;i<=N;i++)rx[i]=rX[i]-rX[i-1];
  for(int i=1;i<=N;i++)rv[i]=v[N-i+1];

  /*
  for(int i=0;i<=N;i++)cout<<x[i]<<" "<<v[i]<<endl;
  cout<<endl;
  for(int i=0;i<=N;i++)cout<<rx[i]<<" "<<rv[i]<<endl;
  cout<<endl;
  */

  vector<int>L(N+1);
  int ll_=0;
  for(int l=0;l<=N;l++){
    ll_+=v[l]-x[l];
    if(l==0)L[0]=ll_;
    else L[l]=max(L[l-1],ll_);
  }
  vector<int>R(N+1);
  int rr_=0;
  for(int r=0;r<=N;r++){
    rr_+=rv[r]-rx[r];
    if(r==0)R[0]=rr_;
    else R[r]=max(R[r-1],rr_);
  }

  /*
  for(auto it:L)cout<<it<<endl;
  cout<<endl;
  for(auto it:R)cout<<it<<endl;
  cout<<endl;
  */

  ll_ = 0;
  int ans1 = 0;
  for(int l=0;l<=N;l++){
    int rmax=N-l;
    ll_+=v[l]-2*x[l];
    int A = ll_+R[rmax];
    if(ans1<A)ans1=A;
  }
  rr_ = 0;
  int ans2 = 0;
  for(int r=0;r<=N;r++){
    int lmax=N-r;
    rr_+=rv[r]-2*rx[r];
    int B = rr_+L[lmax];
    if(ans2<B)ans2=B;
  }

  //cout<<endl;
  //cout<<ans1<<" "<<ans2<<endl; 
  cout<<max(ans1,ans2)<<endl; 
  return 0;
}


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

using namespace std; //ごめんなさい
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,M;
  cin>>N>>M;
  vector<ll>x(N),y(N),z(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>z[i];
  int B=pow(2,3);
  ll ans=0;
  for(int bit=0;bit<B;bit++){
    vector<int>a(3);
    for(int i=0;i<3;i++){
      if((bit>>i)&1)a[i]=1;
      else a[i]=-1;
    }
    vector<ll>X(N);
    for(int i=0;i<N;i++)X[i]=a[0]*x[i]+a[1]*y[i]+a[2]*z[i];
    sort(rng(X));
    reverse(rng(X));
    ll res=0;
    for(int i=0;i<M;i++)res+=X[i];
    ans=max(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


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

import collections
c = collections.Counter(x)

rems = [[0] * 2 for _ in range(m)]

for key, val in c.items():
    rems[key%m][0] += val%2
    rems[key%m][1] += (val//2) * 2

ans = 0
for i in range(1 + m//2):
    if(i*2 == m)|(i==0):
        ans += sum(rems[i])//2
        continue

    j = m-i
    if(sum(rems[i]) < sum(rems[j])):
        pair_mul = sum(rems[i])
        more = j
    else:
        pair_mul = sum(rems[j])
        more = i
    pair_same = (rems[more][1] - max(pair_mul - rems[more][0], 0))//2
    ans += pair_mul + pair_same

print(ans)

Measured memory_bytes: 71656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		if (n < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	}
}


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

typedef long long ll;

int N,K;
ll H[310];
ll dp[310][310][310];
ll inf = 1e18;

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> H[i+1];
    for (int i = 0; i < 310; i++)
        for (int j = 0; j < 310; j++)
            for (int k = 0; k < 310; k++)
                dp[i][j][k] = inf;

    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= K; j++) {
            for (int k = 0; k <= K; k++) {
                //not delete
                if (i - k >= 0 && j - k >= 0)
                    dp[i+1][j][0] = min(dp[i+1][j][0], dp[i - k][j - k][0] + max(0LL, H[i + 1] - H[i - k]));
                //delete
                if (j + 1 <= K)
                    dp[i+1][j+1][k+1] = min(dp[i+1][j+1][k+1], dp[i][j][k]);
            }
        }
    }

    ll ans = inf;
    for (int j = 0; j <= K; j++) 
        for (int k = 0; k <= K; k++) 
            ans = min(ans, dp[N][j][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 232960
import functools


@functools.lru_cache(maxsize=None)
def num_counts(size, P):
    if size == 1:
        return 1 + (A[size - 1] + 1) % 2 if P == 0 else A[size - 1] % 2
    if A[size - 1] % 2 == 0:
        return num_counts(size - 1, P) * 2
    else:
        return num_counts(size - 1, P) + num_counts(size - 1, (P + 1) % 2)


if __name__ == "__main__":
    N, P = [int(x) for x in input().split(" ")]
    A = [int(x) for x in input().split(" ")]
    print(num_counts(len(A), P))


Measured memory_bytes: 67532
import java.util.Arrays;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  int k = sc.nextInt();
  int k1 = 0;
  int k2 = 0;
  int k3;
  char[] alp = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','*'};
  int[] ex = new int[26];
  Arrays.fill(ex,0);
  for(int i = 0;i < s.length();i++){
    for(int j = 0;j < 26;j++){
  if(s.charAt(i) == alp[j] && ex[j] == 0){
    ex[j] = 1;
    break;
  }
    }
  }
  int first = 26;
  int second = 26;
  int third = 26;
  for(int i = 0;i < 26;i++){
    if(first == 26 && ex[i] == 1){
      first = i;
    }
    else if(first != 26 && second == 26 && ex[i] == 1){
      second = i;
    }
    else if(first != 26 && second != 26 && third == 26 && ex[i] == 1){
      third = i;
      break;
    }
  }
  String ans = "zzzzz";
  for(int i = 0;i < s.length();i++){
    if(s.charAt(i) == alp[first]){
      int till = s.length()  -i;
      k1 = k - till;
      if(k1 <= 0){
        if(s.substring(i,i+k).compareTo(ans) <= 0) {
        	ans = s.substring(i,i+k);
        }
      }
      else{for(int j = 0;j < s.length();j++){
    	    if(s.charAt(j) == alp[second]){
    	         till = s.length()  -j;
    	        k2 = k1 - till;
    	        if(k2 <= 0){
    	        	if(s.substring(j,j+k1).compareTo(ans) <= 0) {
    	            	ans = s.substring(j,j+k1);
    	            }
    	        }
    	        else{for(int m = 0;m < s.length();m++){
    	    	    if(s.charAt(m) == alp[third]){
    	    	         till = s.length()  -m;
    	    	        k3 = k2 - till;
    	    	        if(k3 <= 0){
    	    	        	if(s.substring(m,m+k2).compareTo(ans) <= -1) {
    	    	            	ans = s.substring(m,m+k2);
    	    	            }
    	    	        }
    	    	        
    	    	      }
    	    	    }
    	        }
    	      }
    	    }
    	    
    }
  }
  }
  System.out.println(ans);
}}

Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
  int ans;
  if(n==100000) ans=90909;
  else if(n>=10000) ans=9+900+n-10000+1;
  else if(n>=1000) ans=9+900;
  else if(n>=100) ans=9+n-100+1;
  else if(n>=10) ans=9;
  else ans=n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

class calc
{
  static void Main(string[] args)
  {
    var targetNumber = 0;
   	int index = 1;
    string[] str = Console.ReadLine().Split(' ');
    foreach(var number in str)
    {
      if(int.Parse(number) == 0)
        targetNumber = index;
      index++;
    }
	Console.WriteLine(targetNumber);
  }
}

Measured memory_bytes: 27396
{-# LANGUAGE OverloadedStrings #-} 
import Data.Text.Lazy as T
import Data.Text.Lazy.IO as TIO
import Data.Monoid
import Data.Vector.Unboxed
import Data.List

main = do
  input <- TIO.getContents
  let ls = T.lines input 
      n = ls !! 0
      l = T.words $ ls !! 1
      (s0,s2,s4) = Data.List.foldl f (0,0,0) l
        where f  (s0,s2,s4) a  | ( (read $  T.unpack a) `mod` 4) == 0 = (s0, s2, s4 + 1)
                               | ( (read $  T.unpack a) `mod` 2 ) == 0 =  (s0, s2 + 1, s4)
                               | otherwise =  (s0 + 1, s2 , s4)
      getR (s0,s2,s4) | (s0<=s4) || ( s0 == s4+1 && s2 == 0 ) = "Yes"  
                      | otherwise = "No"
  Prelude.putStr $  getR (s0,s2,s4)


Measured memory_bytes: 7932
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int h, w, d;
    cin >> h >> w >> d;
    vector<P> p(h * w);
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            int a;
            cin >> a;
            --a;
            p[a] = P(i, j);
        }
    }
    vector<vector<int>> S(d);
    for(int i = 0; i < d; ++i){
        S[i].emplace_back(0);
        for(int j = i; j + d < h * w; j += d){
            int cost = abs(p[j + d].first - p[j].first) + abs(p[j + d].second - p[j].second);
            S[i].emplace_back(S[i].back() + cost);
        }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l, --r;
        int idx = l % d;
        int ans = S[idx][r / d] - S[idx][l / d];
        cout << ans << '\n';
    }
}

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

bool isPalindrome(string s){
	string t = s;
	reverse(t.begin(),t.end());
	return s == t;
}

int main(){
	string s;
	cin >> s;
	bool ans = true;
	if(!isPalindrome(s)) ans = false;
	if(!isPalindrome(s.substr(0,s.size()/2))) ans = false;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;


}



Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
vector<string> vt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a;
	cin >> a;
	int t = a.size();
	for (int i = 0; i < t; i++)
	{
		string c;
		for (int y = 0; y < 5; y++)
		{
			if (i + y >= t)continue;
			c += a[i + y];
			vt.push_back(c);
		}
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	int m;
	cin >> m;
	cout << vt[m - 1];
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(){

    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    printf("%d", max(max(a,b),c) - min(min(a,b),c));

    return 0;
}

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int min(int a, int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}

Measured memory_bytes: 128