akhauriyash/Code-Regression huggingface dataset:
void main(){
	char[] s = readln().chomp().dup();
	char[] t = readln().chomp().dup();
	sort!("a<b")( cast(ubyte[]) s);
	sort!("a>b")( cast(ubyte[]) t);

	writeln(s<t?"Yes":"No");
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>

using namespace std;

#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9 + 7;

bool IsPrime(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}

int Get_Digit(ll A) {
    int digits = 0;
    while (A > 0) {
        A /= 10;
        digits++;
    }
    return digits;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> ans;
    for (int A = 1; A < sqrt(N) + 1; A++) {
        if (N % A == 0) {
            ll c;
            ll B = N / A;
            c = Get_Digit(B);
            ans.push_back(c);
        }
    }
    sort(ans);
    cout << ans[0] << endl;
}

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

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

  int n;
  cin >> n;
  
  map<int, int> o, e;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (i&1) {
      o[x]++;
    } else {
      e[x]++;
    }
  }
  
  vector<pair<int, int>> odd, even;
  for (auto i : o) odd.push_back(i);
  for (auto i : e) even.push_back(i);
  
  sort(odd.begin(), odd.end(), [&](auto l, auto r) {
    return l.second > r.second;
  });

  sort(even.begin(), even.end(), [&](auto l, auto r) {
    return l.second > r.second;
  });
  
  int mx = 0;
  if ((odd[0].first == even[0].first) && n > 2) mx = max({odd[0].second + even[1].second, odd[1].second + even[0].second});
  else mx = odd[0].second + even[0].second;
  cout << n - mx << '\n';

}


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

using namespace std;

int main()
{
    int n,w;
    int wt[105];
    long long val[105];

    cin>>n>>w;
    vector< vector<long long> >dp(n+1,vector<long long> (w+1));

    for(int i=0;i<n;i++){
        cin>>wt[i+1]>>val[i+1];
        dp[i][0]=0;
        dp[0][i]=0;
    }
    dp[n][0]=dp[0][n]=0;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(j<wt[i]) {
                dp[i][j]=dp[i-1][j];
            }
            else {
                dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
            }
        }
    }

    cout << dp[n][w] <<endl;

    return 0;
}


Measured memory_bytes: 80256
#!/usr/bin/env python3

from copy import deepcopy
from functools import lru_cache
import sys

POSS = sorted([1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049])
NMAX = 10 ** 5
# sys.setrecursionlimit(NMAX + 1)

@lru_cache(maxsize=NMAX + 1)
def dfs(n):
    assert 0 <= n <= NMAX
    res = n
    for p in reversed(POSS):
        if n - p >= 0:
            res = min(res, dfs(n - p) + 1)
    return res

def main():
    n = int(input())
    print(dfs(n))

main()


Measured memory_bytes: 95320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x=0,sum=0,a=1;
  cin>>n>>k;
  while(1){
    if(sum>=n) break;
    sum+=a;
    if((sum-a)/a>=k){
      sum-=a; ++a; --x;
    }
    ++x;
  }
  cout<<x<<endl;
  return 0;
}



Measured memory_bytes: 3116
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_r
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
	void addmod(ll & a, ll b) {
		a += b;
		if (a >= mod) {
			a -= mod;
		}
	}

	vector<VLL> operator * (vector<VLL> A, vector<VLL> B) {
		int n = A.size();
		vector<VLL> C(n, VLL(n));
		REP(i, 0, n) {
			REP(k, 0, n) {
				REP(j, 0, n) {
					addmod(C[i][j], (A[i][k] * B[k][j]) % mod);
				}
			}
		}
		return C;
	}

	vector<VLL> operator ^ (vector<VLL> A, ll k) {
		if (k == 1) {
			return A;
		}
		vector<VLL> h = A ^ (k / 2);
		h = h * h;
		h = k % 2 == 1 ? h * A : h;
		return h;
	}

	void main() {
		// matrix multiplication - k steps is sum(A^k)
		ll n, k;
		cin >> n >> k;
		vector<VLL> A(n, VLL(n));

		REP(i, 0, n) {
			REP(j, 0, n) {
				cin >> A[i][j];
			}
		}

		vector<VLL> ansA = A ^ k;
		ll ans = 0;
		REP(i, 0, n) {
			REP(j, 0, n) {
				addmod(ans, ansA[i][j]);
			}
		}
		cout << ans << endl;

	}
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;
 
int main()
{
	int m, k;
	cin >> m >> k;
	if(m == 0 && k == 0)
	{
		cout << "0 0";
		return 0; 
	}
	if(m == 1 && k == 1)
	{
		cout << -1;
		return 0;
	}
	if(m == 1 && k == 0)
	{
		cout << "0 0 1 1";
		return 0;
	}
	if(k >= (1 << m))
	{
		cout << -1;
		return 0;
	}
	if(k != (1 << m) - 1)
	{
		int last = (1 << m) - 1;
		for (int i = 0; i < last; ++i)
		{
			if(i != k)
				cout << i << " ";
		}
		cout << k << " ";
		for (int i = last - 1; i >= 0; --i)
		{
			if(i != k)
				cout << i << " ";
		}
		cout << last << " ";
		cout << k << " ";
		cout << last;
	}
	else
	{
		int last = (1 << m) - 1;
		for (int i = 0; i < last - 1; ++i)
		{
			cout << i << " ";
		}
		cout << k << " ";
		for (int i = last - 2; i >= 0; --i)
		{
			cout << i << " ";
		}
		cout << last - 1 << " ";
		cout << k << " ";
		cout << last - 1;
	}
}	

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> void pp(T a, T b){ for(T i = a; i != b; ++i) cout << *i << ' '; cout << endl; }

#define INF "|"

struct Edge {
  int from, to;
  string cost;
  Edge(int from_, int to_, string cost_){
    from = from_;
    to = to_;
    cost = cost_;
  }
  Edge(){
    from = to = 0;
    cost = "";
  }
};

int n,a,s,g;
Edge edge[410];
string d[50];

int main(){
  int i;

  while(1){
    scanf("%d %d %d %d",&n,&a,&s,&g);
    if(n == 0 && a == 0 && s == 0 && g == 0) break;

    rep(i,a){
      int from,to;
      string cost;
      // cin >> from >> to >> cost;
      cin >> to >> from >> cost;
      Edge e(from,to,cost);
      edge[i] = e;
    }

    rep(i,n) d[i] = INF;
    d[g] = "";
    int count = 0,cc=0;
    while(1){
      bool update = false;
      rep(i,a){
        Edge e = edge[i];
        if(d[e.from] != INF && d[e.to] > e.cost + d[e.from]){ // d[0] > d[0] + "a"
          // cout << d[e.to]<< ' ' <<  d[e.from] << ' ' <<  e.cost << endl;
          d[e.to] = e.cost + d[e.from];
          update = true;
          if(e.to == s && count >= n+1) cc++;
        }
      }
      count++;
      if(cc >= 1) break;
      if(count >= 500) break;
      if(!update) break;
    }

    cout << ((d[s] == "|" || cc >= 1) ? "NO" : d[s]) << endl;
  }

  return 0;
}

Measured memory_bytes: 1988
def main():
    N, M = [int(i) for i in input().split()]
    t = [[], [], [], [], [], [], [], []]
    for i in range(N):
        x, y, z = [int(i) for i in input().split()]
        for j in range(8):
            xs = 1 if j % 2 == 0 else -1
            ys = 1 if (j // 2) % 2 == 0 else -1
            zs = 1 if (j // 4) % 2 == 0 else -1
            t[j].append(xs * x + ys * y + zs * z) 
    res = []
    for li in t:
        li.sort(reverse=True)
        res.append(sum(li[:M]))
    print(max(res))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3416
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	if A == 0 {
		fmt.Println(0)
		return
	}
	C := N / (A + B)
	// この時点で最初のN個のうち少なくともC*A個は青いボールが並んでいる。
	D := N - (A+B)*C
	fmt.Println(C*A + min(D, A))
}

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


Measured memory_bytes: 512
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int m = Integer.parseInt(line[1]);
        int l = Integer.parseInt(line[2]);
        int[][] a = new int[n][m];
        int[][] b = new int[m][l];
        long[][] c = new long[n][l];

        for(int i = 0; i < n; i++){
            line = br.readLine().split(" ");
            for(int j = 0; j < m; j++){
                a[i][j] = Integer.parseInt(line[j]);
            }
        }

        for(int i = 0; i < m; i++){
            line = br.readLine().split(" ");
            for(int j = 0; j < l; j++){
                b[i][j] = Integer.parseInt(line[j]);
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < l; j++){
                for(int k = 0; k < m; k++)
                    c[i][j] += a[i][k] * b[k][j];
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < l; j++){
                System.out.print(c[i][j]);
                if(j != l-1)
                    System.out.print(" ");
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 35292
#include<iostream>
#include<vector>
 
using namespace std;
 
int main() {
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
    v[i]--;
  }
  v.push_back(n);
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(v[i]==i) {
      swap(v[i],v[i+1]);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

inline int read(){
	int a = 0;
	char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		a = a * 10 + c - 48;
		c = getchar();
	}
	return a;
}

const int MAXN = 1e5 + 7;
struct Edge{
	int end , upEd;
}Ed[MAXN << 1];
int head[MAXN] , N , M , cntEd;
bool vis[MAXN];

inline void addEd(int a , int b){
	Ed[++cntEd].end = b;
	Ed[cntEd].upEd = head[a];
	head[a] = cntEd;
}

int ans;

int dfs(int x){
	vis[x] = 1;
	int col = 0 , more = 0;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(!vis[Ed[i].end]){
			int t = dfs(Ed[i].end);
			if(t > 0) more += t;
			else col -= t;
		}
	ans += more + col;
	return col - more - 1;
}

namespace solveTree{
	void main(){
		if(dfs(1))
			cout << "-1";
		else
			cout << ans;
	}
}

namespace solveCir{
	vector < int > cir , val;
	int find(int x , int p){
		vis[x] = 1;
		for(int i = head[x] ; i ; i = Ed[i].upEd)
			if(Ed[i].end != p)
				if(vis[Ed[i].end]){
					cir.push_back(x);
					return Ed[i].end;
				}
				else{
					int t = find(Ed[i].end , x);
					if(t){
						cir.push_back(x);
						return x == t ? 0 : t;
					}
				}
		vis[x] = 0;
		return 0;
	}

	inline int abss(int x){return x < 0 ? -x : x;}
	
	void main(){
		find(1 , 0);
		for(auto t : cir)
			val.push_back(-dfs(t));
		int sum = 0;
		for(auto t : val)
			sum += t;
		if(sum & 1){puts("-1"); return;}
		sum >>= 1;
		if(cir.size() & 1){
			for(int i = 0 ; i + 1 < cir.size() ; i += 2)
				sum -= val[i];
			ans += abss(sum);
			for(int i = (int)val.size() - 2 ; i >= 0 ; --i){
				sum = val[i] - sum;
				ans += abss(sum);
			}
		}
		else{
			int cur = 0;
			for(auto t : val)
				cur = t - cur;
			if(cur){puts("-1"); return;}
			vector < int > now;
			now.push_back(0);
			cur = 0;
			bool f = 0;
			for(int i = (int)val.size() - 2 ; i >= 0 ; --i){
				cur = val[i] - cur;
				now.push_back(f ? -cur : cur);
				f ^= 1;
			}
			sort(now.begin() , now.end());
			int mid = now[((int)now.size() - 1) >> 1];
			for(auto t : now)
				ans += abss(mid - t);
		}
		cout << ans;
	}
}

signed main() {
	N = read();
	M = read();
	for(int i = 1 ; i <= M ; ++i){
		int a = read() , b = read();
		addEd(a , b);
		addEd(b , a);
	}
	if(M == N - 1)
		solveTree::main();
	else
		solveCir::main();
	return 0;
}


Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, D;
    cin >> N >> D;
    auto dist = [](ll x,ll y) {return sqrt(x*x+y*y);};
    int ans = 0;
    REP(i,N) {
        ll X, Y;
        cin >> X >> Y;
        if (D >= dist(X,Y)) ans++;
    }

    cout << ans << '\n';

    return 0;
}

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


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !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()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
   			int n = s.nextInt();
   			String s1=s.next();
   			List<Character> l = new ArrayList<>();
   			int c=1;
   			for(int i=0;i<s1.length();i+=c) {
   				c=1;
   				int j=i+1;
   				while( j<s1.length() && s1.charAt(i)==s1.charAt(j)) {
   					c++;
   					j++;
   				}
   				n-=c+1;
   				
   			}
   			
			
			System.out.println(Math.abs(n));
    }	
}





        
    

      
 

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

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

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    int A, B, C; cin >> A >> B >> C;
    
    cout << min(C, B / A) << endl;

    return 0;
}

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

int levenshtein(string s1, string s2) {
	int len1 = s1.size(),
	    len2 = s2.size();
	vector<vector<int>>dp(len1+1, vector<int>(len2+1));
	for (auto i = 0; i <= len1; i++) dp[i][0] = i;
	for (auto i = 0; i <= len2; i++) dp[0][i] = i;
	for (auto i = 1; i <= len1; i++) {
		for (auto j = 1; j <= len2; j++) {
			int cost = !(s1[i-1] == s2[j-1]);
			dp[i][j] = min({
					dp[i-1][j]+1,
					dp[i][j-1]+1,
					dp[i-1][j-1]+cost
					});
		}
	}
	return dp[len1][len2];
}

int main() {
	string s1, s2;
	cin>>s1>>s2;
	cout << levenshtein(s1, s2) << endl;
	return 0;
}

Measured memory_bytes: 4956
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<pair<P, int>> v(n);
    rep(i, n) {
        cin >> v[i].fi.fi >> v[i].fi.se;
        v[i].se = i;
    }
    sort(whole(v));
    dsu u(n);
    set<P> sx;
    
    rep(i, n) {
        auto it = sx.lower_bound(P(v[i].fi.se, 0));
        if (it!=sx.begin()) {
            it--;
            while (1) {
                u.merge(v[i].se, it->se);
                if (it==sx.begin()) break;
                sx.erase(it--);
            }
        }
        sx.insert(P(v[i].fi.se, v[i].se));
    }
    /*
    set<P> sy;
    auto comp = [](pair<P, int> a, pair<P, int> b) {
        return a.fi.se < b.fi.se;
    };
    
    sort(whole(v), comp);
    rep(i, n) {
        auto it = sy.lower_bound(P(v[i].fi.fi, 0));
        if (it!=sy.begin()) {
            it--;
            u.merge(v[i].se, it->se);
            //debug(i); debug(it->se);
        }
        sy.insert(P(v[i].fi.fi, v[i].se));
    }
    */
    
    
    vector<int> ans(n);
    rep(i, n) {
        ans[i] = u.size(i);
    }
    
    
    rep(i, n) pr(ans[i]);
    return 0;
}


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

int main() 
{
  int n,count=0,flag=0;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++)
    cin >> a[i];

  while( 1 ) 
  {
    for(int i=0; i<n; i++)
    {   
      if( a[i]%2 == 0 ) 
        a[i] /= 2;
      else
        flag=1;
    }   

    if( flag == 1 ) break;

    count++;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
#define MOD 998244353
typedef long long ll;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    string s,f,l;
    cin>>s;
    int n=s.length();
    REP(i,(n-1)/2) f+=s[i];
    for(int i=(n+1)/2;i<n;i++) l+=s[i];
    if(f==l)cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int f[10000007];
long long int n;
void sieve()
{
	long long int i, j;
	for(i=2;i<10000001;i++)
	for(j=i+i;j<10000001;j+=i)
	{
		f[j]++;
	}
}
main()
{
	 cin >> n;
	 f[1] = 1;
	 long long int i;
	 for(i=2;i<=10000000;i++)
	 f[i] = 2;
	 sieve();
	 long long int ans = 0;
	 for(i=1;i<=n;i++)
	 {
	 	ans+=f[i]*i;
	 }
	 cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 81744
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;


int main()
{
  int n, x, cnt = 0;

  while (true)
    {
      cin >> n >> x;
      if (n == 0 && x == 0)
        break;

      cnt = 0;

      for (int i = 1; i <= n; i++)
        {
          for (int j = i + 1; j <= n; j++)
            {
              for (int k = j + 1; k <= n; k++)
                {
                  if (i + j + k ==x)
                    cnt++;
                }
            }
        }
      cout << cnt << endl;
    }



  return 0;
}


Measured memory_bytes: 3108
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List

main = do
    _ <- getLine
    as <- sort . map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    print $ solve as

solve :: [Int] -> Int
solve xs =
    let js = scanl (+) 0 xs
        noSmallers = zipWith (\x smallers -> smallers*2 < x) xs js
        in
    (+1) . length . takeWhile not . reverse $ noSmallers

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/
int n;
//a[L]からa[R-1]までの総和を返す
int sumLtoR(vi &s, int L, int R){
    return s[R] - s[L];
}
/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string s; cin >> n >> s;
    vi countW(n+1, 0);
    vi countE(n+1, 0);
    rep(i,n){
        countW[i+1] = countW[i] + (s[i] == 'W' ? 1 : 0);
    }
    rep(i,n){
        countE[i+1] = countE[i] + (s[i] == 'E' ? 1 : 0);
    }
//costは振り向く人の数
    int minimum_cost = 1000000000;
    rep(i,n){
        int cost = sumLtoR(countW, 0, i) + sumLtoR(countE, i, n);
        if(s[i] == 'E') cost--;
        minimum_cost = min(minimum_cost, cost);
    }
    cout << minimum_cost << '\n';
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
  	double D;
  	int cnt=0;
  	cin >> N >> D;
  	for(int i=0;i<N;i++){
		double X,Y;
      	cin >> X >> Y;
      	if(sqrt(X*X+Y*Y)<=D) cnt++;
    }
  	cout << cnt << endl;
}

Measured memory_bytes: 3844
y=list(raw_input())
k=int(raw_input())
for i in range(len(y)):
	if y[i]=='a':
		continue
	else:
		if 123-ord(y[i])<=k:
			k-=(123-ord(y[i]))
			y[i]='a'
y[len(y)-1]=chr(ord(y[len(y)-1])+k%26)
print ''.join(y)

Measured memory_bytes: 15472
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vector(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() - 1) cout << v[i];
	  else cout << v[i] << " ";  
	}
  cout << endl;	
}

void solve(){
  	int n, q;
  	vector<int> v;
  	cin >> n ;
  	for(int i = 0; i < n; i++){
	  int x;
	  cin >> x;
	  v.push_back(x);	
	}
	sort(all(v));
	cin >> q;
	for(int i = 0; i < q; i++){
    int query;
    cin >> query;
    int lo = lower_bound(all(v), query) - v.begin();
    int hi = upper_bound(all(v), query) - v.begin();
    cout << lo <<  " " << hi << endl;
   } 
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
unsigned long long n,m;
unsigned long long ans;
int main()
{
	cin >>n >>m;
	if (n==1 && m==1)
	{
		cout <<1;
		return 0;
	}
	if (n==1 || m==1)
	{
	    cout <<m+n-3;
	    return 0;
	}
	ans=(n-2)*(m-2);
	cout <<ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const bool DEBUG = 0;

vector<int> A;

int sw;

int query(vector<int> Q) {
	if (DEBUG) {
		int s = 0;
		for (auto x : Q) {
			s += A[x];
		}
		if (sw) s *= -1;
		if (s < 0) {
			return -1;
		} else {
			return 1;
		}
	} else {
		cout << "? ";
		for (auto i : Q) {
			cout << i + 1 << ' ';
		}
		cout << endl;
		string res;
		cin >> res;
		int x = 0;
		if (res == "Red") {
			x = 1;
		} else {
			x = -1;
		}
		if (sw) x *= -1;
		return x;
	}
}

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

	int n;
	if (DEBUG) {
		string s;
		cin >> s;
		for (auto t : s) {
			if (t == 'R') {
				A.push_back(1);
			} else {
				A.push_back(-1);
			}
		}
		n = (int)A.size() / 2;
	} else {
		cin >> n;
	}
	auto gt = [&](int l, int r) {
		vector<int> a;
		for (int i = l; i < r; i++) {
			a.push_back(i);
		}
		return a;
	};
	if (query(gt(0, n)) < 0) sw = 1;
	int l = -1;
	int r = -1;
	{
		int L = 0;
		int R = n;
		while (R - L > 1) {
			int m = (R + L) >> 1;
			if (query(gt(m, m + n)) > 0) {
				L = m;
			} else {
				R = m;
			}
		}
		l = R;
		r = R + n - 2;
	}
	vector<int> ans(2 * n, -2);
	for (int i = 0; i < 2 * n; i++) {
		if (l <= i && i <= r) {
			//
		} else {
			vector<int> c;
			for (int j = l; j <= r; j++) {
				c.push_back(j);
			}
			c.push_back(i);
			ans[i] = query(c);
		}
	}
	vector<int> F;
	vector<int> S;
	for (int i = 0; i < 2 * n; i++) {
		if (ans[i] == -1) {
			if ((int)F.size() < (n - 1) / 2) {
				F.push_back(i);
			}
		}
		if (ans[i] == 1) {
			if ((int)S.size() < (n - 1) / 2) {
				S.push_back(i);
			}
		}
	}
	vector<int> all;
	for (auto i : F) {
		all.push_back(i);
	}
	for (auto i : S) {
		all.push_back(i);
	}
	for (int i = 0; i < 2 * n; i++) {
		if (l <= i && i <= r) {
			vector<int> c = all;
			c.push_back(i);
			ans[i] = query(c);
		}
	}
	cout << "! ";
	for (auto x : ans) {
		if (sw) x *= -1;
		if (x == 1) {
			cout << 'R';
		} else {
			cout << 'B';
		}
	}
	cout << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 1000000007
#define nonod numberofnodes
#define pr pair <ll,ll>
#define mnx  1000001
#define inf 10000000000000000001
#define prin(x) cout<<setprecision(7)<<fixed<<x<<endl;
using namespace std;


void masterstroke(){
	string a;
	cin>>a;
	ll x=a.length();
	ll v[x]={0};
	ll c=0;
	for(ll j=0;j<x-1;j++){
		if(a[j]=='B'&&a[j+1]=='C'){
			v[j]=c;
			j+=1;
		}
		else if(a[j]=='A'){c++;}
		else{
			c=0;
		}
	}
	ll ans=0;
	for(ll i=0;i<x;i++){
		ans+=v[i];
	}
	cout<<ans<<endl;



}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e3+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

pii a[maxN];
ll f[maxN][2*maxN];
int main() {
	int n,T;
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].X,&a[i].Y);
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=T+3010;j++)
		{
			f[i][j] = max(f[i-1][j],f[i][j]);
			if(j-a[i].X<T && j-a[i].X >=0)
				f[i][j] = max(f[i][j],f[i-1][j-a[i].X]+a[i].Y);
		}
	}
	ll ans = 0;
	for(int i=1;i<=T+3010;i++)
	{
		ans = max(ans,f[n][i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 141568
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  string S;
  long long K;
  cin >> S >> K;
  bool onlyone = true;
  int pos = -1;
  for(int i = 0; i < S.length(); i++) {
    if(S[i] != '1') {
      onlyone = false;
      pos = i;
      break;
    }
  }
  if(onlyone == true) {
    //    cout << "Only one" << endl;                                                              
    cout << 1 << endl;
  } else {
    //    cout << pos << " " << K << endl;                                                         
    if(pos-1 >= K-1) cout << 1 << endl;
    else cout << S[pos] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, *x = $stdin.read.split.map(&:to_i)
m = 10**9 + 7

diff = x.each_cons(2).map { |a, b| b - a }

k = 0
l = 1
puts diff.each.with_index(1).inject(0) { |sum, (d, i)| k = (k * i + l) % m; l = l * i % m; (sum * i + d * k) % m }



Measured memory_bytes: 12668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;
static const int white = 0;
static const int gray = 1;
static const int black = 2;
using P = pair<ll,ll>;

int N,M,s,t;
vector<vector<P> > EdgeA(101010), EdgeB(101010);

void dijkstra(){
    priority_queue<P, vector<P>, greater<P> > pqa;
    priority_queue<P, vector<P>, greater<P> > pqb;
    vector<int> colora(N+10,white), colorb(N+10,white);
    vector<ll> da(N+10,INF), db(N+10,INF);
    da[s] = 0;
    db[t] = 0;
    pqa.push(make_pair(0,s));
    pqb.push(make_pair(0,t));
    colora[s] = gray;
    colorb[t] = gray;

    while(!pqa.empty()){
        P f = pqa.top(); pqa.pop();
        int u = f.second;
        colora[u] = black;

        if(da[u] > f.first) continue;

        for(auto e : EdgeA[u]){
            int v = e.second;
            if(colora[v] == black) continue;
            if(da[v] > da[u] + e.first){
                da[v] = da[u] + e.first;
                pqa.push(make_pair(da[v], v));
                colora[v] = gray;
            }
        }
    }

    while(!pqb.empty()){
        P f = pqb.top(); pqb.pop();
        int u = f.second;
        colorb[u] = black;

        if(db[u] > f.first) continue;

        for(auto e : EdgeB[u]){
            int v = e.second;
            if(colorb[v] == black) continue;
            if(db[v] > db[u] + e.first){
                db[v] = db[u] + e.first;
                pqb.push(make_pair(db[v], v));
                colorb[v] = gray;
            }
        }
    }

    ll minute = INF;
    vector<ll> mind(N+10);
    for(int i=N-1;i>=0;i--){
        if(minute > da[i] + db[i]){
            minute = da[i] + db[i];
        }
        mind[N-i-1] = minute;
    }
        
    for(int i=N-1;i>=0;i--){
        cout << 1000000000000000 - mind[i] << endl;
    }
}

int main(){
    cin >> N >> M >> s >> t;
    s--; t--;
    rep(i,M){
        int u,v,a,b; cin >> u >> v >> a >> b;
        u--; v--;
        EdgeA[u].push_back(make_pair(a, v)); EdgeA[v].push_back(make_pair(a, u));
        EdgeB[v].push_back(make_pair(b, u)); EdgeB[u].push_back(make_pair(b, v));
    }

    dijkstra();
}

Measured memory_bytes: 21112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc140/abc140_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  cout << pow(N, 3) << endl;
}

Measured memory_bytes: 256
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0;lli a=0ll,b=0ll,c=0ll,sum=0ll,res=0ll;
    cin>>n>>m;
    vector<pair<lli, lli> > vp;
    for(int i=0;i<n;++i)
    {
        cin>>a;
        vp.pb({a,1ll});
    }
    for(int i=0;i<m;++i)
    {
        cin>>b>>c;
        vp.pb({c,b});
    }
    sort(vp.begin(),vp.end(),greater<pair<lli,lli> >());
    for(auto i: vp)
    {
        if(sum+i.se<=n)
        {
            res+=(1ll*i.fi*i.se);
            sum+=i.se;
        }
        else
        {
            res+=(1ll*i.fi*(n-sum));
            sum=n;
            break;
        }
    }
    cout<<res<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    char s[400], t[400];
    cin >> s >> t;
    strcat(t, s);
    cout << t << endl;
    return 0;
}

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

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i,_n) for(ll _i = 0; _i < _n; _i++)
#define rep2(_i,_s,_n) for(ll _i = _s; _i < _n; _i++)
#define elif else if
#define push(_a) push_back(_a)
#define append(_x) push_back(_x)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecL(_name, _n) vec<long> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecLL(_name, _n) vec<ll> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecUL(_name, _n) vec<ul> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecULL(_name, _n) vec<ull> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define findMaxIdx(_name) distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";
#define mapLoop(_i, _name) for(auto i = _name.begin(); i != _name.end(); i++)

#define comp_idx(_name) [&_name](long l_idx,  long r_idx){return _name[l_idx] < _name[r_idx];}

int main()
{
    long N;
    cin >> N;
    inputVecLL(A, N);
    map <ll, long> ansbuf;
    vec <ll> SA(N);
    rep(i, N){
      ansbuf[(i + 1) + A[i]] += 1;
      SA[i] = (i + 1) - A[i];
    }

    long ans = 0;
    rep(i, N){
      ans += ansbuf[SA[i]];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 28920
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String[] symbols = in.nextLine().split(" ");
		Stack<String> stack = new Stack<>();
		for (int i=0; i<symbols.length; i++) {
			if (symbols[i].equals("+")) {
				int value1 = Integer.parseInt(stack.pop());
				int value2 = Integer.parseInt(stack.pop());
				stack.push(Integer.toString(value1 + value2));
			} else if (symbols[i].equals("-")) {
				int value1 = Integer.parseInt(stack.pop());
				int value2 = Integer.parseInt(stack.pop());
				stack.push(Integer.toString(value2 - value1));
			} else if (symbols[i].equals("*")) {
				int value1 = Integer.parseInt(stack.pop());
				int value2 = Integer.parseInt(stack.pop());
				stack.push(Integer.toString(value1 * value2));
			} else {
				stack.push(symbols[i]);
			}
		}
		System.out.println(Integer.parseInt(stack.pop()));
		
	}

}



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

int main() {
    int N=0,M=0,ans=0;
    cin >> N >> M;
    vector<int> like(M);

    for(int i=0; i<N; i++){
        int k=0;
        cin >> k;
        for(int x=0; x<k; x++){
            int index=0;
            cin >> index;
            like.at(index-1) += 1;
        }
    }
    for(int m=0; m<M; m++){
        if(like.at(m) == N){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

struct PNL{int x;int y;};


int main(){
struct PNL p[201];
int x=0,y=0,N,n=0,cmd=0,X=0,Y=0,xl=0,yl=0;
while(1){
x=0,y=0,N,n=0,cmd=0,X=0,Y=0,xl=0,yl=0;
cin>>N;if(N==0)break;
p[0].x=0;p[0].y=0;
for(int i=1;i<N;i++)
{
cin>>n>>cmd;
if(cmd==0){p[i].x=p[n].x-1;p[i].y=p[n].y;}
else if(cmd==1){p[i].x=p[n].x;p[i].y=p[n].y-1;}
else if(cmd==2){p[i].x=p[n].x+1;p[i].y=p[n].y;}
else if(cmd==3){p[i].x=p[n].x;p[i].y=p[n].y+1;}
}

for(int j=0;j<N;j++)
{if(p[j].x>X)X=p[j].x;
else if(p[j].x<xl)xl=p[j].x;
else if(p[j].y>Y)Y=p[j].y;
else if(p[j].y<yl)yl=p[j].y;
}
x=X-xl+1;y=Y-yl+1;
printf("%d %d\n",x,y);
for(int j=0;j<N;j++)
{p[j].x=0;p[j].y=0;}

}
return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  long long K;
  cin >> K;
  char ans = '1';
  for (int i = 0; i < S.size(); i++){
    if (i >= K){
      break;
    }
    if (S[i] != '1'){
      ans = S[i];
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    long res;
    long digit = 1; // 現在扱う桁
    ArrayList<ArrayList<Long>> pre = new ArrayList<>(10); // 先頭の数ごとに最新の桁のルンルン数を保持しておく
    ArrayList<Long> list = new ArrayList<>();
    for (long i = 0; i <= 9; i++) {
      pre.add(new ArrayList<Long>());
      pre.get((int)i).add(i);
      if (i == 0) continue;
      list.add(i);
    }

    while(list.size() < k) {
      digit *= 10;
      ArrayList<ArrayList<Long>> prepre = new ArrayList<>();
      for (int i = 0; i <= 9; i++) {
        prepre.add(new ArrayList<>());
        prepre.get(i).addAll(pre.get(i));
      }
      for (ArrayList<Long> e: pre) {
        e.clear();
      }
        pre.get(0).addAll(prepre.get(0));
        pre.get(0).addAll(prepre.get(1));
      for (int i = 1; i <= 8; i++) {
        for (long e: prepre.get(i-1)) {
          list.add(i*digit+e);
          pre.get(i).add(i*digit+e);
        }
        for (long e: prepre.get(i)) {
          list.add(i*digit+e);
          pre.get(i).add(i*digit+e);
        }
        for (long e: prepre.get(i+1)) {
          list.add(i*digit+e);
          pre.get(i).add(i*digit+e);
        }
      }
        for (long e: prepre.get(8)) {
          list.add(9*digit+e);
          pre.get(9).add(9*digit+e);
        }
        for (long e: prepre.get(9)) {
          list.add(9*digit+e);
          pre.get(9).add(9*digit+e);
        }
      }
    res = list.get(k-1);
    System.out.println(res);
    sc.close();
  }
}

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

namespace tenka1_2018_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			for (int i = 0; i < x[2]; i++)
			{
				int n = i % 2;
				if (x[n] % 2 == 1) x[n]--;
				x[n ^ 1] += x[n] / 2; x[n] /= 2;
			}
			Console.WriteLine(x[0] + " " + x[1]);
		}
	}
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sth=100;
	while(n--)
	{
		int x;
		cin>>x;
		int cnt=0;
		while(x%2==0)
		{
			x/=2;
			cnt++;
		}
		sth=min(sth,cnt);
	}
	cout<<sth<<endl;
	return 0;
}

Measured memory_bytes: 256
function insert(tree, rootId, z) {
    let y = null;
    let x = tree[rootId];
    while (x) {
        y = x;
        if (z < x.key) {
            x = tree[x.left];
        } else {
            x = tree[x.right];
        }
    }

    if (y === null) {
        tree[rootId] = {key: z, parent: y, left: null, right: null};
    } else if (z < y.key) {
        y.left = z;
        tree[z] = {key: z, parent: y ? y.key : null, left: null, right: null};
    } else {
        y.right = z;
        tree[z] = {key: z, parent: y ? y.key : null, left: null, right: null};
    }
}

function find(tree, nodeId, k) {
    let node = tree[nodeId];
    while (node.key !== null && node.key !== k) {
        if (node.key < k) {
            node = node.right ? tree[node.right] : null;
        } else {
            node = node.left ? tree[node.left] : null;
        }
        if (!node) return;
    }
    return node;
}

function preParse(inputs, idx, walked) {
    if (!idx) {
        return;
    }
    walked[0] += ' ';
    walked[0] += inputs[idx].key;
    preParse(inputs, inputs[idx].left, walked);
    preParse(inputs, inputs[idx].right, walked);
}

function inParse(inputs, idx, walked) {
    if (!idx) {
        return;
    }
    inParse(inputs, inputs[idx].left, walked);
    walked[1] += ' ';
    walked[1] += inputs[idx].key;
    inParse(inputs, inputs[idx].right, walked);
}

function printOut(tree, rootId) {
    const walked = ['', ''];
    preParse(tree, rootId, walked);
    inParse(tree, rootId, walked);

    console.log(walked[1]);
    console.log(walked[0]);
}


function main(_stdin) {
    const stdin = _stdin.split('\n');
    const len = stdin.shift();
    const inputs = stdin.filter((e, i) => i < len);

    const tree = [];
    const rootId = parseInt(inputs[0].split(' ')[1], 10);
    for (const input of inputs) {
        const order = input.split(' ');
        if (order[0] === 'insert') {
            insert(tree, rootId, parseInt(order[1], 10));
        } else if (order[0] === 'find') {
            console.log(find(tree, rootId, parseInt(order[1], 10)) ? 'yes' : 'no');
        } else {
            // print
            printOut(tree, rootId);
        }
    }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 254068
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BVotingJudges {
public:
    int N, M, V, P;
    vc<int> A;

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        in>>N>>M>>V>>P;
        A.resize(N);
        for(auto& a : A) in>>a;
        sort(ALL(A));
        int left = -1, right = N + 1;
        auto check = [&](int x){
            int cnt = A.end() - upper_bound(ALL(A), A[x]+M);
            if(cnt>=P) return false;
            if(x>=V-1) return true;
            int v = V - x - 1;
            if(v<=P-1) return true;
            v -= P - 1;
            lint sum = 0;
            FOR(j, x+1, N-P+1){
                sum += A[x] + M - A[j];
            }
            return sum >= 1ll * M * v;
        };
        while(1<right-left){
            int mid = (left+right) >> 1;
            if(check(mid)) right = mid;
            else left = mid;
        }
        out<<N-right<<'\n';
    }
};


int main() {
	BVotingJudges solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    int K;
    int64_t ans;
    cin >> K;

    queue<int64_t> q{{1,2,3,4,5,6,7,8,9}};
    int count=0;

    while(count<=K+1){
        int64_t now = q.front(); q.pop();

        if(now%10!=0) q.push(now*10+now%10-1);
        q.push(now*10+now%10);
        if(now%10!=9) q.push(now*10+now%10+1);
        count++;

        if(count==K){
            ans=now;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b;cin>>a>>b;
    ll ans = max({2*a-1 , 2*b-1 , a+b});
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int AB = A * B;
		int CD = C * D;
		if (AB <= CD) {
			System.out.println(CD);
		} else {
			System.out.println(AB);
		}
		sc.close();
	}
}

Measured memory_bytes: 22612