akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    int a=100000,b=0,t;
    cin>>t;
      for(int k=0;k<t;k++){
         b=a*1.05;
         b=(b+999)/1000*1000;
         a=b;
       }
     cout<<a<<endl;
}

Measured memory_bytes: 3072
import java.util.*;
public class Main{
  public static void main(String[] args){
	
	      Scanner s=new Scanner(System.in);
	      String s1=s.next();
	      String s2=s.next();
	      int[][] dp=new int[s1.length()+1][s2.length()+1];
	      for(int i=0;i<dp.length;i++)
	        Arrays.fill(dp[i],0);
	      for(int i=1;i<dp.length;i++){
	        for(int j=1;j<dp[0].length;j++){
	          if(s1.charAt(i-1)==s2.charAt(j-1)){
	            dp[i][j]=dp[i-1][j-1]+1;
	          }
	          else{
	               dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
	          }
	             }
	             }
	             
	             int len=dp[dp.length-1][dp[0].length-1];
	             StringBuilder res=new StringBuilder();
	             int i=dp.length-1;
	             int j=dp[0].length-1;
	             while(len>0) {
	            	 if(s1.charAt(i-1)==s2.charAt(j-1)) {
	            		 res.append(s1.charAt(i-1));
	            		 i--;
	            		 j--;
	            		 len--;
	            	 }
	            	 else if(dp[i-1][j]>dp[i][j-1]) {
	            		 i--;
	            	 }
	            	 else
	            		 j--;
	             }
	             
	             System.out.println(res.reverse().toString());
	             }
	             }
	             
	             
	             

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

int n;
double a[200010], ans;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= 2 * n; ++i) scanf("%lf", &a[i]);
	sort(a + 1, a + 1 + 2 * n);
	for(int i = 1; i <= 2 * n; ++i) ans += (2.0 * n - i) * a[2 * n - i + 1];
	printf("%.10f\n", ans / (2.0 * n - 1.0));
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

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

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	k := scanInt()+1
	ans := 0
	for i := 1; i < k; i++ {
		for j := 1; j < k; j++ {
			for l := 1; l < k; l++ {
				ans += gcd(i,gcd(j,l))
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}


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

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

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

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

int main(void){
	int64 N, K;
	cin >> N >> K;
	map<int64, vector<int64>> mp;
	priority_queue<int64> pq, pq2;
	priority_queue<int64, vector<int64>, greater<int64> > pq3;
	int64 nc = 0, sum = 0;
	REP(i, N){
		int64 t, d;
		cin >> t >> d;
		mp[t].push_back(d);
	}
	for(auto v : mp){
		sort(all(v.sc), greater<int64>());
		if(v.sc.size()) pq2.push(v.sc[0]);
		FOR(i, 1, v.sc.size()) pq.push(v.sc[i]);
	}
	REP(i, K){
		if(pq2.size()) { sum += pq2.top(); pq3.push(pq2.top()); pq2.pop(); nc++;}
		else { sum += pq.top(); pq3.push(pq.top()); pq.pop(); }
	}
	sum += nc*nc;
	while(pq.size()){
		if((nc-1)*(nc-1)-(nc*nc)+pq.top() > pq3.top()){
			sum += (nc-1)*(nc-1)-(nc*nc)+pq.top();
			sum -= pq3.top();
			pq3.push(pq.top());
			pq.pop();
			pq3.pop();
			nc--;
		}else{
			break;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 12916
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/
int fun(int x){
    int sum = 0;
    while(x > 0){
        sum += x%10;
        x /= 10;
    }
    return sum;
}

int main(){
    int N; cin >> N;
    int mn = MM;
    for (int i = 1; i < N; i++){
        int t = N-i;
        int ch = fun(i) + fun(t);
        mn = min(mn,ch);
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := 0
	for _, v := range a {
		ans += v - 1
	}
	fmt.Println(ans)
}


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

#define uint        unsigned int
#define ld          long double
#define int         long long
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

/*const int mod = 998244353;
int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}
*/
int n,m,p[maxn],vis[maxn],in[maxn];
vector<int>adj[maxn];
set<int>anc[maxn];

signed main()
{
    showoff;
    cin >> n >> m;
    FOR(i,1,n+m){
    int u,v;
    cin >> u >> v;
    adj[u].pb(v);
    anc[v].insert(u);
    in[v]++;
    }
    int root;
    FOR(i,1,n+1)if(!in[i]){root = i;break;}
    queue<int>q;
    q.push(root);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        vis[x] = 1;
        for(auto &y:adj[x]){
            bool fo = 1;
            for(auto &z:anc[y]){
                if(vis[z])continue;
                fo = 0;
                break;
            }
        if(fo){
            p[y] = x;
            q.push(y);
        }
        }
    }
    FOR(i,1,n+1)cout << p[i] << "\n";
    return 0;
}


Measured memory_bytes: 27136
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

int fact(int n) {
	int r = 1;
	for (int i = 1; i <= n; i++) {
		r *= i;
	}

	return r;
}

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

	int n;
	cin >> n;
	int a = 1, b = 1;
	vector<int> v(n);
	vector<int> u(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

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

	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (int j = i + 1; j < n; j++) {
			if (v[j] > v[i]) cnt++;
		}
		a += cnt * fact(n - i - 1);
	}

	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (int j = i + 1; j < n; j++) {
			if (u[j] > u[i]) cnt++;
		}
		b += cnt * fact(n - i - 1);
	}

	cout << abs(a - b);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, m; cin >> n >> m;

    double p = pow(1.0 / 2, m);
    double x = 1900.0 * m + 100 * (n - m);
    int ans = x / p;

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


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    string t;
    cin>>s>>t;
    int c = 0;
    for(int i=0;i<(int)s.size();++i) c+=s[i]!=t[i];
    cout<<c;
    return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
 ** A main function starts from here  **
 ***************************************/
int main(){
  ll A, B;
  cin >> A >> B;
  ll current = 1;
  ll ans =0;
  while(current < B){
    current -=1;
    current +=A;
    ans ++;
  }

  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n, m;
vector<int> G[100010];
int dp[100010];

int rec(int v) {
    if (dp[v] != -1) return dp[v];
    int res = 0;
    for (int u : G[v]) {
        res = max(res, rec(u) + 1);
    }
    return dp[v] = res;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
    }
    fill(dp, dp + n, -1);
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, rec(i));
    cout << ans << endl;
}

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


int main(){

  vector<int> n(3);
  cin >> n[0] >> n[1] >> n[2];

  sort(n.begin(),n.end());

  if( n[0]==5 && n[1] == 5 && n[2] == 7 ) cout << "YES" << endl;
  else cout << "NO" << endl;




  return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn = 2e5 + 10;
int n;
int a[maxn];
ll s[maxn];

ll get(int x1 , int x2 , int x3){
    return max(max(max(s[x1] , s[x2] - s[x1]) , s[x3] - s[x2]) , s[n] - s[x3]) - 
           min(min(min(s[x1] , s[x2] - s[x1]) , s[x3] - s[x2]) , s[n] - s[x3]);
}

int main(){
    cin >> n;
    for(int i = 1 ; i <= n ; ++ i){
        cin >> a[i];
        s[i] = a[i] + s[i - 1];
    }
    int l1 = 1 , mid = 2 , r1 = 3;
    ll ans = s[n];
    while(r1 < n && abs((s[n] - s[r1 + 1]) - (s[r1 + 1] - s[mid])) < abs((s[n] - s[r1]) - (s[r1] - s[mid])))
        r1 ++;
    ans = min(get(l1 , mid , r1) , ans);
    while(mid < n - 1){
        ++ mid;
        while(l1 < mid && abs((s[mid] - s[l1 + 1]) - (s[l1 + 1])) < abs((s[mid] - s[l1]) - (s[l1])))
            l1 ++;
        while(r1 < n && abs((s[n] - s[r1 + 1]) - (s[r1 + 1] - s[mid])) < abs((s[n] - s[r1]) - (s[r1] - s[mid])))
            r1 ++;
        ans = min(get(l1 , mid , r1) , ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a, b, c = "";
    cin >> a >> b;
    int i, j, x = a.size(), y = b.size();
    int dp[x+1][y+1];
    memset(dp, 0, sizeof(dp));
    for(i = 1; i <= x; ++i)
        for(j = 1; j <= y; ++j) {
            if(a[i-1] == b[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    while(x && y) {
        if(a[x-1] == b[y-1]) c = a[x-1] + c, --x, --y;
        else if(dp[x][y] == dp[x-1][y]) --x;
        else --y;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 38804
#include <iostream>

using namespace std;

int main(){

  int a, b;

  cin >> a >> b;

  if (a > b){
    if (b == 1){
      cout << "Bob" << endl;
    }
    else{
      cout << "Alice" << endl;
    }
  }
  else if (a < b){
    if (a == 1){
      cout << "Alice" << endl;
    }
    else {
      cout << "Bob" << endl;
    }
  }
  else if (a == b){
    cout << "Draw" << endl;
  }
  else {
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,a,n[10000],d,count=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&n[i]);
  }
  for(i=0;i<a;i++){
    d=1;
    for(j=2;j*j<=n[i];j++){
      if(n[i]%j==0){
    d=0;
    break;
      }
    }
    if(d==1)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=0;i<=n;++i)
#define INF 100000000
#define MOD 1000000009
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

vector<int> v;
bool memo[26];
string str;
int n;
vector<char> alpha = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main(){
    cin >> str;
    n = str.size();

    REP(i, 26) memo[i] = true;

    if(n < 26){
        REP(i, n){
            auto itr = find(alpha.begin(), alpha.end(), str[i]);
            int index = distance(alpha.begin(), itr);
            memo[index] = false;
        }
        
        rep(i, 26){
            if(memo[i]){
                cout << str << alpha[i] << endl;
                return 0;
            }
        }
    } else {
        REP(i, 26){
            auto itr = find(alpha.begin(), alpha.end(), str[i]);
            int index = distance(alpha.begin(), itr);
            v.push_back(index);
        }

        for(int i=25;i>=2;--i){
            if(v[i-1] < v[i]){
                REP(k, i-1){
                    auto itr = find(alpha.begin(), alpha.end(), str[k]);
                    int index = distance(alpha.begin(), itr);
                    memo[index] = false;
                }
                int j = v[i-1]+1;
                while(true){
                    if(memo[j]){
                        REP(k, i-1) cout << str[k];
                        cout << alpha[j] << endl;
                        return 0; 
                    }
                    ++j;
                }
            }
        }

        if(str != "zyxwvutsrqponmlkjihgfedcba"){
            cout << alpha[v[0]+1] << endl;
            return 0;
        }

        cout << "-1" << endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int ans=0;
	rep(i,10){
		int t;
		cin>>t;
		ans+=t;
	}
	cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int sum = 111;
    for (int i = 1;i <= 9;i++){
        if (n >= 100 && n <= 111){
            n = 111;
            break;
        }
        if(n > sum*i && n <= sum*(i+1)){
            n = sum*(i+1);
            break;
        }
    }

    cout << n << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int[] w = new int[10];
	    int[] k = new int[10];
	    int tw = 0, tk = 0;

	    for(int i = 0; i < 10; i++) w[i] = sc.nextInt();
	    for(int j = 0; j < 10; j++) k[j] = sc.nextInt();

	    Arrays.sort(w);
	    Arrays.sort(k);
	    for(int i = 0; i < 3; i++){
		tw += w[9-i];
		tk += k[9-i];
	    }

	    System.out.println(Integer.toString(tw)+" "+Integer.toString(tk));
	}
    }

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

Measured memory_bytes: 12000
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Aug  4 05:07:15 2018
//
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

var N, M int
var ps pairs

func main() {
	fmt.Scan(&N, &M)
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		ps = append(ps, pair{a, b})
	}

	sort.Sort(ps)

	x := 0
	count := 0
	for i := range ps {
		if ps[i].a > x {
			count++
			x = ps[i].b - 1
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 8580
//#include <bits/stdc++.h>
#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 <ctime>
#include <memory.h>
#include <math.h>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);++(i))
#define REP1(i,n) for((i)=1;(i)<=(int)(n);++(i))

int cnt_digits (long num) {
	int count =0;
	while (num !=0) {   
		count++;  
		num/=10;
	} 
   return count;
}

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long n; cin >> n;
    long res = 100000000;
    for (int i=1; i<=sqrt(n)+1; i++) {
        if (n%i==0) {
        	// cout << i << " " << n/i << endl;
        	long ans = max(cnt_digits(i),cnt_digits(n/i));
        	// cout << "ans = " << ans << endl;
        	if (ans < res) res = ans;
        }
    }
    cout << res << endl;
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**18+1
    n,k=MI()
    aa=LI()
    pp=[]
    mm=[]
    zero=0
    for a in aa:
        if a>0:pp.append(a)
        elif a<0:mm.append(a)
        else:zero+=1
    pp.sort()
    mm.sort()
    cm=len(mm)*len(pp)
    cz=zero*(zero-1)//2+zero*(n-zero)

    def ok1(c):
        i=0
        cnt=0
        for m in mm:
            while i<len(pp) and m*pp[i]>=c:i+=1
            if i==len(pp):break
            cnt+=len(pp)-i
        return cnt<k

    def ok2(c):
        cnt=0
        j=len(mm)-1
        for i,m in enumerate(mm):
            while j>i and m*mm[j]>=c:j-=1
            if i>=j:break
            cnt+=j-i
        j=len(pp)-1
        for i,p in enumerate(pp):
            while j>i and p*pp[j]>=c:j-=1
            if i>=j:break
            cnt+=j-i
        return cnt<k

    # 答えが負
    if k<=cm:
        l=-inf
        r=inf
        while l+1<r:
            c=(l+r)//2
            if ok1(c):l=c
            else:r=c
    # 答えが0
    elif k<=cm+cz:
        print(0)
        exit()
    # 答えが正
    else:
        mm.reverse()
        k-=cm+cz
        l=-inf
        r=inf
        while l+1<r:
            c=(l+r)//2
            if ok2(c):l=c
            else:r=c
    print(l)

main()

Measured memory_bytes: 88532
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
  Int N;
  cin >> N;
  bool * a;
  map<string, Int> order;
  map<string, set<Int>> m;
  for (Int i = 0; i < N; i++)
  {
      string S;
      Int P;
      cin >> S >> P;
      m[S].insert(P);
      order[S+to_string(P)] = i+1;
  }
  
  for(auto mm:m){
      auto s = mm.second;
      for (auto itr = s.rbegin(); itr != s.rend(); itr++){
        cout  << order[mm.first+to_string(*itr)] << endl;
      }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (a + b >= c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  double x1, y1, x2, y2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
  printf("%lf\n", pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 0.5));
}



Measured memory_bytes: 2856
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int H, W, h, w;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> H >> W >> h >> w;
    if(H % h == 0 && W % w == 0) finish("No");
    cout << "Yes" << endl;
    int c = h;
    if(H % h == 0) c = w;
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            if((c == h && i % h == 0) || (c == w && h != w && j % w == 0)) cout << 1000 * (c - 1) - 1 << " ";
            else cout << -1000 << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1792
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    q = n // 1000

    if n % 1000 > 0:
        q += 1

    res = q * 1000 - n
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cout = main(kwargs)
    print(cout)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;
int main() {

    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];

    vector<int> diff(1000, 0);
    REP(i, N){
        diff[abs(X-p[i])]++;
    }
    if(diff[0] != 1){
        cout << X << endl;
        return 0;
    }
    int ans = 0;
    REP1(i, 1000){
        // cout << diff[i] << endl;
        if(diff[i] != 2){
            ans = i;
            break;
        }
    }
    int flag = 0;
    REP(i, N){
        if(X+ans==p[i]){
            cout << X-ans << endl;
            flag = 1;
        }
        if(X-ans==p[i]){
            cout << X+ans << endl;
            flag = 1;
        }
    }
    if(flag==0){
        cout << X-ans << endl;
    }
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

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

    ll n,ans=0;
    cin>>n;
    ll l=sqrt(n);
    
    forx(i,1,(int)l+1){
        if(n%i==0){
            ll x=(n-i)/i;
            if(x>i)ans+=x;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
const long long INF = 1LL<<60;

int main(){
	int n; cin>>n;
	vector<int> a(n);
	cinf(n,a);
	vector<int> left(n,0),right(n,0);
	left[0]=abs(a[0]);
	right[n-1]=abs(a[n-1]);
	for(int i=1;i<n;i++){
		left[i]=left[i-1]+abs(a[i]-a[i-1]);
	}
	for(int i=n-2;i>=0;i--){
		right[i]=right[i+1]+abs(a[i]-a[i+1]);
	}
	cout << right[1]+abs(a[1])<<endl;
	for(int i=1;i<n-1;i++){
		cout << left[i-1]+abs(a[i-1]-a[i+1])+right[i+1]<<endl;
	}
	cout << left[n-2]+abs(a[n-2]) << endl;
}

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

int main()
{
    string s, t, u;
    int a, b;

    cin >> s >> t >> a >> b >> u;

    if (u == s)
    {
        a--;
    }
    else if (u == t)
    {
        b--;
    }

    string res = to_string(a) + " " + to_string(b);
    cout << res << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    string s; cin>>s;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='1') cout<<9;
        else cout<<1;
    }
}

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

def solve(num):
    res = 0
    for i in range(n):
        if (info[i][0] | num) == num:
            res += info[i][1]
    return res


k = bin(k)[2::]
ans = 0
num = int(k,2)
ans = solve(num)

for i in range(len(k)):
    if k[i] == "1":
        num = int(k[0:i]+"0"+(len(k)-i-1)*"1", 2)
        ans = max(ans, solve(num))
print(ans)

Measured memory_bytes: 61528
// JOI - Prelim  0515
// 通学経路
#include <bits/stdc++.h>

using namespace std;

using Int  = int_fast64_t;
using UInt = uint_fast64_t;

template <typename T>
using vec1 = vector<T>;

template <typename T>
using vec2 = vec1<vec1<T>>;

template <typename T>
vec2<T> InitVec2(size_t x, size_t y, const T& i = T())
{
    return vec2<T>(y, vec1<T>(x, i));
}

template <typename T>
T Get(const vec2<T>& v2, size_t x, size_t y)
{
    return v2[y][x];
}

template <typename T>
T& Ref(vec2<T>& v2, size_t x, size_t y)
{
    return v2[y][x];
}

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

const array<Int, 2> dx{1, 0};
const array<Int, 2> dy{0, 1};

UInt       A_ = 0;
UInt       B_ = 0;
vec2<char> vec2map_;
UInt       goal_count = 0;

void move(UInt x, UInt y)
{
    if (x == A_ - 1 && y == B_ - 1) {
        ++goal_count;
        return;
    }
    if (x >= A_ || y >= B_) {
        return;
    }
    if (!Get(vec2map_, x, y)) {
        return;
    }
    for (auto i = 0u; i < dx.size(); ++i) {
        const auto nx = x + dx[i];
        const auto ny = y + dy[i];
        move(nx, ny);
    }
}

bool sub()
{
    A_ = cin2var<UInt>();
    B_ = cin2var<UInt>();

    if (!A_ || !B_) return false;

    vec2map_ = InitVec2<char>(A_, B_, 1);

    const auto N(cin2var<UInt>());
    for (auto i = 0u; i < N; ++i) {
        const auto X(cin2var<UInt>() - 1);
        const auto Y(cin2var<UInt>() - 1);
        Ref(vec2map_, X, Y) = 0;
    }

    goal_count = 0;
    move(0, 0);
    cout << goal_count << endl;

    return true;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    while (sub());
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    map<char, ll> mp;
    rep(i, n) mp[s[i][0]]++;

    vector<int> v(5);
    rep(i, 5) v[i] = i;
    string march = "MARCH";

    ll ans = 0;
    rep(i, 5)
    {
        rep2(j, i + 1, 5)
        {
            rep2(k, j + 1, 5)
            {
                ans += mp[march[i]] * mp[march[j]] * mp[march[k]];
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6340
package main

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

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	N := nextInt()
	K := nextInt()
	x := nextInts(N)
	start := 0
	for i := 0; i < N; i++ {
		if x[i] > 0 {
			break
		} else {
			start++
		}
	}
	start = min(N-1, start)
	ans := int(1e10)
	for i := 0; i+K-1 < N; i++ {
		j := i + K - 1
		if start == 0 {
			ans = min(ans, abs(x[j]))
		} else if start == N-1 {
			ans = min(ans, abs(x[i]))
		} else {
			len1 := 2*abs(x[i]) + abs(x[j])
			len2 := abs(x[i]) + 2*abs(x[j])
			ans = min(ans, len1, len2)
		}
	}
	fmt.Println(ans)
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func printInts(out []int, str string) {
	var bb bytes.Buffer
	for i := range out {
		bb.WriteString(strconv.Itoa(out[i]))
		bb.WriteString(str)
	}
	fmt.Println(bb.String())
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder1
{
    class Program
    {
        static void Main()
        {
            var S = ReadLine();
            var K = long.Parse(ReadLine());

            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != '1')
                {
                    WriteLine(K >= i + 1 ? S[i] : '1');
                    return;
                }
            }
            WriteLine('1');
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    int i=0;
    int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1] << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main
{
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        List<Integer> list=new ArrayList<Integer>();
        for(int i=0;i<n;i++)
          list.add(sc.nextInt());
        List<Integer> dyn=new ArrayList<Integer>();
        dyn.add(0);
        dyn.add((int)(Math.abs(list.get(1)-list.get(0))));
        for(int i=2;i<n;i++)
        {
             dyn.add((int)(Math.min(dyn.get(i-1)+(int)Math.abs(list.get(i)-list.get(i-1)),dyn.get(i-2)+(int)Math.abs(list.get(i)-list.get(i-2)))));
        }
        System.out.println(dyn.get(n-1));
        sc.close();
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

using pos = struct {
	int y;
	int x;
};

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

	int h, w;
	cin >> h >> w;

	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	vector<pair<pos, pos>> ans;
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] % 2 == 0) {
				continue;
			}

			ans.push_back({
				{i + 1, j + 1},
				{i + 2, j + 1}
			});
			a[i + 1][j]++;
		}
	}

	for (int j = 0; j < w - 1; j++) {
		if (a[h - 1][j] % 2 == 0) {
			continue;
		}
		ans.push_back({
			{h, j + 1},
			{h, j + 2}
		});
		a[h - 1][j + 1]++;
	}

	cout << ans.size() << endl;
	for (auto e : ans) {
		cout << e.first.y << " " << e.first.x << " ";
		cout << e.second.y << " " << e.second.x << endl;
	}
	return 0;
}


Measured memory_bytes: 5236
#include<stdio.h>
 
int main(){
  char a[11], b[11], c[11], s[4];
  scanf("%s %s %s", a, b, c);
  
  s[0] = toupper(a[0]);
  s[1] = toupper(b[0]);
  s[2] = toupper(c[0]);
  s[3] = '\0';
  
  printf("%s\n", s);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  cin >> A;
  int B = 700;
  for(int i = 0; i < A.size(); i++) {
    if(A.at(i) == 'o') {
      B += 100;
    }
  }
  cout << B << endl;
}


Measured memory_bytes: 3592
#include <iostream>

int main() {
  int n, a, b, c, d;

  std::cin >> n >> a >> b >> c >> d;

  std::string s;
  std::cin >> s;

  a--; b--;
  c--; d--;

  std::string answer = "Yes";

  for (int i = a + 1; i <= c; i++) {
    if (s[i] == '#' && s[i - 1] == '#') {
      answer = "No";
    }
  }

  for (int i = b + 1; i <= d; i++) {
    if (s[i] == '#' && s[i - 1] == '#') {
      answer = "No";
    }
  }

  if (d < c) {
    bool can_overtake = false;
    for (int i = b; i <= d; i++) {
      if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
        can_overtake = true;
      }
    }

    if (!can_overtake) {
      answer = "No";
    }
  }

  std::cout << answer << std::endl;

  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int people[100010];
int main() {
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		int a,b;
		scanf("%d %d",&a,&b);
		people[a]++;
		people[b+1]--;
	}
	for(int i=1;i<=N+1;i++) {
		people[i]+=people[i-1];
	}
	int ans=0;
	for(int i=N;i>=0;i--) {
		if(people[i+1]>=i) {ans=i;break;}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
using namespace std;
#define MAX_H 500
#define MAX_W 500
class Elem{
public:
	Elem():c('*'),h(0),w(0),area(0){}
	char c;
	int h, w, area;
};
int main(void){
	Elem **map;

	// alloc big arraies
	map = new Elem*[MAX_H+1];
	for(int i = 0; i < MAX_H+1; i++){
		map[i] = new Elem[MAX_W+1];
	}

	while( true ){
		int H,W;
		int maxArea = 0;

		cin >> H >> W;
		if( H == 0 && W == 0 ) break;

		// input
		cin.ignore();
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cin >> map[i][j].c;
				map[i][j].h = map[i][j].w = 0;
			}
			cin.ignore();
		}

		// wacther initiate
		for(int i = 0; i < H+1; i++) map[i][W].area = map[i][W].h = map[i][W].w = 0;
		for(int i = 0; i < W+1; i++) map[H][i].area = map[H][i].h = map[H][i].w = 0;
		
		for(int i = H - 1; i >= 0; i--){
			for(int j = W - 1; j >= 0; j--){
				if( map[i][j].c == '.' ){
					int minWid;
					map[i][j].h = map[i+1][j].h + 1;
					map[i][j].w = map[i][j+1].w + 1;
					map[i][j].area = minWid = map[i][j].w;
					for(int k = 1; k < map[i][j].h; k++){
						minWid = min(minWid, map[i+k][j].w);
						map[i][j].area = max( map[i][j].area, minWid * (k+1));
					}
					maxArea = max( maxArea, map[i][j].area );
				}else{
					map[i][j].area = map[i][j].h = map[i][j].w = 0;
				}
			}
		}
		cout << maxArea << '\n';
	}

	// free
	for(int i = 0; i < MAX_H+1; i++){
		delete [] map[i];
	}
	delete [] map;

	return 0;
}

Measured memory_bytes: 4832
#include <iostream>
int main(){
   int N,def=0,temp,ans=0;
   std::cin>>N;
   int a[N],c[N];
   for(int i=0;i<N;i++){
    std::cin>>a[i];
   }
   for(int i=0;i<N;i++){
    std::cin>>temp;
    def+=temp;
   }
   for(int i=0;i<N-1;i++){
     std::cin>>c[i];
   }
   for(int i=0;i<N-1;i++){
    if(a[i+1]-a[i]==1){
      ans+=c[a[i]-1];
    }
   }
   ans+=def;
   std::cout<<ans<<std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int sum=0;
    for(int i=0;i<n;i++){
        int c;
        cin>>c;
        if(c<a||c>=b){
            sum++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
/// 
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define re_fr(i,a,b) for(int i=a;i>=b;i--)
#define frl(i,a,b) for(ll i=a;i<=b;i++)
#define re_frl(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define MX 1e18
#define eps 1e-9
#define mod 1000000007
#define mod2 100000000
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
void fil()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
int main()
{
    fast();
    string s; cin>>s;
    cout<<"ABC"<<s<<endl;









    return 0;
}


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

void swap(int a, int b, char* cup)
{
	char temp;
	temp = cup[a];
	cup[a] = cup[b];
	cup[b] = temp;
}

int main(void)
{
	char cup[3] = { 'A' , 'B', 'C'}, a, b, ch;
	int na, nb;

	while (cin >> a >> ch >> b)
	{
		if (a == 'A') na = 0;
		else if (a == 'B') na = 1;
		else na = 2;
		if (b == 'A') nb = 0;
		else if (b == 'B') nb = 1;
		else nb = 2;
		swap(na, nb, cup);
	//	for (int i = 0; i < 3; i++) cout << cup[i] << " ";
	//	cout << endl;
	}
	for (int i = 0; i < 3; i++)
	{
		if (cup[i] == 'A')
		{
			if (i == 0) cout << "A" << endl;
			else if (i == 1) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();
    ArrayList<Integer>ans  = new ArrayList<>();

    for(int i=0; i<=S.length() - T.length(); i++) {
    	int cou = 0;
       	for(int j=0; j< T.length(); j++) {
      		if(ss[i+j] == t[j]) {
    		cou++;
    		}
    	}
    	ans.add(cou);
    	cou = 0;
    }
    Collections.sort(ans,Collections.reverseOrder());
    	System.out.println(T.length() - ans.get(0));
    	
      }
}


Measured memory_bytes: 36456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, m;
 	cin >> n >> m;
 	ll u, v;
 	set <ll> check;
 	set <pll> edges;
 	while (m--) {
 		cin >> u >> v;
 		if (u == 1) check.insert(v);
 		if (v == 1) check.insert(u);
 		edges.insert({u, v});
 	}   
 	for (auto it : check) {
 		if (edges.find({it, n}) != edges.end() || edges.find({n, it}) != edges.end())  {
 			cout << "POSSIBLE" << endl;
 			exit(0);
 		}
 	}
 	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 20692
#include <iostream>
#include <queue>

int main()
{
	using namespace std;

	int x, y;
	cin >> x >> y;

	priority_queue<int> q;
	q.push(x);
	q.push(y);

	auto Pop = [&q]()
	{
		int poped = q.top();
		q.pop();
		q.push(poped - 1);
		return poped;
	};

	cout << (Pop() + Pop()) << endl;
}


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

int main()
{
std::string str;
std::cin >> str;
long int len = str.length();
long int count = 0;
long int buf = 0;
if(str[0] == 'S'){
    buf = 1;
}
for(long int i = 1; i < len; i++){
    if(buf > 0 && str[i] == 'T'){
        buf--;
        count += 2;
    } else if(str[i] == 'S'){
        buf++;
    } else {
        buf = 0;
    }
}
std::cout << len - count << std::endl;
return 0;
}

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

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> leng(n);
    rep(i,n){
        cin >> leng[i];
    }
    vector<int> leap(n+1);
    leap[0] = 0;
    repp(j,n+1,1){
        leap[j] = leap[j-1] + leng[j-1];
    }
    int ans = 0;
    while (ans < leap.size() && leap[ans] <= x){
        ans++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-03-29 20:45:29
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++)
        cin >> b[i];

    vector<vector<int>> a(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int temp;
            cin >> temp;
            a[i].push_back(temp);
        }
    }

    // Proc Below

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int stat = 0;
        for (int j = 0; j < m; j++) 
            stat += a[i][j]*b[j];
        
        if (stat + c > 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256