akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int cntResult = 0;
            for(int i = 1; i <= N; i=i+2)
            {
               
                    int cnt = 0;
                    for(int j = 1; j <= i; j=j+2)
                    {
                        
                        if (i % j == 0)
                        {
                            cnt++;
                        }
                    }
                    if (cnt == 8)
                    {
                        cntResult++;
                    }
                
            }
            Console.WriteLine(cntResult);

        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 27116
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    string s,t; cin>>s>>t;
    t.pop_back();
    if(s==t){
    	cout<<"Yes\n";
    }
    else{
    	cout<<"No\n";
    }
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n,a,b;cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
    return 0;
}


Measured memory_bytes: 764
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import groupby
from heapq import heappop, heappush, heapify
def resolve():
    n, k, q = map(int, input().split())
    A = list(map(int, input().split()))

    ans = INF
    for m in sorted(A):
        C = []
        for key, it in groupby(A, key = lambda a : a >= m):
            if key is False:
                continue
            D = list(it)
            if len(D) >= k:
                D.sort()
                C.append(D[:len(D) - k + 1][::-1])

        if sum(len(a) for a in C) < q:
            continue
        heap = [(C[i].pop(), i) for i in range(len(C))]
        heapify(heap)
        for _ in range(q):
            M, i = heappop(heap)
            if C[i]:
                heappush(heap, (C[i].pop(), i))
        ans = min(ans, M - m)

    print(ans)
resolve()

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int h, w;
    cin >> h >> w;
    char ary[h][w] = {};
    rep(i, h) {
        rep(j, w) { cin >> ary[i][j]; }
    }

    // 処理
    // 出力
    for (int i = 0; i < h; i++) {
        for (int k = 0; k < 2; k++) {
            for (int j = 0; j < w; j++) {
                cout << ary[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;

template <typename Monoid>
struct SegmentTree{
private:
    int N;
    vector<Monoid> node;
    using F = function<Monoid(Monoid, Monoid)>;
    F f;
    Monoid e;

public:
    SegmentTree(){}
    SegmentTree(F f, Monoid e):f(f), e(e){}
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.assign(2*N-1,e);
    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }
    void set_val(int k, Monoid x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }
    // [a,b)
    Monoid query(int a, int b){return query(a, b, 0, 0, N);}
    Monoid query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return e;
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = query(a, b, 2*k+1, l, (l+r)/2);
        vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};



int main() {
    auto f = [=](int a, int b){return min(a, b);};
    SegmentTree<int> seg(f,IINF);

    int n, q;
    cin >> n >> q;
    seg.init(n);
    for(int i=0; i<q; i++){
        int c, x, y;
        cin >> c >> x >> y;
        if(c){
            cout << seg.query(x, y+1) << endl;
        }
        else{
            seg.set_val(x, y);
        }
    }
    return 0;
}



Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>

using namespace std;
int main(){
  int n;
  int s[111];
  while(cin>>n){
    if(n ==0)
      break;
    for(int i = 0;i<n;i++){
      cin>>s[i];
    }
    sort(s,s+n);
    int ans = 0;
    for(int i = 1;i<n-1;i++)
      ans += s[i];

    ans /= n-2;
    cout<<ans<<endl;
  }
  return 0;


}

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

int main(){
    int a,b;
    cin >> a >> b;
    int count = 0;
    int amari = 0;
    if (a>=500){
        amari = a % 500;
        count = a/500;
    }

    if (amari<=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    
}

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

int main(){
  int n,k,s=0; cin>>n;
  int a[n],b[n];
  
  for(int i=0;i<2*n;i++){
    cin>>k;
    if(i<n) a[i] = k;
    else b[i-n] = k;
  }
  
  for(int i=0;i<n;i++){
    if(a[i]-b[i]>0) s += a[i]-b[i];
  }
  
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	double s = (double)W * (double)H / 2;
	int ans = 0;
	if (W % 2 == 0 && W / 2 == x && H % 2 == 0 && H / 2 == y) ans = 1;
	cout << s << " " << ans;
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;


int main() {
   int A,B;
   cin>>A>>B;
   if(A+B==3){
       cout<<3<<endl;
   }else if(A+B==4){
       cout<<2<<endl;
   }else{
       cout<<1<<endl;
   }





}


Measured memory_bytes: 256
def main():
    n = input()
    s = raw_input()
    a1 = set()
    a2 = set()
    a3 = set()
    jj = [set()]
    for j in xrange(n - 1, 1, -1):
        jj.append(jj[-1] | {s[j]})
    jj = jj[::-1]
    for i, c1 in enumerate(s[:-2]):
        if c1 in a1:
            continue
        a1.add(c1)
        for j in xrange(i + 1, n - 1):
            ss = c1 + s[j]
            if ss in a2:
                continue
            a2.add(ss)
            for c3 in jj[j - 1]:
                a3.add(ss + c3)
    print len(a3)

main()


Measured memory_bytes: 42396
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var a = Console.ReadLine()[0];

        if (Char.IsUpper(a))
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("a");
        }
    }
}


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

int main(){
  string s;
  cin >> s;
  int n;
  n = s.size();
  string t;
  t = s.substr((n + 1) / 2);
  s.erase((n - 1) / 2);
  string s1, t1;
  s1 = s;
  reverse(s1.begin(), s1.end());
  t1 = t;
  reverse(t1.begin(), t1.end());
  if((s == t1)&&((s == s1)&&(t == t1))) {
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
S = input()
T = input()

#print(T[len(T)-1])

if S in T :
  text = T.replace(S,"",1)
  if text == T[len(T)-1]:
    if len(text) == 1:
      print("Yes")
      sys.exit()
  else:
    print("No")
    sys.exit()

print("No")

Measured memory_bytes: 9024
#include<cstdio>
#include<algorithm>
using namespace std;
int n,i,ans;
int digit(int x)
{
	int sum=0;
	while(x)sum+=x%10,x/=10;
	return sum;
}
int main()
{
	ans=1e9;
	scanf("%d",&n);
	for(i=1;i<n;i++)ans=min(ans,digit(i)+digit(n-i));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N;
  cin >> N;
  int l[N], r[N];
  int ans = 0;
  rep(i, N) {
    cin >> l[i] >> r[i];
    ans += r[i]-l[i] +1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
const ll M=1e9+7;
const int MAXN=2e5+1;


int mat[25][25];

ll dp[22][(1<<22)];

int main(){

	int n; sfi(n)

	f(i,0,n)
		f(j,0,n)
			sfi(mat[i][j])

	

	

	dp[0][0]=1;

	for(ll i=1;i<=n;i++){
		for(ll mask=0;mask<(1<<n);mask++){
			int j=__builtin_popcount(mask);
			if(j!=i) continue;

			for(int j=0;j<n;j++){
				if(mat[i-1][j] && mask&(1<<j)){
					dp[i][mask]=(dp[i][mask]+dp[i-1][mask^(1<<j)])%M;
				}
			}
		}
	}

	pfln(dp[n][(1<<n)-1])

	return 0;	
}

Measured memory_bytes: 321792
#include<iostream>

using namespace std;

int main() {
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int x;
	cin >> x;
	cout << a[x - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n;
     cin>>n;
     ll x=n/500;
     ll y=n%500;
     ll z=y/5;
     cout<<(x*1000+z*5)<<endl;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 256
import java.util.Scanner;


class Main {

	public static void main(String[] args){
		double debt = 100000;
		double rate = 1.05;

		Scanner in = new Scanner(System.in);
		int numWeeks = in.nextInt();
		
		for (int i=1; i<=numWeeks; i++){
			debt = debt * rate;
			if(debt%1000 == 0){
				//do nothing
			} else {
				debt = (debt - (debt%1000)) + 1000;
			}
		}
		System.out.println((int) debt);
	}
}

Measured memory_bytes: 25748
import numpy as np

n = int(input())
A = list(map(int,input().split()))

for i in range(n):
    A[i] -= i+1

a = np.array(A)

m = int(np.median(a))

sad = int(abs(a-m).sum())

M = int(a.max() - a.min())

for i in range(1,M):
    s = int(abs(a-m-i).sum())
    if sad > s:
        sad = s
    else:
        break

for i in range(1,M):
    s = int(abs(a-m+i).sum())
    if sad > s:
        sad = s
    else:
        break

print(sad)


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

const int N = 1e4 + 5, D = 1e2 + 5;

int DP[N][D];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	
	string k; cin >> k;
	int n = sz(k), d, ans = 0, sum = 0; cin >> d;
	DP[0][0] = 1;
	for (int i = 1; i < n; i++) for (int j = 0; j < d; j++) 
		for (int l = 0; l < 10; l++) DP[i][j] = (DP[i][j] + DP[i - 1][(j - l % d + d) % d]) % MOD;
	for (int i = 0; i < n; i++) for (int j = 0; j < k[i] - '0'; j++, sum = (sum + 1) % d) ans = (ans + DP[n - i - 1][(d - sum) % d]) % MOD;
	ans = (ans - (sum % d != 0) + MOD) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }


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

	string s;
	cin >> s;

	vi vec(26);
	for (int i = 0; i < s.size(); i++) {
		vec[s[i] - 'a']++;
	}

	for (int i = 0; i < vec.size(); i++) {
		if (vec[i] >= 2) {
			cout << "no" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
bool IsPrime[10010];

void calc()
{
	memset(IsPrime, 1, sizeof(bool) * 10010);
	IsPrime[0] = 0;
	IsPrime[1] = 0;
	for(int i = 2; i < 10010; ++i)
	{
		if(IsPrime[i])
		{
			for(int j = 2 * i; j < 10010; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n)
	{
		int count = 0;
		for(int i = 1; i < n; ++i)
		{
			if(IsPrime[i] && IsPrime[n - i + 1])
			{
				count++;
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();
		List<String> list = new ArrayList<>();
		Set<String> set = new HashSet<>();
		for(int i = 0; i < s.length(); i++) {
			list.add(s.substring(i));
		}
		Collections.sort(list);
		boolean end = false;
		for(String e : list) {
			for(int i = 1; i <= e.length(); i++) {
				String tmp = e.substring(0, i);
				if(!set.contains(tmp) && k != 1) {
					k--;
					set.add(tmp);
				} else if(!set.contains(tmp) && k == 1) {
					System.out.println(tmp);
					end = true;
					break;
				}
			}
			if(end)
				break;
		}

	}

}


Measured memory_bytes: 56916
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    int ans = 0;
    vector<int> H(N);
    for(int &h:H)
        cin >> h;
    for(int i=0; i<N; i++){
        bool f = true;
        for(int j=0; j<i; j++){
            if(H[j] > H[i]) f = false;
        }
        if(f) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	char hoge[256] = "aaaaaaaaaaaaaaaaa";
	cin >> hoge;
	cout << (strncmp(hoge, "YAKI", 4) == 0 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
nk = list(map(int,input().split()))
n = nk[0]
k = nk[1]

A = list(map(int,input().split()))

for i in range(k + 1, n + 1):
    if A[i - 1] > A[i - k - 1]:
        print("Yes")
    else:
        print("No")

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

using namespace std;
// #define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
// #define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  long double a;
  long double b;
  cin >> a >> b;

  long double ans = a * b;
  long long res = floor(ans);
  // cout << (long long)ans << endl;
  // cout << (long long)ans << endl;
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3796
import java.util.*;
class Main{
	Scanner sc=new Scanner(System.in);
	boolean[][] card=new boolean[4][13];
	void aa(){
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String m=sc.next();
			int s=sc.nextInt();
			card[bb(m)][s-1]=true;
		}
		for(int i=0;i<4;i++){
			for(int j=1;j<14;j++){
				if(!card[i][j-1]){
					String m=cc(i);
					System.out.println(m+" "+j);
				}
			}
		}
	}
	int bb(String m){
		if(m.equals("S"))return 0;
		else if	(m.equals("H"))return 1;
		else if	(m.equals("C"))return 2;
		else return 3;
	}
	String cc(int n){
		String m="";
		switch (n){
			case 0:
			m="S";
			break;
			case 1:
			m="H";
			break;
			case 2:
			m="C";
			break;
			case 3:
			m="D";
			break;
		}
		return m;
	}
	public static void main(String[]arg){
		new Main().aa();
	}
}

Measured memory_bytes: 18240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);



int main(){
	string s,t,u;
	cin >> s >> t;
	int a,b;
	cin >> a >> b >> u;
	if(u==s)a--;
	if(u==t)b--;
	cout << a << " " << b << endl;
}



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

const int N=1e6;

char Istr[N+3];
int Ncnt[3],posA[N+3];
int n,Nn;
stack< pair<int,int> > Smod;

void fSwap(int Ca,int Cb){
	swap(Ncnt[Ca],Ncnt[Cb]);
	for(int i=1;i<=n;i++)
		if(Istr[i]=='A'+Ca) Istr[i]='A'+Cb;
		else if(Istr[i]=='A'+Cb) Istr[i]='A'+Ca;
}
void SurA(){
	int Ctb=0,Ctc=0,Cta=0;
	for(int i=1;i<=n;i++)
		if(Istr[i]=='A')
			posA[++Cta]=i;
	posA[++Cta]=n+1;
	for(int i=1;i<=Cta;i++){
		bool Bb=false;
		for(int j=posA[i-1]+1;j<=posA[i]-1;j++)
			Bb|=Istr[j]=='B';
		Ctb+=Bb;
	}
	Cta--;
	for(int i=1;i<=Cta-1;i++)
		if(posA[i]+1==posA[i+1]-1 && Istr[posA[i]+1]=='C')
			Ctc++;
	int Vmor=Ctc-Ctb;
	Nn=n;n=0;
	for(int i=1;i<=Nn;i++)
		if(Istr[i]=='A')
			if(Vmor>0 && n>=2 && Istr[n]=='C' && Istr[n-1]=='A') Vmor--;
			else Istr[++n]=Istr[i];
		else
			if(Istr[n]!=Istr[i]) Istr[++n]=Istr[i];
	if(Vmor>0) exit(0);
}
void DelC(){
	int Vdel=0;
	for(int i=1;i<=n;i++){
		if(Istr[i]=='C') Vdel++;
		if(Istr[i]=='B') Vdel--;
	}
	//if(Vdel<0) exit(0);
	Nn=n;n=0;Istr[Nn+1]='-';
	for(int i=1;i<=Nn;i++)
		if(Istr[i]=='C')
			if(Vdel && (!n || Istr[n]!=Istr[i+1])) Vdel--;
			else Istr[++n]=Istr[i];
		else Istr[++n]=Istr[i];
	//if(Vdel) exit(0);
}
void DelBC(){
	int Cta=0,Ctb=0,Ctc=0;
	for(int i=1;i<=n;i++){
		if(Istr[i]=='A') Cta++;
		if(Istr[i]=='B') Ctb++;
		if(Istr[i]=='C') Ctc++;
	}
	if(Ctb<Cta) exit(0);
	int Nn=n;n=0;Istr[Nn+1]='-';
	for(int i=1;i<=Nn;i++)
		if(Istr[i]=='A') Istr[++n]=Istr[i];
		else if(Ctb>Cta && n && ((Istr[n]=='B' && Istr[i]=='C') || (Istr[n]=='C' && Istr[i]=='B')) && Istr[i+1]!=Istr[n-1])
			Ctb--,n--;
		else Istr[++n]=Istr[i];
	Istr[n+1]='\0';
}
int main(){
	scanf("%s",Istr+1);
	Nn=strlen(Istr+1);n=0;
	for(int i=1;i<=Nn;i++)
		if(Istr[n]!=Istr[i]){
			Istr[++n]=Istr[i];
			Ncnt[Istr[i]-'A']++;
		} 
	Istr[Nn+1]=0;
	if(Ncnt[0]>Ncnt[1]) fSwap(0,1),Smod.push(make_pair(0,1));
	if(Ncnt[1]>Ncnt[2]) fSwap(1,2),Smod.push(make_pair(1,2));
	if(Ncnt[0]>Ncnt[1]) fSwap(0,1),Smod.push(make_pair(0,1));
	if(!Ncnt[0]) exit(0);
	SurA();DelC();DelBC();
	while(!Smod.empty()){
		fSwap(Smod.top().first,Smod.top().second);
		Smod.pop();
	}
	printf("%s\n",Istr+1);
	return 0;
}

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

using ll = long long int;
using ld=long double;

int main(){
    ll n;
    cin>>n;
    ll s=ceil(sqrt(n));
    ll ans=2e12;
    for(ll i=1;i<=s;i++){
        if(n%i==0){
            ans=min(ans,i+n/i);
        }
    }
    cout<<ans-2;
    return 0;
}


Measured memory_bytes: 256
// ref: https://qiita.com/drken/items/ace3142967c4f01d42e9, 1-2: DP

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> dp(N+1, INT_MAX); dp[0]=0;
    
    for(int n=1; n<=N; ++n){
        for(int pow6=1; pow6<=n; pow6*=6){ dp[n]=min(dp[n], dp[n-pow6]+1); }
        for(int pow9=1; pow9<=n; pow9*=9){ dp[n]=min(dp[n], dp[n-pow9]+1); }
    }
    
    cout << dp[N] << endl;
    
    return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
int max_n = 2001;
signed main()
{
    int S, W;
    cin >> S >> W;
    if (S > W)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "unsafe" << endl;
    }
}

Measured memory_bytes: 3728
#include <iostream>
#include <complex>
#include <vector>
#include <stack>

using namespace std;

template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
}

typedef complex<double> P;
#define X real()
#define Y imag()

double dot(P a, P b){
    return (a * conj(b)).X;
}
double cross(P a, P b){
    return (a * conj(b)).Y;
}

vector<P> points;
deque<P> selected;
int max_count;

void search(int index) {
    if(index > points.size()) return;
    int selected_size = selected.size();

    bool is_all_overlap = true;
    if(selected_size >= 2 && selected_size > max_count) {
        // calc is all overlaps
        vector<P> copied_selected;
        copy(selected.begin(), selected.end(), back_inserter(copied_selected));

        for (int i = 0; i < selected_size ; ++i) {
            for (int j = 0; j < selected_size; ++j) {
                if(i == j) continue;
                // two point check
                double d12 = abs(copied_selected[i] - copied_selected[j]);
                if(d12 > 2.0 + 1e-10) {
                    is_all_overlap = false;
                    break;
                }

                for (int k = 0; k < selected_size; ++k) {
                    if(i == k || j == k) continue;
                    // three point check
                    P p1 = copied_selected[i];
                    P p2 = copied_selected[j];
                    P p3 = copied_selected[k];

                    P center12 = P((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    double allow_distance = 1 + sqrt(1 - ((d12 * d12) / 4));
                    if(abs(center12 - p3)  > allow_distance + 1e-10) {
                        is_all_overlap = false;
                        break;
                    }
                }

            }
            if(!is_all_overlap) {
                break;
            }
        }

        copied_selected.clear();
        copied_selected.shrink_to_fit();
    }

    if (is_all_overlap) {
        // update max count
        if(selected_size > max_count) {
            max_count = selected_size;
        }

        P p = points[index];
        // remove bad situation
        if(selected.empty() || abs(p - selected.front()) <= 2.0 + 1e-10) {
            // take
            selected.push_front(p);
            search(index + 1);
            selected.pop_front();
        }

        // for next dispatch
        // not take
        search(index + 1);
    }
}

int main() {
    int n;
    while (cin >> n) {
        if(n == 0) break;
        points.clear();
        points.shrink_to_fit();
        selected.clear();
        selected.shrink_to_fit();
        max_count = 0;

        // load points
        for (char i = 0; i < n; ++i) {
            double x;
            double y;
            scanf("%lf,%lf", &x, &y);
            P p = P(x, y);
            points.push_back(p);
        }

        search(0);
        cout << max_count << endl;
    }
    return 0;
}

Measured memory_bytes: 3176
A, B, C, D = map(int, input().split())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)


nc = B // C - (A - 1) // C
nd = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
ncd = B // CD - (A - 1) // CD
ans = (B - A + 1) - nc - nd + ncd

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005
ll w[101];
ll v[101];
ll dp[101][N];
ll n,W;
ll dps(ll i,ll j)
{
    if(j<0)
        return -hell;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(i==0)
        return 0;
    dp[i][j]=max(dp[i][j],max(v[i]+dps(i-1,j-w[i]),dps(i-1,j)));
    return dp[i][j];
}
void solve()
{
    cin>>n>>W;
    memset(dp,-1,sizeof(dp));   
    rep(i,1,n+1)
    {
        cin>>w[i]>>v[i];
    }
    cout<<dps(n,W)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 82548
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n-1];
        for(int i=0;i<n;++i) a[i] = sc.nextInt();
        for(int i=0;i<n;++i) b[i] = sc.nextInt();
        for(int i=0;i<n-1;++i) c[i] = sc.nextInt();
        int last = -1;
        long ans = 0;
        for(int i=0;i<n;++i){
            int cur = a[i];
            ans+=b[cur-1];
            if(cur - last == 1) ans+=c[a[i]-2];
            last = cur;
        }
        System.out.print(ans);
    }


}


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

using namespace std;

const int INF=1000000000;
int cnt[100][30];

int main(){
        string s[100];
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
                for(int j=0;j<30;j++){
                        cnt[i][j]=0;
                }
        }
        for(int i=0;i<n;i++){
                cin>>s[i];
                for(int j=0;j<(int)s[i].size();j++){
                        cnt[i][s[i][j]-'a']++;
                }
        }
        int res[30];
        for(int i=0;i<30;i++){
                res[i]=INF;
        }
        for(int i=0;i<n;i++){
                for(int j=0;j<30;j++){
                        res[j]=min(cnt[i][j], res[j]);
                }
        }
        for(int i=0;i<26;i++){
                for(int j=0;j<res[i];j++){
                        cout<<(char)('a'+i);
                }
        }
        cout<<endl;
        return 0;
}


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

int main() {
  string s;
  cin >> s;

  int t0 = 0, t1 = 0;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == '0')
      t0++;
    else
      t1++;
  printf("%d\n", 2 * min(t0, t1));

  return 0;
}

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

int main() {
  int N,K,x;
  x=1;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
      if(2*x < x + K){
          x*=2;
      }else{
          x+=K;
      }
  }
  cout << x << endl;
} 

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

cnt2 = 0
cnt4 = 0

for i in range(n):
    if a[i] % 2 == 0 and a[i] % 4 != 0:
        cnt2 += 1
    elif a[i] % 4 == 0:
        cnt4 += 1

n = n - cnt2
if cnt2 == 0:
    if n-cnt4 <= cnt4+1:
        print("Yes")
    else:
        print("No")
else:
    if n-cnt4 <= cnt4:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14224
def binary_search(ary, key, imin, imax):
    if imax < imin:
        return False
    else:
        imid = imin + (imax - imin) // 2
        if ary[imid] > key:
            return binary_search(ary, key, imin, imid - 1)
        elif ary[imid] < key:
            return binary_search(ary, key, imid + 1, imax)
        else:
            return True

n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

cnt = 0
for i in t:
    if binary_search(s, i, 0, n-1):
        cnt += 1
print(cnt)


Measured memory_bytes: 16708
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto M = RD!long;
	auto Q = RD!long;

	auto table = new long[][](N+1, N+1);
	foreach (i; 0..M)
	{
		auto L = RD!long;
		auto R = RD!long;
		++table[L][R];
	}

	auto dp = new long[][](N+2, N+2);
	foreach_reverse (i; 1..N+1)
	{
		foreach (j; i..N+1)
		{
			dp[i][j] = dp[i][j-1] + dp[i+1][j] - dp[i+1][j-1] + table[i][j];
		}
	}

	string[] ans;
	foreach (i; 0..Q)
	{
		auto p = RD!long;
		auto q = RD!long;
		ans ~= to!string(dp[p][q]);
	}
	foreach (e; ans) writeln(e);

	stdout.flush();
}

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

//#define fin cin
//#define fout cout

#define leftSon (node << 1)
#define rightSon ((node << 1) | 1)

#define pii pair < int , int >
#define F first
#define S second

using namespace std;

typedef long long ll;

const int inf = 0x3f3f3f3f;
const long long infL = LLONG_MAX;

struct psychotronic_induction {
    int electromagnetic_wave = 7;
};

int main()
{
   
    /*
    ifstream fin("input.in");
    ofstream fout("output.out");
    */

    long long n, m;
    scanf("%lld %lld", &n, &m);

    if (m < 2 * n) {
        printf("%lld\n", min(n, m / 2));
        return 0;
    }

    long long ans = 0;
    m -= 2 * n; ans += n;
    ans += m / 4;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 2e6 + 5;

int n, k;
string S;
int num;


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> k >> S;
    num++;
    for (int i = 1; i < n; i++)
        if (S[i] != S[i - 1])
            num++;
    num -= 2 * k;
    if (num < 1)
        num = 1;
    cout << n - num << endl;;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

//int k;
//string s;
signed main(){
	acc_io;
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double C,Ta,Tb;
	Ta=30*(60*h+m);
	Tb=60*6*m;
//	if(Tb>Ta) C=Tb-Ta;
//	else C=Ta-Tb;
	C=abs(Ta-Tb);
	if(C>180*60) C=360*60-C;
	C=C*PI/(60*180);
//	DBG("C",C,0,0);

	double ans;
	ans=sqrt(a*a+b*b-2*a*b*cos(C));
	cout << fixed << setprecision(20) << ans << endl;	
//	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4116
// AOJ 1153 "等しい合計点" (ICPC国内予選 2008 Problem A)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int[] taro = new int[n];
            int[] hanako = new int[m];
            int taroSum = 0;
            int hanakoSum = 0;
            for (int i = 0; i < n; i++) {
                taro[i] = sc.nextInt();
                taroSum += taro[i];
            }
            for (int i = 0; i < m; i++) {
                hanako[i] = sc.nextInt();
                hanakoSum += hanako[i];
            }
            
            // 太郎と花子のカードを1枚ずつ交換することを全通り試す
            int ansTaro = -1;   // 太郎が渡すカードの点数
            int ansHanako = -1; // 花子が渡すカードの点数
            int sum = 999;      // 渡すカードの点数の合計(初期値は適当に大きい数)
            boolean isChanged = false; // 交換したかどうか
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    taroSum = taroSum - taro[i] + hanako[j];
                    hanakoSum = hanakoSum - hanako[j] + taro[i];
                    if (taroSum == hanakoSum) {
                        if (taro[i] + hanako[j] < sum) {
                            ansTaro = taro[i];
                            ansHanako = hanako[j];
                            sum = taro[i] + hanako[j];
                        }
                        isChanged = true;
                    }
                    taroSum = taroSum - hanako[j] + taro[i];
                    hanakoSum = hanakoSum - taro[i] + hanako[j];
                }
            }
            
            if (isChanged) {
                System.out.println(ansTaro + " " + ansHanako);
            } else {
                System.out.println(-1);
            }
        }
    }
}

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

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

    if (S.front() != 'A') {
        cout << "WA";
        // cout << "1st";
        return 0;
    }

    int c_count = 0;
    for (int i=1; i<S.size(); i++) {
        if (i <= 1 || S.size()-1 <= i) {
            if (isupper(S[i])) {
                cout << "WA";
                // cout << "2nd" << i << " " << S[i];
                return 0;
            }
        }
        if (S[i] == 'C') {
            c_count++;
            continue;
        }
        if (isupper(S[i])) {
            cout << "WA";
            // cout << "3rd";
            return 0;
        }
    }
    if (c_count != 1) {
        cout << "WA";
        // cout << "4th";
        return 0;
    }

    cout << "AC";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
const int MAX_V = 10010;
const int INF = 1e9;
typedef pair<int, int> P;

struct edge{
    int u, v, d, c;
    bool operator<(const edge &e)const{
        return c < e.c;
    }
};

struct edge2{
    int to, dist, cost, id;
};

int n, m, ans;
vector<edge> es;
vector<edge2> G[MAX_V]; 
int d[MAX_V];
bool used[MAX_V];
int MINcost[MAX_V];

void dijkstra(int s){
    fill(d, d + MAX_V, INF);
    fill(MINcost, MINcost + MAX_V, INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push({0, s});
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        int dist = p.first;
        rep(i, 0, G[from].size()){
            edge2 e = G[from][i];
            int newDist = dist + e.dist;
            int nxt = e.to;
            if(d[nxt] > newDist){
                d[nxt] = newDist;
                MINcost[nxt] = e.cost;
                q.push({newDist, nxt});
            }else if(d[nxt] == newDist){
                MINcost[nxt] = min(MINcost[nxt], e.cost);
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        es.clear();
        es.resize(m);
        ans = 0;
        rep(i, 0, n) G[i].clear();
        rep(i, 0, m){
            cin >> es[i].u >> es[i].v >> es[i].d >> es[i].c;
            es[i].u--; es[i].v--;
            G[es[i].u].push_back({es[i].v, es[i].d, es[i].c});
            G[es[i].v].push_back({es[i].u, es[i].d, es[i].c});
        }
        sort(es.begin(), es.end());
        dijkstra(0);
        rep(i, 1, n){
            ans += MINcost[i];
        }
        cout << ans << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int>B(N-1);
  for(int i=0; i<N-1; i++)cin >> B.at(i);
  
  int ans =0;
  for(int i=0; i<N-2; i++)ans += min(B.at(i), B.at(i+1));
  ans += B.at(N-2) + B.at(0);
  
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v<=w) return puts("NO"),0;
    puts((v-w)*t>=abs(a-b)?"YES":"NO");
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#define rep(i,n) for(int i = 0; i < (int)n; i++)

using namespace std;
int main(){
    int A,B;
    cin >> A >> B;

    int a1 = A + B;
    int a2 = A - B;
    int a3 = A * B;

    int ans = max(a1,a2);
    ans = max(ans,a3);

    cout << ans << endl;

}

Measured memory_bytes: 256