akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
ll A,B,C,D;
void input()
{
	A=read<ll>(),B=read<ll>(),C=read<ll>(),D=read<ll>();
}
void work()
{
	if(D<B)puts("No");
	else if(A<B)puts("No");
	else
	{
		ll tmp=__gcd(B,D);
		ll num=(A-C-1)/tmp-(A-B)/tmp;
		if(num>0)puts("No");
		else puts("Yes");
	}
}
int main()
{
	//file();
	int T=read<int>();
	while(T--)
	{
		input();
		work();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  cout << (n+110)/111*111 << endl;
  return 0;
}

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

using namespace std;

const int MAX_N = 2020;

// f[u] is the sum of depth;

int n, head[MAX_N], current, siz[MAX_N], f[MAX_N];
char S[MAX_N];

struct edge
{
    int to, nxt;
} edges[MAX_N << 1];

void addpath(int src, int dst)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    head[src] = current++;
}

void dfs(int u, int fa)
{
    siz[u] = S[u] - '0', f[u] = 0;
    for (int i = head[u]; i != -1; i = edges[i].nxt)
        if (edges[i].to != fa)
            dfs(edges[i].to, u), siz[u] += siz[edges[i].to], f[u] += f[edges[i].to] + siz[edges[i].to];
}

int collect(int u, int fa)
{
    int mpos = 0;
    for (int i = head[u]; i != -1; i = edges[i].nxt)
        if (edges[i].to != fa && (mpos == 0 || f[mpos] < f[edges[i].to]))
            mpos = edges[i].to;
    if (mpos == 0)
        return 0;
    int verdict = collect(mpos, u) + siz[mpos];
    if (f[u] - f[mpos] - siz[mpos] >= verdict)
        // could be finished;
        return (f[u] & 1);
    // extra;
    return verdict - (f[u] - f[mpos] - siz[mpos]);
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d%s", &n, S + 1);
    for (int i = 1, u, v; i <= n - 1; i++)
        scanf("%d%d", &u, &v), addpath(u, v), addpath(v, u);
    int ans = 0x3f3f3f3f;
    for (int rt = 1; rt <= n; rt++)
    {
        dfs(rt, 0);
        if (collect(rt, 0) == 0)
            ans = min(ans, f[rt] >> 1);
    }
    if (ans == 0x3f3f3f3f)
        puts("-1");
    else
        printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3916
#include<stdio.h>
int main(void)
{
	int K, k=0,g=0;
	scanf("%d", &K);
	for (int i = 1; i <= K; i++) {
		if (i % 2 == 0) {
			g++;
		}
		else {
			k++;
		}
	}
	printf("%d", k * g);
	return 0;
}

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

int main() {
  int n; cin >> n;
  const int INF = 100005;
  vector<int> d(INF), arc(INF), abc(INF);
  rep(i,n) {
    int di; cin >> di;
    d[di]++;
  }
  int ans = 0;
  rep(k,INF) {
    if (k==0) continue;
    abc[k] = abc[k-1] + d[k];
    arc[k] = n - abc[k];
    //printf("%d, %d, %d, %d\n", k, d[k], abc[k], arc[k]);
    if (arc[k] == abc[k]) ans++;
    if (arc[k] < abc[k]) break;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    char c;
    cin>>c;

    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
    {
        cout<<"vowel"<<endl;
    }
    else
    {
        cout<<"consonant"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,id[1000],p[1000],q[1000],r[1000],P,Q,R,c[1000],C,i,a;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&id[i],&p[i],&q[i],&r[i]);
      c[i]=(p[i]+r[i])*4+q[i]*9;
    }
    scanf("%d %d %d %d",&P,&Q,&R,&C);
    a=1;
    for(i=0;i<n;i++){
      if(P>=p[i]&&Q>=q[i]&&R>=r[i]&&C>=c[i]){
	printf("%d\n",id[i]);
	a=0;
      }
    }
    if(a)printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 632
a = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())

for i in range(n):
	b, f, r, v = map(int, input().split())
	a[b-1][f-1][r-1] += v

for k in range(4):
	for j in range(3):
		for i in range(10):
			print(" {}".format(a[k][j][i]), end="")
		print("")
	if not k == 3: print("#" * 20)

Measured memory_bytes: 7676
#include <stdio.h>

int main( ) {
  int num[3];
  int buff;

  scanf("%d %d %d", &num[0], &num[1], &num[2]);

  if (num[0] > num[1]) {
    buff = num[1];
    num[1] = num[0];
    num[0] = buff;
  }

  if (num[1] > num[2]) {
    buff = num[2];
    num[2] = num[1];
    num[1] = buff;
  }

  if (num[0] > num[1]) {
    buff = num[1];
    num[1] = num[0];
    num[0] = buff;
  }

  printf("%d %d %d\n", num[0], num[1], num[2]);

  return 0;
}



  

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int a, b, h;
    int area;
    cin >> a >> b >> h;

    area = (a + b) * h * 0.5;

    cout << area << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import fractions
from functools import reduce
input = sys.stdin.readline
n, m = [int(x) for x in input().rstrip().split()]
a = [int(x)//2 for x in input().rstrip().split()]
a = list(set(a))

def lcm_base(x, y): return x * y // fractions.gcd(x, y)
lcm = reduce(lcm_base, a, 1)


for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        break
else:
    print((m // lcm + 1) // 2)


Measured memory_bytes: 89580
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int N;cin>>N;
  vector<int>p(N);
  rep(i,N)cin>>p[i];
  int ans=0;
  REP(i,N-1)if((p[i]<p[i-1]&&p[i]>p[i+1])||(p[i]>p[i-1]&&p[i]<p[i+1]))ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <climits>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 6e5 + 5;
const long long mod = 1e9 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    string s , t;
    cin >> s >> t;
    bool flag = true;
    map < char , char > ans , ans2;
    ans.clear();
    rep(i , 0 , s.length() - 1) {
        if(ans.find(s[i]) != ans.end()) {
            if(ans[s[i]] != t[i]) {
                flag = false;
                //cout << i << endl;
                break;
            }
        }
        else 
            ans[s[i]] = t[i];
        if(ans2.find(t[i]) != ans2.end()) {
            if(ans2[t[i]] != s[i]) {
                flag = false;
                break;
            }
        }
        else 
            ans2[t[i]] = s[i];
    }
    if(flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define W 8
#define H 8
#define BLANK 0
#define BOMB 1
#define BLAST 2

vector< vector<int> > map(8, vector<int>(8));

void explode(int x, int y)
{
	if (map[x][y] == BLAST) {
		return;
	} else if (map[x][y] == BLANK) {
		map[x][y] = BLAST;
		return;
	} else if (map[x][y] == BOMB) {
		map[x][y] = BLAST;
		if (x-1 >= 0) explode(x-1, y);
		if (x-2 >= 0) explode(x-2, y);
		if (x-3 >= 0) explode(x-3, y);
		if (x+1 < W) explode(x+1, y);
		if (x+2 < W) explode(x+2, y);
		if (x+3 < W) explode(x+3, y);
		if (y-1 >= 0) explode(x, y-1);
		if (y-2 >= 0) explode(x, y-2);
		if (y-3 >= 0) explode(x, y-3);
		if (y+1 < H) explode(x, y+1);
		if (y+2 < H) explode(x, y+2);
		if (y+3 < H) explode(x, y+3);
		return;
	}
}

int main()
{
	int n, count = 0;
	int x, y;
	int i, j;

	cin>>n;
	while (count++ < n) {
		cin.ignore(0xFF, '\n');
		cin.ignore(0xFF, '\n');
		for (j = 0; j < H; j++) {
			for (i = 0; i < W; i++) {
				map[i][j] = cin.get()-'0';
			}
			cin.ignore(0xFF, '\n');
		}
		cin>>x>>y;
		explode(x-1, y-1);
		cout<<"Data "<<count<<":"<<endl;
		for (j = 0; j < H; j++) {
			for (i = 0; i < W; i++)
				if (map[i][j] == BOMB) cout<<BOMB;
				else cout<<BLANK;
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define LL long long
LL ans;
int main(){
	int n,i,m,a,b;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		m=n/i;
		a=i,b=a+(m-1)*i;
		ans+=(LL)(a+b)*m/2;
	}
	printf("%lld\n",ans);
	return 0;
}

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

n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

sum_a = 0
rest_a = a_list[0]
for i in range(n):
  if b_list[i] <= rest_a:
    sum_a += b_list[i]
    rest_a = a_list[i+1]
  elif b_list[i] >= rest_a + a_list[i+1]:
    sum_a += rest_a + a_list[i+1]
    rest_a = 0
  else:
    sum_a += b_list[i]
    rest_a = a_list[i+1] - b_list[i] + rest_a

print(sum_a)

Measured memory_bytes: 19376
N, A, B, C, *L = map(int, open(0).read().split())
ans = float('inf')
for i in range(4**N):
  a = 0
  b = 0
  c = 0
  m = 0
  for j in range(N):
    if i%4==0:
      if a!=0:
        m += 10
      a += L[j]
    elif i%4==1:
      if b!=0:
        m += 10
      b += L[j]
    elif i%4==2:
      if c!=0:
        m += 10
      c += L[j]
    i //= 4
  if a==0 or b==0 or c==0:
    continue
  ans = min(ans, m+abs(A-a)+abs(B-b)+abs(C-c))
print(ans)

Measured memory_bytes: 3064
H, N = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]

INF = int(1e18)
dp = [INF] * (H + 1)
dp[H] = 0;
for i in range(N):
    for j in range(H, -1, -1):
        dp[max(0, j - A[i][0])] = min(dp[max(0, j - A[i][0])], dp[j] + A[i][1])

ans = dp[0]
print(ans)


Measured memory_bytes: 43372
#include <iostream>
#define N 100000+1
using namespace std;

void swap_int(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int partition_t(int A[], int p, int r) {
    int i = p-1, j;
    int x = A[r];
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap_int(A+i, A+j);
        }
    }
    swap_int(A+i+1, A+r);
    return i+1;
}

int main()
{
    int n, i, index;
    int A[N];

    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];

    index = partition_t(A, 0, n-1);

    for (i = 0; i < n; i++) {
        if (i)
            cout << ' ';
        if (i == index)
            cout << '[' << A[i] << ']';
        else
            cout << A[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3392
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	int n;
	long long ans;
	char s[4000];
	scanf("%d\n%s", &n, s);
	vector<int> r, g, b;
	for(int i = 0; i < n; ++i)
	{
		switch(s[i])
		{
			case 'R':
				r.push_back(i);
				break;
			case 'G':
				g.push_back(i);
				break;
			case 'B':
				b.push_back(i);
				break;
		}
	}
	ans = r.size() * g.size() * b.size();
	for(int i = 0; i < n; ++i)
	{
		for(int j = i + 1; j < n; ++j)
		{
			if(2 * j - i < n)
			{
				ans -= (s[i] != s[j]) && (s[j] != s[2 * j - i]) && (s[2 * j - i] != s[i]);
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3772
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // https://atcoder.jp/contests/abc147/submissions/8921445
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        N : usize,
        str1 : String,
        str2 : String,
    );
    let N : usize = N;
    let mut str1 = str1.chars();
    let mut str2 = str2.chars();

    for i in 0..N{
        print!("{}{}",str1.next().unwrap(),str2.next().unwrap());
    }
    println!();
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
using namespace std;
ll t;
ll arr[200005];
map<string,string>np;
vector<ll>v,v1;
int main()
{
    ll a,b,c,d,e,f=0,g,i,j,cnt;
    string s1,s2,s3;
    map<ll,ll>mp;
    cin>>a;
    for(i=0;i<a;i++)
    {
        cin>>b;
        mp[b]++;
        if(mp[b]>1)f=1;
    }
    if(f==1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;

}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007

int main(){
    int n, d;
    cin >> n >> d;
    vector<int> x[n];
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            int a; cin>>a;
            x[i].emplace_back(a);
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int total = 0;
            for(int k=0; k<d; k++){
                int d = abs(x[i][k] - x[j][k]);
                total += d * d;
            }
            int s = sqrt(total) + 0.5;
            if(s*s == total) ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 123;

char s[3][maxn];
int n;

int main() {
    scanf("%d", &n);
    REP(i, 3) scanf("%s", s[i]);
    int ans = 0;
    REP(i, n) {
        set<char> now;
        REP(j, 3) now.insert(s[j][i]);
        ans += now.size() - 1;
    }
    printf("%d", ans);
}

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

AB = []
for i in range(N):
  A, B = map(int,input().split())
  AB.append([A,B])
AB = sorted(AB,key = lambda x:x[0])
cost = 0

for a,b in AB:
  cost += (min(max(M,0),b))*a
  M-=b
  if M<=0:
    break
print(cost)
  

Measured memory_bytes: 26240
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] temp = in.nextLine().trim().split("\\s");
        int n = Integer.parseInt(temp[0]);
        int k = Integer.parseInt(temp[1]);
        
        int[] h = new int[n];
        int count = 0;
        for(String a : in.nextLine().trim().split("\\s")){
            h[count++] = Integer.parseInt(a);
        }
        // System.out.println(Arrays.toString(h));
        int[] dp = new int[n];
        for(int i = 1; i < n; i++){
            dp[i] = Integer.MAX_VALUE;
            for(int j = 1; j <= k; j++){
                if(i-j >= 0){
                    dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i]-h[i-j]));
                }
            }
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 46348
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int Q,p,ans_seisu;
	double seisu[24],syosu[8],ans_syosu;

	for(int i = 0; i <= 23; i++){
		seisu[i] = pow(2,i);
	}

	for(int i = 1; i <= 7; i++){
		syosu[i] = 1.0/pow(2,i);
	}

	char buf[9],work[33];

	scanf("%d",&Q);

	for(int loop = 0; loop < Q; loop++){
		scanf("%s",buf);

		p = 0;

		for(int i = 0;buf[i] != '\0';i++){
			switch(buf[i]){
			case '0':
				work[p++] = '0',work[p++] = '0',work[p++] = '0',work[p++] = '0';
				break;
			case '1':
				work[p++] = '0',work[p++] = '0',work[p++] = '0',work[p++] = '1';
				break;
			case '2':
				work[p++] = '0',work[p++] = '0',work[p++] = '1',work[p++] = '0';
				break;
			case '3':
				work[p++] = '0',work[p++] = '0',work[p++] = '1',work[p++] = '1';
				break;
			case '4':
				work[p++] = '0',work[p++] = '1',work[p++] = '0',work[p++] = '0';
				break;
			case '5':
				work[p++] = '0',work[p++] = '1',work[p++] = '0',work[p++] = '1';
				break;
			case '6':
				work[p++] = '0',work[p++] = '1',work[p++] = '1',work[p++] = '0';
				break;
			case '7':
				work[p++] = '0',work[p++] = '1',work[p++] = '1',work[p++] = '1';
				break;
			case '8':
				work[p++] = '1',work[p++] = '0',work[p++] = '0',work[p++] = '0';
				break;
			case '9':
				work[p++] = '1',work[p++] = '0',work[p++] = '0',work[p++] = '1';
				break;
			case 'a':
				work[p++] = '1',work[p++] = '0',work[p++] = '1',work[p++] = '0';
				break;
			case 'b':
				work[p++] = '1',work[p++] = '0',work[p++] = '1',work[p++] = '1';
				break;
			case 'c':
				work[p++] = '1',work[p++] = '1',work[p++] = '0',work[p++] = '0';
				break;
			case 'd':
				work[p++] = '1',work[p++] = '1',work[p++] = '0',work[p++] = '1';
				break;
			case 'e':
				work[p++] = '1',work[p++] = '1',work[p++] = '1',work[p++] = '0';
				break;
			case 'f':
				work[p++] = '1',work[p++] = '1',work[p++] = '1',work[p++] = '1';
				break;
			}
		}

		work[p] = '\0';

		ans_seisu = 0;
		for(int i = 1; i <= 24; i++){
			if(work[i] == '1'){
				ans_seisu += seisu[24-i];
			}
		}

		ans_syosu = 0;
		for(int i = 25; i <= 31; i++){
			if(work[i] == '1'){
				ans_syosu += syosu[i-24];
			}
		}

		if(work[0] == '1')printf("-");

		printf("%d",ans_seisu);

		if(ans_syosu == 0){
			printf(".0\n");
		}else{
			printf(".");

			for(int i = 1; i <= 7; i++){
				ans_syosu *= 10;
				printf("%.0f",floor(ans_syosu));

				ans_syosu -= floor(ans_syosu);
				if(ans_syosu == 0)break;
			}
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int x, a, b;
	cin >> x >> a >> b;

	if(b <= a){
		cout << "delicious" << endl;
	}else if(b <= a + x){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n, n){
    int sum = 0;
    for(int i=2; i<n; i++){
      if((i%2) && !(n%i)){sum++;}
      if(!(i%2) && n%i == i/2){sum++;}
    }
    cout <<(sum+1)/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
A = sum([list(map(int, input().split())) for _ in range(3)], [])
N = int(input())

for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3064
from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
c = Counter(a)
ans = 0
for i in range(n):
    if c[a[i]] > 0:
        m = (1 << a[i].bit_length()) - a[i]
        c[a[i]] -= 1
        if c[m] > 0:
            c[m] -= 1
            ans += 1
print(ans)

Measured memory_bytes: 37132
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	while(m--)
	{
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	for(auto &neighbors : graph) cout << neighbors.size() << '\n';
}

Measured memory_bytes: 3544
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read


n,s,*a = [int(i) for i in read().split()]
MOD = 998244353
 

def mul(c,m,dp): #multiply (1-x^c) up to x^m
    for i in range(m,c-1,-1):
        dp[i] += dp[i-c]
        dp[i] %= MOD
 
dp = [0]*(s+1)

ans = 0
for c in a:
    dp[0] += 1
    mul(c,s,dp)
    ans += dp[s]
    #print(dp)    

print(ans%MOD)    


    

Measured memory_bytes: 40560
def sieveOfEratosthenes():
    L = 1000001
    isPrime = [ True for _ in range(L) ]
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, L):
        if isPrime[i]:
            for j in range(i * i, L, i):
                isPrime[j] = False
    return isPrime

if __name__ == '__main__':
    isPrime = sieveOfEratosthenes()
    while True:
        a, d, n = [ int(x) for x in list(filter(lambda x: x != '', \
            input().strip().split(' '))) ]
        if a == 0 and d == 0 and n == 0:
            break

        count = 0
        while True:
            if isPrime[a]:
                count += 1
            if count == n:
                break
            a += d
        
        print(a)


Measured memory_bytes: 13508
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    ll mina = 3 * pow(10, 5);
    ll count = 0;
    for (ll i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        if (mina == 0)
        {
            mina = a;
        }
        if (a <= mina)
        {
            count++;
        }
        mina = min(a, mina);
    }
    cout << count << endl;
}

int main()
{
    solve();
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<Tiii> VTiii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    long long n;
    scanf("%lld",&n);
    long long m;
    scanf("%lld",&m);
    std::vector<long long> L(m);
    std::vector<long long> R(m);
    std::vector<long long> C(m);
    for(int i = 0 ; i < m ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
        scanf("%lld",&C[i]);
    }

    VTiii a(m);
    REP(i,0,m){
        a[i]=mt(L[i]-1,R[i],C[i]);
    }

    sort(ALL(a));
    Vi dp(n,INF);
    dp[0]=0;
    REP(i,0,m){
        int l=get<0>(a[i]);
        int r=get<1>(a[i]);
        int c=get<2>(a[i]);
        for(int j=r-1;j>=l;j--){
            if(dp[j]>dp[l]+c){
                dp[j]=dp[l]+c;
//                cout<<"changed "<<j<<" "<<dp[j]<<endl;
            }else{break;}
        }
    }
    if(dp[n-1]!=INF) cout<<dp[n-1]<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	string s;
	cin >> s;
	int count = 0;
	for(char c: s)
		if(c == 'R')
			count++;
	if(count == 3)
		cout << count;
	else if (count == 2)
	{
		if(s[1] == 'R')
			cout << count;
		else cout << '1';
	}
	else cout << count;
}

Measured memory_bytes: 3600
//Knight

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int mod = 1000000007;

//n=元の数,p=乗数,m=mod
ll repsqr(ll n,ll p,ll m){
    if(p==0)return 1;
    if(p%2==0){
        ll t=repsqr(n,p/2,m);
        return t*t%m;
    }
    return n*repsqr(n,p-1,m)%m;
}

signed main (){
    int x,y;cin>>x>>y;
    if((x+y)%3!=0||min(x,y)*2<max(x,y)){
        cout<<0<<nnn;
        return 0;
    }

    //2a +  b = x
    //a  + 2b = y
    //
    //2a +  b = x
    //2a + 4b = 2y
    //3b = 2y - x
    //
    //4a + 2b = 2x
    //a  + 2b = y
    //3a = 2x - y
    int a=(2*x-y)/3;
    int b=(2*y-x)/3;
    int ans=1,wa=1;
    rep(i,0,min(a,b))ans=ans*(a+b-i)%mod;
    rep(i,0,min(a,b))wa=wa*(i+1)%mod;
    ans=ans*repsqr(wa,mod-2,mod)%mod;
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3624
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

n, l = inp
t = inp
ans = 0
t.each do |d|
  if d >= l
    ans += 1
  end
end
p ans

Measured memory_bytes: 8332
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a, i##_END_ = b; i < i##_END_; ++i)
#define per(i, a, b) for(int i = (b)-1, i##_BEGIN_ = a; i >= i##_BEGIN_; --i)
#define foreach(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#ifdef Leefir
	#define ast(x) assert(x)
	#define dig(...) fprintf(stderr, __VA_ARGS__)
#else
	#define ast(x) ;
	#define dig(...) ;
#endif
#define showtime dig("%.6lf\n", clock()/(double)CLOCKS_PER_SEC);
typedef long long ll;
typedef double db;
const int inf = (int)1e9;
const ll linf = (ll)1e18;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define pb(x) push_back(x)
#define sz(x) (int)(x).size()

template<class TAT>
inline void read(TAT &res){
	char c; res = 0;
	bool neg = false;
	while(c = getchar(), c != '-' && (c < '0' || c > '9'));
	if(c == '-') neg = true, c = getchar();
	do res = (res*10) + (c^48);
	while(c = getchar(), c >= '0' && c <= '9');
	if(neg) res = -res;
}
template<class TAT>
inline void print(TAT x){
	if(x == 0){ putchar('0'); return;}
	if(x < 0){ putchar('-'); x = -x;}
	static char stk[30];
	int top = 0;
	while(x) stk[++top] = x%10^48, x /= 10;
	while(top) putchar(stk[top--]);
}
namespace Program{

const int mod = (int)1e9+7;
const int N = (int)1e5;
int n, m, fac[N+5];
void Main(){
	dig("______________________________C\n"); 
	scanf("%d %d", &n, &m);
	fac[0] = 1; rep(i, 1, N+1) fac[i] = fac[i-1]*(ll)i%mod;
	
	int ans = fac[n]*(ll)fac[m]%mod;
	if(n < m) swap(n, m);
	if(n==m) ans = ans*2%mod;
	else if(n!=m+1) ans = 0;
	printf("%d\n", ans);
}

} //namespace Program
/*

*/
int main(){
#ifdef Leefir
	dig("**********************define Leefir**********************\n");
	freopen("data.in", "r", stdin);
//	freopen("data.out", "w", stdout);
#endif
	srand(time(NULL));
	
	Program::Main();
	
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] a = new int[N];
        for(int i=0;i<N;i++){
            a[i] = int.Parse(str[i]);
        }
        int count = 0;
        int c = 0;
        bool[] b = new bool[8];
        for(int i=0;i<N;i++){
            int x = a[i]/400;
            if(x >= 8){
                c++;
            }
            else if(!b[x]){
                b[x] = true;
                count++;
            }
        }
        int max = c+count;
        int min = Math.Max(1,count);
        sb.Append(min+" "+max+"\n");
    }
}

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

bool q(long n){
    cout<<"? "<<n<<endl;
    char a;
    cin>>a;
    return a=='Y';
}

int main(){
    int d=1e9;
    if(q(d)){
        while(d>1 && q(d-1)) d/=10;
        cout<<"! "<<d<<endl;
    }else{
        while(d/=10,!q(d));
        long l=d,r=d*10,m;
        while(l+1<r){
            m=(l+r)/2;
            if(q(m*10)) r=m;
            else l=m; 
        }
        cout<<"! "<<r<<endl;
    }
}


Measured memory_bytes: 596
x, n = map(int, input().split(" "))

if n == 0:
    print(x)
else:
    p = list(map(int, input().split(" ")))

    p_under = list(filter(lambda v: v<=x, p))
    p_upper = list(filter(lambda v: v>=x, p))
    p_under.sort(reverse=True)
    p_upper.sort()

    cnt = 0
    while(True):
        if x - cnt not in p_under:
            print(x - cnt)
            break
        if x + cnt not in p_upper:
            print(x + cnt)
            break
        cnt += 1


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

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
const int maxn = 2e5+100;

const ll inf = 1e18;

int main()
{
    ll n , m;
    cin >> n >> m;
    set < ll > divisor;
    for(ll i = 1; i*i <= m; i++){
        if(m % i == 0){
            divisor.insert(i);
            divisor.insert(m/i);
        }
    }
    ll mx = 1;
    for(auto v : divisor){
        if((m/v) >= n)mx = max(mx , v);
    }
    cout << mx << endl;
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll H, W, K;
string field[1005];
vector<i_i> Apples;
int sh, sw, gh, gw;
ll dist[22][22];
ll DIST[1005][1005];
ll sdist[22], gdist[22];
ll dp[1 << 20][20];
int dh[4] = {1, -1, 0, 0};
int dw[4] = {0, 0, 1, -1};
void search(int index) {
    for(int h = 0; h < H; h++) {
        for(int w = 0; w < W; w++) {
            DIST[h][w] = 1e9;
        }
    }
    i_i start = Apples[index];
    DIST[start.first][start.second] = 0;
    queue<i_i> que;
    que.push(start);
    while(!que.empty()) {
        i_i now = que.front();
        int nowh = now.first;
        int noww = now.second;
        que.pop();
        for(int i = 0; i < 4; i++) {
            int newh = nowh + dh[i];
            int neww = noww + dw[i];
            if(newh < 0 or newh >= H) continue;
            if(neww < 0 or neww >= W) continue;
            if(field[newh][neww] == '#') continue;
            if(chmin(DIST[newh][neww], DIST[nowh][noww] + 1)) {
                que.push({newh, neww});
            }
        }
    }
    for(int i = 0; i < Apples.size(); i++) {
        ll d = DIST[Apples[i].first][Apples[i].second];
        dist[index][i] = d;
        //cerr << d << " ";
    }
    sdist[index] = DIST[sh][sw];
    gdist[index] = DIST[gh][gw];
    //cerr << endl;
}

ll counter(ll x) {
    if(x == 0) return 0;
    return (x & 1) + (counter(x/ 2));
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> K;
    for(int h = 0; h < H; h++) {
        cin >> field[h];
        for(int w = 0; w < W; w++) {
            if(field[h][w] == 's') {
                sh = h;
                sw = w;
            }
            if(field[h][w] == 'e') {
                gh = h;
                gw = w;
            }
            if(field[h][w] == 'a') {
                Apples.emplace_back(h, w);
            }
        }
    }
    ll ans = 1e18;
    for(int i = 0; i <= 20; i++) {
        for(int j = 0; j < (1 << 20); j++) {
            dp[j][i] = 1e18;
        }
    }
    for(int i = 0; i < Apples.size(); i++) {
        search(i);
        dp[1 << i][i] = sdist[i];
    }
    for(int bits = 1; bits < (1 << Apples.size()); bits++) {
        for(int i = 0; i < Apples.size(); i++) {
            if(!(bits & (1 << i))) continue;
            //cerr << bits << " " << i << " " << dp[bits][i] << endl;
            if(counter(bits) >= K) {
                chmin(ans, dp[bits][i] + gdist[i]);
            }
            for(int j = 0; j < Apples.size(); j++) {
                if(bits & (1 << j)) continue;
                chmin(dp[bits | (1 << j)][j], dp[bits][i] + dist[i][j]);
            }
        }
    }
    if(ans >= 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 175868
#include<iostream>
using namespace std;
int main(){
    string s,t;
    int i,j,f;
    char c,p;
    cin>>s>>t;
    for(i=0;i<='z'-'a';i++){
        c=(char)('a'+i);
        for(j=f=0;j<s.size();j++){
            if(s[j]==c){
                if(f){
                    if(t[j]!=p){cout<<"No"<<endl;return 0;}
                }
                else p=t[j],f++;
            }
        }
        for(j=f=0;j<t.size();j++){
            if(t[j]==c){
                if(f){
                    if(s[j]!=p){cout<<"No"<<endl;return 0;}
                }
                else p=s[j],f++;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 776
N = int(input())
M = list(map(int,input().split()))
X = sorted(M)
c = 0
for i, v in enumerate(X):
    if i >= N-1:
        break
    else:
        a = X[i]+X[i+1]
        b = a/2
        X[i+1]= a/2

print(b)

Measured memory_bytes: 2940
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

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

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

#pragma endregion

int main(){
  	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int a[200];
	for(int i = 0; i < 200; ++i) a[i] = 0;
	while(cin >> s){
		for(int i = 0; i < s.length(); ++i){
			if((int)s[i] < (int)'a') a[s[i] + 'a' - 'A']++;
			else a[s[i]]++;
		}
	}
	for(int i = 'a'; i < 'z' + 1; ++i){
		cout << char(i) << " : " << a[i] << endl;
	}
}


Measured memory_bytes: 3180
#include<iostream>
using namespace std;
int main(){
	string a,b;
	bool pd=0;
	cin>>a>>b;
	int cd=a.length();
	for(int i=cd-1;i>=0;i--){
		//cout<<i<<" "<<cd-1-i<<endl;
		if(a[i]==b[cd-1-i]) continue;
		else{
			pd=1; cout<<"NO"<<endl;
			break;
		}
	}
	if(pd==0)
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = Integer.valueOf(sc.nextLine());
        String input = sc.nextLine();
        String[] inputs = input.split(" ");
        int max = -1;
        int sum = 0;
        for(String inputEntry: inputs) {
            int number = Integer.valueOf(inputEntry);
            sum =sum + number;
            if(number>max) {
                max = number;
            }
        }
        if((sum-max)>max) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
    int S[3] = {0, 0, 0};
    for(int i=0;i<3;i++){
        char temp;
        cin >> temp;
        S[temp-'a']++;
    }

    if(S[0]*S[1]*S[2]==0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
   
struct edge_t
{
  int from;
  int to;
  int cost;
};
 
typedef struct edge_t Edge;
   
int main(void)
{
  int num, i, k, from, to, cost, update;
  int nedge = 0;
  int dis[10000];
  Edge *edges, *p;
   
  edges = malloc(sizeof(Edge) * 500000);
   
  scanf("%d", &num);
   
  for (i = 0; i < num; i++)
    {
      scanf("%d %d", &from, &k);
   
      while(k--)
	{
	  scanf("%d %d", &to, &cost);
   
	  p = &edges[nedge++];
	  p -> from = from;
	  p -> to = to;
	  p -> cost = cost;
        }
      dis[i] = INT_MAX;
    }
  dis[0] = 0;
   
  update = 1;
  while(update)
    {
      update = 0;
      for(i = 0; i < nedge; i++)
	{
	  from = edges[i].from;
	  to = edges[i].to;
	  cost = edges[i].cost;
	    
	  if(dis[from] < INT_MAX && dis[to] > cost + dis[from])
	    {
	      dis[to] = cost + dis[from];
	      update = 1;
            }
        }
    }
  for(i = 0; i < num; i++)
    {
      printf("%d %d\n", i, dis[i]);
    }
  return 0;
}

Measured memory_bytes: 6460
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int k = Integer.parseInt(line[0]);
        int n = Integer.parseInt(line[1]);
        line = br.readLine().split(" ");
        int a[] = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(line[i]);
        }
        int ma = a[0]+k-a[n-1];
        for(int i = 1; i < n; i++){
            ma = Math.max(ma, a[i]-a[i-1]);
        }
        System.out.println(k-ma);
    }
}


Measured memory_bytes: 61312
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
a = [list(input()) for _ in range(H)]

# a = [s for s in a if s != ["."]*W]

# b = [[0]*len(a) for _ in range(len(a[0]))]
# for i in range(len(a)):
# 	for j in range(len(a[0])):
# 		b[j][i] = a[i][j]

# b = [s for s in b if s != ["."]*len(b[0])]

# c = [[0]*len(b) for _ in range(len(b[0]))]

# for i in range(len(b)):
# 	for j in range(len(b[0])):
# 		c[j][i] = b[i][j]

# for s in c:
# 	print("".join(s))

gyou = set()
retu = set()

for i in range(H):
	for j in range(W):
		if a[i][j] == "#":
			retu.add(j)
			gyou.add(i)


for g in gyou:
	for r in retu:
		print(a[g][r], end="")
	print()


Measured memory_bytes: 5220