akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int>d(n);
  int count=0;
  vector<int>memo(110);
  
  for(int i=0; i<n; i++){
    cin >> d[i];
  }

  for(int i=0; i<n; i++){ //バケット法
    memo[d[i]]++;
  }
  
  for(int i=0; i<110; i++){
    if(memo[i]>0){
      count++;
    }
  }
  cout << count << endl;    
  
}

Measured memory_bytes: 256
N, x = gets.strip.split.map(&:to_i)
children = gets.strip.split.map(&:to_i).sort
count = 0

if children.reduce(:+) == x
  puts N 
else
  children.each do |child|
    if x >= child
      count += 1
      x -= child
    else
      break
    end
  end
  puts [count, N - 1].min
end

Measured memory_bytes: 1916
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();
		for (int i = 0; i < m; i++) {
			set.add(sc.nextInt());
		}
		sc.close();

		long[] dp = new long[n + 1];
		dp[0] = 1;
		if (!set.contains(1)) {
			dp[1] = 1;
		}
		for (int i = 2; i <= n; i++) {
			if (!set.contains(i)) {
				dp[i] = dp[i - 2] + dp[i - 1];
				dp[i] %= 1000000007;
			}
		}
		System.out.println(dp[n]);
	}
}


Measured memory_bytes: 66004
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


pair<ll, ll> divide(ll h, ll w){
    if (h % 2 == 0 || w % 2 == 0) return {h*w/2, h*w/2};
    //if (h > w) swap(h, w);
    //return {h*(w+1)/2, h*(w-1)/2};
    return {h*((w+1)/2), h*((w-1)/2)};
    
}

int main(){
    
    long long H, W;
    cin >> H >> W;

    ll ans = INF;
    // Wは固定で高さを全探索
    for (ll h = 1; h < H; h++){
        vector<ll> area(3);
        area[0] = h*W;
        pair<ll, ll> p = divide(H-h, W);
        area[1] = p.first;
        area[2] = p.second;
        sort(area.begin(), area.end());
        ans = min(ans, area[2]-area[0]);
    }

    // Hは固定で幅を全探索
    for (ll w = 1; w < W; w++){
        vector<ll> area(3);
        area[0] = H*w;
        pair<ll,ll> p = divide(H,W-w);
        area[1] = p.first;
        area[2] = p.second;
        sort(area.begin(), area.end());
        ans = min(ans, area[2]-area[0]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 3608
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long A =sc.nextLong();
    String B =sc.next();
    String b[] =B.split("",0);long D;
    D =Integer.parseInt(b[0]+b[2]+b[3]);
    long E =A*D;
    long F =E/100;
    System.out.println(F);
  }
}

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

int main(){
	int N,i;
	cin >> N;
	int X[N],Y[N];
	for (i=0;i<N;i++){
		cin >> X[i];
		Y[i]=X[i];
	}
	sort(Y,Y+N);
	for(i=0;i<N;i++){
		if(X[i]<=Y[(N/2)-1]){
			cout << Y[N/2];
		}
		else{
			cout << Y[(N/2)-1];
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dp[101][101][4];	// [4]ツづ債縦ツ，ツ可。

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		memset(dp,0,sizeof(dp));
		dp[0][0][1]=dp[0][0][2]=1;
		rep(i,h)
			dp[i][0][0]=1;
		rep(i,w)
			dp[0][i][3]=1;
		repi(i,1,h)
			repi(j,1,w){
				dp[i][j][0]=dp[i-1][j][0]+dp[i-1][j][1];
				dp[i][j][1]=dp[i-1][j][3];
				dp[i][j][2]=dp[i][j-1][0];
				dp[i][j][3]=dp[i][j-1][2]+dp[i][j-1][3];
				rep(k,4)
					dp[i][j][k]%=100000;
			}
		cout<<accumulate(dp[h-1][w-1],dp[h-1][w-1]+4,0)%100000<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
K = int(input())

s = "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".split(", ")

print(s[K-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int A[100010] = {}; 
	int B[100010] = {}; 
	int mn = N, mx = 0; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		mn = min(mn, A[i]), mx = max(mx, A[i]); 
		B[A[i]] ++; 
	}
	if(mx - mn >= 2) cout << "No" << endl; 
	else if(mx == mn){
		if(N == mx + 1 || N >= mx * 2) cout << "Yes" << endl; 
		else cout << "No" << endl; 
	}
	else{
		if(B[mx] >= 2 * (mx + B[mx] - N) && mx + B[mx] - N > 0) cout << "Yes" << endl; 
		else cout << "No" << endl; 
	}
}

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

using namespace std;

#define ll long long
#define ar array

int n, k, tmp;
string s;




void solve(){
    

    cin >> n;
    
    if(n%1000 == 0) cout << "0" << endl;
    else
        cout <<  1000-(n % 1000) << "\n";

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  map<string, int> blue;
  map<string, int> red;
  int N, M;
  cin >> N;
  string s;
  rep(i, N){
    cin >> s;
    blue[s]++;
  }
  cin >> M;
  rep(i, M){
    cin >> s;
    red[s]++;
  }
  int ans = 0;
  for(auto itr : blue){
    s = itr.first;
    ans = max(ans, blue[s] - red[s]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => Int64.Parse(x)).ToArray();
        var n = l[0]; var m = l[1];
        var hs = Console.ReadLine().Split(' ')
            .Select(x => Int64.Parse(x)).ToArray();
        var vs = new List<View>();
        var line = new List<Int64[]>();
        foreach (var i in hs)
        {
            vs.Add(new View() { High = i });
        }
        for (var i = 0; m > i; i++)
        {
            var li = Console.ReadLine().Split(' ')
                .Select(x => Int64.Parse(x)).ToArray();
            vs[(Int32)li[0] - 1].CanGo.Add(vs[(Int32)li[1] - 1]);
            vs[(Int32)li[1] - 1].CanGo.Add(vs[(Int32)li[0] - 1]);
        }
        var res = 0;
        for (var i = 0; vs.Count > i; i++)
        {
            var s = vs[i];
            var f = true;
            foreach (var j in s.CanGo)
            {
                if (j.High >= s.High)
                {
                    f = false;
                    break;
                }
            }
            if (f) res++;
        }
        Console.WriteLine(res);
    }
}

class View
{
    public Int64 High { get; set; }
    public HashSet<View> CanGo = new HashSet<View>();
}

Measured memory_bytes: 76692
x, y= map(int,input().split())

A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]

if x in A:
    if y in A:
        print("Yes")
    else:
        print("No")
if x in B:
    if y in B:
        print("Yes")
    else:
        print("No")
if x in C:
    if y in C:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;i<10;i++)
    for(int j=i;j<10;j++){
      if(i*j==n){
        puts("Yes");
        n=0;
      }
    }
  if(n)puts("No");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long d[510000];
pair<long long,int> e[510000];
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=0;i<a;i++)scanf("%lld",d+i);
    long long ret=-999999999999999LL;
    long long sum=0;
    for(int i=0;i<a;i++){
        e[i]=make_pair(d[i]+(long long)i*b,i);
        sum+=d[i];
    }
    std::sort(e,e+a);
    for(int i=0;i<=a;i++){
        //printf("%lld\n",sum);
        ret=max(ret,(long long)i*(i-1)*b+sum+(long long)b*c*i);
        if(i<a){
            sum-=d[e[i].second];
            sum-=(long long)e[i].second*b;
        }
         
    }
    printf("%lld\n",ret);
}


Measured memory_bytes: 14616
# coding: utf-8

n = int(input().rstrip())

dish_list = [int(i) for i in input().rstrip().split(" ")]
manzoku = [int(i) for i in input().rstrip().split(" ")]
bonus = [int(i) for i in input().rstrip().split(" ")]

prev = -10
ans = sum(manzoku)
for i in range(n):
    dish = dish_list[i]
    if dish - prev == 1:
        ans += bonus[prev - 1]
    prev = dish
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int,int> mi,me,md;
  set<int> s;
  rep(i,n) {
    cin >> a[i];
    mi[a[i]+1]++;
    me[a[i]]++;
    md[a[i]-1]++;
    s.insert(a[i]+1);
    s.insert(a[i]);
    s.insert(a[i]-1);
  }
  int ans = 0;
  for (auto si:s) {
    int cnt = 0;
    if (mi.count(si)) cnt += mi[si];
    if (me.count(si)) cnt += me[si];
    if (md.count(si)) cnt += md[si];
    ans = max(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;


int main()
{
    int n;
    cin >>n;
    int p[n];
    int a[n+1];
    for(int i=0;i<n;i++){
        cin >> p[i];
        a[i]=0;
    }
    int m=10000000;
    int b=0;
    while(b<=p[0]){
        int form=b;
        a[0]=b;
        for(int i=0;i<n;i++){
            a[i+1]=max(p[i]-a[i],0);
        }
        form+=a[n];
        for(int i=1;i<n;i++)
            form+=(a[i]*2);
        m=min(m,form);
        b++;
    }
    cout << m << endl;
        return 0;
}



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

#define ll  long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)

int main(){
    string s,t;
    cin >> s >> t;
    ll sl = s.length() + 1,tl = t.length() + 1;
    string dp[2][tl];
    rep(i,0,tl){
        dp[0][i] = "";
    }
    rep(i,1,sl){
        dp[1][0]="";
		dp[0][0]="";
        rep(j,1,tl){
                if(s[i - 1] == t[j - 1]){
                    dp[1][j] = dp[0][j - 1];
                    dp[1][j] += s[i - 1];
                }
                else{
                    if(dp[1][j - 1].length() > dp[0][j].length()){
                        dp[1][j] = dp[1][j - 1];
                    }
                    else dp[1][j] = dp[0][j];
                }
         
        }
        rep(it,0,tl){
            dp[0][it] = dp[1][it];
        }
    }
    cout << dp[1][tl - 1] << endl;
    

    
}



Measured memory_bytes: 16840
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m,*t=map(int,open(0).read().split())\n"
"s=sorted\n"
"a=s(t[:n])[::-1]\n"
"for c,b in s(zip(t[n+1::2],t[n::2]))[::-1]:\n"
" while(c>a[n-1])*n*b:n-=1;a[n]=c;b-=1\n"
"print(sum(a))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 36536
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	

	string S;
	cin >> S;

	int size = S.size();

	int half = size / 2;

	int ans = 0;
	for (int i = 0; i < half; i++) {
		ans += (S[i] != S[size - 1 - i]);


	}
	
	cout << ans;





}




Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, K, C;
	String S;
	List<Integer> result;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		K = Integer.parseInt(tokens[1]);
		C = Integer.parseInt(tokens[2]);
		S = in.readLine();
	}

	void calc() {
		List<Integer> indexes = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			if (S.charAt(i) == 'o') {
				indexes.add(i);
				i += C;
			}
		}
		List<Integer> indexes2 = new ArrayList<>();
		for (int i = N - 1; i >= 0; i--) {
			if (S.charAt(i) == 'o') {
				indexes2.add(i);
				i -= C;
			}
		}
		result = new ArrayList<>();
		int n = indexes.size();
		for (int i = 0; i < n; ++i) {
			int l = indexes.get(i);
			int r = indexes2.get(n - 1 - i);
			if (l == r) {
				result.add(l);
			}
		}
		if (result.size() > K) {
			result.clear();
		}
	}

	void showResult() {
		for (int i = 0; i < result.size(); ++i) {
			System.out.println((result.get(i) + 1));
		}
	}
}

Measured memory_bytes: 56712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static long mod = 1000000007;   // 10^9 + 7

		static void Main(string[] args)
		{
			int a = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			if (a >= 3200) {
				Console.WriteLine(s);
			} else {
				Console.WriteLine("red");
			}
		}
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,c;
  cin >> a >> b >> c;
  int64_t  k;
  cin >> k;
  if(k<=a)cout << k << endl;
  else if(k<=a+b)cout << a << endl;
  else if(k<=a+b+c)cout << a-(k-a-b) << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
  
  
  
void solve(int N) {
    vector<int> v(401);
    int max_len = 0;
    for (int i = 0; i < N * (N-1) / 2; i++) {
        int j; cin >> j; v[j]++;
        max_len = max(max_len, j);
    }
  
    set<vector<int>> ans;
    for (int i = 0; i < (1<<(N-2)); i++) {
        vector<int> s;
        auto count = v;
        bool flag = false;
  
        if (i % 2) s.push_back(max_len);
        else s.push_back(0);
  
        int t = max_len;
        int j = 0;
        while (t) {
            if (!count[t]) {
                t--;
                continue;
            }
  
            int position = (i & (1 << j)) ? max_len - t : t;
            for (auto k : s) {
                int dist = abs(k - position);
                if (count[dist]) count[dist]--;
                else {
                    flag = true;
                    break;
                }
            }
            if (flag) break;
            s.push_back(position);
            j++;
        }
        if (flag) continue;
        sort(s.begin(), s.end());
        vector<int> ad;
        for (int i = 0; i < N-1; i++) ad.push_back(s[i+1] - s[i]);
        ans.insert(ad);
        reverse(ad.begin(), ad.end());
        ans.insert(ad);
    }
  
    for (auto avec: ans) {
        for (int i = 0; i < N-1; i++) {
            if (i < N-2) cout << avec[i] << " ";
            else cout << avec[i] << endl;
        }
    }
      
    cout << "-----" << endl;
}
  
int main() {
    int N;
    while (cin >> N, N) {
        solve(N);
    }
  
  
    return 0;
}

Measured memory_bytes: 3164
import java.util.*;
  public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m=sc.nextInt();
    int d=sc.nextInt();
    sc.close();
    int d10=d/10;
    int d1=d%10;
    int cnt=0;
    if(d10>=2&&m>=4){
      for(int i=4;i<=m;i++){
        for(int j=2;j<d10;j++){//10の位で，d10未満分
          for(int k=2;k<10;k++){
            if(i==j*k){
              cnt++;
            }
          }
        }
        for(int k=2;k<=d1;k++){//１０の位がd10のとき
          if(i==d10*k){
            cnt++;
          }
        }
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 22228
from itertools import combinations
n, k = map(int, input().split())
dots = sorted([list(map(int, input().split())) for _ in range(n)])

ans = float("inf")
for x1, x2 in combinations(range(n), 2):
	wid = dots[x2][0] - dots[x1][0]
	dots_cand = sorted(dots[x1: x2 + 1], key=lambda x: x[1])
	for y1, y2 in combinations(range(x2 + 1 - x1), 2):
		if y2 - y1 + 1 >= k:
			area = (dots_cand[y2][1] - dots_cand[y1][1]) * wid
			if area < ans:
				ans = area

print(ans)

Measured memory_bytes: 3064
<?php

$file_handle = fopen('php://stdin', "r");	

//wfs
function wfs() {
	global $sec;
	global $ary_start;
	global $goal_flag;

	$queue[0] = $ary_start;			//スタートを$queueに入れて開始
	$queue_size = count($queue[0]);	//キューの長さを取得
	$queue[0]['sec'] = 0;			//スタート時の秒数(階層の深さ)を入れる
	while (!empty($queue)) {		//$queueが1つ以上あればループ
	   $cur = array_shift($queue);	//配列$queueの頭から１つ取り出す。
	   
	   //終了条件。全ての配列が同じ色なら終了
	   $cnt = 0;	//カウント
	   for($i=0; $i<$queue_size; $i++){
	       if ($cur[$i] !== $cur[0]){ break; }
	       $cnt++;
	   }
	   if ($cnt === $queue_size) {
	       $goal_flag = 1;
	       $sec = $cur['sec'];	//ゴールした時の秒数
	       break;	//色がすべて同じならwhileを抜ける
	   }
	   
	   //探索
	    for($i=0; $i<$queue_size-1; $i++){
	    	if ($cur[$i] !== $cur[$i+1]){	//隣接する体節の色が違う場合
    			$new = $cur;
    			$new['sec'] = $cur['sec'] + 1;
	    		//変化する色ごとに場合分け
	    		if ($cur[$i] !== 'r' && $cur[$i+1] !== 'r'){
	    			$new[$i] = 'r';  $new[$i+1] = 'r';
	    		} else if ($cur[$i] !== 'g' && $cur[$i+1] !== 'g'){
	    			$new[$i] = 'g';  $new[$i+1] = 'g';
	    		} else {
	    			$new[$i] = 'b';  $new[$i+1] = 'b';
	    		}
	    		$str = toString($new);
	    		if (empty($visited[$str])){
		    		array_push($queue, $new);
				    $visited[$str] = 1;
				}
	    	}
	    }
	}
}

//再訪防止用。配列のキーに文字列を設定するために使用
function toString($ary){
	$str = '';
	foreach ($ary as $key => $val){
		if (is_numeric($key)) {		//配列のキーが数値ならば（secがあるので）
			$str = $str.$val;
		}
	}
	return $str;
}


while (1){
	//変数の初期化
	$sec = 0;
	$goal_flag = 0;

	//ファイル読み込み
	$stdin = trim(fgets($file_handle));
	//終了条件
	if ($stdin == '0'){
		break;
	}
	$ary_start = str_split($stdin);
	

	//探索
	wfs();

	//出力
	if ($goal_flag === 1){
		echo $sec;
	} else {
		echo 'NA';
	}
	echo PHP_EOL;
}

fclose($file_handle);

Measured memory_bytes: 12924
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	string s;
	int ans=0;
	cin>>s;
	if(s[0]=='1') ans++;
	if(s[1]=='1') ans++;
	if(s[2]=='1') ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = int(input())

l = 1
cur_ret = [[0]]
while l < a:
    new_ret = []
    na = new_ret.append
    for i in cur_ret:
        k = max(i) + 2
        for j in range(k):
            na(i+[j])
    cur_ret = new_ret
    l+=1

def format(x):
    x = list(map(lambda x : chr(x+97),x))
    return "".join(x)

cur_ret = list(map(format,cur_ret))
cur_ret.sort()
for i in cur_ret:
    print(i)

Measured memory_bytes: 32460
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)

	ks := []int{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}
	fmt.Println(ks[n-1])
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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


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

static const int N=100;
int dp[N+1][N+1];
int p[N+1];
int main(){
    int n;
    cin>>n;
    int h,w;//h:num of gyo,w:num of retu
    for(int i=1;i<=n;i++){
        cin>>p[i-1]>>p[i];
    }
    for(int i=1;i<=n;i++){
        dp[i][i]=0;
    }
    for(int l=2;l<=n;l++){
        for(int i=1;i<=n-l+1;i++){
            int j=l+i-1;
            dp[i][j]=(1<<21);
        for(int k=i;k<=j-1;k++){
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
        
        }
        }
        
    }
    cout<<dp[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
	ll a1, a2, b1, b2;
	cin >> a1 >> a2 >> b1 >> b2;
	if (a1 * b2 >= a1 * b1 && a1 * b2 >= a2 * b1 && a1 * b2 >= a2 * b2)cout << a1 * b2;
	else if (a1 * b1 >= a1 * b2 && a1 * b1 >= a2 * b1 && a1 * b1 >= a2 * b2)cout << a1 * b1;
	else if (a2 * b1 >= a1 * b1 && a2 * b1 >= a1 * b2 && a2 * b1 >= a2 * b2) cout << a2 * b1;
	else cout << a2 * b2;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 98765432198765432
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

ll fac[200001];
ll inv[200001];
ll nCr(int n, int r)
{
	ll c = fac[n];
	c = (c*inv[r]) % MOD;
	c = (c*inv[n - r]) % MOD;
	return c;
}
map<int,int> M;
int main() {
	fac[0] = inv[0] = 1;
	fup(i, 1, 200000, 1)
		fac[i] = (fac[i - 1] * i) % MOD;
	inv[200000] = POW(fac[200000], MOD - 2);
	fdn(i, 199999, 1, 1)
		inv[i] = (inv[i + 1] * (i+1)) % MOD;
	int n,m;
	scanf("%d%d",&n,&m);
	int t=m;
	for(int i=2;i*i<=t;i++)
	{
		while(t%i==0)
		{
			M[i]++;
			t/=i;
		}
	}
	if(t!=1)M[t]++;
	ll ans=1;
	for(auto it=M.begin();it!=M.end();it++)
	{
		int tt=it->Y;
		ans=(ans*nCr(n+tt-1,tt))%MOD;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
     int main() {
     double n,ans;
     while(cin>>n&&n!=0){
     vector<int>s(n);
     for(int i=0;i<n;i++){cin>>s.at(i);}
     ans=0;
     for(int i=0;i<n;i++){ans+=s.at(i);}
     double m=ans/n;
     double v=0;
     for(int i=0;i<n;i++){v+=(s.at(i)-m)*(s.at(i)-m);}
     double a=v/n;
     cout << fixed << setprecision(5);
     cout<<sqrt(a)<<endl;
     }
      return 0;
    }


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    int n;cin>>n;
    vector<ll> a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    int pre[n+1]={0};
    for(int i=1;i<=n;i++){
        pre[i]=(pre[i-1]+a[i])%mod;
        pre[i]%=mod;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(a[i]*pre[i-1])%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5516
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> st(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		st[i] = { a,i + 1 };
	}
	sort(st.begin(), st.end());
	for (int i = 0; i < N; i++)cout << st[i].second << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,n) for(int i=0; i<n; i++)
#define forp(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        cout<<(n*360/gcd(360,n))/n<<nl;;
    }
    return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,st,en) for(long long i=(st),i##Len_=(en);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

struct Node {
    ll parent;
    ll point;
};


Node gNode[2 * 100001];
vector <vector<int>> ab(2*100001);

int dfs(int now, int papa)
{
    for(int i = 0; i < ab[now].size(); ++i)
    {
        int tar = ab[now][i];
        if(tar != papa)
        {
            gNode[tar].point += gNode[now].point;
            dfs(tar,now);
        }
    }
    return 0;
}

int main()
{

    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll N,Q;
    cin >> N >> Q;


    // 1.初期化
    for(int i = 0;i < N;++i){
        gNode[i].parent = -1;
        gNode[i].point = 0;
    }

    ll a,b;
    for(ll i = 0; i < N-1; ++i)
    {
        cin >> a >> b;
        --a;--b;
        //ねは0に
        ab[a].push_back(b);
        ab[b].push_back(a);
//        cout << a << " " << b << endl;
    }

    ll p,x;
    REP(i,Q)
    {
        cin >> p >> x;
        --p;
        gNode[p].point += x;
//        cout << p << " " << x << endl;
    }

    dfs(0,-1);


    REP(i,N)
    {

        cout << gNode[i].point << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 25856
a,b,c,x,y = map(int,input().split())


count = 0
if a+b>2*c:
    count += min(x,y)*2*c
    if x==y:
        count += 0
    elif x>y:
        if a > 2*c:
            count += 2*c*(x-y)
        else:
            count += a*(x-y)
    else:
        if b > 2*c:
            count += 2*c*(y-x)
        else:
            count += b*(y-x)
else:
    count += a*x+b*y

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
##
NMC=input().split()
N=int(NMC[0])
M=int(NMC[1])
C=int(NMC[2])
#
Bs=input().split()#M個の数字
#
count=0
dict={}
#
for i in range(N):
  dict[i]=input().split()#str型注意
##
for j in range(N):
  atai=0
  for k,s in zip(dict[j],range(M)):
    atai+=int(k)*int(Bs[s])
  if (atai+C)>0:
    count+=1
print(str(count))


Measured memory_bytes: 3064
N,K=map(int,input().split())
h=input()

def ans142(N:int, K:int, h:list):
    N=int(N)
    K=int(K)
    count=0
    if N==1:
        h=int(h)
        if h>=K:
           return(1)
        elif h<K:
           return(0)
    else:
     h=h.split()
     for i in range(0,N):
        if int(h[i])>=K:
            count+=1
     return(count)
print(ans142(N,K,h))


Measured memory_bytes: 16480
N = int(input())

A = []

for i in range(N):

    a = int(input())

    A.append(a)

ans = 0
amari = 0

for i in range(N):

    ans += (A[i] + amari) // 2

    if A[i] == 0:
        amari = 0
    else:
        amari = (A[i] + amari) % 2
        
print (ans)



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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
const int maxn = 1e5 + 10;
vi adj[maxn];
bool mark[maxn];
int main(){
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	deque<int> d;
	d.push_back(0);
	mark[0] = 1;
	while(1){
		int v = d.back();
		int ne = -1;
		for(auto u : adj[v])
			if(!mark[u])
				ne = u;
		if(ne != -1){
			mark[ne] = 1;
			d.push_back(ne);
		}
		else break;
	}
	while(1){
		int v = d.front();
		int ne = -1;
		for(auto u : adj[v])
			if(!mark[u])
				ne = u;
		if(ne != -1){
			mark[ne] = 1;
			d.push_front(ne);
		}
		else break;
	}
	cout << d.size() << endl;
	for(auto i : d)
		cout << i + 1 << " ";
	cout << endl;
}


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

using namespace std;

typedef long long ll;

vector<ll> a;

void dfs(ll x)
{
    a.push_back(x);
    ll r = x % 10;
    if (r < 9 && x * 10 + (r + 1) <= 4000000000)
        dfs(x * 10 + (r + 1));
    if (x * 10 + r <= 4000000000)
        dfs(x * 10 + r);
    if (r > 0 && x * 10 + (r - 1) <= 4000000000)
        dfs(x * 10 + (r - 1));
}

int main()
{
    ios_base::sync_with_stdio(0);
    int k;
    cin >> k;
    for (int i = 1; i <= 9; ++i)
        dfs(i);
    sort(a.begin(), a.end());
    cout << a[k - 1];
    return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
  
using namespace std;
  
void Solution()
{
    string s1, s2;
    
    cin>>s1;
    cin>>s2;  // or cin>>s1>>s2;
    
    s1 = s1 + s1; // clockwise
    
    if(s1.find(s2) != string::npos)  // means can not find the matching words
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}
  
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1192
n = int(raw_input())
ais =[0] + map(int,raw_input().split()) + [0]
skip = -float('inf')
cumul = 0
res  = []
for i in range(1,len(ais)-1):
	val = abs(ais[i] - ais[i-1])
	skip = -abs(ais[i] - ais[i-1]) - abs(ais[i+1] - ais[i]) + abs(ais[i+1] - ais[i-1])
	res.append(skip)
	cumul += val
cumul += abs(ais[-1] - ais[-2])
for i in range(len(res)):
	print res[i] + cumul

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

int main() {
  int h[30] = {0};
  string w;
  bool hit = true;
  cin >> w;
  for (int i = 0; i < w.size(); i++) {
    h[w[i] - 'a']++;
  }
  for (int i = 0; i < ('z' - 'a'); i++) {
    if (h[i] % 2 != 0)
      hit = false;
  }
  if (hit) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

struct Po {
    ll t,b,l,r;
};
void solve()
{
    ll H,W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    vector<vector<Po>> po(H, vector<Po>(W));

    for1(i,H) {
        string S;
        cin >> S;
        for1(j,W) {
            s[i][j] = S[j];
        }
    }

    for1(i,H) {
        ll l = -1;
        for1(j,W) {
            if (s[i][j] == '#') {
                l = j;
            }
            po[i][j].l = l;
        }
        ll r = W;
        for (ll j = W-1; j >= 0; --j) {
            if (s[i][j] == '#') {
                r = j;
            }
            po[i][j].r = r;
        }
    }

    for1(j,W) {
        ll t = -1;
        for1(i,H) {
            if (s[i][j] == '#') {
                t = i;
            }
            po[i][j].t = t;
        }
        ll b = H;
        for (ll i = H-1; i >= 0; --i) {
            if (s[i][j] == '#') {
                b = i;
            }
            po[i][j].b = b;
        }
    }

    ll ans = 0;
    for1(i,H) {
        for1(j,W) {
            if (s[i][j] == '#') {
                continue;
            }
            ll a1 = po[i][j].b - po[i][j].t - 1 + po[i][j].r - po[i][j].l - 1 - 1;
            //cout << i << " " << j << " " << a1 << endl;
            ans = max(ans, a1);
        }
    }

    cout << ans << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 129408
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, cnt;
pair<int, int>mx;
bool useda[100];
pair<int, int>red[100], blue[100];

int main() {
	cin >> n;
	lp(n)
		cin >> red[i].first >> red[i].second;
	lp(n)
		cin >> blue[i].first >> blue[i].second;
	sort(red, red + n);
	sort(blue, blue + n);
	cnt = 0;
	lp(n)
		useda[i] = false;
	lp(n) {
		mx = make_pair(-1, -1);
		for (int j = 0; red[j].first < blue[i].first && j < n;j++) {
			if (!useda[j]&&red[j].second < blue[i].second) {
				if (mx.second < red[j].second) {
					mx = make_pair(j, red[j].second);
				}
			}
		}
		if (mx.first != -1) {
			useda[mx.first] = true;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const ll MAXN = 1e18;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n;
	int k;
	cin >> n >> k;
	int ans = 1;
	for(int i=0; i<n; i++){
		if(ans*2 < ans+k){
			ans*=2;
		}else{
			ans+=k;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3600
N,M=map(int,input().split())
A=sorted(map(int,input().split()))
B=[0]
for a in A:
    B.append(B[-1]+a)
def f(n):
    a,b=0,0
    r=N-1
    for l in range(N):
        while r>-1 and A[l]+A[r]>=n:
            r-=1
        a+=N-1-r
        b+=A[l]*(N-1-r)+B[N]-B[r+1]
    return a,b
l,r=0,10**6
x=0
while l+1<r:
    t=(l+r)//2
    a,b=f(t)
    if a<M:
        r=t
    else:
        x=max(x,t)
        l=t
a,b=f(x)
print(b-x*(a-M))

Measured memory_bytes: 14268
using System;
using System.Linq;
using System.Collections;
class Program
{
    public static void Main()
    {
        string[] imp = Console.ReadLine().Split(' ');
        int n, k;
        n = int.Parse(imp[0]);
        k = int.Parse(imp[1]);
        long ans = 0;
        if (k != 0)
        {
            for (int b = k + 1; b <= n; b++)
                ans += (((long)n + 1) / b) * (b - k) + Math.Max((n + 1) % b - k, 0);
            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine((long)n * n);
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
primes = []

def prepare_prime(N):
    s = 0
    memo = [0 for _ in range(N)]
    for i in range(2, N):
        if s + 2 >= N:
            break

        p = i
        if memo[i] == 0:
            if i % 5 == 1:
                primes.append(i)
            while p < N:
                if memo[p] == 0:
                    memo[p] = 1
                    s += 1
                p += i
    return

prepare_prime(55555)

for idx in range(N):
    print(primes[idx + 2], end=' ' if idx < N-1 else '\n')


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        for (int j = 0; j < T.size(); ++j) {
            int l = min(lcp[j], j);
            ans = max(ans, l);
        }
    }
        
    cout << ans << endl;
    return 0;
}

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

void solve(){
    int n, k;
    cin >> n >> k;
    vi h(n);
    for(auto &it: h) cin >> it;

    vi dp(n, 1e9+5);
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        for(int j = max(i-k, 0); j < i; ++j){
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
        }
    }
    cout << dp[n-1] << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}

Measured memory_bytes: 4760
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;

int g[500][500];
int l[500],r[500];
int dp[500];

bool cmp(int i, int j) {
  return r[i] < r[j];
}

int main() {
  int n,s;
  while(cin >> n >> s) {
    s--;
    vector<int> id(n);
    REP(i,n) {
      cin >> l[i] >> r[i];
      id[i] = i;
    }
    sort(ALL(id),cmp);
    REP(i,n) REP(j,n) cin >> g[i][j];
    REP(k,n)REP(i,n)REP(j,n)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    REP(i,n) {
      if (g[s][i]<=r[i]) {
        dp[i] = max(0,r[i]-max(l[i],g[s][i]));
      } else {
        dp[i] = -500000000;
      }
    }
    REP(i,n) {
      int a = id[i];
      REP(j,n) {
        int b = id[j];
        if (r[a]+g[a][b]<=r[b]) {
          chmax(dp[b], dp[a] + max(0,r[b]-max(l[b],r[a]+g[a][b])));
        }
      }
    }
    cout << *max_element(dp,dp+n) << endl;
  }
}

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

int main() {
  string N, ans = "No";
  cin >> N;
  for(char s : N) {
    if (s == '7') ans = "Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0)cout << 0.5 << endl;
	else printf("%.15f", (double)(n / 2 + 1) / n);
	return 0;
}

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

x = list(map(int,input().split()))

limit = 10**18

ans = 1

q = 0

if 0 in x:
    ans = 0
else:
    for i in x:
        ans *= i
        if ans>limit:
            q = 1
            break
    
if q == 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21720