akhauriyash/Code-Regression huggingface dataset:
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;++i)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int n,k;cin>>n>>k;
    int ans=0;
    if(k==0)cout<<n*n<<endl;
    else{
        rep(i,k+1,n+1){
            int h=0;
            ans+=n/i*(i-k)+max(n%i-k+1,h);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# 家に帰ったら整理して

=begin

# X Y Z K
# A1...AX
# B1...
# C1...

X, Y, Z, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort.reverse
B = gets.split.map(&:to_i).sort.reverse
C = gets.split.map(&:to_i).sort.reverse
V = Array.new

A.each_with_index do |a, i|
  B.each_with_index do |b, j|
    break if (i + 1) * (j + 1) > K

    C.each_with_index do |c, k|
      break if (i + 1) * (j + 1) * (k + 1) > K

      V << (a + b + c)
    end
  end
end

puts V.sort.reverse[0...K]
=end

# X, Y = gets.split.map(&:to_i)
# ans = 0
# num = X
# while num <= Y
#   ans += 1
#   num *= 2
# end

# p ans

N = gets.to_i

# u -> v , weight = w
# u v w
temp = []
glaph = Array.new(N) { Hash.new }
(N - 1).times do
  u, v, w = gets.split.map(&:to_i)
  glaph[u - 1][v - 1] = w
  glaph[v - 1][u - 1] = w
end

gone = Array.new(N) { true }
ans = Array.new(N)
queue = [0]

ans[0] = true
gone[0] = true

while curr = queue.shift
  glaph[curr].each do |k, v|
    if gone[k]
      gone[k] = false
      ans[k] = (v%2 == 0) ? ans[curr] : !ans[curr]
      queue << k
    end
  end
end

ans.each { |a| puts a ? '1' : '0' }


Measured memory_bytes: 33020
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL ans = 0;

void solve(){
	vector<LL> f(N+1,0);
	for(int i=1;i<=N;i++){
		for(int j=i;j<=N;j+=i) f[j]++;
	}
	for(int i=0;i<=N;i++) ans += i*f[i];
}

int main(){
	cin >> N;

    solve();

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

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

const int MAX_M=101;

int N,M,d,v,ans;
vector<int> vs(MAX_M);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> M,N){
        for (int i=0;i<M;++i) vs[i]=0;
        for (int i=0;i<N;++i){
            cin >> d >> v; --d;
            vs[d]=max(vs[d],v);
        }
        ans=0;
        for (int i=0;i<M;++i) ans+=vs[i];
        cout << ans << '\n';
    }
}


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

template<class T> T comb(T n, T r) {
    if (r * 2 > n) r = n - r;
    T dividend = 1;
    T divisor = 1;
    for (T i = 1; i <= r; i++ ) {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

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

    int n;
    cin >> n;

    vector<string> s(n);
    REP(i, n) cin >> s[i];
    REP(i, n) sort(s[i].begin(), s[i].end());
    sort(s.begin(), s.end());

    ll ans = 0;
    ll count = 0;
    vector<ll> num;
    REP(i, n - 1) {
        if (s[i] == s[i + 1]) count++;
        else {
            num.push_back(count);
            count = 0;
        }
    }

    if (count != 0) num.push_back(count);

    REP(i, num.size())
        if (num[i] != 0) ans += comb(num[i] + 1, (ll)2);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6908
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

bool binarySearch(vector<int> &a, int n, int k) {
	int ng = 0;
	int ok = n;
	
	while( ok > ng ) {
		int mid = (ok + ng) / 2;
	
		if( a[mid] == k ) return true;
		
		if( a[mid] < k ) {
			ng = mid + 1;
		} else if( a[mid] > k ) {
			ok = mid;
		}			
	}
	
	return false;
}

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

	vector<int> s(n);
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	
	sort(s.begin(), s.end());
	
	int q;
	cin >> q;
	
	int ans = 0;
	for(int i = 0; i < q; ++i) {
		int t;
		cin >> t;
		
		if( binarySearch(s, n, t) ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3124
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a + L[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b + L[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c + L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)
    
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

ll zeroer(ll x) {
    if(x<=0) return 0;
    else return x;
}

int main(void) {
    ll n, k;
    cin >> n >> k;
    ll j;
    ll ans=0;
    
    for(j=k+1; j<=n; j++) {
        ans+=n/j*(j-k)+zeroer(n%j-zeroer(k-1));
    }
    
    
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,'%d%d',$N,$M);
$A=[];
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  $A[$i]=0;
}
for ($i=0; $i <=$M-1 ; $i++) {
  // code...
  fscanf(STDIN,'%d%d',$P,$Q);
  $A[$P-1]++;
  $A[$Q-1]++;
}
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  echo $A[$i];
  echo "\n";
}

 ?>

Measured memory_bytes: 3576
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int N;

	cin >> N ;
	
	int a = 10000 - N;

	while (a>=1000) {
		a -= 1000;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 3624
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let _ = readInt()!
let S = readLine()!

var redCount = 0
var blueCount = 0
for c in S.characters {
    switch c {
    case "R":
        redCount += 1
    case "B":
        blueCount += 1
    default:
      	break
    }
}

print((redCount > blueCount) ? "Yes" : "No")

Measured memory_bytes: 7012
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
using namespace std;
int n;
list<int>a;
vector<int>ans;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;a.push_back(x);
	}
	for(int ccc=0;ccc<n;ccc++)
	{
		list<int>::iterator id,it=a.begin();
		bool flag=0;
		for(int i=0;it!=a.end();it++)
		{
			i++;
			if(*it==i)
			{
				id=it;
				flag=1;
			}
		}
		if(!flag)
		{
			cout<<-1<<endl;
			return 0;
		}
		ans.push_back(*id);
		a.erase(id);
	}
	for(int i=n;i--;)cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

void p(const vector<int> &v)
{
    for (size_t i = 0; i < v.size() - 1; ++i) {
        printf("%d ", v[i]);
    }
    printf("%d\n", v[v.size() - 1]);
}

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> v;
    int t;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &t);
        v.push_back(t);
    }
    int c = 0;
    for (size_t i = 0; i < v.size(); ++i) {
        int mini = i;
        for (size_t j = i; j < v.size(); ++j) {
            if (v[j] < v[mini]) {
                mini = j;
            }
        }
        if (static_cast<int>(i) != mini) {
            int tmp = v[i];
            v[i] = v[mini];
            v[mini] = tmp;
            ++c;
        }
    }
    p(v);
    printf("%d\n", c);
}

Measured memory_bytes: 2768
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    long n, p;
    scan(n, p);

    long ans = 1;

    for (long i = 2; i*i <= p; i++) {
        int cnt;

        while (p % i == 0) {
            p /= i;
            cnt++;
        }

        ans *= i^^(cnt / n);
    }

    if (n == 1 && p > 1) {
        ans *= p;
    }

    writeln(ans);
}










void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

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

    sort(x_sorted, x_sorted+n);

    set<int> s_smaller, s_larger;
    for(int i=0; i<n/2; i++){
        s_smaller.insert(x_sorted[i]);
    }
    for(int i=n/2; i<n; i++){
        s_larger.insert(x_sorted[i]);
    }

    for(int i=0; i<n; i++){
        if(s_smaller.find(x[i]) != s_smaller.end()){
            cout << x_sorted[n/2] << endl;
        }
        else{
            cout << x_sorted[n/2 - 1] << endl;
        }
    }


    return 0;
}

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

int main()
{
	string X;
	cin >> X;
	int ans =1000000;//ansに大きな数を入れる//

	for (int i = 0; i <= X.size()-3; i++) {//Xの長さよりも３回少なくループする。iは０から始まり１ずつふえる//

		int MIN = min(ans, abs(753 - stoi(X.substr(i, 3))));
		//ansとXから抜き出したiから三番目までの数を比べ、小さいほうをint MINに代入する。//
		//初回は大きな数と比べるため必ず抜き出した数がint MINに代入される//
		ans = abs(MIN);
		//int MINを絶対値にしてansに代入し、ループする//
	}
	//上のfor文で最も小さいansを出力する//
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            long h = long.Parse(Console.ReadLine());
            var count = 0;
            var temp = h;
            while(temp > 1)
            {
                temp /= 2;
                count++;
            }
            count++;
            Console.WriteLine(Math.Pow(2,count) - 1);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
int N , M ;
cin >> N >> M  ;
double out = 0 ;
int count = 0  ;
double ans = (double)1/N ;
//printf("%.12f\n",ans);  
for( int i = 1 ; i < N+1 ; i++ ){
  //double ans = 1/N;
  int k = i ;
  while(k<M){
    count++ ;
    k = k*2 ;
  }
  //cout << count << endl ;
  rep(i,count) ans = ans/2.0 ;
  //printf("%.12f\n",ans);
  out += ans ;
  ans = (double)1/N ;
  count = 0 ;
}
  printf("%.12f\n",out);
}   

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif
	int N;
	int kazu[100001] = { 0 };
	int tmp;
	int ans = 0;
	int ansTmp;

	scanf("%d", &N);

	int i;
	for (i = 0; i < N; i++) {
		scanf("%d", &tmp);
		kazu[tmp]++;
	}
	for (i = 0; i < 99999; i++) {
		ansTmp = kazu[i] + kazu[i + 1] + kazu[i + 2];
		if (ansTmp > ans) {
			ans = ansTmp;
		}
	}
	printf("%d\n", ans);
}

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

int main(){
  long long x, k, d;
  cin >> x >> k >> d;
  if(x<0){
    x *= -1;
  }
  long long pre = x/d;
  if(k > pre){
    if(min(x - d*pre,-x + d*(pre+1))==x - d*pre){
      if((k-pre)%2==0){
        cout << x - d*pre << endl ;
      } else {
        cout << -x + d*(pre+1) << endl ;
      }
    } else {
      if((k-(pre+1))%2==0){
        cout << -x + d*(pre+1) << endl ;
      } else {
        cout << x - d*pre << endl ;
      }
    }
  } else {
    //cout << min(x - d*pre,-x + d*(pre+1)) << endl ;
    cout << x - d*k << endl ;
  }
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
using namespace std;
const int INF=INT_MAX/2;

struct edge { int to, weight;};
typedef vector<edge> Edges;
typedef vector<Edges> Graph;

int  DP[1 << 15][15];

int rec(int S, int v, int V, Graph &G){
	if(DP[S][v]>=0){
		return DP[S][v];
	}
	if (S==(1 << V)-1 && v==0) 
	{
		return DP[S][v]=0;
	}

	int r = INF;
	for(int i=0;i<G[v].size();i++){
		edge f = G[v][i];
		if((S >> f.to)%2==0){
			r=min(r,rec((S | (1 << f.to)) ,f.to,V,G)+f.weight);
		}
	}
	return DP[S][v]=r;
}

int main(){
	int V,E,d,s;
	edge e;
	cin >> V >> E ;

	Graph G(V);
	for (int i=0;i<E;i++){
		cin >> s >> e.to >> e.weight;
		G[s].push_back(e);
	}

	memset(DP,-1,sizeof(DP));
	int result =rec(0,0,V,G) ;
	if(result>=INF){
		cout << -1<< endl;
	}else{
		cout << result <<endl;
	}

	return 0 ;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  ll a, b;
  cin >> a >> b;
  if((a < 0 && b > 0 ) || a == 0 || b == 0) {
    cout << "Zero" << endl;
  } else if(a > 0){
    cout << "Positive" << endl;
  } else if((b-a+1)%2 == 1) {
    cout << "Negative" << endl;
  } else if((b-a+1)%2 == 0) {
    cout << "Positive" << endl;
  } else {
    assert(false);
  }

  return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap.Strict    as M
import           Data.List             (sort)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, k] <- readInts
  as <- readInts
  print $ solve n k as

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> Int -> [Int] -> Int
solve n k as = sum $ take (l - k) cs where
  cs = sort hist
  hist = M.elems $ M.fromListWith (+) [(i, 1) | i <- as]
  l = length cs


Measured memory_bytes: 36220
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
	int n = s.nextInt();
	String a,b;

	for(int i = 0;i < n;i++) {
	a = s.next();
	b = s.next();
	int[][] c = new int[a.length()+1][b.length()+1];
	for(int j = 1;j <= a.length();j++) {
		for(int k = 1;k <= b.length();k++) {
			if(a.charAt(j-1) == b.charAt(k-1)) {
				c[j][k] = c[j-1][k-1] + 1;
			}else {
				c[j][k] = Math.max(c[j-1][k], c[j][k-1]);
			}
		}
	}
	System.out.println(c[a.length()][b.length()]);
	}
}
}



Measured memory_bytes: 63844
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(s <= w ? "unsafe" : "safe");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

int	main() {
	long N, K;
	cin >>N >>K;
	if (N<=K) {
		cout <<0 <<endl;
		return 0;
	}
	vector<long> H(N, 0);
	for (long i=0; i<N; i++)
		cin >>H.at(i);
	sort(H.begin(), H.end());
	long S=0;
	N -=K;
	for (long i=0; i<N; i++)
		S +=H.at(i);
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 1792
n, m = map(int, input().split())
list_data = [ list(map(int,input().split(" "))) for i in range(m)]
list_condition = list(map(int, input().split()))

for i in range(m):
    a = list_data[i]
    a.pop(0)

ans = 0

for i in range(2**n):
    list_ans = [0] * m
    for l in range(m):
        for j in range(n):
            if ((i >> j) & 1):
                if j+1 in list_data[l]:
                    list_ans[l] += 1
    a = list(map(lambda x:x % 2, list_ans))
    if a == list_condition:
        ans += 1

print(ans)


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> l(n);
  for (int i = 0; i < n; i++) cin >> l.at(i);
  
  sort(l.begin(), l.end());
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (l[i] + l[j] > l[k]) {
          if (l[i] != l[j] && l[j] != l[k]) {
            ans++;
          }
        }
      }
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int x;
  cin >> x;
  
  int i = 0;
  long long int m = 100;
  while (m < x){
    m += m / 100;
    i++;
  }
  
  cout << i << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N,X;
	cin >> N >> X;
	vector<ll> L(N);
	FOR(i,0,N)cin >> L[i];
	ll ans = 1;
	FOR(i,0,N){
		X -= L[i];
		if(X>=0)ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222




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


  cin >> n;
  queue<pll> q;
  q.push(make_pair(0,0));
  ll a[3] = { 3,5,7 };
  while (!q.empty()) {
    pll p = q.front();
    q.pop();
    if (p.first > n) continue;
    if (p.second == 7) ans++;
    rep(i, 3) {
      q.push(make_pair(p.first * 10 + a[i], p.second | (1 << i)));
    }
  }
  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+233;

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


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <vector>
using namespace std;
 
 int n, W;
 int weight[110], value[110];
 int dp[1000][5500];

int main() {
  int n,k;
  cin >> n >>k;
  if(n%k==0){
      cout << 0 << endl;
  }else{
      cout << 1 <<endl;
  }
}

Measured memory_bytes: 256
import bisect


def f(a: list, n: int) -> list:
    i = bisect.bisect(a, 0)
    return a[min(i, n):]


assert f([1, 2, 3], 1) == [1, 2, 3]
assert f([-1, 2, 3], 1) == [2, 3]
assert f([-2, -1, 3], 1) == [-1, 3]
assert f([-2, 0, 3], 1) == [0, 3]
assert f([-2, -1, 3], 3) == [3]
assert f([-2, -1, 3], 0) == [-2, -1, 3]
assert f([], 0) == []


def main():
    # pass
    N, K = map(int, input().split())
    V = [int(x) for x in input().split()]
    Vr = list(reversed(V))

    ans = -float("inf")
    for l in range(0, max(N, K)+1):
        for r in range(0, max(N, K)+1):
            n = max(0, K - r - l)  # 戻すことができる最大の回数

            if N < l + r or K < l + r:
                continue

            # l, r個ずつ取り出す
            a1 = V[:l]
            a2 = Vr[:r]
            a = a1 + a2
            a = sorted(a)

            score = sum(f(a, n))
            ans = max(ans, score)

            # print(f"{l} {r} {n} {a1}+{a2}={a}")
            # # print(i, a[:i], b)
            # print(f"score={score}")

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,k;
int r,s,p;
string arr;
int dp[100005][3];
int cost[3];

int score(char ch,int num){
	if(ch=='r'){
		if(num<=1) return 0;
		return p;
	}
	else if(ch=='s'){
		if(num==0) return r;
		return 0;
	}
	else{
		if(num==1) return s;
		return 0;
	}
}
int f(int curr,int shape){
	if(curr>=n) return 0;
	int&ret = dp[curr][shape];
	if(~ret) return ret;
	ret = 0;
	for(int i=0; i<3; i++){
		if(i!=shape){
			ret = max(ret,f(curr+k,i));
		}
	}
	return ret+=score(arr[curr],shape);
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	cin>>r>>s>>p;
	cost[0] = r;
	cost[1] = s;
	cost[2] = p;
	cin>>arr;
	int ret = 0;
	for(int i=0; i<k; i++){
		int mx = 0;
		for(int j=0; j<3; j++) mx = max(mx,f(i,j));
		ret+=mx;
	}
	cout<<ret;
}

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

using namespace std;
using ll = long long;

constexpr ll MOD = 1e9 + 7;
int mx[] = {-1, 1, 0, 0}, my[] = {0, 0, -1, 1};

template <class Data>
vector<Data> slide_queries(auto f, const vector<Data> &v, int k)
{
	deque<int> deq;
	vector<Data> ret;
	for (int i = 0; i < (int)v.size(); ++i)
	{
		while (!deq.empty() && f(v[deq.back()], v[i]))
		{
			deq.pop_back();
		}
		deq.push_back(i);
		if (i - k + 1 >= 0)
		{
			ret.emplace_back(v[deq.front()]);
			if (deq.front() == i - k + 1)
				deq.pop_front();
		}
	}
	return ret;
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> p(n), a(n, 1);
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
		if (i)
		{
			if (p[i - 1] <= p[i])
				a[i] = a[i - 1] + 1;
		}
		if (a[i] >= k)
			cnt++;
	}
	if (cnt)
		cnt--;
	auto RmQ = slide_queries(greater<int>(), p, k + 1);
	auto RMQ = slide_queries(less<int>(), p, k + 1);
	int ans = n - k + 1;
	for (int i = 0; i < n - k; ++i)
	{
		if (a[i + k] > k)
			continue;
		if (p[i] == RmQ[i] && p[i + k] == RMQ[i])
			ans--;
	}
	cout << ans - cnt << endl;
}

Measured memory_bytes: 4088
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(void) {
	vector<int> a(3), b(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> b[i];
	}
	int town_01 = 0, town_02 = 0, town_03 = 0, town_04 = 0;
	for (int i = 0; i < 3; i++) {
		if (a[i] == 1) {
			town_01++;
		}
		else if (a[i] == 2) {
			town_02++;
		}
		else if (a[i] == 3) {
			town_03++;
		}
		else if (a[i] == 4) {
			town_04++;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (b[i] == 1) {
			town_01++;
		}
		else if (b[i] == 2) {
			town_02++;
		}
		else if (b[i] == 3) {
			town_03++;
		}
		else if (b[i] == 4) {
			town_04++;
		}
	}
	//cout << town_01 << " " << town_02 << " " << town_03 << " " << town_04 << endl;
	if ((town_01 == 1 && town_02 == 1 && town_03 == 2 && town_04 == 2) || (town_01 == 1 && town_02 == 2 && town_03 == 1 && town_04 == 2) || (town_01 == 1 && town_02 == 2 && town_03 == 2 && town_04 == 1) || (town_01 == 2 && town_02 == 1 && town_03 == 1 && town_04 == 2) || (town_01 == 2 && town_02 == 1 && town_03 == 2 && town_04 == 1) || (town_01 == 2 && town_02 == 2 && town_03 == 1 && town_04 == 1)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

#define LL unsigned long long int
#define SZ 110
#define LCM30 2329089562800

int main()
{
    string s;
    int i, n, c=0;

    cin >> n >> s;
    for(i=0; i<=n-3; i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            c++;
    }

    cout << c;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N; cin >> N;
    set<int> se;
    rep(i, N){
        int a;
        cin >> a;
        se.insert(a);
    }
    if (se.size() == N){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 12968
#include<iostream>

using namespace std;

int main(){

  int data[15][15], x, y, size, sum = 0, max = 0;
  char trash[2];


  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      data[i][j] = 0;
    }
  }


  while(cin >> x >> trash[0] >> y >> trash[1] >> size){

    if(size == 1){

      data[x][y]++;
      data[x][y-1]++;
      data[x-1][y]++;
      data[x+1][y]++;
      data[x][y+1]++;

    }else if(size == 2){

      data[x][y]++;
      data[x][y-1]++;
      data[x-1][y]++;
      data[x+1][y]++;
      data[x][y+1]++;
      data[x-1][y-1]++;
      data[x+1][y-1]++;
      data[x-1][y+1]++;
      data[x+1][y+1]++;

    }else{

      data[x][y]++;
      data[x][y-1]++;
      data[x-1][y]++;
      data[x+1][y]++;
      data[x][y+1]++;
      data[x-1][y-1]++;
      data[x+1][y-1]++;
      data[x-1][y+1]++;
      data[x+1][y+1]++;
      data[x-2][y]++;
      data[x+2][y]++;
      data[x][y+2]++;
      data[x][y-2]++;

      
 
    }
  }


  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      if(data[i][j] == 0){
	sum++;
      }
      if(data[i][j] > max){
	max = data[i][j];
      }
    }
  }

  cout << sum << endl << max << endl;

  return 0;

}

Measured memory_bytes: 0
use std::io::stdin;
use std::io::Error;
use std::io::Read;

#[derive(Debug)]
struct Input {
    n: u32,
    k: u32,
    s: String,
}

fn handle_input(input_str: String) -> Result<Input, Error> {
    let mut iter = input_str.split_whitespace();
    let n: u32 = iter.next().unwrap().parse().unwrap();
    let k: u32 = iter.next().unwrap().parse().unwrap();
    let s = iter.next().unwrap();
    let input = Input {
        n: n,
        k: k,
        s: s.to_string(),
    };
    Ok(input)
}

fn handle_output(input: Input) -> Result<String, Error> {
    let mut iter = input.s.chars();
    let mut ret = String::new();
    for i in 0..input.s.len() {
        let c = iter.next().unwrap();
        if i == (input.k as usize - 1) {
            match c {
                'A' => ret.push('a'),
                'B' => ret.push('b'),
                'C' => ret.push('c'),
                _ => ret.push(' '),
            }
        } else {
            ret.push(c);
        }
    }
    Ok(ret)
}

fn main() {
    let mut input_str = String::new();
    stdin().read_to_string(&mut input_str).unwrap();
    let input = handle_input(input_str).unwrap();
    let output = handle_output(input).unwrap();
    println!("{}", output);
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <algorithm>

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

using namespace std;

int main(){
	long long int n,z,w,aN_1,aN;
	cin >> n >> z >> w;
	REP(i,n-1) cin >> aN_1;
	cin >> aN;
	if (n<2) aN_1 = aN;
	long long int ans;
	ans = max(abs(aN_1-aN),abs(aN-w));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
typedef long long int ll;

int main() {
	// your code goes here
    ll n,j,temp;
    cin>>n;
    ll a;
    ll b[(ll)pow(n,0.5)];
    ll k=0;
    for(a=1;a<=pow(n,0.5);a++){
        if(n%a==0){
            b[k++]=(a-1)+((n/a)-1);
            
        }
        
    }
    ll min=b[0];
    for(a=1;a<k;a++){
        if(b[a]<min){
            min=b[a];
        }
    }
    cout<<min<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string N;
    cin >> N;
    string ans = "hon";
    if (N[N.size() - 1] == '3') ans = "bon";
    if
        (N[N.size() - 1] == '0' ||
        N[N.size() - 1] == '1' ||
        N[N.size() - 1] == '6' ||
        N[N.size() - 1] == '8') 
            ans = "pon";

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

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int min(int a,int b){
	return a>b?b:a;
}
int abs(int a){
	return a>0?a:-a;
}
ll gcd(ll a,ll b){
	if(b==0){
		return a;
	}
	else if(a>b){
		return gcd(b,a%b);
	}
	else {
		return gcd(a,b%a);
	}
}
int main(){
	ll a,b,c,d,i,j,lcm;
	cin>>a>>b>>c>>d;
	ll ans=b-a+1;
	if(a%c==0||a%d==0){
		ans--;
	}
	//if(b%c==0||b%d==0){
	//	ans--;
	//}
	//cout<<((b/c))-(a/c)<<"\n";
	//cout<<((b/d))-(a/d)<<"\n";
	lcm = (c/gcd(c,d))*d;
	//cout<<((b/lcm))-(a/lcm)<<"\n";
	ans -= ((b/c))-(a/c);
	ans -= ((b/d))-(a/d);
	lcm = (c/gcd(c,d))*d;
	ans+=((b/lcm))-(a/lcm);
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
vector<ld> xl;
vector<ld> yl;
int N;
ld distance(ld x,ld y){
    ld max_dis=0;
    rep(i,N){
        max_dis=max(max_dis,sqrtl(powl(xl[i]-x,2)+powl(yl[i]-y,2)));


    }
    return max_dis;

}
//x方向で偏微分最小点
ld x_min_dist(ld y){
    ld xl=0,xr=1000;
    rep(i,60){
        if(distance((2*xl+xr)/3,y)<distance((xl+xr*2)/3,y)){
            xr=(xl+xr*2)/3;
        }
        else{
            xl=(2*xl+xr)/3;
        }

    }
    return distance(xl,y);
}

int main(){
cin>>N;
rep(i,N){
    ld x,y;
    cin>>x>>y;
    xl.push_back(x);
    yl.push_back(y);
}
ld yl=0,yr=1000;
rep(i,60){
    if(x_min_dist((2*yl+yr)/3)<x_min_dist((yl+yr*2)/3)){
        yr=(yl+yr*2)/3;
    }
    else{
        yl=(2*yl+yr)/3;
    }
}


cout(10)<<x_min_dist(yl)<<endl;
return 0;
}

Measured memory_bytes: 3820
def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()

    string = ''
    ans = 0
    for i, ti in enumerate(t):
        if i < k:
            if ti == 'r':
                ans += p
            elif ti == 's':
                ans += r
            else:
                ans += s
            string += ti
        else:
            if ti == string[i-k]:
                string += 'e'
            else:
                if ti == 'r':
                    ans += p
                elif ti == 's':
                    ans += r
                elif ti == 'p':
                    ans += s
                string += ti
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  int N; cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++)
    cin>>p[i];
  vector<int> sum(N);
  for(int i=0;i<N;i++)
    sum[p[i]-1] = 1e9 + i;
  vector<ll> a(N);
  for(int i=0;i<N;i++)
    a[i] = 30000 * (i+1);
  vector<ll> b(N);
  for(int i=0;i<N;i++)
    b[i] = sum[i] - a[i];
  for(int i=0;i<N;i++)
    cout<<a[i]<<" ";
  cout<<endl;
  for(int i=0;i<N;i++)
    cout<<b[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int h[] = new int[n];
            for (int i = 0; i < n; i++) {
                h[i] = Integer.parseInt(in.next());
            }
            // 最初の旅館は必ず見えるので1
            int ans = 1;

            for (int i = 1; i < n; i++) {
                int cnt = 0;
                for (int j = 0; j <= i - 1; j++) {
                    if (h[i] >= h[j]) ++cnt;
                }
                if (cnt >= i) ans++;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

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

  vector<int16_t> X, Y;
  X.reserve(N);
  Y.reserve(N);

  for (int n=0; n<N; ++n) {
    int16_t x, y;
    cin >> x >> y;
    X.push_back(x);
    Y.push_back(y);
  }

  double sum = 0;
  
  for (int ii=0; ii<N-1; ++ii) {
    for (int jj=ii; jj<N; ++jj) {
      int32_t xdiff = X[ii] - X[jj];
      int32_t ydiff = Y[ii] - Y[jj];
      sum += sqrt(xdiff*xdiff + ydiff*ydiff);
    }
  }

  cout << setprecision(15) << sum/N*2 << endl;

  return 0;
}


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

string pattern[] = {"remaerd", "resare", "maerd", "esare"};

string solve(const string& s) {
    int cur = 0;
    while(cur < s.size()) {
        bool ok = false;
        for(auto p : pattern) {
            string t = s.substr(cur, p.size());
            if(t == p) {
                ok = true;
                cur += p.size();
                break;
            }
        }
        if(!ok) return "NO";
    }
    return "YES";
}

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    cout << solve(s) << endl;
}


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

int partition(long a[],long b[],int l,int r);
int quicksort(long a[],long b[],int l,int r);

int main(void){
  int N,i;
  long a[200005],b[200005],time;
  char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  for(i=0;i<N;i++){
    fgets(str,sizeof(str),stdin);
    p=strtok(str," \n");
    a[i]=atol(p);
    p=strtok(NULL," \n");
    b[i]=atol(p);
  }
  
  
  quicksort(b,a,0,N-1);
  
  
  for(i=0,time=0;i<N;i++){
    time+=a[i];
    if(time>b[i]){
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  
  
  return 0;
}


int partition(long a[],long b[],int l,int r){
    int i,j,bbuff;
    long abuff,pivot;
    
    i=l-1,j=r;
    pivot=a[r];
    for(;;){
        while(a[++i]<pivot);
        
        while(i<=--j && a[j]>=pivot);
        
        if(i>=j){
            abuff=a[r],a[r]=a[i],a[i]=abuff;
            bbuff=b[r],b[r]=b[i],b[i]=bbuff;
            break;
        }
        
        abuff=a[i],a[i]=a[j],a[j]=abuff;
        bbuff=b[i],b[i]=b[j],b[j]=bbuff;
        
    }
    
    return i;
}

int quicksort(long a[],long b[],int l,int r){
    int v;
    
    if(l>=r){
        return 0;
    }
    
    v=partition(a,b,l,r);
    
    quicksort(a,b,l,v-1);
    quicksort(a,b,v+1,r);
    
    return 0;
    
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(N);
  for (int i = 0; i < N; i++){
    cin >> X[i];
  }
  vector<map<int, int>> mp(M);
  for (int i = 0; i < N; i++){
    mp[X[i] % M][X[i]]++;
  }
  int ans = 0;
  for (int i = 0; i <= M / 2; i++){
    if (i == 0 || i * 2 == M){
      int tmp = 0;
      for (auto P : mp[i]){
        tmp += P.second;
      }
      ans += tmp / 2;
    } else {
      int sum1 = 0;
      for (auto P : mp[i]){
        sum1 += P.second;
      }
      int sum2 = 0;
      for (auto P : mp[M - i]){
        sum2 += P.second;
      }
      ans += min(sum1, sum2);
      int d = abs(sum1 - sum2);
      vector<int> val;
      if (sum1 > sum2){
        for (auto P : mp[i]){
          val.push_back(P.second);
        }
      } else {
        for (auto P : mp[M - i]){
          val.push_back(P.second);
        }
      }
      int sum = max(sum1, sum2);
      int cnt = val.size();
      int odd_cnt = 0;
      for (int i = 0; i < cnt; i++){
        if (val[i] % 2 == 1){
          odd_cnt++;
        }
      }
      if (odd_cnt < min(sum1, sum2)){
        ans += d / 2;
      } else {
        for (int j = 0; j < cnt; j++){
          ans += val[j] / 2;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13000
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    A, B, C = map(int, input().split())

    answer = B + C - A

    if answer < 0:
        answer = 0

    print(answer)
    
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 4212
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}


constexpr int contest_num {26};
constexpr int order_max_cnt {25000}; // TODO : changeble

ll calc_satisfy(const vector<vector<ll>>& S, const vector<ll>& C, const vector<int>& order, const int& D) {
  ll answer {};
  vector<int> fin_day(contest_num, -1);
  rep(i, D) {
    answer += S[i][order[i]-1];
    fin_day[order[i]-1] = i;
    rep(j, contest_num) {
      answer -= C[j]*(i-fin_day[j]);
    }
  }
  return answer;
}

#include <random>

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

  int D;
  cin >> D;
  vector<ll> c(contest_num);
  rep(i, contest_num) cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(contest_num));
  rep(i, D) {
    rep(j, contest_num) {
      cin >> s[i][j];
    }
  }
  //vector<int> order(D);
  //rep(i, D) cin >> order[i];
  //int M;
  //cin >> M;
  //vector<std::pair<int, int>> query(M);
  //rep(i, M) cin >> query[i].first >> query[i].second;
  //rep(i, M) {
  //  order[query[i].first-1] = query[i].second;
  //  calc_satisfy(s, c, order, D);
  //}
  std::random_device rnd;

  ll max_params {-LLINF};
  vector<int> max_order(D);
  rep(i, contest_num) {
    vector<int> order(D, i+1);
    ll tmp = calc_satisfy(s, c, order, D);
    if (max_params < tmp) {
      max_order = order;
    }
  }
  rep(i, order_max_cnt) {
    vector<int> order(D);
    rep(j, D) {
      order[j] = (rnd() % contest_num) +1;
    }
    ll tmp = calc_satisfy(s, c, order, D);
    if (max_params < tmp) {
      max_order = order;
    }
  }
  rep(i, D) cout << max_order[i] << '\n';
}


Measured memory_bytes: 3668