akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int  N, K, Q;
    scanf("%d %d %d", &N, &K, &Q);
    vector<int> answerers(Q);
    vector<int> state(N, K-Q);

    rep(i, Q) {
        scanf("%d", &answerers[i]);
        state[answerers.at(i)-1] += 1;
    }
    
    rep(i, N) {
        if (state[i]>0) printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 1408
import sys
import numpy as np
# inputを高速化する。
input = sys.stdin.readline
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
# dpの配列を作る。
dp = np.zeros(n, dtype=int)
# hの配列を作る。
h = np.array(h)
for i in range(1, n):
    # start は負になることはない。
    start = max(0, i-k)
    # 行列として足し算できるのでforを使う必要がない。
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))
print(dp[n-1])

Measured memory_bytes: 38260
import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    c = 2*x/(a*b)
    rad = math.atan(b/c)
    print(math.degrees(rad))
else:
    d = 2*(b-(x/a**2))
    rad = math.atan(d/a)
    print(math.degrees(rad))

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

using namespace std;

void Solve() {
	int n, m;
    cin >> n >> m;

    vector<long long> a(n+1), mars(m+1), mars2(m+1);

    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i]--;
    }

    long long cr = 0;
    long long change = 0;

    for (int i = 1; i < n; ++i) {
        int dist = (a[i+1] - a[i] + m) % m;
        cr += dist;
        mars2[(a[i]+1) % m] -= 1;
        mars2[a[i+1]] += 1;
        mars[a[i+1]] += dist - 1;

        if ((a[i] + 1) % m> a[i+1]) {
            cr -= (m - (a[i] + 1));
            change -= 1;
        }
        // cerr << cr << "\n";
    }

    long long ans = cr;
    // cerr << cr << "\n";
    change += mars2[0];
    cr += mars[0];

    for (int i = 1; i < m; ++i) {
        cr += change;
        ans = min(ans, cr);
        // cerr << cr << "\n";
        change += mars2[i];
        cr += mars[i];
    }

    cout << ans << "\n";
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
}

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

int main() {
    int n, h, w; cin >> n >> h >> w;
    //printf("n=%d, h=%d, w=%d\n", n, h, w);
    //cout << (max(1,n -h + 1)) << endl;
    //cout << (max(1, n -w + 1)) << endl;
    cout << (max(1,n -h+ 1) * max(1, n -w + 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<atcoder/all>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long Int;

int main(){
    int n, m;
    string field[110];
    cin >> n >> m;
    for(int i = 0;i < n;i++){
        cin >> field[i];
    }

    int S = n * m, T = n * m + 1;
    atcoder::mf_graph<int> mf(n*m+2);
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            if(i && field[i][j] == '.' && field[i-1][j] == '.'){
                if((i + j) % 2){
                    mf.add_edge(i * m + j, (i-1) * m + j, 1);
                }
                else{
                    mf.add_edge((i-1) * m + j, i * m + j, 1);
                }
            }
            if(j && field[i][j] == '.' && field[i][j-1] == '.'){
                if((i + j) % 2){
                    mf.add_edge(i * m + j, i * m + j - 1, 1);
                }
                else{
                    mf.add_edge(i * m + j - 1, i * m + j, 1);
                }
            }
            if((i + j) % 2){
                mf.add_edge(S, i * m + j, 1);
            }
            else{
                mf.add_edge(i * m + j, T, 1);
            }
        }
    }
    int mx = mf.flow(S, T);
    for(auto e: mf.edges()){
        if(e.from != S && e.to != T && e.flow == 1){
            int fi = e.from / m, fj = e.from % m;
            int ti = e.to / m, tj = e.to % m;
            if(fi == ti){
                field[fi][min(fj, tj)] = '>';
                field[fi][max(fj, tj)] = '<';
            }
            else{
                field[min(fi, ti)][fj] = 'v';
                field[max(fi, ti)][fj] = '^';
            }
        }
    }
    cout << mx << endl;
    for(int i = 0;i < n;i++)cout << field[i] << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  
  vector<string>S(N);
  vector<int>P(N);
  
  for(int i=0;i<N;i++){
    cin>>S.at(i)>>P.at(i);
  }
  
  vector<pair<string,int>> T(N);
  vector<pair<string,int>> U(N);
  
  for(int i=0;i<N;i++){
    T.at(i)=make_pair(S.at(i),-P.at(i));
      U.at(i)=T.at(i);
  }
  
  sort(T.begin(),T.end());
  
 
   for(int i=0;i<N;i++){
     for(int j=0;j<N;j++){
if(T.at(i)==U.at(j)){
  cout<<j+1<<endl;
}
     }
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



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

  vector<int> h(N);
  int maxHeight = 0;

  for(int i = 0; i < N; i++){
    cin >> h[i];
    if(maxHeight < h[i]){
      maxHeight = h[i];
    }
  }

  int answer = 0;
  for(int j = 0; j< maxHeight; j++){
    bool prevH0 = true;
    for(int i = 0; i < N; i++){
      if(h[i] == 0){
        prevH0 = true;
      } else {
        if(prevH0) answer += 1;
        h[i] -= 1;
        prevH0 = false;
      }
    }
  }

  cout << answer << endl;

  return 0;
}



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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if ( C > (A-B)){
    
  cout << C-(A-B) << endl;
  }
  else {
    cout << '0'<< endl;
  }
}
  
  
 



  
 




Measured memory_bytes: 256
from functools import reduce

# 入力
N = int(input())
S1 = input()
S2 = input()

MOD = 1000000007


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


# (1x2)x2 と (2x1) を1ブロックとみなして、色の塗り方の組合せを数え上げる
ans, _ = reduce(
    lambda acc, s: (
        (3 * acc[0], 3) if acc[1] == 0 and s[0] == s[1] else
        (6 * acc[0], 1) if acc[1] == 0 and s[0] != s[1] else
        (acc[0], 2) if acc[1] == 1 else
        (acc[0], 3) if acc[1] == 2 and s[0] == s[1] else
        (3 * acc[0], 1) if acc[1] == 2 and s[0] != s[1] else
        (2 * acc[0], 3) if acc[1] == 3 and s[0] == s[1] else
        (2 * acc[0], 1)
    ),
    zip(S1, S2),
    (ModInt(1), 0)
)

# 出力
print(ans)


Measured memory_bytes: 3572
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=[10**9+7]*(n)
a[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            a[i]=min(a[i],abs( l[i]-l[i-j])+a[i-j]) 
print(a[-1])


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

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

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

    int n;
    cin >> n;

    vector<double> ls(n);

    for (int i = 0; i < n; ++i) {
        cin >> ls[i];
    }
    double sum = accumulate(ls.begin(), ls.end(), 0.0);
    double max_l = *max_element(ls.begin(), ls.end());
    
    cout << ( sum > max_l * 2? "Yes" : "No" ); 

    return 0;
}

Measured memory_bytes: 256
def dfs(now1, now2, now3, d):
    if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
    res = 10**18
    res = min(res, dfs(now1+l[d], now2, now3, d+1)+10)
    res = min(res, dfs(now1, now2+l[d], now3, d+1)+10)
    res = min(res, dfs(now1, now2, now3+l[d], d+1)+10)
    res = min(res, dfs(now1, now2, now3, d+1))
    
    return res

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
print(dfs(0, 0, 0, 0)-30)

Measured memory_bytes: 45148
import sys
def main():
    for x in sys.stdin:
        if x == "0\n":
            break
        else:
            X = list(x)
            total = 0
            for i in range(len(X) - 1):
                total += int(X[i])
            print(total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int k,s;
  cin >>k>>s;
int count=0;

  for(int i=0;i <=k;i++){
  for(int j=0;j <=k;j++){int x=i,y=j,z=s-x-y;
   if(x+y+z==s && z >=0 && z <=k){
   count++;}
  }
 }
  cout <<count <<endl;
}

Measured memory_bytes: 256
//////////////////////////////
//////////////////////////////
////                      ////
////  Please give me AC!  ////
////  Please give me AC!  ////
////                      ////
//////////////////////////////
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll a,b;
  cin>>a>>b;
  ll c=max(a+b,a-b);
  ll d=max(c,a*b);
  cout<<d<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
double dp[3005],p[3005];
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>p[i];
	dp[1]=p[0];
	dp[0]=1-p[0];
	for(int i=1;i<n;i++)
		for(int j=i+1;j>=0;j--)
			dp[j]=(j==0?0:dp[j-1]*p[i])+(1-p[i])*dp[j];
	double ans=0;
	for(int i=n/2+1;i<=n;i++)
		ans+=dp[i];
	cout<<setprecision(9)<<fixed<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t ni(int64_t x){
  int64_t y;
  y=0;
while(x!=0){if(x%2==1){y++;}
           x=x/2;}
  return y;
}
int64_t san(int64_t z){
  int64_t v;
  v=0;
while(z!=0){z=z%ni(z);
           v++;}
  return v;
}

int main() {
int64_t n,a,ans;
  a=0;
  cin>>n;
  vector<char> kari(n);
  vector<int64_t> vec(n);
 for(int64_t i=0;i<n;i++){
 cin>>kari.at(i);
 }
 for(int64_t i=0;i<n;i++){
 if(kari.at(i)=='0'){vec.at(i)=0;}
    if(kari.at(i)=='1'){vec.at(i)=1;
                       a++;}
 } 
  int64_t b=a-1;
  int64_t c=a+1;
vector<int64_t> rb(n);
vector<int64_t> rc(n);
  rb.at(n-1)=1;
   rc.at(n-1)=1;
for(int64_t i=0;i<n-1;i++){
  if(b==0){break;}
rb.at(n-2-i)=(rb.at(n-1-i)*2)%b;
}
for(int64_t i=0;i<n-1;i++){
rc.at(n-2-i)=(rc.at(n-1-i)*2)%c;
} 
  int64_t ab,ac;
  ab=0;
  ac=0;
    for(int64_t k=0;k<n;k++){
      if(b==0){break;}
      if(vec.at(k)==1){
        ab=(ab+rb.at(k))%b;
      }
      ab+=b;
    }
    for(int64_t k=0;k<n;k++){
      if(vec.at(k)==1){
        ac=(ac+rc.at(k))%c;
      }}
    
for(int64_t i=0;i<n;i++){
  vec.at(i)=1-vec.at(i);
  ans=0;
  if(vec.at(i)==0){
    if(b!=0){ans=(ab-rb.at(i))%b;
  cout<<san(ans)+1<<endl;
  }
  if(b==0){cout<<0<<endl;}
  }
  if(vec.at(i)==1){
    ans=(ac+rc.at(i))%c;
  cout<<san(ans)+1<<endl;
  }
  vec.at(i)=1-vec.at(i);
}
}

Measured memory_bytes: 8216
#include <stdio.h>

int main(void)
{
    int a, b, sum, output;
    
    while(scanf("%d %d", &a, &b) != EOF)
    {
        sum    = a + b;
        output = 1;

        while(sum >= 10)
        {
            sum /= 10;
            output++;
        }

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

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

unordered_map<ll, int> get_primes(ll n) {
    unordered_map<ll, int> facs;
    ll n2 = n;
    for(ll i = 2; i*i <= n; i++) {
        while (n2 % i == 0) {
            facs[i] += 1;
            n2 /= i;
        }
    }
    if (n2 > 1)
        facs[n2] += 1;
    return facs;
}

int main() {
    ll n; cin >> n;
    auto cnt_ops = [](int x) {
        int res = 0, fac = 1;
        while(x > 0) {
            if (x >= fac) {
                x -= fac++;
                res += 1;
            } else {
                break;
            }
        }
        return res;
    };
    unordered_map<ll, int> mp = get_primes(n);
    int ans = 0;
    for(auto& [prime, freq]: mp) {
        // cout << "freq " << freq << endl;
        ans += cnt_ops(freq);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
if __name__ == '__main__':
    a, b = map(int, input().split())
    ans = 0
    alist = []
    blist=[]
    for i in range(1300):
        tax = int(i * 1.08 - i)
        if int(tax) == a:
            alist.append(i)


    for i in range(1100):
        tax = int(i * 1.1 - i)
        if int(tax) == b:
            blist.append(i)

    ablist = set(alist) & set(blist)
    ablist = list(ablist)

    if len(ablist) == 0:
        print(-1)
    else:
        ablist.sort()

        print(ablist[0])


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

int main() {
    string s; cin >> s;
    char hon[5] = {'2', '4', '5', '7', '9'};
    char pon[4] = {'0', '1', '6', '8'};
    for (int i = 0; i < 5; i++) {
        if (s[s.size()-1] == hon[i]) { 
            cout << "hon" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 4; i++) {
        if (s[s.size()-1] == pon[i]) {
            cout << "pon" << endl;
            return 0;
        }
    }
    cout << "bon" << endl;
} 

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

int main() {
    long a;
    long b;

    while(cin >> a >> b) {
        long c = a + b;

        int result = 0;
        do {
            c /= 10;
            result++;
        } while(c != 0);

        cout << result << endl;
    }

    return 0;
}


Measured memory_bytes: 2960
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#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 out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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



int main(){
    char s;
    cin>>s;
    printf("%c\n",s+1);
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static boolean check(String str, char c) {
		for(int i = 0; i < str.length(); i++) if(str.charAt(i) != c) return false;
		return true;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s = sc.next();
		int ans = Integer.MAX_VALUE;

		for(int i = 0; i <= ('z' - 'a'); i++) {
			char goal = (char)('a' + i);
			String now = s;
			int tmp = 0;
			while(!check(now, goal)) {
				String newstr = "";
				for(int j = 0; j + 1 < now.length(); j++) {
					if(now.charAt(j) == goal || now.charAt(j + 1) == goal) newstr += goal;
					else newstr += now.charAt(j);
				}
				now = newstr;
				tmp++;
			}
			ans = Math.min(tmp, ans);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 42836
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(Number);
var n = input.shift();
var minimum = input[0];
var maximum = -Math.pow(10, 9) * 2;

for (var i = 1; i < input.length; i++) {
  maximum = Math.max(maximum, input[i] - minimum);
  minimum = Math.min(minimum, input[i]);
}

console.log(maximum);

Measured memory_bytes: 35940
#include<stdio.h>
 
int main (void){
 
    int N_num;
    int K_num;
    int dp[258][3][2]={{{0}}};
 
    int i,j,k,l;
    int date,kind;
    int ans=0;
 
    scanf("%d%d",&N_num,&K_num);
 
    for(i=0;i<N_num;i++){
        for(j=0;j<3;j++){
            for(k=0;k<2;k++){
                dp[i][j][k]=0;
            }
        }
    }
    for(i=0;i<3;i++)dp[0][i][0]=1;
 
    for(i=0;i<K_num;i++){
        scanf("%d%d",&date,&kind);
        for(j=0;j<3;j++){
            if(j!=kind-1){
                for(k=0;k<2;k++){
                    dp[date-1][j][k]=-1;
                }
            }
        }
    }
    for(i=0;i<N_num;i++){
        for(j=0;j<3;j++){
            if(dp[i][j][0]!=-1){
                for(k=0;k<2;k++){
                    switch(k){
                    case 0:
                        for(l=0;l<3;l++){
                            if(j==l){
                                if(dp[i+1][l][1]!=-1){
                                    dp[i+1][l][1]+=dp[i][j][0];
                                    dp[i+1][l][1]%=10000;
                                }
                            }else{
                                if(dp[i+1][l][0]!=-1){
                                    dp[i+1][l][0]+=dp[i][j][0];
                                    dp[i+1][l][0]%=10000;
                                }
                            }
                        }
                        break;
                    case 1:
                        for(l=0;l<3;l++){
                            if(j==l){
                            }else{
                                if(dp[i+1][l][0]!=-1){
                                    dp[i+1][l][0]+=dp[i][j][1];
                                    dp[i+1][l][0]%=10000;
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
    }
 
 
    /*for(j=0;j<3;j++){
        printf("###");
        for(i=0;i<N_num;i++){
            for(k=0;k<2;k++){
                printf("%3d",dp[i][j][k]);
            }
            printf(" ");
        }
        puts("");
    }*/
 
 
    for(i=0;i<3;i++){
        for(j=0;j<2;j++){
            if(dp[N_num-1][i][j]!=-1){
                ans+=dp[N_num-1][i][j];
                ans%=10000;
            }
        }
    }
    printf("%d\n",ans);
 
    return 0;
}

Measured memory_bytes: 600
def abc110_b():
    _, _, x, y = map(int, input().split())
    city_x = list(map(int, input().split()))
    city_y = list(map(int, input().split()))
    if max(city_x) < min(city_y):
        for i in range(max(city_x), min(city_y)+1):
            if x >= i or i > y:
                return "War"
        return "No War"
    else:
        return "War"


print(abc110_b())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using lint=long long;
void err(){
    std::cout<<"Impossible"<<'\n';
    exit(0);
}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint i=0;i<n;i++){
        lint x;std::cin>>x;
        if(n<=x)err();
        a.at(x)++;
    }
    lint max=0;
    for(lint i=0;i<n;i++){
        if(a.at(i))max=i;
    }
    if(max==1&&n!=2)err();
    lint min=(max+1)/2;
    for(lint i=1;i<min;i++){
        if(a.at(i))err();
    }
    if(a.at(min)!=max%2+1)err();
    for(lint i=min+1;i<=max;i++){
        if(a.at(i)<2)err();
    }
    std::cout<<"Possible"<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[111][111];
int dp[2][111][111][111];
int sum1[111][111],sum2[111][111];
int query1(int i,int l,int r)
{
	return sum1[i][r]-sum1[i][l-1];
}
int query2(int i,int l,int r)
{
	return sum2[r][i]-sum2[l-1][i];
}
int main()
{
	int n,m,sx,sy;
	int ans=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]=='E')
			{
				sx=i;
				sy=j;
			}
	for(int i=1;i<=n;i++)
	{
		sum1[i][0]=0;
		for(int j=1;j<=m;j++)
			sum1[i][j]=sum1[i][j-1]+(s[i][j]=='o');
	}
	for(int j=1;j<=m;j++)
	{
		sum2[0][j]=0;
		for(int i=1;i<=n;i++)
			sum2[i][j]=sum2[i-1][j]+(s[i][j]=='o');
	}
	int now=0,to=1;
	memset(dp,0,sizeof(dp));
	for(int l=0;l<sy;l++)
	{
		for(int r=0;r<=m-sy;r++)
			for(int u=0;u<sx;u++)
				for(int d=0;d<=n-sx;d++)
				{
					ans=max(ans,dp[now][r][u][d]);
					if(sy-l-1>r)
						dp[to][r][u][d]=max(dp[to][r][u][d],dp[now][r][u][d]+query2(sy-l-1,max(sx-u,d+1),min(sx+d,n-u)));
					if(sy+r+1<=m-l)
						dp[now][r+1][u][d]=max(dp[now][r+1][u][d],dp[now][r][u][d]+query2(sy+r+1,max(sx-u,d+1),min(sx+d,n-u)));
					if(sx-u-1>d)
						dp[now][r][u+1][d]=max(dp[now][r][u+1][d],dp[now][r][u][d]+query1(sx-u-1,max(sy-l,r+1),min(sy+r,m-l)));
					if(sx+d+1<=n-u)
						dp[now][r][u][d+1]=max(dp[now][r][u][d+1],dp[now][r][u][d]+query1(sx+d+1,max(sy-l,r+1),min(sy+r,m-l)));
					dp[now][r][u][d]=0;
				}
		swap(now,to);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 11008
//??°??????????????????????????? -> C??????????????¨????????????C????±??????£?????????D???C????????£?????????????????£???????´???????????????§2??????A,B????????????????????????

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int n;
int data[1000];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> data[i];
	sort(data, data + n);
	
	double maxval = 0;
	for (i = 1; i < n - 2; i++) {
		maxval = max(maxval, (double)(data[n - 1] + data[n - 2]) / (data[i] - data[i - 1]));
	}
	maxval = max(maxval, (double)(data[n - 1] + data[n - 4]) / (data[n - 2] - data[n - 3]));
	maxval = max(maxval, (double)(data[n - 3] + data[n - 4]) / (data[n - 1] - data[n - 2]));
	
	printf("%.14f\n", maxval);
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>
 
int main (void)
{
  int a,b,c;
  
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  
  if((a==b&&b!=c)||(a!=b&&b==c)||(a==c&&a!=b))
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;

const int N=100005;
const int inf=1000000000; 

struct E{
	int to,next;
}mem[N<<1];
int n,x,y,rt,num,ans,all;
int d[N],head[N],sz[N],tag[N],vis[N],dp[N],sum[N];
char s[N];
vector<int> lev[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs1(int k,int pre){
	int j,u;
	sz[k]=1;
	if (s[k]=='B') sum[k]=1;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs1(u,k);
		sz[k]+=sz[u];
		sum[k]+=sum[u];
	}
	if (sz[k]==sum[k]) vis[k]=1;
	if (sz[k]!=sum[k]){
		for (j=head[k];j;j=mem[j].next){
			u=mem[j].to;
			if (u==pre) continue;
			if (!vis[u]){
				lev[k].push_back(u);
				lev[u].push_back(k);
				d[k]++; d[u]++;
			}
		}
	}
}

void dfs2(int k,int pre){
	int j,u,mx1,mx2; mx1=mx2=-inf;
	if (tag[k]) dp[k]=1;
	else dp[k]=-1;
	dp[k]++;
	for (j=0;j<lev[k].size();j++){
		u=lev[k][j];
		if (u==pre) continue;
		dfs2(u,k);
		mx2=max(mx2,dp[u]);
		if (mx2>mx1) swap(mx1,mx2);
	}
	if (mx1!=-inf&&mx2!=-inf) ans=max(ans,mx1+mx2+dp[k]);
	if (mx1!=-inf){
		ans=max(ans,mx1+dp[k]);
		dp[k]=mx1+dp[k];
	}
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	scanf("%s",s+1);
	for (i=1;i<=n;i++)
		if (s[i]=='W'){
			rt=i;
			break;
		}
	if (!rt){
		printf("0\n");
		return 0;
	}
	dfs1(rt,0);
	for (i=1;i<=n;i++) if (!vis[i]){
		tag[i]=0; all++;
		if ((s[i]=='W'&&d[i]%2==0)||(s[i]=='B'&&d[i]%2==1)) tag[i]=1;
	}
	all=(all-1)*2;
	for (i=1;i<=n;i++) all+=tag[i];
	dfs2(rt,0);
	printf("%d\n",all-ans);
	return 0;
} 


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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(), p.end());
  int Z=p.at(K-1)-p.at(0);
  for(int i=1;i<=N-K;i++){
    Z=min(Z,p.at(K+i-1)-p.at(i));
  }
  cout<<Z<<endl;
}

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

int main() {
  char c;
  cin >> c;
  if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant";
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int ll
using namespace std;
using ll = long long ;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
//#define endl '\n'
///       Author
///        ::
///    (  NOBODY  )
///   No Copyright .....You can copy and paste it without my permission...................................
///    Another Loser...........
/// !!!!!!!!!!!!!!!
#define pb push_back
#define N 1000020
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

int32_t main()
{


    int a,mx=0,c,x;
     cin>>a;
     map<string ,int>mp;
    for(int i=0; i<a; i++)
    {   string s;
        cin>>s;
        mp[s]++;
        mx=max(mx,mp[s]);
    }
    for(auto c:mp)
    {
      if(c.ss==mx)cout<<c.ff<<endl;
    }
    return 0;
}



Measured memory_bytes: 25216
#include<stdio.h>
#include<stdlib.h>
#define size 100005
main()
{
	long int i,n,count=0;
	scanf("%ld",&n);
	long int a[size];
	long int b[size];
	for(i=0;i<n+1;++i)
	{
		scanf("%ld",&a[i]);
	}
	for(i=0;i<n;++i)
	{
		scanf("%ld",&b[i]);
	}
for(i=0;i<n;++i)
{
    if(((a[i]+a[i+1])==b[i]) || ((a[i]+a[i+1])<b[i]))
	{
	    count+=(a[i]+a[i+1]);
		a[i]=0;
		a[i+1]=0;	
	}
	else
	{
	      if(a[i]>b[i] || a[i]==b[i])
		  {
		    a[i]=a[i]-b[i];	
		  }
		  else
		  {
		  	a[i+1]=a[i+1]-(b[i]-a[i]); 	
		    a[i]=0;
		  }
		  count+=b[i];	
	}	
}
printf("%ld",count);
}

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


typedef long long ll;
template<class V, int NV> class SegTree {
public:
	static V const def = (1LL << 31) - 1;
	V comp(V l, V r) { return min(l, r); };

	vector<V> val;
	SegTree() { val = vector<V>(NV * 2, def); }

	V getval(int l, int r) { //[l,r]
		l += NV; r += NV + 1;
		V ret = def;
		while (l < r) {
			if (l & 1) ret = comp(ret, val[l++]);
			if (r & 1) ret = comp(ret, val[--r]);
			l /= 2; r /= 2;
		}
		return ret;
	}
	void update(int i, V v) {
		i += NV;
		val[i] = v;
		while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
	}
};
int N, T;
int A[101010];
SegTree<ll, 1 << 20> st;
//-----------------------------------------------------------------
int main() {
	cin >> N >> T;
	rep(i, 0, N) scanf("%d", &A[i]);

	rep(i, 0, N) st.update(i, A[i]);

	int m = 0;
	int ans = 0;
	rep(i, 1, N) {
		int mm = st.getval(0, i - 1);
		int d = A[i] - mm;
		if (d < 0) continue;
		if (m < d) {
			m = d;
			ans = 1;
		}
		else if (m == d) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 17024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
N = parseInt(readline())

ac = 0
wa = 0
tle = 0
re = 0
for _ in 1:N
    s = chomp(readline())
    if s == "AC"
        ac += 1
    elseif s == "WA"
        wa += 1
    elseif s == "RE"
        re += 1
    else
        tle += 1
    end
end


println("AC x $(ac)")
println("WA x $(wa)")
println("TLE x $(tle)")
println("RE x $(re)")
end


main()

Measured memory_bytes: 190068
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]

if K > max(A):
    print('IMPOSSIBLE')
    exit()
if K in A:
    print('POSSIBLE')
    exit()

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

gcd_ = A[0]
for a in A[1:]:
    gcd_ = gcd(gcd_, a)

if K % gcd_ == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <map>

using std::cout;
using std::cin;

int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    
    if (d2 == 1)
        cout << 1;
    else
        cout << 0;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=5005;
const LL INF=1e16;
int n;
int p[N];
LL a,b;
int c[N][N][2];
LL dp[N];
int main(){
	n=read(),a=read(),b=read();
	For(i,1,n)
		p[i]=read();
	p[n+1]=n+1;
	For(i,0,n+1){
		Fod(j,i-1,0)
			c[i][j][0]=c[i][j+1][0]+(p[j]>p[i]);
		For(j,i+1,n+1)
			c[i][j][1]=c[i][j-1][1]+(p[j]<p[i]);
	}
	For(i,0,N-1)
		dp[i]=INF;
	dp[0]=0;
	For(i,0,n){
		if (dp[i]==INF)
			continue;
		For(j,i+1,n+1)
			if (p[j]>p[i]&&c[j][i][0]+c[i][j][1]==j-i-1)
				dp[j]=min(dp[j],dp[i]+b*c[i][j][1]+a*c[j][i][0]);
	}
	cout<<dp[n+1]<<endl;
	return 0;
}

Measured memory_bytes: 195840
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print(b - (a + b) // 2)
else:
    # 折り返して会いにいく
    ans = 0
    if a - 1 < n - b:
        ans = a
        a, b = 1, b - a
    else:
        ans = n - b + 1
        a, b = a + (n - b) + 1, n
    print(b - (a + b) // 2 + ans)



Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int x,y,tmp;
	while(scanf("%d %d",&x,&y)){
		if(x==0 && y==0) break;
		if(x>y){
			tmp=x;
			x=y;
			y=tmp;
		}
		printf("%d %d\n",x,y);
	}
		return 0;
}
			

Measured memory_bytes: 600
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;

void solve() {
    unordered_map<char, int> mp;
    mp['a'] = 0, mp['b'] = 0, mp['c'] = 0;
    rep(i, S.length()) {
        mp[S[i]]++;
    }
    int i_max = 0, i_min = i_inf;
    each(i, mp) {
        i_max = max(i.second, i_max);
        i_min = min(i.second, i_min);
    }
    if (abs(i_max - i_min) <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    cin >> S;
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define ll long long

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

//int c=0;
int maxHappy(vector<vector<int>> &a,vector<vector<int>> &dp,int n,int i,int j)
{
	if(i>=n)
	{
		return 0;
	}
	if(dp[i][j]!=-1)
	{
		//c++;
		return dp[i][j];
	}
	int m=0;
	for(int k=0;k<3;k++)
	{
		if(k!=j)
		{
			m=max(m,a[i][k]+maxHappy(a,dp,n,i+1,k));
		}
	}
	return dp[i][j]=m;
}

int main()
{
	fastio
	int n,i,j;
	cin>>n;
	vector<vector<int>> a(n,vector<int>(3));
	vector<vector<int>> dp(n,vector<int>(4,-1));
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	int ans=0;
	ans=maxHappy(a,dp,n,0,3);
	cout<<ans;
}


Measured memory_bytes: 23456
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if (!(a%2)||!(b%2)||!(c%2)) printf("0");
	else 
	   printf("%lld",min(min(a*b,b*c),c*a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n;
    ll d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    fo(i, n){
        ll x, y;
        cin >> x>> y;
        if (x*x + y*y <= d) {
            ans++;
        }
    }
    cout << ans;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
const int M=25;
long double a[N];
int num[N];
int tf[M][M]={0};
int num_2,num_5,ans=0,n;
void get(int y)
{
	int x=y;
    num_2=num_5=0;
    while (x%2==0)
    {
        num_2++;
        x=x/2;
    }
    x=y;
    while (x%5==0)
    {
        num_5++;
        x=x/5;
    }
}
signed main()
{
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    long double t=1e9;
    for (int i=1;i<=n;i++) a[i]=a[i]*t;
    for (int i=1;i<=n;i++) num[i]=a[i]+0.99;
    for (int i=1;i<=n;i++)
    {
        get(num[i]);
        num_2=min(18LL,num_2),num_5=min(18LL,num_5);
        //有ttwo个2，ffive个5
        for (int i=18-num_2;i<=18;i++)
            for (int j=18-num_5;j<=18;j++) ans+=tf[i][j];
        tf[num_2][num_5]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8420
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

int main(void){
  double a, b, x;
  double ans;
  cin >> a >> b >> x;
  
  if(x <= a*a*b/2.0){
   ans = 90 - atan((2.0*a* (x/(a*a*b)) )/b) * (180/M_PI);
  }else{
   ans = atan((2.0*b* ( ((a*a*b)-x) / (a*a*b)) ) /a) * (180/M_PI);
  }
  
  cout << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split(' '))

def gcd(x, y):

    if x <= y:
        if y % x == 0:
            return x
        else:
            return gcd(y % x, x)
    else:
        if x % y == 0:
            return y
        else:
            return gcd(x % y, y)

    return 0

def lcm(x, y):
    return x * y // gcd(x, y)

e = lcm(c, d)

ans = (b - a + 1) - (((b // c) + (b // d) - (b // e)) - (((a - 1) // c) + ((a - 1) // d) - ((a - 1) // e)))

print(ans)

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

x = []
for i in range(A, B, 1):
  x.append(i)
y = []
for j in range(C, D, 1):
  y.append(j)
  
z = x + y

z_duplicate = [k for k in set(z) if z.count(k) > 1]
print(len(z_duplicate))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

LL N, K;
VLL Ap, A0, Am;
LL Aps, A0s, Ams;

LL calc(LL x) {
	LL ans = 0;
	for (LL n = 0; n < Aps;n++) {
		LL s = n, e = Aps;
		while (e - s > 1) {
			LL m = (e + s) / 2;
			if (Ap[m] * Ap[n] <= x)s = m;
			else e = m;
		}
		ans += s - n;
	}
	if (x >= 0) {
		ans += A0s * Aps;
		ans += A0s * (A0s - 1) / 2;
	}
	for (LL n = 0; n < Ams; n++) {
		LL s = n, e = Ams;
		while (e - s > 1) {
			LL m = (e + s) / 2;
			if (Am[m] * Am[n] > x)s = m;
			else e = m;
		}
		ans += Ams - e;
		if (x >= 0) {
			ans += A0s;
		}
		s = -1, e = Aps;
		while (e - s > 1) {
			LL m = (e + s) / 2;
			if (Am[n] * Ap[m] > x)s = m;
			else e = m;
		}
		ans += Aps - e;
	}
	return ans;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N >> K;
	for (LL n = 0; n < N; n++) {
		LL a;
		cin >> a;
		if (a > 0)Ap.push_back(a);
		else if (a == 0)A0.push_back(a);
		else Am.push_back(a);
	}
	sort(Ap.begin(), Ap.end(), [](LL a, LL b) {
		return a < b;
	});
	sort(Am.begin(), Am.end(), [](LL a, LL b) {
		return a < b;
	});
	Aps = Ap.size();
	Ams = Am.size();
	A0s = A0.size();
	LL s = -1e18;
	LL e = 1e18;
	//(積<=sの組数) < K <= (積<=eの組数)
	while (e - s > 1) {
		LL m = (e + s) / 2;
		LL c = calc(m);
		if (c < K)s = m;
		else e = m;
	}
	cout << e << "\n";
	return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;


const int MAX_V = 15;

void init(int m[MAX_V][MAX_V]){
	rep(i,MAX_V) rep(j,MAX_V) m[i][j] = INF;
	rep(i,MAX_V) m[i][i] = 0;
}

void warshallFloyd(int m[MAX_V][MAX_V], int n){
	rep(k,n){
		rep(i,n){
			rep(j,n){
				m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
			}
		}
	}
}

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

	int c[MAX_V][MAX_V];
	init(c);
	rep(i,10){
		rep(j,10){
			cin >> c[i][j];
		}
	}
	warshallFloyd(c,10);

	int sum = 0;
	rep(i,h){
		rep(j,w){
			int a;
			cin >> a;
			if(a == -1) continue;
			sum += c[a][1];
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 384
// AtCoder Beginner Contest 084
// D - 2017-like Number
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    ll N, C, K; cin >> N >> C >> K;
    vll T(N); cin >> T;
    sort(all(T));
    int ans = 1;

    int p = 0;
    int c = 0;
    ll t0 = T[0];
    while (p < N) {
        c++;
        if (c > C || T[p] > t0 + K) { //cout << p << endl;
            ans++;
            t0 = T[p];
            c = 1;
        }
        p++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st;
	    TreeSet<String> set;
	    while((st=sc.readLine())!=null){
		int hit = 0, blow = 0;
		set = new TreeSet<String>();
		String[] a = st.split(" ");
		String[] b = sc.readLine().split(" ");
		for(int i=0; i<4; i++)
		    set.add(a[i]);
		for(int i=0; i<4; i++)
		    if(a[i].equals(b[i])){
			hit++;
			set.remove(a[i]);
		    }
		for(int i=0; i<4; i++)
		    if(set.contains(b[i]))
			blow++;
		System.out.println(hit+" "+blow);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 16900
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        if(i%15!=0){
            if(i%3!=0){
                if(i%5!=0)ans+=i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
h,w = map(int,input().split())
s = [input() for _ in range(h)]
vec = {(-1, 0), (0, -1), (1,0), (0,1)}
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      b = False
      for v in vec:
        ii = i+v[0]
        jj = j+v[1]
        if 0 <= ii <= h-1 and 0 <= jj <= w-1 and s[ii][jj] == '#':
          b = True
          break
      if not b:
        print('No')
        exit()
print('Yes')        

Measured memory_bytes: 3064
N, M = (int(i) for i in input().split())
L = []
for i in range(N):
  a, b = (int(i) for i in input().split())
  L.append((a, b))
L.sort()
ans = 0
for a, b in L:
  if M >= b:
    ans += a*b
    M -= b
  else:
    ans += M*a
    break
print(ans)

Measured memory_bytes: 54872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int x[8],y[8],ax[8],ay[8];
bool used[8];
void dfs(int cur){
    if(cur==8){
        rep(i,8) ax[i]=x[i],ay[i]=y[i];
        return;
    }
    int ty=0;
    while(used[ty]) ++ty;
    rep(i,8){
        bool flag=true;
        rep(j,cur){
            if(i==x[j]) flag=false;
            if(abs(ty-y[j])==abs(i-x[j])) flag=false;
        }
        if(flag){
            x[cur]=i,y[cur]=ty;
            used[ty]=true;
            dfs(cur+1);
            used[ty]=false;
        }
    }
}
string s[8];
int main(){
    int k;
    cin>>k;
    rep(i,k){
        cin>>y[i]>>x[i];
        used[y[i]]=true;
    }
    dfs(k);
    rep(i,8)rep(j,8) s[i]+='.';
    rep(i,8) s[ay[i]][ax[i]]='Q';
    rep(i,8) cout<<s[i]<<endl;
    return 0;
}


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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

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

#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

const cpp_int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<cpp_int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  cpp_int res = 0;
  cpp_int power_of_two = 1;
  for (int i = 0; i < 60; ++i) {
    cpp_int one = 0;
    for (cpp_int &element : arr) {
      if (element % 2 == 1) {
        one++;
      }
      element /= 2;
    }
    cpp_int zero = n - one;
    res = (res + power_of_two * one * (n - one)) % MOD;
    power_of_two = (power_of_two * 2) % MOD;
  }
  cout << res << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n,m;
  while(RD(m,n) && (n||m)) { 
    vector<P> v[n][m];
    rep(i,n*2-1) {
      if(!(i%2)) {
	int k=m-1,x;
	rep(j,k) {
	  cin >> x;
	  if(!x) {
	    v[i/2][j].pb(P(i/2,j+1));
	    v[i/2][j+1].pb(P(i/2,j));
	  }
	}
      } else {
	int k=m,x;
	rep(j,k) {
	  cin >> x;
	  if(!x) {
	    v[i/2][j].pb(P(i/2+1,j));
	    v[i/2+1][j].pb(P(i/2,j));
	  }
	}
      }
    }
    int d[n][m];
    memset(d,0,sizeof(d));
    d[0][0]=1;
    queue<P> que;
    que.push(P(0,0));
    while(!que.empty()) {
      P p=que.front();que.pop();
      int nx=p.F,ny=p.S;
      rep(i,v[nx][ny].size()) {
	P q=v[nx][ny][i];
	int x=q.F,y=q.S;
	if(!d[x][y]) {
	  d[x][y]=d[nx][ny]+1;
	  que.push(P(x,y));
	}
      }
    }
    pr(d[n-1][m-1]);
  }
  return 0;
}


Measured memory_bytes: 1284
LIMIT = 10 ** 18
n = gets.to_i
a = gets.split.map(&:to_i)
prod = 1
if a.include?(0)
  prod = 0
else
  a.each do |v|
    prod *= v
    if prod > LIMIT
      prod = -1
      break
    end
  end
end
puts prod


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   deque<char> s;
   string v;
   int q, t, f, cnt = 0;
   char c;
   cin >> v;

   rep(i, 0, v.size())
       s.emplace_back(char(v[i]));

   cin >> q;
   rep(i, 0, q)
   {
      cin >> t;
      if (t == 1)
         ++cnt;
      else
      {
         cin >> f >> c;
         if (cnt % 2 == 0)
         {
            if (f == 1) s.insert(s.begin(), c);
            else s.insert(s.end(), c);
         }
         else
         {
            if (f == 1) s.insert(s.end(), c);
            else s.insert(s.begin(), c);
         }
      }
   }

   if (cnt % 2 == 0)
   {
      for (auto itr = s.begin(); itr != s.end(); ++itr) cout << *itr;
   }
   else
   {
      for (auto itr = s.rbegin(); itr != s.rend(); ++itr) cout << *itr;
   }
   cout << '\n';
}

Measured memory_bytes: 976
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main(){
	int X;
	scanf("%d",&X);

	int ans;
	ans = 24+(24-X);

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll X;
    cin >> X;
    cout << X/500*1000+X%500/5*5;
    return 0;
}


Measured memory_bytes: 256