akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


int main(){//
    int N, Q;
    cin >> N >> Q;
    //vec[i][j]: 頂点iと結ばれている頂点の数列
    vector<vector<int>> vec(N, vector<int>());
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }

    //score[i]: 頂点iの点数
    vector<ll> score(N, 0);//とりあえず指定された頂点piのみにxiを足す．
    for(int i=0; i<Q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        score[p] += x;
    }

    // cout << " vec: " << endl; print_vec2(vec);
    // cout << " score: " ; print_vec(score);

    //頂点iのカウンター値は iの親ノードのカウンター値と iのscoreの和
    vector<ll> ans(N, 0);//ans[i]: 頂点iのカウンター値
    //BFSする
    //q.fist: 注目ノード, q.second: 注目ノードの親
    queue<P> q;
    q.push(P(0, -1));
    while(q.size() != 0){
        int child = q.front().first;
        int parent = q.front().second;
        ans[child] += score[child];
        q.pop();
        for(int j=0; j<vec[child].size(); j++){
            int next_c = vec[child][j];
            // cout << " cihld: " << child << "  parent: " << parent << "  next_c: " << next_c << endl;
            
            if(next_c == parent) continue;
            ans[next_c] += ans[child];
            q.push(P(next_c, child));

        }
    }

    for(int i=0; i<N; i++){
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 18676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
int const MOD = 1e9 + 7;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i = 0; i < y; i++) {
        res = res * x % MOD;
    }
    return res;
}

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

    ll ans = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]
lst = inputs[1].sort

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p nn
  p lst
end

idx = nn/2 - 1
pd idx
pd lst[idx+1]
pd lst[idx]

puts lst[idx+1] - lst[idx]


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    vector<char> vec(100);
    rep(i,6){
        cin >> vec.at(i);
    }
    if(vec.at(0) == vec.at(5)&&vec.at(1) == vec.at(4)&&vec.at(2) == vec.at(3)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

A_cnt = Counter(A)
tmp = 0
for x in A_cnt.values():
	if x >= 2:
		tmp += x-1
print(len(A_cnt) if tmp % 2 == 0 else len(A_cnt)-1)


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

using namespace std;

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	if((a+b == c) || (b+c == a) || (a+c == b))
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	ll n,x;
	cin >> n >>x;
	ll a[n];
	FOR(i,n) cin >> a[i];
	ll sum=0;
	if(a[0] > x) {sum+=a[0]-x;a[0]-=a[0]-x;}
	for(ll i=1;i < n;i++){
		if(a[i]+a[i-1] > x) {
			sum+=a[i]+a[i-1]-x;
			a[i]-=a[i]+a[i-1]-x;
			
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String n = r.readLine();
		String s = r.readLine();

		int count = 0;
		while (s.contains("ABC")) {
			int index = s.indexOf("ABC");
			s = s.substring(index + 3, s.length());
			++count;
		}

		System.out.println(count);

		r.close();
	}
}

Measured memory_bytes: 21332
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n;
	cin >> n;
	int a = n / 100;
	int b = (n / 10)%10;
	int c = n % 10;
	if (a == c)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	long double a,b; 
        	cout<<fixed<<setprecision(0); 
       		cin>>a>>b;
       		cout<<floor(a*b);




             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


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

using namespace std;

const int MOD = 1000000007;

int main(){
    const int maxSize = 500001;
	vector<long long> inv(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r || r < 0) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    auto perm = [&](int n, int r){
        if(n < r || r < 0) return 0LL;
        return fact[n] * factInv[n-r] % MOD;
    };
    int N, M; cin >> N >> M;
    long long res = perm(M, N);
    for(int i=1;i<=N;i++){
        long long d = comb(N, i) * perm(M-i, N-i) % MOD;
        if(i%2){
            res = (res + MOD - d) % MOD;
        } else {
            res = (res + d) % MOD;
        }
    }
    res = (res * perm(M, N)) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 14696
import sys

while True:
	n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 == n and 0 == x:
		break
		
	cnt = 0
	ave = x // 3
	for i in range( 1, ave ):
		ave2 = (x-i) // 2
		for j in range( i+1, ave2+1 ):
			k = x-i-j
			if j < k and k <= n:
				cnt += 1
	
	print( cnt )

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if((A+B) < (C+D)) cout << "Right" << endl;
    if((A+B) > (C+D)) cout << "Left" << endl;
    if((A+B) == (C+D)) cout << "Balanced" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct UnionFind{
    vector<int>par,siz;
    UnionFind(int x){
        par.resize(x);
        siz.resize(x);
        rep(i,x){
            par[i]=i;
            siz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y)return;
        if(siz[x]<siz[y])swap(x,y);
        par[y]=x;
        siz[x]+=siz[y];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return siz[find(x)];
    }
};
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    P x[200010];
    int ans[200010];
    cin>>n;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        a--,b--;
        x[a]={b,i};
    }
    UnionFind uf(n);
    set<int>st;
    rep(i,n){
        vector<int>l;
        if(!st.empty()){
            for(auto it=st.begin();(*it)<x[i].fi;it++){
                if(it==st.end())break;
                int s=*it;
                uf.unite(s,x[i].fi);
                l.pb(s);
            }
        }
            st.insert(x[i].fi);
            l.pb(x[i].fi);
            for(int j=1;j<l.size();j++)st.erase(l[j]);
        /*for(int j:st)cout<<j<<" ";
        cout<<endl;*/
    }
    rep(i,n)ans[x[i].se]=uf.size(x[i].fi);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 15304
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int t[100010], x[100010],y[100010];

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

    bool flg=true;
    for (int i = 1; i <= n; i++) {
        if((x[i]-x[i-1]+y[i]-y[i-1]>t[i]-t[i-1])||(abs(x[i]-x[i-1]+y[i]-y[i-1])%2!=(t[i]-t[i-1])%2)){
            flg=false;
        }
    }
    cout<<((flg)?"Yes":"No")<<endl;

    return 0;
}

Measured memory_bytes: 1408
N, W = map(int, input().split())
#dp[何番目の品物][重さ]
dp = [[-1 for i in range(W+1)] for j in range(N+1)]

items = []
for i in range(N):
  items.append(list(map(int, input().split())))

# i:i番目の荷物 empty:残り容量
def rec(i, empty):
  if dp[i][empty] != -1:
    return dp[i][empty]

  res = 0
  if i == N:
    pass
  elif empty < items[i][1]:
    res = rec(i+1, empty)
  else:
    res = max(rec(i+1, empty), rec(i+1, empty - items[i][1]) + items[i][0])

  dp[i][empty] = res
  return res

print(rec(0, W))



Measured memory_bytes: 24092
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    Vi num(5,0);
    rp(i,n){
        string s;
        cin >> s;
        if(s[0]=='M') num[0]++;
        if(s[0]=='A') num[1]++;
        if(s[0]=='R') num[2]++;
        if(s[0]=='C') num[3]++;
        if(s[0]=='H') num[4]++;
    }
    ll ans=0;
    ans+=num[0]*num[1]*num[2];
    ans+=num[0]*num[1]*num[3];
    ans+=num[0]*num[1]*num[4];
    ans+=num[0]*num[2]*num[3];
    ans+=num[0]*num[2]*num[4];
    ans+=num[0]*num[3]*num[4];
    ans+=num[1]*num[2]*num[3];
    ans+=num[1]*num[2]*num[4];
    ans+=num[1]*num[3]*num[4];
    ans+=num[2]*num[3]*num[4];
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main() {
  int A,B;
  cin >> A >>B;
  int N=0;
  int C=A;
  
  for (int i=0;i<B-C+1;i++){
    if (A/10000%10 == A%10 && A/1000%10 == A/10%10){
      N++;
      A++;
    }
    else{
      A++;
    }
  }
  cout << N << endl;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	ans := n
	ans *= n
	ans *= n

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,m;
  cin>>n>>m;
  vll a(n),b(m);
  REP(i,n)cin>>a[i];
  REP(i,m)cin>>b[i];
  sort(ALL(a));
  sort(ALL(b));

  vll cuma(1e6+1),cumb(1e6+1);
  REP(i,n)cuma[a[i]]++;
  REP(i,m)cumb[b[i]]++;

  REP(i,1e6+1){
    if(cuma[i]>1 || cumb[i]>1){
      cout<<0<<endl;
      return 0;
    }
  }

  for(ll i=1e6; i>0; i--){
    cuma[i-1]+=cuma[i];
    cumb[i-1]+=cumb[i];
  }

  map<ll,ll> ma,mb;
  REP(i,n)ma[a[i]]+=1;
  REP(i,m)mb[b[i]]+=1;

  ll ans=1;
  for(ll i=n*m; i>=1; i--){
    if(ma[i]==1 && mb[i]==1)
      continue;
    ll now;
    if(ma[i]==1)
      now=cumb[i];
    else if(mb[i]==1)
      now=cuma[i];
    else
      now=cuma[i]*cumb[i]-(n*m-i);
    ans=ans*now%MOD;
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 143784
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            exit()
    print('NG')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <cstdio>
int main() {
    int t,n;
    for(int i=0;i<4;i++) {
        scanf("%d %d",&t,&n);
        int sale;
        if(t==1) sale=6000*n;
        if(t==2) sale=4000*n;
        if(t==3) sale=3000*n;
        if(t==4) sale=2000*n;
        printf("%d\n",sale);
    }
}

Measured memory_bytes: 1028
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    H = (H * 60. + M) / 2.;
    M = M * 6.;
    double angle;
    angle = abs(H - M);
    angle = min(angle, 360. - angle);
    // if(angle == 180)
    // {
    //     cout << fixed << setprecision(20) << A + B << endl;
    //     return 0;
    // }
    double ans;
    ans = sqrt((A * A) + (B * B) - (2. * A * B * cos(angle / 180. * M_PI)));
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}




Measured memory_bytes: 4200
/*
 * https://qiita.com/drken/items/ecd1a472d3a0e7db8dce#%E5%95%8F%E9%A1%8C-6abc-098-d-xor-sum-2
 * 勉強させていただいた記事
 * 
 */

#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

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

    ll res=0;
    int right=0,sum=0;
    rep(left,N){
        while(right<N&&(sum^A[right])==(sum+A[right])){//^は排他的論理和の演算子,
            sum+=A[right];//1が重複しない範囲を尺取で求める
            right++;
        }
        res+=right-left;//leftに対して、条件を満たすrightが複数あるのでright-leftで組みが戻る
        if(right==left)right++;
        else{
            sum-=A[left];
        }
    }

    cout<<res<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,q,ans;
struct seg
{
	int tr[N<<2];
	void build(int k,int l,int r)
	{
		tr[k]=(k==1?n:1e9);
		if(l==r)
			return;
		int mid=l+r>>1;
		build(k<<1,l,mid);
		build(k<<1|1,mid+1,r);
	}
	void update(int k,int l,int r,int a,int b,int v)
	{
		if(l==a&&r==b)
		{
			tr[k]=min(tr[k],v);
			return;
		}
		int mid=l+r>>1;
		if(b<=mid) update(k<<1,l,mid,a,b,v);
		else if(a>mid) update(k<<1|1,mid+1,r,a,b,v);
		else update(k<<1,l,mid,a,mid,v),update(k<<1|1,mid+1,r,mid+1,b,v);
	}
	int query(int k,int l,int r,int x)
	{
		if(l==r)
			return tr[k];
		int mid=l+r>>1;
		if(x<=mid) return min(tr[k],query(k<<1,l,mid,x));
		else return min(tr[k],query(k<<1|1,mid+1,r,x));
	}
}t1,t2;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>q;
	ans=(n-2)*(n-2);
	t1.build(1,1,n);
	t2.build(1,1,n);
	while(q--)
	{
		int t,x;
		cin>>t>>x;
		if(t==1)
		{
			int v=t2.query(1,1,n,x);
			ans-=v-2;
			t1.update(1,1,n,1,v,x);
		}
		else
		{
			int v=t1.query(1,1,n,x);
			ans-=v-2;
			t2.update(1,1,n,1,v,x);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11792
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
#include <climits>

using namespace std;

int main()
{
    int numm[105];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {   
        int temp;
        cin >> temp;
        numm[i] = temp;

    }
    
    int mincost = INT_MAX;


    for (int i = -100; i < 101; i++)
    {
        int cost = 0;
        for (int j = 0; j < n; j++)
        {
            cost += ((numm[j] - i) * (numm[j] - i));

        }
        if (cost < mincost) mincost = cost;

    }
    cout << mincost;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){
  char s[201],tmp[201];
  int m,h;


  while(1){
    scanf("%s\n",s);
    if(strcmp(s,"-")==0)
      return 0;
    scanf("%d\n",&m);
    for(int i=0;i<m;i++){
      scanf("%d\n",&h);
      memset(tmp,0,sizeof(tmp));
      int len=strlen(s)-h;
      strncpy(tmp,s,h);
      memmove(s,s+h,len);
      strncpy(s+len,tmp,h);
    }
    puts(s);
  }


}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

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

const int MAX=10000000;
const int MOD=1000000007;

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(ll i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll COM(ll n,ll r){
    if(n<r || n<0 || r<0) return 0;
    else return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

int main()
{
    COMinit();
    ll x,y;
    cin >> x >> y;
    if((x+y)%3!=0) cout << 0 << endl;
    else{
        ll n=(2*y-x)/3;
        ll m=(2*x-y)/3;
        if(n<0 || m<0) cout << 0 << endl;
        else{
            cout << COM(n+m,n) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[101][2][101];

void solve() {
    string N;
    cin >> N;
    int K;
    cin >> K;
    int L = N.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < L; ++i) {
        const int D = N[i] - '0';
        for (int smaller = 0; smaller < 2; ++smaller) {
            for (int k = 0; k <= K; ++k) {
                for (int d = 0; d <= (smaller ? 9 : D); ++d) {
                    if (d != 0) {
                        dp[i+1][smaller || (d < D)][k+1] += dp[i][smaller][k];
                    } else {
                        dp[i+1][smaller || (d < D)][k] += dp[i][smaller][k];
                    }
                }
            }
        }
    }
    cout << dp[L][0][K] + dp[L][1][K] << endl;
}

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


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  sort(l.begin(), l.end());
  int sum = 0;
  for (int i = n - k; i < n; ++i) sum += l[i];
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
    int a,b,c,d; cin >> a >> b >> c >> d;
    bool t = true;
    while (a > 0 && c > 0) {
        if(t){
          c -= b;
          t = !t;
        }
        else{
          a -= d;
          t = !t;
        }
    }
    if (t) puts("No");
    else
      puts("Yes");
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t;
  cin >> t;
  int s = t.size();
  if(t[0] == '?') t[0] = 'D';
  for(int i = 1; i < s-1; i++){
    if(t[i] == '?'){
      if(t[i-1] == 'D' && t[i+1] == 'D') t[i] = 'P';
      else if(t[i-1] == 'P') t[i] = 'D';
      else if(t[i-1] == 'D' && t[i+1] == 'P') t[i] = 'D';
      else t[i] = 'P';
    }
  }
  if(t[s-1] == '?') t[s-1] = 'D'; 
  cout << t << endl;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		if (((g * 10 + b) % 4) == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include<cstring>
#include<cstdio>

using namespace std;
bool mat[500][500];
int flags[500];
int main() {
    int n,m;
    while(cin >> n >> m){
        if(n==0&&m==0){
            break;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                mat[i][j]=false;
            }
        }
        for(int i=0;i<n;i++){
            flags[i]=0;
        }
        for(int i=0;i<m;i++){
            int a,b;
            cin >> a >> b;
            mat[a-1][b-1]=true;
            mat[b-1][a-1]=true;
        }
        for(int i=1;i<n;i++){
            if(mat[0][i]){
                flags[i]=1;
            }
        }
        for(int i=0;i<n;i++){
            if(flags[i]==1){
                for(int j=0;j<n;j++){
                    if(mat[i][j]&&flags[j]==0){
                        flags[j]=2;
                    }
                }
            }
        }
            
        
        int cnt=0;
        for(int i=0;i<n;i++){
            if(flags[i]){
                cnt++;
            }
        }
        if(cnt>0){
            cout << cnt-1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
#define str string
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };


const int N = 4e5 + 30;
const lli mod = 998244353;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-6;

lli bp(lli a, lli b = mod - 2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}
ostream& operator<<(ostream& c, pir a)
{
	c << a.fr << " " << a.sc;
	return c;
}



lli n, m, k;
lli pat, f[N];
lli c(int n, int k)
{
	return (((f[n] * bp(f[n - k])) % mod) * bp(f[k])) % mod;
}
int main()
{
	fastio;
	cin >> n >> m >> k;
	f[0] = 1;
	for (lli i = 1; i <= n; i++)
	{
		f[i] = f[i - 1] * i;
		f[i] %= mod;
	}
	for (lli i = k; i >= 0; i--)
	{
		pat += ((m * c(n - 1, i)) % mod) * bp(m - 1LL, n - i - 1LL);
		pat %= mod;
	}
	cout << pat << endl;
	return 0;
}


/*


  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/



Measured memory_bytes: 5204
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


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


int main() {

	
	priority_queue<int> que;

	string s;
	int n;
	while (cin >> s) {
		if (s == "end") {
			break;
		}else if (s == "extract") {
			cout << que.top() << endl;
			que.pop();
		}
		else
		{
			cin >> n;
			que.push(n);
		}
	}
	

	
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H+2,vector<char>(W+2));
  for(int j = 0; j<W+2;j++){
    vec.at(0).at(j) = '#';
  }
  for(int i = 1; i<H+1;i++){
    vec.at(i).at(0) = '#';
    for(int j= 1;j<W+1;j++){
      cin >> vec.at(i).at(j);
    }
    vec.at(i).at(W+1) = '#';
  }
  for(int j = 0; j<W+2;j++){
    vec.at(H+1).at(j) = '#';
  }
  
  for(int i = 0; i<H+2;i++){
    for(int j= 0;j<W+2;j++){
      cout << vec.at(i).at(j);
    }
    cout << endl;
  }
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    dic = {}
    n = int(input())
    if n == 0:
        break

    for i in range(n):
        key, value = input().split()
        dic[key] = value

    ret = ''

    m = int(input())
    for i in range(m):
        s = input().strip()
        ret += dic.get(s, s)

    print(ret)

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2005;
int n,l,r,a[N];

signed main(){
	read(n);read(l);read(r);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int dis;
			if(j<=l||i>=r) dis=j-i;
			else if(i<=l&&j>=r) dis=j-r+l-i+1;
			else if(i<=l) dis=min(j-i,r-j+1+l-i);
			else if(j>=r) dis=min(j-i,i-l+1+j-r);
			else dis=min(j-i,r-j+i-l+1);
			a[dis]++;
		}
	for(int i=1;i<n;i++) write(a[i]),puts("");
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	var jpy, btc float64
	for i := 0; i < n; i++ {
		var value float64
		var currency string
		_, _ = fmt.Scan(&value, &currency)
		switch currency {
		case "JPY":
			jpy += value
		case "BTC":
			btc += value
		}
	}
	fmt.Println(jpy + btc * 380000)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long a[N], b[N];
int n;

int main() {
    //freopen("009A.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        a[i] %= b[i];
    }
    long long res = 0;
    long long cnt = 0;
    for (int i = n; i >= 1; i--) {
        long long tmp = b[i] - a[i] - cnt;
        tmp %= b[i];
        if (tmp < 0) tmp += b[i];
        res += tmp;
        cnt += tmp;
    }
    cout << res << endl;
}


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

int main(){
  ll n;cin >> n;
  vector<ll> A(n);
  for(ll i=0; i<n; i++){
    cin >> A.at(i);
  }
  vector<ll> ans(n);
  bool flag = true;
  ans.at(0) = 0;
  for(ll i=0; i<n; i++){
    if(flag){ans.at(0) += A.at(i);flag = false;}
    else{ans.at(0) -= A.at(i);flag = true;}
  }
  for(ll i=1; i<n; i++){
    ans.at(i) = 2*(A.at(i-1) - ans.at(i-1)/2);
  }
  for(ll i=0; i<n; i++){
    cout << ans.at(i) << ' ';
  }
  cout << endl;
}

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

using namespace std;

int toint(string &str, int &i){
	int j = 0;
	while('0' <= str[i+j] && str[i+j] <= '9'){
		j++;
	}
	int ret = stoi(str.substr(i,j));
	ret = (ret+1)/2;
	i+=j;
	return ret;
}

int calc(string &str, int &i, int end){
	vector<int> v;
	int ret = 0;
	for(;i < end;i++){
		if(str[i] == '['){
			int idx = i+1;
			i++;
			int d = 1;
			while(1){
				if(str[idx] == ']') d--;
				else if(str[idx] == '[')d++;

				if(d == 0) break;
				idx++;
			}
			v.push_back(calc(str, i, idx));
			i = idx;
		}
		else if(str[i] == ']'){
			continue;
		}
		else{
			//cout << str[i] << endl;
			v.push_back(toint(str,i));
		}
	}
	sort(v.begin(), v.end());
	for(int j = 0; j < (v.size()+1)/2; j++){
		ret += v[j];
	}
	//for(int j = 0; j < v.size(); j++){
	return ret;
}


int main(){
	int nn; cin >> nn;
	for(int z = 0; z < nn; z++){
		string str;cin >> str;
		int i = 1;
		cout << calc(str, i, str.size()) << endl;
	}

	return 0;
}




Measured memory_bytes: 3208
N=int(input())
H=list(map(int,input().split()))
F=H
T=True
B=max(H)
C=H.index(max(H))
if B-H[N-1]>1 and B!=H[N-1]:
    T=False
if C==N-1 and N!=1:
    del H[N-1]
    B=max(H)
    H=F
    C=H.index(B)
if T:
    for i in range(N-1):
        if i>C:
            if H[i]+1<H[C]:
                T=False
if T:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63984
x1,y1,x2,y2=map(int,input().split())
x3=x2-(y2-y1)
y3=y2+(x2-x1)
x4=x3+(y2-y3)
y4=y3+(x3-x2)
print(str(x3)+' '+str(y3)+' '+str(x4)+ ' '+str(y4))

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    string s, t; cin >> s >> t;
    int sn = s.size(), tn = t.size();

    int dp[sn+1][tn+1];
    rep(i,sn+1) rep(j,tn+1) dp[i][j] = 0;

    rep(i,sn){
        rep(j,tn){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    /*
    rep(i,sn+1){
        rep(j,tn+1){
            cout << dp[i][j] << " ";
        }cout << endl;
    }
    */

    // 最長部分文字列を復元する処理
    int len = dp[sn][tn];
    string ans = "";
    int i = sn, j = tn;

    while(len){
        while(i>=0 && dp[i][j]==len) --i;
        while(j>=0 && dp[i+1][j]==len) --j;
        ans.push_back(s[i]);
        --len;
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 38768
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  bool sp[b];
  for(int i = 0; i < b; i++) {
    sp[i] = false;
  }
  int sum = 0;
  bool con = true;
  while(con) {
    sum += a;
    if(sp[sum % b]) {
      con = false;
      break;
    } else {
      sp[sum % b] = true;
    }
  }
  if(sp[c]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp> 

using namespace std;
using namespace boost::multiprecision;

int main(void) {

  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  long long S;
  for (long long i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  S = 1;
  for (long long  i = 0; i <= K - 1; i++) {
    S *= A.at(i);
  }
  //cout << S.at(K-1) << endl;
  for (long long i = 0; i < N - K; i++) {

    //cout << S.at(K+i) << endl;
    if (A.at(K+i) > A.at(i)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

}


Measured memory_bytes: 4836
# -*- coding:utf-8 -*-

N = int(input())
a = list(map(int,input().split()))

SUM_CARD = sum(a)
i=0

sum_before = a[i]
diff_sum = abs(sum_before*2-SUM_CARD)
i+=1

while(i<N-1):
    sum_before = sum_before + a[i]
    diff_sum_new = abs(sum_before*2-SUM_CARD)
    if diff_sum_new<diff_sum:
        diff_sum = diff_sum_new
    i += 1

print(diff_sum)


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

int main() {
    int n, k;
    int a[1002];
    cin >> n >> k;
    for (int i =0 ; i < n; i++) cin >> a[i];
    sort(a, a+n);
    for (int i = 1; i < k; i++) a[i] += a[i-1];
    cout << a[k-1];
   // system("pause");
}

Measured memory_bytes: 3160
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

bool good(char ch)
{
    return (ch=='A' || ch=='C' || ch=='G' || ch=='T');
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string s;
    cin>>s;
    int i,cs=0,ms=0;
    for(i=0;i<s.length();++i)
    {
        if(good(s[i]))
            ++cs;
        else
            cs=0;
        ms=max(ms,cs);
    }
    cout<<ms;


    return 0;
}


Measured memory_bytes: 256
let _ =
  let sum = ref 0. in
  Scanf.scanf " %d" @@ fun n ->
    for _ = 1 to n do
      Scanf.scanf " %f %s" @@ fun x u ->
        sum := !sum +. if u = "BTC" then x *. 380000.0 else x
    done;
  Printf.printf "%f\n" !sum

Measured memory_bytes: 512
def mod(val, mod_base):
  if val >= mod_base:
    return val%mod_base
  return val

# 配るDP
def resolve():
  base = 998244353
  N, K = map(int, input().split(" "))

  LRs = []
  for _ in range(K):
    (L, R) = map(int, input().split(" "))
    LRs.append((L, R))

  dp = [0] * (N+1)
  dp_sum = [0] * (N+1)
  dp[1] = 1
  dp_sum[1] = 1

  for i in range(1, N):
    dp_sum[i] = dp[i] + dp_sum[i-1]

    for lr in LRs:
      left = i + lr[0]
      right = i + lr[1] + 1
      if left <= N:
        dp[left] += dp_sum[i]
        dp[left] = mod(dp[left], base)
      if right <= N:
        dp[right] -= dp_sum[i]
        dp[right] = mod(dp[right], base)
  print(mod(dp[-1], base))

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 76720
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        w: i64, h: i64, x: i64, y: i64
    }
    let val = (w * h) as f64 / 2.0;
    let dup = if 2 * x == w && 2 * y == h {
        1
    } else {
        0
    };
    puts!("{} {}\n", val, dup);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	string d[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string x;
	cin >> x;
	for (int i = 0; i < 7; ++i) {
		if (d[i] == x) {
			PRI(7 - i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
import numpy as np
from numba import njit, i8


@njit(i8[:](i8[:]), cache=True)
def max_acc(li):
    res = li.copy()
    cur_max = res[0]
    for i in range(len(li)):
        if res[i] > cur_max:
            cur_max = res[i]
        res[i] = cur_max
    return res


@njit(i8(i8, i8, i8[:, :]), cache=True)
def solve(R, C, goods):
    dp = np.zeros(C + 1, dtype=np.int64)
    for i in range(R):
        dp[1:] += goods[i]
        dp = max_acc(dp)
        for _ in range(2):
            dp[1:] = np.maximum(dp[:-1] + goods[i], dp[1:])
            dp = max_acc(dp)
    return dp[-1]


R, C, K, *rcv = map(int, open(0).read().split())
goods = np.zeros((R, C), dtype=np.int64)
for r, c, v in zip(*[iter(rcv)] * 3):
    goods[r - 1][c - 1] = v
print(solve(R, C, goods))


Measured memory_bytes: 203024
#include<bits/stdc++.h>
using namespace std;
#define kmax 1009

bool solve(int*arr, int n){
  	int ab = true;
  	for(int i = 0;i<n;i++){
      	if( (arr[i]%2 == 0) && (arr[i]%3 != 0 && arr[i]%5 != 0)){
           ab = false;
        }
  
    }
 
  return ab;
}



int main(){
 	int arr[kmax];
  	int n;cin>>n;
  	for(int i = 0;i<n;i++){
		cin>>arr[i];      
      
    }
 	
  if(solve(arr,n)) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  
  return 0;
}

Measured memory_bytes: 256