akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n;
  cin >> n;
  ll a[n];
  REP(i, n) cin >> a[i];

  ll s[n + 1];
  s[0] = 0;

  ll cp = 0, cm = 0;

  REP(i, n){
    if(i % 2 == 0){
      if(s[i] + a[i] <= 0){
        cp += 1 - (s[i] + a[i]);
        s[i + 1] = 1;
      }
      else s[i + 1] = s[i] + a[i];
    }
    else{
      if(s[i] + a[i] >= 0){
        cp += 1 + (s[i] + a[i]);
        s[i + 1] = - 1;
      }
      else s[i + 1] = s[i] + a[i];
    }
  }

  REP(i, n){
    if(i % 2){
      if(s[i] + a[i] <= 0){
        cm += 1 - (s[i] + a[i]);
        s[i + 1] = 1;
      }
      else s[i + 1] = s[i] + a[i];
    }
    else{
      if(s[i] + a[i] >= 0){
        cm += 1 + (s[i] + a[i]);
        s[i + 1] = - 1;
      }
      else s[i + 1] = s[i] + a[i];
    }
  }

  cout << min(cp, cm) << endl;
  return 0;
}


Measured memory_bytes: 1792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
plus = []
minus = []
for _ in range(n):
    s = S()
    ret = 0
    ret2 = 0
    for i in s:
        if ret and i == ')':
            ret -= 1
        elif i == '(':
            ret += 1
        else:
            ret2 += 1
    if ret2 > ret:
        plus += [(ret, ret2)]
    else:
        minus += [(ret, ret2)]


plus.sort()
minus.sort(key=lambda x:x[1], reverse=True)
L = plus + minus

now = 0
for x, y in L:
    if x > now:
        print("No")
        exit()
    now = now - x + y

if now:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 206968
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N;
}
void solve() {
  // Nを2数の席に分割

  int k = 0;
  for (int i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      k = i;
    }
  }
  int p = N / k;
  cout << k + p - 2 << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
	int n;
	string sgmt[10] = {
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111"
	};

	while (cin >> n) {
		if (n == -1)break;
		string s = "0000000";

		for (int x = 0;x < n;x++) {
			int a;
			cin >> a;

			string ans;

			for (int i = 0;i < 7;i++) {
				if (s[i] != sgmt[a][i])ans.push_back('1');
				else ans.push_back('0');
				s[i] = sgmt[a][i];
			}

			cout << ans << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
int n; cin>>n;
int b[1100];
for(int i=0;i<n-1;i++)
cin>>b[i];

int ans=b[0];

for(int i=1;i<n-1;i++)
  ans+=min(b[i],b[i-1]);
  ans+=b[n-2];

  cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

mt19937 mt(736);


class trie
{
	struct node
	{
		array<int, 26> nxt{}, cnt{};
		bool fin;
		int sz;

		node() : fin(false), sz(0)
		{
			fill(nxt.begin(), nxt.end(), -1);
		}
	};

	vector<node> mem;


	int build_sz(int v)
	{
		if (v == -1)
			return 0;

		for (auto it : mem[v].nxt)
			mem[v].sz += build_sz(it);

		if (mem[v].fin)
			mem[v].sz++;

		return mem[v].sz;
	}

	array<int, 26> build_cnt(int v)
	{
		if (v == -1)
			return {0};

		auto &cur = mem[v];

		for (int i = 0; i < cur.nxt.size(); i++)
			if (cur.nxt[i] != -1)
			{
				auto q = build_cnt(cur.nxt[i]);

				q[i] = mem[cur.nxt[i]].sz;

				for (int j = 0; j < q.size(); j++)
					cur.cnt[j] += q[j];
			}

		return cur.cnt;
	}

public:
	explicit trie(const vector<string> &arr) : mem(1)
	{
		for (const auto &str : arr)
		{
			int last = 0;

			for (auto it : str)
			{
				if (mem[last].nxt[it - 'a'] == -1)
				{
					mem[last].nxt[it - 'a'] = mem.size();
					mem.emplace_back();
				}

				last = mem[last].nxt[it - 'a'];
			}

			mem[last].fin = true;
		}

		build_sz(0);

		assert(mem.front().sz == arr.size());

		build_cnt(0);
	}


	[[nodiscard]] ll get_ans() const
	{
		ll ans = 0;

		for (const auto &cur : mem)
		{
			for (int i = 0; i < cur.nxt.size(); i++)
				if (cur.nxt[i] != -1 && mem[cur.nxt[i]].fin)
					ans += cur.cnt[i];
		}

		return ans;
	}
};


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<string> arr(n);

	for (auto &it : arr)
	{
		cin >> it;
		reverse(it.begin(), it.end());
	}

	trie tr(arr);

	cout << tr.get_ans() - (int) arr.size() << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	do
	{
		solve(fin);

		cout << "===" << endl;

		string str;
		while (getline(fin, str) && str != string(max(1, (int) str.size()), '='));
	} while (fin);

	cout << setprecision(6) << "clock: " << double(clock() - st) / CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 365264
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#define INF (1<<20)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
struct edge{ int to,cost;};
int C,N,M,S,D;
vector<edge> G[111];
int minc[111][11];
void solve(){
  memset(minc,-1,sizeof(minc));
  priority_queue< PP,vector<PP>,greater<PP> > q;
  q.push( PP(0,P(0,S)) );
  while(!q.empty()){
    PP p = q.top(); q.pop();
    int v=p.second.second;
    int m=p.second.first;
    if(minc[v][m]!=-1) continue;
    minc[v][m]=p.first;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(minc[e.to][m]==-1){
	q.push( PP(e.cost+p.first,P(m,e.to)) );
      }
      if(minc[e.to][m+1]==-1 && m<C){
	q.push( PP(e.cost/2+p.first,P(m+1,e.to)) );
      }
    }
  }
}

main(){
  while(1){
    scanf("%d %d %d %d %d",&C,&N,&M,&S,&D);
    if(C==0 && N==0 && M==0 && S==0 && D==0) break;
    for(int i=0;i<M;i++){
      int a,b,f;
      scanf("%d %d %d",&a,&b,&f);
      edge e;
      e.to=b;e.cost=f;
      G[a].push_back(e);
      e.to=a;
      G[b].push_back(e);
    }
    solve();
    int res=INF;
    for(int i=0;i<=C;i++){
      if(minc[D][i]==-1) continue;
      res=min(res,minc[D][i]);
    }
    printf("%d\n",res);
    for(int i=1;i<=N;i++)
      G[i].clear();
  }
}

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

	int main() {
		int h, w;
		cin >> h >> w;

		vector<string> v(w);
		for (int i = 0; i < w+2; i++) {
			cout << "#";
		}
		cout << endl;
		string a;
			for (int j = 0; j < h; j++) {
				cin >> a;
				cout << "#" << a << "#" << endl;
			}
			
		for (int k = 0; k < w+2; k++) {
			cout << "#";
		}
		cout << endl;
	}

  



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

int main(){
	//202
	double N,K;
	cin>>N>>K;
  	if((N-K)/(K-1)==int((N-K)/(K-1))) cout<<int((N-K)/(K-1))+1<<endl;
 	else cout<<int((N-K)/(K-1))+2<<endl;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	char str[10];
	cin>>str;
    if(str[1]!=str[2])
    cout<<"No"<<endl;
    else if(str[0] == str[1]||str[2] == str[3])
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);

  if (A == B && B == C)
    return !printf("0\n");

  int X[3]={A, B, C};
  std::sort(X, X+3);
  
  int res=0;
  for (int i=0; i<2; ++i) {
    while (X[i]+2 <= X[2]) {
      ++res;
      X[i] += 2;
    }
  }

  if (X[0] == X[1]) {
    if (X[0] < X[2]) 
      ++res;
  } else {
    res += 2;
  }

  printf("%d\n", res);
}


Measured memory_bytes: 128
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));


function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $array[] = 1<<(ord($str[$i])-97);
}
$seg = new SegTree($array);

while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);


class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    if(is_array($n)){
      $array = $n;
      $n = count($array);
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = $n, $I = 2**$this->bits; $i < $I; ++$i){
        $array[] = 0;
      }
      $this->tree[0] = $array;
      $this->rollupAll();
    }else{
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = 0; $i < $this->bits; ++$i){
        $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
      }
    }
  }
  function rollupAll(){
    for($i = 1; $i < $this->bits; ++$i){
      $treei = &$this->tree[$i];
      $treeim = $this->tree[$i-1];
      for($j = 0, $J = 2**($this->bits - $i + 1); $j < $J; $j+=2){
        $treei[] = op($treeim[$j], $treeim[$j+1]);
      }
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = op($this->tree[$j-1][$i>>$j<<1], $this->tree[$j-1][($i>>$j<<1) + 1]);
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    $bits = $this->bits;
    $i = 0;
    while($f!=$t){
      $treei = $tree[$i];
      if(($f >> $i) & 1 == 1){
        $sum = op($sum, $treei[$f>>$i]);
        $f+=1<<$i;
      }
      if(($t >> $i) & 1 == 1){
        $sum = op($sum, $treei[($t>>$i)-1]);
        $t-=1<<$i;
      }
      ++$i;
    }
    return $sum;
  }
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 55912
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	a, b = getlist()
	A = str(a) * b
	B = str(b) * a
	ans = sorted([A, B])
	print(ans[0])


if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 2000005;
int cnt[10000005];
void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1 ; i <= n ; i++) {
        for (int j = i ; j <= n ; j+= i) {
            cnt[j]++;
        } 
        ans += (ll)i * cnt[i];
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 42668
n, m, l = (int(x) for x in input().split())

a = []

for i in range(n):
    a.append([int(x) for x in input().split()])

b = []

for i in range(m):
    b.append([int(x) for x in input().split()])
    

c = []

## cij = ai1 * b1j + ai2 * b2j + ....

for i in range(n):
    # c[i] = []
    ci = []
    for j in range(l):
        cij = 0
        for k in range(m):
            cij += a[i][k] * b[k][j]
        ci.append(cij)
    
    c.append(ci)

for ci in c:
    
    flag = True
    for cij in ci:
        if flag:
            flag = False
        else:
            print(" ", end="")
        print(cij, end="")
    print()

        


Measured memory_bytes: 7136
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int main() {
  int N, A;
  cin >> N >> A;
  if (N % 500 <= A) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 384
def ok(i, j, _x, _y, _a)
  if _a == 1
    if i < _x 
      return true
    end
   
  elsif _a == 2
    if i >= _x 
      return true
    end

  elsif _a == 3
    if j < _y 
      return true
    end

  elsif _a == 4
    if j >= _y 
      return true
    end
  end

end

w, h, n = gets.chomp.split(" ").map{|i| i.to_i}
x, y, a = Array.new(3){Array.new(n)}
for i in 0...n
  x[i], y[i], a[i] = gets.chomp.split(" ").map{|i| i.to_i}
end

field = Array.new(w){Array.new(h){false}}

for k in 0...n
  for i in 0...w
    for j in 0...h
      if ok(i, j, x[k], y[k], a[k])
        field[i][j] = true
      end
    end
  end
  #p field
end

s = 0

for i in 0...w
  for j in 0...h
    unless field[i][j] then
      s = s + 1
    end
 end
end

p s
 


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

using namespace std;

const int N=1000010,mod=1e9+7;

int n,h,d,q,p,ans,f[N];

void inc(int&x,int y){x+=y;if(x>=mod)x-=mod;}
void dec(int&x,int y){x-=y;if(x<0)x+=mod;}

int pw(int x,int y){
	int re=1;
	while(y){
		if(y&1)re=1ll*re*x%mod;
		y>>=1;x=1ll*x*x%mod;
	}return re;
}

int main(){
//	freopen("e.in","r",stdin);
//	freopen("e.out","w",stdout);
	scanf("%d%d%d",&n,&h,&d);
	for(int i=q=1;i<=n;++i){
		q=1ll*q*i%mod;
		inc(p,q);
	}
	ans=1ll*q*pw(p,mod-2)%mod;
	for(int i=f[0]=1,s=1;i<=h;++i){
		if(i-d-1>=0)dec(s,f[i-d-1]);
		f[i]=1ll*s*p%mod;
		inc(s,f[i]);
	}
	ans=1ll*f[h]*ans%mod;
	cout<<ans<<endl;
	return 0;
}


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

#define int long long

signed main() {
    int n, sum = 0, m;
    scanf("%lld%lld", &n, &m); n--;
    int k = n / 4 * 4, ans = k;
    while(k < n) {
        ++k ;
        ans ^= k;
    }
    int s = ans; n = m;
    k = n / 4 * 4, ans = k;
    while(k < n) {
        ++k ;
        ans ^= k;
    }
    printf("%lld\n", ans ^ s);
    return 0;
}

Measured memory_bytes: 256
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-9-23 21:03:15
# Powered by Visual Studio Code
#

n, m, x, y = gets.chomp.split(" ").map{|i| i.to_i}
k = gets.chomp.split(" ").map{|i| i.to_i}
l = gets.chomp.split(" ").map{|i| i.to_i}
if [x, k.max].max < [y, l.min].min
  puts "No War"
else
  puts "War"
end


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll k;cin >>k;
    vector<ll>a(k);
    for (int i = 0; i < k; ++i) {
        cin >>a[i];
    }
    reverse(all(a));
    a.push_back(1);
    ll mint=2,mx=2;
    if(a[0]!=2){
        cout <<-1<<endl;
        return 0;
    }
    for (int i = 0; i < k; ++i) {
        mx+=a[i]-1;
        mx -= mx % a[i + 1];
        ll cost = (mint % a[i + 1]) ? a[i + 1] - mint % a[i + 1] : 0;
        mint += cost;
        if(mint>mx){
            cout <<-1<<endl;
            return 0;
        }
    }
    cout <<mint<<" "<<mx<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int n;
	cin >> n;
	int cur = 1;
	rep(i, 0, n) {
		int x;
		cin >> x;
		if (x == cur) cur++;
	}
	if (cur == 1) cout << -1 << '\n';
	else cout << n - cur + 1 << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long ans=0;
		for(int i=0; i<n; i++){
			ans+=sc.nextInt()-1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26096
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,K;
cin >> N >> K;

auto dig = [&](int c) {
    int res = 0;
    while (c) {
        c /= K;
        ++res;
    }
    return res;
};

cout << dig(N) << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H,W;cin>>H>>W;
	string S[H];
	vector<vector<pair<int,int>>> count(H,vector<pair<int,int>>(W));
	int a,b;
	for(int i=0;i<H;i++){
		cin>>S[i];
		a=0;
		for(int j=0;j<W;j++){
			if(S[i].at(j)=='#'){
				a=0;
			}else{
				a++;
			}count[i][j].second=a;
		}for(int j=W-2;j>=0;j--){
			if(S[i].at(j)=='.'&&S[i].at(j+1)=='.'){
				count[i][j].second=count[i][j+1].second;
			}
		}
	}
	for(int j=0;j<W;j++){
		b=0;
		for(int i=0;i<H;i++){
			if(S[i].at(j)=='#'){
				b=0;
			}else{
				b++;
			}count[i][j].first=b;
		}for(int i=H-2;i>=0;i--){
			if(S[i].at(j)=='.'&&S[i+1].at(j)=='.'){
				count[i][j].first=count[i+1][j].first;
			}
		}
	}
	int ans=0;
	int x,y;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			x=count[i][j].first;
			y=count[i][j].second;
			ans=max(ans,x+y-1);
		}
	}cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;


int solve(vector<int> weights, vector<int> values, int total_weight)
{
  int n = weights.size();
  vector<vector<int> > dp(n, vector<int>(total_weight + 1, 0));
  for (int i = 0; i <= total_weight; ++i) {
    if (weights[0] <= i) {
      dp[0][i] = values[0];
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int w = 1; w <= total_weight; ++w) {
      int val = dp[i - 1][w];
      if (w - weights[i] >= 0) {
        val = max(val, dp[i - 1][w - weights[i]] + values[i]);
      }
      dp[i][w] = val;
    }
  }
  return dp[n - 1][total_weight];
}

int main()
{
  int N, W;
  fscanf(stdin, "%d %d", &N, &W);
  vector<int> values(N, 0);
  vector<int> weights(N, 0);
  for (int i = 0; i < N; ++i) {
    fscanf(stdin, "%d %d", &values[i], &weights[i]);
  }
  int ans = solve(weights, values, W);
  fprintf(stdout, "%d", ans);
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 4960
/* 00:08 - 12:00 */
#include <iostream>
using namespace std;
int main(){
	int n,ret,p,a,b;
	
	while(cin >> n , n){
		pair<int,int> ret = make_pair(0,0) ;
		for(int i=0;i<n;i++){
			cin >> p >> a >> b;
			ret = max(ret,make_pair(a+b,p));
		}
		cout << ret.second << " " << ret.first << endl;
	}
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(){

  int n;
  cin >> n;

  vector<int> p(n);
  int ct = 0;
  cin>>p;

  reps(i,1,n-1){
    if(((p[i-1]<p[i])&&(p[i]<p[i+1]))||((p[i-1]>p[i])&&(p[i]>p[i+1]))){
      ct++;
    }
  }

  cout << ct <<endl;
  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 24" ].parse.expand.solve == 2 );
	assert( [ "5 1" ].parse.expand.solve == 1 );
	assert( [ "1 111" ].parse.expand.solve == 111 );
	assert( [ "4 972439611840" ].parse.expand.solve == 206 );
	
	assert( [ "190000000000 972439611841" ].parse.expand.solve == 1 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto np = input.front.split.to!( long[] );
	return tuple( np[ 0 ], np[ 1 ] );
}

auto solve( long n, long p )
{
	// pを素因数分解して素因数ごとの個数をカウント
	auto gs = primefactorize( p ).group;
	
	// as全部に掛けられる個数の素因数があったら最大公約数を大きくできる
	auto ans = 1L;
	foreach( g; gs )
	{
		auto d = g[ 1 ] / n;
		if( 0 < d ) ans *= g[ 0 ] ^^ d;
	}
	return ans;
}

// 素数列
auto primes( long x )
{
	long[] ps;
	if( x < 2 ) return ps;
	
	auto cs = new bool[]( x + 1 );
	ps = [ 2L ];
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps;
}

// 素因数分解
long[] primefactorize( long x )
{
	auto s = cast( long ) sqrt( cast( float ) x ) + 1;
	return primefactorize( x, s.primes );
}

// 素因数分解（事前に作った素数列を使う）
auto primefactorize( long x, long[] ps )
{
	long[] fs;
	if( x < 2 ) return fs;
	
	foreach( p; ps )
	{
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
	}
	if( 1 < x ) fs ~= x;
	return fs;
}


Measured memory_bytes: 3708
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}


int main(){
	int N;
	cin>>N;
	for(ll i=0;i<100000;i++){
		ll tmp=i*i;
		if(tmp>N){
			cout<<(i-1)*(i-1)<<endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int[] a;
        a = new int[100];

        int[] b;
        b = new int[100];

        int i = 0;

        while (true) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();

            if (a[i] == 0 && b[i] == 0)
                break;

            i++;
        }

        i = 0;
        while (true) {
            for (int j = 0; j < b[i]; j++) {
                System.out.print("#");
            }
            System.out.println();
            for (int j = 0; j < a[i] - 2; j++) {
                System.out.print("#");
                for (int k = 0; k < b[i]-2; k++) {
                    System.out.print(".");
                }
                System.out.println("#");
            }
            for (int j = 0; j < b[i]; j++) {
                System.out.print("#");
            }
                System.out.println('\n');
            i++;
            if (a[i] == 0 && b[i] == 0)
                break;
        }
    }
}



Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    lint ans = 0;
    rep1(i, n) for (lint j = i; j <= n; j++) {
        if (n <= i * j) break;
        ans++;
        if (i != j) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int a, b, c, x;
        scanf("%d %d %d %d", &a, &b, &c, &x);
        int ans = 0;
        for (int i = 0; i <= a; i ++) {
                for (int j = 0; j <= b; j ++) {
                        for (int k = 0; k <= c; k ++) {
                                if (500 * i + 100 * j + 50 * k == x) {
                                        ans ++;
                                }
                        }
                }
        }
        printf("%d\n", ans);
        return 0;
}



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

int main() {

  int N, K, X, Y;
  Y = 0;
  cin >> N >> K; 
  for(int i = 0;i < N;i++){
   cin >> X;
   if(X * 2 > (K - X) * 2){
    Y = Y + (K - X);
   }else{
    Y = Y + X;
   }
  }
  cout << Y * 2 << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 50;
const int MAXCHERCHE = 10000;
bool deja[MAXN][MAXCHERCHE];
bool dU[MAXN];
int mini[MAXN];

struct pr_Q
{
	int temps , noeud , arg;
	bool operator < (const pr_Q & autre) const
	{
		return temps > autre.temps;
	}
};

struct arc
{
	int fin , temps , val;
};

struct Source
{
	int gain , temps;
};

vector <arc> adj[MAXN];
int32_t main()
{
	int nbNoeuds , nbChemins , argent;
	cin >> nbNoeuds >> nbChemins >> argent;
	for (int i = 0 ; i < nbChemins ; i++)
	{
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--;b--;
		adj[a].push_back({b,d,c});
		adj[b].push_back({a,d,c});
	}
	Source villes[nbNoeuds];
	for (int i = 0 ; i < nbNoeuds ; i++)
	{
		int a,b;
		cin >> a >> b;
		villes[i] = {a,b};
		mini[i] = 1e18;
	}
	priority_queue<pr_Q> Q;
	Q.push({0 , 0 , argent});
	while (!Q.empty())
	{
		pr_Q actu = Q.top(); Q.pop();
		if (actu.arg < 0) continue;
		if (actu.arg >= MAXCHERCHE && dU[actu.noeud])
		{
			continue;
		}
		if (actu.arg < MAXCHERCHE && deja[actu.noeud][actu.arg])
		{
			continue;
		}
		if (actu.arg >= MAXCHERCHE)
		{
			dU[actu.noeud] = true;
		}
		else
		{
			deja[actu.noeud][actu.arg] = true;
		}
		mini[actu.noeud] = min(mini[actu.noeud] , actu.temps);
		for (auto voisin : adj[actu.noeud])
		{
			Q.push({actu.temps + voisin.temps , voisin.fin , actu.arg - voisin.val });
		}
		Q.push({actu.temps + villes[actu.noeud].temps , actu.noeud , actu.arg + villes[actu.noeud].gain});
	}
	for (int i = 1 ; i < nbNoeuds ; i++)
	{
		cout<<mini[i]<<endl;
	}
}

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

int main(int argc, const char * argv[]) {
    int n, a, max[2], max2[2];
    int i;
    
    cin >> n;
    
    max[0] = 0;    max[1] = 0;
    max2[0] = 0;   max2[1] = 0;
    
    for(i=0; i<n; i++){
        cin >> a;
        if(a >= max[0]){
            max2[0] = max[0];
            max2[1] = max[1];
            max[0] = a;
            max[1] = i;
        } else if(a > max2[0]){
            max2[0] = a;
            max2[1] = i;
        }
    }
    
    for(i=0; i<n; i++){
        if(i == max[1]) cout << max2[0]  << endl;
        else cout << max[0] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 1664
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
void read(T&);
template<class T>
void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;

int main () {
  std::string s1, s2;
  std::cin >> s1 >> s2;
  write((s1[0] == s2[0]) + (s1[1] == s2[1]) + (s1[2] == s2[2])), EL;
  return 0;
}

template<class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template<class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


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

const long long INF = 4'000'000'000'000;

long long d[300][300];
const int V = 300;

void warshall_floyd() {
    for (int k = 0; k < V; k++)
    {
        for (int i = 0; i < V; i++)
        {
            for (int j = 0; j < V; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    for (int i = 0; i < 300; i++)
    {
        for (int j = 0; j < 300; j++)
        {
            d[i][j] = INF;    
        }
        d[i][i] = 0;
    }
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> d[i][j];
        }
    }
 
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j) continue;
            for (int k = 0; k < n; k++)
            {
                if (i == k || j == k) continue;

                if (d[i][j] + d[i][k] < d[j][k]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    warshall_floyd();
 
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j) continue;
            for (int k = 0; k < n; k++)
            {
                if (i == k || j == k) continue;

                if (d[i][j] + d[i][k] <= d[j][k]) {
                    d[j][k] = INF;
                }
            }
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (d[i][j] == INF) continue;

            ans += d[i][j];
            d[j][i] = 0;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

void insertSort(int a[], int n) {
    for (int i = 1; i < n; i++) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
            a[j + 1] = v;
        }
        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                cout << a[i] << endl;
            } else {
                cout << a[i] << " ";
            }
        }
    }

}

int main() {
    int n; cin >> n;
    int a[n + 1];
    for (int i = 0; i < n; i++) cin >> a[i];
        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                cout << a[i] << endl;
            } else {
                cout << a[i] << " ";
            }
        }

    insertSort(a, n);


    return 0;
}


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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    ll n;
    string s;
    cin >> n >> s;
    ll tmp=0, tmp2=0, count2=0, count3=0, swi=0;
    vector<int> shiro(n),kuro(n);
    int kurocount=0, shirocount=0;
    rep(i,n){
        if(s[n-i-1]=='.'){
            shirocount++;
        }
        if(s[i]=='#'){
            kurocount++;
        }

        shiro[n-i-1]=shirocount;
        kuro[i]=kurocount;

        if(s[i]=='.'&&swi==1){
            count2++;
            tmp2=0;
        }
        if(s[i]=='#'){
            tmp++;
            swi=1;
        }
        if(s[i]=='#'&&tmp2==0){
            tmp2=1;
            count3+=count2;
            count2=0;
        }
    }
    if(tmp2==0){
        count3+=count2;
    }
    ll count = tmp;
    tmp=iinf;
    rep(i,n-1){
        amin(tmp, shiro[i+1]+kuro[i]);
    }
    amin(count,count3);
    amin(count,tmp);
    cc(count);
}

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

int main(){
  char c;
  char aph[26]{};
  while(cin >> c)aph[c-'a']++;
  for(int i=0; i<26; i++){
    if(!aph[i]){
      cout << (char)(i+'a');
      return 0;
    }
  }
  cout << "None";
  return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x;
    cin>>x;
    ll k=100;
    ll res=0;
    while(k<x){
        res++;
        k*=1.01;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
// #define int long long
int dp[3000+10][3000+10];
int dps[3000+10][3000+10];
const int mod=998244353;
int32_t main()
{
    // cout<<"fafaf"<<endl;
	int n,s;
	cin>>n>>s;
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[1][a[1]]=1;
	dps[1][a[1]]=1;
	int ans=0;
	for(int i=2;i<=n;i++){
		for(int sum=a[i]+1;sum<=3000;sum++)
		{
            dp[i][sum]=dps[i-1][sum-a[i]];
		}
		dp[i][a[i]]=i;
		dp[i][a[i]]%=mod;		
		for(int sum=0;sum<=3000;sum++){
		    dps[i][sum]=dps[i-1][sum];
		    dps[i][sum]+=dp[i][sum];
		    dps[i][sum]%=mod;
		}


	}	
	for(int i=1;i<=n;i++) ans+=(1ll*(n-i+1)*dp[i][s])%mod,ans%=mod;
	cout<<ans;	

	
	return 0;
}


Measured memory_bytes: 70912
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      int H = sc.nextInt();
      int W= sc.nextInt();

      if (H == 0 && W == 0) { break; }

      for(int i=1; i <= H; i++){
        if(i % 2 == 0){
          int j = 0;
          while(j <= W){
            if(W == 1){
              System.out.print(".");
              break;
            } else {
              System.out.print(".");
              j++;
              if(j == W){ break; }
              System.out.print("#");
              j++;
              if(j == W){ break; }
            }
          }
        }
        if(i % 2 != 0){
          int j = 0;
          while(j <= W){
            if(W == 1){
              System.out.print("#");
              break;
            } else {
              System.out.print("#");
              j++;
              if(j == W){ break; }
              System.out.print(".");
              j++;
              if(j == W){ break; }
            }
          }
        }
        System.out.print("\n");
      }
      System.out.printf("\n");
    }
  }
}



Measured memory_bytes: 37984
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define inf 1e18+5
using namespace std;
const int N=2e5+5;
int h[N],a[N];
int seg[4*N];
void update(int t,int l,int r,int idx,int val)
{
    if(l==r)
    {
        seg[t]=max(seg[t],val);
        return;
    }
    int mid=(l+r)/2;
    if(idx<=mid)update(2*t+1,l,mid,idx,val);
    else update(2*t+2,mid+1,r,idx,val);
    seg[t]=max(seg[2*t+1],seg[2*t+2]);
    return;
}
int query(int t,int l,int r,int c,int d)
{
    if(r<c||l>d)return 0;
    if(l>=c&&r<=d)return seg[t];
    int mid=(l+r)/2;
    int q1=query(2*t+1,l,mid,c,d);
    int q2=query(2*t+2,mid+1,r,c,d);
    return max(q1,q2);
}
void solve()
{
  int n,ans=0; cin>>n;
  for(int i=0;i<n;i++){cin>>h[i]; h[i]--;}
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)
  {
      int q=0;
      if(h[i])q=query(0,0,n-1,0,h[i]-1);
      ans=max(ans,a[i]+q);
      update(0,0,n-1,h[i],a[i]+q);
  }
  cout<<ans;
  return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--)solve();
    return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcde = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abcde[0];
            var b = abcde[1];
            var c = abcde[2];
            var d = abcde[3];
            var e = abcde[4];
            if (a >= c + e && c >= e && b >= d + e && d >= e)
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");

            {


            }
        }
    }
}

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

int main(){
  vector<int> prime;
  bool is_prime[100001];
  rep(i,0,100001) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  rep(i,2,100001){
    if(is_prime[i]){
      prime.push_back(i);
      for(int j=2*i;j<=100000;j+=i) is_prime[j]=false;
    }
  }
  vector<int> a;
  rep(i,1,prime.size()){
    auto x=upper_bound(prime.begin(),prime.end(),(prime[i]+1)/2);
    auto y=lower_bound(prime.begin(),prime.end(),(prime[i]+1)/2);
    int z=x-y;
    if(z!=0) a.push_back(prime[i]);
  }
  
  int n;
  cin>>n;
  rep(i,0,n){
    int b,c;
    cin>>b>>c;
    cout<<upper_bound(a.begin(),a.end(),c)-lower_bound(a.begin(),a.end(),b)<<endl;
  }
}

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


int main()
{
	string W, T;
	int count = 0;

	cin >> W;
	
	while (cin>>T){
		if (T == "END_OF_TEXT"){
			break;
		}
		for (int i = 0; i < T.size(); i++){
			if ('A' <= T[i] && T[i] <= 'Z'){
				T[i] = char(tolower(T[i]));
			}
		}
		if(T==W){
			count++;
		}
	}
	cout << count << endl;
	
	return 0;
}


Measured memory_bytes: 3140
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
struct twodimBIT{
    private:
        vector<vector<T>> array;
        const int n;
        const int m;
    public:
        twodimBIT(int _n, int _m) : array(_n+1, vector<T>(_m+1, 0)), n(_n), m(_m) {}
        T sum(int x, int y){
            T s = 0;
            for(int i = x; i > 0; i-=i&(-i)){
                for(int j = y; j > 0; j-=j&(-j)){
                    s += array[i][j];
                }
            }
            return s;
        }
        T sum(int x1, int y1, int x2, int y2){
            return sum(x2, y2) - sum(x1-1, y2) - sum(x2, y1-1) + sum(x1-1, y1-1);
        }
        void add(int x, int y, T k){
            for(int i = x; i <= n; i+=i&(-i)){
                for(int j = y; j <= m; j+=j&(-j)){
                    array[i][j] += k;
                }
            }
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    twodimBIT<int> cnt(n, n);
    int l, r;
    rep(i,m){
        cin >> l >> r;
        cnt.add(l, r, 1);
    }
    rep(i,q){
        cin >> l >> r;
        cout << cnt.sum(l, l, r, r) << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
counts_number = int(input())
tmp_map = map(int, input().split())
num_list = list(tmp_map)
even_of_num_list = []
approve_counts = 0

for i in num_list:
    if i % 2 == 0:
        even_of_num_list.append(i)

for x in even_of_num_list:
    if x % 3 == 0 or x % 5 == 0:
        approve_counts += 1

if approve_counts == len(even_of_num_list):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 9152
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

vector<vector<int>> edges;
vector<ll> counter;
vector<ll> ans;

void solve(const int cur, const int prev, ll &acc, const int N, const int Q) {
    acc += counter[cur];
    ans[cur] = acc;
    for (auto &next : edges[cur]) {
        if (next == prev) continue;
        solve(next, cur, acc, N, Q);
    }
    acc -= counter[cur];
}

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

    edges.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    counter.resize(N, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        counter[p] += x;
    }

    ans.resize(N, -1);
    ll acc = 0;
    solve(0, -1, acc, N, Q);

    cout << ans[0];
    for (int i = 1; i < N; i++) {
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 32128
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <functional>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  // 二分探索，lower_bound
  // https://qiita.com/e869120/items/702ca1c1ed6ff6770257
  // https://scrapbox.io/ganariya/AtCoderBeginnerContest077_C%E5%95%8F%E9%A1%8C300%E7%82%B9_%E3%80%8CSnuke_Festival%E3%80%8D_(copy)
  ll N; cin>>N;
  vector<ll> A(N), B(N), C(N);
  rep(i,N) cin>>A[i]; sort(ALL(A));
  rep(i,N) cin>>B[i]; sort(ALL(B));
  rep(i,N) cin>>C[i]; sort(ALL(C));

  ll res = 0;
  rep(i,N) {
    ll left = lower_bound(ALL(A), B[i]) - A.begin() - 1;        // index:[0,left]の(left+1)通りが条件満たす
    ll right = lower_bound(ALL(C), B[i]+1) - C.begin(); // index:[right,N)の(N-right)通りが条件満たす
    res += (left+1)*(N-right);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2560