akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);

	//0118
	static class PropertyDistribution {
		int h, w;
		char[][] field;
		int[] dir_y = {-1, 0, 1, 0};
		int[] dir_x = { 0, 1, 0,-1};
		Stack<Point> stack;

		void print_divideNum() {
			for(;;) {
				h = sc.nextInt();
				w = sc.nextInt();
				if(h == 0 || w == 0) break;
				String[] str = new String[h];
				for(int i=0; i<h; i++) {str[i] = sc.next();}

				field = new char[h][w];
				for(int i=0; i<h; i++) {
					for(int j=0; j<w; j++) {field[i][j] = str[i].charAt(j);}
				}

				stack = new Stack<Point>();
				int count = 0;
				for(int y=0; y<h; y++) {
					for(int x=0; x<w; x++) {
						if(field[y][x] != 'X') {
							count++;
							searchField(new Point(y, x), field[y][x]);
						}
					}
				}
				System.out.println(count);
			}
		}

		void searchField(Point p, char mark) {
			stack.push(p);
			while(!stack.empty()) {
				Point point = stack.pop();
				for(int i=0; i<4; i++) {
					int ny = point.y + dir_y[i], nx = point.x + dir_x[i];
					if(ny >= 0 && nx >= 0 && ny < h && nx < w) {
						if(field[ny][nx] == mark) {
							stack.push(new Point(ny, nx));
							field[ny][nx] = 'X';
						}
					}
				}
			}
		}

		static class Point {
			public int y, x;
			public Point(int y, int x) {
				this.y = y; this.x = x;
			}
		}
	}

	public static void main(String[] args) {
		PropertyDistribution pd = new PropertyDistribution();
		pd.print_divideNum();
	}
}

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

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
        int ma = 0;
        int idx = 0;
        bool sign = false;
        for (int i = 0; i < n; i ++) { 
                if (ma < abs(a[i])) {
                        ma = max(ma, abs(a[i]));
                        idx = i;
                        sign = a[i] > 0;
                }
        }
        vector<pair<int, int>> ans;
        for (int i = 0; i < n; i ++) {
                if (i != idx) {
                        ans.emplace_back(idx, i);
                        a[i] += a[idx];
                }
        }
        if (sign) {
                for (int i = 0; i < n - 1; i ++) {
                        ans.emplace_back(i, i + 1);
                        a[i + 1] += a[i];
                }
        } else {
                for (int i = n - 1; i >= 1; i --) {
                        ans.emplace_back(i, i - 1);
                        a[i - 1] += a[i];
                }
        }
        printf("%d\n", (int) ans.size());
        for (auto res : ans) printf("%d %d\n", res.first + 1, res.second + 1);
        return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    ans = 0

    """
    他言語ならこれで行けるはずだが、pythonだとTLE
    dp = [[0 for _ in range(N+10)] for _ in range(N+10)]
    for i in reversed(range(N)):
        for j in reversed(range(i+1,N)):
            if S[i] != S[j]:
                dp[i][j] = 0
            else:
                dp[i][j] = dp[i+1][j+1] + 1
            if i >= j: continue
            tmp = min(dp[i][j], j-i)
            ans = max(ans, tmp)
    """
    i = j = 0

    while  j <= N-1:
        # 頭から見ていき、部分文字列が、その後ろのどこかにあれば範囲を広げる。かぶってはいけないのでj-iが最大
        if S[i:j] in S[j:]:
            ans = max(ans, j-i)
            j += 1
        else:
            i += 1
        

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		S = scn.nextLine();

		System.out.println(searchAns(N));
	}

	static String S;

	public static boolean solve(int n) {// 必要な引数を入れる
		for (int i = 0; i < S.length() - 2 * n + 1; i++) {
			String s = S.substring(i, i + n);
			String ss = S.substring(i + n);
			if (ss.contains(s)) {
				S = S.substring(i);
				return true;
			}
		}
		return false;
	}

	public static int searchAns(int N) {// 必要な引数を入れる
		int l = 1;
		while (solve(l)) {
			l++;
		}
		return l-1;
	}
}

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

#define ll long long
#define F first
#define S second
using namespace std;

template <class T, class P>
ostream &operator << (ostream &out, pair<T, P> &a){
    out << a.F << " " << a.S;
    return out;
}

template <class T>
ostream &operator << (ostream &out, vector <T> &a){
    for(auto &x : a)out << x << ' ';
    return out;
}

template <class T>
ostream &operator << (ostream &out, set <T> &a){
    for(auto &x : a) out << x << ' ';
    return out;
}

template <class T, class P>
ostream &operator << (ostream &out, map <T, P> &a){
    for(auto &x : a) out << x.F << " " << x.S << endl;
    return out;
}
const int N = 1e5 + 10;
const ll INF = 1e9 + 7;

int n;
string s;
ll t[N], d[N];
ll ans;
map <ll, ll> mp;

void solution(){
    int cnt = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> t[i];
        d[i] = t[i];
    }
    sort(d + 1, d + 1 + n);
    for(int i = 1; i <= n; i++){
        mp[d[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        if(abs(i - mp[t[i]]) % 2 == 1)cnt++;
    }
    cout << cnt / 2;
}


int main(){
    int n = 1;
   //cin >> n;
    while(n){
        n--;
        solution();
    }
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int64_t N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int64_t i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin() , A.end());
    int64_t sum = 0;
    for(int64_t i = 0; i < N - K; i++){
        sum += A.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] fib = new int[n+1];
		fib[0] = 1;
		fib[1] = 1;
		
		for(int i=2; i<n+1; i++) {
			fib[i] = fib[i-1] + fib[i-2];
		}
		
		System.out.println(fib[n]);
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

Measured memory_bytes: 24412
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;


int main(){
    int n;
    string s;
    cin>>n>>s;
    int left=0, right=0;
    int l=0, r=0;
    for(int i=0;i<n;i++){
        if(s[i]==')'){
            if(left==0){
                l++;
            }else{
                left--;
            }
        }else{
            left++;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='('){
            if(right==0){
                r++;
            }else{
                right--;
            }
        }else{
            right++;
        }
    }
    reverse(s.begin(),s.end());
    while(l){
        s+='(';
        l--;
    }
    reverse(s.begin(),s.end());
    while(r){
        s+=')';
        r--;
    }
    cout<<s<<endl;


}

Measured memory_bytes: 3592
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { //Partition babyyyyyyyyy
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		PriorityQueue<Long> can = new PriorityQueue<Long>(Collections.reverseOrder());
		PriorityQueue<Long> must = new PriorityQueue<Long>(Collections.reverseOrder());
		for (int i = 0; i < N; i++) can.add(I.nextLong());
		int M = I.nextInt();
		for (int i = 0; i < M; i++) must.add(I.nextLong());
		while (!can.isEmpty()) {
			long x = can.peek();
          	long y = must.peek();
          	if (x==y) must.poll();
			can.poll(); //Have to remove candidate regardless
			if (must.isEmpty()) break;
		}
		O.pln(must.size()==0?"YES":"NO");
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 73524
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()

	answer := calcName(n)
	fmt.Println(answer)

}

func debug(a ...interface{}) {
	fmt.Println(a...)
}

func calcName(n int) string {
	if n == 0 {
		return ""
	}
	n--
	return calcName(n/26) + string(n%26+97)
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    
    reverse(a.begin(), a.end());
    
    for(i = 0; i < n; i++){
        if(i == n - 1){
            cout << a.at(i) << endl;
        }
        else{
            cout << a.at(i) << " ";
        }
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
  if(a>b){
    return gcd(b,a);
  }
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  long long N,M;
  cin>>N>>M;
  string S,T;
  cin>>S>>T;
  long long X=gcd(N,M);
  bool ok=true;
  long long n=N/X;
  long long m=M/X;
  for(int i=0;i<X;i++){
    if(S[i*n]!=T[i*m]){
      ok=false;
      break;
    }

  }
  if(ok){
    cout<<N*M/X<<endl;
  }else{
    cout<<-1<<endl;
  }



}





  
  


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

using namespace std;

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

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

    if (h <= sum_val) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    ll val;
    cin >> n;
    vector<vector<ll>> arr;
    for(int i = 0; i < n; i++) {
        cin >> val;
        arr.push_back({val, i});
    }
    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());
    vector<vector<ll>> dp(n, vector<ll>(n, INT_MIN));
    auto dfs = [&] (auto& self, int l, int r) -> ll { // possible target range
        if (dp[l][r] != INT_MIN)
            return dp[l][r];

        int idx = n - (r-l+1);
        ll val = arr[idx][0];
        ll pos = arr[idx][1];
        if(l == r) {
            dp[l][r] = val*llabs(pos-l);
            return dp[l][r];
        }
        // move leftmost
        dp[l][r] = self(self, l+1, r) +val*llabs(pos-l);
        // move right most
        dp[l][r] = max(dp[l][r], self(self, l, r-1)+val*llabs(pos-r));
        // printf("(%d, %d) => %lld\n", l, r, dp[l][r]);
        return dp[l][r];
    };
    cout << dfs(dfs, 0, n-1) << endl;
    return 0;
}



Measured memory_bytes: 34884
while 1:
    a, b, c = map(int, input().split())
    if a == 0:
        break

    data = []
    n = int(input())
    for _ in range(n):
        data.append(list(map(int, input().split())))

    data = sorted(data, key=lambda x: -x[3])
    parts = [2] * (a+b+c)

    for d in data:
        a = d[0]
        b = d[1]
        c = d[2]
        if d[3] == 1:
            parts[a-1] = 1
            parts[b-1] = 1
            parts[c-1] = 1
        else:
            if parts[a-1] == 1 and parts[b-1] == 1:
                parts[c-1] = 0
            elif parts[c-1] == 1 and parts[b-1] == 1:
                parts[a-1] = 0
            elif parts[a-1] == 1 and parts[c-1] == 1:
                parts[b-1] = 0

    for part in parts:
        print(part)


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

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> c(h);

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

    for(int i=0;i<h;i++){
        cout<<c[i]<<endl;
        cout<<c[i]<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 100000000
#define ll long long

int dp[1 << 16];
int main() {
	int N;
	while (cin >> N, N) {
		int t[16][17];
		REP(i, 0, N) {
			REP(j, 0, N + 1) {
				cin >> t[i][j];
			}
		}

		REP(i, 0, 1 << N) dp[i] = INF;
		dp[0] = 0;
		REP(mask, 0, (1 << N)) {
			if (dp[mask] == INF) continue;

			REP(i, 0, N) {
				if (mask&(1 << i)) continue;

				int min_time = t[i][0];
				REP(j, 0, N) {
					if (mask&(1 << j)) min_time = min(min_time, t[i][j + 1]);
				}
				dp[mask | (1 << i)] = min(dp[mask | (1 << i)], dp[mask] + min_time);
			}
		}

		cout << dp[(1 << N) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3340
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n+1];
    a[0] = 1;
    for(int i = 1; i <= n; i++) {
      a[i] = sc.nextInt();
    }

    long ans = 0;
    int max = a[1];
    for(int i = 2; i <= n; i++) {
      if(max > a[i]) {
        ans += (max-a[i]);
      }else{
        max = a[i];
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 60448
// Problem : C - Sqrt Inequality
// Contest : AtCoder - Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#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;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ld a,b,c;
	cin>>a>>b>>c;
	ld a1,b1,c1;
	a1=sqrt(a);
	b1=sqrt(b);
	c1=sqrt(c);
	if(a1+b1+1.0E-14<c1)
	cout<<"Yes";
	else 
	cout<<"No";
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3748
#include <stdio.h>

int main()
{
	long k,n;
	scanf("%ld%ld", &k, &n);
	long a[n];
	int i = 0;
	while (i < n)
		scanf("%ld", &a[i++]);
	long sum = a[n - 1] - a[0];
	i = 1;
	while (i < n)
	{
		if ((k - a[i] + a[i - 1]) < sum)
		{
			sum = k - a[i] + a[i - 1];
		}
		i++;
	}
	printf("%ld", sum);
	return (0);
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int main(){
//  ios::sync_with_stdio(false);
//  cin.tie(0);
  ll n;
  while (cin >> n, n) {
    ll mx = 0;
    for (ll i = 1; i <= n; i++) {
      for (ll j = 1; j <= n; j++) {
        if (i * i * i + j * j * j <= n * n * n) {
          mx = max(mx,i * i * i + j * j * j);
        }
      }
    }
    cout << n * n * n - mx << endl;

  }
  return 0;
}



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

int main(){
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  
  long long ans = 0;
  for(int i = 0; i*r <= n; i++){
    for(int j = 0; j*g <= n; j++){
      int now = n - i*r - j*g;
      if(now < 0) continue;
      if(now % b) continue;
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define MOD 1000000007
using namespace std;
typedef long long int ll;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll p[n];
    for(ll i=0;i<n;i++)
        p[i]=0;
    p[n-1]=a[n-1];
    for(ll i=n-2;i>0;i--)
    {
        p[i]=p[i+1]+a[i];
    }
    ll sum=0;
    for(ll i=0;i<n-1;i++)
    {
       sum+=((a[i]%MOD)*(p[i+1]%MOD))%MOD;
    }
    cout<<sum%MOD<<"\n";
}

Measured memory_bytes: 6764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit

@njit('(i4[:],i4[:],i4[:],i4)', cache=True)
def EulerTour(head, nxt, to, root):
    N = len(head) - 1
    parent = np.zeros_like(head)
    ind_L = np.empty_like(head)
    ind_R = np.empty_like(head)
    tour = np.empty(N + N, np.int32)
    stack = np.empty(N + N, np.int32)
    stack[0] = -root
    stack[1] = root
    t = -1
    s = 2
    while s > 0:
        s -= 1
        v = stack[s]
        t += 1
        tour[t] = v
        if v > 0:
            ind_L[v] = t
            p = parent[v]
            k = head[v]
            while k != -1:
                w = to[k]
                if w == p:
                    k = nxt[k]
                    continue
                parent[w] = v
                stack[s] = -w
                s += 1
                stack[s] = w
                s += 1
                k = nxt[k]
        else:
            ind_R[-v] = t
    return tour, ind_L, ind_R, parent


@njit('(i4[:],i4[:],i4[:],i4[:],i4[:])', cache=True)
def main(C, tour, ind_L, ind_R, parent):
    N = len(C) - 1
    removed = np.zeros(N + 1, np.int64)
    answer = np.full_like(removed, N * (N + 1) // 2)
    memo = np.zeros_like(answer)
    for v in tour:
        if v > 0:
            memo[v] = removed[C[parent[v]]]
        else:
            v = -v
            removed[C[v]] += 1
            p = parent[v]
            x = (ind_R[v] - ind_L[v]) // 2 + 1  # subtree size
            x -= removed[C[p]] - memo[v]
            answer[C[p]] -= x * (x + 1) // 2
            removed[C[p]] += x
    for i, x in enumerate(removed):
        x = N - x
        answer[i] -= x * (x + 1) // 2
    return answer


@njit('(i4[:],i4[:],i4,i4)', cache=True)
def edges_to_array(A, B, N, M):
    head = np.full(N + 1, -1, np.int32)
    nxt = np.empty(M + M, np.int32)
    to = np.empty(M + M, np.int32)
    for i in range(M):
        a = A[i]
        b = B[i]
        nxt[i << 1] = head[a]
        to[i << 1] = b
        head[a] = i << 1
        nxt[i << 1 | 1] = head[b]
        to[i << 1 | 1] = a
        head[b] = i << 1 | 1
    return head, nxt, to


N = int(readline())
C = np.zeros(N + 1, np.int32)
C[1:] = np.array(readline().split(), np.int32)
AB = np.array(read().split(), np.int32)
head, nxt, to = edges_to_array(AB[::2], AB[1::2], N, N - 1)

tour, ind_L, ind_R, parent = EulerTour(head, nxt, to, 1)
answer = main(C, tour, ind_L, ind_R, parent)
print('\n'.join(answer[1:].astype(str)))


Measured memory_bytes: 157400
import java.util.Scanner;
import java.util.HashMap;
public class Main{
	static boolean[] kk;
	static HashMap<Integer,Long>[] map;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		kk=new boolean[n];
		map=new HashMap[n];
		for(int i=0; i<n; i++){
			map[i]=new HashMap<>();
		}
		for(int i = 0; i<n-1; i++){
			int u = sc.nextInt();
			int v = sc.nextInt();
			long w = sc.nextLong();
			map[u-1].put(v,w);
			map[v-1].put(u,w);
		}
		dfs(-1,0,0);
		for(int i=0; i<n; i++){
			if(kk[i]){
				System.out.println(1);
			}else{
				System.out.println(0);
			}
		}
	}
	static void dfs(long sum,int r,int o){
		if(sum%2==0){
			kk[r]=true;
		}
		for(int j:map[r].keySet()){
			if(j-1!=o){
				dfs(map[r].get(j)+sum,j-1,r);
			}
		}
		return;
	}
}


Measured memory_bytes: 124248
# -- coding: utf-8 --
N = int(input())
dict_res = {}
for i in range(N):
    char = input()
    if not char in dict_res:
        dict_res[char] = 1
    else:
        dict_res[char] += 1
M = int(input())
for i in range(M):
    char = input()
    if not char in dict_res:
        dict_res[char] = -1
    else:
        dict_res[char] -= 1
res = max(dict_res.values())
if res < 0:
    print(0)
else:
    print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M, ans = 0, s = 0;
	vector<int> A;
	unordered_map<int,int> d;
	
	cin>>N>>M;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		s += A[i];
		
		d[s%M]++;
	}
	s = 0;
	for(int i = 0; i < N; i++){
		int t = s%M;
		ans += d[t];
		// cout<<A[i]<<" "<<d[t]<<" "<<t<<endl;
		s += A[i];
		d[s%M]--;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 4492
def main():
    S = input()
    T = input()
    t = len(T)
    for i in range(len(S) - t, -1, -1):
        for j in range(t):
            if S[i + j] != T[j] and S[i + j] != '?':
                break
        else:
            print((S[:i] + T + S[i + t:]).replace("?","a"))
            exit()

    print("UNRESTORABLE")
main()

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n;
  std::cin >> n;
  vi b;
  REP(i, n - 1) { b.PB(read()); }
  int sum = b[0];
  FOR(i, 1, n - 1) { sum += min(b[i], b[i - 1]); }
  print(sum + b[n - 2]);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

    int a = scan.nextInt();
    int b = scan.nextInt();

    if(a < b){
    System.out.println("a < b");
    }else if(a > b){
    System.out.println("a > b");
    }else{
    System.out.println("a == b");
    }
}
}

Measured memory_bytes: 26184
using System;

class P
{
  static void Main()
  {
    var a = Console.ReadLine().Split(' ');
    int W = int.Parse(a[0]), H = int.Parse(a[1]), x = int.Parse(a[2]), y = int.Parse(a[3]), r = int.Parse(a[4]);
    Console.WriteLine(x - r < 0 || x + r > W || y - r < 0 || y + r > H ? "No" : "Yes");
  }
}

Measured memory_bytes: 9004
#include<iostream>
#include<iomanip>
using namespace std;
//　int/double　だと計算結果がint型になってしまう。
//　3は3.0って書けばdouble型として認識してくれる。
int main(void) {
	double L;
	cin >> L;
	//long double AA = L/3;
	//long double Ans = AA * AA * AA;
	//int L = 3;
	double Ans = (L / 3.0) * (L / 3.0) * (L / 3.0);
	cout << fixed << setprecision(10) << Ans << endl;
}

Measured memory_bytes: 256
bingos = 3.times.map{ gets.chomp.split(' ').map(&:to_i) }.flatten
n = gets.to_i
arys = []
n.times do
  arys << gets.to_i
end

arys.each do |ary|
  idx = bingos.index(ary)
  bingos[idx] = nil if idx
end

if (bingos[0].nil? && bingos[3].nil? && bingos[6].nil?) || (bingos[1].nil? && bingos[4].nil? && bingos[7].nil?) || (bingos[2].nil? && bingos[5].nil? && bingos[8].nil?) || (bingos[0].nil? && bingos[4].nil? && bingos[8].nil?) || (bingos[2].nil? && bingos[4].nil? && bingos[6].nil?) || (bingos[0].nil? && bingos[1].nil? && bingos[2].nil?) || (bingos[3].nil? && bingos[4].nil? && bingos[5].nil?) || (bingos[6].nil? && bingos[7].nil? && bingos[8].nil?)
  print 'Yes'
else
  print 'No'
end


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ld A, B; cin >> A >> B;
    cout << (ll)floor(A * B) << "\n";
}

Measured memory_bytes: 3800
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a, b;
	cin >> a >> b;
	int i;
	for(i=0;i<b.size();i++){
		cout << a[i];
		cout << b[i];
	}
	if(a.size()>b.size())
		cout << a[a.size()-1];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
#include <unordered_map>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int ch, cv;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while(cin>>ch>>cv,ch){
	unordered_map<string,int> memo;
	string xs, g;
	REP(i,9){ string s; cin >> s; xs += s;}
	REP(i,9){ string s; cin >> s; g += s;}

	priority_queue<pair<int,string>, vector<pair<int,string>>, greater<pair<int,string>>> pq;
	pq.push(MP(0,xs));
	memo[xs] = 0;
	while(!pq.empty()){
	  auto p = pq.top(); pq.pop();
	  if(memo[p.second] < p.first) continue;
	  if(p.second == g) break;

	  int i;
	  for(i=0;;++i) if(p.second[i] == '0') break;

	  string tmp = p.second;
	  int d = p.first + ch;
	  swap(tmp[i], tmp[(i+8)%9]);
	  if(!memo.count(tmp) || memo[tmp] > d){
		memo[tmp] = d;
		pq.push(MP(d,tmp));
	  }
	  tmp = p.second;
	  swap(tmp[i], tmp[(i+1)%9]);
	  if(!memo.count(tmp) || memo[tmp] > d){
		memo[tmp] = d;
		pq.push(MP(d,tmp));
	  }

	  tmp = p.second;
	  d = p.first + cv;
	  swap(tmp[i], tmp[(i+3)%9]);
	  if(!memo.count(tmp) || memo[tmp] > d){
		memo[tmp] = d;
		pq.push(MP(d,tmp));
	  }
	  tmp = p.second;
	  swap(tmp[i], tmp[(i+6)%9]);
	  if(!memo.count(tmp) || memo[tmp] > d){
		memo[tmp] = d;
		pq.push(MP(d,tmp));
	  }
	}
	cout << memo[g] << endl;
  }

  return 0;
}

Measured memory_bytes: 42212
import math
A,B,C = map(int, input().split())

#A-B Partern
base1 = A*B
part1_a = math.ceil(C/2)
part1_b = C-part1_a 
ans1 = abs((base1*part1_a)-(base1*part1_b))

#A-C Partern
base2 = A*C
part2_a = math.ceil(B/2)
part2_b = B - part2_a 
ans2 = abs((base2*part2_a)-(base2*part2_b))

#B-C Partern
base3 = B*C
part3_a = math.ceil(A/2)
part3_b = A - part3_a 
ans3 = abs((base3*part3_a)-(base3*part3_b))

print(min(ans1,ans2,ans3))

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int begin_bracket = 0, end_bracket = 0;
  int ne_begin_bracket = 0, ne_end_bracket = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (s.at(i) == '(') {
      begin_bracket++;
    } else {
      end_bracket++;
      if (begin_bracket + ne_begin_bracket < end_bracket) {
        ne_begin_bracket++;
      }
    }
  }
  for (i = 0; i < ne_begin_bracket; i++) {
    cout << '(';
  }
  cout << s;
  for (i = 0; i < begin_bracket + ne_begin_bracket - end_bracket; i++) {
    cout << ')';
  }
  cout << endl;

  return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n;
  string s;

  cin >> n;
  getline(cin, s);
  REP(i, n) {
    getline(cin, s);
    while(1) {
      string::size_type index = s.find("Hoshino");
      if(index == string::npos) break;
      else s.replace(index, 7, "Hoshina");
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N;
	scanf("%d", &N);
	int A[N], i, j, k;
	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);

	int max = 0;
	for (i = 0; i < N-1; i++) {
		for (j = i+1; j < N; j++) {
			if (max < abs(A[i] - A[j]))
				max = abs(A[i]-A[j]);
		}
	}

	printf("%d\n", max);

	return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()
L = [[] for _ in range(10)]
for i,s in enumerate(S):
    n = int(s)
    L[n].append(i)

count = 0
import bisect
for i in range(1000):
    s = str(i)
    s = s.zfill(3)
    if L[int(s[2])] and L[int(s[0])]:
        r = int(L[int(s[2])][-1])
        l = int(L[int(s[0])][0])
        r2 = bisect.bisect_left(L[int(s[1])], r)
        l2 = bisect.bisect_right(L[int(s[1])], l)
        if r2-l2>0:
            count+=1

print(count)


Measured memory_bytes: 68876
#include<iostream>
#include<string>
using namespace std;
int main(){
   int H,W;
   cin >> H >> W;
   string str;
   int field[H+2][W+2];
   int i,j;
   for (i=1;i<=H;i++){
     field[i][0]=1;
     field[i][W+1]=1;
   }
   for (j=1;j<=W;j++){
     field[0][j]=1;
     field[H+1][j]=1;
   }
   for (i=1;i<=H;i++){
     cin >> str;
     for(j=1;j<=W;j++){
       if(str[j-1]=='#'){
         field[i][j]=0;
       }else{
         field[i][j]=1;
       }
     }
   }
   for (i=1;i<=H;i++){
     for(j=1;j<=W;j++){
       if(field[i][j]==0){
         if (field[i+1][j]*field[i-1][j]*field[i][j+1]*field[i][j-1]!=0){
           cout<<"No";
           return 0;
         }
       }
     }
   }
   cout<<"Yes";
   return 0;
}


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

int main()
{
	int a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	x/=50;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(10*i+2*j+k==x) ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic hereｓs
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int K = sc.nextInt();
        
        HashMap<String, Integer> hm = new HashMap<>();
        
        int slen = s.length();
        int subMax = slen;
        if(subMax>K){
            subMax = K;
        }
        
        for(int m=1;m<=subMax;m++){
            for(int i=0;i<slen;i++){
                if(i+m<=slen){
                    String tmp = s.substring(i, i+m);
                    String blankCheck = tmp.replaceAll(" ", "");
                    if(blankCheck.length()==0){
                        continue;
                    }
                    if (hm.containsKey(tmp)==false){
                        hm.put(tmp, 1);
                    }
                }
            }
        }
        
        Object[] mapKey = hm.keySet().toArray();
        Arrays.sort(mapKey);
        
        String ss = String.valueOf(mapKey[K-1]);
        
        System.out.println(ss);
    }
    
}


Measured memory_bytes: 43476
#include <iostream>
#include <string>

using namespace std;

int n = 0;

bool input(){
  	cin >> n;
    if (n == -1) {
  	    return (false);
 	}
 	return (true);
}

string ans(){
    string res = "";
  	while (n != 0){
        res = char('0' + n % 4) + res;
        n /= 4;
    }
    if (res.size() == 0){
		res = "0";
    }
    
	return (res);
}

int main(){
    while(input()){
        string a = ans();
        cout << a << endl;
    }
	
	return (0);
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll M, K;
  cin >> M >> K;

  if(K == 0){
    for(int i = 0; i < (1<<M); i++){
      cout << i << ' ' << i;
      if(i == (1<<M)-1) cout << endl;
      else cout << ' ';
    }
    return 0;
  }
  
  ll x = 0;
  for(int i = 1; i <= (1<<M)-1; i++){
    x ^= i;
  }
  if(K >= (1<<M)){
    cout << -1 << endl;
    return 0;
  }
  if(x ^ K != K){
    cout << -1 << endl;
    return 0;
  }
  for(int i = 0; i <= (1<<M)-1; i++){
    if(i == K) continue;
    cout << i << ' ';
  }
  cout << K << ' ';
  for(int i = (1<<M)-1; i >= 0; i--){
    if(i == K) continue;
    cout << i << ' ';
  }
  cout << K << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int minPlace;
  int A[n];
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
    if (A[i] == 1) minPlace = i;
  }
  int res = 200000;
  for (int i = 0; i < k; i++) {
    int d = 1;
    if (minPlace-i > 0) {
      d += (minPlace-i) / (k-1);
      if ((minPlace-i) % (k-1) > 0) d++;
    }
    if (n-(minPlace+k-i) > 0) {
      d += (n-(minPlace+k-i)) / (k-1);
      if ((n-(minPlace+k-i)) % (k-1) > 0) d++;
    }
    if (d<res) res = d;
  }

  printf("%d\n", res);



  return 0;
}


Measured memory_bytes: 1016
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] C = new int[N - 1];
        int[] S = new int[N - 1];
        int[] L = new int[N - 1];
        for (int i = 0; i < N - 1; i++)
        {
            C[i] = cin.nextInt();
            S[i] = cin.nextInt();
            L[i] = cin.nextInt();
        }

        for (int i = 0; i < N; i++)
        {
            long time = 0;
            for (int j = i; j < N - 1; j++)
            {
                time += (L[j] - (time % L[j])) % L[j];
                time = Math.Max(time, S[j]);
                time += C[j];
            }
            Console.WriteLine(time);
        }

    }

    

}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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

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

struct Bus
{

	int  Time;
	bool SameFlg;

};

int main()
{

	int N, M, h, m, i;
	struct Bus Ta[200];

	cin >> N;
	for( i = 0; i < N; i++ ) {

		cin >> h >> m;

		Ta[i].Time    = h * 60 + m;
		Ta[i].SameFlg = false;

	}

	cin >> M;
	for( int j = i ; j < i + M; j++ ) {

		cin >> h >> m;

		Ta[j].Time    = h * 60 + m;
		Ta[j].SameFlg = false;

	}

	for( i = 0; i < N + M; i++ ) {
		for( int j = i; j < M + N; j++ ) {

			int temp;

			if( Ta[i].Time > Ta[j].Time ) {

				temp	   = Ta[i].Time;
				Ta[i].Time = Ta[j].Time;
				Ta[j].Time = temp;

			}

		}
	}

	for( i = 0; i < N + M; i++ ) {
		for( int j = i + 1; j < N + M; j++ ) {

			if( Ta[i].Time == Ta[j].Time ) Ta[i].SameFlg = true;

		}
	}

	for( i = 0; i < N + M; i++ ) {
		
		if( i != N + M - 1 && !Ta[i].SameFlg ) {
			if( Ta[i].Time % 60 >= 10 )
				cout << Ta[i].Time / 60 << ":" << Ta[i].Time % 60 << " ";
			else
				cout << Ta[i].Time / 60 << ":0" << Ta[i].Time % 60 << " ";
		}

		else if( !Ta[i].SameFlg ) {
			if( Ta[i].Time % 60 >= 10 )
				cout << Ta[i].Time / 60 << ":" << Ta[i].Time % 60 << endl;
			else
				cout << Ta[i].Time / 60 << ":0" << Ta[i].Time % 60 << endl;
		}

	}

	return 0;

}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
int n,k;

int main()
{
    scanf("%d%d",&n,&k);
    puts(n>=2*k-1?"YES":"NO");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int h,w,d;
	int locate[100100]={0};
	int csum[100100]={0};
	int i,j;
	int a;
	int x0,y0,x1,y1;
	int q;
	int l,r;
	scanf("%d%d%d",&h,&w,&d);
	for(j=0;j<h;j++){
		for(i=0;i<w;i++){
			scanf("%d",&a);
			locate[a-1]=j*w+i;
		}
	}
	for(i=d;i<w*h;i++){
		x0=locate[i-d]%w;
		y0=locate[i-d]/w;
		x1=locate[i]%w;
		y1=locate[i]/w;
		csum[i]=csum[i-d]+abs(x0-x1)+abs(y0-y1);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d%d",&l,&r);
		printf("%d\n",csum[r-1]-csum[l-1]);
	}
	return 0;
}


Measured memory_bytes: 1792
N, Y = map(int, input().split())
Y //= 1000

for xi in range(N+1):
  for yi in range(N+1-xi):
    zi = N -xi -yi
    if xi + 5*yi + 10*zi == Y:
      print(zi, yi, xi)
      exit()
else:
  print(-1, -1, -1)



Measured memory_bytes: 3064