akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s = read_vec::<i64>();
    let ans  = if s[0] % s[1] == 0{
        0
    } else {
        1
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
int main()
{
	int a;
	cin>>a;
	int h=a/3600,m=a/60%60,s=a%60;
	cout<<h<<':'<<m<<':'<<s<<endl;
	return 0;
}


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

int main(){
	int N;
	cin>>N;
	while(N > 0){
		int m = 0;
		for(int i=0;;i++){
			if((i*i+i)/2 >= N){
				cout<<i<<endl;
				N -= i;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        double[] l = new double[n];
        for(int i = 0; i < n; i++){
            l[i] = (sc.nextDouble() + 1) / 2;
        }

        double max = 0;
        for(int i = 0; i < k; i++){
            max += l[i];
        }
        double sum = max;
        for(int i = 0; i < n - k; i++){
            sum = sum - l[i] + l[k + i];
            max = Math.max(max, sum);
        }

        System.out.println(max);
        sc.close();
    }
}

Measured memory_bytes: 160416
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;

int main() 
{ 

string s, t; cin>>s>>t;

int x=s.size(), y=t.size();
int cnt=x,tt=0;
for(int i=0; i<=(x-y); i++)
{
	tt=0;
	for(int j=0; j<y; j++)
	{
		if(s[i+j]!=t[j]) tt++;
	}
	
	cnt= min(cnt, tt);
}
cout<<cnt<<endl;
    return 0;
} 


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v.rbegin(),v.rend());
  long long ret = 1;
  for(int i=0; i<n; i++){
    int j = v[i] - i/4;
if(j<=0)break;
    ret += j;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cstring>
char str[100000];
int main() {
	scanf("%s", str);
	int len=strlen(str);
	for(int i=0; i<len; i++) {
		if(str[i]==',') printf(" ");
		else printf("%c", str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define N_ 101000
using namespace std;
struct point {
	int x, num;
	bool operator<(const point &p)const {
		return x<p.x;
	}
}X[N_], Y[N_];
struct Edge {
	int a, b, c;
	bool operator <(const Edge &p)const {
		return c < p.c;
	}
}E[2 * N_];
int UF[N_];
int n;
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
int main() {
	int i;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &X[i].x, &Y[i].x);
		X[i].num = Y[i].num = i;
		UF[i] = i;
	}
	sort(X + 1, X + n + 1);
	sort(Y + 1, Y + n + 1);
	int cnt = 0;
	for (i = 1; i < n; i++) {
		E[cnt++] = { X[i].num,X[i + 1].num,X[i + 1].x - X[i].x };
		E[cnt++] = { Y[i].num,Y[i + 1].num,Y[i + 1].x - Y[i].x };
	}
	sort(E, E + cnt);
	int res = 0;
	for (i = 0; i < cnt; i++) {
		if (Find(E[i].a) != Find(E[i].b)) {
			res += E[i].c;
			UF[Find(E[i].a)] = Find(E[i].b);
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m[530000][2],li,id[200001],tot;
struct Node{
	int l,r,x,b,e;
};
bool operator < (Node x,Node y){
	return m[x.l+li][x.x]>m[y.l+li][y.x];
}
priority_queue <Node> q;
void build(){
	for (int i=li-1;i;--i){
		m[i][0]=m[i<<1][0]<m[i<<1|1][0]?m[i<<1][0]:m[i<<1|1][0];
		m[i][1]=m[i<<1][1]<m[i<<1|1][1]?m[i<<1][1]:m[i<<1|1][1];
	}
}
int query(int l,int r,int x){
	int ans=inf;
	for (l+=li-1,r+=li+1;l^r^1;l>>=1,r>>=1){
		if (~l&1&&ans>m[l^1][x]) ans=m[l^1][x];
		if (r&1&&ans>m[r^1][x]) ans=m[r^1][x];
	}
	return ans;
}
Node make(int b,int e,int x){
	int t=id[query(b,e,x)];
	return (Node){t,id[query(t,e,x^1)],x,b,e};
}
void read(int& x){
    x=0;
    int y=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') y=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    x=x*y;
}
int main(){
	int i,x;
	Node y;
	read(n);
	memset(m,0x3f,sizeof(m));
	for (li=1;li<n+2;li<<=1);
	for (i=1;i<=n;++i){
		read(m[i+li][i&1]);
		id[m[i+li][i&1]]=i;
	}
	build();
	q.push(make(1,n,1));
	n>>=1;
	for (i=1;i<=n;++i){
		y=q.top();
		q.pop();
		printf("%d %d ",m[li+y.l][y.x],m[li+y.r][y.x^1]);
		if (y.b<y.l) q.push(make(y.b,y.l-1,y.x));
		if (y.r<y.e) q.push(make(y.r+1,y.e,y.x));
		if (y.l+1<y.r) q.push(make(y.l+1,y.r-1,y.x^1));
	}
	return 0;
}

Measured memory_bytes: 7284
N,K=map(int, input().split())
A=tuple(map(int,input().split()))
l=[0]*40
for i in A:
    b=bin(i)
    for i in range(-1,1-len(b),-1):
        if b[i]=="1":
            l[i]+=1
x=[0]*40
xi=0
for i in range(40):
    if l[i]<=N//2 and xi+2**(39-i)<=K:
        x[i]=1
        xi+=2**(39-i)
a=0
for i in range(40):
    if x[i]:
        a+=(N-l[i])*2**(39-i)
    else:
        a+=l[i]*2**(39-i)
print(a)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 1010

ll N;
ll A[MAX_N] = {};
vector< pair<bool, ll> > A2;     // first: いるなら true, second: 対応する A の値
vector<ll> ans_v;

signed main()
{
    cin >> N;
    bool isAllNeg = true;
    ll negAns = 1;
    REP(i, N) {
        cin >> A[i];
        if(A[i] > 0) { isAllNeg = false; }
        else { negAns = (negAns == 1) ? A[i] : max(negAns, A[i]); }
    }

    // 全部負の場合→最小のもの1つをとる
    if(isAllNeg) {
        printf("%lld\n", negAns);
        printf("%lld\n", N-1);
        bool isFind = false;
        REP(i, N-1) {
            if(A[i] == negAns || isFind) {
                printf("%lld\n", N-i);
                isFind = true;
            }
            else { printf("1\n"); }
        }
        return 0;
    }

    // 偶数番目の集合の、正の整数だけ足したもの VS 奇数番目の同じもの
    ll odd_num = 0, even_num = 0;
    REP(i, N) {
        if(i % 2 == 0) {
            if(A[i] > 0) { even_num += A[i]; }
        } else {
            if(A[i] > 0) { odd_num += A[i]; }
        }
    }

    REP(i, N) {
        bool ness = false;
        if(odd_num > even_num) {
            if(i % 2 != 0 && A[i] > 0) { ness = true; }
        } else {
            if(i % 2 == 0 && A[i] > 0) { ness = true; }
        }
        A2.push_back(make_pair(ness, A[i]));
    }
    for(auto& a : A2) {
        //DBG("(%s, %lld)\n", a.first ? "true" : "false", a.second);
    }
    // 両端を削る
    while(1) {
        if(A2[0].first) { break; }
        ans_v.push_back(1);
        A2.erase(A2.begin());
    }
    while(1) {
        if(A2[A2.size()-1].first) { break; }
        ans_v.push_back(A2.size());
        A2.erase(A2.begin() + A2.size() - 1);
    }
    // 必要なものどうしの、ちょうど真ん中にあるものを足していく
    while(A2.size() > 1) {
        ll next;
        for(next = 1; next < A2.size(); ++next) {
            if(A2[next].first) { break; }
        }
        //printf("  next: %lld\n", next);
        ans_v.push_back(next / 2 + 1);
        if(next == 2) {
            A2.erase(A2.begin() + 2);
            A2.erase(A2.begin() + 1);
        } else {
            A2.erase(A2.begin() + (next / 2) + 1);
            A2.erase(A2.begin() + (next / 2) - 1);
        }
    }

    printf("%lld\n", max(odd_num, even_num));
    printf("%zu\n", ans_v.size());
    for(auto& a : ans_v) {
        printf("%lld\n", a);
    }


    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  
  int count = 0;
  
  for(int i = a; a <= i && i <=b;i++){
    int s = i / 10000;
    int t = i % 10;
    int u = i / 1000;
    int uu = u % 10;
    int v = i / 10;
    int vv = v % 10;
    if(s == t && uu == vv){
      count++;
    }
  }
  
  cout << count << endl;
}
  

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

int main() {

  double a, b, c;
  cin >> a >> b >> c;

  double area = a * b * sin(c * M_PI/180) / 2;
  double l = sqrt(a * a + b * b - 2 * a * b * cos(c * M_PI / 180)) + a + b;
  double h = b * sin(c * M_PI / 180);

  printf("%.8f", area);
  printf("\n");

  printf("%.8f", l);
  printf("\n");

  printf("%.8f", h);
  printf("\n");

  return 0;

}


Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll cnt = 0, cur = 100;
ll  X;

void solve(){
    while(cur < X){
        cnt++;
        cur *= 1.01;
    }

    cout << cnt << endl;
}

int main(){
    cin >> X;

    solve();
}


Measured memory_bytes: 3640
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 3000 + 5;
int n, m, dp[MAX_N][MAX_N];
string s, t;

void read_input() {
	cin >> s >> t;
	n = s.size();
	m = t.size();
	s = " " + s;
	t = " " + t;
}

void solve() {
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (s[i] == t[j])
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
		}
}

void print_output() {
	string ans;
	int i = n, j = m;
	while (i && j) {
		if (dp[i][j] == dp[i - 1][j])
			i--;
		else if (dp[i][j] == dp[i][j - 1])
			j--;
		else {
			ans += s[i];
			i--, j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


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


#define NUM 1001

ll N,K;
ll dp[NUM][NUM];

ll recursive(ll num_ball,ll num_box){

	if(dp[num_ball][num_box] != -1)return dp[num_ball][num_box];

	if(num_ball == 0 || num_box == 1)return 1;

	ll ret = 0;

	for(ll next_box = 1; next_box <= num_box; next_box++){
		if(next_box > num_ball)break;
		ret += recursive(num_ball-next_box,next_box);
		ret %= MOD;
	}

	return dp[num_ball][num_box] = ret;
}

int main(){

	scanf("%lld %lld",&N,&K);

	for(ll i = 0; i <= N; i++){
		for(ll p = 0; p <= K; p++){
			dp[i][p] = -1;
		}
	}

	printf("%lld\n",recursive(N,K));

	return 0;
}



Measured memory_bytes: 11016
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
P = read_ints()


def ret_mean(X):
    return (X + 1) / 2




import numpy as np
P_mean = np.array([ret_mean(p) for p in P])
P_accum = np.zeros(N+1)
P_accum[1:] = P_mean.cumsum()

ans = 0
# print(P_accum)
for i in range(N - K + 1):
    j = i + K
    ans = max(ans, P_accum[j] - P_accum[i])
print(ans)


Measured memory_bytes: 27932
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll a[100];
int main() {
  int n;
  cin >> n;
  rep(i,n)  cin >> a[i];
  sort(a,a+n);
  cout << a[n-1] - a[0] << endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
#define pb push_back


int n;
vector<int> dat;

bool input(){
	cin>>n;
	
	rep(i,n){
		int a;
		cin>>a;
		dat.pb(a);
	}
	
	return true;
}

const int N = 111111;


class P{
	public:
	int pos,val;
	P(int pos, int val):pos(pos), val(val){}
	bool operator < (const P& a) const{
		if(val==a.val)return pos>a.pos;;
		return val>a.val;
	}
};

typedef pair<int,int> pii;

vector<pii> edge[N];
int visit[N];
void solve(){
	
	rep(i,n){
		if(dat[i]!=0){
			edge[i].pb(pii(i+dat[i], 0));
		}
	}
	
	rep(i,n){
		rep(j,6){
			if(dat[i]==0){
				if(i+j+1<=n-1){
					edge[i].pb(pii(i+j+1, 1));
				}
			}
		}
	}
	
	priority_queue<P> que;
	que.push(P(0,0));
	
	rep(i,N)visit[i]=0;
	
	while(!que.empty()){
		P u = que.top();
		que.pop();
		
		if(visit[u.pos]==1)continue;
		visit[u.pos] = 1;
		
		//printf("pos = %d  val=%d\n",u.pos, u.val);
		
		if(u.pos==n-1){
			cout<<u.val<<endl;
			break;
		}
		
		rep(i,edge[u.pos].size()){
			que.push(P(edge[u.pos][i].first, u.val+edge[u.pos][i].second));
		}
	}
}

int main(){
	input();
	solve();
}

Measured memory_bytes: 9168
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s;
	cin >> s;
	int res = 700;
	REP(i, 3) if (s[i] == 'o') res += 100;
	cout << res << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	if (n <= 104) {
		cout << 0 << endl;
	}
	else if (105 <= n && n <= 134) {
		cout << 1 << endl;
	}
	else if (135 <= n && n <= 164) {
		cout << 2 << endl;
	}
	else if (165 <= n && n <= 188) {
		cout << 3 << endl;
	}
	else if (189 <= n && n <= 194) {
		cout << 4 << endl;
	}
	else {
		cout << 5 << endl;
	}
	return 0;
}

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

using namespace std;
const int maxn = 1e3 + 5;
const int inf = 0x3f3f3f3f;

char s[maxn], t[maxn];

int main() {
    scanf("%s", s);
    scanf("%s", t);
    int n = strlen(s), m = strlen(t);
    int res = inf, cnt, l, r;

    for (int i = 0; i + m - 1 < n; i++) {
        l = i;
        r = 0;
        cnt = 0;
        while (r < m) {
            if (s[l] != t[r]) cnt++;
            l++;
            r++;
        }
        res = min(res, cnt);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
#include <string>
#include <bitset>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	int res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') ans++;
		else {
			res = max(res, ans);
			ans = 0;
		}
	}
	res = max(res, ans);
	cout << res;
}


Measured memory_bytes: 3624
MOD = 10**9 + 7
n = int(input())
s1 = input()
s2 = input()
if s1[0] == s2[0]:
    end = 1
    count = 1
    ans = 3
else:
    end = 0
    count = 2
    ans = 6
while count < n:
    if end == 1:
        if s1[count] == s2[count]:
            ans *= 2
            ans %= MOD
            count += 1
        else:
            ans *= 2
            ans %= MOD
            count += 2
            end = 0
    else:
        if s1[count] == s2[count]:
            count += 1
            end = 1
        else:
            ans *= 3
            ans %= MOD
            count += 2
print(ans)

Measured memory_bytes: 61844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = x;
  rep1(i,d){ //i日目（1-index）
    rep(j,n){ //j人目
      if((i-1)%a[j] == 0) ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

void binPrint(unsigned long long x, int bits){
  for (int i=bits-1; i>=0; i--){
    cout << (x&(1ull<<i)?1:0);
  }
  cout << endl;
}
int main(void){
  unsigned long long flg=0, mask[10];
  int n,q, qtype, i, s;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int k;
    cin >> k;
    mask[i] = 0ull;
    for (int j=0; j<k; j++){
      int t;
      cin >> t;
      mask[i] |= 1ull << t;
    }
  }
  cin >> q;
  for (int _i=0; _i<q; _i++){
    cin >> qtype >> i;
    switch(qtype){
    case 0: // TST
      cout << (flg&(1ull<<i)?1:0) << endl;
      break;
    case 1: // SET
      flg |= mask[i];
      break;
    case 2: // CLR
      flg &= ~mask[i];
      break;
    case 3: // FLP
      flg ^= mask[i];
      break;
    case 4: // ALL
      cout << ((flg&mask[i])==mask[i]?1:0) << endl;
      break;
    case 5: // ANY
      cout << ((flg&mask[i])?1:0) << endl;
      break;
    case 6: // NON
      cout << ((flg&mask[i])==0?1:0) << endl;
      break;
    case 7: // CNT
      s=0;
      for (unsigned long long tmp=flg&mask[i]; tmp; tmp>>=1){
        s += tmp&1;
      }
      cout << s << endl;
      break;
    case 8: // VAL
      cout << (flg&mask[i]) << endl;
    }
  //binPrint(flg, 64);
  }
  return 0;
}



Measured memory_bytes: 3140
#include<iostream>

using namespace std;
int main()
{
    
    int a,b,c;
    cin>>a>>b>>c;
    int d=(int)b/a;
    if(c<d)
    {
        cout<<c<<endl;
    }
    else if(d<c)
    {
        cout<<d<<endl;
    }
    else if(c==d)
    {
        cout<<c<<endl;
    }
  
    return 0;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $sum=array_sum($a);

  $tot=0;
  $min=PHP_INT_MAX;
  for($i=0;$i<$n-1;$i++){
    $tot+=$a[$i];
    if(abs($sum-$tot*2) < $min){
      $min = abs($sum-$tot*2);
    }
  }

  echo $min;


Measured memory_bytes: 36244
import sys
import math
a = sys.stdin.readlines()

count=1
b=0
for i in a:
	c=i.strip("\n").split(" ")
	if count==1:
		d=int(c[1])
	else:
		e=math.sqrt(int(c[0])**2 + int(c[1])**2)
		if d >= e:
			b = b + 1
	count = count + 1
print(b)

Measured memory_bytes: 23400
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>b>>a;
	for(register int k=a-b+1;k<=a+b-1;++k)
	{
		if(k!=a-b+1)
		cout<<" ";
		cout<<k;
	}
	return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1e6 + 1;

typedef pair<int,int>   ii;

int a[N];

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

    int n;  cin >> n;
    int s = 0;

    bool one = 0;

    for(int i = 0 ; i < n ; ++i)    {
        char c; cin >> c;
        if (c == '1')   a[i] = 0;
        if (c == '2')   a[i] = 1;
        if (c == '3')   a[i] = 2;

        if (a[i] == 1)
            one = 1;

        if(((n - 1) & i) == i)
            s += a[i];
    }
    if (one)    cout << s % 2;
    else        cout << s % 4;
}

Measured memory_bytes: 4224
from collections import defaultdict
import math
def Prime(n):
    num = int(math.sqrt(n))
    ls = []
    for i in range(2,num+1):
        while 1:
            if n%i == 0:
                n = n//i
                ls.append(i)
            else:
                break
    if n!=1:
        ls.append(n)
    return ls

def main():
    n = int(input())
    dc = defaultdict(int)
    for i in range(2,n+1):
        ls = Prime(i)
        for j in ls:
            dc[j] += 1
    ls = list(dc.values())

    lenth = len(ls)
    ans = 0
    #case1 a^74
    for i in range(lenth):
        if ls[i]>=74:
            ans +=1
    
    #case2 a^24 b^2
    for i in range(lenth):
        for j in range(lenth):
            if i==j:
                continue
            if ls[i]>=24 and ls[j]>=2:
                ans +=1
    
    #case3 a^14 b^4
    for i in range(lenth):
        for j in range(lenth):
            if i==j:
                continue
            if ls[i]>=14 and ls[j]>=4:
                ans +=1
    
    #case4 a^4 b^4 c^2
    for i in range(lenth):
        for j in range(lenth):
            if i==j:
                continue
            for k in range(lenth):
                if i==k or j==k:
                    continue
                if ls[i]>=4 and ls[j]>=4 and ls[k]>=2:
                    
                    ans += 0.5
    print(int(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 40688
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let s: String = parse_line().unwrap();
    let t: String = parse_line().unwrap();
    let mut common = 0;

    for i in 0..n {
        if t.starts_with(&s[i..]) {
            common = n - i;
            break;
        }
    }
    println!("{}", n * 2 - common);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, l, q;
    cin >> n >> m >> l;
    vector<vector<ll>> dist(n);
    vector<vector<ll>> supply(n);
    rep(i, n) dist[i].resize(n, INT_MAX);
    rep(i, n) supply[i].resize(n, INT_MAX);
    
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        
        if (c <= l) {
            dist[a][b] = c;
            dist[b][a] = c;
        }
    }
    
    cin >> q;
    
    rep(k, n) {
        rep(i, n) {
            rep(ii, n) {
                dist[i][ii] = min(dist[i][ii], dist[i][k] + dist[k][ii]);
            }
        }
    }
    
    rep(i, n) {
        rep(ii, n) {
            if (i == ii) {
                continue;
            }
            
            if (dist[i][ii] <= l) {
                supply[i][ii] = 1;
            }
        }
    }
    
    rep(k, n) {
        rep(i, n) {
            rep(ii, n) {
                supply[i][ii] = min(supply[i][ii], supply[i][k] + supply[k][ii]);
            }
        }
    }
    
    rep(i, q) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        
        if (supply[s][t] == INT_MAX) {
            cout << -1 << endl;
        }
        else {
            cout << (supply[s][t] - 1) << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2048
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include <climits>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;#include <stdio.h>
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


ll gcd(ll a, ll b);

vector<pair<int, int>>	op;		// 操作
vector<int>				value;	// 各ノードの、自分だけ考慮した値
vector<int>				sum;	// 各ノードの、合計。
vector<vector<int>>		link;	// 各ノードの、接続先
vector<bool>			isEnd;	// 各ノードの、探索済みフラグ

// ツリーを探索して合計を求める。
// now: 現在注目しているノードのindex
// parentValue: 親の合計値
void traverse(int now, int parentValue) {
	// 各ノードは一度だけ探索する。
	// 双方向リンクなのでこれがないと無限ループする。
	if (isEnd[now]) return;
	isEnd[now] = true;

	// 自分の合計 = 親の合計 + 自分だけの値
	sum[now] = parentValue + value[now];

	// 自分の合計を渡して、子を再帰的に処理。
	for (int i = 0; i < link[now].size(); i++)
		traverse(link[now][i], sum[now]);
}

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	// 入力の読み込み
	int N, Q;
	cin >> N >> Q;

	// リンクデータはノードの個数。
	link.resize(N);

	// edgeデータはN-1個
	for (int i = 0; i < N-1; i++) {
		int ai, bi;

		cin >> ai >> bi;

		// ノードの子供をたどれるようにしておく。
		link[ai - 1].push_back(bi - 1);
		link[bi - 1].push_back(ai - 1);
	}


	// opデータはQ個
	op.resize(Q);
	for (int i = 0; i < op.size(); i++) {
		cin >> op[i].first >> op[i].second;

		// 1から始まるindexを0から始まるindexにする。
		op[i].first--;
	}

	// value, sum, isEndはノードの個数。
	value.resize(N);
	for (int i = 0; i < value.size(); i++) value[i] = 0;
	
	sum.resize(N);
	for (int i = 0; i < sum.size(); i++) sum[i] = 0;

	isEnd.resize(N);
	for (int i = 0; i < isEnd.size(); i++) isEnd[i] = false;


	// 各ノードについて、自分だけ考慮した値を求める。
	for (int i = 0; i < op.size(); i++) {
		int opIndex = op[i].first;
		int opValue = op[i].second;

		value[opIndex] += opValue;
	}

	// ツリーを探索して、各ノードの合計を求める。
	// ルートから重複なく探索することで、
	// edgeデータの形式や順序に関係なく処理できる。
	traverse(0, 0);

	// 出力
	for (int i = 0; i < sum.size(); i++)
		cout << sum[i] << ' ';


}



Measured memory_bytes: 22784
fh = int(input())
oh = int(input())
ft = int(input())
om = int(input())
count = 0

for i in range(fh + 1):
    if om < i * 500:
        break
    for j in range(oh + 1):
        if om < i * 500 + j * 100:
            break
        for k in range(ft + 1):
            nm = 0
            nm = i * 500 + j * 100 + k * 50
            if om == nm:
                count +=1

print(count)

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

int main() {
    vector<int> w(10), k(10);
    for(int i=0;i<10;i++){
        cin >> w[i];
    }
    for(int i=0;i<10;i++){
        cin >> k[i];
    }
    sort(w.rbegin(), w.rend());
    sort(k.rbegin(), k.rend());
    cout << w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;
    return 0;
}



Measured memory_bytes: 3096
n = int(input())
a = list(map(int, input().split(" ")))
counter = 1
counter_break = 0

for i in range(n):
    if a[i] != counter:
        counter_break += 1
    else:
        counter += 1
if n == counter_break:
    print(-1)
else:
    print(counter_break)

Measured memory_bytes: 26268
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int hpi = sc.nextInt();
			int hpm = sc.nextInt();

			if ((hpi | hpm) == 0) {
				break;
			}

			int h = sc.nextInt();
			int w = sc.nextInt();

			char mtemp[][] = new char[h][];
			int map[][] = new int[h][w];

			for (int i = 0; i < h; i++) {
				mtemp[i] = sc.next().toCharArray();
			}

			int chm[] = new int[256];
			int T = sc.nextInt();

			for (int i = 0; i < T; i++) {
				chm[sc.next().charAt(0)] = sc.nextInt();
			}

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = chm[mtemp[i][j]];
				}
			}

			int S = sc.nextInt();

			int[] chp = new int[256];

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

			chp['R'] = 0;
			chp['L'] = 1;
			chp['D'] = 2;
			chp['U'] = 3;

			int d[] = new int[S];
			int s[] = new int[S];

			int t = 0;
			for (int i = 0; i < S; i++) {
				d[i] = chp[sc.next().charAt(0)];
				s[i] = sc.nextInt();
				t += s[i];
			}

			int P = sc.nextInt();
			int p[] = new int[P];
			for (int i = 0; i < P; i++) {
				p[i] = sc.nextInt();
			}

			int trap[] = new int[t + 1];

			int index = 0;
			trap[0] = 0;
			int ii = 0;
			int jj = 0;
			for (int i = 0; i < t;) {
				for (int j = 0; j < s[index]; j++, i++) {
					ii += dy[d[index]];
					jj += dx[d[index]];
					trap[i + 1] = map[ii][jj] + trap[i];
				}
				index++;
			}

			int[][] dp = new int[t + 1][1 << P];

			for (int i = 0; i < t + 1; i++) {
				Arrays.fill(dp[i], -Integer.MAX_VALUE);
			}
			Arrays.fill(dp[0], hpi);

			for (int i = 0; i < t; i++) {
				for (int j = 0; j < 1 << P; j++) {
					if (dp[i][j] > trap[i]) {
						dp[i + 1][j] = Math.max(dp[i + 1][j],
								Math.min(dp[i][j], hpm + trap[i]));
						for (int k = 0; k < P; k++) {
							int shk = 1 << k;
							if ((shk & j) != 0) {
								continue;
							}
							dp[i + 1][j | shk] = Math
									.max(dp[i + 1][j | shk],
											Math.min(dp[i][j] + p[k], hpm
													+ trap[i]));
						}
					}
					// dp[i][j] -= trap[i];
				}
				// System.out.println(trap[i] + " " + Arrays.toString(dp[i]));
			}

			boolean ok = false;
			for (int i = 0; i < 1 << P; i++) {
				if (dp[t][i] > trap[t]) {
					ok = true;
				}
			}
			System.out.println(ok ? "YES" : "NO");
		}
	}

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

Measured memory_bytes: 37000
from collections import deque


if __name__ == '__main__':

    H, W = map(int, input().split())
    s_h, s_w = map(int, input().split())
    e_h, e_w = map(int, input().split())

    s_h -= 1
    s_w -= 1
    e_h -= 1
    e_w -= 1

    M = []

    for i in range(H):
        s = input()
        M.append(s)

    found = False

    dq = deque()
    dist = [[0 for _ in range(W)] for _ in range(H)]

    for i in range(H):
        for j in range(W):
            dist[i][j] = int(1e7)

    dist[s_h][s_w] = 0

    dq.append((s_h, s_w))

    while dq:
        h, w = dq.pop()
        # print(h, w)
        if h == e_h and w == e_w:
            found = True
            break
        for dx in range(-2, 3, 1):
            for dy in range(-2, 3, 1):
                nh = h + dx
                nw = w + dy
                if dx == 0 and dy == 0:
                    continue
                if nh >= H or nh < 0 or nw >= W or nw < 0:
                    continue
                d = 1
                if M[nh][nw] == '#':
                    continue
                if (abs(dx) == 1 and abs(dy) == 0) or (abs(dy) == 1 and abs(dx) == 0):
                    d = 0
                if dist[nh][nw] > dist[h][w] + d:
                    dist[nh][nw] = dist[h][w] + d
                    if d == 0:
                        dq.append((nh, nw))
                    else:
                        dq.appendleft((nh, nw))
    if not found:
        dist[e_h][e_w] = -1
    print(dist[e_h][e_w])
    # for dx in range(-2, 3, 1):
    #         for dy in range(-2, 3, 1):
    #             print(dx, dy)


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

public class Main {
	private static int n;
	private static int[] dp;
	
	public static void main(String[] args) {
		initialize();
		solve();
	}
	
	private static void initialize() {
		try (Scanner scan = new Scanner(System.in)) {
			n = scan.nextInt();
		}
		dp = new int[44+1];
		Arrays.fill(dp, -1);
	}
	
	private static void solve() {
		System.out.println(fibonacci(n));
	}
	
	private static int fibonacci(int i) {
		if(dp[i] != -1) return dp[i];
		if(i == 0 || i == 1) return dp[i] = 1;
		return dp[i] = fibonacci(i-1) + fibonacci(i-2);
	}
}



Measured memory_bytes: 26300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

vector<string>v;
int main() {
	string S;cin>>S;
	int K;cin>>K;
	int N=S.length();
	ll cnt=0;
	REP(i,N){
		REP(j,5){
			if(i+j>=N)break;
			string s=S.substr(i,j+1);
			v.pb(s);
			cnt++;
		}
	}
	VSORT(v);
	unique(v.begin(),v.end());
	REP(i,cnt){
		//p(v[i]);
	}
	p(v[K-1]);
}


Measured memory_bytes: 1660
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
# 上位 2/3を取得
aa=a[:2*n]
# 上位から1,2..1,2 と割り振る場合の2位の集合を取得
aaa=aa[1::2]

print(sum(aaa))

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 char EOL = '\n';
const int MOD = 1000000007;
const int INF = 1000000001;

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;

    vector<vector<pair<int, int>>> g(n, vector<pair<int, int>>());
    int l, r, d;
    REP(i, m) {
        cin >> l >> r >> d;
        l--; r--;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    vector<bool> visited(n, false);
    vector<int> p(n, 0);

    function<bool(int)> rec = [&](int c) {
        visited[c] = true;
        for (auto e : g[c]) {
            if (visited[e.first]) {
                if (p[c] + e.second != p[e.first]) return false;
            } else {
                p[e.first] = p[c] + e.second;
                if (!rec(e.first)) return false;
            }
        }
        return true;
    };

    REP(i, n) {
        if (!visited[i]) {
            if (!rec(i)) {
                cout << "No" << EOL;
                return;
            }
        }
    }
    cout << "Yes" << EOL;
}



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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#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,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O2")
//#pragma GCC optimization ("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 1000005;
int ara[N];
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    LL ans = 0;
    FOR(i,1,n)cin >> ara[i];
    int mx = ara[1];
    for(int i = 2;i <= n;i++){
        if(ara[i] < mx){
            ans += mx - ara[i];
        }
        mx = max(mx,ara[i]);
    }
    cout << ans << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

constexpr double EPS = 1e-6;

int N, K;
int x[60], y[60], c[60];

bool solve2(double X, double Y, double M) {
	int cnt = 0;

	REP(i, N) {
		double cur = c[i]*c[i] * (pow(x[i]-X,2)+pow(y[i]-Y,2));
		if (sqrt(cur) <= M + EPS) ++cnt;
	}
	return cnt >= K;
}

bool solve(double X) {
	// x[i], y[i]中心
	vector<double> xp, yp;
	REP(i, N) FOR(j, i + 1, N) { // iとjの中心 iからのj相対を
		double x1 = x[j] - x[i], y1 = y[j] - y[i];
		
		double r1 = X / c[i];
		double r2 = X / c[j];
		
		if (x1*x1 + y1*y1 > pow(r1+r2, 2) - EPS) continue;
		
		double a = (x1*x1 + y1*y1 + r1*r1 - r2*r2) / 2;
		
		xp.push_back((a*x1 + y1*sqrt((x1*x1+y1*y1)*r1*r1-a*a)) / (x1*x1+y1*y1) + x[i]);
		yp.push_back((a*y1 - x1*sqrt((x1*x1+y1*y1)*r1*r1-a*a)) / (x1*x1+y1*y1) + y[i]);
		xp.push_back((a*x1 - y1*sqrt((x1*x1+y1*y1)*r1*r1-a*a)) / (x1*x1+y1*y1) + x[i]);
		yp.push_back((a*y1 + x1*sqrt((x1*x1+y1*y1)*r1*r1-a*a)) / (x1*x1+y1*y1) + y[i]);
	}
	
	REP(i, N) {
		xp.push_back(x[i]);
		yp.push_back(y[i]);
	}
	
	bool ok = false;
	REP(i, xp.size()) if (solve2(xp[i], yp[i], X)) ok = true;
	return ok;
}

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%d %d %d", x + i, y + i, c + i);
	
	double l = 0, r = INF;
	REP(t, 60) {
		double m = (l + r) / 2;
		if (solve(m)) r = m;
		else l = m;
	}
	
	printf("%.17lf\n", l);
	
	return 0;
}


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

int main(){
    map<string,int> map;
    int n; cin>>n;
    for(int i=0;i<n;i++){
        string s; cin>>s;
        if(map.find(s)==map.end()){
            map[s]=1;
        }else{
            map[s]++;
        }
    }
    int m; cin>>m;
    for(int i=0;i<m;i++){
        string s; cin>>s;
        if(map.find(s)!=map.end())map[s]--;
    }
    int ans=0;
    for(auto it=map.begin();it!=map.end();it++){
        ans=max(ans,(*it).second);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
 
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
 
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))

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

int main(int argc, const char * argv[]) {
    
    string str;
    
    int num;
    
    while(true){
        int sum=0;
        cin>>str;
        if(str=="0"){
            break;
        }
        
        for(int i=0;i!=str.size();++i){
            num=str[i]-'0';
            sum+=num;
        }
        cout<<sum<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3164
#include <cstdio>
#include <cstring>
bool l[10000001];
int main()
{
  memset(l,true,sizeof(l));
  int i;
  for(i=3; i*2<10000001; i+=2){
    if(!l[i]) continue;
    int j;
    for(j=i*2;j<10000001; j+=i){
      l[j] = false;
    }
  }
  for(;;){
    int n;
    scanf("%d",&n);
    if(n == 0) break;
    if(n % 2 == 0) n--;
    for(;;){
      if(l[n] && l[n-2] && l[n-6] && l[n-8]) break;
      n -= 2;
    }
    printf("%d\n",n);
  }
  return 0;
}

Measured memory_bytes: 10800
//it was hard to write
//so it should be hard to read
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define last(x) (x).size() - 1
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef double ld;

const int MAXN = 1e6 + 5;
const ll INF = 1e18 + 7;
const int inf = 1e9 + 7;
const double EPS = 1e-9;

int s;
int a[MAXN];
bool used[MAXN];

int f(int x) {
	if (x & 1) return (3 * x) + 1;
	else return (x >> 1);
}

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(9);
    cout << fixed;
	cin >> s;
	a[1] = s;
	used[s] = 1;
	for (int i = 2; i <= MAXN; i++) {
		a[i] = f(a[i - 1]);
		if (used[a[i]] == 1) {
			cout << i;
			return 0;
		}
		used[a[i]] = 1;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int n;

    cin>>n;
    string s;
    cin>>s;
    int cnta,cntb;
    cnta=cntb=0;

    rep(i,s.size()){
        if(s[i]=='R'){
            cnta++;
        }
        else{
            cntb++;
        }
    }
    if(cnta>cntb)   cout<<"Yes";
    else
    {
        cout<<"No";
    }
    return 0;
    
    
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e18;
const ll MAX = 100001;
//
//

struct mi {
    ll v; explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mi& a, const mi& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mi& a, const mi& b) { 
        return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { 
        return a.v < b.v; }
   
    mi& operator+=(const mi& m) { 
        if ((v += m.v) >= MOD) v -= MOD; 
        return *this; }
    mi& operator-=(const mi& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mi& operator*=(const mi& m) { 
        v = v*m.v%MOD; return *this; }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi pow(mi a, ll p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mi inv(const mi& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mi operator-() const { return mi(-v); }
    mi& operator++() { return *this += 1; }
    mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};
void solve(){
    int n, s;
    cin>>n>>s;
    int arr[n+1];
    for(int i = 1; i <= n; i++)
        cin>>arr[i];
    mi dp[n+1][s+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= s; j++){
            dp[i][j] = dp[i-1][j]*2;
            if(j >= arr[i])
                dp[i][j] += dp[i-1][j-arr[i]];
        }

    cout<<dp[n][s];
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 74016
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int K, N; cin >> K >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	v.push_back(v[0] + K);
	
	int mx = 0;
	for (int i = 0; i < N; i++) {
		mx = max(mx, v[i + 1] - v[i]);
	}
	cout << K - mx << '\n';
	
	return 0;
}

Measured memory_bytes: 1792
n,m,v,p = map(int, input().split())
al = list(map(int, input().split()))
al.sort(reverse=True)

def check(x):
    if x<p:
        return True
    if al[p-1]>al[x]+m:
        return False

    s = 0
    for i in range(n):
        if i<p-1:
            s += m
        elif p-1<=i<x:
            s += al[x]+m-al[i]
        else:
            s += m
    return s>=m*v

ok = -1
ng = n
while ng-ok>1:
    mid = (ok+ng)//2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok+1)

Measured memory_bytes: 62576