akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
/*long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}*/
/*void set_levels(int cur, int dont){
	level[cur] = level[dont] + 1;
	parent[cur] = dont;
	for(int i = 0; i < vec[cur].size(); i++){
		if(vec[cur][i] != dont) set_levels(vec[cur][i], cur);
	}
}*/
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string n; int k; cin>>n>>k;
	ll dp[n.length()][k+1][2] = {};
	for(int i = 0; i < n.length(); i++){
		if(i == 0){
			dp[i][0][0]++;
			for(int u = 1; u < n[0] - '0'; u++){
				dp[i][1][0]++;
			}
			dp[i][1][1]++;
			continue;
		}
		//dp[i][0][0] = dp[i-1][0][0] + dp[i-1][0][1];
		for(int u = 0; u < n[i] - '0'; u++){
			if(!u){
				for(int j = 0; j <= k; j++){
					dp[i][j][0] += dp[i-1][j][1];
				}
			}else
			for(int j = 1; j <= k; j++){
				dp[i][j][0] += dp[i-1][j-1][1]; 
			}
		}
		for(int j = 0; j <= k; j++){
			dp[i][j][0] += dp[i-1][j][0];
		}
		for(int u = 1; u <= 9; u++){
			for(int j = 1; j <= k; j++){
				dp[i][j][0] += dp[i-1][j-1][0];
			}
		}
		if(n[i] - '0'){
			for(int j = 1; j <= k; j++){
				dp[i][j][1] = dp[i-1][j-1][1];
			}
		}else{
			for(int j = 0; j <= k; j++)
				dp[i][j][1] = dp[i-1][j][1];
		}
	}
	cout<<dp[n.length()-1][k][0] + dp[n.length()-1][k][1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=305,INF=1<<28;
int dis[MAX][MAX];
int N;

void floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin>>N;
        if(N==0) break;
        int M,A,B,C;cin>>M>>A>>B>>C;
        A--;
        B--;
        C--;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) dis[i][j]=INF;
            dis[i][i]=0;
        }
        
        for(int i=0;i<M;i++){
            int a,b,c;cin>>a>>b>>c;
            a--;b--;
            dis[a][b]=c;
        }
        
        floyd();
        
        int ans=INF;
        
        for(int i=0;i<N;i++){
            ans=min(ans,dis[A][i]+dis[i][B]+dis[i][C]);
        }
        
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 3172
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int main(){
    int n,x,mi=1e9,ma=-1e9,idi,ida;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x>ma){ma=x;ida=i;}
        if(x<mi){mi=x;idi=i;}
    }
    printf("%d\n",n*2);
    if(abs(mi)>abs(ma)){
        printf("%d %d\n%d %d\n",idi,n,idi,n);
        for(int i=n;i>1;i--)
            printf("%d %d\n%d %d\n",i,i-1,i,i-1);
    }
    else{
        printf("%d %d\n%d %d\n",ida,1,ida,1);
        for(int i=1;i<n;i++)
            printf("%d %d\n%d %d\n",i,i+1,i,i+1);
    }
    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void solve() {
    while (true) {
        ll N;
        cin >> N;
        if (N == 0) break;
        vector<ll> A(N);
        rep(i, N) cin >> A[i];
        vector<ll> dp(N + 1, -INF);
        rep(i, N) {
            dp[i + 1] = max(dp[i] + A[i], A[i]);
        }
        ll ans = *max_element(dp.begin(), dp.end());
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	int kotae = 0;
	int V[20], C[20];
	rep(i, N) cin >> V[i];
	rep(i, N) cin >> C[i];
	rep(i, N) {
		if (V[i] > C[i]) kotae += V[i] - C[i];
	}

	co(kotae);

	Would you please return 0;
}

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

int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}
int main(){
    int data;
    cin>>data;
    for(int i=0;i<data;i++){
        int m,n;
        cin>>m>>n;
        int cnt=0;
        for(int p=-200;p<=200;p++){
            for(int q=-200;q<=200;q++){
                if(p==0 && q==0) continue;
                int g=p*p+q*q;
                int val1=p*m+q*n;
                int val2=p*n-q*m;
                if(val1%g==0 && val2%g==0){
                    cnt++;
                }
            }
        }
        cout<<(cnt==8 ? "P" : "C")<<endl;
    }

    return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	//変数の宣言
	int c[3][3];
	int check[3]={0,0,0};
	int i,j,t;
	int flag=0;
	
	//データの読み込み
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			t=scanf("%d", &c[i][j]);
		}
	}
	
	//実際の処理
	for(i=0;i<2;i++){
		for(j=0;j<3;j++){
			check[j]=c[i+1][j]-c[i][j];
		}
		if(check[0]!=check[1]) flag=1;
		if(check[1]!=check[2]) flag=1;
		
		for(j=0;j<3;j++){
			check[j]=c[j][i+1]-c[j][i];
		}
		if(check[0]!=check[1]) flag=1;
		if(check[1]!=check[2]) flag=1;
	}
	
	//出力
	if(flag==0){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int count[4][3][10]={{{0}}};

int main(void){
   int n,i,j,k;
   int b,f,r,v;
   cin >>n;
   for(i=0;i<n;i++){
       cin >>b>>f>>r>>v;
       count[b-1][f-1][r-1] += v;
   }
   for(i=0;i<3;i++){
       for(j=0;j<3;j++){
           for(k=0;k<10;k++){
               cout <<" "<<count[i][j][k];
           }
           cout <<endl;
       }
       if(i < 3) {
           cout <<"####################"<<endl;
       }
   }
   for(j=0;j<3;j++){
       for(k=0;k<10;k++){
               cout <<" "<<count[i][j][k];
            }
        cout <<endl;
    }
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 998244353;
int c[202020];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if ((z == 0) != (i == 0))
		{
			printf("0\n");
			return 0;
		}
		c[z]++;
	}
	ll r = 1;
	for (int i = 1; i <= num; i++)for (int j = 0; j < c[i]; j++)r = r*c[i - 1] % mod;
	printf("%lld\n", r);
}

Measured memory_bytes: 640
# include <iostream>
# include <cstdio>
# include <algorithm>
# include <queue>
# include <vector>
# include <cstring>
# include <algorithm>
# include <map>
using namespace std;
long long N,X,D;
typedef pair<long long ,long long > P;
map <int ,vector<P> > m;
int main(void){
    // freopen("aaa.in","r",stdin);
    scanf("%lld%lld%lld",&N,&X,&D);
    // cout<<N<<X<<D<<endl;
    if (D==0){
        if (X) cout<<N+1<<endl;
        else cout<<1<<endl;
        return 0;
    }
    for (long long i=0;i<=N;i++){
        long long t = (X*i)%D;
        long long l,r;
        l = X*i/D + i*(i-1)/2;
        r = X*i/D + (2*N-i-1)*i/2;
        // cout<<t<<"  "<<l<<"  "<<r<<endl;
        m[t].push_back(make_pair(l,r));
    }
    long long ans = 0;
    map <int ,vector<P> >::iterator i;
    for ( i = m.begin();i!=m.end();i++)
    {
        sort(i->second.begin(),i->second.end());
        long long l , r;
        l = i->second[0].first;
        r = i->second[0].second;
        int len = i->second.size();
        for (int j=1;j<len;j++){
            if (i->second[j].first<=r) r = max (r,i->second[j].second);
            else{
                ans+=(r-l+1);
                l = i->second[j].first;
                r = i->second[j].second;
            }
        }
        ans+=(r-l)+1;
    }
    printf("%lld\n",ans);
    return 0;   
}



Measured memory_bytes: 22144
/* 問題文
 * 高橋君は，いつも頭の中に整数を 1 つ思い浮かべています．
 * 
 * はじめ，高橋君が思い浮かべている整数は 0 です． これから，高橋君は + または - の記号を，あわせて 4 つ食べようとしています． 高橋君が + を食べると，思い浮かべている整数は 1 大きくなります． 一方，高橋君が - を食べると，思い浮かべている整数は 1 小さくなります．
 * 
 * 高橋君が食べようとしている記号は，文字列 S で与えられます． S の i 文字目は，高橋君が i 番目に食べる記号です．
 * 
 * すべての記号を食べ終わった後，高橋君が思い浮かべている整数を求めてください．
 * 
 * 制約
 * S の長さは 4
 * S の各文字は + または */

#include <stdio.h>

int main(){
    int ans = 0;
    char line[4];

    scanf("%s", line);
    
    for(int i=0; line[i]!='\0'; i++){
        if(line[i] == '+')
            ans++;
        else
            ans--;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

int main() {
    ll n, p; cin >> n >> p;
    if (n == 1) {cout << p << endl; return 0;}
    int ans = 0;
    for (int i = 1; pow(i,n) <= p; i++) {
        if (p % (ll)pow(i,n) == 0) ans = max(ans,i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int s,w;cin>>s>>w;
    if(s>w)cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
        print(ans)
    else:
        print(0)
    return

#D
def D():
    n = II()
    a = LI()
    a = a + [a[0]]
    ans = [0] * n
    x = 0
    for i in range(1, n, 2):
        x = x + a[i + 1] - a[i]
    ans[1] = a[0] - x
    ans[0] = ans[1] + 2 * x
    for i in range(2, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(" ".join(map(str, ans)))

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


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


def run_prime_factorization(max_number: int) -> dict:
    '''Run prime factorization.
    Args:
        max_number: Int of number (greater than 1).
    Returns:
        A dictionary's items ((base, exponent) pairs).
    Landau notation: O(log n)
    '''

    from math import sqrt

    ans = dict()
    remain = max_number

    for base in range(2, int(sqrt(max_number)) + 1):
        if remain % base == 0:
            exponent_count = 0

            while remain % base == 0:
                exponent_count += 1
                remain //= base

            ans[base] = exponent_count

    if remain != 1:
        ans[remain] = 1

    return ans


def main():
    a, b = map(int, input().split())

    # KeyInsight:
    # x, yが互いに素であることと，x, yの最大公約数が1であることは同値
    # 素因数分解して，共通の素因数をすべて選ぶ
    count = 1
    result_a = run_prime_factorization(a)
    result_b = run_prime_factorization(b)
    count += len(result_a.keys() & result_b.keys())
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int flg,n[4];
void func(int sum,int cnt){
	if(cnt<3){
		func(sum-n[cnt],cnt+1);
//		cout<<0<<' '<<sum<<' '<<n[cnt]<<endl;
		if(flg==1) cout<<'+'<<n[cnt];
		else {
			func(sum+n[cnt],cnt+1);
//			cout<<1<<' '<<sum<<' '<<n[cnt]<<endl;
			if(flg==1) cout<<'-'<<n[cnt];
		}
	}
	else if(sum==0) flg=1;
}
int main(void){
	int i,j;
	char a[5];
	cin>>a;
	j=0;
	for(i=3;i>=0;i--){
		n[j]=a[i]-'0';
		j++;
	}
	flg=0;
	cout<<n[3];
	func(7-n[3],0);
	cout<<"=7"<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
XS = gets.split.map(&:to_i)
YS = gets.split.map(&:to_i)

XS.unshift(0)
YS.unshift(0)

MOD = 10 ** 9 + 7

n = 0
(1..N).each do |k|
  n += ((k - 1) * XS[k]) - ((N - k) * XS[k])
end
m = 0
(1..M).each do |k|
  m += ((k - 1) * YS[k]) - ((M - k) * YS[k])
end
p (n * m) % MOD

Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.
long long int power(long long int x, unsigned long long  int y)
{
    long long res = 1,m=y+2;
    x%=m;
    while (y > 0) {
        if (y & 1)
            res = res * x%m;
        x = x * x%m;
        y >>= 1;
    }
    return res;
}
long long int modInverse(long long int a,long long  int m=MOD)
{
            return power(a, m-2);
 
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    LL t=1;//cin>>t;
    while(t--){
      LL n,i;cin>>n;
      LL fac[10040];fac[0]=1;
      fo(i,1,10040) fac[i]=i*fac[i-1],fac[i]%=MOD;
      LL ans=0;
      fo(i,1,n+1){
        if(n-2*i-1<0||n-3*i<0) break;
        ans+=(fac[n-2*i-1]*modInverse(fac[i-1])%MOD)*modInverse(fac[n-3*i])%MOD;
        ans%=MOD;
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3712
import math
a, b, x = map(int, input().split())
remain = a * a * b - x
ans = 0
if remain <= x:
    c = remain / a / a * 2
    ans = math.degrees(math.atan2(c, a))
else:
    c = x / a / b * 2
    ans = math.degrees(math.atan2(b, c))
print(ans)


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

int main(){
  int n;
  cin >> n;
  int ans = 0, index = 1;
  while(index <= n){
    int count = 0;
    for(int i = 1;i <=index;i++){
      if(index % i == 0)count++;
    }
    if(count == 8)ans++;
    index +=2 ;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
var Main = input => {
    var args = input.split("\n");
    // var num_count = args[0];
    var num_list = args[1].split(" ");
    var input_sum = num_list.reduce((acc, cur) => Number(acc) + Number(cur));
    var half = Math.ceil(input_sum / 2.0);
    var sum = 0;
    var i = 0;
    for (; i < num_list.length; i++) {
        sum += Number(num_list[i]);
        if (sum >= half) {
            break;
        }
    }
    console.log(Math.min(Math.abs(input_sum - sum * 2), Math.abs(input_sum - (sum - Number(num_list[i])) * 2)));
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
const int N=100010,Mod=998244353;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
string s;
int n,ans[N];
int main()
{
  cin>>s;
  n=s.size();
  char cur='R';
  int count[2],last_index;
  count[0]=count[1]=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]==cur) count[i%2]++;
    else
    {
      if(s[i]=='L')
      {
        last_index=i-1;
        ans[last_index]+=count[(last_index)%2];
        ans[last_index+1]+=count[(last_index+1)%2];
      }
      else
      {
        ans[last_index]+=count[(last_index)%2];
        ans[last_index+1]+=count[(last_index+1)%2];
      }
      count[0]=0;
      count[1]=0;
      cur=s[i];
      count[i%2]++;
    }
  }
  ans[last_index]+=count[last_index%2];
  ans[last_index+1]+=count[(last_index+1)%2];
  for(int i=0;i<n;i++) cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}


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

#define rep(i, n)       rep2(i, 0, n)
#define rep2(i, m, n)   for(int i = m; i < (int)(n); ++i)
#define X real()
#define Y imag()

typedef complex<double> Pt;

const double EPS = 1e-9;

int main()
{
    int n;
    while (cin >> n, n) {
        double x, y;
        vector<Pt> p;
        rep (i, n) {
            cin >> x >> y;
            p.push_back(Pt(x, y));
        }
        
        int ans = 1;
        rep (i, n) rep2 (j, i + 1, n) {
            double d = abs(p[i] - p[j]);
            if (d > 2.0) continue;
            
            Pt m = (p[i] + p[j]) / 2.0;
            Pt v = Pt(p[i].Y - p[j].Y, p[j].X - p[i].X);
            v /= abs(v);
            v *= sqrt(1.0 - d * d / 4.0);
            
            int t1 = 0, t2 = 0;
            Pt c1 = m + v, c2 = m - v;
            rep (k, n) {
                if (abs(p[k] - c1) < 1.0 + EPS) ++t1;
                if (abs(p[k] - c2) < 1.0 + EPS) ++t2;
            }
            ans = max(max(t1, t2), ans);
        }
        
        cout << ans << endl;        
    }
}

Measured memory_bytes: 1272
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <numeric>
using namespace std;
using ll = long long;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+8
#define PI acos(-1)
#define TAU PI * 2
const ll MOD = 1000000007;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    string ok;

    int at = a;
    int bt = c;

    while(true){
        // 高橋くん
        bt -= b;
        if(bt <= 0){
            ok = "Yes";
            break;
        }

        // 青木くん
        at -= d;
        if(at <= 0){
            ok = "No";
            break;
        }
    }

    println(ok);
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {

int W, H, x,y,r;
cin>>W>>H>>x>>y>>r;

if(x>=r&&y>=r&&W>=x+r&&H>=y+r)
    cout<<"Yes"<<endl;
else cout<<"No"<<endl;
    
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[110][100010];
int w[100010];
int v[100010];

int main()
{
    int n,w_limit;
    cin >> n >> w_limit;
    rep(i,n)
    {
        cin >> w[i] >> v[i];
    }
    rep(i,n)
    {
        rep(j,w_limit+1)
        {
            chmax(dp[i+1][j], dp[i][j]);
            int nj = j+w[i];
            if (nj<=w_limit)
            {
                chmax(dp[i+1][nj], dp[i][j]+v[i]);
            }
        }
    }
    cout << dp[n][w_limit] << endl;
}

Measured memory_bytes: 78592
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]
def main():
    n=int(input())
    mod=10**9+7
    ans=1
    for p in P:
        if p>n: break
        c = 1
        d = p
        while d<=n:
            c += n//d
            d *= p
        ans *= c%mod
    print(ans%mod)    
main()

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, min = 0, ma = 0, ans = 0, ansb = 0, count = 0, countb, crowdy[101] = {}, bu = 0;
	int reset = 0, w = 0;
	char hairetu[200] = {};
	int number[10000], price[10000], sort[100000] = {}, kisu[10000] = { 100000 }, gusu[10000] = { 100000 };
	using namespace std;
	int x = 0, y = 0, z = 0, play[200] = {}, acount = 0, bcount = 0;
	std::string toki, tokit, fun, funt;
	int cake = 4, cookie = 7;
	bool okada = true;
	cin >> a;

	int cnt = 0;
	for (int j = 1; j <= a; j++) {
		cnt = 0;
		for (int i = 1; i <= j; ++i) {
			if (j % i == 0) {

				cnt++;
			
			}
		
		}
		if (j % 2 == 1) {
			if (cnt == 8) {
				x++;
			
			}
		}
	}
	
	cout << x << endl;
		
	
	return 0;
	
}


Measured memory_bytes: 256
import sys
readline=sys.stdin.readline
read=sys.stdin.read

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1
    ans=0
    for i in range(ek):
        if k>>i&1:
            m=(k>>(i+1))<<(i+1)|((1<<i)-1)
            ans=max(ans,sum((e[1] for e in ab if e[0]|m==m)))
    ans=max(ans,sum((e[1] for e in ab if e[0]|k==k)))
    print(ans)

if __name__=='__main__':
    main()


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n,m;cin>>n>>m;
    V l(m),r(m);
    rep(i,m)cin>>l[i]>>r[i];
    sort(RALL(l));
    sort(ALL(r));
    //cout<<r[0]<<l[0]<<endl;
    cout<<(r[0]>=l[0]?r[0]-l[0]+1:0)<<endl;
}


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

typedef long long LL;

const int N=3000,mod=998244353;

int a,b,c,d;
LL dp[N+9][N+9];

void work(){
  scanf("%d%d%d%d",&a,&b,&c,&d);
  dp[a][b]=1;
  for (int i=a;i<=c;++i)
	for (int j=b;j<=d;++j){
	  if (i==a&&j==b) continue;
	  if (i>a) dp[i][j]+=dp[i-1][j]*j;
	  if (j>b) dp[i][j]+=dp[i][j-1]*i;
	  if (i>a&&j>b) dp[i][j]-=dp[i-1][j-1]*(i-1)*(j-1);
	  dp[i][j]=(dp[i][j]%mod+mod)%mod;
	}
  printf("%lld\n",dp[c][d]);
}

int main(){
  int T=1;
  //scanf("%d",&T);
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 74108
#include <bits/stdc++.h>
#define N 3500
using namespace std;
int mem[N][N];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s, w;
    vector <char> path;
    cin >> s >> w;
    memset(mem, 0, sizeof(mem));
    int m = s.size();
    int n = w.size();
    for(int i = m - 1;i >= 0;i--)
    {
        for(int j = n - 1;j >= 0;j--)
        {
            if(s[i] == w[j])
            {
                mem[i][j] = 1 + mem[i + 1][j + 1];
            }
            else
            {
                int a= mem[i+1][j];
                int b = mem[i][j + 1];
                mem[i][j] = max(a , b);
            }
        }
    }
    if(mem[0][0] != 0){
    for(int i = 0;i < m;i++)
    {
        for(int j = 0;j < n;j++)
        {
            int a = mem[i+1][j];
            int b = mem[i][j+1];
            int c = max(a, b);
            if(c == mem[i][j])
            {
                if(mem[i][j] == a)
                {
                    i++;
                    j--;
                    continue;
                }
                else
                {
                    continue;
                }
            }
            else
            {
                path.push_back(s[i]);
                if(path.size() == mem[0][0])
                    break;
                i++;
                continue;
            }
        }
        if(path.size() == mem[0][0])
            break;
    }
    if(path.empty() != 1)
        for(int i = 0;i < path.size();i++)
            cout << path[i];
    if(path.empty() != 1)
        cout << endl;}
    return 0;
}

Measured memory_bytes: 51476
N = int(input())
Red = [0] * N
Blue = [0] * N
for j in range(N):
    Red[j] = [0] * 2
    Red[j][0], Red[j][1] = map(int, input().split())
for k in range(N):
    Blue[k] = [0] * 2
    Blue[k][0], Blue[k][1] = map(int, input().split())
Blue = sorted(Blue)
Red = sorted(Red)
ans = 0
for i in range(N):
    kouho = -1
    blue_x = Blue[i][0]
    blue_y = Blue[i][1]
    kouho_y = -1
    for p in range(len(Red)):
        if blue_x > Red[p][0]:
            if kouho_y < Red[p][1] <blue_y:
                kouho_y = Red[p][1]
                kouho = p
        else:
            continue
    if kouho >= 0:
        ans += 1
        del Red[kouho]

print(ans)
#print(Red)
#print(Blue)


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

int main(){
	int n = 1 , a , b ;
	cin >> a >> b ;
	if( a > 0 && b > 0 ){
		cout << "Positive" ;
	}
	if( a > 0 && b < 0 ){
		cout <<"Zero" ;
	}
	if( a < 0 && b > 0 ){
		cout << "Zero" ;
	}
	if( a == 0 || b == 0 ){
		cout << "Zero" ;
	}
	if( a < 0 && b < 0 ){
		if( a < b )
			swap( a , b ) ;
		if( ( a - b + 1 ) % 2 == 1 ){
			cout << "Negative" ;
		}
		if( ( a - b + 1 ) % 2 == 0 ){
			cout << "Positive" ;
		}
	}
}


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

typedef long long ll;
const int N = 508;

int mod;
int n;
int l[N], u[N], left[N], right[N];
int stdo[N], f[N][N];

int work(int K) {
	int i, j, k, id; **f = 1;
	for (i = 0; i < 2 * n; ++i)
		if ((id = stdo[i]) < n) {
			for (j = left[i], k = n + K - 1; j >= 0; --j, ++k)
				f[i + 1][j + 1]	= (f[i][j + 1] * ll(u[id] - k) + f[i][j] * ll(l[id] - right[i] - j)) % mod;
			f[i + 1][0] = f[i][0] * ll(u[id] - k) % mod;
		} else for (j = 0; j <= left[i]; ++j) f[i + 1][j] = f[i][j] * ll(u[id] - right[i] - j) % mod;
	return f[2 * n][K];
}

int main() {
	int i; ll ans = 0;
	scanf("%d%d", &n, &mod);
	for (i = 0; i < 2 * n; ++i) l[i] = u[i] = 1 + (int)sqrt(4 * n * n - i * i), stdo[i] = 2 * n - i - 1;
	for (i = 0; i < n; ++i) l[i] = ceil(sqrt(n * n - i * i)); *u = 2 * n;
	std::inplace_merge(stdo, stdo + n, stdo + 2 * n, [] (const int x, const int y) {return l[x] < l[y];});
	for (i = 0; i < 2 * n; ++i)
		left[i + 1] = left[i], right[i + 1] = right[i], stdo[i] < n ? ++left[i + 1] : ++right[i + 1];
	for (i = 0; i <= n; ++i) i & 1 ? ans -= work(i) : ans += work(i);
	ans %= mod, printf("%d\n", int(ans + (ans >> 63 & mod)));
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>
#define N 10000
int Prime(int);
int main(){
  int k[N],n;
  int i,num=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k[i]);
    if(Prime(k[i])==0)num++;
  }
  printf("%d\n",num);
  return 0;
}
int Prime(int x){
  int j,num=0;
  if(x==2)return 0;
 else if(x%2==0)return 1;
  for(j=3;j<=sqrt(x);j+=2){
    if(x%j==0){
      num=1;
      break;
    }
  }
  return num;
}



Measured memory_bytes: 2060
# -*- coding: utf-8 -*-
n = int(input())
v = list(map(lambda x: int(x), input().split(' ')))


import collections
even_frq_dict = collections.defaultdict(int)
len_even = 0
for i in range(0, n, 2):
    even_frq_dict[v[i]] += 1
    len_even += 1

len_odd = 0
odd_frq_dict = collections.defaultdict(int)
for i in range(1, n, 2):
    odd_frq_dict[v[i]] += 1
    len_odd += 1


even_frqs = list(sorted(list(even_frq_dict.items()), key=lambda x: x[1]))
odd_frqs = list(sorted(list(odd_frq_dict.items()), key=lambda x: x[1]))

if len(even_frqs) == 1 and len(odd_frqs) == 1:
    if even_frqs[0][0] == odd_frqs[0][0]:
        print(min(len_even, len_odd))
    else:
        print(0)
    exit()
elif len(even_frqs) == 1:
    print(len_odd - odd_frqs[-1][1])
    exit()
elif len(odd_frqs) == 1:
    print(len_even - even_frqs[-1][1])
    exit()


e_num1, e_frq1 = even_frqs[-1]
e_num2, e_frq2 = even_frqs[-2]
o_num1, o_frq1 = odd_frqs[-1]
o_num2, o_frq2 = odd_frqs[-2]

ans = 0
if e_num1 == o_num1:
    cnd1 = (len_even - e_frq2) + (len_odd - o_frq1)
    cnd2 = (len_even - e_frq1) + (len_odd - o_frq2)
    ans = min(cnd1, cnd2)

else:
    ans = (len_even - e_frq1) + (len_odd - o_frq1)

print(ans)



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

int get_root(int i, int wood[])
{
    while (wood[i] != -1)
    {
        i = wood[i];
    }
    return i;
    // if (wood[i] == -1)
    // {
    //     return i;
    // }
    // return get_root(i, wood);
    // return wood[i] == -1 ? i : get_root(wood[i], wood);
}

int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    int wood[n];
    int depth[n] = {0};
    rep(i, n) wood[i] = -1;

    int a, b;
    int friends[n] = {0};
    rep(i, m)
    {
        scanf("%d%d", &a, &b);
        a--;
        b--;
        friends[a]++;
        friends[b]++;
        a = get_root(a, wood);
        b = get_root(b, wood);
        if (depth[a] > depth[b])
            swap(a, b);
        if (a != b)
        {
            depth[b] = depth[b] > depth[a] + 1 ? depth[b] : depth[a] + 1;
            wood[a] = b;
        }
        // rep(i, n)
        // {
        //     printf("%d ", wood[i]);
        // }
        // printf("\n");
    }
    int group_num[n] = {0};
    rep(i, n)
    {
        int idx = get_root(i, wood);
        group_num[idx]++;
    }
    int ans[n] = {0};
    rep(i, k)
    {
        scanf("%d%d", &a, &b);
        a--;
        b--;
        if (get_root(a, wood) == get_root(b, wood))
        {
            ans[a]--;
            ans[b]--;
        }
    }
    rep(i, n)
    {
        printf("%d ", ans[i] + group_num[get_root(i, wood)] - friends[i] - 1);
    }
    printf("\n");
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int a;
  cin >> a;
  
  if (a == 1) {
    cout << "Hello World" << endl;
  } else {
    int b, c;
    cin >> b >> c;
    cout << b + c << endl;    
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
int main()
{
    int N; cin >> N;
    string S; cin >> S;
    int x = 0, xmax = 0;
    REP(i, N) {
        if (S[i] == 'I') x++;
        else x--;
        xmax = max(xmax, x);
    }
    cout << xmax << endl;
    return 0;
}

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

int main(){
  int n, a, b, c, d;
  cin >> n;
  a = n / 1000;
  b = (n / 100) % 10;
  c = (n / 10) % 10;
  d = n - 1000 * a - 100 * b - 10 * c;
  
  if ((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl; 
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2> inline bool relax(T1& a, const T2& b) {
    return a > b ? a = b, true : false;
}

template <typename T1, typename T2> inline bool strain(T1& a, const T2& b) {
    return a < b ? a = b, true : false;
}

// :::::::::::::::::::::::::::::::

void solve() {
    int n;
    cin >> n;
    
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    
    vector<int> l(n + 1, -1), r(n + 1, -1);
    for (int i = 0; i < n; ++i)
        r[a[i]] = i;
    for (int i = n - 1; i >= 0; --i)
        l[b[i]] = i;
    
    int mx = 0;
    for (int i = 0; i <= n; ++i)
        if (r[i] != -1 && l[i] != -1)
            strain(mx, r[i] - l[i] + 1);
    
    vector<int> res(n);
    for (int i = 0; i < n; ++i)
        res[(i + mx) % n] = b[i];
    for (int i = 0; i < n; ++i) {
        if (res[i] == a[i]) {
            cout << "No\n";
            return;
        }
    }
    
    cout << "Yes\n";
    for (int i : res)
        cout << i << ' ';
    cout << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


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

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

    if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3))
        puts("Bad");
    else
        puts("Good");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int sum(const int x){
	int xx=x;
	int cnt=0;
	while(xx){
		cnt+=xx%10;
		xx/=10;
	}
	return cnt;
}
int main(){
	int x;
	scanf("%d",&x);
	if(x%sum(x)==0)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let t: String = read(&mut stdin_lock, &mut buf, b'\n');

    let sv: Vec<char> = s.chars().collect();
    let tv: Vec<char> = t.chars().collect();
    let mut ans = 0;

    for i in 0..sv.len() {
        if sv[i] == tv[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc149/tasks/abc149_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int R_MAX = 1e4;
const int S_MAX = 1e4;
const int P_MAX = 1e4;

int N, K;
int R, S, P;
char T[N_MAX + 1];

int sc[3];
int dp[2][3];

int get_hand(char c) {
  if (c == 'r') return 0;
  if (c == 's') return 1;
  return 2;
}

void solve() {
  sc[0] = R; sc[1] = S; sc[2] = P;
  int ans = 0;
  REP(i, K) {
    fill(dp[0], dp[2], 0);
    auto cur = dp[0];
    auto nxt = dp[1];
    for (int j = i; j < N; j += K) {
      fill(nxt, nxt + 3, 0);
      int cp = get_hand(T[j]);
      REP(pl0, 3) REP(pl1, 3) {
        if (pl0 == pl1) continue;
        if ((3 + cp - pl1) % 3 == 1) {
          nxt[pl1] = max(nxt[pl1], cur[pl0] + sc[pl1]);
        } else {
          nxt[pl1] = max(nxt[pl1], cur[pl0]);
        }
      }
      swap(cur, nxt);
    }
    ans += *max_element(cur, cur + 3);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
  scanf("%d%d%d", &R, &S, &P);
  scanf("%s", T);
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pii pair <int, int>
#define xx first
#define yy second
#define LL long long
using namespace std;

const int N = 100100;
int a[N], b[N];
priority_queue <pii, vector <pii>, greater <pii> > q;

int main ()
{
//    freopen ("in", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        scanf ("%d", &a[i]);
        q.push (pii (a[i], 1));
    }
    for (int i = 1; i <= m; i++) {
        scanf ("%d", &b[i]);
        q.push (pii (b[i], 2));
    }
    int c1 = 0, c2 = 0;
    LL res = 0;
    while (!q.empty ()) {
        pii tmp = q.top();
        q.pop();
        if (tmp.yy == 1) {
            c1++;
            res += 1LL * (m + 1 - c2) * tmp.xx;
        } else {
            c2++;
            res += 1LL * (n + 1 - c1) * tmp.xx;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=b && a>=c){cout<<b+c<<endl;return 0;}
    else if(a<=b && b>=c){
        cout<<a+c<<endl;
        return 0;
    }else{
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    if (a != c) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  } else if (a == c) {
    if (a != b) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  } else if (c == b) {
    if (a != c) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  }else{
    cout << "No";
  }
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

struct Node {
    i64 val;
    Node *p, *l, *r;
    Node() {}
    Node(i64 v) : val(v), p(nullptr), l(nullptr), r(nullptr) {}
};

struct Tree {
    Node* root;

    Tree() : root(nullptr) {}

    void insert(i64 val) {
        auto cur = root;
        Node* p  = nullptr;
        Node* x  = new Node(val);
        while (cur) {
            p = cur;
            if (x->val < cur->val) {
                cur = cur->l; // 左に移動
            } else {
                cur = cur->r; // 右に移動
            }
        }
        x->p = p;

        if (!p) {
            root = x;
        } else if (x->val < p->val) {
            p->l = x;
        } else {
            p->r = x;
        }
    }

    void dump_preorder(const Node* cur) const {
        if (!cur) {
            return;
        }
        cout << " " << cur->val; // 自身
        dump_preorder(cur->l);   // 左
        dump_preorder(cur->r);   // 右
    }

    void dump_preorder() const {
        dump_preorder(root);
    }

    void dump_inorder(const Node* cur) const {
        if (!cur) {
            return;
        }
        dump_inorder(cur->l);    // 左
        cout << " " << cur->val; // 自身
        dump_inorder(cur->r);    // 右
    }

    void dump_inorder() const {
        dump_inorder(root);
    }
};

//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    auto tree = Tree();
    rep(i, 0, N) {
        string s;
        cin >> s;
        if (s == "insert") {
            i64 v;
            cin >> v;
            tree.insert(v);
        } else {
            tree.dump_inorder();
            cout << "\n";
            tree.dump_preorder();
            cout << "\n";
        }
    }
}



Measured memory_bytes: 26564
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    ArrayList<Double> v = new ArrayList<>();

    for (int i = 0; i < N; i++) {
      v.add(scn.nextDouble());
    }

    Collections.sort(v);
    double ans = v.stream().reduce(v.get(0), (average, elem) -> (elem + average) / 2.0);
    System.out.println(ans);
  }

}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int n,k,l;
  cin>>n>>k>>l;
  vector<int> hen[n],den[n];
  int a,b;
  for(int i=0;i<k;i++){
    cin>>a>>b;
    hen[a-1].push_back(b-1);
    hen[b-1].push_back(a-1);
  }
  for(int i=0;i<l;i++){
    cin>>a>>b;
    den[a-1].push_back(b-1);
    den[b-1].push_back(a-1);
  }
  int ban[n];k=0;
  queue<int> que;
  bool used[n]={};
  for(int i=0;i<n;i++){
    if(used[i])continue;
    used[i]=true;
    que.push(i);
    while(!que.empty()){
      a=que.front();
      que.pop();
      ban[a]=k;
      for(int j=0;j<hen[a].size();j++){
        if(!used[hen[a][j]]){
          que.push(hen[a][j]);
          used[hen[a][j]]=true;
        }
      }
    }
    k++;
  }
  map<pair<int,int>,int> mp;
  pair<int,int> p[n];
  k=0;for(int i=0;i<n;i++)used[i]=false;
  for(int i=0;i<n;i++){
    if(used[i])continue;
    used[i]=true;
    que.push(i);
    while(!que.empty()){
      a=que.front();
      que.pop();
      p[a]=make_pair(ban[a],k);
      mp[make_pair(ban[a],k)]++;
      for(int j=0;j<den[a].size();j++){
        if(!used[den[a][j]]){
          que.push(den[a][j]);
          used[den[a][j]]=true;
        }
      }
    }
    k++;
  }
  for(int i=0;i<n;i++)cout<<mp[p[i]]<<' ';
  return 0;
}


Measured memory_bytes: 32116
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	if(a+b == c || a+c == b || b+c == a) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_variables)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::mem::swap;
use std::io::prelude::*; // input()

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
fn main() {
    let sx = input::<i64>();
    let sy = input::<i64>();
    let tx = input::<i64>();
    let ty = input::<i64>();
    let mut s = String::new();
    for _ in sy..ty {
        s.push('U');
    }
    for _ in sx..tx {
        s.push('R');
    }
    for _  in sy..ty {
        s.push('D');
    }
    for _ in sx..tx {
        s.push('L');
    }

    s.push('L');
    for _ in sy..ty {
        s.push('U');
    }
    s.push('U');
    for _ in sx..tx {
        s.push('R');
    }
    s.push('R');
    s.push('D');

    s.push('R');
    for _ in sy..ty {
        s.push('D');
    }
    s.push('D');
    for _ in sx..tx {
        s.push('L');
    }
    s.push('L');
    s.push('U');
    println!("{}", s);
}
//UURDDLLUUURRDRDDDLLU
//UURDDLLUUURRDRDDDLLU


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

typedef long long ll;

int main(void)
{
    //freopen("input.txt", "r", stdin);

    int n, i, val, cnt = 1;
    cin >> n;
    int big;
    cin >> big;
    for(i = 1; i < n; i++)
    {
        cin >> val;
        if(val <= big)
        {
            big = val;
            cnt++;
        }
    }
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int a, b, x;
  cin >> a >> b >> x;
 
  if (a <= x && b > x - a) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}


Measured memory_bytes: 3708