akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int n,cnt[15],x[15][15],y[15][15],ans=0;
void check(int w)
{
	int num=0;
	REP(i,n)
		if(w>>i&1)
		{
			++num;
			REP(j,cnt[i])
				if((w>>x[i][j]&1)!=y[i][j])return;
		}
	ans=max(ans,num);
}
int main()
{
	cin>>n;
	REP(i,n)
	{
		cin>>cnt[i];
		REP(j,cnt[i])cin>>x[i][j]>>y[i][j],--x[i][j];
	}
	rep(i,1,1<<n)check(i);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();

	int A[100000], B[100000], C[100000];
	rep(i, N) A[i] = getint();
	rep(i, N) B[i] = getint();
	rep(i, N) C[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort(N, B);
	pakuri_sort(N, C);

	ll kotae = 0;
	int a = 0, c = 0;
	rep(b, N) {
		while (a < N && A[a] < B[b]) a++;
		while (c < N && B[b] >= C[c]) c++;
		kotae += (ll)a * (N - c);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
# frozen_string_literal: true

N = gets.to_i
heights = gets.chomp.split(' ').map(&:to_i)
heights[N] = Float::INFINITY

cnt = 0
max_cnt = 0
N.times do |i|
  if heights[i] >= heights[i + 1]
    cnt += 1
  else
    max_cnt = [max_cnt, cnt].max
    cnt = 0
  end
end

puts max_cnt


Measured memory_bytes: 12036
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)


const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

struct segment_tree{

    vector<ull>tree;
    int size;
    ll DEF;
    void init(int n){
        size=1;
        DEF=INF;
        while(size<n)size*=2;
        tree=vector<ull>(2*size,0);
    }

    ull merge(ull a,ull b){return a|b;}
    bool search(ull x,int l,int r){
        int m=(l+r)/2;
        if(size<=l || size<=r || l>r) return false;
        if(tree[m]==x)
            return true;
        else if(tree[m]>x)
            return search(x,l,m);
        else
            return search(x,m,r);
    }
    bool search(ull x){
        return search(x,0,size);
    }
    void set(int i,int x,ull v,int lx, int rx){
        if(rx-lx==1){
            tree[x]=v;
            return;
        }
        int m=(rx+lx)/2;
        if(i<m){
            set(i,2*x+1,v,lx,m);
        }
        else{
            set(i,2*x+2,v,m,rx);
        }
        tree[x]=merge(tree[2*x+1],tree[2*x+2]);
    }
    void set(int i,ull v){
        set(i,0,v,0,size);
    }
    ull sum(int l,int r,int x,int lx,int rx){
        if(r<=lx || rx<=l) return 0;//change
        else if(l<=lx && rx<=r)return tree[x];
        int m=(lx+rx)/2;
        return merge(sum(l,r,2*x+1,lx,m),sum(l,r,2*x+2,m,rx));
    }
    ull sum(int l,int r){
        return sum(l,r,0,0,size);
    }
    void print(){
        for(int i=0; i<tree.size(); i++)
            cout << to_string(tree[i]) << " ";
        cout << "\n";
    }
};


ll gcd(ll a,ll b){ return (a%b==0? b: gcd(b,a%b)) ;}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}


void solve();
int main(){
    FAST;
    int t=1;
    //   cin >> t;
    while(t--)
        solve();
    return 0;
}
list<char>ans;
vector<bool>vis;
bool ok;
void dfs(int src,vector<vector<char>>adj){
    vis[src]=true;
    for(char nbr:adj[src-'a']){
        if(!vis[nbr])
            dfs(nbr,adj);
        else
            ok=false;
    }
    ans.push_back(src);
}
void solve(){
    int n,k;
    cin >>n >> k;
    vi v(n);
    for(int i=0; i<n; i++)
        cin >> v[i];
    vector<bool>ans(n-k);
    int j=0;
    for(int i=k; i<n; i++){
        ans[j]=v[i]>v[i-k];
        j++;
    }
    for(int i=0; i<ans.size(); i++)
        cout << (ans[i]?"Yes":"No") << "\n";
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
const int MXN = 1000010;
bool Seive[MXN];
vector<int64_t> Primes;

void initSeive(int64_t N)
{
  for (int i = 0; i <= N; i++)
    Seive[i] = true;
}

bool isPrime(int64_t x)
{
  return Seive[x];
}

void makeSeive(int64_t N)
{
  initSeive(N);
  Seive[0] = Seive[1] = false;
  for (int64_t i = 2; i <= N; i++)
  {
    if (!isPrime(i))
      continue;
    Primes.emplace_back(i);
    for (int64_t j = 2; i * j <= N; j++)
    {
      Seive[i * j] = false;
    }
  }
}

int64_t modinv(int64_t a, int64_t m)
{
  int64_t b = m, u = 1, v = 0;
  while (b)
  {
    int64_t t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

int64_t pow_mod(int64_t x, int64_t n)
{
  int64_t res = 1;
  if (n > 0)
  {
    res = pow_mod(x, n / 2);
    if (n % 2 == 0)
      res = (res * res) % MOD;
    else
      res = (((res * res) % MOD) * x) % MOD;
  }
  return res;
}

int main()
{
  int64_t N, a, lcm = 1, ans = 0;
  cin >> N;
  makeSeive(1000010);
  vector<int64_t> A(N);
  map<int64_t, int64_t> mp;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    A.at(i) = a;
    if (isPrime(a))
    {
      if (mp.count(a))
        mp[a] = max(mp.at(a), (int64_t)1);
      else
        mp[a] = 1;
      continue;
    }
    for (int64_t p : Primes)
    {
      if (a < 2)
        break;
      int64_t tmp = 0;
      while (a % p == 0)
      {
        a /= p;
        tmp++;
      }
      if (tmp == 0)
        continue;
      if (mp.count(p))
        mp[p] = max(mp.at(p), tmp);
      else
        mp[p] = tmp;
    }
  }
  for (auto it = mp.begin(); it != mp.end(); it++)
  {
    int64_t p, n;
    tie(p, n) = *it;
    lcm = (lcm * (pow_mod(p, n) % MOD)) % MOD;
  }
  for (int i = 0; i < N; i++)
  {
    int64_t x = lcm * modinv(A.at(i), MOD) % MOD;
    ans = (ans + x) % MOD;
  }
  cout << ans % MOD << endl;
}


Measured memory_bytes: 2548
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 string s,t;
 cin>>s>>t;
 ll slen=s.length();
 ll tlen=t.length();
 
 rep(i,0,slen){
  if(s[i]==t[0]){
   j=0;
   while(s[i+j]==t[j]&&j<tlen)j++;
   if(j==tlen||i+j==slen){
    pr(n+i);
    return 0;
   }
  }
 }
 pr(slen+tlen);
return 0;}


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

int main()
{
    int n;
    cin >> n;
    int cnt = 0;

    for (int i = 1; i <= n; i++) {
        if ((int)log10(i)%2 == 0) cnt++;
    }

    cout << cnt << "\n";
}


Measured memory_bytes: 256
n = int(input())
ab_array = [[int(x) for x in input().split()] for x in range(n)]
ab_array = sorted(ab_array, key=lambda x: x[1])
time = 0
for a, b in ab_array:
    if b < a+time:
        print("No")
        exit()
    time += a
print("Yes")


Measured memory_bytes: 42836
shift_num=input()
input_line=input()

character_dict={'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'H':8,'I':9,'J':10,'K':11,'L':12,'M':13,'N':14,'O':15,'P':16,'Q':17,'R':18,'S':19,'T':20,'U':21,'V':22,'W':23,'X':24,'Y':25,'Z':26}
new_line=''
for item in input_line:
  char_index=int(character_dict[item])+int(shift_num)
  if char_index>26:
    for key, value in character_dict.items():
      if value == (char_index-26):
        new_line=new_line+str(key)
  else:
    for key, value in character_dict.items():
      if value == (char_index):
        new_line=new_line+str(key)
print (new_line)

Measured memory_bytes: 3064
#include<stdio.h>
int x,y,z;
int main()
{
	while(scanf("%d%d%d",&x,&y,&z)!=EOF)
	{
		int maxx=-1;
		for(int i=1;;i++)
		{
			if(y*i+(i+1)*z<=x) maxx=i;
			else break;
		}
		printf("%d\n",maxx);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int L,M,N,sum,day;
	int i;

	scanf("%d",&L);
	while(L!=0){
		sum=0;
		day=0;
		for(i=1; i<=12; i++){
			scanf("%d %d",&M, &N);
			sum += M-N;
			if(sum >= L && day==0)
				day=i;
		}
		if(sum >= L)
			printf("%d\n",day);
		else
			printf("NA\n");

		scanf("%d",&L);
	}
		
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    rep(i, s.length()){
        if(s[i] == '9'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    int H, W, cnt=0;
    cin>>H>>W;

    for(int i=0; i<H*W; i++){
        cnt++;
        string S;
        cin>>S;
        if(S=="snuke") break;
    }

    int n=cnt/W;
    if(cnt%W!=0) n++;

    int a=cnt%W;
    if(a==0) a=W;

    if(a==1) cout<<'A';
    else if(a==2) cout<<'B';
    else if(a==3) cout<<'C';
    else if(a==4) cout<<'D';
    else if(a==5) cout<<'E';
    else if(a==6) cout<<'F';
    else if(a==7) cout<<'G';
    else if(a==8) cout<<'H';
    else if(a==9) cout<<'I';
    else if(a==10) cout<<'J';
    else if(a==11) cout<<'K';
    else if(a==12) cout<<'L';
    else if(a==13) cout<<'M';
    else if(a==14) cout<<'N';
    else if(a==15) cout<<'O';
    else if(a==16) cout<<'P';
    else if(a==17) cout<<'Q';
    else if(a==18) cout<<'R';
    else if(a==19) cout<<'S';
    else if(a==20) cout<<'T';
    else if(a==21) cout<<'U';
    else if(a==22) cout<<'V';
    else if(a==23) cout<<'W';
    else if(a==24) cout<<'X';
    else if(a==25) cout<<'Y';
    else if(a==26) cout<<'Z';

    cout<<n<<endl;
}


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

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; }
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int A,B;

// *********************************************************



int main(){

    cin>>A>>B;

    double min8, max8, min10, max10;

    min8 = A /0.08;
    max8 = (A+1)/0.08;
    min10 = B/0.1;
    max10 = (B+1)/0.1;

    if(min8 == min10){
        cout << min8 << endl;
    }else{
        if(min8<min10 && min10 < max8){
            cout << min10 <<endl;
        }else if(min8>min10 && min8<max10){
            for(;min10<min8;){
                min10++;
            }
            cout << min10 <<endl;
        }else{
            cout<< -1 <<endl;
        }
    }

   

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//cards with the same value appear in the output in the same order as they do in the input (instance).
//chech the stablitity of bubble and insertion
struct card{
  char c;
  int num;
};
void print_array(struct card a[], int n){
int i = 0;
    for(i = 0; i<n-1; i++)
        printf("%c%d ",a[i].c, a[i].num);
    printf("%c%d\n",a[i].c,a[i].num);
}
void selection_sort(struct card a[], int n){
    int res = 0;
    for(int i = 0; i<n; i++){
        int mini = i;
        for(int j=i; j<n;j++){
            if(a[j].num < a[mini].num) mini = j;
        }
        //swap
        struct card temp = a[i];
        a[i] = a[mini];
        a[mini] = temp;
    }
    print_array(a,n);
    
}
void bubble_sort(struct card a[], int n){
    for(int i = 0; i<n; i++){
        for(int j=n-1; j>=i+1;j--){
            if(a[j].num < a[j-1].num)
            {
                struct card temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
        }
    }
    print_array(a,n);
}

int check(struct card arr[], int n, struct card origin[],int au[]){
    int ch[10];
    int count = 0;
    for(int i = 1; i<=9; i++){
        if(au[i]>1) ch[count++] = i;//from 0
    }
    char test_arr[10][5];
    char test_org[10][5];
    for(int i = 0; i<10; i++){
        for(int j = 0; j<5; j++){
            test_arr[i][j] = 'w';
            test_org[i][j] = 'w';
        }
    }
    for(int i = 0; i<count; i++){
        int temp = 0;
        for(int j = 0; j<n; j++){
            if(origin[j].num == ch[i])
             test_org[i][temp++] = origin[j].c;
        }
        temp = 0;
        for(int j = 0; j<n; j++){
            if(arr[j].num == ch[i])
             test_arr[i][temp++] = arr[j].c;
        }
        
    }
    for(int i = 0; i<count; i++){
        for(int j = 0; j<5; j++){
            if(test_arr[i][j]!=test_org[i][j]) return 0;
        }
    }
    
    
    
    return 1;
}

int main()
{
    int n = 0;
    scanf("%d", &n);
    struct card arr[n+1];
    struct card origin[n+1];
    int au[10]; 
    for(int i = 1; i<=9; i++){
        au[i]  = 0;
    }
    for(int i = 0; i<n; i++){
        char c; int num;
        scanf(" %c%d ",&c,&num);
        //printf("%c%d\n",c,num);
        struct card temp;
        temp.c = c;
        temp.num = num;
        arr[i] = temp;
        origin[i] = temp;
        au[num]++;
    }
    bubble_sort(arr,n);
    if(check(arr,n,origin,au)){
        printf("Stable\n");
    }else printf("Not stable\n");
    for(int i = 0; i<n; i++){
        arr[i] = origin[i];

    }
    selection_sort(arr,n);
    if(check(arr,n,origin,au)){
        printf("Stable\n");
    }else printf("Not stable\n");
    
    return 0;
}



Measured memory_bytes: 2708
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int cnt;
void solve(){
  int l,r,d;cin>>l>>r>>d;
  rep(i,l,r){
    if((i%d)==0)cnt++;
  }
  cout<<cnt;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3596
#文字列の格納
list_station = list(input())

#文字列の初期化
text = "No"
i = 0

#判別
while i < len(list_station) - 1:
    if list_station[i] != list_station[i+1]:
        text = "Yes"
        break
    else:
        i += 1

#結果の表示
print(text)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)			
    {
        
    }*/
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    
    //if(h==0)
    //h=12;
   // if(m==0)
    //m=60;
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;
    double theta = abs(hour_angle - minute_angle); 
    theta= min(360 - theta, theta);  
   // cout<<theta;
    double ans=sqrt(a*a+b*b-2*a*b*cos(theta*3.141592653589793238/180.0000000));
    cout << fixed << setprecision(15) <<ans<<endl; 
}

Measured memory_bytes: 4268
n=int(input())
a=list(map(int,input().split()))
money=1000
stock=0
for i in range(n-1):
  if a[i]>a[i+1]:
    money+=stock*a[i]
    stock=0
  else:
    stock+=money//a[i]
    money=money%a[i]
print(money+stock*a[n-1])

Measured memory_bytes: 61852
/**
    AUTHOR:JUNSH
    TIME:19/6/1
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    while(s.length()<15){
        s+='o';
    }
    int ans=0;
    for(int i=0;i<15;++i){
        if(s[i]=='o')ans++;
    }
    if(ans>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


Measured memory_bytes: 256
N,M=io.read("*n","*n")
T={}
for i=1, M do
    T[i]=0
end
for i=1, N do
    K=io.read("*n")
    for j=1, K do
        A=io.read("*n")
        T[A]=T[A]+1
    end
end
counter=0
for i=1, M do
    if T[i]==N then
        counter=counter+1
    end
end
print(counter)

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mid ((l+r)>>1)
const int N=1<<20;
struct node{
	int to,ne;
}e[N];
int n,k,i,mn[N],x,a[N],d[N],tot,h[N],u,v,id[N],cnt;
priority_queue<int,vector<int>,greater<int> >q;
void add(int x,int y){e[++tot]={y,h[x]},h[x]=tot,d[y]++;}
void up(int t){mn[t]=min(mn[t<<1],mn[t<<1|1]);}
int query(int t,int l,int r,int x,int y){
	if (x>y) return 1e9;
	if (x<=l && r<=y) return mn[t];
	int ans=1e9;
	if (x<=mid) ans=min(ans,query(t<<1,l,mid,x,y));
	if (mid<y) ans=min(ans,query(t<<1|1,mid+1,r,x,y));
	return ans;
}
void update(int t,int l,int r,int x,int y){
	if (l==r){
		mn[t]=y;
		return;
	}
	if (x<=mid) update(t<<1,l,mid,x,y);
	else update(t<<1|1,mid+1,r,x,y);
	up(t);
}
int main(){
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++) scanf("%d",&x),a[x]=i;
	memset(mn,63,sizeof(mn));
	for (i=n;i;i--){
		x=query(1,1,n,max(a[i]-k+1,1),a[i]-1);
		if (1<=x && x<=n) add(a[i],a[x]);
		x=query(1,1,n,a[i]+1,min(a[i]+k-1,n));
		if (1<=x && x<=n) add(a[i],a[x]);
		update(1,1,n,a[i],i);
	}
	for (i=1;i<=n;i++)
		if (!d[i]) q.push(i);
	while (!q.empty()){
		u=q.top(),q.pop(),id[u]=++cnt;
		for (i=h[u];i;i=e[i].ne)
			if (!(--d[v=e[i].to])) q.push(v);
	}
	for (i=1;i<=n;i++) printf("%d\n",id[i]);
}

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

vector<int>pre, in, post;
int n,pos=0;

void rec(int l, int r) {
	if (l >= r)return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);


}



void solve()
{
	rec(0, pre.size());
	for (int i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << post[i];
	}
	cout << endl;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		pre.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		in.push_back(x);
	}

	solve();

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    ll h,n,k,x,c = 0;
    

    
    cin >> n >> k;
    while (n!=0)
    {
        n/=k;
        c++;
    }
    cout << c << endl;
    
        
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  int n,m;
  int res=0;
  cin >> n >> m;

  res = (n-1)*(m-1);

  cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] mt = new int[10];
		for(int i = 0; i < 10; i++){
			mt[i] = scan.nextInt();
		}
		for(int i = 0; i < 10 - 1; i++){
			for(int j = 10 - 1; j > i; j--){
				if(mt[i] < mt[j]){
					int big = mt[j];
					mt[j] = mt[i];
					mt[i] = big;
				}
			}
		}
		for(int i = 0; i < 3; i++){
			System.out.printf("%d\n", mt[i]);
		}
	}
}

Measured memory_bytes: 26132
import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

pow2 :: Int -> Int -> Int -> Int
pow2 k now cnt = if now >= k then cnt
  else pow2 k (2*now) (cnt+1)

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  print $ (sum [((1/(fromIntegral n) :: Double) * (1/2 :: Double)^(pow2 k i 0)) | i <- [1..n]])


Measured memory_bytes: 508
//Himanshu Manwani
//grid problem ..
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h ,v;  cin>>h>>v;
    char mat[h][v];
    for(int i =0;i<h;i++)
    {
        for(int j= 0;j<v;j++)
        {
            cin>>mat[i][j];
        }
    }
    ll dp[h][v];
    memset(dp,0,sizeof(dp));
    int i;
    for( i =0;i<h;i++)
    {
        if(mat[i][0] == '.')dp[i][0] = 1;
        else break;
    }//dp[i][0] = 0;
    for( ; i<h;i++)dp[i][0] = 0;
    for( i =0;i<v;i++)
    {
        if(mat[0][i] == '.')dp[0][i] = 1;
        else break;
    }//dp[0][i] = 0;
    for( ; i<v;i++)dp[0][i] = 0;
    for(int i =1;i<h;i++)
    {
        for(int j=1;j<v;j++)
        {
            if(mat[i][j] == '#')dp[i][j] = 0;
            else
            {
                dp[i][j] = add(dp[i-1][j],dp[i][j-1]); 
            }
            
        }
    }  
    cout << dp[h-1][v-1];  

    
    return 0;
 }

Measured memory_bytes: 9088
import scala.io.StdIn.readInt
object Main {
  def main(args: Array[String]) {
    val inputS = readInt
    val tmp = inputS / 60
    val s = inputS % 60
    val h = tmp / 60
    val m = tmp % 60
    println(s"$h:$m:$s")
  }
}

Measured memory_bytes: 43756
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void) {
	int A, N, M, X, cnt = 0, sum , dig;
	cin >> A >> N >> M;
	for (int Y = 1;pow(Y + A, N) <= M;Y++) {
		X = pow(Y + A, N);
		sum = 0;
		while (X) {
			dig = X % 10;
			sum = sum + dig;
			X = X / 10;
		}
		if (sum == Y) {
			cnt++;
			//cout << pow(Y+A,N) << endl;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<long> data(N);
  for(int i = 0; i < N; i++)cin >> data.at(i);
  long ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      for(int k = j + 1; k < N; k++){
        if(((data.at(i) + data.at(j)) > data.at(k)) && ((data.at(j) + data.at(k)) > data.at(i)) && ((data.at(k) + data.at(i)) > data.at(j))){
          if(data.at(i) != data.at(j) && data.at(k) != data.at(j) && data.at(i) != data.at(k))ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[100005];
vector<int> v[100005];
void dfs(int x,int y){
    for(int i=0;i<v[x].size();++i){
        int z=v[x][i];
        if(y==z) continue;
        dfs(z,x);
        a[x]^=(a[z]+1);
    }
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].pb(y),v[y].pb(x);
    }
    dfs(1,0);
    if(a[1])puts("Alice");
    else puts("Bob");
    //system("pause");
    return 0;
}


Measured memory_bytes: 13952
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<cctype>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

  ll a;

  cin >> a;

  cout << (a + a*a + a*a*a) << endl;

  return 0;

}   


Measured memory_bytes: 3628
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().ok().unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());
    println!("{}", a * (a - 1) / 2 + b * (b - 1) / 2);
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    size_t maxLength = max(a.length(), b.length());
    a.insert(a.begin(), maxLength - a.length(), '0');
    b.insert(b.begin(), maxLength - b.length(), '0');

    int comp = a.compare(b);
    if (comp < 0)
        puts("LESS");
    else if (comp == 0)
        puts("EQUAL");
    else
        puts("GREATER");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[10];
	for(int i=1;i<5;i++)
		cin>>a[i];
	sort(a+1,a+5,greater<int> ());
	swap(a[0],a[4]);
	const int cnt[10]={1,9,7,4};
	for(int i=0;i<4;i++)
		if(a[i]!=cnt[i]){
			cout<<"NO"<<endl;
			return 0; 
		}
	cout<<"YES"<<endl; 
	return 0;
}

Measured memory_bytes: 256
using System;

namespace Atcoder
{
    class programing
    {
        static void Main(string[] args)
        {
            var num = long.Parse(Console.ReadLine());
            long ans = long.MaxValue;
            for (int i = 1; i <= Math.Sqrt(num); i++)
            {
                if (num % i != 0) continue;
                long ij = i + (num / i) - 2;
                ans = Math.Min(ans, ij);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(int argc, char *args[])
{
	int n;
	long int a,min=1000000,max=-1000000;
	long long int sum=0;
	int i;

	scanf("%d", &n);

	for(i=0; i<n; i++) {
		scanf("%ld", &a);

		sum += a;

		if( a < min ) {
			min = a;
		}

		if( a > max ) {
			max = a;
		}
	}

	printf("%ld %ld %lld\n", min, max, sum);

	return 0;

}

Measured memory_bytes: 600
#include <iostream>

using namespace std;
int main() {
	int N;
	cin >> N;

	for(int i4 = 0; i4 <= 25 ; i4++) {
		for (int i7 = 0; i7 <= 15; i7++) {
			if (N == i4 * 4 + i7 * 7) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

int aabs(int x)
{
    if (x < 0)
        x *= -1;
    return x;
}

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

signed main()
{
    int n;
    int x[100], y[100], h[100];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    int cx, cy, ch;
    for (cx = 0; cx <= 100; cx++)
    {
        for (cy = 0; cy <= 100; cy++)
        {
            for (int i = 0; i < n; i++)
            {
                if (h[i] > 0)
                {
                    ch = h[i] + aabs(cx - x[i]) + aabs(cy - y[i]);
                }
            }
            ch = mmax(ch, 0);
            for (int i = 0; i < n; i++)
            {
                int tmp = ch - aabs(cx - x[i]) - aabs(cy - y[i]);
                tmp = mmax(tmp, 0);
                if (h[i] != tmp)
                {
                    goto LL;
                }
            }
            goto LABEL;
        LL:
        {
        }
        }
    }
    goto LABEL;
LABEL:
    cout << cx << " " << cy << " " << ch << endl;
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x, a, b;
	cin >> x >> a >> b;

	if(a >= b)
	{
		cout << "delicious" << endl;
		return 0;
	}
	if(b-a <= x)
	{
		cout << "safe" << endl;
		return 0;
	}

	cout << "dangerous" << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 10 || b >= 10) {
    cout << -1 << endl;
  } else {
    cout << a * b << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int n, m, d[20], count[20][50001] = { 0 };

int minc(int c1, int c2);


int main()
{
	int i = 0, j;

	scanf("%d %d", &n, &m);
	//printf("%d %d\n",n,m);
	while (i < m) {
		scanf("%d", &d[i]);
		//printf("%d ",d[i]);
		if (d[i] != ' ')i++;
	}
	

	for (i = 1; i <= n; i++) {
		count[0][i] = i;
	}

	for (i = 1; i < m; i++) {
		for (j = 1; j <= n; j++) {
			if (j - d[i] >= 0) {
				count[i][j] = minc(count[i - 1][j], count[i][j - d[i]] + 1);
			}
			else {
				count[i][j] = count[i - 1][j];
			}
		}
	}
	
	printf("%d\n", count[m-1][n]);

	return 0;
}

int minc(int c1, int c2)
{
	return c1 < c2 ? c1 : c2;
}

Measured memory_bytes: 4500
<?php
define('MOD', 10 ** 9 + 7);

fscanf(STDIN, '%d %d', $n, $m);
$step = array_fill(1, $n, true);
for ($i  = 1; $i <= $n; $i++) {
    fscanf(STDIN, '%d', $a);
    $step[$a] = false;
    if (!($step[$a - 1] ?? true)) {
        echo (0) . PHP_EOL;
        exit();
    }
}

$dp[0] = 1;
for ($i = 0; $i < $n; $i++) {
    if (!$step[$i + 1]) {
        $dp[$i + 1] = 0;
        continue;
    }
    $dp[$i + 1] = ($dp[$i] + ($dp[$i - 1] ?? 0)) % MOD;
}
echo $dp[$n] . PHP_EOL;

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

int main() {
  int N;
  cin >> N;
  
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    A.at(i).second = i + 1;
    cin >> A.at(i).first;
  }
  
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    cout << A.at(i).second;
    if (N != N - 1) cout << " ";
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int k,a,b;
    cin >> k;
    cin >> a >> b;

    int largest = (b / k) * k;
    if(a <= largest){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
L = input()
MOD = 10**9 + 7

if L[-1] == "0":
    OK, NG = 1, 2
else:
    OK, NG = 3, 0

for i in range(len(L)-2, -1, -1):
    if L[i] == "1":
        OK, NG = (3*OK + NG)%MOD, 2*NG%MOD
    else:
        OK, NG = OK%MOD, (2*OK + 3*NG)%MOD

print(OK)

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    vector<bool> broken(N, false);
    ll dp[N+2] = {};
    dp[0] = 1;
    rep(i, M){
        int a; cin >> a;
        broken[a] = true;
    }
    for(int i = 0; i <= N-1; i++){
        if(!broken[i]){
            dp[i+1] += dp[i]; dp[i+1] %= mod;
            dp[i+2] += dp[i]; dp[i+2] %= mod;
        }
    }
    cout << dp[N] << endl;
    return 0;
}


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

int compare(int a, int b) {
  if (a >= b) return a;
  else return b;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int x = compare(a, b);
  int y = compare(a, c);
  int z = compare(b, c);
  if (x == y) cout << a * 10 + b + c << endl;
  else if (b < c) cout << c * 10 + a + b << endl;
  else cout << b * 10 + a + c << endl;
}
  

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll H, N, A[112345];

int main() {

	cin >> H >> N;
	rep(i, N) cin >> A[i];

	if (accumulate(A, A + N, 0) >= H) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main() {
  
  double const INF = 1e14;
  
  int N; cin >> N;
  double dist[N];
  int ID[20], weights[N];
  rep(i, N) {
    int id; cin >> id; ID[i] = id;
    cin >> dist[i] >> weights[i];
  }
  
  double Weight[1<<N];
  rep(i, 1<<N) {
    Weight[i] = 0;
    rep(j, N) {
      if(i >> j & 1) Weight[i] += weights[j]*20;
    }
  }
  
  double dp[1<<N][N]; fill(dp[0], dp[1<<N], INF);
  pair<int, int> prev[1<<N][N];
  rep(i, N) {
    dp[1<<i][i] = 0.;
  }
  
  rep(S, (1<<N)-1) {
    rep(u, N) {
      if(!(S & (1<<u))) continue;
      if(dp[S][u] == INF) continue;
      rep(v, N) {
        if(S & (1<<v)) continue;
        int nS = S|(1<<v);
        double cand = dp[S][u] + abs(dist[u]-dist[v])*(70.+Weight[S])/2000.;
        if(dp[nS][v] > cand) {
          dp[nS][v] = cand; prev[nS][v].first = S; prev[nS][v].second = u;
        }
      }
    }
  }
  
  int last = -1; double mn = INF;
  rep(i, N) {
    if(mn > dp[(1<<N)-1][i]) {
      mn = dp[(1<<N)-1][i]; last = i;
    }
  }
  
  vector<int> ans;
  int S = (1<<N)-1;
  rep(i, N) {
    ans.push_back(ID[last]);
    int nS = prev[S][last].first, nlast = prev[S][last].second;
    S = nS, last = nlast;
  }
  reverse(ans.begin(), ans.end());
  rep(i, N) {
    if(i) cout << ' ';
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 9188
# 正解パターンは2種類しか絶対にない
# それの小さいほうをとればよい

s = list(input())

N = len(s)

for i in range(N) : 
    s[i] = int(s[i])
    
s0 = []
s1 = []
    
for i in range(N) : 
    if i%2 == 0 : 
        s0.append(0)
    else : 
        s0.append(1)
        
for i in range(N) : 
    if i%2 == 1 : 
        s1.append(0)
    else : 
        s1.append(1)

# print(s)        
# print(s0)
# print(s1)

cnt0 = 0
cnt1 = 0

for i in range(N) : 
    if s[i] != s0[i] : 
        cnt0 += 1
    if s[i] != s1[i] : 
        cnt1 += 1
        
# print(cnt0)
# print(cnt1)

print(min(cnt0, cnt1))

Measured memory_bytes: 5548
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    vector<double> A(N); cin >> A;
    double lb=0,ub=INF;
    for (int i=0;i<500;++i){
        double mid=(ub+lb)/2;
        ll need=0;
        for (int i=0;i<N;++i){
            need+=ceil(A[i]/mid)-1;
        }
        (need<=K?ub:lb)=mid;
    }
    cout << (int)ceil(ub) << '\n';
}

Measured memory_bytes: 4772
#include <stdio.h>
#include <math.h>

int main(){
double a,b,c,s,l,h,Pi=3.1415926535;
  
  scanf("%lf %lf %lf",&a,&b,&c);
  
  s = a*b*sin(c/180*Pi)*1/2;
  l = a+b+sqrt(a*a + b*b -2*a*b*cos(c/180*Pi));
  h = b*sin(c/180*Pi);
 printf("%f\n%f\n%f\n",s,l,h);
  return 0;
  
}


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

#n,*w = [int(i) for i in read().split()]
#n,*t = map(int,read().split())

#n = int(input())
#s = input()
h,n = [int(i) for i in readline().split()]

a = [int(i) for i in readline().split()]


if h <= sum(a):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 13588
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if (op == "+"):
        print(a + b)
    elif(op == "-"):
        print(a - b)
    elif(op == "/"):
        print(a // b)
    elif(op == "*"):
        print(a * b)
    elif(op == "?"):
        break

Measured memory_bytes: 7696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (110)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

bool isPrime(int n){
  if(n == 1) return false;
  rep(i, 2, min((int)(pow(n, 0.5) + 1), n)){
    if(n % i == 0) return false;
  }
  return true;
}

/////////////////////////////////////////////////////////

void Main() {
  ll N; cin >> N;
  ll res = INF;
  rep(i, 1, N){
    ll A = i;
    ll B = N - A;
    int sum = 0;
    while(A > 0){
      sum += A % 10;
      A /= 10;
    }
    while(B > 0){
      sum += B % 10;
      B /= 10;
    }
    chmin(res, sum);
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
import bisect
import sys
input = sys.stdin.readline
a, b, q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(a)] + [INF]
t = [-INF] + [int(input()) for i in range(b)] + [INF]
ans = []
for i in range(q):
    x = int(input())
    idxs = bisect.bisect(s, x)
    idxt = bisect.bisect(t, x)
    lis = []
    lis.append(x - min(s[idxs - 1], t[idxt -1]))
    lis.append(x - s[idxs - 1] + (t[idxt] - s[idxs - 1]))
    lis.append(t[idxt] - x + (t[idxt] - s[idxs - 1]))
    lis.append(x - t[idxt - 1] + (s[idxs] - t[idxt - 1]))
    lis.append(s[idxs] - x + (s[idxs] - t[idxt - 1]))
    lis.append(max(s[idxs], t[idxt]) - x)
    ans.append(min(lis))
for i in range(q):
    print(ans[i])





Measured memory_bytes: 16364
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(x int) int {
	if x < 0 {
		return -1 * x
	} else {
		return x
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nextInt() - i - 1
	}

	sort.Ints(b)

	median := b[n/2]
	if n % 2 == 0 {
		median = (median + b[n/2 - 1]) / 2
	}

	sum := 0
	for i := 0; i < n; i++ {
		sum += abs(b[i] - median)
	}

	fmt.Println(sum)
}

Measured memory_bytes: 5120