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

using namespace std;

using lli = long long int;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, i, j;
    
    string S;
    
    cin >> S;
    
    n = S.size();
    
    lli s, k, k1, k2;
    
    i = 0;
    k = 0;
    s = 0;
    while (S[i] == '>')
    {
        ++k;
        ++i;
    }
    s += (k * (k + 1)) / 2;
    
    k1 = k2 = 0;
    
    while (i <= n)
    {
        if ((i == n) || ((S[i] == '<' && S[i - 1] == '>')))
        {
            k = max({k1, k2});
            s += (k * (k + 1)) / 2;
            
            k = min({k1, k2});
            k--;
            s += (k * (k + 1)) / 2;
            
            k1 = 0;
            k2 = 0;
        }
        if (S[i] == '<')
        {
            k1++;
        }
        else
        {
            k2++;
        }
        ++i;
    }
    
    
    
    cout << s;
    
    return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iostream>
using namespace std;
typedef pair<string,int> P;
bool compare(const P &p1,const P &p2) {
	if(p1.second!=p2.second) {
		return p1.second>p2.second;
	}else {
		return p1.first<p2.first;
	}
}
int main() {
	int n;
	while(cin>>n,n) {
		getchar();
		map<string,int> m[26];
		string x,y,z;
		for(int i=0;i<n;i++) {
			getline(cin,x);
			stringstream sstr(x);
			while(getline(sstr,y,' ')) {
				m[y[0]-'a'][y]++;
			}
		}
		cin>>z;
		int k=z[0]-'a';
		if(m[k].empty()) {
			cout<<"NA"<<endl;
		}else {
			vector<P> V;
			for(map<string,int>::iterator itr=m[k].begin();itr!=m[k].end();itr++) {
				V.push_back(*itr);
			}
			sort(V.begin(),V.end(),compare);
			cout<<(V[0].first);
			for(int i=1;i<min(5,(int)V.size());i++) {
				cout<<" "<<(V[i].first);
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999

ll max(ll a, ll b){
	if (a>b) return a;
	else return b;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<ll> n(3);
	REP(i, 3){cin >> n[i];}
	sort(n.begin(), n.end());
	ll mx = n[2];
	ll ans = (n[2] - n[0])/2 + (n[2] - n[1])/2;
	if ((n[0]%2==n[2]%2) && (n[1]%2==n[2]%2)){cout << ans << endl;}
	else if ((n[0]%2==n[2]%2)||(n[1]%2==n[2]%2)){cout << ans+2 << endl;}
	else {cout << ans+1 << endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int prim(vector<vector<int>> a) {
	int n = a.size();
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push(P(0, 0));
	set<int> mst;
	int res = 0;
	while (mst.size() < n) {
		int s = pq.top().second;
		int w = pq.top().first;
		pq.pop();
		if (mst.find(s) == mst.end()) res += w;
		mst.insert(s);
		REP(j, n) {
			if (a[s][j] >= 0 && mst.find(j) == mst.end()) {
				pq.push(P(a[s][j], j));
			}
		}
	}
	return res;
}

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

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	REP(i, n)REP(j, n) cin >> a[i][j];

	cout << prim(a) << "\n";
	
	return 0;
}



Measured memory_bytes: 3176
a, b, c = map(int, input().split())
print(min(
    abs(b-a)+abs(c-b),
    abs(c-a)+abs(b-c),
    abs(a-b)+abs(c-a),
    abs(c-b)+abs(a-c),
    abs(a-c)+abs(b-a),
    abs(b-c)+abs(a-b)
))


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

int main(){
  string s,t;
  int count = 0;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i] != t[i])count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3896
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();

            int current = 1;
            for (int i = 0; i < N; i++) {
                int nextA = 2 * current;
                int nextB = current + K;
                current = Math.min(nextA, nextB);
            }
            System.out.println(current);
        }
    }
}


Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	int ans = inf;
	rep(i, -100, 101) {
		int cnt = 0;
		rep(j, 0, n) cnt += pow(a[j] - i, 2);
		ans = min(ans, cnt);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

mod = 1000000007

dp = [1 for _ in range(N + 1)]
for a in A:
    dp[a] = 0

for n in range(2, N + 1):
    dp[n] *= dp[n - 1] + dp[n - 2]

    if dp[n] >= mod:
        dp[n] -= mod

print(dp[N])


Measured memory_bytes: 7836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    double n; cin >> n;
    double count = 0;
    rep(i, n){
        if((i+1) % 2 == 1) count++;
    }
    double ans = count / n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long answer=0;
  long long before=-1;
  int judge=0;
  for(int i=0;i<N;i++){
    long long A;
    cin>>A;
    if(A>before+1){
      cout<<-1<<endl;
      judge++;
      break;
    }
    else if(A<=before) answer+=before;
    if(i==N-1) answer+=A;
    before=A;
  }
  if(judge==0) cout<<answer<<endl;
  
  
  return 0;
}

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

int main(){
  int n;
  cin>>n;

  switch(n%10){
      case 2: cout<<"hon"<<endl;
        break;
      case 4: cout<<"hon"<<endl;
        break;
      case 5: cout<<"hon"<<endl;
        break;
      case 7: cout<<"hon"<<endl;
        break;
      case 9: cout<<"hon"<<endl;
        break;
      case 0: cout<<"pon"<<endl;
        break;
      case 1: cout<<"pon"<<endl;
        break;
      case 6: cout<<"pon"<<endl;
        break;
      case 8: cout<<"pon"<<endl;
        break;
      case 3: cout<<"bon"<<endl;
        break;
  }
}

Measured memory_bytes: 3628
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int a, b;
  cin >> a >> b;
  // l = 1 + 2 + ... + m : depth of snow
  // a = m+1 + ... + n, b = m+1 + m+2 + .... + n + (n+1)
  // thus, n+1 = b-a <-> n=b-a-1. compute l = (1+2+...+n) - a
  int n = b-a-1;
  int ans = 0;
  for(int i=1; i<n+1; ++i){
    ans += i;
  }
  ans -= a;
  cout << ans << endl;


}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        v: [i32; n],
    }
    let mut col = vec![0, 0, 0, 0, 0, 0, 0, 0, 0];
    for i in 0..n {
	let rating = v[i];
	let waru = rating / 400;
	if waru < 8 {
	    col[waru as usize] = 1;
	} else {
	    col[8] = col[8] + 1;
	}
    }
    let mut ret = 0;
    for i in 0..8{
	ret += col[i];
    }

    if ret == 0 {
	println!("{} {}", 1, col[8]);
    } else {
	println!("{} {}", ret, ret + col[8]);
    }
}


Measured memory_bytes: 2084
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define NOT_ZERO 1
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long ll;
typedef unsigned short int usi;

int main()
{
    int a=0,b=0,c=0,d=0;
    int n;

    for(int i=0; i<4; i++) {
        scanf("%d",&n);
        if(n==1)a=1;
        if(n==4)b=1;
        if(n==7)c=1;
        if(n==9)d=1;

    }

    printf(a*b*c*d==1?"YES":"NO");

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=2e3+10;
const int maxm=110;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,m,q;
int mapp[maxn][maxn];
int sum[maxn][maxn];
int xsum[maxn][maxn];
int ysum[maxn][maxn];
int sfunc(int x1,int y1,int x2,int y2)
{
    return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
}
int xfunc(int x1,int y1,int x2,int y2)
{
    return xsum[x2][y2]-xsum[x2][y1]-xsum[x1-1][y2]+xsum[x1-1][y1];
}
int yfunc(int x1,int y1,int x2,int y2)
{
    return ysum[x2][y2]-ysum[x2][y1-1]-ysum[x1][y2]+ysum[x1][y1-1];
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d %d %d",&n,&m,&q))
    {
        for(int i=1;i<=n;i++)
        {
            char s[maxn];
            scanf("%s",s);
            for(int j=1;j<=m;j++)
                mapp[i][j]=s[j-1]-'0';
        }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            {
                sum[i][j]=mapp[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
                xsum[i][j]=(mapp[i][j-1]==1&&mapp[i][j]==1)+xsum[i][j-1]+xsum[i-1][j]-xsum[i-1][j-1];
                ysum[i][j]=(mapp[i-1][j]==1&&mapp[i][j]==1)+ysum[i][j-1]+ysum[i-1][j]-ysum[i-1][j-1];
            }
        while(q--)
        {
            int x1,y1,x2,y2;
            scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
            printf("%d\n",sfunc(x1,y1,x2,y2)-xfunc(x1,y1,x2,y2)-yfunc(x1,y1,x2,y2));
        }
    }
    return 0;
}


Measured memory_bytes: 64896
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int p;
    string s;
    int a[n+1];
    int w[n+1];
    for(int i=0;i<n;i++){
         a[i]=0;
         w[i]=0;
    }

    int cnt_a=0,cnt_w=0;

    for(int i=0;i<m;i++){
        cin >> p >> s;
        if(s[0]=='A'){
            if(a[p-1]==0){
                a[p-1]=1;
                cnt_a+=1;
                cnt_w = cnt_w + w[p-1];
            }
        }
        else{
            if(a[p-1]==0){
                w[p-1]+=1;
            }
        }
    }

    cout << cnt_a << " " << cnt_w << endl;
    return 0;
}




Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n, q, A[] = new int[100000], m[] = new int[50000];
		n = sc.nextInt();
		for(int i = 0; i < n; i++)
		{
			A[i] = sc.nextInt();
		}
		q = sc.nextInt();
		for(int i = 0; i < q; i++)
		{
			m[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < q; i++)
		{
			int ok = -1;
			int ng = n;
			boolean aru = false;
			while(Math.abs(ok - ng) > 1)
			{
				int mid = (ok + ng) / 2;
				if(A[mid] == m[i])
				{
					aru = true;
					break;
				}
				if(A[mid] > m[i])
				{
					ng = mid;
				}
				else
				{
					ok = mid;
				}
			}
			if(aru)
			{
				++ans;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 68404
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
#define 	  endl 			'\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
        int mx = 0;
        int n; cin >> n;
        int ansr = 0;
        for(int i = 0; i < n; i++){
        	int x; cin >> x;
        	if(mx <= x)
        		mx = max(mx, x);
        	else{

        		ansr += max(0LL, mx - x);
        	}
        	mx = max(mx, x);
        }
        cout << ansr ;
    	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

const int MOD = 1e9+7;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    sort(All(A));

    if(N%2==0){
        for(int i=0;i<N/2;i++){
            if(A[2*i]!=2*i+1||A[2*i+1]!=2*i+1){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        if(A[0]!=0){
            cout << 0 << endl;
                return 0;
        }
        for(int i=0;i<N/2;i++){
            if(A[2*i+1]!=2*i+2||A[2*i+2]!=2*i+2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    ll res = 1;
    for(int i=0;i<N/2;i++){
        res*=2;
        res%=MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
def main():
  a,b,c = list(map(int,input().split()))
  flg=0
  i=0
  while i<=a:
    if (b*i+c) % a==0:
      flg=1
    i+=1
  if flg==1:
    print("YES")
  else:
    print("NO")
  
main()

Measured memory_bytes: 9132
using System;
using System.Linq;

namespace ABC134B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int checkable = (nd[1] * 2) + 1;
            Console.WriteLine(Math.Ceiling((double)nd[0] / checkable));
        }
    }
}


Measured memory_bytes: 13268
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#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 all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 1000 * 1000 + 5;
const ll mod = 1000000007;
const ll mod3 = 998244353;
const ll INF = 1000000000 * 1ll * 1000000000 + 500000;
const ld pi = acosl(-1.0);

int n, k;
vector<pii> intervals;
vector<ll> dp;

void input() {
  cin >> n >> k;
  intervals.resize(k);
  for (int i = 0; i < k; i++) {
    cin >> intervals[i].first >> intervals[i].second;
  }
}

void solve(int testId) {
  dp.resize(n);
  dp[0] = 1;
  ll cur_sum = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (i - intervals[j].first >= 0) {
        cur_sum += dp[i - intervals[j].first];
      }
      if (i - intervals[j].second - 1 >= 0) {
        cur_sum = (cur_sum + mod3 - dp[i - intervals[j].second - 1]);
      }
    }
    cur_sum %= mod3;
    dp[i] = cur_sum;
  }
  cout << dp.back() << endl;
}

int main() {
  // freopen("test", "r", stdin);
  int testcases = 1;
  // scanf("%d", &testcases);
  for(int testId = 1; testId <= testcases; testId++) {
    input();
    solve(testId);
  }
  return 0;
}


Measured memory_bytes: 4828
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
t = [0] * N
for i in range(N):
  x = a[i]
  t[i] = (x + 1) / 2
s = sum(t[: K])
res = s + 0
for i in range(N - K):
  s -= t[i]
  s += t[i + K]
  res = max(res, s)
print(res)

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

using namespace std;


int main(){
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
// ABC 146-B
// 2019.11.24 bal4u

#include <stdio.h>

char S[10005];

int main()
{
	int i, N;
	
	scanf("%d%s", &N, S);
	for (i = 0; S[i]; ++i) {
		S[i] += N;
		if (S[i] > 'Z') S[i] -= 'Z', S[i] += 'A'-1;
	}
	puts(S);
	return 0;
}


Measured memory_bytes: 128
/* ex4_1
  terakura */

#include <stdio.h>
#include <math.h>

int main(void){
    double short_hund, long_hund, hour, minute, angle, area;
    scanf("%lf %lf %lf %lf", &short_hund, &long_hund, &hour, &minute );


//短針とが０時０分の為す角は(時間＊2π/12) + (π/6の”分”ぶんの60)
    angle = ((hour *  2 * M_PI / 12) +( M_PI / 6 * minute / 60)) -(minute / 60) * 2 * M_PI ;     //短針と長針のなす角度(ラジアン)
    area = sqrt( pow(short_hund, 2) + pow(long_hund, 2) - 2 * short_hund * long_hund * cos(angle));     //余弦定理で面積を計算

    printf("%.20lf\n", area);

    return 0;
}


Measured memory_bytes: 2640
#include<iostream>
using namespace std;
int main()
{
	int d;
	cin>>d;
	if(d==25)
	cout<<"Christmas";
	else
	if(d==24)
	cout<<"Christmas Eve";
	else
	if(d==23)
	cout<<"Christmas Eve Eve";
	else
	if(d==22)
	cout<<"Christmas Eve Eve Eve";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
hap = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for _ in range(n+10)]

dp[0][0] = hap[0][0]
dp[0][1] = hap[0][1]
dp[0][2] = hap[0][2]

for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + hap[i+1][k])

ans = 0
for k in range(3):
    ans = max(ans, dp[n-1][k])

print(ans)

Measured memory_bytes: 47384
#include<cstdio>
using namespace std;
template<class T>inline void read(T&a){
	char c=getchar();int f=1;a=0;
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0') a=(a<<1)+(a<<3)+c-48,c=getchar();
	a*=f;
}
template<class T>void write(T a){
	if(a<0) putchar('-'),a=-a;
	if(a>9) write(a/10);
	putchar(a%10+48);
}
#define int long long
int n,k,d;
signed main(){
	read(n);read(k);read(d);
	n=(n<0?-n:n);
	if(n/d>=k) write(n-k*d);
	else write(((k&1)^((n/d)&1))?d-n%d:n%d);
	return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

#define int ll
#define pb(x) push_back(x)
#define INF (int)1e17
#define PI 3.14159265358979323846
 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};


void solve(){
	int h,w,m; cin >> h >> w >> m;
	int row[h+1],col[w+1];
	memset(row,0,sizeof(row));
	memset(col,0,sizeof(col));
	map<pair<int,int>,int> points;
	For(i,m){
		int x,y; cin >> x >> y;
		points[{x,y}]++;
		row[x]++;col[y]++;
	}
	
	vector<pair<int,int>> ff,ss;
	FOR(i,1,h+1){
		ff.push_back({row[i],i});
	}
	FOR(i,1,w+1){
		ss.push_back({col[i],i});
	}
	// for(auto ele : ss){
	// 	deb(ele.first,ele.second);
	// }

	sort(ff.rbegin(),ff.rend());
	sort(ss.rbegin(),ss.rend());
	int ans=0;
	FOR(i,1,w+1){
		//deb(ff[0].first,ss[i-1].first);
		int cnt=ff[0].first+ss[i-1].first;
		if(points.count({ff[0].second,ss[i-1].second}))cnt--;
		ans=max(ans,cnt);
	}
	FOR(i,1,h+1){
		int cnt=ff[i-1].first+ss[0].first;
		if(points.count({ff[i-1].second,ss[0].second}))cnt--;
		ans=max(ans,cnt);
	}
	cout << ans <<"\n";
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		//freopen("in.txt", "r", stdin);
	#endif
	ios_base:: sync_with_stdio(false); 
	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
  #endif
}

Measured memory_bytes: 43600
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define test ll t;cin >> t; while(t--)
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"

ll n,W;
ll w[105],val[105];
ll dp[115][100105];
ll Mval=1e6+5;



int main()
{
   std::ios::sync_with_stdio(false);
   cin>>n>>W;
   ll mmax=0;
   rep(i,n)
   {
       cin>>w[i]>>val[i];
       mmax=max(mmax,val[i]);
   }
   mmax*=n;
   
   rep(i,Mval)
   dp[0][i]=inf;
   
   dp[0][0]=0;
   
   rep(i,n)
   {
       
       rep(j,Mval+1)
       {
           if(j-val[i]>=0)dp[i+1][j]=min(dp[i][j],w[i]+dp[i][j-val[i]]);
           else
           dp[i+1][j]=dp[i][j];
       }
   }
   
   ll ans=0;
   rep(i,mmax+1)
   {
       if(dp[n][i]<=W)
       {
        //   cout<<dp[n][i]<<" ";
           ans=i;
       }
   }
   cout<<ans;
}







Measured memory_bytes: 88320
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s, t;
	cin >> s >> t;
	vector<vector<int>>v(26, vector<int>(26));
	for (int i = 0; i < s.size(); i++) {
		v[s[i] - 'a'][t[i] - 'a'] = 1;
	}
	vector<int>w(26);
	vector<int>x(26);
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 26; j++) {
			w[i] += v[i][j];
			x[j] += v[i][j];
			if (w[i] >= 2) {
				cout << "No\n";
				return 0;
			}
			if (x[j] >= 2) {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 916
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
elif W % 2 == 0:
    print(H * W // 2)
else:
    if H % 2 == 0:
        print(H * W // 2)
    else:
        print((W + 1) // 2 + (H - 1) * W // 2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, a;
    string s;
    cin>>s;
    if(s[0]!=s[1] || s[0]!=s[2])
        cout<<"Yes";
    else if(s[0]==s[1] && s[0]==s[2])
        cout<<"No";
}



Measured memory_bytes: 3616
s = int(input())

c = [False for i in range(1000001)]

n = 1
an = s
while True:
    if c[an]:
        print(n)
        break
    c[an] = True

    if an & 1 == 0:
        an >>= 1
    else:
        an = 3 * an + 1
    n += 1


Measured memory_bytes: 10904
import math
A, B, H ,M = map(int , input().split())
T = 60 * H + M
omega1 = math.pi / 360
omega2 = math.pi / 30
theta = omega1*T - omega2*T
c = math.cos(theta)
l = math.sqrt(A**2 + B**2 - 2*A*B*c)
print(l)

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

int main(){
    int A , B;
    char op;
    int ans;

    cin >> A >> op >> B;

    if(op == '+'){
        ans = A + B;
    }
    else if(op == '-'){
        ans = A - B;
    }
    cout << ans << endl;

    return 0;
}

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

 #define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
 }

Measured memory_bytes: 2580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1005;
int n,q,mp[N*2][N*2][2];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

inline int gets(const int x1,const int x2,const int y1,const int y2,const bool c){
	if(x1>x2||y1>y2) return 0;
	return mp[x2][y2][c]-(x1?mp[x1-1][y2][c]:0)-(y1?mp[x2][y1-1][c]:0)+(x1&&y1?mp[x1-1][y1-1][c]:0);
}

inline int split(const int x,const int y,const bool c){
	int m=(q<<1)-1,ans=0;
	ans+=gets(0,x,0,y,c)+gets(0,x,y+1,y+q,c^1)+gets(0,x,y+q+1,m,c);
	ans+=gets(x+1,x+q,0,y,c^1)+gets(x+1,x+q,y+1,y+q,c)+gets(x+1,x+q,y+q+1,m,c^1);
	ans+=gets(x+q+1,m,0,y,c)+gets(x+q+1,m,y+1,y+q,c^1)+gets(x+q+1,m,y+q+1,m,c);
	return ans;
}

int main(){
	n=nxi(),q=nxi();
	for(int i=1; i<=n; ++i){
		const int a=nxi()%(q<<1),b=nxi()%(q<<1);
		char c;
		while((c=getchar())!='W'&&c!='B');
		++mp[a][b][c=='W'];
	}
	for(int i=0; i<q<<1; ++i){
		for(int j=1; j<q<<1; ++j){
			mp[i][j][0]+=mp[i][j-1][0];
			mp[i][j][1]+=mp[i][j-1][1];
		}
	}
	for(int i=1; i<q<<1; ++i){
		for(int j=0; j<q<<1; ++j){
			mp[i][j][0]+=mp[i-1][j][0];
			mp[i][j][1]+=mp[i-1][j][1];
		}
	}
	int ans=0;
	for(int i=-1; i<q; ++i){
		for(int j=-1; j<q; ++j){
			//printf("(%d %d) ",split(i,j,0),split(i,j,1));
			apx(ans,split(i,j,0));
			apx(ans,split(i,j,1));
		}
		//puts("");
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 31616
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string N;
    cin >> N;

    int M = N.size();
    ll dp[M+1][2];
    dp[0][0] = 0;
    dp[0][1] = 1;

    REP(i, M) {
        int s = N[i] - '0';

        // exact
        dp[i+1][0] = min(dp[i][0] + s, dp[i][1] + s + 1);

        // bigger
        dp[i+1][1] = min(dp[i][0] - s, dp[i][1] - s - 1) + 10;
    }

    cout << min(dp[M][0], dp[M][1] + 1) << endl;

}


Measured memory_bytes: 17052
#include<bits//stdc++.h>
using namespace std;
int main(){
  int n;string s;
  cin >>n;
  if(n >= 400&& n<=599) cout << 8 << endl;
  else if(n>=600&&n <800) cout << 7 << endl;
  else if(n >= 800&& n <1000) cout << 6 << endl;
  else if(n >= 1000&& n <1200) cout << 5 << endl;
  else if(n >= 1200&&n <1400)cout << 4 << endl;
  else if(n>=1400&& n <1600) cout << 3 << endl;
  else if(n >= 1600&& n <1800) cout << 2 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>

using namespace std;

bool ans[2001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, q, m;
	ans[0]=true;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>a;
		for(int j=2000; j>=a; j--) {
			if(ans[j-a]) ans[j]=true;
		}
	}
	cin>>q;
	for(int i=0; i<q; i++) {
		cin>>m;
		cout<<(ans[m]?"yes\n":"no\n");
	}
	return 0;
}



Measured memory_bytes: 3116
import heapq
N = int(input())
a = [int(_) for _ in input().split()]

d = {}

for i in range(N):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

q = []

for x in d:
    for i in range(d[x]//2):
        heapq.heappush(q,-x)

if len(q) <2:
    print(0)
else:
    h = - heapq.heappop(q)
    w = - heapq.heappop(q)
    print(h * w)

Measured memory_bytes: 17932
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll K;
  cin>>K;
  ll A[K];
  for(ll i=0;i<K;++i) cin>>A[i];
  ll mini[K+1], maxi[K+1];
  mini[K] = 2;
  maxi[K] = 2;
  bool ok = true;
  for(ll i=K-1;i>=0;--i) {
    mini[i] = mini[i+1] + (A[i]-mini[i+1]%A[i])%A[i];
    if(mini[i]>maxi[i+1]) ok = false;
    maxi[i] = maxi[i+1]/A[i]*A[i]+A[i]-1;
  }
  /**
  for(ll i=0;i<=K;++i) cout<<mini[i]<<" ";
  cout<<endl;
  for(ll i=0;i<=K;++i) cout<<maxi[i]<<" ";
  cout<<endl;
  **/
  if(ok) {
    cout<<mini[0]<<" "<<maxi[0]<<endl;
  }
  else cout<<-1<<endl;
}


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

int main(void){
    int N;
    cin >> N;
    string s;
    int AB{0}, BA{0}, A{0}, B{0};

    for(int i{0}; i<N; ++i){
        cin >> s;
        for(int j{1}; j<s.size(); ++j){
            if(s[j-1]=='A' and s[j]=='B')
                ++AB;
        }
        if(s[0]=='B' and s[s.size()-1]=='A'){
            ++BA;
        }
        else if(s[0]=='B'){
            ++B;
        }
        else if(s[s.size()-1]=='A'){
            ++A;
        }
    }
    int sum{AB};

    if(A+B==0 and BA>0)
        sum += BA-1;
    else
        sum += BA+min(A, B);

    cout << sum << endl;

}


Measured memory_bytes: 256
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod (lint)1000000007
#pragma endregion

int n;
vector<int> d;
void input() {
	cin >> n;
	d.resize(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	return;
}
lint solve() {
	if (n == 1) return 1;
	map<int, int> p;
	for (int i = 0; i < n; i++) {
		p[d[i]]++;
	}
	if (n % 2 == 0) {
		bool h = true;
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				if (p[i] != 0) { h = false; break; }
			}
			else{
				if (p[i] != 2) { h = false; break; }
			}
		}
		if (h) {
			lint ans = 2;
			for (int i = 0; i < n - 2; i += 2) {
				ans *= 2;
				ans %= mod;
			}
			return ans;
		}
		else 
			return 0;
	}
	if (n % 2 == 1) {
		bool h = true;
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				if (p[i] != 1) { h = false; break; }
				else continue;
			}
			if (i % 2 == 1) {
				if (p[i] != 0) { h = false; break; }
			}
			else {
				if (p[i] != 2) { h = false; break; }
			}
		}
		if (h) {
			lint ans = 2;
			for (int i = 0; i < n - 4; i += 2) {
				ans *= 2;
				ans %= mod;
			}
			return ans;
		}
		else 
			return 0;
	}
}

int main(void) {
	input();
	printf("%lld\n", solve());
	
	return 0;
}

Measured memory_bytes: 8396
def resolve():
    S = input()
    table=[0]*2019
    table[0]=1
    x = 0
    x_10 =1
    for i in S[::-1]:

        x = (x+ int(i)*x_10)%2019

        table[x]+=1

        x_10*=10
        x_10 %= 2019

    ans =0
    for i in table:
        ans += i*(i-1)//2
    
    print(ans)



if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9324
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll x = max(a, b);
    ll y = max(c, d);

    ll p = min(a, b);
    ll q = min(c, d);

    ll com1 = x * y;
    ll com3 = p * q;
    ll com4 = x * q;
    ll com5 = y * p;

    ll res = max(com1, max(com3, max(com4, com5)));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3136
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int n;
    string c;
    string res ;
    
    cin >> c ;
    string tmp = {"abcdefghijklmnopqrstuvwxyz"};
    
    n = tmp.find(c);

    res = tmp[n+1];

    cout << res << endl;
}


Measured memory_bytes: 256
import math
a, b,h,m = list(map(int, input().split()))
rel_hour = (h*60 + m)/12/60
#print(rel_hour)
arg_hour = 2* math.pi *rel_hour
arg_min = 2*math.pi * m/60
ans = (abs(a**2+b**2-2*a*b*math.cos(arg_hour-arg_min)))**(1/2)
print(ans)

Measured memory_bytes: 9520
n,k = map(int,input().split())

if 2*n<k:
    print(0)
elif k%2 == 1:
    m = int(n/k)
    print(m**3)
else:
    m = int(n/k)
    l = int((n+k/2)/k)
    print(m**3+l**3)

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(string& S) {
    int answer = 0;
    REP(i,0,S.size()) {
        int another = S.size()-i-1;
        if (i >= another) break;
        if (S[i] != S[another]) {
            answer++;
        }
    }

	stringstream ss;
	ss << answer;
	cout << ss.str() << '\n';

    return;
}

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

    solve(S);
    
    return 0;
}



Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();
  let mut a = vec![];

  for _ in 0..n {
    let a_i = read::<i32>();
    a.push(a_i);
  }

  let base = a.iter().min().expect("faild to find min");

  println!("{}", dsf(&a[..], base) + base);
}

fn dsf(a_p: &[i32], base: &i32) -> i32 {
  let a_min = match a_p.iter().min() {
    Some(s) => s,
    None => return 0,
  };
  let min_idx = find_all(a_p, *a_min);

  if min_idx.len() == a_p.len() {
    return a_min - base;
  }

  let mut prev_i: usize = 0;
  let mut sum = 0;

  for i in &min_idx {
    let a_slice = &a_p[prev_i..*i];
    sum += dsf(a_slice, a_min);

    prev_i = i + 1;
  }

  if prev_i < a_p.len() {
    let a_slice = &a_p[prev_i..];
    sum += dsf(a_slice, a_min);
  }
  sum += (*a_min - base);
  sum
}

fn find_all(a_p: &[i32], t: i32) -> Vec<usize> {
  let mut a_is = vec![];
  for (i, v) in a_p.iter().enumerate() {
    if *v == t {
      a_is.push(i);
    }
  }
  return a_is;
}


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

int main() {
	int A, B, K;

	cin >> A >> B >> K;

	for( int i = 0; i < K; i++ ) {
		if( i % 2 ) {
			if( B % 2 ) {
				B--;
			}
			B /= 2;
			A += B;
		}
		else {
			if( A % 2 ) {
				A--;
			}
			A /= 2;
			B += A;
		}
	}
	
	cout << A << " " << B << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int r=sc.nextInt();
		int g=sc.nextInt();
		int b=sc.nextInt();
		int v=100*r+10*g+b;
		System.out.println(v%4==0?"YES":"NO");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

bool Solve() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0 && s[i] == 'L') return false;
    if (i % 2 == 1 && s[i] == 'R') return false;
  }
  return true;
}

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

  cout << (Solve() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
flag = False
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        ans = 10000*x + 5000*y + 1000*z
        if ans == Y and 0 <= z:
            flag = True
            break
    else:
        continue
    break

if flag:
    print(x, y, z)
else:
    print(-1, -1, -1)


Measured memory_bytes: 9096
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    A_max = pow(10, 5)+1
    N = int(input())
    A_lsit = list(map(int, input().split()))
    Q = int(input())
    B_list = [0]*Q
    C_list = [0]*Q
    for q in range(Q):
        B, C = map(int, input().split())
        B_list[q] = B
        C_list[q] = C
    
    bucket_list = [0]*A_max
    for A in A_lsit:
        bucket_list[A] += 1

    S = 0
    for i in range(A_max):
        S += i*bucket_list[i]
    for q in range(Q):
        B = B_list[q]
        C = C_list[q]
        S += bucket_list[B] * (C-B)
        print(S)
        bucket_list[C] += bucket_list[B]
        bucket_list[B] = 0
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 22216
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)
#define SORT(v) sort((v).begin(), (v).end())

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int size;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity)
      : F(f), UNITY(unity), size(n), dat(2 * n, unity) {}

  // Sets i-th value (0-indexed) to x for initial setup.
  // build() must be called after set() calls.
  void set(int i, const Monoid &x) { dat[size + i] = x; }
  void build() {
    for (int k = size - 1; k > 0; --k) {
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Sets i-th value (0-indexed) to x.
  void update(int i, const Monoid &x) {
    int k = size + i;
    dat[k] = x;
    while (k > 1) {
      k >>= 1;
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Queries by [l,r) range (0-indexed, open interval).
  Monoid fold(int l, int r) {
    l += size;
    r += size;
    Monoid vleft = UNITY, vright = UNITY;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vleft = F(vleft, dat[l++]);
      if (r & 1) vright = F(dat[--r], vright);
    }
    return F(vleft, vright);
  }

  // Queries by a single index (0-indexed).
  Monoid operator[](int i) { return dat[size + i]; }

  /* debug */
  void print() {
    for (int i = 0; i < size; ++i) {
      cout << (*this)[i];
      if (i != size - 1) cout << ",";
    }
    cout << endl;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<int> a(N), sa(N);
  map<int, int> oddm, evenm;
  REP(i, N) {
    int x;
    cin >> x;
    a[i] = sa[i] = x;
  }
  SORT(sa);
  REP(i, N) {
    if (i % 2 == 1) {
      oddm[sa[i]]++;
    } else {
      evenm[sa[i]]++;
    }
  }
  REP(i, N) {
    if (i % 2 == 1) {
      oddm[a[i]]--;
    } else {
      evenm[a[i]]--;
    }
  }
  i64 ans1 = 0, ans2 = 0;
  for (auto [x, k] : oddm)
    if (k > 0) ans1 += k;
  for (auto [x, k] : evenm)
    if (k > 0) ans2 += k;
  assert(ans1 == ans2);
  cout << ans1 << endl;
}


Measured memory_bytes: 13468
#include <iostream>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;

int main() {
    long h, w, n;
    cin >> h >> w >> n;
    map<P, long> blacks;
    set<P> cand;
    for (int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        blacks[{a, b}] = 1;
        for (int x=-1; x<2; x++)
            for (int y=-1; y<2; y++)
                cand.insert({a+x, b+y});
    }
    long cnt[10] = {0};
    cnt[0] = (h-2) * (w-2);
    for (auto c:cand) {
        int temp = 0;
        if (c.first < 2 || c.first > h-1 || c.second < 2 || c.second > w-1) continue;
        for (int x=-1; x<2; x++)
            for (int y=-1; y<2; y++)
                temp += blacks[{c.first+x, c.second+y}];
        cnt[temp]++;
        cnt[0]--;
    }
    for (auto ci:cnt)
        cout << ci << '\n';
    return 0;
}

Measured memory_bytes: 198656