akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int H,W,K; cin>>H>>W>>K;
	vector<vector<char>> choco(H, vector<char> (W));
	rep(i,H)rep(j,W)cin>>choco[i][j];
	int ans = inf;
	for(int bit = 0; bit < (1<<(H-1)); ++bit){
		vector<int> uni(H);
		int div_row = 0;
		int e_ans = 0;
		rep(i,H-1){
			uni[i] = div_row;
			if(bit & (1<<i)){
				++div_row;
			}
		}
		uni[H-1] = div_row;

		// cout<<line<<endl;
		// printf("[%d] ... ", bit);
		// show(uni);
		vector<int> bk_cnt(div_row+1,0);
		rep(j,W){
			vector<int> t(div_row+1,0);
			rep(i,H){
				if(choco[i][j] == '1'){
					t[uni[i]]++;
				}
			}
			bool go = true;
			rep(i,div_row+1){
				if(t[i] > K)e_ans += 100000;
				if(bk_cnt[i] + t[i] > K){
					go = false;
					break;
				}
			}
			if(go){
				rep(i,div_row+1)bk_cnt[i] += t[i];
			}else{
				e_ans++;
				rep(i,div_row+1)bk_cnt[i] = t[i];
			}
			// show(bk_cnt);
		}
		// printf("this term's ans is %d\n", e_ans+div_row);
		// cout<<line<<endl;
		ans = min(ans, e_ans+div_row);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int a[100000];
int main()
{
    int n,i,temp,k,sum,x;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&a[i]);

         sum=0,x=0;
        for(i=1; i<=n; i++)
        {
            sum=sum+fabs(a[i]-x);
            x=a[i];
        }
          sum=sum+fabs(x-0);

          
    for(k=1; k<=n; k++)
    {
        
        int sum2=sum;
        
        int x=fabs(a[k]-a[k-1])+fabs(a[k+1]-a[k]);
        
        int y=fabs(a[k+1]-a[k-1]);
        
        
        if(x-y>=0)
        sum2=sum2-(x-y);
        else
                 sum2=sum2+(x-y);
        printf("%d\n",sum2);
    }



    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[100000];
int b[100000];
char str[2]="SW";
int n;
int check(){
	int i;
	FOR(i,2,n){
		if(b[i-1]==a[i-1]) b[i]=b[i-2];
		else b[i]=1-b[i-2];
	}
	if((a[0]==b[0])!=(b[1]==b[n-1])) return 0;
	else if((a[n-1]==b[n-1])!=(b[n-2]==b[0])) return 0;
	else return 1;
}
int main(void)
{
	int i,j;
	char s;
	scanf("%d%*c",&n);
	FOR(i,0,n){
		scanf("%c",&s);
		a[i]=(s!='o');
	}
	FOR(i,0,2){
		FOR(j,0,2){
			b[0]=i,b[1]=j;
			if(check()){
				FOR(i,0,n) putchar(str[b[i]]);
				puts("");
				return 0;
			}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const int INF=1e9;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n){
    ll x;
    cin >> x;
    x--;
    a[x]=i;
  }
  set<int>st;
  st.insert(-1);
  st.insert(n);
  
  ll ans=0;
  rep(i,n){
    auto itr=st.lower_bound(a[i]);
    int r=*itr;
    int l=*(--itr);
    ans+=(a[i]-l)*(r-a[i])*(i+1);
    st.insert(a[i]);
  }
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 11264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[][] table = new int[8][];
            table[1] = new int[] { 0, 0, 300, 500, 600, 700, 1350, 1650 };
            table[2] = new int[] { 0, 6, 0, 350, 450, 600, 1150, 1500 };
            table[3] = new int[] { 0, 13, 7, 0, 250, 400, 1000, 1350 };
            table[4] = new int[] { 0, 18, 12, 5, 0, 250, 850, 1300 };
            table[5] = new int[] { 0, 23, 17, 10, 5, 0, 600, 1150 };
            table[6] = new int[] { 0, 43, 37, 30, 25, 20, 0, 500 };
            table[7] = new int[] { 0, 58, 52, 45, 40, 35, 15, 0 };

            while (true)
            {
                int s = int.Parse(Console.ReadLine());

                if (s == 0) break;

                string[] input = Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]);
                int m = int.Parse(input[1]);
                bool flg = CheckTime(h, m);

                int t = int.Parse(Console.ReadLine());

                if (!flg)
                {
                    input = Console.ReadLine().Split(' ');
                    h = int.Parse(input[0]);
                    m = int.Parse(input[1]);
                    flg = CheckTime(h, m);
                }
                else Console.ReadLine();

                int min = Math.Min(s, t);
                int max = Math.Max(s, t);

                int p = table[min][max];

                if (flg && table[max][min] <= 40)
                {
                    p /= 2;

                    int q = p % 50;
                    if (q > 0) p = p - q + 50;
                }
                sb.AppendLine(p.ToString());
            }
            Console.Write(sb);
        }

        static bool CheckTime(int h, int m)
        {
            switch (h)
            {
                case 17:
                    return m >= 30;
                case 18:
                    return true;
                case 19:
                    return m <= 30;
                default:
                    return false;
            }
        }
    }
}

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

int main(){
  long long n, m; cin >> n >> m;
  priority_queue<long long> que;
  for(int i = 0; i < n; i++){
    long long a; cin >> a;
    que.push(a);
  }
  for(int i = 0; i < m; i++){
    long long tmp = que.top();
    que.pop();
    que.push(tmp / 2);
  }
  long long out = 0;
  for(int i = 0; i < n; i++){
    out += que.top();
    que.pop();
  }
  cout << out;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

int main() {
  std::string s;
  std::getline(std::cin, s);
  std::cout << s.substr(0, 4) << " " << s.substr(4) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <iostream>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N,K,Q; cin>>N>>K>>Q;

    vector<int> o(N,0);
    for (int i = 0; i < Q; ++i) {
        int a; cin>>a; --a;
        o[a]++;
    }

    int border=Q-K;

    for (int i = 0; i < N; ++i) {
        if(o[i]>border) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		List<List<Integer>> graph = new ArrayList<>();
		for (int i = 0;i < N;++ i) graph.add(new ArrayList<>());
		for (int i = 0;i < M;++ i) {
			int x = sc.nextInt() - 1, y = sc.nextInt() - 1, z = sc.nextInt();
			graph.get(x).add(y);
			graph.get(y).add(x);
		}
		int ans = 0;
		boolean bfs[] = new boolean[N];
		Arrays.fill(bfs, false);
		for (int i = 0;i < N;++ i) {
			if (bfs[i]) continue; // 調べ終わっている
			bfs[i] = true;
			++ ans;
			Queue<Integer> queue = new ArrayDeque<>();
			for (queue.add(i);!queue.isEmpty();) {
				int tmp = queue.poll();
				for (int next : graph.get(tmp)) {
					if (bfs[next]) continue; // 既に色を塗った
					bfs[next] = true;
					queue.add(next);
				}
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


const int MX = 1e6 + 5;
int freq[MX], A[200005];
vi divs[MX];



int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	for (int i = 1; i < MX; ++i) {
		for (int j = i; j < MX; j += i)
			divs[j].pb(i);
	}

	int N;

	cin >> N;


	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
		++freq[A[i]];
	}

	int ans = 0;

	for (int i = 1; i <= N; ++i) {
		bool good = true;
		for (auto& div : divs[A[i]]) {
			if (freq[div] - (A[i] == div)) {
				good = false;
				break;
			}
		}
		ans += good;
	}

	cout << ans << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 122384
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 1e6+6;
const ll inf =1e9;

int main(){
	fastio;
	ll tc,n;
	tc=1;
//	cin>>tc;
	while(tc--){
		cin>>n;
		cout<<fixed<<setprecision(12)<< 2*acos(-1)*(1.0*n) <<endl;
		
	}
}

Measured memory_bytes: 3804
n = int(input())
s = []
for _ in range(n): 
    s.append(input())
m = int(input())
t = []
for _ in range(m): 
    t.append(input())

a = 0
for x in list(set(s)):
    a = max(a, s.count(x) - t.count(x))

print(a)

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

const ll INF = 1LL << 60;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = INF;
	rep(bit, (1 << n)) {
		vector<int> s;
		rep(i, n) {
			if (bit & (1 << i)) {
				s.push_back(i);
			}
		}
		vector<ll> t(n);
		rep(i, s.size()) {
			int u = s[i];
			rep(j, u) {
				if (a[j] + t[j] >= a[u] + t[u]) {
					t[u] = a[j] + t[j] - a[u] + 1;
				}
			}
		}
		int cnt = 1;
		rep(i, (int)s.size() - 1) {
			int u = s[i];
			int v = s[i + 1];
			if (a[u] + t[u] < a[v] + t[v]) cnt++;
		}
		if (cnt < k) continue;
		ll mn = 0;
		rep(i, n) mn += t[i];
		ans = min(ans, mn);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,h = m()
po = []
for i in range(n):
    a,b = m()
    po.append([a,b])

po.sort(reverse = True)

on = po[0]

po.sort(reverse = True,key = lambda x:x[1])

co = 0

for i in range(n):
    if h <= 0:
        break
    if on[0] <= po[i][1]:
        co += 1
        h -= po[i][1]
    else:
        break
if h <= 0:
    print(co)
else:
    print(co + (-(-h//on[0])))





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

int main(void) {
    int n;
    int **graph;

    scanf("%d", &n);
    graph = malloc(n * sizeof(int*));
    for(int i = 0; i < n; i++) {
        graph[i] = malloc(n * sizeof(int));
        memset(graph[i], 0, n * sizeof(int));
    }


    for(int i = 0; i < n; i++) {
        int uIdx;
        int deg;
        scanf("%d %d", &uIdx, &deg);
        for(int j = 0; j < deg; j++) {
            int vIdx;
            scanf("%d", &vIdx);
            graph[uIdx - 1][vIdx - 1] = 1;
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            printf("%d", graph[i][j]);
            if(j < n - 1) {
                printf(" ");
            }
        }
        printf("\n");
    }
    
    for(int i = 0; i < n; i++) {
        free(graph[i]);
    }
    free(graph);
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll a, b;
    cin >> a >> b;
    if(a > 0) {
        cout << "Positive" << endl;
    }
    else if(a <= 0 && b >= 0) {
        cout << "Zero" << endl;
    }
    else {
        ll count = b-a;
        if(count%2 == 0) {
            cout << "Negative" << endl;
        }
        else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if((a+b)%2==0){
      cout << (a+b)/2 << endl;
  }else{
      cout << (a+b)/2+1 << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#define int long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0,-1 }; // x軸方向への変位
int dy[4] = { 1, 0,-1, 0 }; // y軸方向への変位





signed main() {
	string s;
	set<char> charSet;
	set<string> ansSet;
	int K;
	cin >> s >> K;
	for (int i = 0; i < (int)s.size(); i++) {
		charSet.insert(s[i]);
	}
	for (char c : charSet) {
		if (ansSet.size() > K) break;
		
		for (int i = 0; i < (int)s.size(); i++) {
			if (s[i] == c) {
				for (int j = i; j < (int)s.size(); j++) {
					
					string str = s.substr(i, j - i + 1);
					if ((int)str.size() > K) break;
					ansSet.insert(str);
				}
			}
		}

	}
	int count = 0;
	for (string st : ansSet) {
		count++;
		if (count == K) cout << st << "\n";
	}


	return 0;




}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int H, W, N;
PII xs[18][500][500];

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

  cin >> H >> W >> N;
  REP(y,H) REP(x,W)
	cin >> xs[0][y][x];

  vector<PII> ps(N);
  REP(i,N) cin >> ps[i];

  for(int i=1;i<18;++i){
	REP(y,H) REP(x,W){
	  auto&& par = xs[i-1][y][x];
	  xs[i][y][x] = xs[i-1][par.FF][par.SS];
	}
  }

  bool no = true;
  set<PII> s;
  for(auto&& p: ps){
	PII np = xs[17][p.FF][p.SS];
	if(s.count(np)){
	  no = false;
	}
	s.insert(np);
  }
  if(no){
	cout << -1 << endl;
	return 0;
  }

  int ans = 0;
  vector<vector<PII>> db(H, vector<PII>(W));
  REP(y,H) REP(x,W) db[y][x] = MP(y,x);
  for(int i=17;i>=0;--i){
	bool excess = false;
	set<PII> s;
	for(auto&& p: ps){
	  PII np = db[p.FF][p.SS];
	  np = xs[i][np.FF][np.SS];
	  if(s.count(np)){
		excess = true;
		break;
	  }
	  s.insert(np);
	}
	if(!excess){
	  ans |= 1<<i;
	  REP(y,H) REP(x,W){
		PII p = db[y][x];
		db[y][x] = xs[i][p.FF][p.SS];
	  }
	}
  }
  cout << ans+1 << endl;

  return 0;
}

Measured memory_bytes: 51556
/*
 * Program compiled with natsubf by Natsu Kinmoe
 * Natsubf is a multifunctional brainfuck tool
 * https://github.com/natsukmoe/natsubf
 */
#include <cstdio>

char ram[30000];
int ptr;

int main(){
	ptr+=2;
	ram[ptr]=getchar();
	ptr+=1;
	ram[ptr]+=8;
	while(ram[ptr]){
		ram[ptr]-=1;
		ptr-=1;
		ram[ptr]-=8;
		ptr-=1;
		ram[ptr]+=12;
		ptr-=1;
		ram[ptr]+=8;
		ptr+=3;
	}
	ptr-=3;
	ram[ptr]+=1;
	ptr+=1;
	ram[ptr]+=1;
	ptr+=2;
	ram[ptr]+=1;
	ptr-=1;
	ram[ptr]-=1;
	while(ram[ptr]){
		ram[ptr]-=1;
		while(ram[ptr]){
			ram[ptr]-=1;
			while(ram[ptr]){
				ram[ptr]-=1;
				while(ram[ptr]){
					ram[ptr]-=1;
					while(ram[ptr]){
						ram[ptr]-=1;
						while(ram[ptr]){
							ram[ptr]-=1;
							while(ram[ptr]){
								ram[ptr]-=1;
								while(ram[ptr]){
									ram[ptr]-=1;
									while(ram[ptr]){
										ram[ptr]-=1;
										while(ram[ptr]){
											ram[ptr]-=1;
											while(ram[ptr]){
												ram[ptr]-=1;
												while(ram[ptr]){
													ram[ptr]-=1;
													while(ram[ptr]){
														ram[ptr]-=1;
														while(ram[ptr]){
															ram[ptr]-=1;
															while(ram[ptr]){
																ram[ptr]-=1;
																while(ram[ptr]){
																	ram[ptr]-=1;
																	while(ram[ptr]){
																		ram[ptr]-=1;
																		while(ram[ptr]){
																			ram[ptr]-=1;
																			while(ram[ptr]){
																				ram[ptr]-=1;
																				while(ram[ptr]){
																					ram[ptr]-=1;
																					while(ram[ptr]){
																						ram[ptr]-=1;
																						while(ram[ptr]){
																							ram[ptr]-=1;
																							while(ram[ptr]){
																								ram[ptr]-=1;
																								while(ram[ptr]){
																									ram[ptr]-=1;
																									while(ram[ptr]){
																										ram[ptr]-=1;
																										while(ram[ptr]){
																											while(ram[ptr]){
																												ram[ptr]-=1;
																											}
																											ptr+=1;
																											ram[ptr]-=1;
																											ptr-=2;
																											putchar(ram[ptr]);
																											ptr+=1;
																										}
																									}
																								}
																							}
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	ptr+=1;
	while(ram[ptr]){
		ptr-=3;
		putchar(ram[ptr]);
		while(ram[ptr]){
			ram[ptr]-=1;
		}
	}
	return 0;
}


Measured memory_bytes: 1480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005;
int vis[N],n;
vector<int> v[N];
void dfs(int p,int fa){
	int sum=0;
	for(unsigned i=0;i<v[p].size();i++)if(v[p][i]!=fa){
		dfs(v[p][i],p);
		sum+=vis[v[p][i]];
	}
	if(sum==0)vis[p]=1; else if(sum>1){
		puts("First"); exit(0);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int s=read(),t=read();
		v[s].push_back(t);
		v[t].push_back(s);
	}
	if(n%2==1){
		puts("First"); return 0;
	}
	dfs(1,0);
	if(vis[1])puts("First"); else puts("Second");
}


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 55;
ll dis[maxn][maxn * maxn], ans[maxn];
int n, m, s, u, v, c[maxn], d[maxn], a, b;
bool mark[maxn][maxn * maxn];
vector<pair<int, pair<int, int>>> vec[maxn];
queue<pair<int, int>> q;

void spfa()
{
    while (!q.empty())
    {
        u = q.front().first;
        v = q.front().second;
        mark[u][v] = 0;
        q.pop();
        if (v + c[u] < maxn * maxn && dis[u][v + c[u]] > dis[u][v] + d[u])
        {
            dis[u][v + c[u]] = dis[u][v] + d[u];
            if (!mark[u][v + c[u]])
            {
                mark[u][v + c[u]] = 1;
                q.push({u, v + c[u]});
            }
        }
        for (auto &w : vec[u])
        {
            if (v >= w.second.first && dis[u][v] + w.second.second < dis[w.first][v - w.second.first])
            {
                dis[w.first][v - w.second.first] = dis[u][v] + w.second.second;
                if (!mark[w.first][v - w.second.first])
                {
                    mark[w.first][v - w.second.first] = 1;
                    q.push({w.first, v - w.second.first});
                }
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    memset(dis, 63, sizeof dis);
    memset(ans, 63, sizeof ans);
    cin >> n >> m >> s;
    s = min(s, maxn * maxn - 1);
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v >> a >> b;
        u--;
        v--;
        vec[u].push_back({v, {a, b}});
        vec[v].push_back({u, {a, b}});
    }
    for (int i = 0; i < n; i++)
        cin >> c[i] >> d[i];
    mark[0][s] = 1;
    dis[0][s] = 0;
    q.push({0, s});
    spfa();
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < maxn * maxn; j++)
            ans[i] = min(ans[i], dis[i][j]);
        cout << ans[i] << endl;
    }
	return 0;
}


Measured memory_bytes: 5436
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

#define alt(s) (s == '0' ? '1' : '0')

int main()
{
	string S;
	char pre;
	int ans = 0;

	cin >> S;

	pre = S[0];
	repc(i, 1, S.length() - 1) {
		if (pre == S[i]) {
			S[i] = alt(pre);
			ans++;
		}
		pre = S[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B;
  
  int C[VMAX+ 1];
  int n, i, j;
  scanf("%d", &n);
  
  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);
  
  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;
  
  for ( i = 0; i < n; i++ ) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }
  
  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];
  
  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for ( i = 1; i <= n; i++ ) {
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 9544
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================



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);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll cnt = 0;
//#define int long long;


// ========================================================================


/*signed*/int main() {
	ll n; cin >> n;
	vl dp(100);
	dp[0] = 2;
	dp[1] = 1;
	for (int i = 2; i < n + 1; i++) dp[i] = dp[i - 1] + dp[i - 2];
	cout << dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>

using namespace std;

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

    int answer = 0;

    for (int i = 0; i < N; ++i) {
        int h ;
        cin >> h;
        if (h >= K) answer++;
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
while True:
	n = int(input())
	if(n==0): break
	data = {}
	firstname = ''
	for i in range(n):
		d = input()
		name = d.split(':')[0]
		if(i==0): firstname = name
		data[name] = []
		for x in d.split(':')[1].strip('.').split(','):
			data[name].append(x)
	removed = []
	for x in data[firstname]:
		if x in data:
			removed.append(x)
			for y in data[x]:
				data[firstname].append(y)
			data.pop(x)
	edited = set(data[firstname])
	for i in removed:
		edited.remove(i)
	print(len(edited))


Measured memory_bytes: 5720
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int int64_t
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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; i < n; i++)
#define out(n) cout << n << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    string k = s; REVERSE(k);
    int ans = 0;
    REP(i,s.size()) if(s[i]!=k[i]) ans++;
    out(ans/2);

    return 0;
}

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

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    float a,N,ans = 0;
    cin >> N;
    for(int i=0; i<N;i++){
        cin >> a;
        ans += 1.0/a;
    }
    cout << 1.0 / ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

result = 0
for bit in range(60):
    c = int((A & 1).sum())
    A >>= 1
    result = (result + c * (N - c) * (1 << bit)) % 1000000007
print(result)


Measured memory_bytes: 29120
import sys
N, K = map(int,input().split())
hairetu = []
for _ in range(N): hairetu.append(list(map(int,input().split())))
hairetu.sort()
cnt = 0
for i in range(N):
  cnt += hairetu[i][1]
  if K <= cnt:
    print(hairetu[i][0])
    sys.exit()

Measured memory_bytes: 27872
import java.util.*;
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();
       
		System.out.println(c + " " + a + " " + b);
	}
}


Measured memory_bytes: 21460
#include<stdio.h>
#include<string.h>
int main()
{
	int n,s[4]={0};
	char b[3];
	for(;;)
	{
		if(scanf("%d",&n)==EOF)
			break;
		scanf(",%s",&b);
		if(!strcmp("A",b))
			s[0]++;
		else if(!strcmp("B",b))
			s[1]++;
		else if(!strcmp("AB",b))
			s[2]++;
		else
			s[3]++;
	}
	for(n=0;n<4;n++)
		printf("%d\n",s[n]);
	return 0;
}

Measured memory_bytes: 596
use std::io;
use std::str::FromStr;

#[allow(dead_code)]
fn readval<T: FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    
    buf.trim().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn readvec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();

    buf.trim().split(" ")
              .map(|c| c.parse::<T>().ok().unwrap())
              .collect::<Vec<T>>()
}

fn main() {
    let s: String = readval();

    let mut stack: Vec<char> = vec![];
    let mut ans = 0;

    for si in s.chars() {
        if stack.len() == 0 {
            stack.push(si);
        }
        else if stack[stack.len()-1] == si {
            stack.push(si);
        }
        else {
            stack.pop();
            ans += 2;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
bad = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        bad.add(b)
    elif h[a-1] == h[b-1]:
        bad.add(a)
        bad.add(b)
    elif h[a-1] < h[b-1]:
        bad.add(a)
print(n - len(bad))


Measured memory_bytes: 19976
n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
        if l[i]+l[j] > l[k] and l[j]+l[k] > l[i] and l[k]+l[i] > l[j]:
          c += 1
print(c)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 

  int64_t n,k;
  cin>>n>>k;

  vector<int64_t> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }

  int64_t wk=1;
  int64_t wk_n=wk;
  for(int i=0;i<n;i++){

    if(i<=k-1)
      ;
    else{//k
      //wk*=a.at(i);
      //wk/=a.at(i-(k));
      if(a.at(i)>a.at(i-k))
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
    }

//    wk_n=wk;
  }


	return 0;
}

Measured memory_bytes: 4772
#include <stdio.h>

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

    int R[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &R[i]);
    }

    int minv = R[0];
    int max_gap = R[1] - R[0];

    for(int i = 1; i < n; i++){
        if(max_gap < R[i] - minv){
            max_gap = R[i] - minv;
        }
        if(R[i] < minv){
            minv = R[i];
        }
    }

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

    return 0;
}



Measured memory_bytes: 3508
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)

int main(){
  string S;
  cin >> S;
  int cnt = 0;
  rep(i, 3){
    if(S.at(i) == 'o'){
      cnt++;
    }
  }
  cout << 700 + 100 * cnt << endl;
}

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

using namespace std;

namespace Solver {

    int M;
    vector<string> ds;
    inline void Read() {
        cin >> M;
        ds.resize(M);
        for (int i = 0; i < M; i++) cin >> ds[i];
    }

    inline void Work() {
        for (int i = 0; i < M; i++) {
            set<string> ss;
            for (int j = 1; j < ds[i].length(); j++) {
                vector<string> s(4);
                s[0] = ds[i].substr(0, j);
                s[1] = ds[i].substr(0, j);
                s[2] = ds[i].substr(j);
                s[3] = ds[i].substr(j);
                reverse(s[1].begin(), s[1].end());
                reverse(s[3].begin(), s[3].end());

                for (int l = 0; l < 2; l++) {
                    for (int m = 2; m < 4; m++) {
                        if (l == m) continue;
                        ss.insert(s[l] + s[m]);
                        ss.insert(s[m] + s[l]);
                    }
                }

            }

            cout << ss.size() << endl;
        }
    }

    inline void Solve() {
        Read();
        Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1312
A=[0]*5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
K = int(input())
 
for i in range(4):
  for j in range(i+1,5):
    if abs(A[i]-A[j]) > K:
      print(':(')
      exit()
print('Yay!')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++1)
using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
int cnt = 0;
for (int i=0;i<b-a+1;i++){
if(c%(a+i)==0) {
cnt ++;
}
}
cout << cnt<< endl;
return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int a[N];
int main()
{
    FASTINOUT;
    int x,y,mx=0;
    cin>>x;
    for (int i=0;i<x;i++){
        cin>>y;
        a[y]++;
    }
    for (int i=1;i<=1e5+1;i++){
        mx=max(mx,a[i-1]+a[i]+a[i+1]);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
priority_queue<ll>que;
pair<ll,ll>p[114514];
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		que.push(a);
	}
	for(int i=0;i<m;i++){
		ll b,c;
		cin>>b>>c;
		p[i].first=-c,p[i].second=b;
	}
	sort(p,p+m);
	ll cnt=n;
	for(int i=0;i<m;i++){
		while(p[i].second){
			que.push(-p[i].first);
			p[i].second--;
			cnt--;
			if(!cnt)break;
		}
		if(!cnt)break;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ll x=que.top();
		que.pop();
		ans+=x;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3956
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextLine
    var acc = scala.collection.mutable.ArrayBuffer[String]()

    def go(n: Int, s: String): Unit = {
      if (n == 0) {
        acc += s
      } else {
        go(n - 1, s + "3")
        go(n - 1, s + "5")
        go(n - 1, s + "7")
        go(n - 1, s + "0")
      }
    }

    go(n.length, "")
    println(acc.map(_.toInt).filter(_ <= n.toInt).count(s => s.toString.distinct.length == 3 & !s.toString.contains("0")))
  }
}


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

int main(void){
    int n, d, x, ans ;
    cin >> n >> d >> x;
    ans = x;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += (d + a - 1) / a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,T = map(int,input().split())
ans = [1001,0]
status = 0

for i in range(N):
    c,t = map(int,input().split())

    if t <= T and c < ans[0]:
        ans[0] = c
        ans[1] = t
        status = 1
    else:
        pass

if status == 0:
    print("TLE")
else:
    print(ans[0])


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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,tc,c,l,r,p,cnt,v,x;

char s[N];

int o[]={3,5,7};

int go(ll x){
    int ans=0;
    ll k=x;
    bool a3=false,a5=false,a7=false;
    while(k){
        if (k%10 == 3)
            a3=true;
        else if (k%10 == 5)
            a5=true;
        else if (k%10 == 7)
            a7=true;
        k/=10;
    }
    if (a3 && a5 && a7)
        ans++;
    for(int i=0;i<3;i++){
        ll y = x*10 + o[i];
        if (y<=n)
            ans+=go(y);
    }
    return ans;
}

int main(){
//	#ifndef ONLINE_JUDGE
//		freopen("test.txt","r",stdin);
//	#endif
    int ans=0;
    scanf("%d",&n);
    for(int i=0;i<3;i++)
        ans+=go(o[i]);
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int H, W, i, j;

  for (; scanf("%d %d", &H, &W); ) {
    if (H == W && H == 0) {
      break;
    }

    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        putchar(i == 0 || i == H - 1 || j == 0 || j == W - 1 ? '#' : '.');
      }

      putchar('\n');
    }

    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define MAX2 2510
using namespace std;

int h,w;
vector<int> vec[MAX2];
int dp[MAX2];

int getManhattan(int a,int b)
{
  int x1 = a%w;
  int y1 = a/w;
  int x2 = b%w;
  int y2 = b/w; 
  return abs(x1-x2) + abs(y1-y2);
}

int main()
{
  while(cin >> w >> h,w|h)
    {
      rep(i,MAX2){ dp[i] = inf; vec[i].clear(); }
      int max_digit = -inf;
      int g;
      rep(i,h)
	{
	  rep(j,w)
	    {
	      string s;
	      cin >> s;
	      if(s[0] == '.')continue;
	      if(s[0] == 'S')
		{
		  vec[0].push_back(j+i*w);
		  dp[j+i*w] = 0;
		}
	      else if(s[0] == 'G')
		{
		  g = j+i*w;	  
		}
	      else
		{
		  int intValue = (atoi)(s.c_str());
		  vec[intValue].push_back(j+i*w);
		  max_digit = max(max_digit,intValue);
		}
	    }
	}

      if(max_digit == -inf)max_digit = 0;
      vec[++max_digit].push_back(g);

      rep(i,max_digit)
	{
	  rep(j,vec[i].size())
	    {
	      if(dp[vec[i][j]] == inf)continue;
	      rep(k,vec[i+1].size())
		dp[vec[i+1][k]] = min(dp[vec[i+1][k]],
				      dp[vec[i  ][j]]+getManhattan(vec[i][j],vec[i+1][k]));   
	    }
	}

      cout << dp[vec[max_digit][0]] << endl;
    }
  return 0;
}

Measured memory_bytes: 1420
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

vector<ll> dp(10005, 0);

bool is_square(long long N) {
    long long r = (long long)floor(sqrt((long double)N));  // 切り捨てした平方根
    return (r * r) == N;
}

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

    reps(n, 1, N + 1) {
        if (n < 6) {
            cout << 0 << endl;
        } else {
            ll cnt = 0;
            for (ll x = 1; x * x < n; x++) {
                for (ll y = 1; y * y < n; y++) {
                    ll now = x * x + y * y + x * y;
                    ll r = n - now;
                    for (ll z = 1; (x + y + z) * z <= r; z++) {
                        if ((x + y + z) * z == r) {
                            cnt++;
                        }
                    }
                }
            }

            cout << cnt << endl;
        }
    }

    return 0;
}

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

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

  int ans=1000000;
  for(int i=1; i<=n/2+1; i++){
    int x=i,y=n-i, a=0,b=0;
    while(x!=0){
      a+=x%10;
      x/=10;
    }
    while(y!=0){
      b+=y%10;
      y/=10;
    }
    ans=min(ans,a+b);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String args[] ) throws Exception {
    	
    	
    	 Scanner sc = new Scanner(System.in);
    	 int count = 0;
    	 
         while (sc.hasNext() && count<201){
             String s = sc.nextLine();
             String[] array = s.split(" ");
             
             int a = Integer.parseInt(array[0]);
             int b = Integer.parseInt(array[1]);
             
             int valLen = String.valueOf(a+b).length();
             System.out.println(valLen);
             
             count++;
        	 }
    }
}

Measured memory_bytes: 26304
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=220;
int h,w,ans,d[N][N],vis[N][N];
char a[N][N];
queue<int>qx,qy;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
void bfs(int x,int y)
{
	memset(d,0,sizeof(d));memset(vis,0,sizeof(vis));
	qx.push(x);qy.push(y);vis[x][y]=1;
	while(!qx.empty())
	{
		int nx=qx.front(),ny=qy.front();qx.pop();qy.pop();
		for(int i=0;i<4;i++)
		{
			int xx=nx+dx[i],yy=ny+dy[i];
			if(xx<1||yy<1||xx>h||yy>w||vis[xx][yy]||a[xx][yy]=='#')continue;
			d[xx][yy]=d[nx][ny]+1;qx.push(xx);qy.push(yy);vis[xx][yy]=1;
			ans=max(ans,d[xx][yy]);
		}
	}
}
int main()
{
	h=gi();w=gi();
	for(int i=1;i<=h;i++)scanf("%s",a[i]+1);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(a[i][j]=='.')bfs(i,j);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640