akhauriyash/Code-Regression huggingface dataset:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from collections import Counter
N, K = MI()
add = Counter([])

for _ in range(N):
    a, b = MI()
    tmp = add[a]
    add[a] = b
    add[a] += tmp

num = sorted(list(add.keys()))
cnt = 0

for n in num:
    cnt += add[n]
    if cnt >= K:
        print(n)
        break

Measured memory_bytes: 81308
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define MOD 1000000007
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n;
    cin >> n;
    set<ll> st;
    int ans = 0;
    ll a;
    imfor(i, n) {
        cin >> a;
        if (st.find(a) != st.end()) {
            st.erase(a);
            ans--;
        }
        else {
            st.insert(a);
            ans++;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> s(h, vector<int>(w, 0));
    string ss;
    for(int ih=0;ih<h;ih++) {
        cin >> ss;
        for(int iw=0;iw<w;iw++) {
            if(ss[iw]=='0') s[ih][iw] = 0;
            else s[ih][iw] = 1;
        }
    }

    int ans = 2000;
    bool flg;
    for(int ihs=0;ihs<(1<<(h-1));ihs++) {
        int cnt = 0, g = 0;
        flg = true;
        vector<int> id(h);
        for(int ih=0;ih<h;ih++) {
            id[ih] = g;
            if((ihs>>ih)&1) g++;
        }
        g++;

        vector<vector<int>> c(g, vector<int>(w, 0));
        for(int ih=0;ih<h;ih++) {
            for(int iw=0;iw<w;iw++) {
                c[id[ih]][iw] += s[ih][iw];
            }
        }

        vector<int> bfr(g);
        cnt = g - 1;
        bool flgbfr;
        for(int iw=0;iw<w;iw++) {
            flgbfr = false;
            for(int ig=0;ig<g;ig++) {
                if(c[ig][iw]>k) { 
                    flg = false;
                }
                else if (bfr[ig]+c[ig][iw]>k) {
                    flgbfr = true;
                }
                else {
                    bfr[ig] += c[ig][iw];
                }
            }
            if(flgbfr) {
                cnt++;
                for(int ig=0;ig<g;ig++) {
                    bfr[ig] = c[ig][iw];
                }
            }
        }
        if(flg) ans = min(ans, cnt);
    }

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


Measured memory_bytes: 3668
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ans={}
    ans["AC"]=0
    ans["WA"]=0
    ans["TLE"]=0
    ans["RE"]=0
    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    for i in range(n):
        s=readline().rstrip()
        ans[s]+=1
    print("AC x ",end="")
    print(ans["AC"])
    print("WA x ",end="")
    print(ans["WA"])
    print("TLE x ",end="")
    print(ans["TLE"])
    print("RE x ",end="")
    print(ans["RE"])
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16204
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var N = nm[0];
			var M = nm[1];
			var skm = ReadLines(M)
					.Select(x => x.Split(' ').Skip(1).Select(int.Parse).Select(i => i - 1))
					.Select((x, i) => new { k = i, s = x })
					.SelectMany(x => x.s.Select(s => new { s, k = x.k }))
					.GroupBy(x => x.s, x => x.k)
					.ToList();
			var pm = Convert.ToInt32(Console.ReadLine().Replace(" ", ""), 2);

			var ans = 0;
			foreach (var i in Enumerable.Range(0, (int)Math.Pow(2, N)))
			{
				var sw = Convert.ToString(i, 2).Reverse();
				var rp = new int[M];

				foreach (var cs in sw.Select((x, j) => new { c = x, s = j }).Where(x => x.c == '1'))
				{
					var sk = skm.FirstOrDefault(x => x.Key == cs.s);
					if (sk == null) continue;
					foreach (var k in sk)
					{
						rp[k]++;
					}
				}

				var rpi = Convert.ToInt32(string.Join("", rp.Select(x => x % 2)), 2);
				if (rpi == pm) ans++;
			}
			Console.WriteLine(ans);
		}

		static IEnumerable<string> ReadLines(int n)
		{
			foreach (var _ in Enumerable.Range(0, n)) yield return Console.ReadLine();
		}
	}
}


Measured memory_bytes: 15964
<?php
fscanf(STDIN, "%d", $n);
$v = explode(" ",fgets(STDIN));
for($i=0; $i<$n; $i++) {
    $v[$i] = intval($v[$i]);
}
sort($v);
for($i=0; $i<$n-1; $i++) {
    $v[$i+1] = ($v[$i]+$v[$i+1])/2;
}
echo $v[$n-1];
?>

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

int main(void) {

	/* ここにコードを書く */

	int a;
	string s;
	
	cin >> a;
	cin >> s;
	
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var s = Console.ReadLine();

            var d_min = 753;
            for (int i = 0; i < s.Length - 2; i++) {
                var n = int.Parse(s.Substring(i, 3));
                if (Math.Abs(753 - n) < d_min) {
                    d_min = Math.Abs(753 - n);
                }
            }

            Console.WriteLine(d_min);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	int n;
	cin >> n;
	// vector<int> a(n);
	// for(int i=0; i<n; i++) cin >> a[i];

	ll ans(0);

	if(n >= 1e+5) ans = 99999 - 9999 + 999 - 99 + 9;
	else if(n >= 9999){
		ans += n - 9999;
		ans += 999 - 99;
		ans += 9;
	}
	else if(n >= 999){
		ans += 999 - 99;
		ans += 9;
	}else if(n >= 99){
		ans += n - 99;
		ans += 9;
	}else if(n >= 9){
		ans = 9;
	}else{
		ans = n;
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

//最小全域木をクラスカル法で求める
//クラスカル法とは辺をコストの小さい順にソートし両端点が異なる連結成分にあるならその辺を使う
//という操作を繰り返すそのためにまずpiたちとqiたちを一緒にしてソートする
//これらの値の小さい順に辺を追加できるだけ追加していけば最小全域木が求まる
//各ステップで辺は何本追加できるか？
//配列のpiに対応する要素を見るときは(i,j)と(i+1,j)を結ぶ辺を何本追加できるかを求め
//さらにすべてのjに対し(i,j)と(i+1,j)を連結にすればよい
//そしてこの連結操作はこれ以降x座標iとi+1を同一視するという操作です
//よってこの操作では(i,j)と(I,J+1)を結ぶような辺の数が1減少するということが起こる
//以上をまとめるとPIたちとqiたちをまとめてソートし
//a=W+1,b=H+1としてその列を前から見て
//(i,j)と(i+1,j)を結ぶ辺を見るときはそのような列をb本使いaを1減らし
//(i,j)と(i,j+1)を結ぶ辺を見るときはそのような辺をa本使いbを1減らす

int main() {
	ll W, H; cin >> W >> H;
	ll a = W + 1;
	ll b = H + 1;
	vector<pii>V;
	ll sum = 0;
	REP(i, W) {
		int x; cin >> x;
		V.push_back({ x,1 });
	}
	REP(i, H) {
		int x; cin >> x;
		V.push_back({ x,0 });
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < V.size(); ++i) {
		if (V[i].second == 1) {
			sum += V[i].first*b;
			a--;
		}
		else {
			sum += V[i].first*a;
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2420
#include <iostream>

int main() {
    uint64_t n;
    std::cin >> n;

    uint64_t max = 0, res = 0;
    while (n--) {
        uint64_t temp = 0;
        std::cin >> temp;

        if (temp > max) {
            max = temp;
        } else {
            res += (max - temp);
        }
    }

    std::cout << res;
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
p = list(map(int, input().split()))

p_sorted = sorted(p)

ans = 0

for i in range(n):
  if p_sorted[i] != p[i]:
    ans += 1
  else:
    pass

if ans == 2 or ans == 0:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <set>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <limits>
#include <cmath>
#include <typeinfo>
 
 
using namespace std; 
 
 
// ||    



int firstDigit(int n) 
{ 
    // Remove last digit from number 
    // till only one digit is left 
    while (n >= 10)  
        n /= 10; 
      
    // return the first digit 
    return n; 
} 

int lastDigit(int n) 
{ 
    // return the last digit 
    return (n % 10); 
} 


void sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
}
 
void reverseStr(string& str) 
{ 
    int n = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 

void bubbleSort(int arr[], int n)  
{  
    for(int i = 1; i <= n; i++) {
    	for(int j = 0; j < n; j++)  {
       		if (arr[j] > arr[j+1]) {
       			swap(arr[j], arr[j+1]); 

       		}  
    	}
    }      
 
} 

bool allCharactersSame(string s) 
{ 
	int n = s.length();
    for (int i = 1; i < n; i++) 
        if (s[i] != s[0]) 
            return false; 
  
    return true; 
}

int main() { 
	int n = 0;
	cin >> n;
	cout << n *n << endl;
 
    return 0;
}


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

int main(void){
    long long n;
    std::cin >> n;

    long long a, b, c, d, e;
    std:: cin >> a >> b >> c >> d >> e;

    long long MinMove = std::min({a, b, c, d, e});
    long long  ans = (n + MinMove - 1) / MinMove + 4;
  std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
def bubble_sort(A):
    flag = True
    swap = 0
    while flag:
        flag = False
        for j in range(len(A)-1,0,-1):
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1],A[j]
                swap += 1
                flag = True
    return swap
  
if __name__=='__main__':
   N=int(input()) 
   A=list(map(int,input().split()))
   swap = bubble_sort(A)
   print(*A)
   print(swap)


Measured memory_bytes: 5608
#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 <unordered_map>
#include <bitset>
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
typedef pair<int, int> P;

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<P> > vec(n, vector<P>());

  rep(i,m){
    int p,q,c;
    scanf("%d %d %d", &p, &q, &c);
    p--;q--;
    vec[p].pb(mp(q,c));
    vec[q].pb(mp(p,c));
  }

  // pair[i,j] node iでjの路線
  // 毎回mapでチェックするとTLEするから，最初にpair[i,j] -> idx におきかえていく．
  // あらたなグラフをnvecにする
  map<P, int> p2i;  //pair to int
  vector<vector<P> > nvec;
  int idx=0;
  rep(i,n){
    // まずmap対応をつくる
    if(p2i.find(mp(i,0))==p2i.end()){
      p2i[mp(i,0)] =idx++;
      nvec.pb(vector<P>());
    }
  }
  rep(i,n){
    // map対応表さくせい続き
    for(auto p : vec[i]){
      if(p2i.find(mp(i,p.se))==p2i.end()){
        p2i[mp(i,p.se)]=idx++;
        nvec.pb(vector<P>());
      }
      if(p2i.find(mp(p.fi,p.se))==p2i.end()){
        p2i[mp(p.fi,p.se)]=idx++;
        nvec.pb(vector<P>());
      }
    }
    // つなぐ
    // a->bの辺に対して，aで乗る(cost1)，bでおりる，a->bに移動するの3本を張る
    for(auto p :vec[i]){  //p.fi:dist p.se:type
      nvec[p2i[mp(i,0)]].pb(mp(p2i[mp(i,p.se)], 1));
      nvec[p2i[mp(i,p.se)]].pb(mp(p2i[mp(p.fi,p.se)],0));
      nvec[p2i[mp(p.fi,p.se)]].pb(mp(p2i[mp(p.fi,0)],0));
    }
  }

  priority_queue<P, vector<P>, greater<P> > pq;  // <cost, to>
  vector<int> c(idx, INF);
  pq.push(mp(0,p2i[mp(0,0)]));
  while(!pq.empty()){
    P p = pq.top(); pq.pop();
    int cost=p.fi, now=p.se;
    if(cost > c[now]) continue;
    for(auto nxt: nvec[now]){
      int ni =nxt.fi, nc=cost + nxt.se;
      if(c[ni] > nc){
        c[ni] = nc;
        pq.push(mp(nc, ni));
      }
    }
  }

  if(c[p2i[mp(n-1,0)]]==INF) cout<<-1<<endl;
  else cout<<c[p2i[mp(n-1,0)]]<<endl;

  return 0;
}


Measured memory_bytes: 66020
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

void rsort_u32(void *base, const int count){
	typedef uint32_t rsort_t;
	rsort_t *a=base;
	rsort_t *b=malloc(count*sizeof(rsort_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}

int a[200000];
bool b[1000001];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	rsort_u32(a, n);
	int ans=0;
	for(int i=0; i<n; i++){
		bool f=true;
		if(i<n-1 && a[i]==a[i+1]) b[a[i]]=true;
		int q=sqrt(a[i]);
		for(int j=1; j<=q; j++){
			if(a[i]%j==0){
				if(b[j]){ f=false; break; }
				if(b[a[i]/j]){ f=false; break; }
			}
		}
		if(f) ans++;
		b[a[i]]=true;
	}
	printf("%d\n", ans);
}



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



int N, M;
int X[101010];
//-----------------------------------------------------------------
int cnt1[101010]; // cnt1[i] : ?? mod M == iの個数
int cnt2[101010]; // cnt2[i] : ?? mod M == iで同じ数のペアが作れる個数
int main() {
	cin >> N >> M;
	rep(i, 0, N) scanf("%d", &X[i]);

	map<int, int> m;
	rep(i, 0, N) m[X[i]]++;

	for (auto p : m) {
		cnt1[p.first % M] += p.second;
		cnt2[p.first % M] += p.second / 2;
	}

	int ans = 0;
	rep(i, 0, M / 2 + 1) {
		int j = M - i;

		if (i == 0 || i == j) {
			ans += cnt1[i] / 2;
		}
		else {
			

			if (cnt1[i] < cnt1[j])
			{
				ans += cnt1[i];
				int d = cnt1[j] - cnt1[i];
				d = d / 2;
				ans += min(d, cnt2[j]);
			}
			else {
				ans += cnt1[j];
				int d = cnt1[i] - cnt1[j];
				d = d / 2;
				ans += min(d, cnt2[i]);
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#define MAX 200010
#define x first
#define y second

using namespace std;

int n,v1,v2;
int ans[MAX];
pair<int,int> a[MAX];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i].x,a[i].y=i;
    sort(a+1,a+n+1);
    v1=a[n/2].x,v2=a[n/2+1].x;
    for(int i=1;i<=n/2;i++) ans[a[i].y]=v2;
    for(int i=n/2+1;i<=n;i++) ans[a[i].y]=v1;
    for(int i=1;i<=n;i++)cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[200010];
int main()
{
	int N;
	cin >> N;
	ll sum1 = 0;
	ll sum2 = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum2 += A[i];
	}
	ll ans = INF;
	for (int i = 0; i < N - 1; i++) {
		sum1 += A[i];
		sum2 -= A[i];
		ans = min(ans, abs(sum1 - sum2));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
//library end
int n,k,m;
int a[114];
int cnt=0;
char c;
signed main(){
    cin>>c;
    char ch=c+1;
    cout<<ch<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, wa=0;
	char s[50][50], d[50][50];

	scanf("%d %d", &H, &W);

	for(int i=0; i<H; i++){
		scanf("%s", s[i]);
	}

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			d[i][j]=0;
			if(s[i][j]=='#'){
				wa++;
			}
		}
	}

	queue<vector<int> > q;

	vector<int> v(2);
	v[0]=0;
	v[1]=0;
	q.push(v);
	d[0][0]=1;
	while(1){
		if(q.empty()){
			break;
		}
		int i=q.front()[0];
		int j=q.front()[1];
		if(i==H-1 && j==W-1){
			break;
		}
		if(i>=1 && s[i-1][j]!='#' && d[i-1][j]==0){
			v[0]=i-1;
			v[1]=j;
			q.push(v);
			d[i-1][j]=d[i][j]+1;
		}
		if(j>=1 && s[i][j-1]!='#' && d[i][j-1]==0){
			v[0]=i;
			v[1]=j-1;
			q.push(v);
			d[i][j-1]=d[i][j]+1;
		}
		if(i<H-1 && s[i+1][j]!='#' && d[i+1][j]==0){
			v[0]=i+1;
			v[1]=j;
			q.push(v);
			d[i+1][j]=d[i][j]+1;
		}
		if(j<W-1 && s[i][j+1]!='#' && d[i][j+1]==0){
			v[0]=i;
			v[1]=j+1;
			q.push(v);
			d[i][j+1]=d[i][j]+1;
		}
		q.pop();
	}

	int ans;

	if(d[H-1][W-1]==0){
		ans=-1;
	}else{
		ans=H*W-wa-d[H-1][W-1];
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int i;
    vi v(5);
    read(v,0,5);
    for(i=0; i<5; i++)
    {
        if(v[i]==0)break;
    }
    cout<<i+1<<endl;
    return 0;
}


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


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

const int maxn = 501;
int g[maxn][maxn];
int n;

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	VI ison(n, 0);
	VI numoffinrow(n, 0);
	VI colscount(n, 0);
	int numallblackcols = 0;
	bool possible = false;
	for (int i = 0; i < n; ++i) {
		char c;
		int black_count = 0;
		for (int j = 0; j < n; ++j) {
			cin >> c;
			g[i][j] = (c == '#' ? 1 : 0);
			if (g[i][j]) ison[j] = 1;
			black_count += g[i][j];
			if (!g[i][j]) ++numoffinrow[i];
			colscount[j] += g[i][j];
		}
		if (black_count > 0) possible = true;
	}
	for (int j = 0; j < n; ++j) {
		if (colscount[j] == n) ++numallblackcols;
	}
	if (!possible) {
		cout << -1;
		return 0;
	}
	int sol = 2*n + 1000;
	for (int i = 0; i < n; ++i) {
		if (ison[i]) {
			sol = min(sol, numoffinrow[i] + (n-numallblackcols));
		} else {
			sol = min(sol, numoffinrow[i] + 1 + (n-numallblackcols));
		}
	}
	cout << sol;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
const int N = 2 * 1e5 + 10;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

void solve() {
    ll n, val;
    cin>>n>>val;
    ll arr[n], prof[n];
    for(int i = 0;i < n;i++) {
        cin>>arr[i]>>prof[i];
    }
    ll dp[n+1][val+1];

    for(int i = 0; i <= n; i++) {
        for(int j = 0 ; j <= val ;j++) {
            if(i == 0|| j ==0) {
                dp[i][j] = 0;
                continue;
            }

            ll max_without = dp[i-1][j];
            ll max_with = 0;

            if(j >= arr[i-1]) {
                max_with += prof[i-1];
                max_with += dp[i-1][j - arr[i-1]];
            }

            dp[i][j] = max(max_without, max_with);
        }
    }
    cout<<dp[n][val];
}
int main()
{
    ll t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
return 0;
}

Measured memory_bytes: 79104
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dru(n: u64, m: u64) -> u64 {
    if n % m == 0 {
        return n / m;
    } 
    n / m + 1
}

fn main() {
    let (n, k) = input_tuple();
    let mut boundaries: Vec<u64> = Vec::new();
    let mut i = 0u32;
    loop {        
        let boundary = dru(k, 2u64.pow(i));
        boundaries.push(boundary);
        if boundary <= 1 {
            break;
        }
        i += 1;
    }
    // println!("{:?}", boundaries);
    let mut pre = n + 1;
    let mut sum = 0f64;
    let mut dividor = 1f64;
    for boundary in boundaries {               
        if boundary <= n {
            // println!("({} - {}) / {} / {}", pre, boundary, dividor, n);
            sum += (pre - boundary) as f64 / dividor / n as f64;
            pre = boundary;            
        }
        dividor *= 2f64;       
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    int P, Q;
    vector<int> p(n), q(n), a(n);
    rep(i, n) scanf("%d", &p[i]);
    rep(i, n) scanf("%d", &q[i]);
    rep(i, n) a[i]=i+1;
    int cnt=0;
    do{
        if(a==p) P=cnt;
        if(a==q) Q=cnt;
        ++cnt;
    }while(next_permutation(a.begin(), a.end()));
    printf("%d\n", abs(P-Q));
}

Measured memory_bytes: 256
n, k = (int(i) for i in input().split())
cnt = 0
for x in range(k+1, n+1):
    cnt = cnt + int(n / x) * (x - k) + max(int(n % x) - (k - 1), 0)
    #print(int(n / x) * (x - k), end=" ")
    #print(max(int(n % x) - (k - 1), 0))
if k == 0:
    cnt = cnt - n
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,L;
	cin >> N >> L;
	int sum = 0;
	int temp,ans = inf,temp2 = inf;
	for(int i = 1;i<=N;i++)sum += L + i - 1;
	int a = inf;
	for(int i = 1;i<=N;i++){
		temp = sum - (L + i - 1);
		temp2= abs(sum - temp);
		if(temp2< a){
			a = temp2;
			ans = temp;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def dist(s, t, g):
    q = [s]
    dists = [-1]*len(g)
    dists[s] = 0
    while len(q) != 0:
        p = []
        for u in q:
            for v in g[u]:
                if dists[v] != -1:
                    continue
                p.append(v)
                dists[v] = dists[u] + 1
        q = p
    return dists[t]

def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n*3)]
    for _ in range(m):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        g[u].append(v+n)
        g[u+n].append(v+2*n)
        g[u+2*n].append(v)
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    print(dist(s, t, g)//3)

if __name__ == "__main__":
    main()


Measured memory_bytes: 59804
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

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

    int ans = N / 1.08; // 切り捨てるので小さくなる場合がある
    if (int(ans * 1.08) == N) {
        cout << ans << endl;
    }
    else {
        bool a = false;
        int tmp = ans * 1.08;
        while (tmp <= N) {
            if (tmp == N) {
                a = true;
                break;
            }
            tmp = ++ans * 1.08;
        }
        if (a) {
            cout << ans << endl;
        }
        else {
            cout << ":(" << endl;
        }
    }
}

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

using namespace std;

class UnionFind {
 public:
  std::vector<int> parent;

  UnionFind(int n) : parent(n, -1) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
  }

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

  int size(int x) { return -parent[root(x)]; }

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) std::swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
  }
  int64_t cur = static_cast<int64_t>(N) * (N - 1) / 2;
  UnionFind uf(N);
  vector<int64_t> res;
  for (int i = M - 1; i > -1; i--) {
    res.emplace_back(cur);
    if (uf.issame(A[i], B[i])) continue;
    int64_t a = uf.size(A[i]), b = uf.size(B[i]);
    cur -= a * b;
    uf.unite(A[i], B[i]);
  }
  reverse(res.begin(), res.end());
  for (auto x : res) {
    cout << x << '\n';
  }
  return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){
	ll n;
	cin >> n;
	string s;
	cin >> s;

	for(int i=0;i<s.length();i++){
		printf("%c",('A'+(s[i]-'A'+n)%26));
	}
	cout << endl;
	

	return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> ws(n);
    vector<int> ds(n);
    for (int i = 0; i < n; i++) {
        cin >> ws[i] >> ds[i];
    }

    auto cnt = [&](long long w, int d, long long p) -> long long {
        if (p < w) return 0;
        p -= w;
        return p / d + 1;
    };
    long long L = 0, R = (long long) 2e18 + 1;
    while (L < R - 1) {
        long long M = L + (R - L) / 2;
        long long tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp += cnt(ws[i], ds[i], M);
        }
        if (tmp >= k) {
            R = M;
        } else {
            L = M;
        }
    }
    cout << R << endl;
}

Measured memory_bytes: 1408
group = []
multi = 0
i = 0 
cnt = 0
while multi < 100 do
	multi = 2 ** i
	group[i]=multi
	i+=1
end
#p group
num = gets.to_i
#p num

group.each do |value|
	if num < value
		p(group[cnt-1])
		break
	else
		cnt+=1
	end
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x){
		cout<<(n/x+1)*t;
	} 
	else{
		cout<<n/x*t;
	}
	re 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll n,m;
    cin >> n >> m;
    const ll x = n;
    bool ok[x];
    ll wa[x];
    ll cntac = 0, cntwa = 0;
    for(ll i=1;i<=n;i++){
        ok[i] = false;
        wa[i] = 0;
    }
    for (ll i=0;i<m;i++){
        ll p;
        string s;
        cin >> p >> s;
        if(ok[p]) continue;
        if(s == "WA"){
            wa[p]++;
        }
        else{
            cntac++;
            cntwa += wa[p];
            ok[p] = true;
        }
    }
    cout << cntac << " " << cntwa << endl;


}

Measured memory_bytes: 1152
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

const int N = 110;
int a[N];
int n, m;

int main() {
	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	
	double k = sum / (double)(4 * m);
	sort(a, a + n);
	for (int i = n - 1; i >= n - m; i--) {
		if (a[i] < k) {
			puts("No");
			return 0;
		}
	}

	puts("Yes");

	return 0;
}

Measured memory_bytes: 256
a = []
for _ in range(3):
    a += list(map(int, input().split()))
n = int(input())
b = {int(input()): None for _ in range(n)}

r = [(ai in b) for ai in a]

combs = [
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6],
]
if any([all([r[c] for c in comb]) for comb in combs]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
n=int(input())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
lc=list(map(int,input().split()))
ans=sum(lb)
for i in range(1,n):
    if la[i]==la[i-1]+1:
        ans+=lc[la[i-1]-1]
print(ans)

Measured memory_bytes: 3064
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    H, A = input(int, int)
    print(ceil(H / A))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

int main() {
  int N, K;
  cin >> N >> K;
  
  if (N % 2 > 0 && K <= (1+N)/2){
    cout << "YES" << endl;
  }
  else if (N % 2 == 0 && K <= N / 2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
   
}

Measured memory_bytes: 256
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz


	int n;
	cin >> n;
	cout << n+n*n+n*n*n;

	return 0;
}  


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e6 + 10;
const int MOD = 1e9 + 7;
ll d[N];
ll qpow(ll x, ll k) {
    ll r = 1;
    while(k) {
        if(k & 1) r = r * x % MOD;
        k >>= 1;
        x = x * x % MOD;
    }
    return r;
}
ll C(int i, int j) {
    return d[i] * qpow(d[i-j], MOD-2) % MOD * qpow(d[j], MOD - 2) % MOD;
}
ll Cal(int i, int j) {
    ll res = 0;
    // C(i+j, j)
    for(int x = 0; x <= j; x++) {
        res += C(x+i-j+1, x+1);
        res %= MOD;
    }
    return res;
}
int main() {
	d[0] = 1;
    for(int i = 1; i < N; i++) {
        d[i] = d[i-1] * i % MOD;
    }
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans = Cal(r2+c2, c2) - Cal(r1-1+c2, c2) - Cal(r2+c1-1, c1-1) + Cal(r1-1+c1-1, c1-1);
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << '\n';
}

Measured memory_bytes: 16000
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int y = 0;
            for (int i = 0; i < n; i++) {
                if (sc.nextInt() >= k) y++;
            }
            pw.println(y);
        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("output"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}


Measured memory_bytes: 32396
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

ans = [0 for i in range(N + 1)]
ans[0] = 1

ok = sorted(set(i for i in range(1, N + 1)) - set(A))

for i in ok:
  if i == 1:
    ans[i] = 1
  else:
    ans[i] = ans[i - 2] + ans[i - 1]
print(ans[-1]%(10**9+7))

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(b,c) << " " << max(0,b+c-a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

ll l, k;

void solve() {
	ll ans = 0;
	vl dp(l + 2);
	dp[0] = 1;
	rep(i, dp.size()) {
		if (i - 2 >= 0)dp[i] += dp[i - 2];
		if (i - k - 1 >= 0)dp[i] += dp[i - k - 1];
	}
	range(i, 1, dp.size()) {
		ans += dp[i];
	}
	cout << ans << endl;
}

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



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

int main(){
  int th,ts,ah,as;
  cin >>  th >> ts >> ah >> as;
  ah = ah-ts;
  while(ah > 0 && th > 0){
    th = th - as;
    ah = ah - ts;
  }
  if(th <= 0)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


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

int main(){

	int n,k;
	int num;
	int ans=0;
	int a[200000]={};
	cin>>n>>k;
	
	for(int i=1;i<=n;i++){
		cin>>num;
		a[num]+=1;
	}
	sort(a,a+n+1);
	
	
	for(int i=1;i<=n;i++){
		if(a[i]!=0 && k<=n-i){
			ans+=a[i];
		}
	}
	cout<<ans<<endl;
}



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

#define QWERTY "qwertasdfgzxcvb"

int main(void)
{
    char str[40];
    int count;
    int flag_left;
    int i;
    
    while (1){
        scanf("%s", str);
        if (str[0] == '#'){
            break;
        }
        if (strchr(QWERTY, str[0]) != NULL){
            flag_left = 1;
        }
        else {
            flag_left = 0;
        }
        
        count = 0;
        
        i = 1;
        while (str[i] != '\0'){
            if (strchr(QWERTY, str[i]) != NULL){
                if (flag_left != 1){
                    count++;
                }
                flag_left = 1;
            }
            else {
                if (flag_left == 1){
                    count++;
                }
                flag_left = 0;
            }
            i++;
        }
        printf("%d\n", count);
        
    }
    
    return (0);
}

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

int main(){
  int s,cnt = 1;
  bool b = 1;
  cin >> s;
  set<int> t;
  t.insert(s);
  while(b){
    ++cnt;
    if(s%2){
      s = s * 3 + 1;
    }else{
      s = s / 2;
    }
    if(t.count(s)){
      b = 0;
    }else{
      t.insert(s);
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,i,j;
    cin>>h>>w;
    char c[h+1][w+1];
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        cin>>c[i][j];
    }
    for(i=0;i<=h+1;i++)
    {
        if(i!=0&&i!=h+1)
        {
            for(j=0;j<=w+1;j++)
            {
                if(j!=0&&j!=w+1)
                cout<<c[i-1][j-1];
                else
                cout<<"#";
            }
        }
        else
        {
            for(j=0;j<=w+1;j++)
                cout<<"#";
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#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;
typedef pair<int,int> P;

class ki{
public:
    int N,Q;
    vector<int> a,b;
    vector<int> p,x;
    vector<vector<int> > G;
    vector<P> add;
    vector<int> ans;
    vector<bool> flag;
    ki(){
        cin>>N>>Q;
        a.resize(N), b.resize(N);
        REP(i,N-1) {
            cin>>a[i]>>b[i];
            a[i]--; b[i]--;
        }
        p.resize(Q), x.resize(Q);
        REP(i,Q) {
            cin>>p[i]>>x[i];
            p[i]--;
        }
        G.resize(N);
        add.resize(Q);
        ans.resize(N);
        flag.resize(N,false);
    }

    void unite(){
        REP(i,N-1){
            G[a[i]].push_back(b[i]);
            G[b[i]].push_back(a[i]);
        }
        REP(i,Q){
            add[i] = P(p[i],x[i]);
        }
    }

    static bool compare(P a, P b){
        return a.first < b.first;
    }

    void processing(){
        unite();
        sort(ALL(add), compare);
        sort(ALL(p));
    }

    //int score = 0;
    void dfs(int score, int node){
        flag[node] = true;
        if(binary_search(ALL(p), node)){
            if(p[Q-1] > node){
                FOR(i, lower_bound(ALL(p),node) - p.begin(), upper_bound(ALL(p),node) - p.begin()){
                    score += add[i].second;
                }
            }
            else{
                FOR(i,lower_bound(ALL(p),node) - p.begin(), Q){
                    score += add[i].second;
                }
            }
            
        }
        ans[node] += score;
        if(G[node].size() > 0){
            REP(i,G[node].size()){
                if(flag[G[node][i]] == false){
                    dfs(score, G[node][i]);
                }
            }
        }
    }
    
};

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ki tree;
    tree.processing();
    int score = 0; int node = 0;
    tree.dfs(score,node);
    REP(i,tree.N){
        cout << tree.ans[i] << endl;
    }
}

Measured memory_bytes: 28288
var
  t,c,n,m,i,min:longint;
begin
  readln(n,m);
  min:=maxlongint;
  for i:=1 to n do
    begin
	  readln(c,t);
	  if t<=m then 
	    if c<min then min:=c;
	end;
  if min=maxlongint then write('TLE')
  else write(min);
end.

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

int main() {
	int a, b, c, k; cin >> a >> b >> c >> k;

	ll mx = max({ a,b,c });
	ll ans = a + b + c - mx;
	rep(i, 0, k) mx *= 2;

	cout << ans + mx << endl;

	return 0;
}

Measured memory_bytes: 256