akhauriyash/Code-Regression huggingface dataset:
# Vicfred
# https://atcoder.jp/contests/dp/tasks/dp_a
# dynamic programming
n = int(input())
h = [0]+list(map(int, input().split()))

dp = [0]*(n + 1)
dp[1] = 0
dp[2] = abs(h[2] - h[1])

for i in range(3, n + 1):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
                dp[i - 2] + abs(h[i] - h[i - 2])
            )
print(dp[n])



Measured memory_bytes: 20628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int q;cin>>q;
    vector<int> t(100000,0);
    vector<int> sieve(100000,0);
    rep1(i,50000){
        if(i==1)continue;
        for(int j=i*2;j<=100000;j+=i){
            sieve[j]=1;
        }
    }
    int tmp=0;
    rep(i,100000){
        if(i==0||i==1||i%2==0)continue;
        if(sieve[i]==0&&sieve[(i+1)/2]==0)tmp++;
        t[i]=tmp;
    }
    //rep(i,100)cout<<t[i]<<" ";
    //cout<<endl;
    rep(i,q){
        int l,r;cin>>l>>r;
        int res=t[r]-t[l-2];
        cout<<res<<endl;
    }
}


Measured memory_bytes: 1536
A,B,C,D = map(int, input().split())

Alice_list = []
Bob_list = []

def fill_list(AB_list, starting, ending):
    for idx in range(101):
        if idx < starting:
            AB_list.append(0)
        elif starting <= idx < ending:
            AB_list.append(1)
        else:
            AB_list.append(0)

fill_list(Alice_list, A, B)
fill_list(Bob_list, C, D)

print([x+y for (x,y) in zip(Alice_list,Bob_list)].count(2))

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

int main() {
  int n,m; cin >> n >> m;
  int l,u; l = 0; u = (int)1e6;
  rep(i, m){
    int p, q; cin >> p >> q;
    if(l < p) l = p;
    if(q < u) u = q;
  }
  
  cout << max(u - l + 1, 0) << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
	double yama[100],t;
	int i=0,j,k;
	
	while(0<=scanf("%lf",&yama[i])){
		i++;
	}
	
	for(j=0;j<i;j++){
	for(k=j;k<i;k++){
	if(yama[j]<yama[k]){
t=yama[j];
yama[j]=yama[k];
yama[k]=t;
	}
	}
	}
	
	printf("%lf\n",yama[0]-yama[i-1]);
	return 0;
	}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;

int main(){
    string str;
    cin>>str;
    vector<ll> from(3),to(3);
    from[0] = 1ll;
    for(int i=0;i<(int)str.size();++i){
        fill(to.begin(),to.end(),0);
        if(str[i] == '1'){
            to[0] = (2*from[0])%mo;
            to[1] = (from[0] + from[1])%mo;
            to[2] = ((2*from[1])%mo + (3*from[2])%mo)%mo;
        }else{
            to[0] = from[0];
            to[1] = (2*from[1])%mo;
            to[2] = (from[1] + (3*from[2])%mo)%mo;
        }
        swap(to,from);
    }
    ll ret = 0ll;
    for(int i=0;i<3;++i) (ret +=from[i])%= mo;
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 512
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static long MOD = 998244353;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] d = new int[n];
		HashMap<Integer, Integer> map = new HashMap<>();
		for(i=0;i<n;i++) {
			d[i] = parseInt(sc.next());
			if(map.get(d[i])==null) {
				map.put(d[i], 1);
			} else {
				map.put(d[i], map.get(d[i])+1);
			}
		}
		sc.close();
		long ans=0;
		if(d[0]==0) {
			ArrayList<Integer> list = new ArrayList<>(map.keySet());
			Collections.sort(list);
			boolean f=true;
			for (i = 1;i < list.size(); i++) {
				if(list.get(i)-list.get(i-1)!=1) {
					f=false;
					break;
				}
			}
			if(map.get(list.get(0))>1)f=false; 
			if(f) {
				ans=1;
				i=0;
				int pre = list.get(i);
				i++;
				if(pre==0) {
					pre = list.get(i);
					i++;
				}
				for (; i < list.size(); i++) {
					for (j = 0; j < map.get(list.get(i)); j++) {
						ans*=(long)map.get(pre);
						if(ans>=MOD)ans%=MOD;
					}
					pre = list.get(i);
				}
			}
		}
		out.println(ans);
	}
}


Measured memory_bytes: 52348
//you**can**do**anything 
#include <bits/stdc++.h> 
#define ll long long
#define read(i) scanf("%lli" , &i)
const ll maxn=1e6; 
using namespace std;
 
int fac(ll n)
{
	if(n==1) return 1;
	
	return fac(n-1) * n; 
}
 
int main()
{



ll n ;
cin>>n;
for(int i=0 ;i<=1000 ;i++)
{
	if(n%1000 == 0)
	{
		cout<<i;
		return 0;
	}
	n++;
}
}

Measured memory_bytes: 3632
import math

K = int(input())
ans = 0
for a in range(1,K-1):
    for b in range(a+1,K):
        for c in range(b+1,K+1):
            r = math.gcd(math.gcd(a,b),c)
            r *= 6
            ans += r
for a in range(1,K):
    for b in range(a+1,K+1):
        r = math.gcd(a,b)
        r *= 6
        ans += r
for a in range(1,K+1):
    ans += a
print(ans)

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int tmp;
int main(){
    cin >> N;
    int a[N];
    int b[5] = {0};
    rep(i, N) cin >> a[i];
    rep(i, N){
        if(a[i] % 4 == 0)
            b[4]++;
        else if(a[i] % 2 == 0)
            b[2]++;
        else
            b[1]++;
    }
    if(b[2] == 0){
        if(b[1] <= b[4] + 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }else{
        if(b[1] <= b[4])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(X: int):
    v = [1]
    for i in range(2, X + 1):
        sq = i
        while True:
            sq *= i
            if X < sq:
                break
            v.append(sq)
    print(sorted(v)[-1])


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N, K = gets.split.map(&:to_i)

mod_k = 0
mod_hk = 0

(1..N).each do |i|
  if i % K == 0
    mod_k +=1
  elsif i % K == K / 2
    mod_hk += 1
  end
end

if K.even?
  puts mod_k ** 3 + mod_hk ** 3
else
  puts mod_k ** 3
end


Measured memory_bytes: 1788
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
constexpr double PI = 3.1415926535897932;

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

#include <iostream>


uint32 G[51][51];
bool r[51];
bool able(const uint32 a, const uint32 b,const uint32 notn) {
	if (a == b)return true;
	r[a] = 1;
	for (uint32 i = 1;i <=50;++i) {
		if (i == notn)continue;
		if (r[G[a][i]])continue;
		if (able(G[a][i], b, notn)) return true;
	}
	return false;
}
int main(void) {
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n), b(n);
	for (auto &x : a)std::cin >> x;
	for (auto &x : b)std::cin >> x;
		bool fff = 0;
		for (uint32 i = 0;i < n;++i) {
			if (a[i]!=b[i]&&a[i] <= b[i]*2) fff= 1;
		}
		if (fff) {
			std::cout << "-1\n";
			return 0;
		}
	std::vector<uint32> use;
	for (uint32 i = 0;i <= 50;++i) {
		for (uint32 j = 1;j <= 50;++j) {
			G[i][j] = i % j;
		}
	}
	for (uint32 i = 50;i;--i) {
		bool f = 0;
		for (uint32 j = 0;j < n;++j) {
			for (auto &x : r)x = 0;
			if (!able(a[j], b[j], i))f = 1;
		}
		if (f)use.push_back(i);
		else {
			for (uint32 j = 0;j <= 50;++j)
				G[j][i] = j;
		}
	}
	uint64 ans = 0;
	for (const auto x : use) {
		ans += (uint64)1 << x;
	}
	std::cout << ans << "\n";
	return 0;
}

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

int main() {
	string A;
	cin >> A;
	ll cur[26];
	for (int i = 0; i < 26; i++) {
		cur[i] = 0;
	}
	ll tot = 0;
	ll ans = 0;
	for (int i = 0; i < A.length(); i++) {
		ans += tot-cur[A[i]-'a'];
		tot ++;
		cur[A[i]-'a']++;
	}
	ans++;
	cout << ans << endl;
	// cin >> A;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define INF (int)1e9+4
#define INFL (ll)1e18+4
#define md (int)1e9+7
#define mx 10000000  //use fixed<<setprecion
#define mk make_pair
#define pi pair<int,int>
#define ss second
#define ff first
#define pb emplace_back
#define onell(x) __builtin_popcountll(x)
#define one(x) __builtin_popcount(x)
#define maxi(a) *max_element(a.begin(),a.end());
#define mini(a) *min_element(a.begin(),a.end());
#define all(s) s.begin(),s.end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, a) for (auto& x: a)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sz(x) ((long long)x.size())
#define mez(s) memset(s,0,sizeof s)
#define mex(s) memset(s,-1,sizeof s)
#define metr(s) memset(s,true, sizeof s)
typedef vector<int> vi;
typedef vector<ll>vl;
typedef map<int,int> mp;
typedef queue<int> que;
typedef vector<pi> vp;
int k;
void solve(){
int n=0,x=0,y=0,z=0,l=0,m=0;
string st;
cin>>st;
n=sz(st);
//cout<<st;
if(st[n-1]=='s'){
     rep(i,0,n)cout<<st[i];
     cout<<"es";
}
else{
//	cout<<"HE";
	rep(i,0,n)cout<<st[i];
	cout<<"s";
}

}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
//  cin>>t; 
  while(t--){
  		solve();
  }
  return 0;
}


Measured memory_bytes: 3660
N,D=map(int,input().split())
F=[tuple(map(int,input().split())) for i in range(N)]

EDGE=[[] for i in range(2*N)]
EDGE_INV=[[] for i in range(2*N)]

# 0～N : X_i
# N+1～2N: Y_i = ￢X_i

for i in range(N):
    x1,y1=F[i]

    for j in range(i,N):
        x2,y2=F[j]

        if abs(x1-x2)<D and i!=j:
            EDGE[i].append(N+j)
            EDGE[j].append(N+i)

            EDGE_INV[N+j].append(i)
            EDGE_INV[N+i].append(j)

        if abs(x1-y2)<D:
            EDGE[i].append(j)
            EDGE[N+j].append(N+i)

            EDGE_INV[j].append(i)
            EDGE_INV[N+i].append(N+j)

        if abs(y1-x2)<D:
            EDGE[N+i].append(N+j)
            EDGE[j].append(i)

            EDGE_INV[N+j].append(N+i)
            EDGE_INV[i].append(j)

        if abs(y1-y2)<D and i!=j:
            EDGE[N+i].append(j)
            EDGE[N+j].append(i)

            EDGE_INV[j].append(N+i)
            EDGE_INV[i].append(N+j)

QUE = list(range(2*N))
check=[0]*(2*N)
TOP_SORT=[]

def dfs(x):
    if check[x]==1:
        return
    check[x]=1
    
    for to in EDGE[x]:
        if check[to]==0:
            dfs(to)

    TOP_SORT.append(x) # 全ての点からDFSを行い, 帰りがけに点を答えに入れる
    check[x]=1

while QUE:
    x=QUE.pop()
    dfs(x)

USE=[0]*(2*N)
SCC=[]

def dfs2(x):
    Q=[x]
    USE[x]=1
    ANS=[]

    while Q:
        x=Q.pop()
        ANS.append(x)
        for to in EDGE_INV[x]:
            if USE[to]==0:
                USE[to]=1
                Q.append(to)
    return ANS

for x in TOP_SORT[::-1]:
    if USE[x]==0:
        SCC.append(dfs2(x))


PLACE=[-1]*(2*N)
for i in range(len(SCC)):
    for x in SCC[i]:
        PLACE[x]=i

ANS=[-1]*N
flag=1
for i in range(N):
    if PLACE[i]==PLACE[N+i]:
        flag=0
        break
    
    elif PLACE[i]>PLACE[N+i]:
        ANS[i]=F[i][0]
    else:
        ANS[i]=F[i][1]
    
if flag==0:
    print("No")
else:
    print("Yes")
    for ans in ANS:
        print(ans)


Measured memory_bytes: 10184
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;
int main(void) {
	string s;
	cin >> s;
	vector<int> n(26,0);
	for (int i = 0; s[i] != '\0'; ++i) {
		n[s[i] - 'a']++;
	}
	REP(i, 26) {
		if (n[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
class Dijkstra():
  class Edge():
    # weighted directed edge
    def __init__(self,_to,_cost):
      self.to=_to
      self.cost=_cost
  def __init__(self,V):
    # 0-indexed
    self.G=[[] for i in range(V)]
    self._E=0
    self._V=V
  def E(self):
    # number of edge
    return self._E
  def V(self):
    # number of vertex
    return self._V
  def add(self, _from, _to, _cost):
    # add vertex and edge cost
    self.G[_from].append(self.Edge(_to, _cost))
    self._E+=1
  def shortest_path(self,s):
    # return the list of shortest pathes from s to each vertex
    import heapq
    que=[]
    d=[float('inf')]*self._V
    d[s]=0
    heapq.heappush(que,(0,s))
    while que:
      cost,v=heapq.heappop(que)
      if d[v]<cost:continue
      for i in range(len(self.G[v])):
        e=self.G[v][i]
        if d[e.to]>d[v]+e.cost:
          d[e.to]=d[v]+e.cost
          heapq.heappush(que,(d[e.to],e.to))
    return d

import sys
input=sys.stdin.readline
xs,ys,xt,yt=map(int,input().split())
n=int(input())
xyr=[list(map(int,input().split())) for i in range(n)]
graph=[[10**9]*(n+2) for i in range(n+2)]
graph[0][n+1]=graph[n+1][0]=((xs-xt)**2+(ys-yt)**2)**0.5
for i in range(1,n+1):
  for j in range(1,n+1):
    d=((xyr[i-1][0]-xyr[j-1][0])**2+(xyr[i-1][1]-xyr[j-1][1])**2)**0.5
    graph[i][j]=graph[j][i]=max(0,d-xyr[i-1][2]-xyr[j-1][2])
for i in range(1,n+1):
  d1=((xs-xyr[i-1][0])**2+(ys-xyr[i-1][1])**2)**0.5
  d2=((xt-xyr[i-1][0])**2+(yt-xyr[i-1][1])**2)**0.5
  graph[0][i]=graph[i][0]=max(0,d1-xyr[i-1][2])
  graph[n+1][i]=graph[i][n+1]=max(0,d2-xyr[i-1][2])
d=Dijkstra(n+2)
for i in range(n+2):
  for j in range(n+2):
    d.add(i,j,graph[i][j])
print(d.shortest_path(0)[n+1])

Measured memory_bytes: 161016
#include"bits/stdc++.h"
using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO;
	int n;
	cin>>n;
	if(n%1000==0) cout<<"0\n";
	else
	{
		int x=n/1000;
		int y=(x+1)*1000;
		cout<<y-n<<nl;
	}
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector <long> H(N+100);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  
  long maxH=0;
  long count=0;
  
  for(int i=0;i<N-1;i++){
    if(H.at(i)>=H.at(i+1)){
      count++;
    }
    else{
      maxH=max(maxH,count);
      count=0;
    }

       }
  
     maxH=max(maxH,count);  
cout <<maxH<<endl;
  return 0;
}

  


Measured memory_bytes: 1024
s = input()
for i in range(2**3):
  a = int(s[0])
  ans = s[0]
  for j in range(3):
    a += ((-1)**((i >> j & 1) == 1))*int(s[j+1])
    ans += "+"*((i >> j & 1) == 0)
    ans += "-"*((i >> j & 1) == 1)
    ans += s[j+1]
  if a == 7:
    print(ans+"=7")
    quit()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>


int main(void) {
	int N, a[100000], b[100001], x;
	int i;
	long long ans;

	scanf("%d %d", &N, &x);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	b[0] = a[0];

	for (i = 0; i < N; i++) {
		b[i + 1] = a[i] + a[i + 1];
	}
	b[N] = a[N - 1];

	ans = 0;

	for (i = 0; i < N+1; i++){
		if (b[i] > x) {
			ans = ans + b[i] - x;
			b[i + 1] = b[i + 1] - (b[i] - x);
		}
	}
	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)



int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int q; cin >> q;
    ll C=0;
    priority_queue<ll> zen;
    priority_queue<ll, vector<ll>, greater<ll>> kou;
    ll zensum=0, kousum=0;

    while(q--){
        int type; cin >> type;
        if(type==1){
            ll a, b; cin >> a >> b; C+=b;
            if(zen.size()>kou.size()){
                ll t=zen.top();
                if(a>=t) kou.push(a), kousum+=a;
                else{
                    zen.pop(); zensum-=t;
                    zen.push(a); zensum+=a;
                    kou.push(t); kousum+=t;
                }
            }
            else{
                if(zen.size()==0) zen.push(a), zensum+=a;
                else{
                    ll t=kou.top();
                    if(a<=t) zen.push(a), zensum+=a;
                    else{
                        kou.pop(); kousum-=t;
                        kou.push(a); kousum+=a;
                        zen.push(t); zensum+=t;
                    }
                }
            }
        }
        else{
            ll x=zen.top();
            cout << x << ' ' << x*(int)zen.size() - zensum + kousum - x*(int)kou.size() + C << endl;
        }
        //cout << zensum << ' ' << kousum << endl;
    }

    return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <math.h>
#include<algorithm>
#include <map>
using namespace std;


int main(int argc,char** argv)
{

	int i;
	int count=0;
	cin >> i;
	for(int n = 1; n <= i; n++){
		if( n==105 || n==135 ||n ==165|| n==189 || n==195){
		count ++;
		}
	}
	cout << count <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m, q;
vector<int> A, B, C, D;

int ans = 0;

void dfs(vector<int> a, int k) {
    if (k==n) {
        // rep(i, n) cout << a[i] <<" ";
        // cout << endl;
        int ret = 0;
        rep(i, q) {
            if (a[B[i]-1]-a[A[i]-1]==C[i]) ret+= D[i];
        }
        ans = max(ans, ret);
    } else {
        FOR(i, a.back(), m+1) {
            vector<int> b = a;
            b.push_back(i);
            dfs(b, k+1);
        }
    }
}

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

    cin >> n >> m >> q;
    A.resize(q); B.resize(q); C.resize(q); D.resize(q);
    rep(i, q) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
    }

    FOR(i, 1, m+1) {
        vector<int> a = {i};
        dfs(a, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    cin >> s;

    if(s == "AAA"  || s == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl; 
    
    
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
ll n,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	if(n==2)
	{
		cout<<1;
		return 0;
	}
	for(ll i=1;i*i<=n-1;i++)
	{
		if((n-1)%i==0)
		{
			ans+=2;
//			cout<<i<<endl<<(n-1)/i<<endl;
		}
		if(i*i==n-1)ans--;
		
	}
	for(ll i=2;i*i<=n;i++)
	{
		ll m=n,x=i;
		if(m%x!=0ll)continue;
		while(m%x==0ll)m/=x;
		if(m%x==1ll)
		{
			ans++;
//			cout<<i<<endl;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;

int main() {
    long long i, n;
    cin >> n;
    string s;
    cin >> s;
    long long ch, ans = 0;
    long long* arr = new long long[n + 10];
    long long* arr1 = new long long[n + 10];
    for (i = 0; i <= n; i++){
        arr[i] = 0;
        arr1[i] = 0;
    }
    long long ans1 = 0, ans2 = 0, ans3;
    for (i = 0; i < n; i++)
        if (s[i] == 'R')
            ans1++;
    for (i = 0; i < ans1; i++)
        if (s[i] == 'W')
            ans2++;
    cout << ans2;
//    for (i = 1; i < n; i++)
//        if (s[i - 1] == 'W')
//            arr[i] = arr[i - 1] + 1;
//        else
//            arr[i] = arr[i - 1];
//    for (i = n - 2; i >= 0; i--)
//        if (s[i + 1] == 'R')
//            arr1[i] = arr1[i + 1] + 1;
//        else
//            arr1[i] = arr1[i + 1];
//    long long maxim = 1e9;
//    for (i = 0; i < n; i++) {
//        maxim = min(maxim, arr[i] + arr1[i]);
//        cout << arr[i] << " " << arr1[i] << " " << i << endl;
//    }
//    cout << maxim;
    return 0;
}

Measured memory_bytes: 6880
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}


Measured memory_bytes: 2560
import Control.Monad
import Data.List

solve = foldl' f (0, 0)
  where
    f (n, c) [a, b] = if a < n then (n, c) else (,) b $! (1 + c)

readN = map read . words <$> getLine

main = do
  [n, m] <- readN
  rs <- replicateM m readN
  print $ snd . solve . sortOn last $ rs


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

int main(){
	// 解説を読んだままやってみている……つもり
	int n,k,c;	cin>>n>>k>>c;
	string s;	cin>>s;
	s=" "+s;
	vector<int> L(k+1);

	int tmp=1;
	for(int i=1;i<=n;i++){
		if(tmp>k)break;
		if(s[i]=='o'){
			L[tmp]=i;	++tmp;
			i+=c;
		}
	}

	vector<int> R(k+1);
	tmp=k;
	for(int i=n; i>=1; i--){
		if(tmp<1)break;
		if(s[i]=='o'){
			R[tmp]=i;	--tmp;
			i-=c;
		}
	}

	//for(int i=1;i<=k;i++)cout<<L[i]<<" ";
	//cout<<endl;
	//for(int i=1;i<=k;i++)cout<<R[i]<<" ";
	//cout<<endl;

	bool flag=false;
	for(int i=1;i<=k;i++){
		if(L[i]==R[i]){
			flag=true;
			cout<<L[i]<<endl;
		}
	}

	if(!flag)cout<<endl;
	return 0;
}


Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
long long int dp[3010][3010];
long long int a[3001];
int n;

long long int solve(int i, int j){
      if(dp[i][j]!=-1)return dp[i][j];
      
      if(i==j)return dp[i][j]=a[i];
      if(i>j)return dp[i][j]=0;
      
      dp[i][j]=max(a[i]-solve(i+1, j), a[j]-solve(i, j-1));
      //cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
      return dp[i][j];
}

int main(){
      cin>>n;
      memset(dp, -1, sizeof(dp));
      for(int i=0; i<n; i++)
            cin>>a[i];
      cout<<solve(0, n-1)<<'\n';
}

Measured memory_bytes: 74636
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;




int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	vector<vector<int>> b(h, vector<int>(w));

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

	for (int i = 0;i < h;i++) {
		for (int j = 0; j < w;j++) {
			cin >> b[i][j];
		}
	}
	vector < vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(80 * (h + w) + 1, false)));
	int d = abs(a[0][0] - b[0][0]);
	dp[0][0][d] = true;
	for (int i = 0;i < h;i++) {
		for (int j = 0; j < w;j++) {
			for (int k = 0;k <= 80 * (h + w);k++) {
				int diff = abs(a[i][j] - b[i][j]);
				if (i > 0 && dp[i - 1][j][k]) {
					dp[i][j][k + diff] = true;
					dp[i][j][abs(k - diff)] = true;
				}
				if (j > 0 && dp[i][j - 1][k]) {
					dp[i][j][k + diff] = true;
					dp[i][j][abs(k - diff)] = true;
				}
			}
		}
	}

	for (int i = 0; i <= 80 * (h + w);i++) {
		if (dp[h - 1][w - 1][i]) {
			cout << i << endl;
			break;
		}
	}
}



Measured memory_bytes: 12800
#include <stdio.h>
int main(void){
    int a, b, c;
    int i, count=0;
    scanf("%d %d %d\n", &a, &b, &c);
    
    for (i = a; i <= b; i++) {
        if (c % i == 0) count++;
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int a, b, c, d;

int main(void){
    
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%s\n", (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a,b;
    cin>>a>>b;
    if(a<b)
    {
    cout<<"<";
    }
    if(a>b)
    {
    cout<<">";
    }
    if(a==b)
    {
    cout<<"=";
    }
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a, b, c, d, e]
k = []
for i in l:
    k.append(i - ((i - 1) //10) * 10)
m = 10 - min(k)
for i in range(5):
    if l[i] % 10 != 0:
        l[i] = (l[i] // 10 + 1) * 10
print(sum(l) - m)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void dfs(ll x,ll y,ll r,ll c,vector<string> &v,vector<vector<ll>> &v1)
{  
	if(x>=r||y>=c||x<0||y<0||v[x][y]=='#'||v1[x][y])
	return;
	v1[x][y]++;
	dfs(x+1,y,r,c,v,v1);
	dfs(x,y+1,r,c,v,v1);
	return;
}
void rdfs(ll x,ll y,ll r,ll c,vector<string> &v,vector<vector<ll>> &v2)
{  
	if(x>=r||y>=c||x<0||y<0||v[x][y]=='#'||v2[x][y])
	return;
	v2[x][y]++;
	rdfs(x-1,y,r,c,v,v2);
	rdfs(x,y-1,r,c,v,v2);
	return;
}
void solve()
{ll t,n,m=-1,k,z,x,y,l=INT_MIN,mini=1000000,maxi=INT_MAX,prev;
    cin>>n;
    vector<ll> a(n),b(n),c(n-1);
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    for(ll i=0;i<n-1;i++)
    cin>>c[i];
    x=0;
    x+=b[a[0]-1];
    for(ll i=1;i<n;i++)
    {
    	x+=b[a[i]-1];
    	if(a[i]-a[i-1]==1)
    	{
    		x+=c[a[i-1]-1];
		}
	}
	cout<<x;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}
/*
ll bfs(ll x)
{
	vector<ll> vis(100001,-1),papa(100001,-1);
	vis[x]=0; queue<ll> q;
	q.push(x);
	//cout<<"ok"<<endl;
	ll len=INT_MAX;
	while(!q.empty())
   { ll y=q.front();
     q.pop();
 	for( auto j:adj[y])
	{
		if(vis[j]==-1)
		{   //cout<<"ok"<<endl;
			vis[j]=vis[y]+1;
			papa[j]=y;
			q.push(j);
		}
		else if(j!=papa[y])
		{   //cout<<"chk"<<endl;
			len=min(len,vis[j]+vis[y]+1);
			break;
		}
	}
   }
   //cout<<len<<endl;
   return len;
}*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n, h; cin >> n >> h;
	long int a[100005], b[100005];
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	sort(a, a+n);
	sort(b, b+n);
	int count = 0;
	long int damage = 0;
	for(int i=n-1;i>=0;i--){
		if(damage<h && a[n-1]<=b[i]){
			damage += b[i];
			count++;
		}
		if(damage>=h){
			cout << count << endl;
			return 0;
		}
	}
	while(damage<h){
		damage += a[n-1];
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1792
def main():
    import sys

    input = sys.stdin.readline

    x, y, z, k = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    B = sorted(map(int, input().split()), reverse=True)
    C = sorted(map(int, input().split()), reverse=True)

    ret = []
    for p, a in enumerate(A):
        for q, b in enumerate(B):
            if p * q > k:
                break
            for r, c in enumerate(C):
                if p * q * r > k:
                    break
                ret.append(a + b + c)
    ret.sort(reverse=True)
    print(*ret[:k], sep='\n')


main()

# O(Klog^3K)
# https://img.atcoder.jp/abc123/editorial.pdf


Measured memory_bytes: 105612
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double mini=1e-10;

struct Sec{
    P p,q;
    Sec(P p,P q):p(p),q(q){}
};

struct Com{
    P p;
    double r;
    Com(P p,double r):p(p),r(r){}
    Com(double x,double y,double r):p(P(x,y)),r(r){}
};

vector<P> crc(Com a,Com b){
    vector<P> res;
    P gra=b.p-a.p;
    double dist=abs(gra);
    if(dist>a.r+b.r+mini)return res;
    if(dist<abs(a.r-b.r)-mini)return res;
    double ca = (a.r*a.r+dist*dist-b.r*b.r) / (2.0*a.r*dist);
    double sa = sqrt(max(0.0,1.0-ca*ca));
    P fs=a.p+gra/dist*a.r*P(ca,sa);
    P sc=a.p+gra/dist*a.r*P(ca,-sa);
    res.push_back(fs);
    res.push_back(sc);
    return res;
}

vector<P> crs(Com a,Sec b){
    vector<P> res;
    P gra=b.q-b.p;
    P v=a.p-b.p;
    P edf=b.p+gra*real(v/gra);
    double h=abs(a.p-edf);
    if(a.r+mini<h)return res;

    double w=sqrt(max(0.0,a.r*a.r-h*h));
    double L=abs(b.p-edf)-w;
    double R=abs(b.p-edf)+w;

    if( -mini<L && L<abs(gra)+mini )
        res.push_back(b.p+gra/abs(gra)*L);
    if( -mini<R && R<abs(gra)+mini )
        res.push_back(b.p+gra/abs(gra)*R);
    return res;
}

int n,w;
int px[10],py[10],h[10];
vector<Com> vec;

double calc(double r,double t){
    if(r<t)return r;
    return sqrt(max(0.0, r*r - (r-t)*(r-t) ));
}
bool check(P p,double r){
    double a=calc(r,w)-mini;
    double b=100-calc(r,w)+mini;
    if(p.real()<a||p.real()>b||p.imag()<a||p.imag()>b)return false;

    for(int i=0;i<n;i++)
    if( abs(p-vec[i].p) < vec[i].r-mini )return false;

    return true;
}
bool check(vector<P> v,double r){
    for(int i=0;i<(int)v.size();i++)  if( check(v[i],r) )return true;
    return false;
}

bool check(double r){

    vec.clear();
    for(int i=0;i<n;i++) vec.push_back( Com( px[i], py[i], calc(r,h[i])));
  
    double a=calc(r,w);
    double b=100-calc(r,w);

    P pa=P(a,a),pb=P(b,a),pc=P(b,b),pd=P(a,b);
    if(check(pa,r)||check(pb,r)||check(pc,r)||check(pd,r))return true;

    for(int i=0;i<n;i++){
        vector<P> tm1=crs(vec[i],Sec(pa,pb));
        vector<P> tm2=crs(vec[i],Sec(pb,pc));
        vector<P> tm3=crs(vec[i],Sec(pc,pd));
        vector<P> tm4=crs(vec[i],Sec(pd,pa));
        if(check(tm1,r)||check(tm2,r)||check(tm3,r)||check(tm4,r))return true;
        for(int j=0;j<i;j++){
            vector<P> tm0=crc(vec[i],vec[j]);
            if(check(tm0,r))return true;
        }
    }
    return false;
}

int main(){
    while(1){
        cin>>n>>w;
        if(n==0&&w==0)break;
        for(int i=0;i<n;i++)cin>>px[i]>>py[i]>>h[i];
        double l=0,r=100000,m;
        for(int i=0;i<100;i++){
            m=(l+r)/2.0;
            if(check(m))l=m;
            else r=m;
        }
        cout<<setprecision(8)<<m<<endl;
    }
    return 0;
}


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

namespace ABC022C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            string ABC = "abcdefghijklmnopqrstuvwxyz";
            string remain = ABC;
            string ans = "";

            for (int i = 0; i < S.Length; i++) remain = remain.Replace(S[i].ToString(), "");

            if (S.Length < 26)
            {
                ans = S + remain[0];
            }
            else if (string.Join("", S.Reverse()) == ABC)
            {
                ans = "-1";
            }
            else
            {
                bool ansflag = false;
                List<char> remain_text = new List<char>();
                for(int i = S.Count() - 1; i >= 1; i--)
                {
                    char now_text = S[i];
                    remain_text.Add(now_text);

                    if (remain_text.Count >= 2)
                    {
                        for (int k = 0; k < remain_text.Count - 1; k++)
                        {
                            for (int j = remain_text.Count - 1; j > k; j--)
                            {
                                if (remain_text[j - 1] > remain_text[j])
                                {
                                    char temp = remain_text[j - 1];
                                    remain_text[j - 1] = remain_text[j];
                                    remain_text[j] = temp;
                                }
                            }
                        }
                    }

                    S = S.Substring(0, i);
                    for(int l = 0; l < remain_text.Count; l++)
                    {
                        if (remain_text[l] > S[i - 1])
                        {
                            ans = S.Substring(0, i - 1) + remain_text[l];

                            ansflag = true;
                            break;
                        }
                    }
                    if (ansflag) break;
                }

                if (ansflag != true) ans = "-1";
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    string n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n.size(); i++) {
        char c = n[i];
        ans += (int)(c - '0');
    }
    if (ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3732
while True:
    try:
        L = input().split()
    except:
        break

    S = []
    for i in L:
        if i not in "+-*/":
            S.append(int(i))
        elif i == "+":
            S.append(S.pop()+S.pop())
        elif i == "-":
            t = S.pop()
            S.append(S.pop()-t)
        elif i == "*":
            S.append(S.pop()*S.pop())
        else:
            t = S.pop()
            S.append(S.pop() / t)
    print("{:.6f}".format(S[0]))



Measured memory_bytes: 5612
S=input()
T=input()

def diff(s,t):
  out=0
  for i in range(len(s)):
    if s[i]!=t[i]:
      out+=1
  return out

ans=10000
for i in range(len(S)-len(T)+1):
  tmp = diff(S[i:i+len(T)], T)
  ans = min(ans,tmp)
  
print(ans)

Measured memory_bytes: 9056
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: isize,
    }
    let mut n = n;
    let mut ans = String::new();
    if n == 0 {
        println!("{}", 0);
        return;
    }
    while n != 0 {
        let s = (n % 2).abs();
        // println!("n={:?} s={}", n, n%2);
        ans.push_str(&s.to_string());
        n = (n - s) / -2;
    }
    println!("{}", ans.chars().rev().collect::<String>());
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line);
			if (n == 0) break;

			int[] nums = new int[n];
			for (int i = 0; i < n; i++) {
				nums[i] = parseInt(br.readLine());
			}
			int find = parseInt(br.readLine()), count = 0;
			int min = 0, max = n - 1, mid = (max - min) / 2 + min;
			while (min <= max) {
				count++;
				if (nums[mid] == find) {
					break;
				} else if (nums[mid] > find) {
					max = mid - 1;
				} else {
					min = mid + 1;
				}
				mid = (max - min) / 2 + min;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 17020
<?php
fscanf(STDIN, "%d", $n);
$arr = [];
for ($i = 0; $i < $n; $i++) {
	$arr[] = (int)fgets(STDIN);
}
$sum = array_sum($arr);
if ($sum % 10) {
	echo $sum, "\n";
	return;
}

sort($arr);
while (count($arr)) {
	$min = array_shift($arr);
	if ($min % 10) {
		echo $sum - $min, "\n";
		return;
	}
}
echo "0\n";


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll x;
    cin>>x;
    rep(i,0,150){
    	for (ll j=-150;j<i;j++){
    		if ((i*i*i*i*i)-(j*j*j*j*j)==x){
    			cout<<i<<" "<<j<<endl;
    			return;
    		}
    	}
    }
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3612
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]): Unit ={
    D.answer()
  }
}

object D{
  def multi(a:Long, b:Long):Long = a * b
  def divide(a: Long, b: Long):Long = a / b
  def remain(a: Long, b: Long):Long = a % b

  def primes(max:Int): List[Int] = {
    (1 to (max / 6).toInt + 1).foldLeft(List(2,3)){(acc,c) => {
      val a = c*6-1
      val b = c*6+1
      val sq = acc.takeWhile(a=> a <= math.sqrt(b).toInt+1)
      val k=if(sq.foldLeft(true){(acc, c) => if(acc && remain(a, c) != 0) true else false}) List(a) else List()
      val v=if(sq.foldLeft(true){(acc, c) => if(acc && remain(b, c) != 0) true else false}) List(b) else List()
      acc++k++v
    }}
  }
  def multiper(n:Int, m:Int, c:Int):(Int, Int) = if(m % n == 0) multiper(n, m/n, c+1) else (c,m)

  def fac(l:List[Int], m:Int): List[Int] = {
    l match {
      case List() => List(1) // math.sqrt(math.pow(10,9).toInt) < math.pow(10,9)の素数が入っていることを想定
      case _ => multiper(l.head, m, 0) match {
        case (0,1) => List()
        case (x,1) => List(x)
        case (0,y) => fac(l.tail, y)
        case (x,y) => List(x) ::: fac(l.tail, y)
      }
    }
  }
  def invmod(p:Long, g:Long) = {
    def euclidean(px:Long, py:Long, pgcd: Long, x:Long, y:Long, gcd: Long):Long = {
      pgcd % gcd match {
        case 0 => (x + g) % g
        case m => {
          val d = pgcd / gcd
          euclidean(x,y,gcd, px-(d*x), py-(d*y), m)
        }
      }
    }
    euclidean(1,0,p,0,1,g)
  }
  def comb(n:Long, k:Long, p:Long):Long = {
    (1 to k.toInt).foldLeft(1.toLong)((acc,c)=> remain((multi(remain(multi(acc,(n-c+1)), p), invmod(c,p))), p))
  }
  def input[A](change: String => A) = readLine.split(" ").map(change(_))
  def answer(): Unit ={
    val p = math.pow(10,9).toLong + 7
    val ps = primes(math.sqrt(math.pow(10,9).toInt).toInt)
    val a = input((a=>a.toInt))
    val n = a(0)
    val m = a(1)
    val f = fac(primes(math.sqrt(p).toInt), m)
    val ans = f.foldLeft(1.toLong)((acc,c)=>(multi(acc, comb(c+n-1, c, p))) % p)
    println(ans)
  }
}

Measured memory_bytes: 106984
#include <iostream>
#include <vector>
#include <cstring>
#include <limits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define	MAX (numeric_limits<int>::max()-1)/2

int dfs(int s, int *v, int *pa, vector<int> *dag){
  if(s<0)return 1;
  rep(i,dag[s].size()){
    if(!v[dag[s][i]]){
      v[dag[s][i]]=1;
      if(dfs(pa[dag[s][i]],v,pa,dag)){
        pa[dag[s][i]]=s;
        return 1;
      }
    }
  }
  return 0;
}

int main(){
  int N,M,L;
  while(cin>>N>>M>>L,N){
    int d[N][N];
    rep(i,N)rep(j,N)d[i][j]=MAX;
    rep(i,N)d[i][i]=0;
    rep(i,M){
      int u,v,w; cin>>u>>v>>w;
      d[u][v]=w;d[v][u]=w;
    }

    int p[L],t[L];
    rep(i,L)cin>>p[i]>>t[i];
    rep(k,N)rep(i,N)rep(j,N)d[i][j]=(d[i][j]>d[i][k]+d[k][j])?(d[i][k]+d[k][j]):d[i][j];

    vector<int> dag[L];
    rep(i,L)rep(j,L){if(i!=j && d[p[i]][p[j]]<=t[j]-t[i])dag[i].push_back(j);}

    int num=L;
    int pa[L]; memset(pa,-1,sizeof(pa));
    rep(i,L){
      int v[L]; memset(v,0,sizeof(v));
      if(dfs(i,v,pa,dag)){num--;}
    }
    cout<<num<<endl;
  }
  return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N, M;
    cin >> N >> M;

    ll K = (N-1)/2;

    vector<pll> res;
    
    ll s = 0, t = K;
    while(t>s){
        res.push_back({s, t});
        t--;
        s++;
    }

    s = K+1,  t = 2*K;
    while(t>s){
        res.push_back({s, t});
        t--;
        s++;
    }

    REP(i, M){
        cout << res[i].first+1 << " " << res[i].second+1 << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
	string s; cin >> s;
	long long k; cin >> k;
	int tmp = 0;
	while (s[tmp] == '1') tmp++;
	if (tmp < k) cout << s[tmp] << endl;
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  vector < int > mountain(10); 
  rep(i,10)
    cin>>mountain[i];
  sort(all(mountain),greater<int>());
  rep(i,3)
    cout<<mountain[i]<<endl;
}

Measured memory_bytes: 1212