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

struct Mod {
  vector<ll> fact;
  vector<ll> finv;
  Mod() {}
  Mod(int n, int p) {
    fact.resize(n + 1); fact[0] = 1;
    for (int i = 1; i < n + 1; ++i) fact[i] = fact[i - 1] * i % p;
    finv.resize(n + 1);
    for (int i = 0; i < n + 1; ++i) finv[i] = mod_pow(fact[i], p - 2, p);
  }
  int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if (b) {
      d = extgcd(b, a % b, y, x);
      y -= (a / b) * x;
    } else {
      x = 1, y = 0;
    }
    return d;
  }
  ll mod_pow(ll x, ll n, ll m) {
    if (n == 0) return 1;
    ll res = mod_pow(x * x % m, n / 2, m);
    if (n & 1) res = res * x % m;
    return res;
  }
};

const ll MOD = 1e9 + 7;
ll dp[1001][1001];
Mod m(1001, MOD);

ll f(int i, int j, int k) {
  ll x = 1;
  x = x * m.fact[j] % MOD;
  x = x * m.finv[j - i * k] % MOD;
  x = x * m.mod_pow(m.finv[i], k, MOD) % MOD;
  return x * m.finv[k] % MOD;
}

int main() {
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  dp[0][0] = 1;
  for (int i = 1; i <= B; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (i < A) continue;
      for (int k = C; k <= D; ++k) {
        if (j - i * k < 0) break;
        dp[i][j] += f(i, j, k) * dp[i - 1][j - i * k] % MOD;
      }
      dp[i][j] %= MOD;
    }
  }
  cout << dp[B][N] << endl;
  return 0;
}


Measured memory_bytes: 8064
import sys
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17

n = int(input())
print(n/3*n/3*n/3)


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int i,int j)
{return(i>j);} 
int main()
{int n,k,ans=0;
 cin>>n>>k;
 int a[100];
 for(int i=0;i<n;i++)
 cin>>a[i];
 sort(a,a+n,cmp);
 for(int i=0;i<k;i++)
 ans+=a[i];
 cout<<ans<<endl;
 system("pause");
 return 0;
}

Measured memory_bytes: 504
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int K = Int32.Parse(args[0]);
		int S = Int32.Parse(args[1]);
		
		int ans = 0;
		for(int x = 0; x <= K; x++)
		{
			for(int y = 0; y <= K; y++)
			{
				int tmpZ = S - (x + y);
				if((tmpZ >= 0) && (tmpZ <= K))
					ans++;				
			}			
		}
			
		Console.WriteLine(ans);
	}	
}





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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;

signed main(){
    ll A;
    double B;
    cin >> A >> B;
    B = B*100.0;
    ll Bl = round(B);
    ll C = A*Bl;
    C /= 100;
    cout << C << endl;
    return 0;
}

Measured memory_bytes: 3780
N = int(input())
xyh = [[int(i) for i in input().split()] for i in range(N)]
xyh = sorted(xyh, key=lambda x: x[2], reverse=True)

for CX in range(0, 101):
    for CY in range(0, 101):
        H = -1
        for x, y, h in xyh:
            if h != 0:
                if H == -1:
                    H = abs(x - CX) + abs(y - CY) + h
                elif H != abs(x - CX) + abs(y - CY) + h:
                    break
            else:
                if H != -1 and H - abs(x - CX) - abs(y - CY) > 0:
                    break
        else:
            print(CX, CY, H)

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

struct answer {
  int y1;
  int x1;
  int y2;
  int x2;
};

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

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

  int h, w;
  cin >> h >> w;
  vvi a(h, vi(w));
  rep(i, 0, h) rep(j, 0, w) cin >> a[i][j];

  int n = 0;
  vector<answer> ans;
  rep(i, 0, h) {
    rep(j, 0, w) {
      if(a[i][j] % 2) {
        rep(k, 0, 4) {
          if(0 <= j + dx[k] && j + dx[k] < w && 0 <= i + dy[k] && i + dy[k] < h) {
            n++;
            ans.push_back({i + 1, j + 1, i + dy[k] + 1, j + dx[k] + 1});
            a[i][j]--;
            a[i + dy[k]][j + dx[k]]++;
            break;
          }
        }
      }
    }
  }
  cout << n << endl;
  for(auto ite : ans) {
    cout << ite.y1 << " " << ite.x1 << " " << ite.y2 << " " << ite.x2 << endl;
  }
}


Measured memory_bytes: 5236
N = int(input())                                                                                                                                             
H = list(map(int,input().split()))                                                                                                                           
                                                                                                                                                             
res = 1                                                                                                                                                      
max_h = H[0]                                                                                                                                                 
for i in range(1,N):                                                                                                                                         
    if max_h <= H[i]:                                                                                                                                        
        res = res+1                                                                                                                                          
        max_h = H[i]                                                                                                                                         
                                                                                                                                                             
print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<set>


struct Data{
	long long x,y,z;
	long long value;
	size_t id;
	Data(long long i_x,long long i_y,long long i_z,long long i_value,size_t i_id)
		:x(i_x),y(i_y),z(i_z),value(i_value),id(i_id){}
	bool operator<(const Data &otherobj)const{
		if(this->value>otherobj.value){
			//大きいと先頭に来るようにしたいので、普通と向きを逆に
			return true;
		} else if(this->value<otherobj.value){
			return false;
		}
		if(this->x<otherobj.x){
			return true;
		} else if(this->x>otherobj.x){
			return false;
		}
		if(this->y<otherobj.y){
			return true;
		} else if(this->y>otherobj.y){
			return false;
		}
		if(this->z<otherobj.z){
			return true;
		} else if(this->z>otherobj.z){
			return false;
		}
		return this->id<otherobj.id;
	}
};

void use_set(){
	//入力機構
	size_t N,M;
	std::cin>>N>>M;
	std::vector<long long> X,Y,Z;//10,000,000,000の値が入りintだとオーバーする可能性大。__int64はGCCで使えないため用いないこと。
	X.reserve(N);
	Y.reserve(N);
	Z.reserve(N);
	for(size_t i=0;i<N;i++){
		long long x,y,z;
		std::cin>>x>>y>>z;
		X.push_back(x);
		Y.push_back(y);
		Z.push_back(z);
	}

	//処理機構
	long long ans=0;
	long long xAns,yAns,zAns;//それぞれ(綺麗さの合計),(おいしさの合計),(人気度の合計)を指す
	std::set<Data> dataSet;
	//xAns,yAns,zAnsの全ての正負について考える。計8パターン。
	int pattern[8][3]={{-1,-1,-1},{-1,-1,1},{-1,1,-1},{-1,1,1},{1,-1,-1},{1,-1,1},{1,1,-1},{1,1,1}};
	for(size_t i=0;i<8;i++){
		//各合計を記入
		dataSet.clear();
		for(size_t j=0;j<N;j++){
			dataSet.insert(Data(X[j],Y[j],Z[j],X[j]*pattern[i][0]+Y[j]*pattern[i][1]+Z[j]*pattern[i][2],j));
		}
		//dataSetはソートされている
		//q_sort(vec,index,0,N-1);//クイックソート直実装
		xAns=0;
		yAns=0;
		zAns=0;
		std::set<Data>::const_iterator it=dataSet.begin();
		for(size_t j=0;j<M;j++,it++){
			xAns+=it->x*pattern[i][0];
			yAns+=it->y*pattern[i][1];
			zAns+=it->z*pattern[i][2];
		}
		long long pal=std::abs(xAns)+std::abs(yAns)+std::abs(zAns);
		if(ans<pal){
			ans=pal;
		}
	}

	//出力機構
	std::cout<<ans<<std::endl;


}


int main(){
	use_set();
	return 0;
}


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

using namespace std;

int main(){
    int db = 0;
    int l, r, d;
    cin >> l >> r >> d;
    for (int i = l; i <= r; i++){
        if (i % d == 0){
            db++;    
        }
    }
    cout << db;
    return 0;
}

Measured memory_bytes: 3632
n = $stdin.readline.to_i
k = Math::sqrt(2 * n).to_i + 1

if k * (k - 1) / 2 != n
  puts "No"
  exit
end

s = Array.new(k) { [k - 1] }
1.step(k - 1) do |j|
  0.step(j - 1) do |i|
    e = (j - 1) * j / 2 + i + 1
    s[i] << e
    s[j] << e
  end
end

puts "Yes"
puts k
s.each {|x| puts x.join(" ") }

Measured memory_bytes: 18152
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int rows = scanner.nextInt();
    int cols = scanner.nextInt();
    
    int nonRows = scanner.nextInt();
    int nonCols = scanner.nextInt();
    
    System.out.println((rows - nonRows) * (cols - nonCols));
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


int main(){
  double x;
  cin >> x;
  bool t = false;
  REP(i,50000){
    if(floor(i * 1.08) == x){
      cout << i;
      t = true;
    }
  }
  if(!t){
    cout << ":(";
  }
  return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
	ll n, d, ans, a;
	cin >> n >> d >> ans;
	rep(i, n) {
		cin >> a;
		ans += d/a;
		if (d % a != 0)ans += 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 22.08.2020 21:01:08
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    int n,x,t;
    cin >> n >> x >> t;

    cout << (((n-1)/x)+1)*t << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<climits>
using namespace std;

int main(){
    while(true){
        int e;
        int min = INT_MAX;
        cin >> e;
        if(e==0) break;
        for(int z=0; z < cbrt(e)+1; z++){
            for(int y=0; y < sqrt(e-z*z*z)+1; y++){
                if(e-z*z*z-y*y >= 0){
                    int tmp = z+y+(e-z*z*z-y*y);
                    if(tmp < min) min = tmp;
                }
            }
        }
        cout << min << endl;
    }
    return 0;
}

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

int main() {
    int x,y;
    cin>>x>>y;
    if(x>y) cout<<"a > b"<<endl;
    else if(x==y) cout<<"a == b"<<endl;
    else cout<<"a < b"<<endl;
    return 0;    
}

Measured memory_bytes: 3056
#include <iostream>
#include <iomanip>
/*cout<<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(11)<<ret<<endlで、小数部のみ11桁表示かつゼロ埋め有*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); 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; }

//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
/*int main(void){
    int x;cin>>x;
    int a=-1;
    rep(i,4){
        int tmp=x%10;
        if(a==tmp){
            cout<<"Bad"<<endl;
            return 0;
        }else{
            a=tmp;
            x/=10;
        }
    }
    cout<<"Good"<<endl;

    return 0;
}*/
//////////////////
//  B
/*int main(void){
    int n,l;cin>>n>>l;
    int Left=l,Right=l+n-1;

    int eat;
    if(Left>=0)eat=Left;
    else if(0>=Right)eat=Right;
    else eat=0;

    int sum=n*(l-1) + n*(n+1)/2;//tigau

    cout<<(sum-eat)<<endl;
    return 0;
}*/
//////////////////
//  C //解説を見たら実装できた
long long gcd(long long a, long long b){//最大公倍数を求める
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}
long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}
int main(void){
    long long a,b,c,d;cin>>a>>b>>c>>d;

    long long l=lcm(c,d);//最小公倍数
    long long b_ret = b - b/c - b/d + b/l;//b以下の整数のうち、cでもdでもわれないものの個数
    a=a-1;
    long long a_ret = a - a/c - a/d + a/l;

    cout<<b_ret-a_ret<<endl;
    return 0;
}
//////////////////
//  D　いけそう感がある。しゃくとり法
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std ;
int main() {
  vector<int> v(6) ;
  for (int i = 1 ; i <= 5 ; ++i) {
    cin >> v[i] ;
    if (v[i] == 0) {
      cout << i ;
    }
  }
  return 0 ;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/
void solve()
{
    int x;
    cin>>x;
    int lo=x/200;
    cout<<10-lo<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    auto start = std::chrono::high_resolution_clock::now();
    // tcase{
        solve();
    // }
    auto stop = std::chrono::high_resolution_clock::now(); 
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); 
    // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;     
    return 0;
}


Measured memory_bytes: 3648
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	IOS;

	int x, k;
  	cin >> x >> k;
  
  	for(int i = k-x+1; i <= k+x-1; ++i)
      	cout << i << ' ';

	return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b = readInts()
for i in range(1, 10001):
    if int(i*0.08) == a and int(i*0.1) == b:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 10444
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = [input() for i in range(n)]
b = [input() for j in range(m)]
flag = True
for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k in range(m):
            if a[k + i][j:j + m] != b[k]:
                flag = False
                break
        if flag:
            print('Yes')
            exit()
        flag = True
print('No')


Measured memory_bytes: 3064
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = gets.chomp

if S[0...N/2] == S[N/2..]
  puts 'Yes'
else
  puts 'No'
end


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

typedef long long ll;
typedef pair <int, int> pii;

#define fr first
#define sc second
#define pb push_back
#define mpr make_pair
#define ppb pop_back()
#define ins insert
#define sz(s) int(s.size())
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
int n, C, K, cnt, ans, a, last;
map <int, int> mp;
int main()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> C >> K;
	for(int i = 1;i <= n; ++ i){
		cin >> a;
		++mp[a];
	}
	for(auto to : mp){
		if(!last)last = to.fr;
		if(to.fr > last + K){
			++ans;
			cnt = 0;
			last = to.fr;
		}
		cnt += to.sc;
		if(cnt > C){
			ans += (cnt - 1) / C;
			cnt = (cnt - 1) % C + 1;
			last = to.fr;
		}
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline

K=int(input().rstrip('\n'))
if K % 2 ==0:
  print(-1)
else:
  now = 7
  check = 0
  for i in range(1,K+1):
    if now % K ==0:
      print(i)
      check += 1
      break
    else:
      now = now%K
      now = now*10
      now += 7 
  if check ==0:
    print(-1)

Measured memory_bytes: 63156
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;



typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[600005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



double ab[20000];

bool fa[200009] = {};


int main() {
	
	cin >>N;
	a = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] != i + 1) {
			a++;
		}
	}
	

	if (a <=2) {
		cout <<"YES"<< endl;
	}
	else {
		cout << "NO" << endl;
	}

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;


	
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	map<int,int> m;
	for(int i=1;i<n;i++){
		int a;
		cin>>a;
		m[a]++;
	}
	for(int i=0;i<n;i++){
		cout<<m[i+1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 13040
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        k: usize,
        s: chars,
    }
    let mut ans = 0;
    let mut l = 0;
    let mut r = 0;

    let mut cnt = 0;

    while l < s.len() {
        while r < s.len() {
            let c = s[r];

            if c == '0' {
                if cnt < k {
                    cnt += 1;
                } else {
                    break;
                }
            }
            while r < s.len() && s[r] == c {
                r += 1;
            }
        }
        ans = max(ans, r - l);

        let c = s[l];
        if c == '0' {
            cnt -= 1;
        }
        while l < s.len() && s[l] == c {
            l += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct PartiallyPersistentUnionFind {
  vector< int > data;
  vector< int > last;
  vector< ll> cost;
  vector< vector< pair< int, int > > > add;
  vector< vector< pair< int, ll > > > add2;

  PartiallyPersistentUnionFind() {}

  PartiallyPersistentUnionFind(int sz, vector<ll> costs) : cost(sz, -1), data(sz, -1), last(sz, 1e9), add(sz), add2(sz) {
    for(auto &vs : add) vs.emplace_back(-1, -1);
    for(auto &vs : add2) vs.emplace_back(-1, (ll)-1);
    for(int i = 0; i < costs.size(); i++) {
        cost[i + 1] = -costs[i];
    }
  }

  bool merge(int t, int x, int y) {
    x = root(t, x);
    y = root(t, y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    cost[x] += cost[y];
    add[x].emplace_back(t, data[x]);
    add2[x].emplace_back(t, cost[x]);
    data[y] = x;
    cost[y] = x;
    last[y] = t;
    return true;
  }

  int root(int t, int x) {
    if(t < last[x]) return x;
    return root(t, data[x]);
  }

  int size(int t, int x) {
    x = root(t, x);
    return -prev(lower_bound(begin(add[x]), end(add[x]), make_pair(t, 0)))->second;
  }
  ll Cost(int t, int x) {
    x = root(t, x);
    return -prev(lower_bound(begin(add2[x]), end(add2[x]), make_pair(t, (ll)0)))->second;
  }

    bool issame(int t, int x, int y){
        return root(t, x) == root(t, y);
    }
};

bool checked[100005];
vector<i_i> pathes[100005];

void bfs(int from, int time) {
    if(checked[from]) return;
    //cout << "checked " << from << endl;
    checked[from] = true;
    for(int i = 0; i < pathes[from].size(); i++) {
        if(time < pathes[from][i].second) return;
        int to = pathes[from][i].first;
        bfs(to, time);
    }
}

int main() {
    //cout.precision(10);
    ll N, M;
    cin >> N >> M;
    vector<ll> X;
    for(int i = 0; i < N; i++) {
        ll in;
        cin >> in;
        X.push_back(in);
    }
    PartiallyPersistentUnionFind uni(100050, X);
    vector<pair<ll, pair<int, int> > >edges;
    for(int i = 1; i <= M; i++) {
        int a, b;
        ll y;
        cin >> a >> b >> y;
        edges.push_back({y, {a, b}});
    }
    sort(edges.begin(), edges.end());
    for(int i = 0; i < M; i++) {
        uni.merge(i, edges[i].second.first, edges[i].second.second);
        int a = edges[i].second.first;
        int b = edges[i].second.second;
        pathes[a].push_back({b, i});
        pathes[b].push_back({a, i});
    }
    int ans = 0;
    for(int i = M - 1; i >= 0; i--) {
        int now = edges[i].second.first;
        if(checked[now]) continue;
        ll limit = edges[i].first;
        if(uni.Cost(i, now) < limit) {
            //cout << "Deleted " << now << " " << limit << endl;
            ans++;
            continue;
        }
        //cout << "Cleared " << now << " " << limit << endl;
        bfs(now, i);
    }
    cout << ans << endl;
    /*
    for(int i = 0; i < M; i++) {
        cout << uni.size(i, 1) << " " << uni.Cost(i, 1) << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 28128
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    int N; cin >> N;
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);

    vector<intmax_t> x(N), y(N);
    for (size_t i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    int sz = 1;
    for (intmax_t i = 1; i <= N; ++i) {
        sz *= i;
    }
    dump(sz);

    vector<int> mat[sz];
    int j = 0;
    do {
        for (auto &ii: idx) {
            mat[j].emplace_back(ii);
        }
        j++;
    } while (next_permutation(idx.begin(), idx.end()));


    long double norm = 0;
    for (int i = 0; i < sz; ++i) {
        for (int j = 0; j < N - 1; ++j) {
            long double x_diff = abs(x[mat[i][j]] - x[mat[i][j + 1]]);
            long double y_diff = abs(y[mat[i][j]] - y[mat[i][j + 1]]);
            norm += sqrt(x_diff * x_diff + y_diff * y_diff);
        }
    }

    norm /= (double) sz;
    cout << fixed << setprecision(12);
    cout << norm << "\n";

    return 0;
}


Measured memory_bytes: 3072
use std::io;
use std::collections::HashMap;
use std::collections::BinaryHeap;
use std::mem;
use std::cmp;


fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

fn read_int() -> i64{
    read_ints()[0]
}

fn getn(n:i64) -> i64{
    for i in  0..32 as i64{
        if (n>>i)%2 == 1{
            return i;
        }
    }
    return 0;
}

fn main(){
    let xs = read_ints();
    let n = xs[0];
    let m = xs[1];

    let c = m * 1900 + (n-m)*100;
    println!("{}",c<<m);
}



/*
DOCS


let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}


use std::mem;

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);


let v = vec![0;2]; // [0,0]

s.chars().nth(i as usize).unwrap();


// priority queue
// https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html
use std::collections::BinaryHeap;
let mut heap = BinaryHeap::new();

heap.push(1);
heap.push(5);
heap.push(2);

assert_eq!(heap.pop(), Some(5));
assert_eq!(heap.pop(), Some(2));
assert_eq!(heap.pop(), Some(1));
assert_eq!(heap.pop(), None);


let mut vs = heap.into_vec();
vs.reverse();



*/


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline

s = input()[:-1]
t = input()[:-1]
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = len(s), len(t)
ans = []

while i>0 and j>0:
    if s[i-1]==t[j-1]:
        ans.append(s[i-1])
        i -= 1
        j -= 1
    else:
        if dp[i-1][j]>dp[i][j-1]:
            i -= 1
        else:
            j -= 1
    
ans.reverse()
print(''.join(ans))

Measured memory_bytes: 144252
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        bool isCon = true;
        while(isCon){
            string tmp = System.Console.ReadLine();
            string[] ab = tmp.Split(' ');
            int a = Convert.ToInt32(ab[0]);
            int b = Convert.ToInt32(ab[1]);
            if(a == 0 && b == 0){
                isCon = false;
            }else{
                for(int i = 0; i<a;i++){
                    for(int j = 0; j < b; j++){
                        if((i+j)%2 == 0){
                            Console.Write("#");
                        }else{
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string str1, str2;
  cin >> str1 >> str2;

  if (str1.at(0) == str2.at(2) && str1.at(1) == str2.at(1) && str1.at(2) == str2.at(0)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	sum := 0
	if B == 1 {
		fmt.Println(0)
		return
	}
	for i := 0; ; i++ {
		if sum >= B {
			fmt.Println(i)
			break
		}
		if i == 0 {
			sum += A
		} else {
			sum += A - 1
		}
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define mem(a,v) memset(a,v,sizeof a)
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define f first
#define s second
#define fr(i,n) for(int j=i;j<n;j++)
#define rev(a) reverse(a.begin(),a.end())
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lb(a,v) lower_bound(all(a),v)
#define ub(a,v) upper_bound(all(a),v)
#define ins(v) insert(v)
#define pb(v) push_back(v)
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define sf1(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
using namespace std;
const int N=2e6+5;
int main()
{
    int x,n,k ;
    map<int,int>mp;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
    }
    int s=sz(mp);
    int arr[s],i=0;
    for(auto x:mp)
        arr[i++]=x.s;
    sort(arr,arr+s);
    int ss=0;
    if(s>k)
        for(int i=0;i<(s-k);i++)
                ss+=arr[i];
    cout<<ss<<endl;
    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 1005

using namespace std;

int main()
{
   ll n,a,b,sum=0;

   scanf("%lld",&n);

   while(n--)
   {
       scanf("%lld %lld",&a,&b);

       sum+=(b-a)+1;
   }

   printf("%lld\n",sum);

    return (0);
}




Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)

ans = 0

until h.all?{|v| v.zero? }
  l = h.find_index{|v| v > 0}
  r = l
  r += 1 while r < h.length && h[r] > 0
  (l...r).each {|i| h[i] -= 1}
  ans += 1
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int N; cin>>N;
    vec A(N+2,0); REP(i,N) cin>>A[i+1];
    int ans = 0;
    REP(i,N+1){
        ans += abs(A[i]-A[i+1]);
    }
    REP(i,N){
        int temp = ans;
        temp += abs(A[i]-A[i+2]);
        temp -= (abs(A[i]-A[i+1])+abs(A[i+1]-A[i+2]));
        Out(temp);
    }
}
  


Measured memory_bytes: 2048
A, B =map(int, input().split())
max_A=(A+1)*25/2
max_B=10*(B+1)
p=int(round(max([A*12.5,B*10])+0.4999999999,0))
print(p if(p<min([(A+1)*25/2, 10*(B+1)]) and not(4<5*A-4*B) and not(5*A-4*B<-5)) else -1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    int a[n],tot=0;
    unordered_map<int,int> m;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    	m[a[i]]++;
    	tot+=a[i];
    }
    int q;
    cin>>q;
    while(q--){
    	int b,c;
    	cin>>b>>c;
    	tot -= b*m[b];
    	tot += c*m[b];
    	m[c] += m[b];
    	m[b] = 0;
    	show(tot);
    }
    return 0;
}

Measured memory_bytes: 7920
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    cout << (x >= 30 ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    LL n,k;cin>>n>>k;

    vector<LL> a(n);
    vector<LL> f(n);
    REP(i,n) cin>>a[i];
    REP(i,n) cin>>f[i];

    SORT_ASC(a);
    sort(ALL(f), greater<LL>());

    LL low = 0;
    LL high = 1e15;

    LL result = 0;

    while(low < high){
        LL mid = (low+high)/2;

        LL train = k;
        REP(i,n){
            LL t = mid/f[i];
            train -= max(a[i]-t,0LL);
        }
        if(train >= 0){
            high = mid;
            result = mid;
        }
        else{
            low = mid+1;
        }
    }

    cout << result << endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

#define ll long long
using namespace std;
const int N = 3e5 + 5;
ll a[N], freq[N];
ll ans1[N], ans2[N];

int32_t main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        freq[a[i]]++;
    }
    ll Ans = 0;
    for (int i = 1; i < N; i++) {
        if (!freq[i]) continue;
        ans1[i] = freq[i] * (freq[i] - 1) / 2;
        Ans += ans1[i];
        freq[i]--;
        if (!freq[i]) continue;
        ans2[i] = freq[i] * (freq[i] - 1) / 2;
    }
    for(int i = 1 ; i <= n ; i++) {
        int cur = a[i];
        ll o_ans = Ans;
        Ans -= ans1[cur];
        Ans += ans2[cur];
        cout << Ans <<"\n";
        Ans = o_ans;
    }
    return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N, M, l, r, A[100001] = {},k=0,ans=0;
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> l >> r;
		A[l-1]++;
		A[r]--;
	}
	for (int i = 0; i < N; i++)
	{
		k += A[i];
		if (k == M)ans++;
	}
	cout << ans;
}


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

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int N, M, tmp;
		cin >> N;
		if( N == 0 ) break;

		vector< vector< int > >data;
		vector< int > plist;
		for(int i = 0; i <= N; i++) plist.push_back(0);

		//データ入力
		for(int i = 0; i < N; i++) {
			cin >> M;
			vector<int> newdata;
			for(int j = 0; j < M; j++) {
				cin >> tmp;
				plist.at( tmp ) ++;
				newdata.push_back( tmp );
			}
			data.push_back( newdata );
		}

		//流出情報取得
		int K;
		int flg = false;
		vector<int> leak;
		cin >> K;
		for(int i = 0; i < K; i++) {
			int tmp;
			cin >> tmp;
			if( plist.at(tmp) == 1 )
				leak.push_back( tmp );
			else if(plist.at(tmp) == 0)
				flg = true;
		}

		//leakは、対応するインデックスの個人情報を1人しか知らない流出番号
		vector<int> suspect;
		for(int i = 0; i <= N; i++)
			suspect.push_back( 0 );

		for(int i = 0; i < data.size(); i++) {
			for(int j = 0; j < data.at(i).size(); j++) {
				for(int k = 0; k < leak.size(); k++) {
					if( data.at( i ).at( j ) == leak.at( k ) ) {
						suspect.at( i + 1 ) ++;
						break;
					}
				}
			}
		}

		vector<int> ans;
		for(int i = 0; i < suspect.size(); i++)
			if( suspect.at(i) > 0 ) ans.push_back( i );

		if( ans.size() == 1 && flg == false ) {
			cout << ans.at( 0 ) << endl;
		} else {
			cout << -1 << endl;
		}

	}

	//while(1){}

	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;

int n,m,r;
const int INF=1e7;
int land[200][200],sea[200][200],z[1000];
typedef pair<int,int> P;
typedef pair<P,int> PP;

struct edge{
	int to,cost;
	inline edge(int t,int c){
		to=t,cost=c;
	}	
};

// ?????????????????????n?????????
priority_queue<P,vector<P>,greater<P> > q;
vector<edge> GS[200],GL[200];
int dl[200][200],ds[200][200];

int main(){


	while(scanf("%d %d",&n,&m),n){
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++) dl[i][j]=ds[i][j]=land[i][j]=sea[i][j]=INF;
			land[i][i]=sea[i][i]=0;
			dl[i][i]=ds[i][i]=0;
			GS[i].clear();
			GL[i].clear();
		}
		
		
		for(int i=0;i<m;i++){
			int x,y,t;
			char c;
			scanf("%d %d %d %c",&x,&y,&t,&c);
			x--; y--;
			if(c=='S'){
				GS[x].push_back(edge(y,t));
				GS[y].push_back(edge(x,t));
				sea[x][y]=min(sea[x][y],t);
				sea[y][x]=min(sea[y][x],t);
			}else{
				GL[x].push_back(edge(y,t));
				GL[y].push_back(edge(x,t));
				land[x][y]=min(land[x][y],t);
				land[y][x]=min(land[y][x],t);
			}
		}
		
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					sea[i][j]=min(sea[i][j],sea[i][k]+sea[k][j]);
					land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
				}
			}
		}
		
		for(int i=0;i<n;i++){
			
			ds[i][i]=0;
			q.push(P(0,i));
			while(!q.empty()){
				
				P p=q.top(); q.pop();
				int cost=p.first,pos=p.second;
				if(ds[i][pos]<cost) continue;
				
				for(int j=0;j<GS[pos].size();j++){
					edge e=GS[pos][j];
					if(ds[i][e.to]>ds[i][pos]+e.cost){
						ds[i][e.to]=ds[i][pos]+e.cost;
						q.push(P(ds[i][e.to],e.to));
					}
				}
				
			}

			dl[i][i]=0;
			q.push(P(0,i));
			while(!q.empty()){
				
				P p=q.top(); q.pop();
				int cost=p.first,pos=p.second;
				if(dl[i][pos]<cost) continue;
				
				for(int j=0;j<GL[pos].size();j++){
					edge e=GL[pos][j];
					if(dl[i][e.to]>dl[i][pos]+e.cost){
						dl[i][e.to]=dl[i][pos]+e.cost;
						q.push(P(dl[i][e.to],e.to));
					}
				}		
			}
		}
			
		scanf("%d",&r);
		for(int i=0;i<r;i++){
			scanf("%d",&z[i]);
			z[i]--;
		}
		
		vector<vector<int> > dp(1001,vector<int>(201,INF));
		dp[0][z[0]]=0;

		int res2=INF;
		for(int i=1;i<r;i++){
			for(int j=0;j<n;j++){
				
				//z[i]???????????????????????¨??°???z[i-1]
				
				for(int k=0;k<n;k++){
					//????????????j?????§?§???????j??????k????????????k??????z[i]?????????				
					dp[i][k]=min(dp[i][k],dp[i-1][j]+dl[z[i-1]][j]+ds[j][k]+dl[k][z[i]]);
					if(i==r-1 && res2>dp[i][k]) res2=dp[i][k];
				}
				
				//????????§?§????
				dp[i][j]=min(dp[i][j],dp[i-1][j]+dl[z[i-1]][z[i]]);
				if(i==r-1 && res2>dp[i][j]) res2=dp[i][j];
			}
		}

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

Measured memory_bytes: 4592
/* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */

#include <iostream>
//#include	 <Windows.h>
using namespace std;

int x,y,z;
int main(){
	//cin>>x>>y;
	//z=x+y;
while(cin>>x>>y){
	z=x+y;
if (z>=0){
 if(z<10){
 	cout<<1<<endl;}
 else
  if(z<100){
  	cout<<2<<endl;}
  else
   if(z<1000){
   	cout<<3<<endl;}
   else
    if(z<10000){
    	cout<<4<<endl;}
    else
     if(z<100000){
     	cout<<5<<endl;}
     else
      if(z<1000000){
      	cout<<6<<endl;}
      else
        cout<<7<<endl;}}

return 0;
}

Measured memory_bytes: 3060