akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,A,C;
  cin >> N;
  C=0;
  
  for (int i=0;i<N;i++) {
    cin >> A;
    if ((A % 2 == 1) && (i % 2 == 0)){
      C++;
    }
  }
  cout << C << endl;
}


Measured memory_bytes: 3628
def inpl(): return list(map(int, input().split()))


N = int(input())
data = [[0, 0] for _ in range(N)]
wa = [[0, 0] for _ in range(N)]
for i in range(N):
    a, b = inpl()
    data[i][0] = a
    data[i][1] = b
    wa[i][0] = a+b
    wa[i][1] = i

wa.sort(reverse=True)

ans = 0
turn = "a"
for a, i in wa:
    if turn=="a":
        turn="b"
        ans += data[i][0]
    else:
        turn="a"
        ans -= data[i][1]
print(ans)


Measured memory_bytes: 36656
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NMAX 100004
const int INF = 0x3f3f3f3f;
int height[NMAX]={0};
int sol[NMAX];
int n;

int min(int a,int b){
  return a<b ? a : b ;
}
int solve (int i){
  if (i==n) {
      return 0;
    }
  if(i>n)
      return INF;
  if (sol[i]!=-1) {
      return sol[i];
    }
  int some1=abs(height[i]-height[i+1])+solve(i+1);
  int some2=abs(height[i]-height[i+2])+solve(i+2);
    return sol[i]=min(some1,some2);
}
int main() {
for (int i = 0; i < NMAX; i++) {
    sol[i]=-1;
  }
  scanf("%d",&n);
for (int i = 1; i <=n; i++) {
  scanf("%d",&height[i]);
}
printf("%d",solve(1));
return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
typedef long long ll;
ll dp[100][2];

int main()
{
	int n,p;
	scanf("%d%d",&n,&p);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d",&x);
		if (x&1)
		{
			dp[i][1] = dp[i-1][1] + dp[i-1][0];
			dp[i][0] = dp[i-1][1] + dp[i-1][0];
		}
		else//EVEN
		{
			dp[i][1] = dp[i-1][1] + dp[i-1][1];
			dp[i][0] = dp[i-1][0] + dp[i-1][0];
		}
	}

	printf("%lld\n",dp[n][p]);
}

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

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    ll a=0,b=0,x=0;
    vector<ll> A(N);
    rep(i,N){A[i]=i+1;}
    do{
        int f=1;
        rep(i,N){
            if(A[i]!=P[i]){
                f=0;
                break;
            }
        }
        if(f){a=x;break;}
        x++;
    }while(next_permutation(A.begin(),A.end()));
    x=0;
    rep(i,N){A[i]=i+1;}
    do{
        int f=1;
        rep(i,N){
            if(A[i]!=Q[i]){
                f=0;
                break;
            }
        }
        if(f){b=x;break;}
        x++;
    }while(next_permutation(A.begin(),A.end()));
    cout<<abs(a-b)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
      cout << fixed << setprecision(6);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


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

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

int main(void) {

	string s;
	cin >> s;

	lli K;
	cin >> K;

	for (lli i = 0; i < s.size(); i++) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			break;
		}
		else if (i == K - 1) {
			cout << 1 << endl;
			break;
		}
	}



	return 0;
}

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

int main()
{
    int a,b,k,com;
    vector<int> c;
    cin >> a >> b >> k;

    if (a > b)
    {
        com = b;
    }
    else
    {
        com = a;
    }
    for (int i = 1; i <= com; i++)
    {
        if (a % i == 0 && b % i == 0)
        {
            c.push_back(i);
        }
    }
    cout << c[c.size() - k] << endl;
}   

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, k, x[50], y[50];
    long long ans = 4e18;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int xmn = min(x[i], x[j]);
            int xmx = max(x[i], x[j]);
            int ymn = min(y[i], y[j]);
            int ymx = max(y[i], y[j]);
            int zs;
            long long X = xmx - xmn;
            long long Y = ymx - ymn;
            if(k == 2){
                ans = min(ans, X*Y);
                continue;
            }
            vector<int> z;
            for(int l=0;l<n;l++){
                if(l != i && l != j && x[l] >= xmn && x[l] <= xmx){
                    z.push_back(y[l]);
                }
            }
            zs = z.size();
            if(zs + 2 < k) continue;
            sort(z.begin(), z.end());
            for(int l=0;l<zs-k+3;l++){
                Y = max(ymx, z[l+k-3]) - min(ymn, z[l]);
                ans = min(ans, X*Y);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main()
{
    string S , T;
    int A , B;
    string U;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(U==S)
    {
        A = A - 1;
        cout<<A<<" "<<B<<endl;
    }
    else if(U==T)
    {
        B = B - 1;
        cout<<A<<" "<<B<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    int n,xr=0,ans=0,i;set<int>avb;cin>>n;int a[n];
    for(i=0;i<n;i++)cin>>a[i],xr^=a[i],avb.insert(a[i]^(a[i]-1));
    for(i=29;i>=0;i--){
        if((xr>>i)&1){
            if(avb.count((1<<i+1)-1))xr^=(1<<i+1)-1,ans++;
            else return puts("-1")*0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
vector<ll> c;
vector<ll> paths[201000];

ll SIZE[201000];
vector<ll> a[200100];
map<ll, vector<ll>> mp[200100];
ll p[200100];
ll p2[200100];
ll pc[200100];
ll subsize[200100];
ll TotalSize[200100];
ll ans[200100];

void dfs(int now, int from) {
    p2[now] = from;
    SIZE[now] = 1;
    p[now] = pc[c[now]];
    for(auto to : paths[now]) {
        if(to == from) continue;
        int tmp = pc[c[now]];
        pc[c[now]] = to;
        dfs(to, now);
        SIZE[now] += SIZE[to];
        pc[c[now]] = tmp;
    }
}

int main() {
    cin >> N;
    c.resize(N+1);
    for(int i = 1; i <= N; i++) cin >> c[i];
    for(int i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    for(int i = 1; i <= N; i++) {
        pc[i] = -1;
    }
    dfs(1, -1);
    /*
    for(int i = 1; i <= N; i++) {
        a[i].push_back(-N-1);
    }
    */
   /*
    for(int i = 1; i <= N; i++) {
        cerr << i << " " << p[i] << endl;
    }
    for(int i = 1; i <= N; i++) {
        solve(i);
    }
    */
    for(int i = 1; i <= N; i++) {
        ans[i] = N * (N - 1) / 2;
        ans[i] += N;
        subsize[i] = SIZE[i];
    }
    for(int i = 1; i <= N; i++) {
        if(p[i] != -1) {
            subsize[p[i]] -= SIZE[i];
        }
        TotalSize[i] = N;
    }
    for(int i = 1; i <= N; i++) {
        if(p2[i] != -1) {
            //cerr << i << " " << p2[i] << " " << c[p2[i]] << " " << subsize[i] << endl;
            ans[c[p2[i]]] -= subsize[i] * (subsize[i]+1) / 2;
        }
        // else {
        //    TotalSize[c[i]] -= SIZE[i];
        //}
        if(p[i] == -1) {
            TotalSize[c[i]] -= SIZE[i];
        }
    }
    //cerr << endl;
    for(int i = 1; i <= N; i++) {
        ans[i] -= TotalSize[i] * (TotalSize[i] + 1) / 2;
        //cout << TotalSize[i] << " " << ans[i] << endl;
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 59424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
int main() {
  string s,t; cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 10000;
  loop(i,0,n-m+1) {
    int cnt = 0;
    loop(j,0,m) {
      cnt += s[j+i] != t[j];
    }

    chmin(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
int main(void){
    char s[100+5];
    scanf("%s", s);
    int n=strlen(s);
    
    char target[]="keyence";
    
    if(strcmp(s, target)==0){
        printf("YES\n");
        return 0;
    }
    
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            // s[i~j]を消す
            char str[100+5]={};
            int p=0;
            for(int k=0; k<n; k++){
                if(!(i<=k && k<=j)){
                    str[p]=s[k];
                    p++;
                }
            }
            // printf("%s\n", str);
            if(strcmp(str, target)==0){
                printf("YES\n");
                return 0;
            }
        }
    }
    printf("NO\n");
}


Measured memory_bytes: 1632
using System;
using System.Collections.Generic;

class MyClass
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);
        int count = 0;
        for (int i = a; i <= b; i++)
        {
            if (c % i == 0)
            {
                count++;   
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 19884
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
using namespace std;
int dp[3005][3005];
int main() {
    int n , t;
    cin >> n >> t;
    vector<pair<int , int> > dishes(n);
    for(auto & x : dishes)
        cin >> x.x >> x.y;
    sort(dishes.begin() , dishes.end());
    for(int i = 0; i < n; i++)
        for(int j = 0; j < t; j++)
        {
            dp[i + 1][j] = max(dp[i + 1][j] , dp[i][j]);
            dp[i][j + 1] = max(dp[i][j + 1] , dp[i][j]);
            dp[i + 1][min(t , j + dishes[i].x)] = max(dp[i + 1][min(t , j + dishes[i].x)] , dp[i][j] + dishes[i].y);
        }
    int ans = 0;
    for(int i = 0; i <= n; i++)ans = max(ans, dp[i][t]);
    for(int i = 0; i <= t; i++)ans = max(ans , dp[n][i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define LL long long

namespace io {
    template <typename T> inline void read(T & _x) {
        int f = 0, ch; _x = 0;
        while(!isdigit(ch = getchar())) f |= ch == '-';
        while(isdigit(ch)) _x = _x * 10 + ch - '0', ch = getchar();
        if(f) _x = -_x;
    }
    template <typename T, typename ... Args> inline void read(T &_f, Args& ... args) {
        read(_f), read(args ...);
    }
    inline void _deal(char ch) { putchar(ch); }
    template <typename T> inline void _deal(T _x) {
        if (_x < 0) putchar('-'), _x = -_x;
        if (_x > 9) _deal(_x / 10);
        putchar(_x % 10 + '0');
    }
    inline void write() {}
    template <typename T, typename ... Args> inline void write(T _f, Args ... args) {
        _deal(_f), write(args...);
    }
}

int main() {
	LL a, b, v, w, t;
	io::read(a, v, b, w, t);
	LL dis = std::abs(a - b);
	LL vel = v - w;
	if(vel * t >= dis)
		puts("YES");
	else
		puts("NO");
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
ll n,k,a[N];
class CS{
private:
    ll cs[N],s;
public:
    void init(){
	cs[0]=0,s=0;
    }
    void add(ll x){
	cs[s+1]=cs[s]+x;
	s++;
    }
    ll sum(ll l,ll r){
	if(l>r)return 0;
	return cs[r+1]-cs[l];
    }
};
ll Solve(){
    CS L,R;L.init();R.init();
    lol(i,n)L.add(a[i]);
    lol(i,n)R.add(k-a[i]);
    ll ans=0;
    lol(i,n){
	ll ls=i,rs=n-1-i;
	ll siz=min(ls,rs);
	ll sit=siz;
	if(rs>siz)sit=siz+1;
	//if(siz==0)continue;
	ll res=L.sum(i,i);
	res+=2*L.sum(i-siz,i-1);
	res+=2*R.sum(i+1,i+sit);
	ans=max(ans,res);
	//cout<<res<<endl;
    }
    //cout<<"-----"<<endl;
    return ans;
}
int main(){
    cin>>k>>n;
    lol(i,n)cin>>a[i];
    ll ans=Solve();
    lol(i,n)a[i]=k-a[i];
    sort(a,a+n);
    ans=max(ans,Solve());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
while True:
    s = input()
    if s == '.':
        break

    ans = True
    stack = []
    for i in s:
        if i == '[' or i == '(':
            tmp = 1
            if i == '[':
                tmp = -1
            if not len(stack) or stack[-1] * tmp < 0:
                stack.append(tmp)
            else:
                stack[-1] += tmp

        if i == ']' or i == ')':
            tmp = 1
            if i == ']':
                tmp = -1
            if not len(stack) or stack[-1] * tmp < 0:
                ans = False
                break
            else:
                stack[-1] -= tmp
                if not stack[-1]:
                    stack = stack[0:-1]

    if len(stack):
        ans = False

    print('yes' if ans else 'no')



Measured memory_bytes: 5580
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (a % 2 == b % 2)
		cout << (b - a) / 2;
	else
		cout << min(a, n - b + 1) + (b - a) / 2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,pair<int,int>> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
vector<int> G[5010];
int in[5010],out[5010];
int main(){
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        G[a].push_back(b);
        in[b]++;
        out[a]++;
    }
    stack<int> st;
    int ic=0,oc=0;
    for(int i=0;i<n;i++){
        if(in[i]==0){
            ic++;
            st.push(i);
        }
        if(out[i]==0){
            oc++;
        }
    }
    vector<int> ans;
    while(!st.empty()){
        int a=st.top();st.pop();
        ans.push_back(a);
        for(auto b:G[a]){
            in[b]--;
            if(in[b]==0){
                st.push(b);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]+1<<endl;
    }
    if(ic>1||oc>1){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }

}



Measured memory_bytes: 3764
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(D: int):
    if D == 25:
        print("Christmas")
    else:
        print("Christmas", " ".join(["Eve"]*(25-D)))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    solve(D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "", t = "";
    cin >> s >> t;
    string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    for (int i=0; i<s.size()-t.size()+1; i++) {
        bool flag = true;
        for (int j=0; j<t.size(); j++) {
            if (s.at(i+j) == '?') {
                continue;
            }
            if (s.at(i+j) != t.at(j)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            string buf = s;
            for (int j=0; j<t.size(); j++) {
                buf.at(i+j) = t.at(j);
            }
            for (int j=0; j<s.size(); j++) {
                if (buf.at(j) == '?') {
                    buf.at(j) = 'a';
                }
            }
            if (buf < ans) {
                ans = buf;
            }
        }
    }
    if (ans == "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int dp[110][12000];

int main()
{
    int N,W; cin >> N >> W;
    int v[N],w[N];
    rep(i,N) cin >> v[i] >> w[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            dp[i+1][j] = dp[i][j];
            if(j-w[i] >= 0) dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7392
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m, x, y, val;
    cin >> n >> m >> x >> y;
    vector<int> a = {x};
    vector<int> b = {y};
    for(int i = 0; i < n; i++) {
        cin >> val;
        a.push_back(val);
    }
    for(int i = 0; i < m; i++) {
        cin >> val;
        b.push_back(val);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a.back() < b[0])
        cout << "No War" << endl;
    else
        cout << "War" << endl;
    return 0;
}



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

int main(void)
{
	int N, M, Q;
	int map[504][504];
	int i, j;
	int l, r;
	int p, q;
	int loop;

	scanf("%d %d %d", &N, &M, &Q);

	memset(map, 0, sizeof(map));

	for(i=0; i<M; i++){
		scanf("%d %d", &l, &r);
		map[l][r]++;
	}

	loop = 1;
	for(i=1; i<=N; i++){
		for(j=loop; j>0; j--){
			map[j][i] += (map[j][i-1] + map[j+1][i] - map[j+1][i-1]);
		}
		loop++;
	}

	for(i=0; i<Q; i++){
		scanf("%d %d", &p, &q);
		printf("%d\n", map[p][q]);
	}

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int n,d,x;
  int i,j;
  int a[120];
  int ans = 0;
  scanf("%d",&n);
  scanf("%d",&d);
  scanf("%d",&x);
  ans += x;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){

    for(j=1;j<=d;j+=a[i]){
      ans+=1;
    }


  }

  printf("%d",ans);

  return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<long long> A;
    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;
        A.push(a);
    }
    
    for(int i = 0; i < M; i++){
        long long K = A.top();
        if(K == 0)break;
        A.pop();
        K /= 2;
        A.push(K);
    }
    
    long long sum = 0;
    for(int i = 0; i < N; i++){
        sum += A.top();
        A.pop();
    }
    
    cout << sum << endl;
}

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

typedef long long ll;
using namespace std;

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

    if (s[0] != s[1] && s[0] != s[2] && s[1] != s[2]) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
d = na()
m = ni()
t = na()

dic = defaultdict(int)
for i in range(n):
    dic[d[i]] += 1

flag = True
for i in range(m):
    if dic[t[i]] == 0:
        flag = False
    dic[t[i]] -= 1

print("YES" if flag else "NO")

Measured memory_bytes: 41952
s=input().split()
n=int(s[0]);m=int(s[1]);c=int(s[2])
b=input().split();a=[];ans=0
for i in range(n) : a.append(input().split())
for i in range(n) :
  temp=0
  for j in range(m) : temp+=int(a[i][j])*int(b[j])
  if temp+c>0 : ans+=1
print(ans)

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

int main() {
    int N,T,A;
    int H[100000];
    double av[10000];
    double Aav[10000];
    double minA=1000000000000;
    int ans;
    cin >>N>>T>>A;
    for(int i=0;i<N;i++){
        cin >>H[i];
        av[i]=T-(H[i]*0.006);
        Aav[i]=A-av[i];
        if(A-av[i]<0){
            Aav[i]*=-1;
        }
        if(minA>Aav[i]){
            minA=Aav[i];
            ans=i+1;
        }
    }
    
    cout<<ans;
    return 0;
}


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

#define fir first
#define sec second

using namespace std;

const int MAX_C = 31;
const int MAX_T = (1<<9);
const int INF = (1<<25);
typedef pair<short,short> P;
typedef pair<double,P> PP;
// PP(time, usedTicket, nodeName)

double node[MAX_T][MAX_C];
int n,m,p,a,b;
vector<P> V[MAX_C];
vector<int> Tic;


void solve(int from, int to){
  priority_queue<PP, vector<PP>, greater<PP> > Q;

  node[0][from] = 0;

  Q.push(PP(0,P(0,from)));

  while(!Q.empty()){
    PP pp = Q.top(); Q.pop();

    if(node[pp.sec.fir][pp.sec.sec] < pp.fir) continue;

    for(int i = 0; i < V[pp.sec.sec].size(); i++){
      P next = V[pp.sec.sec][i];
      for(int j = 0; j < Tic.size(); j++){
	if((pp.sec.fir&(1<<j)) == 0){
	  int now = pp.sec.fir+(1<<j);
	  double spend =  pp.fir+(double)next.sec/Tic[j];

	  if(node[now][next.fir] > spend){
	    node[now][next.fir] = spend;
	    Q.push(PP(spend,P(now,next.fir)));
	  }
	}
      }
    }
  }

  double ans = INF;
  for(int i = 0; i <= (1<<n); i++)
    ans = min(ans,node[i][to]);

  if(ans == INF) cout << "Impossible" << endl;
  else printf("%.3f\n",ans);
}

void init(){
  for(int i = 0; i < MAX_T; i++)
    for(int j = 0; j < MAX_C; j++)
      node[i][j] = (double)INF;

  for(int i = 0; i < MAX_C; i++)
    V[i].clear();

  Tic.clear();

}

int main(){
  while(cin >> n >> m >> p >> a >> b && n+m+p+a+b){
    init();
    

    for(int i = 0; i < n; i++){
      int t;
      cin >> t;
      Tic.push_back(t);
    }

    for(int i = 0; i < p; i++){
      int f,t,c;
      cin >> f >> t >> c;
      V[f].push_back(P(t,c));
      V[t].push_back(P(f,c));
    }
    solve(a,b);
  }
  return 0;
}

Measured memory_bytes: 2840
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
            cin >> s[i];
    }
    int ret = -1;
    for (int i = 0; i < n; ++i) {
        vi gr(n, -1);
        int st  = i;
        gr[st]  = 1;
        bool ok = true;
        queue<int> q;
        q.push(st);
        while (!q.empty()) {
            int c = q.front();
            q.pop();
            for (int j = 0; j < n; ++j) {
                if (s[c][j] == '0')
                    continue;
                if (gr[j] == -1) {
                    q.push(j);
                    gr[j] = gr[c] + 1;
                } else if (gr[j] != gr[c] - 1 && gr[j] != gr[c] + 1) {
                    ok = false;
                    break;
                }
            }
            if (!ok)
                break;
        }
        if (ok) {
            for (int j = 0; j < n; ++j) {
                chmax(ret, gr[j]);
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

a, b = na()

if b < a:
    print(a - 1)
else:
    print(a)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
using namespace std;
int main(){
	map<string, int>m;
	int q;
	cin>>q;
	while(q--){
		int c;
		string k;
		cin>>c>>k;
		if(c==0){
			int x;
			cin>>x;
			m[k]=x;
		}
		else if(c==1){
			if(m.find(k)==m.end())
				cout<<0<<endl;
			else
				cout<<m[k]<<endl;
		}
		else if(c==2){
			m.erase(k);
		}
		else if(c==3){
			string y;
			cin>>y;
			map<string, int>::iterator i;
			for(i=m.lower_bound(k); i!=m.upper_bound(y); i++)
				cout<<(*i).first<<" "<<(*i).second<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 27828
import java.util.*;
 
public class Main {
    public static void main(String args[]){
         Scanner sc = new Scanner(System.in);          
         int a = sc.nextInt();
	 int b = sc.nextInt();
         if(a<b){
	 System.out.println("a < b");
	 }else if(a>b){
	 System.out.println("a > b");
	 }else{
	 System.out.println("a == b");
	 }
	}
}


Measured memory_bytes: 26236
#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

string find(int n,string s){
    string res=s.substr(0,n);
    for (int i=1;i+n-1<2*n;++i){
        string comp=s.substr(i,n);
        if (comp<res) res=comp;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; string S; cin >> N >> K >> S;
    string T=S; reverse(T.begin(),T.end());
    string U=S+T;
    if (K==1){
        cout << find(N,U) << '\n';
        return 0;
    }
    reverse(U.begin(),U.end());
    string V=find(N,U);
    int cnt=1;
    for (int i=0;i+1<N;++i,++cnt){
        if (V[i]!=V[i+1]) break;
    }
    deque<char> deq;
    char c=V[0];
    for (int i=0;i<N;++i) deq.emplace_back(V[i]);
    while(--K&&cnt<N){
        for (int i=0;i<cnt;++i){
            deq.pop_back();
            deq.emplace_front(c);
        }
        cnt<<=1;
    }
    for (int i=0;i<N;++i){
        cout << deq.front();
        deq.pop_front();
    }
    cout << '\n';
}

Measured memory_bytes: 3692
n=int(input())
t=input().split()
v=[]
for i in range(n):
    v.append(int(t[i]))

count=0

for i in range(n-1):
    if i == 0:
        count=0
    elif v[i-1] < v[i] < v[i+1] or v[i-1] > v[i] > v[i+1]:
        count=count+1

print(count)

Measured memory_bytes: 3064
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
const long double precision=1e-11;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	long double a,b,c;
	cin>>a>>b>>c;
	long double d=2.000000*sqrt(a*b);
	c-=a;
	c-=b;
	if(c-d>=precision)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main()
{
    int N, cnt = 0;
    string S;

    cin >> N >> S;

    for (int i = 0; i < N - 2; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
            cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

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;
}

int main() {
    string s,t;
    cin >> s >> t;
    cout << t+s << endl;
    return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

long long A, B, C;

int main() {

  cin>>A>>B>>C;
  long long sa=A, sb=B, sc=C;
  long long cnt = 0;
  while(1){
    //cout<<sa<<" "<<sb<<" "<<sc<<endl;
    if(sa==A&&sb==B&&sc==C&&cnt!=0){
      cout<<-1<<endl;
      break;
    }
    if(sa%2==1||sb%2==1||sc%2==1){
      cout<<cnt<<endl;
      break;
    }
    long long ta = sa, tb = sb, tc = sc;
    sa = (tb+tc)/2; sb = (ta+tc)/2; sc = (ta+tb)/2;
    cnt++;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

long long pow_mod(long long a, long long b){
	if(a == 0)
		return 0ll;
	if(b == 0)
		return 1ll;
	if(b == 1)
		return a%MOD;
	long long x = pow_mod(a,b/2);
	x = (x*x)%MOD;
	if(b%2==1)
		return (x*a)%MOD;
	return x;
}

long long ncr(int n, int r, vector<long long>& fact){
	if(n>=0 && r>=0 && n>=r){
		long long ans=(fact[n-r]*fact[r])%MOD;
		return (fact[n]*pow_mod(ans,MOD-2))%MOD;
	}
	return 0ll;
}

long long get_f(int m, int n, vector<long long>& fact, int k){
	long long ans=MOD;
	ans+=(ncr(m-1,k+1,fact)-ncr(n-m,k+1,fact)+MOD);
	return ans%MOD;
}

void solve(){
	int n,k;
	cin>>n>>k;
	vector<long long> a(n,0ll),fact(n+100,1ll);
	for(int i=1;i<fact.size();i++)
		fact[i]=(fact[i-1]*i)%MOD;

	// cout<<ncr(4,2,fact)<<" " << ncr(4,1,fact)<<" " <<ncr(4,0,fact)<<"\n";

	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(full(a));
	if(k==1){
		cout<<0<<"\n";
		return;
	}

	long long ans=0ll;
	for(int i=0;i<n;i++)
		ans+=(((a[i]+MOD)%MOD)*get_f(i+1,n,fact,k-2))%MOD;
	ans%=MOD;
	cout<<ans<<"\n";
}

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

Measured memory_bytes: 1792
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int k = sc.nextInt();
			if (n == 0 && m == 0 && k == 0)
				break;
			int[] dice = new int[n];
			int[] result = new int[n * m + 1];
			java.util.Arrays.fill(dice, 1);
			out: while (true) {
				int pointer = n - 1;
				result[Math.max(1, sum(dice) - k)]++;
				if (dice[pointer] < m) {
					dice[pointer]++;
					continue;
				}
				while (dice[pointer] == m) {
					pointer--;
					if (pointer < 0)
						break out;
				}
				dice[pointer]++;
				while (pointer != n - 1) {
					pointer++;
					dice[pointer] = 1;
				}
			}
			double p = 0;
			for (int i = 0; i < result.length; i++) {
				p += (double) i * result[i] / Math.pow(m, n);
			}
			System.out.println(p);
		}
		sc.close();
	}

	static int sum(int[] dice) {
		int sum = 0;
		for (int i = 0; i < dice.length; i++)
			sum += dice[i];
		return sum;
	}
}

Measured memory_bytes: 21408
from math import sqrt
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, int(sqrt(n))+1):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
m=int(input())
s=0
for i in range(m):
    l=int(input())
    if isPrime(l)==True:
        s+=1
print(s)



Measured memory_bytes: 5680
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,P>;
struct UnionFind {
  vector<int> parent,s;
  UnionFind(int n): parent(n), s(n){
    rep(i,n) {
      parent[i] = i;
      s[i] = 1;
    }
  }
  int root(int x) { return parent[x]==x ? x : parent[x] = root(parent[x]); }
  bool same(int x, int y) { return root(x)==root(y); }
  int size(int x){ return s[root(x)]; }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (s[x] < s[y]) {
      parent[x] = y;
      s[y] += s[x];
    } else {
      parent[y] = x;
      s[x] += s[y];
    }   
  }
};

int main() {
  int n;
  cin >> n;
  vector<P> xi,yi;
  rep(i,n){
    int x,y;
    cin >> x >> y;
    xi.emplace_back(x,i);
    yi.emplace_back(y,i);
  }
  sort(xi.begin(),xi.end());
  sort(yi.begin(),yi.end());
  vector<PP> d;
  rep(i,n-1) d.emplace_back(xi[i+1].first-xi[i].first,P(xi[i+1].second,xi[i].second));
  rep(i,n-1) d.emplace_back(yi[i+1].first-yi[i].first,P(yi[i+1].second,yi[i].second));
  sort(d.begin(),d.end());

  int ans = 0;
  UnionFind u(n);
  rep(i,d.size()){
    P p = d[i].second;
    if(u.same(p.first,p.second)) continue;
    u.unite(p.first,p.second);
    ans += d[i].first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7144
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		if (a + b >= 10) {
			System.out.println("error");
		} else {
			System.out.println(a + b);
		}

	}
}

Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
using namespace std;
 
#define C 3001
 
int main() {
    int w[C], s[C];
    memset(w, 0, sizeof(w));
    memset(s, 0, sizeof(s));
    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;
    w[0] = 1, s[0] = 1;
    for (int i=0; i<C; i++) {
        if (w[i]) {
            if (i + 100 * a < C) w[i + 100 * a] = 1;
            if (i + 100 * b < C) w[i + 100 * b] = 1;
        }
        if (s[i]) {
            if (i + c < C) s[i + c] = 1;
            if (i + d < C) s[i + d] = 1;
        }
    }
    int ms = 0, mw = 100*a;
    for (int i=1; i<f; i++) {
        for (int j=(100*i+e-1)/e; i+j<=f; j++) {
            if (s[i] && w[j] && i * mw > j * ms) ms = i, mw = j;
        }
    }
    cout<<ms + mw<<" "<<ms<<endl;
}

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

using namespace std;

int main() {
    int tmp = 0, n;
    string s;
    cin >> s;
    n = s.length();
    vector<int> ans(n + 1, 0), rl;

    for (int i = 0, j = 0; i < n;) {
        j = i;
        while (s[i] == s[j]) i++;
        rl.push_back(i - j);
    }

    for (int i = 0; i < rl.size(); i++) {
        if (i % 2 == 0) {
            tmp += rl[i];
            if (rl[i] % 2 == 0) {
                ans[tmp] += rl[i] / 2;
                ans[tmp+1] += rl[i] / 2;
            } else {
                ans[tmp] += rl[i] / 2 + 1;
                ans[tmp+1] += rl[i] / 2;
            }
        } else {
            if (rl[i] % 2 == 0) {
                ans[tmp] += rl[i] / 2;
                ans[tmp+1] += rl[i] / 2;
            } else {
                ans[tmp] += rl[i] / 2;
                ans[tmp+1] += rl[i] / 2 + 1;
            }
            tmp += rl[i];
        }
    }
/* for debug
    for (int i = 0; i < rl.size(); i++) {
        cout << rl[i] << " ";
    }
    cout << endl;
*/
    for (int i = 1; i <= n; i++) {
      	if (i == n) cout << ans[i] << endl;
        else cout << ans[i] << " ";
    }
}

Measured memory_bytes: 1528
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b,c,d,k = imap()

ans = (c-a)*60 + (d-b) - k
print(ans)


Measured memory_bytes: 37760
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
A, B, H, M = ri_()
kaku = 6 * M - (30 * H + 30 * M / 60)
print(sqrt(A ** 2 + B ** 2 - 2 * A * B * cos(math.radians(kaku))))

Measured memory_bytes: 11020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll n_): num((n_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint pow(const modint x, ll r) {
        return x^r;
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) {
            int size = factorial.size();
            factorial.resize(n+1);
            for (int i = size; i <= n; i++) {
                factorial[i] = fact(i-1) * modint(i);
            }
        }
        return factorial[n];
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial = {1};
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    modint score = 0;
    rep(i,n){
        score += (C(i, k-1) - C(n-i-1, k-1)) * modint(a[i]);
    }
    cout << score << endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXH = 1.1e3;
const int MAXW = 1.1e3;
int H, W;
char A[110][110];

struct Dinic {
	struct Edge {
		int to, rev;
		ll c, f;
	};
	vi lvl, ptr, q;
	vector<vector<Edge>> adj;
	Dinic(int n) : lvl(n), ptr(n), q(n), adj(n) {}
	void addEdge(int a, int b, ll c, int rcap = 0) {
		adj[a].push_back({b, sz(adj[b]), c, 0});
		adj[b].push_back({a, sz(adj[a]) - 1, rcap, 0});
	}
	ll dfs(int v, int t, ll f) {
		if (v == t || !f) return f;
		for (int& i = ptr[v]; i < sz(adj[v]); i++) {
			Edge& e = adj[v][i];
			if (lvl[e.to] == lvl[v] + 1)
				if (ll p = dfs(e.to, t, min(f, e.c - e.f))) {
					e.f += p, adj[e.to][e.rev].f -= p;
					return p;
				}
		}
		return 0;
	}
	ll calc(int s, int t) {
		ll flow = 0; q[0] = s;
		rep(L,0,31) do { // 'int L=30' maybe faster for random data
			lvl = ptr = vi(sz(q));
			int qi = 0, qe = lvl[s] = 1;
			while (qi < qe && !lvl[t]) {
				int v = q[qi++];
				trav(e, adj[v])
					if (!lvl[e.to] && (e.c - e.f) >> (30 - L))
						q[qe++] = e.to, lvl[e.to] = lvl[v] + 1;
			}
			while (ll p = dfs(s, t, LLONG_MAX)) flow += p;
		} while (lvl[t]);
		return flow;
	}
};

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> A[i];
	Dinic mf(H + W + 2);
	const ll INF = 1e9;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] == 'S') {
				mf.addEdge(H + W, i, INF);
				mf.addEdge(H + W, H + j, INF);
			} else if (A[i][j] == 'T') {
				mf.addEdge(i, H + W + 1, INF);
				mf.addEdge(H + j, H + W + 1, INF);
			} else if (A[i][j] == 'o') {
				mf.addEdge(i, H + j, 1, 1);
			} else if (A[i][j] == '.') {
			} else assert(false);
		}
	}
	ll ans = mf.calc(H + W, H + W + 1);
	if (ans >= INF) {
		cout << -1 << '\n';
	} else {
		cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>                          
using namespace std;
int a,b,ans,c,x;
int main(){
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
    	if(i%10==0) continue;
    	x=i;
    	c=0;
    	while(x!=0)
    	{
    		c=c*10+x%10;
    		x/=10;
		}
		if(c==i) ans++;
	}
	cout<<ans;
	return 0;
}
//68871358
//76140264
//25446011
//200841159

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123;
int n, m[2], used[2][N], comp[N], num, ans[N], cnt[N];
vector <int> g[2][N], vec;

void dfs(int v) {
	used[0][v] = 1;
	comp[v] = num;
	for (int to : g[0][v]) {
		if (used[0][to]) continue;
		dfs(to);
	}
}

void go(int v) {
	vec.pb(v);
	used[1][v] = 1;
	for (int to : g[1][v]) {
		if (used[1][to]) continue;
		go(to);
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m[0] >> m[1];
	for (int i = 0; i < 2; i++) {
		while (m[i]--) {
			int x, y;
			cin >> x >> y;
			g[i][x].pb(y);
			g[i][y].pb(x);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!used[0][i]) {
			num++;
			dfs(i);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!used[1][i]) {
			vec.clear();
			go(i);
			for (int j : vec)
				cnt[comp[j]]++;
			for (int j : vec)
				ans[j] = cnt[comp[j]];
			for (int j : vec)
				cnt[comp[j]]--;
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << ' ';
	}
}


Measured memory_bytes: 22924
#include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;

int main()
{
  string pattern, word;
  cin >> pattern;

  int ans = 0;
  while (cin >> word)
  {
    if (word == "END_OF_TEXT"s)
    {
      break;
    }
    transform(word.begin(), word.end(), word.begin(), ::tolower);
    if (word == pattern)
    {
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3172