akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define MAX 100005

typedef struct pp{
  char name[10];
  int time;
} P;

void enqueue(P);
P dequeue(void);
int min(int, int);

P Q[MAX];
int head, tail, n;

int main()
{
  int elaps = 0, c, i, s;
  P u;
  scanf("%d%d",&n,&s);

  for(i=1; i<=n; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].time);
  }
  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(s, u.time);
    u.time -= c;
    elaps += c;
    if(u.time>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

void enqueue(P x){
  Q[tail] = x;
  if(tail+1 == MAX){
    tail = 0;
  }
  else{
    tail++;
  }
}

P dequeue(){
  P x;
  x = Q[head];
  if(head+1 == MAX){
    head = 0;
  }
  else{
    head++;
  }
  return x;
}

int min(int a, int b){
  if(a<b) return a;
  else return b;
}

Measured memory_bytes: 2160
from collections import Counter

n = int(input())

lis = list(map(int, input().split()))

t = len(lis)

a = Counter(lis[0::2]).most_common()
b = Counter(lis[1::2]).most_common()


ans2 = 1001001001
ans3 = 1001001001
ans4 = 1001001001

if a[0][0] != b[0][0]:
    ans = t - a[0][1] - b[0][1]
    print(ans)
    
else:
    if len(a) != 1:
        ans2 = t - a[1][1] - b[0][1]
    if len(b) != 1:
        ans3 = t - a[0][1]-b[1][1]
    else:
        ans4 = t/2
        
    print(int(min(ans2, ans3, ans4)))
    

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using namespace boost::multiprecision;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
    int cnt[100000];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,q;
    string s;
    cin>>n>>q>>s;
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')cnt[i+1]++;
        cnt[i+1]+=cnt[i];
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<cnt[r-1]-cnt[l-1]<<"\n";
    }
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pb push_back
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W, M;
  cin >> H >> W >> M;
  vector<ll> h(H, 0), w(W, 0);
  map<vector<ll>, bool> hw;
  for (ll i = 0; i < M; ++i) {
    ll hi, wi;
    cin >> hi >> wi;
    h.at(hi - 1) += 1;
    w.at(wi - 1) += 1;
    hw[{hi - 1, wi - 1}] = true;
  }
  ll max_h = 0, max_w = 0;
  for (ll i = 0; i < H; ++i) {
    max_h = max(max_h, h.at(i));
  }
  vector<ll> index_h;
  for (ll i = 0; i < H; ++i) {
    if (h.at(i) == max_h) {
      index_h.push_back(i);
    }
  }
  for (ll i = 0; i < W; ++i) {
    max_w = max(max_w, w.at(i));
  }
  vector<ll> index_w;
  for (ll i = 0; i < W; ++i) {
    if (w.at(i) == max_w) {
      index_w.push_back(i);
    }
  }
  ll ans = max_h + max_w - 1;
  // cout << ans << "\n";
  bool fin = false;
  for (ll i = 0; i < index_h.size(); ++i) {
    for (ll j = 0; j < index_w.size(); ++j) {
      if (!hw[{index_h.at(i), index_w.at(j)}]) {
        ans += 1;
        fin = true;
        break;
      }
    }
    if (fin) {
      break;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 48980
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = b-1;
    if(b-1 < n)cout << floor(a*x/b) - a*floor(x/b) << endl;
    else cout << floor(a*n/b) - a*floor(n/b) << endl;
    return 0;
}

Measured memory_bytes: 3784
export class Main {
  static main(input): string {
    const [n, k]: number[] = input.split("\n")[0].split(" ").map(Number);
    let result = 0;
    let nn: number = n;
    if (nn >= k) {
      result += (nn - k + 1) / n;
      nn = k - 1;
    }
    if (nn > 0) {
      let bufK: number = k;
      let buf2: number = 1;
      while (bufK > 0) {
        bufK /= 2;
        buf2 *= 2;
        if (nn >= bufK) {
          const t: number = Math.ceil(bufK);
          result += (nn - t + 1) / n / buf2;
          nn = t - 1;
        }
      }
    }
    return `${result}`
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int ab_count(string s){
  int index = 0, count = 0;
  while(index != string::npos){
    index = s.find("AB");
    if(index != string::npos){
      count++;
      s = s.substr(index + 1);
    }
  }
  return count;
}

int main(){
  int N;
  int a = 0, b = 0, ab = 0;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++){
    cin >> s[i];
    if(s[i][0] == 'B'){
      if(s[i][s[i].size() - 1] == 'A')ab++;
      else b++;
    }else if(s[i][s[i].size() - 1] == 'A'){
      a++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i< N; i++){
    ans += ab_count(s[i]);
  }
 
  ans += min(a, b);
  if(abs(a - b) != 0){
    ans += ab;
  }else if(ab > 0 && a == 0){
    ans += ab - 1;
  }else{
    ans += ab;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 768
import sys
n = int(input())
ls = []
raw_ls = []
for i in range(n):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    ls.append([a + b, a, b])
res = 0
for i, x in enumerate(sorted(ls, key=lambda x:x[0], reverse=True)):
    if i % 2 == 0:
        res += x[1]
    else:
        res -= x[2]
print(res)

Measured memory_bytes: 60508
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007
// ll max(ll a,ll b)
// {
//     if(a>b) return a;
//     else return b;
// }
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}

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

using namespace std;

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

    int N,M; cin>>N>>M;
    vector<long> cnt(N+1,0);
    for (int i = 0; i < M; i++) {
        int l, r; cin>>l>>r;
        l--; r--;
        cnt[l]++;
        cnt[r+1]--;
    }
    long count = 0;
    long ans = 0;
    for (auto c : cnt) {
        count += c;
        if (count == M)
            ans++;
    }
    cout << ans << endl;

    
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;



int main(void) {
	llint N, Hans, Xans, Yans;
	int fin = 0;
	int jur = 0;

	cin >> N;
	vint x(N), y(N), h(N), H(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		cin >> y[i];
		cin >> h[i];
	}

	for (llint Cx = 0; Cx < 101; Cx++) {

		for (llint Cy = 0; Cy < 101; Cy++) {
		    int cou=0;
			jur = 0;
			for (llint i = 0; i < N; i++) {
				if (h[i] != 0)H[i] = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy);
				else H[i] = -1;
			}
			
			for(int i=0;i<N;i++){
                  if(H[i]>0&&cou==0){
                      Hans=H[i];
                      cou++;
                  }
                  if(H[i]!=-1&&H[i]!=Hans)jur=1;
			}
			for (llint i = 0; i < N; i++) {
			   if (H[i] == -1) {
					if ((Hans- abs(x[i] - Cx) - abs(y[i] - Cy)) > 0) jur = 1;
				}
				
			}

			if (jur==0) {

				Xans = Cx;
				Yans = Cy;
				fin = 1;
				break;
			}

		}
		if (fin == 1)break;
	}
	cout << Xans << " " << Yans << " " << Hans << endl;
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair< ll, ll > P;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll gcd(ll a, ll b)
{
  if (a % b == 0)
  {
    return b;
  }
  return gcd(b, a % b);
}

signed main()
{
  ll K;
  cin >> K;

  ll sum = 0;
  FOR(a, 1, K)
  {
    FOR(b, 1, K)
    {
      FOR(c, 1, K)
      {
        sum += gcd(c, gcd(a, b));
      }
    }
  }

  cout << sum << endl;
}

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

int main() {
    int N,sum=0;
    cin >> N;
    vector<int> data(N);
    for(int i=0; i<N; i++){
        cin >> data.at(i);
    }
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            sum +=data.at(i)*data.at(j);
        }
    }
    cout << sum <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int a[10];
    int b[110];
    int n;
    for(int i = 0; i < 9; i++){
        cin >> a[i];
    }
    cin >> n;
    for(int i = 0; i < n; i++) cin >> b[i];
    
    int map[10] = {0};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            if(b[i] == a[j]) map[j] = 1;
        }
    }

    int ans = 0;

    if(map[0] == 1 && map[3] == 1 && map[6] == 1) ans = 1;
    if(map[1] == 1 && map[4] == 1 && map[7] == 1) ans = 1;
    if(map[2] == 1 && map[5] == 1 && map[8] == 1) ans = 1;
    if(map[0] == 1 && map[1] == 1 && map[2] == 1) ans = 1;
    if(map[3] == 1 && map[4] == 1 && map[5] == 1) ans = 1;
    if(map[6] == 1 && map[7] == 1 && map[8] == 1) ans = 1;
    if(map[0] == 1 && map[4] == 1 && map[8] == 1) ans = 1;
    if(map[2] == 1 && map[4] == 1 && map[6] == 1) ans = 1;
   
   if(ans == 1) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 384
(defn my-counter [f coll acc]
  (let [ope (fn [a k] 
              (assoc a k (f (get a k 0))))]
    (reduce ope acc coll)))

(let [n (Integer/parseInt (read-line))
      s (doall 
          (for [_ (range n)] (read-line)))
      m (Integer/parseInt (read-line))
      t (doall
          (for [_ (range m)] (read-line)))]
  (->> {}
       (my-counter inc s)
       (my-counter dec t)
       (vals)
       (cons 0)
       (apply max)
       (println)
       ))


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;



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

    int n, m;
    cin >> n >> m;

    vector<vector<int>> G(n+1);
    rep(i, m){
        int a, b;
        cin >> a >> b;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dis(n+1, -1);
    queue<int> q;
    q.push(1);
    dis[1] = 0;

    while(!q.empty()){
        int t = q.front(); q.pop();
        for (auto& p : G[t]) {
            if(dis[p] != -1) continue;
                dis[p] = t;
                q.push(p);
        }
    }

    bool ok = true;
    for (int i = 2; i <= n; ++i) {
        if(dis[i] == -1){
            ok = false;
        }
    }

    if(ok){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
        return 0;
    }
    for (int i = 2; i <= n; ++i) {
        cout << dis[i] << "\n";
    }


    return 0;
}


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

using namespace std;

int main() {

    int n;
    cin >> n;

    int last = 0;
    long long ans = 0;

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if(x < last) ans += abs(x - last);
        last = max(last, x);
    }

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


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

int main(){
    vector<int>d1(6);
    vector<int>d2(6);
    for(auto&e:d1){
        scanf("%d",&e);
    }
    for(auto&e:d2){
        scanf("%d",&e);
    }

    for(int i=0;i<4;i++){
        int tmp1=d1[0];
        d1[0]=d1[2], d1[2]=d1[5], d1[5]=d1[3], d1[3]=tmp1;
        for(int j=0;j<4;j++){
            int tmp2=d1[0];
            d1[0]=d1[1], d1[1]=d1[5], d1[5]=d1[4], d1[4]=tmp2;
            for(int k=0;k<4;k++){
                int tmp3=d1[1];
                d1[1]=d1[2], d1[2]=d1[4], d1[4]=d1[3], d1[3]=tmp3;
                if(equal(d1.cbegin(),d1.cend(),d2.cbegin())){
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int n;
	while (cin >> n, n)
	{
		bool f = true;
		int ub = INF; int lb = -INF;
		string s;
		vector<string> v;
		v.push_back(to_string(INF));
		REP(i, n)
		{
			string a;
			cin >> a;
			v.push_back(a);
		}
		v.push_back(v.size() % 2 ? to_string(-INF) : to_string(INF));
		FOR(i, 1, v.size() - 1)
		{
			if (v[i] == "x")
			{
				if (v[i - 1] == "x" || v[i + 1] == "x")
				{
					f = false;
					goto end;
				}
				int pre = stoi(v[i - 1]); int next = stoi(v[i + 1]);
				if (i % 2 == 1)
				{
					if (ub >= pre || ub >= next) ub = min(ub, min(pre, next) - 1);
				}
				else
				{
					if (lb <= pre || lb <= next) lb = max(lb, max(pre, next) + 1);
				}
			}
			else
			{
				int t = stoi(v[i]);
				if (v[i - 1] != "x")
				{
					int pre = stoi(v[i - 1]);
					if (i % 2 == 1)
					{
						if (pre <= t) f = false;
					}
					else
					{
						if (pre >= t) f = false;
					}
				}
			}
		}
	end:;
		if (!f) puts("none");
		else if (ub > lb || ub == -INF || lb == INF) puts("ambiguous");
		else if (ub==lb) cout << ub << endl;
		else puts("none");
	}
	return 0;
}

Measured memory_bytes: 1328
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体
//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};
//////////////////ここまでライブラリ///////////////////////

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  
  lin(N);
  ll res = 0;
  res += N / 500 * 1000;
  N -= res / 1000 * 500;
  res += N / 5 * 5;
  cout << res;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n,t;cin >> n >> t;
    vector<pair<int,int>> x(n,pair<int,int>(n,n));
    rep(i,n){
        cin >> x[i].first >> x[i].second;
    }
    sort(x.begin(),x.end());
    for(int i=0;i<n;i++){
        if(x[i].second>t)continue;
        else {
            out(x[i].first);
            return 0;
        }
    }
    out("TLE");
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string S;
    cin>>S;
    map<char,int> m;
    rep(i,S.size()) m[S[i]]++;
    char answer='a';
    bool ok=false;
    for(char i='a'; i<='z'; i++) {
        if(m.count(i)==0) {
            answer=i;
            ok=true;
            break;
        }
    }
    if(ok) cout<<answer<<endl;
    else cout<<"None"<<endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>A(N);
  for(int i = 0; i < M; i++)cin >> A.at(i);
  
  int count = 0;
  for(int i = 0; i < M; i++){
    count += A.at(i);
  }
  if(count <= N){
    cout << N - count << endl;
  }else{
    cout << "-1" << endl;
  }
  
}


Measured memory_bytes: 7204
c = []
for i in range(3):
    c.append([int(i) for i in input().split()])
b1 = 0
a1 = c[0][0]
a2 = c[1][0]
a3 = c[2][0]
b2 = c[0][1] - a1
b3 = c[0][2] - a1
if a2 + b2 == c[1][1] and a3 + b2 == c[2][1] \
    and a2 + b3 == c[1][2] and a3 + b3 == c[2][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
    int a, b, c[300][300];
    int i, k;
    while (1){
        cin >> a >> b ;
        if (a == 0 && b == 0)break;
        for (i = 0;i < a; i++){
            for (k = 0;k < b; k++){
                if ((i + k) % 2 == 0){
                    c[i][k] = 1;
                } else {
                    c[i][k] = 0;
                }

            }
        }
        for (i = 0; i < a; i++){
            for (k = 0; k < b; k++){
                if (c[i][k] == 1){
                    cout << "#";
                }else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int LEN[45];
bool dp[45][4005];

int main(){

	scanf("%d",&N);

	int maximum = 0,max_index;
	int total = 0;

	for(int i = 0; i < N; i++){

		scanf("%d",&LEN[i]);

		total += LEN[i];

		if(maximum < LEN[i]){
			maximum = LEN[i];
			max_index = i;
		}
	}

	int ans = BIG_NUM;

	for(int another_max = 0; another_max < N; another_max++){ //39
		if(another_max == maximum)continue;

		//maximumを含まない方の作成可能な周長
		for(int num = 1; num <= N-1; num++){
			for(int sum = LEN[another_max]; sum <= total-maximum; sum++){
				dp[num][sum] = false;
			}
		}

		dp[1][LEN[another_max]] = true; //another_maxを必ず含むので、0はtrueにしない

		for(int i = 0; i < N; i++){
			if(i == max_index || i == another_max || LEN[i] > LEN[another_max])continue;

			for(int num = i+1; num >= 1; num--){
				for(int sum = LEN[another_max]; sum <= total-maximum; sum++){
					if(!dp[num][sum])continue;

					dp[num+1][sum+LEN[i]] = true;
					if(num+1 >= 3 && (N-(num+1)) >= 3){
						if(LEN[another_max] < sum+LEN[i]-LEN[another_max]){
							int rest = total-(sum+LEN[i]);
							if(maximum < rest-maximum){

								ans = min(ans,abs(rest-(sum+LEN[i])));
							}
						}
					}
				}
			}
		}
	}

	if(ans == BIG_NUM){

		printf("-1\n");
	}else{

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

	return 0;
}



Measured memory_bytes: 3380
import sys
import math
#import random
#sys.setrecursionlimit(1000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n,k=invr()
ara=inara()

ara.sort()

ans=0

for i in range(k):
	ans+=ara[i]

print(ans)


Measured memory_bytes: 62660
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

readIntArray ()
|> fun [| a; _ |] ->
    [| 1 .. a |]
    |> Array.collect (fun _ ->
        let x = stdin.ReadLine()
        [| x; x |])
    |> String.concat "\n"
    |> printfn "%s"


Measured memory_bytes: 29832
import Data.List
import Data.Array
getInts = do
    x <- getLine
    let y = map (read::String->Int) (words x) 
    return y
 
 
change [] n = []
change s n = 
    if isPrefixOf "AC" s then 
        [n] ++ change (tail s) (n + 1)
    else 
        [n] ++ change (tail s) n
 
solve' x q = do
    [a,b] <- getInts
    print $ (x ! b) - (x ! a)
    if q > 1 then solve' x (q-1)
    else return ()
 
solve s n q = 
    solve' (listArray (0,n) ([0]++(change s 0))) q
 
main::IO()
main=do
    [n,q] <- getInts
    s <- getLine
    solve s n q

Measured memory_bytes: 8060
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (mut a, mut b, k): (usize, usize, usize);
    input!(a, b, k);

    for i in 0..k {
        if i % 2 == 0 {
            if a % 2 != 0 {
                a -= 1;
            }
            a >>= 1;
            b += a;
        } else {
            if b % 2 != 0 {
                b -= 1;
            }
            b >>= 1;
            a += b;
        }
    }
    println!("{} {}", a, b);
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
    int a,b,c,count = 1;
    scanf("%d %d %d",&a,&b,&c);
    if(a!=b){
        count++;
    }
    if(a!=c&&b!=c){
        count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
N=int(input())
a=input().split()
T=int(a[0])
A=int(a[1])
H=[int(x) for x in input().split()]
t=abs(T-0.006*H[0]-A)
s=0
for i in range(N):
    if t>abs(T-0.006*H[i]-A):
        t=abs(T-0.006*H[i]-A)
        s=i
        

print(s+1)


Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))

A = [0] + A + [0]
C = [0]
for i in range(1, n+2):
  C.append(C[-1] + abs(A[i] - A[i-1]))

for i in range(1, n+1):
  dist = C[i-1] + C[-1] - C[i+1] + abs(A[i+1] - A[i-1])
  print(dist)

Measured memory_bytes: 14040
#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 a, b, n;
  string s;
  in(n);
  vector<pair<pair<string, ll>, ll>> c(n);
  rep(i, n){
    in2(s, a);
    c[i].first.first = s;
    c[i].first.second = 100 - a;
    c[i].second = i + 1;
  }
  sort(all(c));
  rep(i, n){
    out(c[i].second);
    memi;
  }
}


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

int main(){
    int ans = 0;
    int n;
    cin >> n;
    
    vector<long> bar(n);
    for (int i = 0; i < n; i++) {
        cin >> bar[i];
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                //cout << i << j << k << endl;
                if (bar[i] == bar[j] || bar[j] == bar[k] || bar[k] == bar[i]) continue;
                long long sum = bar[i] + bar[j] + bar[k];
                long long maxnum = max(max(bar[i], bar[j]), bar[k]);
                if (maxnum < sum - maxnum) ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3608
package main

import (
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	n, m := r(), r()
	a := make([]int, n)
	for i := range a {
		a[i] = r()
	}
	sort.Ints(a)
	minSum := sort.Search(2e5+1, func(s int) bool {
		c := 0
		for i := n - 1; i >= 0; i-- {
			c += n - sort.SearchInts(a, s-a[i])
		}
		return c < m
	}) - 1
	s := make([]int, n+1)
	for i, v := range a {
		s[i+1] = s[i] + v
	}
	ans := 0
	for _, v := range a {
		j := sort.SearchInts(a, minSum-v+1)
		ans += s[n] - s[j] + (n-j)*v
		m -= n - j
	}
	ans += m * minSum
	Fprint(_w, ans)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        long min = Long.MAX_VALUE;
        int count = 0;
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            sum += Math.abs(a);
            min = Math.min(min, Math.abs(a));
            if (a < 0) {
                count++;
            }
        }
        if (count % 2 == 0) {
            System.out.println(sum);
        } else {
            System.out.println(sum - 2 * min);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 49052
n,a,b,c,d=map(int,input().split())
s=list(input())

ans='Yes'
if d>c:
    check=0
    for i in range(a,d):
        if s[i]=='.':
            check=0
        else:
            check+=1
            if check==2:
                ans='No'
else:
    check=0
    for i in range(a,c):
        if s[i]=='.':
            check=0
        else:
            check+=1
            if check==2:
                ans='No'
    check=0
    for i in range(b-2,d+1):
        if s[i]=='.':
            check+=1
            if check==3:
                break
        else:
            check=0
    if check!=3:
        ans='No'
print(ans)

Measured memory_bytes: 4916
#if 0
2019.12.30

朴素 dp 设 f[i][p][q] 表示前 i 次操作后当前棋子为 (p, q) 的最小代价。
事实上由于第 i 次操作后一定有一个棋子是 x[i] ，因此可以优化一维：
f[i][j] 表示前 i 次操作后当前棋子为 (j, x[i]) 的最小代价。

转移有两种：
1) f[i - 1][j] + |x[i - 1] - x[i]| -> f[i][j]
2) min(f[i - 1][k] + |x[i] - k|) -> f[i][x[i - 1]]
用线段树维护 f[~][j] ，第一种转移就是全局加，第二种是单点取 min 。
第二种转移可以把左边的绝对值拆开：
f[i - 1][k] - k + x[i] (k < x[i])
f[i - 1][k] (k = x[i])
f[i - 1][k] + k - x[i] (k > x[i])
线段树分别维护 f[~][j] - j, f[~][j], f[~][j] + j 即可。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
ll f[maxn << 2], fa[maxn << 2], fb[maxn << 2], tag;

void modify(int now, int L, int R, int p, ll x) {
	f[now] = std::min(f[now], x);
	fa[now] = std::min(fa[now], x + p);
	fb[now] = std::min(fb[now], x - p);
	if(L == R) return;
	int M = (L + R) >> 1;
	if(p <= M) modify(now << 1, L, M, p, x);
	else modify(now << 1 | 1, M + 1, R, p, x);
}

void build(int now, int L, int R) {
	f[now] = fa[now] = fb[now] = 1000000000000000000;
	if(L == R) return;
	int M = (L + R) >> 1;
	build(now << 1, L, M);
	build(now << 1 | 1, M + 1, R);
}

ll query(int now, int L, int R, int p) {
	if(R < p) return p + fb[now];
	if(L > p) return fa[now] - p;
	if(L == R) return f[now];
	int M = (L + R) >> 1;
	return std::min(query(now << 1, L, M, p), query(now << 1 | 1, M + 1, R, p));
}

int main() {
	int n = read, q = read, a = read, b = read;

	build(1, 1, n);
	modify(1, 1, n, a, 0);
	/* modify(1, 1, n, b, 0); */

	int last = b;
	while(q --) {
		int x = read;
		ll qu = query(1, 1, n, x) + tag;
		/* debug("qu = %lld\n", qu); */
		tag += std::abs(x - last);
		modify(1, 1, n, last, qu - tag);
		last = x;
		/* debug("tag=%lld\n", tag); */
	}

	printf("%lld\n", f[1] + tag);
}


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

int main() {
	int a, b;
	char op;


	while (1) {
		cin >> a >> op >> b;
		if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '*') {
			cout << a * b << endl;
		}
		else if (op == '/') {
			cout << a / b << endl;
		}
		else break;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(1<<20);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	vector<ll> cnt(n+1,0);
	for(int i=0;i<n;i++){
		cnt[i+1]=(mod_pow(i+1,mod-2)+cnt[i])%mod;
	}
	ll res=0;
	for(int i=0;i<n;i++){
		(res+=a[i]*(cnt[i+1]+cnt[n-i]-1)%mod)%=mod;
	}
	for(int i=1;i<=n;i++){
		res*=i;
		res%=mod;
	}
	if(res<0)res+=mod;
	cout << res << endl;
}


Measured memory_bytes: 18176
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;


int dceil(int x) {
  return ceil(x / 10.0) * 10;
}

int remtime(int x) {
  return dceil(x)-x;
}

int main() {
  int A, B, C, D, E;

  cin >> A >> B >> C >> D >> E;

  int sum = dceil(A) + dceil(B) + dceil(C) + dceil(D) + dceil(E);
  sum -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});

  cout << sum << endl;


  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int n;
    int k = 0;
    cin >> n;
    int tmp = n;
    for(int i = 0; tmp != 0; i++){
        k += tmp % 10;
        tmp /= 10;
    }

    if(n % k == 0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
    int N=inputValue();
    int M=inputValue();
    if(N==M){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


# トポロジカルソート
# deg[i] := 頂点iの入次数
# returns := トポロジカルソートされた頂点番号のリスト
def tsort(deg, nl):
    tsorted = list()
    stack = [i for i, x in enumerate(deg) if x == 0]
    while len(stack) > 0:
        v = stack.pop()
        tsorted.append(v)
        for next_v in nl[v]:
            deg[next_v] -= 1
            if deg[next_v] == 0:
                stack.append(next_v)
    return tsorted


N, M = MI()

nl = [list() for _ in range(N)]
deg = [0 for _ in range(N)]
for _ in range(N - 1 + M):
    A, B = MI()
    A, B = A - 1, B - 1
    nl[A].append(B)
    deg[B] += 1

tsorted = tsort(deg, nl)

ans = [0] * N
p = {tsorted[0]: -1}
for v in tsorted:
    ans[v] = p[v]
    for next_v in nl[v]:
        p[next_v] = v
for a in ans:
    print(a + 1)

Measured memory_bytes: 69552
n,k = map(int,input().split())
gcd_num = [0 for i in range(k+1)]
c = 10**9 + 7
ans = 0
for i in range(k,0,-1):
  x = k//i
  #gcd = xを満たす何組あるかのあまりを計算
  #あまりを取らないとオーバーフローする
  gcd_num[i] = pow(x,n,c)
  #重複するのを取り除く
  for j in range(2,x+1):
    gcd_num[i] -= gcd_num[i * j]
  #最後にgcdの大きさによる重み付けする
  ans += gcd_num[i] * i
  
print(ans%c)
  
  
  
  
  

Measured memory_bytes: 11344
#include<stdio.h>
#include<stdlib.h>
int comp(const void *p,const void *q){
	return *(int *)p - *(int *)q;
}
int main(){
	int i,j,n,m,t[205],w[105],s[105],e[105],p;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d%d%d",&w[i],&s[i],&e[i]);
			t[i*2]=s[i];t[i*2+1]=e[i];
		}
		qsort(t,n*2,sizeof(int),comp);
		for(i=0;i<n*2;i++){
			p=0;
			for(j=0;j<n;j++){
				if(t[i]>=s[j] && t[i]<e[j])p+=w[j];
			}
			//printf("%3d:%d\n",t[i],p);
			if(p>150)break;
		}
		printf("%s\n",(i==n*2)?"OK":"NG");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int char2int(char c) {
  return int(c-'0');
}
int main() {
  string N;
  int K;
  cin >> N >> K;
  int D = N.size();
  vector<vector<ll> > dp(D, vector<ll>((K+1)*2));
  dp[0][0] = 1;
  dp[0][0+K+1] = 0;
  dp[0][1] = char2int(N[0])-1;
  dp[0][1+K+1] = 1;
  REP(i, 1, D) {
    int tmp = char2int(N[i]);
    rep(k, K+1) {
      if(k) { // k>0
        dp[i][k] += dp[i-1][k-1] * 9;
        if(tmp) { // tmp>0
          dp[i][k] += dp[i-1][k+K] * (tmp-1);
          dp[i][k+K+1] += dp[i-1][k+K];
        }
      }
      dp[i][k] += dp[i-1][k];
      if(tmp) dp[i][k] += dp[i-1][k+K+1];
      else dp[i][k+K+1] += dp[i-1][k+K+1];
    }
  }
  cout << dp[D-1][K] + dp[D-1][2*K+1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int gcd(int a, int b) {
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}
int main(void) {
    int N,X;cin>>N>>X;
    vector<int> x(N);
    for (int i = 0; i < N; i++) cin>>x[i];
    vector<int> dist(N);
    int cur = abs(X - x[0]);
    for (int i = 1; i < N; i++) {
        cur = gcd(abs(X - x[i]), cur);
    }
    cout << cur << endl;
    return 0;
}

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

#define print(x) cout << #x << '=' << x << endl


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

	int M= N, sum=0;
	while(M!=0)
	{
		sum += M%10;
		M=M/10;
	}
	// print(sum);
	if(N%sum==0)
		cout << "Yes\n";
	else 
		cout << "No\n";
   	return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
typedef long long ll;
const ll mod = 1e9+7;//998244353
int t = 1;
/*
int rooms,psgs;
vector<int> a[(int)1e5 + 3];
vector<int> p((int)1e5 + 3 , 0);
vector<bool> v((int)1e5 + 3, false);

void dfs(int cur) {
  vector<int>
  for(auto &i:a[cur]) {
    if(v[i])  continue;
    p[i] = cur;
    v[i]=true;
  }
}*/

void solve(int BYasD) {
  ll a;  cin>>a;
  long double b;  cin>>b;
  cout<<(ll)(a*b)<<'\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif
  //cin>>t;
  rep(i,t)  {
  //  cout<<"Case #"<<(i+1)<<'\n';
    solve(i);
    //cout<<'\n';
  }
  return 0;
}


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

int a, b;
int i = 0;

int N;

vector<int> P, Q;
vector<bool> used;
vector<int> perm;

void dfs(int pos) {
    if (pos == N) {
        // calc
        i++;

        if (perm == P) {
            a = i;
        }
        if (perm == Q) {
            b = i;
        }

        return;
    }
    
    for (int j = 1; j <= N; j++)
    {
        if (!used[j]) {
            perm[pos] = j;
            used[j] = true;
            dfs(pos+1);
            used[j] = false; // ここでposで回り続けるからこれでok
        }
    }
}


int main() {
    cin >> N;

    used = vector<bool>(N+1, false);
    perm = vector<int>(N);

    P = Q = vector<int>(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> Q[i];
    }

    dfs(0);

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <mutex>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <vector>
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define SQR(x) (x) * (x)
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);
int bpm(int x, unsigned int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = SQR(x);
    x %= MOD;
  }
  return ans;
}
int LIST[100000 + 10]{};
signed main() {
  int N, K;
  cin >> N >> K;
  for (int i = 100000; i >= 1; i--) {
    LIST[i] = bpm(K / i, N) * i;
    for (int j = 2; i * j <= K; j++) {
      LIST[i] -= LIST[i * j] / (i * j) * i;
    }
  }
  int ans = accumulate(ALL(LIST), 0LL) % MOD;
  cout << ans << endl;
}


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

int main(void) {
    int N; cin >> N;
    while(N) {
        int x = N%10;
        if(x==7) {
            cout << "Yes" << endl;
            return 0;
        }
        N/=10;
    }
    cout << "No" << endl;
}

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

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> c(H,vector<char>(W));
  vector<bool> b1(H),b2(W);
  vector<vector<bool>> b(H,vector<bool>(W));
  
  for(int i=0;i<H;i++){
    b1.at(i)=false;
    for(int j=0;j<W;j++){
      cin>>c.at(i).at(j);
      b2.at(j)=false;
    }
  }
  
  for(int i=0;i<H;i++){
    int mark=0;
    for(int j=0;j<W;j++){
      if(c.at(i).at(j)=='#'){mark=1;break;}
    }
    if(mark==0){b1.at(i)=true;}
  }
  
  for(int i=0;i<W;i++){
    int mark=0;
    for(int j=0;j<H;j++){
      if(c.at(j).at(i)=='#'){mark=1;break;}
    }
    if(mark==0){b2.at(i)=true;}
  }
  
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(b1.at(i)){continue;}
      if(b2.at(j)){continue;}
      cout<<c.at(i).at(j);
    }
    if(b1.at(i)){continue;}
    cout<<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<int, pii> pip;


int main(void)
{
    int H,W;
    cin >> H >> W;
    int ch,cw;
    cin >> ch >> cw;
    ch--;cw--;
    int dh,dw;
    cin >> dh >> dw;
    dh--;dw--;

    vector<string> S(H);
    REP(i,H) cin >> S[i];
    
    vector<vector<int>> ok(H, vector<int>(W, -INF));
    ok[ch][cw] = -1;
    priority_queue<pip> q;
    q.push({-1, {ch, cw}});
    int dx[4]={-1,1,0,0}, dy[4]={0,0,-1,1};
    while(!q.empty()){
        auto f = q.top(); q.pop();
        REP(i, 4){
            int h = f.se.fi + dx[i];
            int w = f.se.se + dy[i];
            if(0<=h&&h<H&&0<=w&&w<W){
                if(S[h][w]=='.' && chmax(ok[h][w], f.fi)){
                    q.push({f.fi, {h,w}});
                }
            }
        }

        Rep(x, -2, 3) Rep(y, -2, 3){
            if(x==0&&y==0) continue;
            int h = f.se.fi + x;
            int w = f.se.se + y;
            if(0<=h&&h<H&&0<=w&&w<W){
                if(S[h][w]=='.' && chmax(ok[h][w], f.fi-1)){
                    q.push({f.fi-1, {h,w}});
                }
            }
        }
    }

    if(ok[dh][dw]==-INF)pr(-1);
    else pr(-(ok[dh][dw]+1));
}

Measured memory_bytes: 9552