akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] ABCD = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int ttW_Tak = (ABCD[2] - 1) / ABCD[1]; 
		int ttW_Aok = (ABCD[0] - 1) / ABCD[3];
		System.out.println(ttW_Tak <= ttW_Aok ? "Yes" : "No");
	}
}


Measured memory_bytes: 32452
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] S = new String[H];
		for(int i = 0;i < H;i ++) {
			S[i] = sc.next();
		}
		int[][] data = new int[H][W];
		for(int i = 0;i < H;i ++) {
			for(int k = 0;k < W;k ++) {
				char c  = S[i].charAt(k);
				if(c == '#') continue;
				char c1, c2, c3, c4, c5, c6, c7, c8;
				if(i != 0 && k != 0) {
					c1 = S[i-1].charAt(k-1);
					if(c1 == '#') data[i][k]++;
				}
				if(i != 0) {
					c2 = S[i-1].charAt(k);
					if(c2 == '#') data[i][k]++;
				}
				if(i != 0 && k != W - 1) {
					c3 = S[i-1].charAt(k+1);
					if(c3 == '#') data[i][k]++;
				}
				if(k != 0) {
					c4 = S[i].charAt(k-1);
					if(c4 == '#') data[i][k]++;
				}
				if(k != W - 1) {
					c5 = S[i].charAt(k+1);
					if(c5 == '#') data[i][k]++;
				}
				if(i != H - 1 && k != 0) {
					c6 = S[i+1].charAt(k-1);
					if(c6 == '#') data[i][k]++;
				}
				if(i != H -1) {
					c7 = S[i+1].charAt(k);
					if(c7 == '#') data[i][k]++;
				}
				if(i != H - 1 && k != W - 1) {
					c8 = S[i+1].charAt(k+1);
					if(c8 == '#') data[i][k]++;
				}
			}
		}
		for(int i = 0;i < H;i ++) {
			for(int k = 0;k < W;k ++) {
				char c = S[i].charAt(k);
				if(c != '#') System.out.print(data[i][k]);
				else System.out.print("#");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	signed long long N;
	double T,A;
	cin >> N >> T >> A;

	int num = -1;
	double d_min = 10e15;
	for(int i=0;i<N;i++){
		signed long long H;
		cin >> H;
		double tmp = T-H*0.006;
		double d = abs(A-tmp);
		if(d < d_min){
			num = i;
			d_min = d;
		}
	}
	cout << num+1 << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $y);
$y /= 1000;
if ($y > 10 * $n || $y < $n) exit('-1 -1 -1');
for ($c = $y % 5; $c <= $n; $c += 5) {
	$n2 = $n - $c;
	$y2 = $y - $c;
	$b = $n2 * 2 - $y2 / 5;
	if ($b >= 0 && $b <= $n2) {
		$a = $n2 - $b;
		exit("$a $b $c");
	}
}
echo '-1 -1 -1';

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

typedef long long ll;

void maxHeap(vector<ll> &h, int i){
    int left = i*2+1;
    int right = i*2+2;
    int largest = i;
    if(left < h.size() && h[left] > h[largest]) largest = left;
    if(right < h.size() && h[right] > h[largest]) largest = right;

    if(largest != i){
        swap(h[largest],h[i]);
        maxHeap(h,largest);
    }
}

void buildMaxHeap(vector<ll> &heap){
    for(int i=heap.size()/2;i>=0;i--){
        maxHeap(heap, i);
    }
}

void input(vector<ll> &heap, int i){
    int sub=i+1;
    if(sub <= 1)return;
    if(heap[sub-1] > heap[sub/2-1]){
        swap(heap[sub-1], heap[sub/2-1]);
        input(heap, sub/2-1);
    }

}

void printheap(const vector<ll> &h){
    cout << "size: " << h.size() << endl;;
    for(int i=0;i<h.size();i++)cout <<" " << h[i];
    cout << "\n";
}


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

    vector<ll> heap;
    string str;
    ll num;
    cin >> str;
    while(str != "end"){
        if(str == "insert"){
            cin >> num;
            heap.push_back(num);
            input(heap, heap.size()-1);
        }else if(str == "print"){
            printheap(heap);
        }else{
            if(!heap.empty()){
                cout << heap.front() << endl;
                heap[0] = heap.back();
                heap.pop_back();
                maxHeap(heap, 0);
            }
        }
        cin >> str;
    }
    return 0;
}



Measured memory_bytes: 11128
/*=======================
Author    : Shounak Dey
Filename  : 1180a.cpp
=======================	*/
 
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
 
#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);
 
 
#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
 
 
#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
 
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}
 
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}
 
int main()
{
	fast_io;
	ll x;
	cin >> x;
	ll l=1,r=2;
	ll sl,sr;
	while(1){
	    sl=(l*(l+1)) >> 1;
	    if((sl>=x))
	        break;
	    l++;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s;
	cin >> s;
	set<char> st(all(s));
	if (st.size() & 1)
		cout << "No" << endl;
	else
	{
		if ((st.count('N') && st.count('S')) || (st.count('E') && st.count('W')))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

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

	solve();
}

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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(int (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cont << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i,0,N) cin >> h[i];
    int cnt = 0;

    REP(i,0,N){
        if(h[i] >= K) ++cnt;
    }

    _PR(cnt);

    return 0;
}

/*



*/

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int mod_pow(int x, int y){
    ll tmp = x, ret = 1;
    while(y){
        if(y & 1){
            ret *= tmp;
            ret %= MOD;
        }
        tmp = tmp * tmp % MOD;
        y >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    for(int i = 0; i < n; ++i) cin >> t[i];
    for(int i = 0; i < n; ++i) cin >> a[i];

    vector<int> h(n, -1);
    h[0] = t[0];
    h[n-1] = a[n-1];
    for(int i = 0; i < n-1; ++i){
        if(t[i+1] > t[i]) h[i+1] = t[i+1];
    }
    for(int i = n - 2; i >= 0; --i){
        if(a[i] > a[i+1]){
            if(h[i] == -1) h[i] = a[i];
            else if(h[i] != a[i]){
                cout << "0\n";
                return 0;
            }
        }
    }
    int ma = 0;
    for(int i = 0; i < n; ++i){
        ma = max(ma, h[i]);
        if(ma != t[i]){
            cout << "0\n";
            return 0;
        }
    }

    ll ans = 1;
    int l = -1, r = -1;
    for(int i = 0; i < n; ++i){
        if(h[i] == -1){
            if(l < 0) l = r = i;
            else ++r;
        }
        else{
            if(l < 0) continue;
            ans = ans * mod_pow(min(h[l-1], h[r+1]), r - l + 1) % MOD;
            l = r = -1;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,c,k; cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];

    ll ans=1;

    sort(all(t));

    ll time=t[0],total=1;
    for(int i=1;i<n;i++){
        if(t[i] - time <= k && total < c) ++total;
        else{
            ++ans;
            total=1;
            time=t[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ll n, a[110];
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    pair<ll, ll> p[210];
    for(int i = -100; i <= 100; i++)
    {
        ll sum=0;
        for(int j = 0; j < n; j++)
            sum+=(a[j]-i)*(a[j]-i);
        p[i+100] = make_pair(sum, i);
    }
    sort(p, p+201);
    cout << p[0].first;
}



Measured memory_bytes: 3636
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int n,y,b,r,t,j;
	for(;scanf("%d%d",&n,&y),n;){
		vector<pair<double,int> >v;
		for(;n--;){
			scanf("%d%d%d",&b,&r,&t);
			if(t==1)v.push_back(make_pair(1+y*r/100.0,b));
			else{
				double d=1;
				for(j=0;j<y;j++)d*=1+r/100.0;
				v.push_back(make_pair(d,b));
			}
		}
		sort(v.begin(),v.end());
		printf("%d\n",v[v.size()-1].second);
	}
}

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

const ll min_v = -10000000000;

int p[5050];
int c[5050];
ll rui[5050];
int visited[5050];

ll ss(int j, int k)
{
  ll mx = min_v;
  for( int i=0;i<j;i++){
    for(int kk=0; kk<k; kk++){
      int l = i + kk + 1;
      ll v;
      if( l > j ){
        v = rui[l-j] + rui[j] - rui[i];
      } else {
        v = rui[l] - rui[i];
      }
      if( v > mx ) mx = v;
    }
  }
  return mx;
}

int main()
{
  int n,k;    cin >> n >> k;
  
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  
  for(int i=0;i<5050;i++){ rui[i] = visited[i] = 0; }
  
  int st = 0; ll mx = min_v;
  
  while( st < n ){
    while( st < n && visited[st] != 0 ){ st++; }
    if( st >= n ){ break; }
    
    int i = st, j = 0;
    rui[0] = 0;
    while( visited[i] == 0 ){
      visited[i] = 1;
      int n_i = p[i];
      rui[1+j] = rui[j] + c[n_i];
      i = n_i;
      j++;
    }
    
    ll v = min_v;
    if( rui[j] > 0 ){
      int m1 = k % j;
      int m2 = (k - m1)/j;
      ll v1 = min_v;
      if( m1 > 0 ) v1 = ss(j,m1) + m2 * rui[j] ;
      ll v2 = min_v;
      if( m2 > 0 ) v2 = ss(j,j) + rui[j] * ( m2 - 1 );
      v = max(v1,v2);
    } else {
      int m1 = ( k >= j ? j : k );
      v = ss(j,m1);
    }
    if( v > mx ) mx = v;
  }
  
  cout << mx << endl;
  
  return 0;
  
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
typedef tuple<int, int, int> TEdge;
const int N = int(2e5) + 7;
const int mod = int(1e9) + 7;
const ll oo = (ll)1e18;

void sub(int& x, int y) {if((x -= y) < 0) x += mod;}
void add(int& x, int y) {if((x += y) >= mod) x -= mod;}
int mul(int x, int y) {return 1ll * x * y % mod;}

int n, m, s, t, u, v, w;
TEdge e[N];
vector<ll> d[2];
vector<int> cnt[2];
vector<pii> a[N];
priority_queue<pii, vector<pii>, greater<pii>> pq;

void Dijkstra(int s, vector<ll>& d, vector<int>& cnt) {
    d.resize(n + 1, oo), cnt.resize(n + 1, 0);
    d[s] = 0; cnt[s] = 1; pq.push(mp(0, s));
    while(pq.size()) {
        pii top = pq.top(); pq.pop();
        if(top.fi != d[top.se]) continue;
        for(pii p: a[top.se]) {
            if(d[p.se] > top.fi + p.fi) {
                d[p.se] = top.fi + p.fi;
                cnt[p.se] = cnt[top.se];
                pq.push(mp(d[p.se], p.se));
            } else if(d[p.se] == top.fi + p.fi) add(cnt[p.se], cnt[top.se]);
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m >> s >> t;
    for(int i = 0; i < m; ++i) {
        cin >> u >> v >> w;
        a[u].pb(w, v), a[v].pb(w, u);
        e[i] = make_tuple(u, v, w);
    }
    Dijkstra(s, d[0], cnt[0]), Dijkstra(t, d[1], cnt[1]);
    ll dis = d[0][t], du, dv; int res = mul(cnt[0][t], cnt[0][t]);
    for(int i = 1; i <= n; ++i)
        if(d[0][i] * 2 == dis && d[0][i] + d[1][i] == d[0][t]) sub(res, mul(mul(cnt[0][i], cnt[0][i]), mul(cnt[1][i], cnt[1][i])));
    for(int i = 0; i < m; ++i) {
        tie(u, v, w) = e[i];
        du = d[0][u], dv = d[1][v];
        if(du * 2 < dis && dv * 2 < dis && du + dv + w == dis) sub(res, mul(mul(cnt[0][u], cnt[0][u]), mul(cnt[1][v], cnt[1][v])));
        swap(u, v);
        du = d[0][u], dv = d[1][v];
        if(du * 2 < dis && dv * 2 < dis && du + dv + w == dis) sub(res, mul(mul(cnt[0][u], cnt[0][u]), mul(cnt[1][v], cnt[1][v])));
    }
    cout << res;
}


Measured memory_bytes: 24184
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i= 0; i <b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int E(int a) {
	return (5 * a + 17) % 32;
}

int D(int a) {
	return (13 * (a - 17 + 32)) % 32;
}

void Cout(vector<int> A) {
	for (auto x : A) {
		char c = x + 'a';
		cout << c;
	}
	cout << endl;
}

int main() {
	int i, j, k;

	int N, M, K;
	int Q;

	int c[10][10];
	int C[10][10];
	map<int,int> A;
	const int INF = 1000000;
	int H, W;
	queue<int> que;
	int d[10] = { 0 };
	
	cin >> H >> W;
	rep(i, 0, 10) {
		rep(j, 0, 10) {
			cin >> c[i][j];
			C[i][j] = INF;
		}
		d[i] = c[i][1];
		if (i != 1)
			que.push(i);
	}


	while (!que.empty()) {
		int x = que.front();
		que.pop();
		rep(i, 0, 10) {
			if (x == i || i == 1)
				continue;
			if (d[i] > d[x] + c[i][x]) {
				d[i] = d[x] + c[i][x];
				que.push(i);
			}
		}

	}


	rep(i, 0, H) {
		rep(j, 0, W) {
			int a;
			cin >> a;
			if (a == -1)
				continue;
			A[a] ++;


		}
	}
	int ans = 0;
	for (auto x : A) {
		ans += x.second * d[x.first];
	}
	cout << ans;
	return 0;
}

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

def main():
	N,K = map(int,input().split())
	cum = [0]
	for _ in range(N):
		cum.append(cum[-1]+int(input())-K)

	s_cum = sorted(cum)

	def invNumCount(A):
		l = len(A)
		res = 0
		BIT = [0]*(l+1)

		def BIT_query(idx):
			res_sum = 0
			while idx > 0:
				res_sum += BIT[idx]
				idx -= idx&(-idx)
			return res_sum

		def BIT_update(idx,x):
			while idx <= l:
				BIT[idx] += x
				idx += idx&(-idx)
			return

		Ai = [None]*l
		for i,e in enumerate(A):
			Ai[e] = i
		for i,e in enumerate(Ai):
			res += i - BIT_query(e+1)
			BIT_update(e+1,1)
		return res

	d = {}
	pos = [None]*(N+1)
	for i,num in enumerate(cum):
		ind = bisect.bisect_left(s_cum,num)
		if num not in d:
			d[num] = 1
		else:
			ind += d[num]
			d[num] += 1
		pos[i] = N-ind

	print(invNumCount(pos))

if __name__ == "__main__":
	main()

Measured memory_bytes: 83232
import sys

def main():
    input = sys.stdin.readline
    A = list(map(int, input().split()))
    n = A[0] * 100 + A[1] * 10 + A[2]

    if n % 4 == 0:
        return 'YES'
    else:
        return 'NO'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N, D;
	cin >> N >> D;
	cout << (N + 2*D) / (2*D + 1) << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

H, W = mi()
N = ii()
A = li()

table = dp2(0, W, H)
i = -1
j = 0
for ind in range(N):
    a = A[ind]
    while a > 0:
        if i+1 < H and not table[i+1][j]:
            table[i+1][j] = ind+1
            i += 1
        elif j+1 < W and not table[i][j+1]:
            table[i][j+1] = ind+1
            j += 1
        else:
            if i > 0 and not table[i-1][j]:
                table[i-1][j] = ind+1
                i -= 1
            elif j > 0 and not table[i][j-1]:
                table[i][j-1] = ind+1
                j -= 1
        a -= 1

for i in range(H):
    for j in range(W):
        print(table[i][j], '', end='')
    print('')

Measured memory_bytes: 4724
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    dic = defaultdict(int)
    for i_ in range(1, N+1):
        i = str(i_)
        dic[(int(i[0]), int(i[-1]))] += 1

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += dic[(i, j)] * dic[(j, i)]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41068
#include<iostream>
#include<list>
#include<cstring>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

struct line{
    int x0,y0,vx,vy;
    vector<double> vd;
    vector<int> vi;
    void add(int x,int y){
        int i,j;
        i = x;j = y;
        x -= x0;
        y -= y0;
        vd.push_back(sqrt(x*x+y*y));
        if(vd.size() > 1){
            vi.push_back(vx*y-vy*x > 0);
        }
        x0 = i;y0 = j;vx = x;vy = y;
    }
    bool equal(struct line l){
        int i,j;
        bool f = true;
        if(vd.size() != l.vd.size()) return false;
        for(i = 0;i < vd.size();i++){
            if(vd[i] != l.vd[i]) f = false;
        }
        for(i = 0;i < vi.size();i++){
            if(vi[i] != l.vi[i]) f = false;
        }
        if(!f){
            f = true;
            for (i = 0; i < vd.size(); i++) {
                if (vd[vd.size()-i-1] != l.vd[i]) f = false;
            }
            for (i = 0; i < vi.size(); i++) {
                if (vi[vi.size()-i-1] == l.vi[i]) f = false;
            }
        }
        return f;
    }
    void ini(int x,int y){
        x0 = x;y0 = y;
        vd.clear();vi.clear();
    }
};

int main(){
    int i,j,k;
    int n,m,x,y;
    line l0,li;
    while(1){
        cin >> n;
        if(!n) break;
        cin >> m;
        cin >> x >> y;
        l0.ini(x,y);
        for(j = 1;j < m;j++){
            cin >> x >> y;
            l0.add(x, y);
        }
        for (i = 0; i < n; i++) {
            cin >> m;
            cin >> x >> y;
            li.ini(x, y);
            for (j = 1; j < m; j++) {
                cin >> x >> y;
                li.add(x, y);
            }
            if(l0.equal(li)) cout << i+1 << endl;
        }
        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {
  int N,K,C;
  cin >> N >> K >> C;

  

  cout << C <<' '<< N <<' '<< K << endl;
  
  return 0;
}

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

using namespace std;

int main () {
  int x;
  cin >> x;
 
  int five_h;
  int five;
  int tmp;
  five_h = x/500;
  tmp = x - five_h*500;
  //cout << five_h<< endl;
  five = tmp/5;
  
  int ans;
  ans = five_h*1000 + five*5;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <utility>
#include <cassert>
#include <cstdio>

using namespace std;
const int INF = 1e9;

struct mail{
  int time, to, cur, next, id;
};

bool operator < (const mail &a, const mail &b){
  if(a.time != b.time) return a.time > b.time;
  if(a.next != b.next) return a.next > b.next;
  return a.cur > b.cur;
}

int main(){
  int n, m, c = 0;
  while(cin >> n >> m, n){
    if(c) printf("\n");
    else ++c;
    vector< vector<int> > D(n, vector<int>(n, INF)), E(n, vector<int>(n, -1));
    for(int i = 0; i < m; ++i){
      int u, v, d;
      cin >> u >> v >> d;
      --u;--v;
      D[u][v] = d;
      D[v][u] = d;
      E[u][v] = d;
      E[v][u] = d;
    }

    for(int i = 0; i < n; ++i) D[i][i] = 0;
    for(int k = 0; k < n; ++k){
      for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
          D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
        }
      }
    }

    vector< vector<int> > next(n, vector<int>(n, -1));
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        for(int k = 0; k < n; ++k){
          if((D[i][k] + D[k][j] != D[i][j]) || (D[i][k] != E[i][k])) continue;
          next[i][j] = k;
          break;
        }
      }
    }

    int l;
    cin >> l;
    vector<string> name(l);
    priority_queue<mail> pque;
    
    for(int i = 0; i < l; ++i){
      int from, to, time;
      cin >> from >> to >> time >> name[i];
      pque.push((mail){time, to-1, from-1, next[from-1][to-1], i});
    }
    
    vector<int> T(n, -1);
    vector< vector<int> > U(n, vector<int>(n, -1));
    vector< pair<int, string> > A;
    
    while(!pque.empty()){
      mail x = pque.top();
      pque.pop();
      
      if(U[x.cur][x.next] < x.time){
        T[x.cur] = max(T[x.cur], x.time);
        U[x.cur][x.next] = T[x.cur];
        T[x.cur] = max(T[x.cur], U[x.cur][x.next] + 2*D[x.cur][x.next]);
      }
      x.time = U[x.cur][x.next] + D[x.cur][x.next];
      x.cur = x.next;
      x.next = next[x.cur][x.to];

      if(x.cur == x.to){
        A.push_back(make_pair(x.time, name[x.id]));
      }else{
        pque.push(x);
      }
    }
    
    sort(A.begin(), A.end());
    for(int i = 0; i < l; ++i){
      cout << A[i].second << " " << A[i].first << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3188
import sys
from functools import reduce

import numpy


def main():
    lines = [list(map(int, x.strip().split())) for x in sys.stdin.readlines()]
    N, X = lines[0]
    location = sorted(lines[1] + [X])
    if len(location) == 1:
        print(location[0] - X)
    else:
        location = numpy.array(location)
        sub = location[1:] - location[:-1]
        result = reduce(gcd, sub)
        print(result)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


if __name__ == '__main__':
    main()


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n,k; cin >> n >> k;
  vi d(k); rep(i,k) cin >> d[i];

  while(1){
    int x = n;
    //cout << n << endl;
    while(1){
      bool flag = false;
      //cout << x % 10 << endl;
      //1番下の桁を検査
      rep(i,k){
	if(not (d[i] == (x % 10))) continue;
	else{
	  flag = true;//ダメな数字があれば
	  break;
	}
      }
      //cout << flag << endl;
      if(flag) break;//次を調べる
      x /= 10;
      //cout << x << endl;
      if(x == 0){
	cout << n << endl;
	return 0;
      }
    }
    n++;
    //if(n == 1010) break;
  }

}


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

int main() {

    string s,t;

    cin >> s >> t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    string ans = "Yes";

    bool ok = false;

    int size_min = min(s.size(),t.size());

    for(int i=0; i<size_min; i++){
        if(s[i] < t[i]){
            ok = true;
            break;
        }
        if(s[i] > t[i]){
            ans = "No";
            break;
        }
    }

    if(ans == "Yes" && !ok && size_min != s.size() && s[size_min-1] == t[size_min-1]){
        ans = "No";
    }

    if(ans == "Yes" && s == t){
        ans = "No";
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int n, b;
	scanf("%d", &n);
	set<int> a;
	for(int i = 0; i < n; i++) {
		scanf("%d", &b);
		a.insert(b);
	}
	for(auto itr = a.begin(); itr != a.end(); itr++) {
		if(itr == a.begin()) printf("%d", *itr);
		else printf(" %d", *itr);
	}
	printf("\n");
}



Measured memory_bytes: 7876
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

/*
2 5
1 WA
1 WA
2 WA
2 AC
2 WA
=>
1 1
*/

fn main() {
    let (N, M) = read!(usize, usize);

    let mut ac = vec![false; N];
    let mut penalty = vec![0; N];

    for (mut p, s) in read![usize, String; M] {
        p -= 1;

        if ac[p] {
            continue;
        }

        match s.as_str() {
            "AC" => {
                ac[p] = true;
            }
            "WA" => {
                penalty[p] += 1;
            }
            _ => unreachable!("invalid input"),
        }
    }

    let mut s = 0;
    let mut t = 0;
    for i in 0..N {
        if ac[i] {
            s += 1;
            t += penalty[i];
        }
    }

    println!("{} {}", s, t)
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  while ( cin >> n, n ) {

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

    int ans = 0;
    for ( int i = 0; i < n; i++ ) {
      if ( a[i]*n <= sum ) ans++;
    }

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



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int f (int x) {
	int r = 0;
	while (r < 19 and (1 << (r + 1)) <= x) r++;
	return r;
}

int main() {
	int l;
	cin >> l;
	const int r = f(l);
	
	vector<pair<P, int>> edge;
	for (int v = 0; v < r; v++) {
		edge.emplace_back(P(v, v + 1), 0);
		edge.emplace_back(P(v, v + 1),(1 << v));
	}
	
	for (int v = r - 1; v >= 0; v--) {
		int val = l - (1 << v);
		if (val >= (1 << r)) {
			edge.emplace_back(P(v, r), val);
			l = val;
		}
	}
	
	cout << r + 1 << ' ' << edge.size() << '\n';
	for (const auto &e : edge) {
		int v, u; tie(v, u) = e.first;
		cout << v + 1 << ' ' << u + 1 << ' ' << e.second << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 標準入力から取得
        Scanner scan = new Scanner(System.in);
        // 取得した文字を格納する可変長リスト
        ArrayList<String> scList = new ArrayList<>();
        
        for (int i = 0; i >= 0; i++) {
            try {
                // 可変長リストに標準入力の値を格納
                scList.add(scan.nextLine());
            } catch (Exception e) {
                break;
            }
        }
        
        String[] numlist = scList.get(0).split(" ");
        
        int Sheep = Integer.parseInt(numlist[0]);
        int Wolve = Integer.parseInt(numlist[1]);
        
        if (Wolve >= Sheep) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}

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

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  	int n;cin>>n;
  	int sum=0;
  	int a[n];
  	for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
  	int res=0;
  	for(int i=0;i<n;i++){
      sum=sum-a[i];
      res+=(sum*a[i]);
    }
  	cout<<res<<endl;
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, A, B, Pa=0, Pb=0;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  for (int i=0; i<N; i++) {
    if (S[i]=='a') {
      if (Pa<A+B) {
        cout << "Yes" << endl;
        Pa=Pa+1;
      }
      else {
        cout << "No" << endl;
      }
    }
    else if (S[i]=='b') {
      if (Pa<A+B && Pb<B) {
        cout << "Yes" << endl;
        Pa=Pa+1;
        Pb=Pb+1;
      }
      else {
        cout << "No" << endl;
      }
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3752
#include <algorithm>
 #include <iostream>
 #include <vector>
 using namespace std;
 typedef long long ll;
 const int INF = 1 << 30;
 const ll INFll = 1ll << 60;
 
 int main() {
   int n,a,b;
   cin >> n >> a >> b;
   cout << (a*n > b ? b : a*n) << endl;
 	return 0;
 }

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int a,b,c,m;
  cin >> a >> b >> c;
  m = MAX(MAX(a,b),c);
  
  cout << (a+b+c-m) << endl;
  return 0;
}

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

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
int x=c-a,y=d-b;  

cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>


int leap_year(int y) {
	if( y % 400 == 0) {
		return 1;
	} else if (y % 100 == 0 && y % 400 != 0) {
		return 0;
	} else if (y % 4 == 0 && y % 100 != 0) {
		return 1;
	} else {
		return 0;
	}
}
int main()
{
	int a, b;
	int n = 0;
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		} else {
			if (n >0) {
				std::cout << std::endl;
			}
			int sum = 0;
			for (int k = a; k <= b; k++) {
				sum = sum + leap_year(k);
			}
			if (sum == 0) {
				std::cout << "NA" << std::endl;
			} else {
			    for (int i =a; i <= b; i++) {
					if (leap_year(i) == 1) {
						std::cout << i << std::endl;
					}
				}
			}
		}
	n++;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){
    stack<int> a;
    char tmp[11];
    //int n; scanf("%d", &n);
    int x;
    while(true){
        scanf("%s", tmp);
        switch(tmp[0]){
            case '+':
                x = a.top();
                a.pop();
                x+=a.top();
                a.pop();
                a.push(x);
                break;
            case '-':
                x = a.top();
                a.pop();
                a.top() -= x;
                break;
            case '*':
                x = a.top();
                a.pop();
                x*=a.top();
                a.pop();
                a.push(x);
                break;
            default:
                a.push(atoi(tmp));
        }
        int ch = getchar();
        if(ch == 10) break;
    }
    printf("%d\n", a.top());
    return 0;
}



Measured memory_bytes: 2728
#include<iostream>
using namespace std;
#include<stdio.h>
#include<stdlib.h>

void to_post(int* A, int* B, int* C, int h)
{
    int x = A[0];
    C[h - 1] = x;
    if(h < 2) return;
    int m = 0;
    while(B[m] != x) m++; 
    if(m > 0) to_post(A + 1, B, C, m);
    if(h - m - 1 > 0) to_post(A + m + 1, B + m + 1, C + m, h - m - 1);
}

int main()
{
    int *A, *B, *C;
    int i, n; scanf("%d", &n);

    A = new int [n]; B = new int [n]; C = new int [n];
    if(A == NULL || B == NULL || C == NULL) exit(EXIT_FAILURE);

    for(i = 0; i < n; i++){ scanf("%d", &A[i]); C[i] = 0; }
    for(i = 0; i < n; i++){ scanf("%d", &B[i]); }

    to_post(A, B, C, n);

    printf("%d", C[0]); for(i = 1; i < n; i++){ printf(" %d", C[i]); } printf("\n");

    return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,INF=0x3f3f3f3f;
typedef long long ll;
set<string>st;
int main()<%
 int n; scanf("%d",&n); string s;
 while(n--)
     cin>>s,st.insert(s);
 cout<<st.size();
%>

Measured memory_bytes: 19316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <list>
#include <queue>
#include <map>

#define N 205
#define LL long long
using namespace std;

int main(){
    LL a,b,c,d;
    cin >> a >> b;
    LL ans = a;
    c = a;
    a = max(c-b,b);
    b = min(c-b,b);
    
    while(1){
        c = a%b;
        d = a/b;
        if(c==0){
            ans += b*(2*d-1); 
            break;
        }
        ans += 2*b*d;
        a = b;
        b = c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    ll i = n/k;
    ans += i*i*i;
    if(k%2 == 0 && k/2 <= n) {
        ll j = 1+(n-k/2)/k;
        ans += j*j*j;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
d, n = map(int, input().split())
if d == 0:
  if n == 100:
    print(101)
  else:
    print(n)
elif d == 1:
  if n == 100:
    print(10100)
  else:
    print(n*100)
else:
  if n == 100:
    print(1010000)
  else:
    print(n*10000)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
using namespace std;
int n,k,ans;
int main()
{
     cin>>n>>k;
     ans=1;
     for(int i=0;i<n;i++)
    {
        if(ans>k)
        {
            ans+=k;
        }
        else 
        ans*=2;

    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#define MOD 1000000007
int n, m, q = 0;
long long k, a[210], b[210], c[210];
inline int minpopcount(long long l, long long r) {
    register int ret = 0;
    for (int i = 60; i >= 0; i--)
        if (((l >> i) & 1) == ((r >> i) & 1))
            ret += (l >> i) & 1;
        else {
            ret++;
            break;
        }
    return ret;
}
struct ans {
    long long d[210], r;
    inline friend bool operator<(const ans& a, const ans& b) {
        for (int i = 1; i < n; i++) {
            if (a.d[i] < b.d[i]) return 1;
            if (a.d[i] > b.d[i]) return 0;
        }
        return 0;
    }
    inline friend bool operator==(const ans& a, const ans& b) {
        for (int i = 1; i < n; i++)
            if (a.d[i] != b.d[i]) return 0;
        return 1;
    }
    inline friend bool operator!=(const ans& a, const ans& b) {
        return !(a == b);
    }
} dt[210 * 210];
std::pair<long long, long long> Q[210 * 210];
long long ans = 0;
long long calc() {
    std::sort(Q + 1, Q + q + 1);
    long long ret = 0, l = 0, r = -1;
    for (int i = 1; i <= q; i++) {
        if (Q[i].first > r) {
            ret += r - l + 1;
            l = Q[i].first;
        }
        r = Q[i].second;
    }
    return ret + r - l + 1;
}
int main() {
    std::cin >> n >> k;
    for (int i = 1; i <= n; i++) std::cin >> a[i];
    std::sort(a + 1, a + n + 1);
    for (int k = 0; k <= 60; k++) {
        for (int i = 1; i <= n; i++) b[i] = a[i] & ((1LL << k) - 1);
        std::sort(b + 1, b + n + 1);
        int N = std::unique(b + 1, b + n + 1) - b - 1;
        for (int i = 1; i <= N; i++) {
            if (a[1] < b[i]) continue;
            int P = i == 1 ? 0 : minpopcount(b[i - 1], b[i]);
            for (int j = 1; j <= n; j++) c[j] = (a[j] - b[i]) >> k;
            dt[++m].r = k + P;
            c[0] = 0;
            for (int j = 0; j < n; j++) dt[m].d[j] = c[j + 1] - c[j];
        }
    }
    std::sort(dt + 1, dt + m + 1);
    for (int i = 1; i <= m; i++) {
        if (i != 1 && dt[i] != dt[i - 1]) {
            (ans += calc()) %= MOD;
            q = 0;
        }
        if (dt[i].r <= k) {
            Q[++q] = std::make_pair(std::max(dt[i].d[0] - k + dt[i].r, 0LL),
                                    dt[i].d[0]);
        }
    }
    (ans += calc()) %= MOD;
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 17920
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int n,m;
int G[10][10];
int main(){
    cin >> n >> m;
    int a,b;
    rep(i,m){
        cin >> a >> b;
        G[a][b]=1;
        G[b][a]=1;
        
    }
    vector<int>c(n-1);
    rep(i,n-1){
        c[i] = i+2;
    }
    sort(c.begin(),c.end());
    int ans = 0;
    do{
        bool f = true;
        if(G[1][c[0]]==0)continue;
        rep(i,n-2){
            if(G[c[i]][c[i+1]]==0)f=false;;
        }
        if(f)ans++;
        
    }while(next_permutation(c.begin(),c.end()));
    cout << ans << endl;
}

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

int main(){
	int S;
	cin >> S;
	
	int h, m, s;
	
	h = S / 3600;
	m = (S - h*3600) / 60;
	s = S - h*3600 - 60*m;
	
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

Measured memory_bytes: 1164
<?php
list($H,$W,$N) = explode(" ",trim(fgets(STDIN)));

$ans = array(0,0,0,0,0,0,0,0,0,0);
$count = ($H - 2) * ($W - 2);

if($N > 0){
    for($i = 1;$i <= $N;$i++){
        list($a,$b) = explode(" ",trim(fgets(STDIN)));
        for($j = -1;$j <= 1;$j++){
            if($a + $j > 1 && $a + $j < $H){
                for($k = -1;$k <= 1;$k++){
                    if($b + $k > 1 && $b + $k < $W){
                        if(isset($map[$a + $j][$b + $k])){
                            $map[$a + $j][$b + $k] ++;
                        }else{
                            $map[$a + $j][$b + $k] = 1;
                        }
                    }
                }
            }
        }
    }
    
    foreach($map as $val){
        foreach($val as $val2){
            $ans[$val2] ++;
            $count --;
        }
    }
}

echo $count . PHP_EOL;

for($i = 1;$i <= 9;$i++){
    echo $ans[$i] . PHP_EOL;
}
?>

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=0;
    cin>>n;
    string s;
    cin>>s;
    for (int i = 0; i < n; i++)
    {
        if(i==0) ans++;
        else
        {
            if(s[i]!=s[i-1]) ans++;
        }
        
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 512
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

toInts :: IO [Int]
toInts = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

solver :: Int -> [Int] -> Int
solver n ls =
  let m = div n 2
   in let (p, f) = splitAt m $ sort ls
       in (head f) - (last p)

main :: IO ()
main = do
  n <- read <$> getLine
  dat <- toInts
  print $ solver n dat

Measured memory_bytes: 17788
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}







int main(){
    std::string s, t; std::cin >> s >> t;
    int n(s.length());
    std::string ss(s + s);
    std::vector<std::vector<int>> id(26);
    for(int i(0); i < 2*n; ++i){
        id[ss[i] - 'a'].push_back(i);
    }
    
    int period(0), cur(-1), nxt;
    for(int i(0), i_len(t.length()); i < i_len; ++i){
        if(id[t[i] - 'a'].empty()){
            std::cout << -1 << std::endl;
            return 0;
        }
        nxt = *(std::upper_bound(std::begin(id[t[i] - 'a']), std::end(id[t[i] - 'a']), cur));
        if(nxt >= n) ++period;
        cur = nxt % n;
    }
    std::cout << (long long)n * period + cur + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long
#define endl '\n'
#define pb push_back
#define debug(x) cout<<#x<<" "<<x<<endl;
const int mod = 1e9+7;
const double pi = 3.141592653589793238460;
using namespace std;

bool is_pal (string s){
return equal(s.begin(), s.begin() + s.size()/2, s.rbegin()) ? 1 : 0;
}

int power (int x , int y){
if(y==0) return 1;
if(y&1) return x*power(x,y/2)%mod*power(x,y/2)%mod;
return power(x,y/2)%mod*power(x,y/2)%mod;
}

int modInv (int x){
return power(x,mod-2);
}

int fact (int n){
    int mul =1;
    for(int i=0;i<n;i++)
    mul=(mul*(i+1))%mod;
    return mul;
}

bool prime[200005]; 

int minn (int x, int y)
{
	if(x<y)
	return x;
	else
	return y;
}

int maxx (int x, int y)
{
	if(x>y)
	return x;
	else
	return y;
}
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
}

void solve(void){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(true){
		c=c-b;
		if(c<=0){
			cout<<"Yes";
			return;
		}
		a=a-d;
		if(a<=0){
			cout<<"No";
			return;
		}
	}
	
}	
signed main() {
fio;
int t = 1;
// cin>>t;
	while(t--)
	solve();

	return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
    double N, K;
    double ret = 0;
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        int c = 0;
        int now = i;
        while(now < K){
            now *= 2;
            c++;
        }
        ret += pow(0.5, c) / N;
    }
    cout << ret << endl;
}


Measured memory_bytes: 512