akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}



int main() {
//	freopen("a.in", "r", stdin);
	int n = read(), k = read();
	int z = (n + 1) / 2; 
	puts(z >= k ? "YES" : "NO");


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  char str[30];
  string sri;
  int r = 0;
  bool find = true;
  cin >> sri;
  while(r <= sri.size()){
    str[r] = sri[r];
    for(int i = 0; r > i; i++){
      if(str[i] == str[r]){
        find = false;
        break;
      }
    }
    r++;
  }
  cout << (find ? "yes" : "no") << endl;
}

Measured memory_bytes: 256
#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 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	string s = s1 + s2;

	int len = (int)s.size();

	double num = 0;

	REP(i, len){
		num *= 10;
		num += s[i] - '0';
	}

	REP(i, 317){
		if (i == sqrt(num)){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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


  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  ll a[x],b[y],c[z];
  rep(i,x){
    cin >> a[i];
  }
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];

  ll ab[x*y];
  rep(i,x) rep(j,y) ab[i*x+j]=a[i]+b[j];
  sort(ab, ab+(x*y),greater<ll>());
  vector<ll> abc;
  rep(i,min(k,x*y)){
    rep(j,z){
      abc.pb(ab[i]+c[j]);
    }
  }
  //  rep(i,k*z) cout << abc[i] << endl;
  sort(abc.begin(), abc.end(),greater<ll>());
  rep(i,k) cout << abc[i] << endl;
  
  return 0;
    

}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );

		while(str.contains("ST")){
			if(str.indexOf("T")>str.length()/2-1){
				str = "";
			}else{
				str = str.replace("ST", "");
			}
		}

		System.out.println(str.length());

	}
}


Measured memory_bytes: 36692
#include <iostream>
using namespace std;
int main(){
  int h1, h2, k1, k2, a, b, c, d;
  int point[2];
  cin >> h1 >> h2;
  cin >> k1 >> k2;
  cin >> a >> b >> c >> d;
  point[0] = ((a * h1) + (b * h2) + ((h1 / 10) * c) + ((h2 / 20) * d));
  point[1] = ((a * k1) + (b * k2) + ((k1 / 10) * c) + ((k2 / 20) * d));
  if(point[0] > point[1]){
    cout << "hiroshi" << endl;
  }else if(point[0] < point[1]){
    cout << "kenjiro" << endl;
  }else{
    cout << "even" << endl;
  }
  return 0;
}

Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
# ABC 083 B - Some Sums
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b = [int(s) for s in input().split()]
b.sort(reverse=True)
alice = sum(b[0::2])
bob   = sum(b[1::2])
# print("Alice : {}".format(alice))
# print("Bob   : {}".format(bob))
print(alice - bob)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c){
        cout << a * x + b * y << endl;
        return 0;
    }else if (x < y){
            cout << min(2 * c * x + b * (y - x), 2 * c * y) << endl;
            return 0;
    }else{
        cout << min(2 * c * y + a * (x - y), 2 * c * x) << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,x,y,a[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(;n--;)
	{
		cin>>x>>y;
		if(x*x+y*y<=m*m)s++;
	}
	cout<<s;
}

Measured memory_bytes: 3644
# https://atcoder.jp/contests/abc116/submissions/5667980
# 写経

from heapq import heappush, heappop
import sys

input = sys.stdin.readline

n, k = map(int, input().split())
kind_value = [[] for _ in range(n)]
for _ in range(n):
    t, d = map(int, input().split())
    kind_value[t - 1].append(d)

for lis in kind_value:
    lis.sort()

kind_value = sorted(
    (lis for lis in kind_value if lis),
    key=lambda x: x[-1], reverse=True)

ret = 0
curr = 0
kind = 0
remains = []
for lis in kind_value:
    kind += 1
    if kind > k:
        break
    curr += lis[-1]
    for d in lis[:-1]:
        heappush(remains, d)
        curr += d
    while len(remains) > k - kind:
        curr -= heappop(remains)
    ret = max(ret, curr + kind * kind)

print(ret)


Measured memory_bytes: 20540
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//abc165c

ll ans;
ll a[55],b[55],c[55],d[55];
ll q;

void dfs(ll n,ll m,ll now,vector<ll> v){
    V<ll> vv;
    vv=v;
    vv.push_back(now);
    if(vv.size()==n){
        ll cnt=0;
        rep(i,q){
            if(vv[b[i]]-vv[a[i]]==c[i]){
                cnt+=d[i];
            }
        }
        chmax(ans,cnt);
        return;
    }
    for(ll i=now;i<=m;i++) dfs(n,m,i,vv);
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m>>q;
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    //V<ll> d;
    for(ll i=1;i<=m;i++){
        V<ll> x;
        dfs(n,m,i,x);
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

vector<int> e[100000];
int n,k;
ll ans;
bool visited[100000];

void dfs(int v){
    visited[v]=true;
    int cnt=0;
    for(int i:e[v]){
        if(visited[i]==false){
            if(v==0){
                if((k-1-cnt)<=0){
                    ans=0;
                    return;
                }
                ans=(ans*(k-1-cnt))%MOD;
            }
            else{
                if((k-2-cnt)<=0){
                    ans=0;
                    return;
                }
                ans=(ans*(k-2-cnt))%MOD;
            }
            ++cnt;
            dfs(i);
        }
    }

}

int main(){
    cin>>n>>k;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        --a;--b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    ans=k;
    memset(visited,false,sizeof(visited));
    dfs(0);
    cout<<ans<<endl;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[200100]={0}, i, q, b[100100], c[100100], s[100100]={0};
    map<long long, long long> mp;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        s[0]+=a[i];
    }
    cin >> q;
    for(i=0;i<q;i++){
        cin >> b[i] >> c[i];
    }
    for(i=1;i<=q;i++){
        s[i]=s[i-1]+(c[i-1]-b[i-1])*mp[b[i-1]];
        mp[c[i-1]]+=mp[b[i-1]];
        mp[b[i-1]]=0;
    }
    for(i=1;i<=q;i++){
        cout << s[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 13436
n = int(input())
a = list(map(int,input().split())) + [0]
ans = 0
maxh = a[0] 
for i in range(n):
    if maxh > a[i]:
        ans += maxh - a[i]
        a[i] = maxh
    else:
        maxh = a[i]
print(ans)

Measured memory_bytes: 32372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;
  
int main(){
  ll n, a, b;
  in(n);
  vector<ll> c(n);
  rep(i, n)
    in(c[i]);
  sort(all(c));
  out(c[n - 1]);
  hina;
  a = c[n - 1] / 2ll;
  c[n - 1] = 1000000000000;
  ll left = -1;
  ll mid;
  ll right = n - 1;
  while(right - left > 1){
    mid = (left + right) / 2ll;
    if(c[mid] >= a)
      right = mid;
    else
      left = mid;
  }
  b = c[right];
  if(abs(c[right + 1] - a) < abs(b - a))
    b = c[right + 1];
  if(right > 0){
    if(abs(c[right - 1] - a) < abs(b - a))
      b = c[right - 1];
  }
  out(b);
  memi;
}

Measured memory_bytes: 1024
N,C = gets.split.map(&:to_i)

cs = (1..C).map{ [] }
N.times{
  s,t,c = gets.split.map(&:to_i)
  cs[c-1] << [s, +1]
  cs[c-1] << [t, -1]
}

ts = []
cs.each{ |c| 
  c.sort!
  (0...c.size-1).reverse_each{ |i|
    if c[i][1] == -1 && c[i][0] == c[i+1][0] && c[i+1][1] == 1
      c[i,2] = []
    end
  }
  c.each{ |f,o|
    if o > 0
      ts << [f.to_f - 0.5, o]
    else
      ts << [f.to_f - 0.1, o]
    end
  }
}

ts.sort!

ans = 0
v = 0
ts.each{ |_,o|
  v += o
  #$stderr.puts v
  ans = [ans, v].max
}
puts ans


Measured memory_bytes: 34932
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll absl(ll a)
{
  return a<0?-a:a;
}
int main()
{
 	int n;
  cin >> n;
  //vector<ll> v; 
  int i;
  ll sum=0;
  ll minus_count=0;
  ll mn =INT_MAX;
  for (i=0; i < n; i++)
  {
   ll x;
    cin >> x;
    minus_count += x <0?1:0;
    sum+=absl(x);
    if ( mn > absl(x))
      mn =absl(x);
  }
  if (minus_count %2 ==0)
  {
    cout << sum;
    return 0;
  }
  cout << sum - mn*2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Order = vector<int>;
int pos = 0;
void recon(int left, int right, deque<int> &post, Order pre, Order in) {
  if ((right - left) == 0) return;
  auto root = pre[pos];
  pos += 1;
  auto mid = distance(in.begin(), find(in.begin(), in.end(), root));
  recon(left, mid, post, pre, in);
  recon(mid + 1, right, post, pre, in);
  post.push_back(root);
}
int main() {
  int n;
  cin >> n;
  Order preOrder(n), inOrder(n);
  deque<int> postOrder;

  for (size_t i = 0; i < n; i++) {
    cin >> preOrder[i];
  }

  for (size_t i = 0; i < n; i++) {
    cin >> inOrder[i];
  }
  recon(0, n, postOrder, preOrder, inOrder);
  for (size_t i = 0; i < n; i++) {
    if (i == 0) {
      cout << postOrder[i];
    } else {
      cout << ' ' << postOrder[i];
    }
  }

  cout << endl;
}


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

#define _BIGNUM_ 100000000

using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  ll count1 = 0;
  char first = '0';
  for (char c: S) {
    if (c == '1') {
      count1 += 1;
    } else {
      first = c;
      break;
    }
  }
  if (count1 < K) {
    cout << first << endl;
  } else {
    cout << 1 << endl;
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

multimap<int,int> mp;

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
    //fileIO();
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x,y;
        cin >> x >> y;
        mp.insert({y,x});
    }
    int temp = 0;
    for(auto it : mp)
    {
        temp += it.second;
        if(temp > it.first)
        {
            cout <<"No";
            return 0;
        }
    }
    cout <<"Yes";
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a,b,c;

int main(){
	cin>>a>>b>>c;
	if(a+b>=c){
		cout<<b+c<<endl;
		return 0;
	}else{
		cout<<2*b+a+1<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
//
//  main.cpp
//  atcoder
//
//  Created by 大森亮 on 2016/12/13.
//  Copyright © 2016年 大森亮. All rights reserved.
//

#include <iostream>
using namespace std;

bool dfs(string &S,int n){
    if(n==S.length()){
        return true;
    }
    bool ret = false;
    if(n+5<=S.length()){
        if(S.substr(n,5)=="dream"||S.substr(n,5)=="erase"){
            ret = ret|dfs(S,n+5);
        }
    }
    if(n+6<=S.length()){
        if(S.substr(n,6)=="eraser"){ret = ret|dfs(S,n+6);}
    }
    if(n+7<=S.length()){
        if(S.substr(n,7)=="dreamer"){ret = ret|dfs(S,n+7);}
    }
    return ret;
}

int main(int argc, const char * argv[]) {
    string S;
    cin>>S;
    bool ans = dfs(S,0);
    cout << (ans?"YES":"NO")<<endl;
}


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

if a > b:
    print(0)
elif n == 1 and a != b:
    print(0)
else:
    min_sum = a * (n - 1) + b
    max_sum = a + b * (n - 1)

    print(max_sum - min_sum + 1)


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

#define int long long

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

int h, w;
char b[444][444]; // 盤面
int group[444][444]; // マスがどのグループに含まれるか。マスにグループIDを割り当てて判別する
map<int, int> mp; // mp[グループ番号]: そのグループの'#'が得られるスコア

// `#` -> '.' の順でいける部分を埋めていく
int rec(int y, int x, int t) {
  group[y][x] = t;
  int ret = 0;

  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i], nx = x + dx[i];
    if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
    if (b[y][x] == b[ny][nx]) continue;
    if (group[ny][nx] != 0) continue;
    int cost = (b[ny][nx] == '.' ? 1 : 0); // 異動先が'.'ならスコアが入る
    ret += rec(ny, nx, t) + cost;
  }

  return ret;
}


signed main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> b[i];
  }

  int ans = 0;
  int cnt = 1; // グループ番号
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (b[i][j] == '#') {
        if (group[i][j] == 0) { // マスにグループ番号が割り振られていない場合
          int score = rec(i, j, cnt); // '#'からいける部分にグループ番号を割り当てる。
          ans += score;
          mp[cnt] = score; // グループ番号にスコアを登録する。これは、再計算を防ぐためにある
          cnt++; // グループ番号をインクリメント
        } else { // すでにグループ番号が割り振られている場合
          ans += mp[group[i][j]];
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
using System;

namespace abc170
{
    class Program
    {
        static void Main()
        {
            var xy = Console.ReadLine().Split(' ');
            var x = int.Parse(xy[0]);
            var y = int.Parse(xy[1]);
            if (y >= x * 2 && y <= x * 4 && y % 2 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27164
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600

class BipartiteMatching{
private:
  int n; //????????°
  vector<vector<int> > graph; //??°??????
  vector<int> match; //??????????????°?????¢
  vector<bool> used;
  bool dfs(int v){
    used[v]=true;
    rep(i, graph[v].size()){
      int u = graph[v][i], w = match[u];
      if(w<0 || (!used[w] && dfs(w)) ){
        match[v]=u;
        match[u]=v;
        return true;
      }
    }
    return false;
  }
public:
  BipartiteMatching(int nn) : n(nn){
    graph.resize(n);
    match.resize(n);
    used.resize(n);
  }
  void add_edge(int u, int v){ //0-indexed??§??????????????°????????????
    graph[u].pb(v);
    graph[v].pb(u);
  }
  int matching(){ //??????????????°??°?????????
    int res=0;
    fill(all(match), -1);
    rep(v, n){
      if(match[v]<0){
        fill(all(used), false);
        if(dfs(v)) res++;
      }
    }
    return res;
  }
}; //END class BipartiteMatching

int main(){
  int x,y,e;
  cin>>x>>y>>e;
  BipartiteMatching bm(x+y);

  rep(i,e){
    int a,b;
    scanf("%d %d", &a, &b);
    bm.add_edge(a,x+b);
  }

  cout<<bm.matching()<<endl;

  return 0;
}

Measured memory_bytes: 3388
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 998244353
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int n,s ;
int arr[5005] ;
string str ;
pii dp[3005][3005][2] ;
int power[3005] ;
pii hf(int i,int s,int p)
{
    if(i == n+1)
    {
        if(s == 0)
            return {0,1} ;
        else
            return {0,0} ;
    }
    if(s<0)
    {
        return {0,0} ;
    }
    if(dp[i][s][p].fi!=-1 && dp[i][s][p].se!=-1)
        return dp[i][s][p] ;
    pii mp = {0,0} ;
    if(p == 0)
    {
        pii rp1 = hf(i+1,s,0) ;
        pii rp2 = hf(i+1,s-arr[i],1) ;
        mp.fi = rp1.fi + rp2.fi + rp2.se*power[i-1] ;
        mp.fi%=mod ;
    }
    else
    {
            pii rp1 = hf( i + 1, s, 1);
			pii rp2 = hf( i + 1, s - arr[i], 1);
			mp.fi = rp1.fi + rp2.fi;
			mp.fi %= mod;
			mp.se = rp1.se * 2 + rp2.se;
			mp.se %= mod;
    }
    dp[i][s][p] = {mp.fi,mp.se} ;
    return  {mp.fi,mp.se} ;
}
void solve()
{
    cin >> n >> s ;
    power[0] = 1 ;
    for(int i=1 ; i<=3000 ; i++)
        power[i] = (2*power[i-1])%mod ;
    for(int i=1 ; i<=n ; i++)
        cin >> arr[i] ;
    for(int i=0 ; i<=n ; i++)
    {
        for(int j=0 ; j<=s ; j++)
        {
            for(int k=0 ; k<=1 ; k++)
            {
                dp[i][j][k] = {-1,-1} ;
            }
        }
    }
    pii ans = hf(1,s,0) ;
    cout << ans.fi << "\n" ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}

Measured memory_bytes: 285712
#include <stdio.h>

int main(void)
{
	int N, D, i;
	scanf("%d", &N);
	scanf("%d", &D);
	D = 2 * D + 1;//監視範囲
	i = N / D;
	if (N%D != 0) {
		i++;
	}
	else {}
	printf("%d", i);
}

Measured memory_bytes: 128
// Maximum_Heap.cs

using System;
using System.Text;

class Maximum_Heap {

	public static int cn;

	public static void Main() {

		int n = int.Parse(Console.ReadLine());
		cn = n;
		string[] str = Console.ReadLine().Split(' ');
		int[] num = new int[n + 1];
		
		for(int i = 1; i <= n; i++) {
			num[i] = int.Parse(str[i - 1]);
		}

		buildMaxHeap(num);
	
		StringBuilder str_b = new StringBuilder();
		for(int i = 1; i <= n; i++) {
			str_b.Append(" " + num[i]);
		}

		Console.WriteLine(str_b);
		
	}

	public static void buildMaxHeap(int[] num) {
		for(int i = cn / 2; i >= 1; i--) {
			maxHeapify(num, i);
		}
	}


	public static void maxHeapify(int[] num, int id) {
		
		int l = id * 2, r = id * 2 + 1, largest;

		if(l <= cn && num[l] > num[id])
		largest = l;
		else
		largest = id;

		if(r <= cn && num[r] > num[largest])
		largest = r;

		if(largest != id) {
			int temp = num[id];
			num[id] = num[largest];
			num[largest] = temp;
			maxHeapify(num, largest);
		}
	}

}

Measured memory_bytes: 68960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    int ans = 0;
    
    rep(i, n) {
        rep(ii, n) {
            if (i == ii) {
                continue;
            }
            
            ans += d[i] * d[ii];
        }
    }
    
    cout << (ans / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int i = 1;

    while (i++ < n) {
        int x = i;

        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }

    cout << endl;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int> 
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define um unordered_map<int,int>
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n) 
 vector<int> adj[1000001];    
 int v[1000001]={0};
int32_t main()
{
 int n;
 cin>>n;
 vll a(n);
 for(int i=0;i<n;i++)
 cin>>a[i];
 int dp[100001]={0};
 dp[0]=0;
 dp[1]=abs(a[1]-a[0]);
 for(int i=2;i<n;i++)
 {
   dp[i]=min((dp[i-1]+abs(a[i-1]-a[i])),(dp[i-2]+abs(a[i-2]-a[i])));
 }
 cout<<dp[n-1];
}

Measured memory_bytes: 28264
table = []
r, c = map(int, input().strip().split())
[table.append(input().strip().split()) for i in range(r)]
table.append([])

for j in range(r + 1):
    for k in range(c + 1):
        if j == r and k != c:
            lastrow = sum(map(int, [table[x][k] for x in range(r)]))
            table[-1].append(lastrow)
        if k == c:
            print(sum(map(int, table[j])))
            break
        print(table[j][k],end=' ')

Measured memory_bytes: 8640
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
const long long DAY = 5000000000000000;
string S, ans;
long long K;

void solve() {
    long long i = 0;
    while (S.at(static_cast<unsigned long>(i)) == '1') {
        i++;
        if (i == K) {
            printf("%c\n", '1');
            return;
        }
    }
    printf("%c\n", S.at(static_cast<unsigned long>(i)));
}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int[] array;
    public static void main(String[] args) {
        read();
        solve();
    }

    static void read(){
        array = new int[10];
        for(int i = 0; i < 10; i++){
            array[i] = sc.nextInt();
        }
    }

    static void solve(){
        Arrays.sort(array);
        System.out.println(array[9]);
        System.out.println(array[8]);
        System.out.println(array[7]);
    }

}

Measured memory_bytes: 25980
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
#include <numeric>
#include <map>
using namespace std;

int a[12][12];
const int INF = 1001001001;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    for (int i = 0; i < N; ++i){
        cin >> C.at(i);
        for (int j = 0; j<M;++j){
            cin >> a[i][j];
        }
    }

    int ans = INF;

    for (int s = 0; s <(1 << N); ++s){
        int cost = 0;
        vector<int> d(M);
        for (int i = 0; i < N; ++i){
            if( s>>i & 1){
                cost += C[i];
                for (int j = 0; j < M; ++j){
                    d[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < M; ++j){
            if(d[j]<X){
                ok = false;
            }
        }
        if(ok){
            ans = min(ans, cost);
        }
    }
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    answer = solve(N, A)

    print(answer)


def solve(N, A):
    result = 0
    max_height = A[0]
    for i in range(1, N):
        max_height = max(max_height, A[i])
        if max_height > A[i]:
            result += max_height - A[i]

    return result


if __name__ == "__main__":
    main()


Measured memory_bytes: 32964
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int get_fist_digit(ll a){
  string s = to_string(a);
  char c = s.at(s.size()-1);
  return (int)c - '0';
}

void bfs(int K){
  // 配列を作る
  int N = pow(10, 5);
  vector<ll> ans;
  rep(i, 9){
    ans.push_back(i+1);
  }

  int cnt = 0;
  while(cnt < N) {
    ll num = ans[cnt];
    int digit = get_fist_digit(num);//一桁目をゲットする
    // cout << num << " " << digit << endl;
    if (digit-1 != -1){
      ans.push_back(num*10+digit-1);
    }
    ans.push_back(num*10+digit);
    if(digit+1 != 10){
      ans.push_back(num*10+digit+1);
    }
    
    if (ans.size()>= K) break;
    cnt++;
  }
  // rep(i, 100){
  //   cout << ans[i] << " ";
  // }
  cout << ans[K-1] << endl;
  
}

int main() {
  ll K;
  cin >> K;
  
  bfs(K);
}


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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, m;
    scan(n, m);

    auto adj = new int[][](n, 0);
    auto iri = new int[](n);
    auto de = new int[](n);

    foreach (i ; 0 .. n - 1 + m) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= bi;
        de[ai]++;
        iri[bi]++;
    }

    int root = -1;
    foreach (i ; 0 .. n) {
        if (iri[i] == 0) {
            root = i;
            break;
        }
    }

    debug {
        writeln("iri", iri);
        writeln("de", de);
    }

    auto p = new int[](n);
    p[] = -1;

    void dfs(int v, int par) {
        if (p[v] == -1) p[v] = par + 1;

        foreach (u ; adj[v]) {
            if (u == par) continue;
            iri[u]--;
        }

        foreach (u ; adj[v]) {
            if (u == par) continue;
            if (p[u] != -1) continue;
            debug {
                writefln("v: %d, u:%d, iri: %d", v, u, iri[u]);
            }
            if (iri[u] == 0) {
                dfs(u, v);
            }
        }
    }

    dfs(root, -1);

    foreach (i ; 0 .. n) {
        writeln(p[i]);
    }
}






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

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

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


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

public class Main {

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

		char[] octs;
		while (!(line = br.readLine()).equals("0")) {
			octs = Integer.toOctalString(Integer.parseInt(line)).toCharArray();
			for (int i = 0; i < octs.length; i++) {
				if (octs[i] >= '4')
					octs[i]++;
				if (octs[i] >= '6')
					octs[i]++;
			}
			System.out.println(String.valueOf(octs));
		}
	}
}

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

int main() {
  int W, a, b;

  cin >> W >> a >> b;

  if (a < b) {
    if (a + W < b) cout << b - a - W << endl;
    else cout << 0 << endl;
  }
  else {
    if (b + W < a) cout << a - b - W << endl;
    else cout << 0 << endl; 
  }

  return 0;
}



Measured memory_bytes: 256
function Main(input) {
    var input_arr = input.split("\n");
    var input_arr_line0 = input_arr[0].split(" ");
    var a = parseInt(input_arr_line0[0]);
    var b = parseInt(input_arr_line0[1]);
    if (b % a === 0) {
        console.log(a + b);
    } else {
        console.log(b - a)
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    if(a+b==c || a+c == b || b+c==a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    map<ll, ll> mp;
    REP(i, n){
        ll din; cin >> din;
        mp[din]++;
    } 
    ll m; cin >> m;
    bool flag = true;
    REP(i, m){
        ll tin; cin >> tin;
        if(mp[tin] == 0){
            flag = false;
        }
        else mp[tin]--;
    }
    if(flag) YES();
    else NO();
}

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

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

using namespace std;
int main()
{
    long int t[5];
    long int n;
    string str;
    long int f;

    cin>>str;
    n = stoll(str);
    for(int i = 0;i<5;i++)
    {
        cin>>str;
        t[i] = stoll(str);
    }
    f = t[0];
    for(int i = 1;i<5;i++)
    {
        if(f>t[i])
            f = t[i];
    }

    long int time = 4;
    time += n/f ;
    if(n%f!=0)
        time++;

    cout<<time;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int, int> P;
 
int h, w, ans;
int castle[1001][1001], times[1001][1001];
int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
char beach[1001][1001];
 
int main(){
    scanf("%d%d", &h, &w);
    for(int i = 0; i < h; i++){
        scanf("%s", &beach[i]);
    }
 
    queue<P> Q;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(beach[i][j] == '.'){
                Q.push(P(i, j));
            } else{
                castle[i][j] = beach[i][j] - '0';
            }
        }
    }
 
    while(Q.size()){
        P p = Q.front();
        Q.pop();
        ans = max(ans, times[p.first][p.second]);
 
        for(int i = 0; i < 8; i++){
            int y = p.first + dy[i], x = p.second + dx[i];
            if(y < 0 || y >= h || x < 0 || x >= w){
                continue;
            }
 
            castle[y][x]--;
            if(castle[y][x] == 0){
                Q.push(P(y, x));
                times[y][x] = times[p.first][p.second] + 1;
            }
        }
    }
 
    printf("%d\n", ans);
 
    return 0;
}

Measured memory_bytes: 10040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i, n) cin >> L[i];
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++){
                if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                if (L[i] + L[j] > L[k] &&
                    L[j] + L[k] > L[i] &&
                    L[k] + L[i] > L[j])cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
public class Hello{
    public static void Main(){
        var a = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ans = "";
        Array.Sort(a);
        ans = String.Join(" ",a);
        WriteLine(ans);
    }
}



Measured memory_bytes: 16416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int X = in();
    int maxa = 0;
    REP(i,7){
        for(int j = 1;;j++){
            if(modpow(j,i+2)<=X){
                int tmp = modpow(j,i+2);
                maxa = max(maxa,tmp);
            }else{
                break;
            }
        }
    }
    cout << maxa << "\n";
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    
    int odd = N - (N / 2);
    
    double result = (double) odd / N;
    
    System.out.println(result);
  
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include <iomanip>

using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    std::cout << std::fixed << std::setprecision(10);

    for (int i = 1; i <= n; ++i) {
        int times = 0;
        int x = i;
        for (int j = 0; j < k; ++j) {
            if (x >= k) {
                break;
            } else if (1 <= x && x <= (k - 1)) {
                x *= 2;
                times++;
            }
        }
        double kake = 1;
        for (int l = 0; l < times; ++l) {
            kake /= 2.0f;
        }
        if (times == 0) {
            ans += kake/n;
        } else {
            ans += (kake / (double) (n));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	rep(i, 0, n+1) {
		rep(j, 0, n + 1) {
			if (i + j > k)break;
			int z = k - i - j;
			if (z <= n)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 200005


int main() {
    fastio;
    lli a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
  	int *a = (int*)malloc(n*sizeof(int));
  	int *nxt = (int*)malloc((n+1)*sizeof(int));
  	for(int i = 0; i < n; i++) cin >> a[i];
  	for(int i = 1; i < n; i++) nxt[a[i-1]] = a[i];
  
  int ans = 0;
  	for(int i = 0; i < n; i++) {
      int b;
      cin >> b;
      ans += b;
    }
  	for(int i = 1; i < n; i++) {
      int c;
      cin >> c;
      if(nxt[i] == i+1) ans += c;
    }
  cout << ans;
  free(a);
  free(nxt);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

from math import gcd
L=[A[0]]*N
R=[A[-1]]*N

for a_idx in range(1,len(A)):
    L[a_idx]=gcd(L[a_idx-1],A[a_idx])
    R[len(A)-a_idx-1]=gcd(R[len(A)-a_idx],A[len(A)-a_idx-1])

ans_list=[0]*N
ans_list[0] = R[1]
ans_list[-1] = L[-2]

for a_idx in range(1,len(A)-1):
    ans_list[a_idx] = gcd(L[a_idx-1],R[a_idx+1])
    
print(max(ans_list))

Measured memory_bytes: 24432
#include <stdio.h>

int main(void) {
    int H, W, N, t;
    scanf("%d%d%d", &H, &W, &N);
    if (W>H) {
        t=H;
        H=W;
        W=t;
    }
    printf("%d", (N+H-1)/H);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VI = vector <int>;
using VVI = vector <VI>;

using VLL = vector <long long>;
using VVLL = vector <VLL>;
const long long MOD = 998244353;

template<class T>
class FenwickTree {
    vector <T> sum;
public:
    FenwickTree (int treeSize) {
        sum = move(vector<T>(treeSize+1));
    }

    void addVal(int idx, T val) {
        while (idx < sum.size()) {
            sum[idx] += val;
            sum[idx] %= MOD;
            idx += (idx & (-idx));
        }
    }

    T getVal(int idx) {
        if (idx <= 0) {
            return 0;
        }

        T ret = 0;

        while (idx) {
            ret += sum[idx];
            ret %= MOD;
            idx -= (idx & (-idx));
        }

        return ret;
    }

    T queryRange(int a, int b) {
        return ((getVal(b) - getVal(a-1))%MOD + MOD ) % MOD;
    }
};

int main() {
    int N;
    int K;

    cin >> N >> K;
    VVI V(N, VI(2));
    FenwickTree <long long> ft(N+1);

    for (int i = 0; i < K; ++i) {
        cin >> V[i][0] >> V[i][1];
    }

    ft.addVal(1, 1);

    for (int p = 2; p <= N; ++p) {
        long long res = 0;

        for (int k = 0; k < K; ++k){
            int start = max(1, p-V[k][1]);
            int to = p-V[k][0];

            if (to >= start) {
                res += ft.queryRange(start, to);
                res %= MOD;
            }
        }

        ft.addVal(p, res);
    }

    cout << ft.queryRange(N, N) << endl;

    return 0;
}

Measured memory_bytes: 15688
use std::io::*;

fn main() {
    let n = read_v();
    let mut count = 0;

    for c in &n {
        if *c == '1' {
            count += 1;
        }
    }
    println!("{}", count);
}

fn read_v() -> Vec<char> {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    b
}



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

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

Measured memory_bytes: 256
#include<cstdio>
const int N = 1e5;
int n, k;
int vis[N];
int main() {
	scanf("%d%d", &n, &k);
	while (k--) {
		int m;
		for (scanf("%d", &m); m--; ) {
			int x;
			scanf("%d", &x);
			vis[x]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (!vis[i]) ans++;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1736
n, l = map(int, input().split())

# 味リストはL, L+1, L+2...
tastes = []
for i in range(n):
    tastes += [l+i]

# 味0があったらそれを食えばいい
if 0 in tastes:
    print(sum(tastes))
else:
    # 差が最小なのを食えばいい
    tastes.sort(key=abs)
    print(sum(tastes[1:]))

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#define SIZE(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int main(){
    int k, a, b;
    int c = 0;
    cin >> k >> a >> b;
    for (int i=a; i<=b; i++){
        if (i%k==0){
            c += 1;
        }
    }
    if (c>0){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll n, d; cin >> n >> d;
  vector<pair<ll, ll>> points(n);
  rep (i, n) {
    ll x, y; cin >> x >> y;
    points[i] = {x, y};
  }

  ll ans = 0;
  for (auto p : points) {
    if (p.first*p.first + p.second*p.second <= d*d) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n, INF = 1e18;
	
	LL xRmi = +INF;
	LL xLmi = +INF;
	LL xCmi = +INF;
	LL xRma = -INF;
	LL xLma = -INF;
	LL xCma = -INF;
	LL yUmi = +INF;
	LL yDmi = +INF;
	LL yCmi = +INF;
	LL yUma = -INF;
	LL yDma = -INF;
	LL yCma = -INF;
	
	LL xmi = +INF;
	LL xma = -INF;
	LL ymi = +INF;
	LL yma = -INF;
	
	cin >> n;
	inc(i, n) {
		LL x, y; string d;
		cin >> x >> y >> d;
		x *= 2;
		y *= 2;
		
		setmin(xmi, x);
		setmax(xma, x);
		setmin(ymi, y);
		setmax(yma, y);
		
		if(d == "R") { setmin(xRmi, x); setmax(xRma, x); }
		ef(d == "L") { setmin(xLmi, x); setmax(xLma, x); }
		ef(d == "U") { setmin(yUmi, y); setmax(yUma, y); }
		ef(d == "D") { setmin(yDmi, y); setmax(yDma, y); }
		else { UR; }
		
		if(d == "R" || d == "L") { setmin(yCmi, y); setmax(yCma, y); }
		ef(d == "U" || d == "D") { setmin(xCmi, x); setmax(xCma, x); }
		else { UR; }
	}
	
	LL M = max(xma - xmi, yma - ymi) + 1;
	
	LL ans = INF;
	inc(i, M) {
		xmi = min({ xRmi, xLmi, xCmi });
		xma = max({ xRma, xLma, xCma });
		ymi = min({ yUmi, yDmi, yCmi });
		yma = max({ yUma, yDma, yCma });
		setmin(ans, (xma - xmi) * (yma - ymi));
		
		xRmi++;
		xRma++;
		xLmi--;
		xLma--;
		yUmi++;
		yUma++;
		yDmi--;
		yDma--;
	}
	
	long double z = 4;
	printf("%.6Lf\n", ans / z);
	
	return 0;
}


Measured memory_bytes: 256