akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t dceil(int64_t, int64_t);
int64_t dfloor(int64_t, int64_t);

int64_t dceil(int64_t x, int64_t y)
{
    if (y < 0) {
        return dceil(-x, -y);
    }
    if (x < 0) {
        return -dfloor(-x, y);
    }
    return (x + y - 1) / y;
}

int64_t dfloor(int64_t x, int64_t y)
{
    if (y < 0) {
        return dfloor(-x, -y);
    }
    if (x < 0) {
        return -dceil(-x, y);
    }
    return x / y;
}

int main()
{
    int64_t t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    a1 -= b1;
    a2 -= b2;
    if (a1 < 0) {
        a1 *= -1;
        a2 *= -1;
    }

    int64_t p = a1 * t1 + a2 * t2;
    if (p == 0) {
        cout << "infinity" << endl;
    } else if (p > 0) {
        cout << 0 << endl;
    } else {
        int64_t q = a1 * t1;
        int64_t x = dfloor(-q, p);

        int64_t result = 2 * x;
        if (q % (-p) != 0) {
            result++;
        }
        cout << result << endl;
    }
    return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> xs(m), ys(m), zs(m);
	for (int i = 0; i < m; i++)
	{
		cin >> xs[i] >> ys[i] >> zs[i];
		xs[i]--;
		ys[i]--;
	}

	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++)
	{
		g[xs[i]].emplace_back(ys[i]);
		g[ys[i]].emplace_back(xs[i]);
	}

	int ans = 0;

	vector<bool> done(n, false);
	for (int i = 0; i < n; i++)
	{
		if (done[i])
		{
			continue;
		}
		ans++;
		stack<int> st;
		st.emplace(i);
		while (!st.empty())
		{
			int now = st.top();
			st.pop();
			if (done[now])
			{
				continue;
			}
			done[now] = true;
			for (auto &next : g[now])
			{
				if (done[next])
				{
					continue;
				}
				st.emplace(next);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7672
INF = 1<<29
def dijkstra(n, from, route, time)
  arr = [from]
  dist = [INF]*n
  dist[from] = 0
  until arr.empty?
    a = arr.min{ |x, y| dist[x] <=> dist[y] }
    arr.delete(a)
    route[a].each do |b|
      d = dist[a] + time[a][b]
      if (old = dist[b]) > d
        dist[b] = d
        if old == INF
          arr << b 
        end
      end
    end
  end
  dist
end
 
loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0
  route_l = n.times.map{ [] }
  time_l = n.times.map{ [] }
  route_s = n.times.map{ [] }
  time_s = n.times.map{ [] }
  m.times do
    tmp = gets.split
    x, y, t = tmp[0,3].map(&:to_i)
    x -= 1; y -= 1
    if tmp[-1] == "L"
      route_l[x] << y; route_l[y] << x
      time_l[x][y] = time_l[y][x] = t
    else
      route_s[x] << y; route_s[y] << x
      time_s[x][y] = time_s[y][x] = t
    end
  end
  l_time = n.times.map{ |i| dijkstra(n, i, route_l, time_l) }
  s_time = n.times.map{ |i| dijkstra(n, i, route_s, time_s) }
  gets  
  dest = gets.split.map(&:to_i).map{ |i| i-1 }
  bpos = [INF]*n
  bpos[dest[0]] = 0
  dest.each_cons(2) do |s, t|
    new_bpos = [INF]*n
    n.times do |nxt|
      min_t = bpos[nxt] + l_time[s][t]
      n.times do |pre|
        time = bpos[pre] + l_time[s][pre] + s_time[pre][nxt] + l_time[nxt][t]
        min_t = time if time < min_t
      end
      new_bpos[nxt] = min_t
    end
    bpos = new_bpos
  end
  p bpos.min
end

Measured memory_bytes: 16240
program abc133d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n, i
    integer(int32), allocatable:: a(:), ans(:)

    read*, n
    allocate(a(n))
    allocate(ans(n))
    read*, a(:)

    ans(1) = (sum(a(1:n:2)) - sum(a(2:n:2)))
    ans(n) = 2*a(n) - ans(1)
    do i=n-1,2,-1
        ans(i) = 2*a(i) - ans(i+1)
    end do
    print'(*(i0,1x))', ans(:)
end program abc133d

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <cassert>
constexpr int P = 1'000'000'007;
int n, x;
std::vector<int> cl, factorial, invFactorial;
std::vector<std::vector<int>> dp;
int power(int a, int b) {
    int ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = 1LL * ans * a % P;
        a = 1LL * a * a % P;
        b >>= 1;
    }
    return ans;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n >> x;
    ++x;
    cl.resize(x + 1);
    for (int i = 0; i < n; ++i) {
        int l;
        std::cin >> l;
        ++cl[l];
    }
    dp.assign(x + 1, std::vector<int>(x + 1));
    dp[0][0] = P - 1;
    factorial.resize(x + 1);
    invFactorial.resize(x + 1);
    factorial[0] = 1;
    for (int i = 1; i <= x; ++i)
        factorial[i] = 1LL * factorial[i - 1] * i % P;
    for (int i = 0; i <= x; ++i)
        invFactorial[i] = power(factorial[i], P - 2);
    for (int l = x; l >= 1; --l) {
        for (int c = x / l; c >= 0; --c) {
            for (int s = 0; s <= x; ++s) {
                if (dp[c][s] == 0)
                    continue;
                for (int i = 1; i * l + s <= x; ++i) {
                    if (i % 2 == 0) {
                        dp[c + i][s + i * l] = (dp[c + i][s + i * l] + 1LL * dp[c][s] * invFactorial[i]) % P;
                    } else {
                        dp[c + i][s + i * l] = (dp[c + i][s + i * l] + 1LL * (P - dp[c][s]) * invFactorial[i]) % P;
                    }
                }
            }
        }
        for (int i = 0; i < cl[l]; ++i)
            for (int c = 0; c <= x; ++c)
                for (int s = 0; s <= x; ++s)
                    dp[c][s] = 1LL * dp[c][s] * (s - l * c) % P;
    }
    int ans = 0;
    for (int c = 0; c <= x; ++c)
        ans = (ans + 1LL * factorial[c] * dp[c][x]) % P;
    std::cout << ans << "\n";
    return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
signed main() {
    cin >> N;
    reps(i, N) {
        if (floor(i * 1.08) == N) { fin(i); }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int r;
  scanf("%d",&r);
  char *ans;
  if(r<1200){
    ans="ABC";
  }else if(r<2800){
    ans="ARC";
  }else{
    ans="AGC";
  }
  printf("%s",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

//区間和
struct RSQ{
    ll n;
    vector<dd>data;
    RSQ(ll vs){
        n=1;
        while(n<vs)n*=2;
        data.resize(2*n-1,1);
    }
    void update(ll k,dd a){
        k+=n-1;
        data[k]=a;
        while(k>0){
            k=(k-1)/2;
            data[k]=data[2*k+1]*data[2*k+2];
        }
    }
    dd query(ll a,ll b,ll k,ll l,ll r){
        if(r<=a||b<=l)return 1;
        if(a<=l&&r<=b){
            return data[k];
        }else{
            dd vl=query(a,b,2*k+1,l,(l+r)/2);
            dd vr=query(a,b,2*k+2,(l+r)/2,r);
            return vl*vr;
        }
    }
    dd query(ll a,ll b){return query(a,b,0,0,n);}//[a,b)の和
};
//////////////////////////////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll t[n],a[n];rep(i,0,n-1)cin>>t[i]>>a[i];
    ll q;cin>>q;
    ll l[q],r[q];rep(i,0,q-1)cin>>l[i]>>r[i];
    vector<ll>v;
    rep(i,0,n-1)v.pb(t[i]);
    rep(i,0,q-1){
        v.pb(l[i]);v.pb(r[i]);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    ll vs=v.size();
    rep(i,0,n-1)t[i]=lower_bound(v.begin(),v.end(),t[i])-v.begin();
    rep(i,0,q-1){
        l[i]=lower_bound(v.begin(),v.end(),l[i])-v.begin();
        r[i]=lower_bound(v.begin(),v.end(),r[i])-v.begin();
    }
    RSQ u(vs+1);
    rep(i,0,n-1){
        dd p=(dd)(100-a[i]*10)/100.0;
        u.update(t[i],p);
    }
    rep(i,0,q-1){
        dd ans=1E9;
        ans*=u.query(l[i],r[i]+1);
        cout<<setprecision(20)<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 24948
# coding: utf-8
import sys
from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as np
#import queue# queue,get(), queue.put()
def run():
    N = int(input())
    current = 0
    ways = []
    dic = {'(': 1, ')': -1}
    SS = read().split()

    for S in SS:
        path = [0]
        for s in S:
            path.append(path[-1]+ dic[s])
        ways.append((path[-1], min(path)))

    ways_pos = sorted([(a,b) for a,b in ways if a >= 0], key = lambda x:(x[1], x[0]), reverse=True)
    ways_neg = sorted([(a,b) for a,b in ways if a < 0], key = lambda x:(x[1] - x[0], -x[0]))

    for i in range(len(ways_pos)):
        go, max_depth = ways_pos[i]
        if current + max_depth >= 0:
            current += go
        else:
            print("No")
            return None

    for i in range(len(ways_neg)):
        go, max_depth = ways_neg[i]
        if current + max_depth >= 0:
            current += go
        else:
            print("No")
            return None

    if current == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    run()

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

set<int> x_dp[8000],y_dp[8000];
vector<int> x_move,y_move;

int main() {

    string s;

    cin >> s;

    bool is_x = true;

    int count = 0;

    s.push_back('T');

    for(int i=0; i<s.size(); i++){
        if(s[i] == 'T'){
            if (is_x) {
                x_move.push_back(count);
            } else {//!is_x
                y_move.push_back(count);
            }
            count = 0;
            is_x = !is_x;
        }
        else{//s[i] == 'F'
            count++;
        }
    }

    if (is_x) {
        x_move.push_back(count);
    } else {//!is_x
        y_move.push_back(count);
    }

    if(s[0] == 'F' && x_move.size() != 0){
        x_dp[0].insert(x_move[0]);
    }
    else if(x_move.size() != 0){
        x_dp[0].insert(x_move[0]);
        x_dp[0].insert(-x_move[0]);
    }

    if(y_move.size() != 0){
        y_dp[0].insert(y_move[0]);
        y_dp[0].insert(-y_move[0]);
    }

    for(int i=1; i<x_move.size(); i++){
        for(auto itr_num : x_dp[i-1]){
            x_dp[i].insert(itr_num + x_move[i]);
            x_dp[i].insert(itr_num - x_move[i]);
        }
    }

    for(int i=1; i<y_move.size(); i++){
        for(auto itr_num : y_dp[i-1]){
            y_dp[i].insert(itr_num + y_move[i]);
            y_dp[i].insert(itr_num - y_move[i]);
        }
    }

    int goal_x,goal_y;

    cin >> goal_x >> goal_y;

    string ans = "No";

    if(x_dp[x_move.size()-1].find(goal_x) != x_dp[x_move.size()-1].end() && y_dp[y_move.size()-1].find(goal_y) != y_dp[y_move.size()-1].end()){
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

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

namespace ITP1_4_D
{
    class Program
    {
        static void Main(string[] args)
        {
            //n個の整数ai(i=1,2,...n)を入力し、それらの最小値、最大値、合計値を求める

            int n=int.Parse(Console.ReadLine());
            List<long> inputs = Console.ReadLine().Split(' ').Select(t => long.Parse(t)).ToList();
            Console.WriteLine("{0} {1} {2}", inputs.Min(), inputs.Max(), inputs.Sum());
        }
    }
}



Measured memory_bytes: 18372
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int side(int from, int to){
  return (to+2) % 3 - (from+2)%3;
}
int main(){
  string s;
  while(cin>>s && s != "#"){
    int N = s.size();
    int dp[100001][2] = {};
    FOR(i, 1, 100000)REP(j,2)dp[i][j] = INF;
    FOR(i, 1, N){
      dp[i][0] = dp[i-1][0] + 1;
      dp[i][1] = dp[i-1][1] + 1;
      if(side(s[i-1], s[i]) >= 0) dp[i][1] = min(dp[i][1], dp[i-1][0]);
      if(side(s[i-1], s[i]) <= 0) dp[i][0] = min(dp[i][0], dp[i-1][1]);
    }
    cout<<min(dp[N-1][0], dp[N-1][1])<<endl;
  }
  return 0;
}

Measured memory_bytes: 1916
#include<iostream>
#include<queue>
using namespace std;
int main(){
	string a;
	cin>>a;
	deque<char> d;
	int f=0;
	for(int i=0;i<a.size();i++) d.push_back(a[i]);
	int t;
	cin>>t;
	while(t--){
		int x;
		cin>>x;
		if(x==1) f^=1;
		else{
			int j;
			char c;
			cin>>j>>c;
			j--;
			if(j^f) d.push_back(c);
			else d.push_front(c);
		}
	}
	if(!f) while(!d.empty()) cout<<d.front(),d.pop_front();
	else while(!d.empty()) cout<<d.back(),d.pop_back();
}


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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0)
            break;

        int result = 0;
        for (int i = 5; i <= n; i++) {
            if (i % 5 == 0) {
                int temp = i;
                while (temp % 5 == 0) {
                    temp /= 5;
                    result++;
                }
            }
        }
        cout << result << endl;
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<ll> kaisuu(n,-1);
    ll now = 0;
    ll next;
    ll times = 0;
    while(true){
        ++times;
        next = a.at(now)-1;
        if(kaisuu.at(next) == -1){
            kaisuu.at(next) = times;
            now = next;
        }else{
            break;
        }
    }
    if(k < times){
        for(i = 0;i < n;++i){
            if(kaisuu.at(i) == k){
                cout << i+1 << endl;
                return 0;
            }
        }
    }else{
        ll syuuki = times - kaisuu.at(next);
        k -= times;
        k %= syuuki;
        now = next;
        while(k){
            next = a.at(now)-1;
            now = next;
            --k;
        }
        cout << now+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6408
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 18:11:44
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}


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

int main()
{
    std::string S;
    std::cin >> S;

    if (S <= "2019/04/30")
    {
        std::cout << "Heisei" << std::endl;
    }
    else
    {
        std::cout << "TBD" << std::endl;
    }

    return 0;
}

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

n,q = map(int,input().split())
imos = []
for i in range(n):
    s,t,x = map(int,input().split())
    imos.append((s-x,x))
    imos.append((t-x,-x))
ans = set()
j = 0
for i in range(q):
    d = int(input())
    imos.append((d,1e100))
imos.sort()
m = 1e100
flag = False
for t,stop in imos:
    if stop == 1e100:
        if ans:
            if not flag:
                m = min(ans)
                flag = True
            print(m)
        else:
            print(-1)
    elif stop > 0:
        ans.add(stop)
        if stop < m:
            m = stop
            flag = True
    else:
        ans.remove(-stop)
        if m == -stop:flag = False


Measured memory_bytes: 90532
import bisect

A,B,Q=map(int,input().split())
S=[int(input()) for i in range(A)]
T=[int(input()) for i in range(B)]
X=[int(input()) for i in range(Q)]

def search(x):
    s=bisect.bisect_right(S,x)
    t=bisect.bisect_right(T,x)
    bs1=max(s-1,0)
    bt1=max(t-1,0)
    bs2=min(s,A-1)
    bt2=min(t,B-1)
    r1=abs(S[bs1]-x)+abs(S[bs1]-T[bt1])
    r2=abs(S[bs1]-x)+abs(S[bs1]-T[bt2])
    r3=abs(S[bs2]-x)+abs(S[bs2]-T[bt1])
    r4=abs(S[bs2]-x)+abs(S[bs2]-T[bt2])
    r5=abs(T[bt1]-x)+abs(T[bt1]-S[bs1])
    r6=abs(T[bt1]-x)+abs(T[bt1]-S[bs2])
    r7=abs(T[bt2]-x)+abs(T[bt2]-S[bs1])
    r8=abs(T[bt2]-x)+abs(T[bt2]-S[bs2])
    r=min([r1,r2,r3,r4,r5,r6,r7,r8])
    return r

for i in X:
    print(search(i))

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

typedef long long ll;

void printArray(vector<int> arr) {
	for (int a: arr) cout << a << " ";
	cout << '\n';
}

int h[100001];
int dp[100001];

int main() {
	std::ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i =0; i<n; i++) cin >> h[i];
	dp[0] = 0;
	for (int i = 1; i<n; i++) {
		dp[i] = dp[max(0, i-k)] + abs(h[i] - h[max(0, i-k)]);
		for (int j = max(0, i-k) + 1 ; j<i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	} 
	cout << dp[n-1] << '\n';
}



Measured memory_bytes: 4444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (k % 2) {
		cout << k / 2 * (k / 2 + 1) << endl;
	}
	else {
		cout << k*k / 4 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
class Dice:
    def __init__(self,l1,l2,l3,l4,l5,l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.top = 1
        self.front = 2
        self.right = 3

    def get_up_front(self):
        return eval("("+"self." + 'l' + str(self.top)+","+"self." + 'l' + str(self.front)+")")

    def get_right(self):
        return eval("self." + 'l' + str(self.right))

    def rot(self):
        self.front,self.right = self.right,7-self.front

    def move(self, order):
        if order == 'S':
            pretop = self.top
            self.top = 7 - self.front
            self.front = pretop
        elif order == 'E':
            pretop = self.top
            self.top = 7 - self.right
            self.right = pretop
        elif order == 'N':
            pretop = self.top
            self.top = self.front
            self.front = 7 - pretop
        elif order == 'W':
            pretop = self.top
            self.top = self.right
            self.right = 7 - pretop

l = list(map(int,input().split()))
q = int(input())
d = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

for i in range(q):
    up,front = list(map(int,input().split()))
    while (up,front) != d.get_up_front():
        for j in range(4):
            d.move('S')
            if up == d.get_up_front()[0]:
                break
        if up != d.get_up_front()[0]:
            for l in range(4):
                d.move('E')
                if up == d.get_up_front()[0]:
                    break
        for k in range(4):
            d.rot()
            if front == d.get_up_front()[1]:
                break
    print (d.get_right())

Measured memory_bytes: 7804
#include <iostream>
#include <cstdio>

using namespace std;

string s1, s2;

int main()
{
	cin >> s1 >> s2;
	cout << s1[0];
	for (int i = 0; i < s1.length() + s2.length() - 1; i++)
		if (i % 2 == 0) cout << s2[i / 2];
		else cout << s1[i / 2 + 1];
	return 0;
}

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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define floot10 cout<<fixed<<setprecision(10);
int t[100005];

signed main(){
  int n;
  cin>>n;
  vector<pair<int,int> > p;
  lp(i,n){
    int s,t2;
    cin>>s>>t2;
    p.push_back(make_pair(s,t2));
  }
  sort(p.begin(),p.end());
  int ans=0;
  t[0]=-1;
  lp(i,n){
    for(int j=ans;j>=0;j--){
      if(t[j]!=0){
	if(t[j]<p[i].first){
	  t[j+1]=min(t[j+1],p[i].second);
	  if(t[j+1]==0)t[j+1]=p[i].second;
	  ans=max(ans,j+1);
	  break;
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 5272
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 101;
int a[MAXN][MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M, N;
    cin >> M >> N;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
            if (i > 0) a[i][j] ^= 1;
        }
    }
    int ans = 0;
    if (N == 1) {
        for (int i = 0; i < M; i++) {
            ans += a[i][0];
        }
        cout << ans << endl;
        return 0;
    } else {
        for (int i = 0; i < M; i++) {
            int maxi = 0;
            // ?????? 0, ?????? 1
            {
                int tmp = a[i][0];
                for (int j = 1; j < N; j++) {
                    tmp += (a[i][j]^1);
                }
                maxi = max(maxi, tmp);
            }
            // ?????? 0, ?????? 1
            {
                int tmp = a[i][N-1];
                for (int j = N-2; j >= 0; j--) {
                    tmp += (a[i][j]^1);
                }
                maxi = max(maxi, tmp);
            }
            // ?????£?????? 0
            if (N > 2) {
                int tmp = a[i][0] + a[i][N-1];
                bool ok = false;
                for (int j = 1; j < N-1; j++) {
                    if (a[i][j] == 1) ok = true;
                }
                if (ok) {
                    tmp += 1;
                    for (int j = 1; j < N-1; j++) {
                        if (a[i][j] == 0) tmp++;
                    }
                    maxi = max(maxi, tmp);
                }
            }
            ans += maxi;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(2);
  vector<int> c(N,0);
 for(int i=0;i<M;i++){
     cin >> vec.at(0)>>vec.at(1);
     for(int j=1;j<=N;j++){
        if(vec.at(0)==j||vec.at(1)==j){
            c.at(j-1)++;}
            
     }
 }
 for(int k=0;k<N;k++){
     cout << c.at(k)<<endl;
 }
}

Measured memory_bytes: 3516
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

typedef long long i64;

int main()
{
	vector<int> a;
	vector<int> pos;
	int n;

	scanf("%d", &n);
	pos.resize(n);
	a.resize(n);
	for(int i = 0; i < n; ++i) {
		int t;
		scanf("%d", &t);
		a[i] = t - 1;
		pos[t - 1] = i;
	}

	i64 s = 0;
	set<int> sec;

	// 1
	s += (i64)(pos[0] + 1) * (i64)(n - pos[0]);
	sec.insert(pos[0]);

	for(int x = 1; x < n; ++x) {

		int p = pos[x];

		auto w = sec.lower_bound(p);

		int r = (w == sec.end() ? n : *w);
		int l = (w == sec.begin() ? -1 : *(--w));

		//printf("%d -> %d %d\n", x + 1, l, r);
		s += (i64)(p - l) * (i64)(r - p) * (x + 1);

		sec.insert(p);
	}

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

	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

int main(){

    int n; cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(all(a));
    if(a.at(0) == 0){
        cout << 0 << endl;
        return 0;
    } 
    rep(i,n){
        ll temp = 1000000000000000000/ans;
        if(a.at(i) > temp){
            cout << -1 << endl;
            return 0;
        }
        ans *= a.at(i);
    }
    cout << ans << endl;

    return 0;

}

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

int main(void) {
    int n;
    int s[1000] = {};
    double m, a;
    
    while(true) {
        m = 0;
        a = 0;
        cin >> n;
        
        if(n == 0)   break;
        
        for(int i = 0; i < n; ++i) {
            cin >> s[i];
            m += s[i];
        }
        m /= n;
        
        for(int i = 0; i < n; ++i) {
            a += (s[i] - m)*(s[i] - m);
        }
        a = sqrt(a / n);
        
        printf("%lf\n", a);
    }
    
    return 0;
}



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

int main(){
	int n;
	cin >> n;
	vector<int> d(n), c(13,0);
	for(int i=0; i<n; i++){
		cin >> d[i];
		c[d[i]]++;
	}
	c[0]++;
	
	vector<bool> con(25, false);
	vector<int> nd;
	for(int i=0; i<13; i++){
		if(( (i==0||i==12)&&c[i]>1 ) || c[i]>2){
			cout << 0 << endl;
			return 0;
		}
		if(c[i]==2 || (c[i]==1&&(i==0||i==12))){
			con[i] = con[24-i] = true;
			c[i] = 0;
		}
		if(c[i]==1){
			nd.push_back(i);
		}
	}
	
	n = nd.size();
	int ans=0;
	if(n==0){
		int tmin = 100;
		int tmp=100;
		for(int j=0; j<24; j++){
			if(con[j]){
				tmin = min(tmin, tmp);
				tmp=1;
			}else{
				tmp++;
			}
		}
		ans = max(ans, tmin);
	}
	for(int i=0; i<(1<<n); i++){
		vector<bool> tcon = con;
		for(int j=0; j<n; j++){
			if((i&(1<<j))!=0){
				tcon[nd[j]] = true;
			}else{
				tcon[24-nd[j]] = true;
			}
		}
		int tmin = 100;
		int tmp=100;
		for(int j=0; j<25; j++){
			if(tcon[j]){
				tmin = min(tmin, tmp);
				tmp=1;
			}else{
				tmp++;
			}
		}
		ans = max(ans, tmin);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long a,b,h,m;
    cin >> a >> b >> h >> m;
  a*= 1000000; b*= 1000000;
    double pi = 3.14159265358979323846;
    double kaku = ((double)(m*6 - h*30)-m/(double)2.0)*pi/(double)180.0;
    double c = 2.0*a*b*cos(kaku);
    double d = a*a+b*b-c;
    double k = sqrt(d)/1000000.0;
    printf("%.9f\n", k);
}

Measured memory_bytes: 4140
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,i;
string s;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s;
	n=(int)s.size();
	for(i=1;i<=n;i++)cout<<'x';
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

N = int(input())

def yakusuu(n):
    lst = []
    for i in range(1, int(math.sqrt(n))+1):
        if(n%i == 0):
            lst.append(i)
    return lst

lst = yakusuu(N)

ans = 10**18
for i in range(len(lst)):
    a = lst[i]
    b = N//lst[i]
    
    ans = min(ans, (a-1)+(b-1))
print(ans)

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

lint mpow(lint x,lint y){
    if(y==0) return 1LL;
    if(y==1) return x%MOD;
    return mpow(x*x%MOD,y/2)*(y%2==0?1:x)%MOD;
}

int main(){
    int cnt[100001];
    lint N;
    cin >> N;
    for(int i=0;i<=N;i++) cnt[i]=0;

    for(int i=0;i<N;i++){
        lint A;
        cin >> A;
        if(N%2==A%2 || cnt[A]>=2){
            cout << "0" << endl;
            return 0;
        }
        cnt[A]++;
    }
    if(N%2==1 && cnt[0]!=1){
        cout << "0" << endl;
        return 0;
    }
    cout << mpow(2LL,N/2) << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int t = 0;
    ll ans = 0;
    rep(i,n) {
        if(t <= a[i]) t = a[i];
        else {
            ans += t-a[i];
        }  
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
r,c = map(int,input().split())
cel = []
com = [0] * (c + 1)
for i in range(r + 1):
  if i < r:
    cel.append(list(map(int,input().split())))
    cel[i].append(sum(cel[i]))
    com = [x + y for (x,y) in zip(com, cel[i])]
  if i == r:
    cel.append(com)
  cel[i] = ' '.join(map(str,cel[i]))
[print(result) for result in cel]


Measured memory_bytes: 5628
# https://atcoder.jp/contests/abc080/tasks/abc080_c
# 普通にbit全探索では？

N = int(input())
F = []
for _ in range(N):
    F.append(list(map(int, input().split())))
P = []
for _ in range(N):
    P.append(list(map(int, input().split())))

bitlen = 10


def ret_score(n: int):
    # 営業時間かぶり計算
    C = []
    for i in range(N):  # Nでiter
        cnt = 0
        for bit in range(bitlen):  # 桁とFを対応
            if ((n >> bit) & 1) and F[i][bit]:  # もし1その桁で1なら
                cnt += 1
        C.append(cnt)

    # スコア計算
    ret = 0
    for i, c in enumerate(C):
        ret += P[i][c]
    return ret


ans = -10**10
for n in range(1, 1 << bitlen):
    ans = max(ans, ret_score(n))
print(ans)


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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define sv(v) sort(v.begin(),v.end());
#define mod 1000000007
#define M 100005
vector<int> ans;
int a,b,c,m;

void answer(){
    ll n,m,k,o;
    cin>>n>>m>>k>>o;
    while(o--){
        if(m<=n){
            m = m*2;
        }
        else if(k<=m){
            k = k*2;
        }
    }
    if(n<m && m<k) cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
 
public class Main{  
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
public  static void main(String[] args)   throws Exception, IOException{
 
    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);
    // int n = sc.nextInt() ;
    int h = sc.nextInt(),w = sc.nextInt();
    char bd[][]=new char[h][w];
    for (int i=0; i<h; i++) {
    	bd[i] = sc.nextString().toCharArray();
    }
    int min[][]=new int[h][w];
    for (int i=0; i<h; i++) {
    	fill(min[i],10000);
 	}
 	min[0][0]=0;
 	dfs(0,0,min,bd,0);
 	int a=0;
 	int ans=min[h-1][w-1];
    for (int i=0; i<h; i++) {
    	for (int t=0;t<w ;t++ ) {
    		if(bd[i][t]=='.')a++;
    	}
 	}

	out.println(ans==10000?-1:a-ans-1);
    out.flush();
}

static void dfs(int x,int y,int min[][],char bd[][],int n){
	for (int i=0,xx,yy; i<4; i++) {
		xx=x+dx[i];
		yy=y+dy[i];
		if(validpos(xx,yy,bd.length,bd[0].length) && min[xx][yy]>n+1 && bd[xx][yy]=='.'){
			min[xx][yy]=n+1;
			dfs(xx,yy,min,bd,n+1);
		}
	}
}
 
static void db(Object... os){
 
    System.err.println(Arrays.deepToString(os));
 
}
 
static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}
 
}

class Pair {
    int d,g;
    Pair(int d, int g) {
        this.d=d;
        this.g=g;
    } 
}
 
 
class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
map<ll,ll> m;
ll div(ll h){
    if(h == 1ll) return 1ll;
    if(h == 2ll or h == 3ll) return 3ll;
    if(m.count(h) != 0)return m[h];
    return m[h] = div(h/2) + div(h/2) + 1;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll h;
    cin>>h;
    cout << div(h) << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
int main()
{
	ll modval = 1000000007;  // 10^9 + 7

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> pos, neg;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < 0)
			neg.push_back(a[i]);
		else
			pos.push_back(a[i]);
	}

	bool neg_answer = false;
	if (pos.size() == 0)
		neg_answer = (k % 2 == 1);
	else if (n == k)
		neg_answer = (neg.size() % 2 == 1);

	ll res = 1;
	if (neg_answer)
	{
		sort(a.begin(), a.end(), [](ll x, ll y)->bool {return abs(x) < abs(y);});  // the smallest abs(negative) at first
			
		for (int i = 0; i < k; i++)
		{
			res *= a[i]; res %= modval; res += modval; res %= modval;
		}
	}
	else
	{
		sort(pos.begin(), pos.end());    // the biggest at last
		sort(neg.rbegin(), neg.rend());  // the biggest abs(negative) at last

		if (k % 2 == 1)
		{
			res = pos.back(); pos.pop_back();
		}

		vector<ll> multvals;
		while (pos.size() >= 2)
		{
			ll multval = pos.back(); pos.pop_back();
			multval *= pos.back(); pos.pop_back();
			multvals.push_back(multval);
		}
		while (neg.size() >= 2)
		{
			ll multval = neg.back(); neg.pop_back();
			multval *= neg.back(); neg.pop_back();
			multvals.push_back(multval);
		}
		sort(multvals.rbegin(), multvals.rend());  // th biggest at first

		for (int i = 0; i < k / 2; i++)
		{
			ll multval = multvals[i]; multval %= modval;
			res *= multval; res %= modval;
		}
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 8092
#include <stdio.h>

int main() {
	int x, b, bingo[3][3] = {};
	bool bing[3][3] = {false};
	
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			scanf("%d", &bingo[i][j]);
		}
	}
	scanf("%d", &x);
	for(int i = 0; i < x; i++) {
		scanf("%d", &b);
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(b == bingo[j][k]) {
					bing[j][k] = true;
				}
			}
		}
	}
	
	if(bing[0][0] && bing[0][1] && bing[0][2] || bing[0][0] && bing[1][0] && bing[2][0]) {
		printf("Yes");
	} else if(bing[1][0] && bing[1][1] && bing[1][2] || bing[0][1] && bing[1][1] && bing[2][1]) {
		printf("Yes");
	} else if(bing[2][0] && bing[2][1] && bing[2][2] || bing[0][2] && bing[1][2] && bing[2][2]) {
		printf("Yes");
	} else if(bing[0][0] && bing[1][1] && bing[2][2] || bing[0][2] && bing[1][1] && bing[0][2]) {
		printf("Yes");
	} else {
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)

#define INF 1000000000000000000
#define MOD 1000000007

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int compare_long(const void *a, const void *b) {
  return *(long*)b - *(long*)a;
}

int main() {
  long H, W, N;
  long m;
  long i, j;
  long ans = 0;
  
  sl(H); sl(W); sl(N);
  m = MAX(H, W);
  ans = ceil(N / (double)m);
  
  pl(ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main(){
    int n, min, max;
    long int sum;
    cin >> n >> n; min = n; max = n; sum = n;
    while(cin >> n){
        if(n < min)
            min = n;
        if(n > max)
            max = n;
        sum += n;
    }
    cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main() {
    int S, hour, minute, second;
    cin >> S;
    hour = S / 3600;
    minute = (S % 3600) / 60;
    second = (S % 3600) % 60;
    cout << hour << ":" << minute << ":" << second << endl;
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int k,n,T;
int main(){
    cin>>n>>T;
    for(int i=1;i<=T;i++){
        int a;
        cin>>a;
        k=max(k,a);
    }
    cout<<max(k-1-(n-k),0)<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  co((a-c)*(b-d));
  
  return 0;
}


Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline
def solve():
  m = int(input())
  digit = 0
  s = 0
  for i in range(m):
    d,c = (int(i) for i in input().split())
    digit += d*c
    s += c
  print((digit-1)//9+s-1)
solve()

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int32_t main()
{
    int a;
    cin>>a;
    int res=a;
    res+=(a*a);
    res+=(a*a*a);
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 3624
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 24, 2018, 8:20 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*
 * 
 */

int isempty();

int isfull();

int pop();

void push(int data);

int MAXSIZE = 100;       
int stack[100];     
int top = -1;            

int main(int argc, char** argv) {
    int data1, data2, result;
    char save[1000];
    while(scanf("%s", save) != EOF)
    {
        if (save[0] == '+')
        {
            data1 = pop();
            data2 = pop();
            push(data1 + data2);
        }
        else if (save[0] == '-')
        {
            data2 = pop();
            data1 = pop();
            push(data1 - data2);
        }
        else if (save[0] == '*')
        {
            data1 = pop();
            data2 = pop();
            push(data1 * data2);
        }
        else
        {
            push(atoi(save));
        }
    }
    result = pop();
    printf("%d\n", result);
    return (EXIT_SUCCESS);
}

int isempty()
{
   if (top == -1)
        return 1;
   else
        return 0;
}
   
int isfull() 
{
    if (top == MAXSIZE)
        return 1;
    else
        return 0;
}

int pop()
{
   int data;
	
   if (!isempty()) {
        data = stack[top];
        top = top - 1;   
        return data;
    }    
   else 
   {
        printf("Could not retrieve data, Stack is empty.\n");
   }
}

void push(int data)
{
   if (!isfull()) 
   {
        top = top + 1;   
        stack[top] = data;
   } 
   else 
   {
        printf("Could not insert data, Stack is full.\n");
   }
}




Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007

int main() {
    int n,k;
    cin>>n>>k;
    long long int sum[n+2];
    sum[0]=0;
    for(int i=1;i<=n+1;i++)
    sum[i]=sum[i-1]+i;
    long long int ans=0;
    for(int i=k;i<=n+1;i++){
        ans+=(sum[n+1]-sum[n+1-i]-sum[i]+1);
        ans=ans%M;
    }
    cout<<ans<<endl;
}

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

int main() {
  int N,T;
  cin >> N >> T;
  long sum=0;
  int t[N];
  cin >> t[0];
  for(int i=1;i<N;i++){
    cin >> t[i];
    sum+=min(T,t[i]-t[i-1]);
  }
  sum+=T;
  cout << sum;
}



Measured memory_bytes: 1024
n=int(input())
lista = [int(i) for i in input().split()]

ans = 0
for i in range(1,n-1):
    if lista[i-1]>lista[i]>lista[i+1]:
        ans+=1
    elif lista[i-1]<lista[i]<lista[i+1]:
        ans+=1
print(ans)

Measured memory_bytes: 38256