akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	u64 N, K;
	cin >> N >>K;

	u64 mod = 998244353;
	vector<pair<u64, u64>> S(K);

	for(u64 i=0; i<K; i++) {
		u64 L, R;
		cin >> L >> R;
		S[i] = make_pair(L, R);
	}
	
	vector<u64> sum(N);
	sum[0] = 1;

	for(s64 i=1; i<N; i++) {
		u64 dp = 0;

		for(const auto& lr : S) {
			s64 R = i - lr.first;
			if(R >= 0) {
				dp = (dp + sum[R]) % mod;
				s64 L = i - lr.second - 1;
				if(L >= 0) {
					dp = (dp >= sum[L]) ? dp - sum[L] : dp + mod - sum[L];
				}
			}
		}
		
		sum[i] = (sum[i-1] + dp) % mod;
	}

	u64 ans = (sum[N-1] >= sum[N-2]) ? sum[N-1] - sum[N-2] : sum[N-1] + mod - sum[N-2];
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    int n;
    cin >> n;

    vector<ll> a(n+1);
    rep(i, n + 1) cin >> a[i];

    if (a[0] == 1 && n == 0) {
        cout << 1 << endl;
        return 0;
    }

    if (a[0] > 0) {
        cout << -1 << endl;
        return 0;
    }


    vector<ll> b(n + 1, 0);
    b[n] = a[n];

    for (int i = n - 1; i >= 0; i--) {
        b[i] = b[i + 1] + a[i];
    }

    vector<ll> c(n + 1, 0);
    c[0] = 1;
    for (int i = 1; i <= n; i++) {
        c[i] = (c[i - 1] - a[i - 1]) * 2;
        chmin(c[i], b[i]);

        if (c[i] < a[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll res = 0;
    rep(i, n + 1) {
        res += c[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5572
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b;

	cin>>a>>b;

	if(a+b==15){
		cout<<"+"<<endl;
	} else if(a*b==15){
		cout<<"*"<<endl;
	} else{
		cout<<"x"<<endl;
	}
}


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

void chmax(double& a, double b) {
  if (a < b) a = b;
}

int main() {
  int N, K;
  cin >> N >> K;
  
  double p[N];
  for (int i = 0; i < N; i++) {
    double a;
    cin >> a;
    p[i] = (a + 1) / 2;
  }
  
  double sum = 0;
  for (int i = 0; i < K; i++) {
    sum += p[i];
  }
  double ans = sum;
  
  for (int i = 0; i < N-K; i++) {
    sum -= p[i];
    sum += p[K+i];
    chmax(ans, sum);
  } 
  cout << fixed << setprecision(8) << ans << endl;
  
}



Measured memory_bytes: 1792
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def dfs(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    stack = [(0,start)]
    
    while stack:
        cost, cur_node = stack.pop()

        # 未探索のノードをstackに入れる
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                stack.append((dist[nex_node],nex_node))
                
    return dist

def isnibu(graph:list, dist:list) -> bool:
    for i,edges in enumerate(graph):
        for _, j in edges:
            if dist[i]%2 == dist[j]%2:
                return False
    
    return True
    
    

n,m = li()

adj_lst = [set() for _ in range(n)]

for _ in range(m):
    a,b = li_()
    
    adj_lst[a].add((1,b))
    adj_lst[b].add((1,a))
    
dist = dfs(adj_lst, n, 0)

nibu = isnibu(adj_lst, dist)

ans = 0
if isnibu(adj_lst, dist):
    ans = sum([dist[i]%2 == 1 for i in range(n)]) * sum([dist[i]%2 == 0 for i in range(n)]) - m
    
else:
    ans = n*(n-1)//2 - m
    
print(ans)

Measured memory_bytes: 53892
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    long long int n;
    cin>>n;
    vector<string>a(10000000);
    vector<int>b(4);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]=="AC"){
            b[0]++;
        }
        else if(a[i]=="WA"){
            b[1]++;
        }
        else if(a[i]=="TLE"){
            b[2]++;
        }
        else{
            b[3]++;
        }
        
    }
    cout<<"AC x "<<b[0]<<endl;
    cout<<"WA x "<<b[1]<<endl;
    cout<<"TLE x "<<b[2]<<endl;
    cout<<"RE x "<<b[3]<<endl;
    
}


Measured memory_bytes: 315836
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N;
	cin >> N;
	vl Acount(N+10, 0);
	vl A(N);
	rep(i, N) {
		cin >> A[i];
		Acount[A[i]]++;
	}
	ll ans = 0;
	rep(i, N + 10) {
		if (Acount[i] > 0) {
			ans += Acount[i] * (Acount[i] - 1) / 2;
		}
	}
	rep(i, N) {
		ll anstmp = ans;
		ll Atmp = A[i];
		anstmp -= (Acount[A[i]] - 1);
		cout << anstmp << endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  deque<char> deq;
  string input; cin >> input;
  FOR(i,0,input.length()-1){
    deq.PB(input[i]);
  }
  int q; cin >> q;
  bool isrev = false;
  FOR(i,0,q-1){
    int t; cin >> t;
    if(t==1){
      isrev = !isrev;
    }
    else{
      int f; cin >> f;
      char c; cin >> c;
      if(isrev) f = (f+1);
      if(f==3) f=1;

      if(f==1){
        deq.push_front(c);
      } else {
        deq.PB(c);
      }
    }
  }
  if(isrev){
    FORD(i,deq.size()-1,0){
      cout << deq[i];
    }
  } else {
    FOR(i,0,deq.size()-1){
      cout << deq[i];
    }
  }  
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
bool judge(string s,char t){
    for(char c:s)if(c != t)return false;
    return true;
}
main(){
    string S;
    cin >> S;
    int minc = INF;
    for(char c = 'a';c <= 'z';c++){
        if(S.find(string(1,c)) == -1)continue;
        string str = S;
        for(int j = 0;j <= 100;j++){
            if(judge(str,c)){
                minc = min(minc,j);
                break;
            }
            string sub;
            for(int i = 0;i < str.length()-1;i++){
                if(str[i] == c || str[i+1] == c) sub += c;
                else sub += str[i];
            }
            str = sub;
        }
    }
    cout << minc << endl;
}   

Measured memory_bytes: 256
#include<iostream>
#include<set>

#include<vector>

using namespace std;

int A, B;
int start;
set<int> st;

int main(){
    cin >> A >> B;
    if(A%2==0) start =12.5*A;
    else start = (int)(12.5*A)+ 1;
    for(int i=start; i< (int)(12.5*(A+1));i++){
        st.insert(i);
    }
    for(int j=((int) 10*B); j<(int) (10*(B+1));j++){
        if(st.find(j)!=st.end()){
        //if(find(v.begin(), v.end(),j)!=v.end()){
            cout << j << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  	cin>>s;
  
 	if(s[0]+s[1]+s[2]==294 && s[0]*s[1]*s[2]==97*98*99){
		cout<<"Yes"<<endl;
    }else{
		cout<<"No"<<endl;
    }
}
	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
 
int main() {
    char ch;
    int counter[26] = {};
    while ( scanf("%c", &ch) != EOF) {
        if (isalpha(ch)) {
            counter[tolower(ch) - 'a']++;
        }
    }
 
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", 'a' + i, counter[i]);
    }
}

Measured memory_bytes: 3212
import copy

n=int(input())
a=[]
ans=0
for _ in range(n):
  b=list(map(int,input().split()))
  ans+=sum(b)
  a.append(b)
  
c=copy.deepcopy(a)
  
for i in range(n):
  for j in range(n):
    ch=0
    for k in range(n):
      if c[i][j]==c[i][k]+c[k][j] and ch==0 and i!=k and j!=k:
        ans-=c[i][j]
        ch+=1
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])
      
if a==c:
  
  print(ans//2)
  
else:
  print(-1)

Measured memory_bytes: 77128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
const int INF = 1000000009;

typedef std::pair<int, int> P;
int n, c;
int recorded[30];//[i]はチャンネル[i]ではこの番組から録画されていないことを示す
std::vector<P> list[30];

int main(){
	scanf("%d%d", &n, &c);
	for(int i = 0; i < n; i++){
		int s, t, c1;
		scanf("%d%d%d", &s, &t, &c1);
		list[c1-1].push_back(P(s, t));
	}
	for(int i = 0; i < c; i++){
		sort(list[i].begin(), list[i].end());
	}
	std::priority_queue<int, std::vector<int>, std::greater<int> > que;
	int ans = 0;
	while(1){
		/*/
		for(int i = 0; i < c; i++){
			printf("%d ", recorded[i]);
		}
		printf("\n");
		//*/
		int start = INF;
		int channel = -1;
		for(int i = 0; i < c; i++){
			if(recorded[i] >= list[i].size()){
				continue;
			}
			if(list[i][recorded[i]].first < start){
				start = list[i][recorded[i]].first;
				channel = i;
			}
		}
		if(channel == -1){
			break;
		}
		int end = list[channel][recorded[channel]].second;
		recorded[channel]++;
		for(int i = recorded[channel]; i < list[channel].size(); i++){
			if(list[channel][i].first == list[channel][i-1].second){
				end = list[channel][i].second;
				recorded[channel]++;
			}else{
				break;
			}
		}
		//printf("%d %d\n", start, end);
		if(que.empty() || que.top() >= start){
			/*/
			if(!que.empty()){
				printf("%d >= %d\n", que.top(), start);
			}
			//*/
			ans++;
			que.push(end);
		}else{
			que.pop();
			que.push(end);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#define NMAX 100
using namespace std;
int N;
char s[NMAX],n[NMAX];
int hantei(int r){
	int l = 209;
	for (int i = 0; i < r; ++i)
	{
		if(s[N-r+i] != n[i]){
			l = min(l,N*2);
			break;
		}else if(i == r-1){
			l = min(l,N*2-r);
		}
	}
	for (int i = 0; i < r; ++i)
	{
		if(s[i] != n[N-r+i]){
			l = min(l,N*2);
			break;
		}else if(i == r-1){
			l = min(l,N*2-r);
		}
	}
	// cout << l << "\n";
	return l;
}
int main(){
	int l = 210;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> s[i];
	}
	for (int i = 0; i < N; ++i)
	{
		cin >> n[i];
	}
	for (int i = 1; i < N+1; ++i)
	{
		l = min(l,hantei(i));
	}
	cout << l << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N; cin >>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  bool iro[8];
  rep(i,8){
    iro[i]=false;
  }
  int count=0;
  rep(i,N){
    if(a.at(i)<400)iro[0]=true;
    if(a.at(i)>=400&&a.at(i)<800)iro[1]=true;
    if(a.at(i)>=800&&a.at(i)<1200)iro[2]=true;
    if(a.at(i)>=1200&&a.at(i)<1600)iro[3]=true;
    if(a.at(i)>=1600&&a.at(i)<2000)iro[4]=true;
    if(a.at(i)>=2000&&a.at(i)<2400)iro[5]=true;
    if(a.at(i)>=2400&&a.at(i)<2800)iro[6]=true;
    if(a.at(i)>=2800&&a.at(i)<3200)iro[7]=true;
    if(a.at(i)>=3200)count++;
  }
  int irokazu=0;
  rep(i,8){
    if(iro[i]==true)irokazu++;
  }
  if(irokazu==0){
    irokazu=1;
    count=N-1;
  }
  cout<<irokazu<<" "<<irokazu+count<<endl;
  return 0;
}

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

int main(){
  int N,M;cin >> N >> M;
  vector<int> ve(N,0);
  vector<stack<int>> ed(N);
  for(int i=0;i<M;i++){
    int X,Y,Z;cin >> X >> Y >> Z;
    ve[X-1]=1;ve[Y-1]=1;
    ed[X-1].push(Y-1);ed[Y-1].push(X-1);
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(ve[i]==0) ans++;
    else if(ve[i]==1){
      ans++;
      queue<int> q;q.push(i);
      while(q.empty()!=true){
        int p=q.front();q.pop();ve[p]=2;
        while(ed[p].empty()!=true){
          if(ve[ed[p].top()]==1) q.push(ed[p].top());
          ed[p].pop();
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 68608
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,t; cin >> n >> t;
	vector<pair<double,P>> other;
	vl zero;
	rep(i,n){
		ll a,b; cin >> a >> b;
		if(a==0) zero.push_back(b);
		else other.emplace_back(a/(double)(b+1),P(a,b));
	}
	sort(rall(other)), sort(all(zero));
	if(!zero.empty()){
		zero[0]++;
		rep(i,zero.size()-1) zero[i+1] += zero[i] + 1;
	}
	ll N = other.size();
	vvl dp(N+1,vl(30,linf));
	dp[0][0] = 0;
	rep(i,N){
		rep(j,30){
			if(dp[i][j] > t) continue;
			chmin(dp[i+1][j], dp[i][j]);
			ll tmp = dp[i][j] + 1 + (dp[i][j]+1)*other[i].second.first + other[i].second.second;
			if(tmp <= t) chmin(dp[i+1][j+1],tmp);
		}
	}
	ll ans = 0;
	rep(i,30){
		if(dp[N][i] > t) continue;
		if(zero.empty()){
			chmax(ans,i); continue;
		}
		auto itr = upper_bound(all(zero),t - dp[N][i]);
		chmax(ans, i + itr - zero.begin());
	}
	cout << ans << endl;
}

Measured memory_bytes: 59756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef pair<int, int> P;
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;
}
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};
const int INF = 1001001001;

int q;
vector<pair<string, string>> dataset;

int main() {
  cin >> q;
  dataset.resize(q);

  rep(i, q) {
    string x, y;
    cin >> x >> y;
    dataset[i] = make_pair(x, y);
  }

  vector<int> ans;

  for (auto&& data : dataset) {
    string x, y;
    tie(x, y) = data;

    vector<vector<int>> dp(x.size() + 1, vector<int>(y.size() + 1, 0));

    rep(i, x.size()) {
      rep(j, y.size()) {
        if (x[i] == y[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]);
        }
      }
    }

    ans.push_back(dp[x.size()][y.size()]);
  }

  for (auto&& i : ans) {
    printf("%d\n", i);
  }
}



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

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

    if(a == b and b == c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
//*/
using namespace std;
static const int _ = []() {
	ios::sync_with_stdio(false);
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	return 0;
}();
// I hate typing .first or .second
template<typename T, typename U>
struct par {
	T x;
	U y;
	par() :x(-1), y(-1) {}
	par(const T& x, const U& y) :x(x), y(y) {}
	bool operator<(const par& other) const {
		if (x == other.x) return y < other.y;
		return x < other.x;
	}
	bool operator==(const par& other) const {
		return x == other.x && y == other.y;
	}
	par operator-(const par& b) const {
		return { x - b.x, y - b.y };
	}
};
#define ll long long
#define ull unsigned long long
#define rep(i,a) for(ll i=0;i<(a);i++)
#define rp1(i,a) for(ll i=1;i<=(a);i++)
#define rng(i,a,b) for(ll i=(a);i<=(b);i++)
#define rev(i,a) for(ll i=(a)-1;i>=0;i--)
#define S size()
#define all(a) (a).begin(),(a).end()
#define any(i,a) for(auto& i:a)
#define pll par<ll,ll>
#define pii par<int,int>
#define X first
#define Y second
#define V vector
#define VL V<ll>
#define VVL V<VL>
#define VS V<string>
template<class T> inline vector<T> rv(ll n) { vector<T> v(n); rep(i, n) cin >> v[i]; return v; }
template<class T> inline void pv(const vector<T>& v) { rep(i, v.size()) cout << v[i] << " "; cout << endl; }
template<class T> inline void amax(T& a, const T& b) { if (a < b) a = b; }
template<class T> inline void amin(T& a, const T& b) { if (a > b) a = b; }
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}
	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
ll GCD(ll a, ll b) {
	while (b) {
		ll r = a % b;
		a = b;
		b = r;
	}
	return a;
}



int main(int argc, char** argv) {
	ll H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << ((H - h) * (W - w)) << endl;

	return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String str = br.readLine();

		int l = 0;
		int r = n + 2;

		String[] subRights = new String[n];
		for(int i = 0; i < n; i++){
			subRights[i] = str.substring(i);
		}

		while(r - l > 1){
			int mid = (l + r)/2;

			boolean hit = false;
			for(int i = 0; i <= n - 2*mid; i++){
				String subLeft = str.substring(i, i + mid);
				char[] leftArray = subLeft.toCharArray();
				char[] rightArray = subRights[i + mid].toCharArray();
//				String subRight = str.substring(i + mid);

//				if(subRight.contains(subLeft)){
//				if(subRights[i + mid].contains(subLeft)){
				if(RKSearcher.indexOf(leftArray, rightArray) >= 0){
//				if(BMSearcher.indexOf(rightArray, leftArray) >= 0){
					hit = true;
					break;
				}
			}

			if(hit){
				l = mid;
			}
			else {
				r = mid;
			}
		}

		System.out.println(l);
	}

}

class RKSearcher {
	private static final long q = 10000000007L;
	private static final int d = 64;

	public static int indexOf(char[] str1, char[] str2){
		int M = str1.length;
		int N = str2.length;
		long dM = 1;
		long h1 = 0;
		long h2 = 0;

		//?????????????????°???????????????equals???????????°??????
		if(M == N){
			if(new String(str1).equals(new String(str2))){
				return 0;
			}
			else {
				return -1;
			}
		}

		else if (M > N){
			return -1;
		}

		for(int i = 1; i < M ; i++){
			dM = (d*dM)%q;
		}

		for(int i = 0; i < M; i++){
			h1 = (h1*d + index(str1[i])) % q;
			h2 = (h2*d + index(str2[i])) % q;
		}
		int i;
		for(i = 0; h1 != h2 ;i++){
			//System.out.println("i = "+i+" h1 "+h1+" h2 "+h2);
			h2 = (h2 + d*q - index(str2[i])*dM) % q;
			if(i+M >= N){
				return -1;
			}
			h2 = (h2*d + index(str2[i+M])) % q;
			if (i > N-M){
				return -1;
			}
		}
		return i;
	}

	private static int index(char c){
		//return c - '0' + 1;
		//??°??????0~9
		if(c >=  '0' && c <= '9'){
			return c - '0';
		}
		//?°??????????10~35
		else if (c >= 'a' && c <= 'z'){
			return c - 'a' + 10;
		}
		//??§?????????36~61
		else if (c >= 'A' && c <= 'Z'){
			return c - 'A' + 36;
		}
		else {
			return -1;
		}
	}
}



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

public class Main {
	static int[][] math;
	static final int MATH_LENGTH = 12;

	public static void main(String[] args) throws IOException {
		//?????°????????????
		math = new int[14][14];
		int x = 0, y = 0;
		int scale = 0;

		//??\???????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inputStr = null;
		while (true) {
			inputStr = br.readLine();
			if (inputStr == null || inputStr.isEmpty()) {
				break;
			}
			//??\???????????????","??§??????
			String[] inputSplitStr = inputStr.split(",");
			x = Integer.valueOf(inputSplitStr[0]);
			y = Integer.valueOf(inputSplitStr[1]);
			scale = Integer.valueOf(inputSplitStr[2]);

			// ???????????´???????????????????¨????
			switch (scale) {
			case 1: //???????????´????°????
				setSmallInk(x + 2, y + 2);
				break;
			case 2: //???????????´?????????
				setMediumInk(x + 2, y + 2);
				break;
			case 3: //???????????´?????§???
				setLargeInk(x + 2, y + 2);
				break;
			}
		}
		//???????????¶????????????????????¨?????????????????????????????????
		int whiteNumber = 0;
		int mostNumber = 0;
		for (int i = 2; i < MATH_LENGTH; i++) {
			for (int j = 2; j < MATH_LENGTH; j++) {
				if (math[i][j] == 0) {
					whiteNumber++;
				}
				if (mostNumber < math[i][j]) {
					mostNumber = math[i][j];
				}
			}
		}
		System.out.println(whiteNumber);
		System.out.println(mostNumber);
	}

	private static void setSmallInk(int x, int y) {
		math[x - 1][y]++;
		math[x][y - 1]++;
		math[x][y]++;
		math[x][y + 1]++;
		math[x + 1][y]++;
	}

	private static void setMediumInk(int x, int y) {
		math[x - 1][y - 1]++;
		math[x - 1][y]++;
		math[x - 1][y + 1]++;

		math[x][y - 1]++;
		math[x][y]++;
		math[x][y + 1]++;

		math[x + 1][y - 1]++;
		math[x + 1][y]++;
		math[x + 1][y + 1]++;
	}

	private static void setLargeInk(int x, int y) {
		math[x - 2][y]++;

		math[x - 1][y - 1]++;
		math[x - 1][y]++;
		math[x - 1][y + 1]++;

		math[x][y - 2]++;
		math[x][y - 1]++;
		math[x][y]++;
		math[x][y + 1]++;
		math[x][y + 2]++;

		math[x + 1][y - 1]++;
		math[x + 1][y]++;
		math[x + 1][y + 1]++;

		math[x + 2][y]++;
	}
}

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

int main() {
    long long n ,m, ans=0;
    cin >> n >> m;
    if(n<m) swap(n,m);
    if(n>=3 && m>=3) ans=(n-2)*(m-2);
    else if(n>1 && m==1) ans=n-2;
    else if(n==1 && m==1) ans=1;
    else ans=0;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
bool check(ll n){
    bool flag = true;
    for(ll i=2;i<n;i++){
        if(n%i==0){
            flag = false;
            break;
        }
    }
    return flag;
}
int main(){
    ll ans;
    cin >> ans;
    while(!check(ans)){
        ans++;
    }
  	cout << ans << endl;
    return 0;
 
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
int inf = 1000000000;
ll INF = 1000000000000000000;
ll n, a, b, h[100010], hh[100010], hmax;
bool truefalse(ll t) {
	ll ans = 0;
	rep(i, n)hh[i] = h[i] - t * b;
	rep(i, n)if (hh[i] > 0)ans += (hh[i] + a - b - 1) / (a - b);
	if (ans > t)return false;
	else return true;
}
int main() {
	cin >> n >> a >> b;
	rep(i,n){
		cin >> h[i];
		hmax = max(hmax, h[i]);
	}
	sort(h, h + n);
	ll MIN = 0, MAX = hmax;
	while (MAX - MIN > 1) {
		ll MID = (MIN + MAX) / 2;
		if (truefalse(MID))MAX = MID;
		else MIN = MID;
	}
	cout << MAX << endl;
	return 0;

}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
const int inf = (int)1e9;

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}
 
 


 
int main(void){
	int n;
	cin>>n;
	vector<int>a(n+1);
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans = 0;
	for(int i=1;i<=n;i++){
		if((i%2==1)&&(a[i]%2==1))ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);

        final String S = sc.next();
        sc.close();
        int len = S.length();

        if(!isPalindrome(S)){
            System.out.println("No");
            return;
        }

        String s1 = S.substring(0, (len - 1) / 2);
        String s2 = S.substring((len + 3) / 2 - 1);

        if(!isPalindrome(s1) || !isPalindrome(s2)){
            System.out.println("No");
            return;
        }

        System.out.println("Yes");
    }
    static boolean isPalindrome (String s) {
        int n = s.length();
        for (int i=0; i<n/2; i++) {
            if (s.charAt(i)!=s.charAt(n-i-1)) {return false;}
        }
        return true;
    }
}

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

int main() {
    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<vector<int>> dp((1 << n), vector<int>(51, 1e8));
    dp[0][0] = 0;
    auto chmin = [](int &a, int b) { a = min(a, b); };
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<pair<int, int>> rem;
        int ite = 0;
        for (int i = 0; i < n; i++) {
            if ((1 << i) & bit) ite++;
        }
        int cnt = ite;
        for (int i = 0; i < n; i++) {
            if (!((1 << i) & bit)) rem.push_back({i, cnt++});
        }

        for (int s = 0; s <= 50; s++) {
            for (auto p : rem) {
                int i0 = p.first;
                int i1 = p.second;

                int x = abs(i0 - ite) % 2 ? b[i0] : a[i0];
                if (x >= s) {
                    chmin(dp[bit | (1 << i0)][x], dp[bit][s] + abs(i1 - ite));
                }
            }
        }
    }
    int ans = 1e8;
    for (int i = 0; i <= 50; i++) {
        chmin(ans, dp[(1 << n) - 1][i]);
    }
    if (ans == 1e8)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

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

int main(){
  int s[10000],t[500];
  int count = 0;
  int n,q;
  int i,j;

  cin >> n;

  for(i = 0 ; i < n ; i++){
    cin >> s[i];
  }

  cin >> q;

  for(i = 0 ; i < q ; i++){
    cin >> t[i];
  }

  for(i = 0 ; i < q ; i++){
    for(j = 0 ; j < n ; j++){
      if(s[j] == t[i]){
	count++;
	break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1200
N = int(input())
S = input()
ans = 0
for i in range(N):
	cnt = 0
	type_flont= sorted(set(S[:i]),key=S.index)
	type_back= sorted(set(S[i:N]),key=S.index)
	for j in range(len(type_back)):
		if(type_back[j] in type_flont):
			cnt+=1
	if(ans < cnt):
		ans = cnt
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    rep(i, m) {
        int a;
        cin >> a;
        sum += a;
    }
    n -= sum;
    if(n < 0) cout << -1 << endl;
    else cout << n << endl;
    
    return 0;
}

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	int n;
	scanf("%d",&n);
	
	int xx = 0;
	int yy = 0;
	int tt = 0;
	bool valid = true;
	for (int i = 0; i < n; i += 1)
	{
		int t;
		scanf("%d",&t);
		
		int x,y;
		scanf("%d %d",&x,&y);
		
		int dx = abs(xx-x);
		int dy = abs(yy-y);
		
		int dt = t-tt;
		
		if (dx+dy > dt)
		{
			valid = false;
		}
		else
		{
			int extra = dt-(dx+dy);
			
			if (extra % 2 != 0)
				valid = false;
		}
		
		xx = x;
		yy = y;
		tt = t;
	}
	
	if (valid)
		printf("Yes\n");
	else
		printf("No\n");
		
	return 0;
}

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

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  ll first = v[0];
  for (int i = k; i < n; ++i) {
    if(first < v[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
    first = v[i-k+1];
  }
}


Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
 
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
 
int main(void){
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, 1, n + 1) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

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

int main(int argc, char *argv[])
{
    int num;
    double x1, x2, x3, y1, y2, y3, px, py, r;
    int i = 0;

    scanf("%d\n", &num);
    while(i < num) {
        scanf("%lf %lf %lf %lf %lf %lf\n", &x1, &y1, &x2, &y2, &x3, &y3);
        
        px = ((y1 - y3) * (pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2)) - (y1 - y2) * (pow(x1, 2) - pow(x3, 2) + pow(y1, 2) - pow(y3, 2))) / (2 * ((x1 - x2) * (y1 - y3) - (x1 - x3) * (y1 - y2)));
        py = ((x1 -x3) * (pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2)) - (x1 - x2) * (pow(x1, 2) - pow(x3, 2) + pow(y1, 2) - pow(y3, 2))) / (2 * ((x1 -x3) * (y1 - y2) - (x1 - x2) * (y1 - y3)));
        r = sqrt(pow(px - x1, 2) + pow(py - y1, 2));
        printf("%.03lf %.03lf %.03lf\n", px, py, r);
        i++;
    }
    
    return 0;
}

Measured memory_bytes: 668
#include<iostream>
#include<algorithm>
using namespace std;
main() {
  for(int n;cin>>n,n;) {
    int dat[100];
    for(int i=0;i<n;i++)
      cin>>dat[i];
    int ans = 0;
    for(int i=0;i<n-1;i++)
      for(int j=n-1;j>i;j--)
	if(dat[j-1]>dat[j]) swap(dat[j-1],dat[j]), ans++;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1156
#include<cmath>
#include<string>
#include<fstream>
#include<iostream>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,a,b) for(int i=a;i<(int)(b);i++)

using namespace std;

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	int sum=0;
	rep(i,1,N+1) {
		int n=i;
		int num=0;
		do{
			num+=n%10;
			n/=10;
		}while(n!=0);
		if(num>=A&&num<=B) sum+=i;
	}
	cout << sum << endl;;
	return 0;
}

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

#define INF 1000000000
#define LM 55555
using namespace::std;


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

int A,B,C,X,Y,N, M,num,v[55555],ch,ans,hit[300000];
string s, t[1000];
bool a, b, c;
int main() {
	cin >> N;
	cin >> s;
	for (int i = 1; i < N; i++) {
		if (s[i] == 'E') {
			hit[0]++;
		}
	}
	ans = hit[0];
	for (int i = 1; i < N; i++) {
		hit[i] = hit[i - 1];
		if (s[i] == 'E'&&s[i-1]=='W') {
			
		}
		if (s[i] == 'E'&&s[i - 1] == 'E') {
			hit[i]--;
		}
		if (s[i] == 'W'&&s[i - 1] == 'W') {
			hit[i]++;
		}
		if (s[i] == 'W'&&s[i - 1] == 'E') {
			
		}
		if (hit[i] < ans) {
			ans = hit[i];
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 1796
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String[] str = new String[2];
		int count = 0; 
		while(in.hasNext()) {
			String buf = in.nextLine();
			str[count] = buf;
		}
		
		String[] split = str[0].split(" ");
		int facter[];
		facter = new int[split.length];

		for ( int i = 0; i < split.length; i++) {
			facter[i] = Integer.parseInt(split[i]);
			
		}
		//swap
		if ( facter[0] < facter[1]) {
			int temp = facter[0];
			facter[0] = facter[1];
			facter[1] = temp;

		}
		
		int r = 0; 
		int x = facter[0];
		int y = facter[1];
		
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		System.out.println(x);
		
		
		
	}

}

Measured memory_bytes: 26176
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    A, B, M = map(int, sys.stdin.readline().split())
    As = list(map(int, sys.stdin.readline().split()))
    Bs = list(map(int, sys.stdin.readline().split()))
    Xs, Ys, Cs = map(list, zip(*(tuple(map(int, sys.stdin.readline().split())) for _ in range(M))))

    # 割引券なしの場合の最安値
    nocoupon = min(As) + min(Bs)

    # 割引券を使った場合
    coupon = min(As[Xs[i] - 1] + Bs[Ys[i] - 1] - Cs[i] for i in range(M))

    print(min(nocoupon, coupon))

if __name__ == '__main__':
    main()

Measured memory_bytes: 37432
#include<iostream>
using namespace std;
int main(){
    int n,k,i,j,ans=0;
    cin>>n>>k;
    int arr[n+1], dp[n+1];
    for(i=1;i<=n;i++)
        cin>>arr[i];
    dp[1] = 0;
    for(i=2;i<=n;i++){
        ans = INT_MAX;
        for(j=i-1;j>=i-k && j>=1;j--){
            ans = min(ans, dp[j] + abs(arr[i] - arr[j]));
        }
        dp[i] = ans;
    }
    cout<<dp[n];
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    string aa;
    cin>>a>>b;
    cin>>aa;
    for(int i=0;i<a+b;i++)
    {
        if(aa[a]!='-')
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(i!=a)
        {
            if(!(aa[i]>='0'&&aa[i]<='9'))
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl; 
    return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N, K;
    cin >> N >> K;
    i32 R, S, P;
    string T;
    cin >> R >> S >> P >> T;
    i32 ans = 0;
    auto score = [&](char c) {
        if (c == 'r') return P;
        else if (c == 's') return R;
        else if (c == 'p') return S;
    };
    for (i32 i = 0; i < K; i++) {
        bool lose = false;
        for (i32 j = i; j < N; j += K) {
            if (j - K >= 0) {
                if (T[j - K] != T[j]) {
                    ans += score(T[j]);
                    lose = false;
                } else if (lose) {
                    lose = false;
                    ans += score(T[j]);
                } else {
                    lose = true;
                }
            } else {
                ans += score(T[j]);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <vector>
int main() {
    int n;
    std::cin >> n;

    long long ans = 1UL;
    bool hasZero  = false;
    std::vector<long double> a(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a.at(i);
        if (a.at(i) == 0) hasZero = true;
    }
    if (hasZero) {
        std::cout << "0\n";
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        if (std::log10(a.at(i)) + std::log10((long double)ans) > 18.0000001) {
            std::cout << "-1\n";
            return 0;
        }
        ans *= (long long)a.at(i);
        if (ans > 1'000'000'000'000'000'000) {
            std::cout << "-1\n";
            return 0;
        }
    }
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4908
x, y = map(int,input().split())

ans = 0

for i in range(x+1):
    for j in range(x+1):
        if 2*i + 4 * j == y and i + j == x:
            ans += 1
            
if ans > 0:
    print('Yes')
else:    
    print('No')

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
    long long int H,N;
    cin>>H>>N;
    long long int A[N];
    for(long long int i=0;i<N;i++){
        cin>>A[i];
        H-=A[i];
    }
    if(H<=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<climits>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define asc(a,n) sort(a,a+n);
#define dsc(a,n) sort(a,a+n,comp);
#define fo(i,x,y) for(int i=x;i<y;i++)
#define inarr(x) int n; cin>>n; int x[n]; fo(i,0,n){cin>>x[i];}
#define test int t; cin>>t; while(t--)
using namespace std;

int basic(){freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);return 0;}
bool comp(int a,int b){return a>b;}



int32_t main()
{// basic(); 
  fast;
  char s[200000];
  int n;
  cin>>n;
  unordered_set <string> stringSet ;
  fo(i,0,n)
  {
    cin>>s;
     if (stringSet.find(s) == stringSet.end()) {stringSet.insert(s) ;}
    
  } cout<<stringSet.size();


  
}







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

int main(){
    int cases;
    scanf("%d", &cases);

    int ac = 0, wa = 0, tle = 0, re = 0;

    for(int i = 0; i < cases ; i++){
        char chances[100];
        scanf("%s", chances);

        int length = strlen(chances);

        if(chances[0] == 'A'){
            ac++;
        }
        else if(chances[0] == 'W'){
            wa++;
        }
        else if(chances[0] == 'T'){
            tle++;
        }
        else if (chances[0] == 'R'){
            re++;
        }
    }

    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    
    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);
int main(){
    ll n,m;
    cin >> n >> m;
    if(n==1||m==1){
        if(n==m) cout << 1 << endl;
        else cout << max(n,m)-2 << endl;
    }else{
        cout << (n-2)*(m-2) << endl;
    }
}

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

using namespace std;

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

    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data

// vector. vector[i],
// set. insert(), contains == set.find(x) != set.end(), size_t size() or count(x) 
// map. contains == count(x) ?


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define max 10000
int main()

{
  int *A,*B,C[max+1];
  int n,i,j;

  scanf("%d",&n);
  
  A=malloc(sizeof(int)*n+1);
  
  B=malloc(sizeof(int)*n+1);
 
  for(i=0;i<=max;i++) C[i]=0;

  for(j=0;j<n;j++){
    scanf("%d",&A[j+1]);
    C[A[j+1]]++;
  }

  for(i=1;i<=max;i++)
    C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 16276
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, h[100100], dp[100100];

ll rec(ll i) {
    if(dp[i] != inf) return dp[i];
    if(i == 0) return 0;

    ll res = inf;
    res = min(res, rec(i-1) + abs(h[i] - h[i-1]));
    if(i > 1) res = min(res, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = res;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 100100; i++) dp[i] = inf;

    cout << rec(n-1) << endl;
}

Measured memory_bytes: 4992
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int H,W,Q;
string s[2010];
bool vis[2010][2010];
bool isroot[2010][2010];
bool cross[2010][2010][4];
int acc[2010][2010][4];
int accr[2010][2010];

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
bool is(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&s[x][y]=='1';
}
void dfs(int x,int y){
	vis[x][y] = 1;
	rep(d,4){
		int nx = x + dx[d], ny = y + dy[d];
		if(is(nx,ny)&&!vis[nx][ny]){
			cross[x][y][d] = 1;
			dfs(nx,ny);
		}
	}
}
int main(){
	cin>>H>>W>>Q;
	rep(i,H) cin>>s[i];
	rep(i,H) rep(j,W) if(is(i,j) && !vis[i][j]){
		isroot[i][j] = 1;
		dfs(i,j);
	}
	rep(i,H){
		acc[i][0][0] = 0;
		rep(j,W) acc[i][j+1][0] = acc[i][j][0] + cross[i][j][0];
		
		acc[i][0][2] = 0;
		rep(j,W) acc[i][j+1][2] = acc[i][j][2] + cross[i][j][2];
	}
	rep(j,W){
		acc[0][j][1] = 0;
		rep(i,H) acc[i+1][j][1] = acc[i][j][1] + cross[i][j][1];
		acc[0][j][3] = 0;
		rep(i,H) acc[i+1][j][3] = acc[i][j][3] + cross[i][j][3];
	}
	rep(i,H) rep(j,W) accr[i+1][j+1] = isroot[i][j];
	rep(i,H+1) rep(j,W) accr[i][j+1] += accr[i][j];
	rep(i,H) rep(j,W+1) accr[i+1][j] += accr[i][j];

//	show(accr[H][W]);

	rep(tq,Q){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--,b--;
		int rt = accr[c][d] - accr[a][d] - accr[c][b] + accr[a][b];
//		show(rt);
		int cr = 0;
		if(a!=0) cr += acc[a-1][d][0] - acc[a-1][b][0];
		if(b!=0) cr += acc[c][b-1][1] - acc[a][b-1][1];
		if(c!=H) cr += acc[c][d][2]   - acc[c][b][2];
		if(d!=W) cr += acc[c][d][3] - acc[a][d][3];
		cout<< rt+cr << endl;
	}
	
}


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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='1')s[i]='9';
    else if(s[i]=='9')s[i]='1';
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256