akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int c;

bool ans(int a){
	if(a == 0){
		return 1;
	}
	if(a < 0) return 0;
	return max(ans(a-4), ans(a-7));
}

int main(){
	cin >> c;
	
	if(ans(c)) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	var S,T,ans string
	fmt.Scan(&N,&S,&T)
	
	for i := 0; i < N; i++ {
		ans += string(S[i]) + string(T[i])
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
a,b,c = gets.split.map(&:to_i)
per_week = a*7+b
week = c / per_week
result = week * 7
rest = c - per_week * week
if rest >= a * 7 then
    result += 7
elsif rest % a == 0 then
    result += rest / a
else
    result += rest / a + 1
end
puts result


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

vector<int>to[100010];
bool seen[100010],black[100010];

int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int f=0,s=0;
    queue<P>q;
    q.push(P(0,1));
    q.push(P(n-1,-1));
    seen[0]=seen[n-1]=true;
    while(!q.empty()){
        int v=q.front().first;
        int color=q.front().second;
        if(color==1)f++;
        else s++;
        q.pop();
        for(int u:to[v]){
            if(seen[u])continue;
            seen[u]=true;
            q.push(P(u,color));
        }
    }
    if(f>s)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
};

int main2() {
  int N = nextInt();
  int M = nextInt();
  UnionFind uf(N + M);
  REP(i, N) {
    int K = nextInt();
    REP(j, K) {
      int L = nextInt() - 1;
      uf.link(i, N + L);
    }
  }
  bool ans = true;
  REP(i, N) {
    if (uf.root(i) != uf.root(0)) ans = false;
  }
  cout << (ans?"YES":"NO") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	char a[1000], b[1000];
	int i;
	scanf("%s%s", a, b);
	for (i = 0; i < strlen(a); i++)
	{
		if (a[i] != b[i])
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1736
s = int(input())
count = 1
M = [0]*s
M[s-1] = 1
while max(M) < 2:
    if s % 2 == 0:
        s = int(s / 2)
        M[s-1] = M[s-1]+1
    else:
        s = 3 * s + 1
        M.extend([0]*s)
        M[s-1] = M[s-1] + 1
    count = count + 1
print(count)

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


int main() {
  int S;
  cin >> S;
  if ((S / 100 !=0 && S / 100 < 13) || (S % 100 != 0 && S % 100 < 13)) {
    if ((S / 100 !=0 && S / 100 < 13) && (S % 100 != 0 && S % 100 < 13)) {
      cout << "AMBIGUOUS" << endl;
    }
    else if (S / 100 !=0 && S / 100 < 13) {
      cout << "MMYY" << endl;
    }
    else {
      cout << "YYMM" << endl;
    }
  }
  else {
    cout << "NA" << endl;
  }
}

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

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& i : A) cin >> i;
    sort(A.begin(), A.end());
    cout << A.back() - A[0] << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int c[3][3];
    for(int i=0; i<3; i++) for(int j=0; j<3; j++) cin >> c[i][j];

    int a[3]; a[0]=0; a[1]=c[1][0]-c[0][0]; a[2]=c[2][0]-c[0][0];
    int b[3]; b[0]=c[0][0]; b[1]=c[0][1]; b[2]=c[0][2];

    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            if(a[i]+b[j]!=c[i][j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
class Combination:
    def __init__(self, N: int, MOD: int):
        fac = [0 for _ in range(N + 1)]
        fac[0] = 1
        for i in range(1, N + 1):
            fac[i] = fac[i - 1] * i % MOD
        self.fac = fac
        self.N = N
        self.MOD = MOD

    def _modpow(self, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % self.MOD
            x = x * x % self.MOD
            n >>= 1
        return ret

    def _modinv(self, x: int) -> int:
        return self._modpow(x, self.MOD - 2)

    def combination(self, n: int, k: int) -> int:
        if n < k:
            return 0
        return self.fac[n] * self._modinv(self.fac[k]) % self.MOD * self._modinv(self.fac[n - k]) % self.MOD

N, A, B = map(int, input().split())
MOD = int(1e9) + 7
S = 2 ** N % MOD

comb = Combination(3 * int(1e5), MOD)


def f(X):
    x = 1
    for i in range(1, X + 1):
        x *= comb._modinv(i)
        x *= (N - i + 1)
        x %= MOD

    return x

S += 3 * MOD - f(A) - f(B) - 1
S %= MOD
print(S)

Measured memory_bytes: 156956
#include <stdio.h>

#define _CRT_SECURE_NO_WARNINGS

int main(void) {
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a > b) {
		printf("a > b\n");
	}
	else if (a < b) {
		printf("a < b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;


int main()
{


    map<string,int>m;

    S a,b;
    cin>>a>>b;

    int x,y;
    cin>>x>>y;

    m[a]=x;
    m[b]=y;

    S u;
    cin>>u;

    m[u]--;

    cout<<m[a]<<" "<<m[b];



    return 0;
}

/*

*/




Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, ans = 1;
        cin >> N;
        while (ans * 2 <= N)
        {
                ans *= 2;
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[32],fc[1024]={1ll},nv[1024]={1ll},dp[32][1024];

ll rwpw(ll a, ll p=MOD-2){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

int main(void){
	int n,d,i,j,k;
	ll tmp;
	cin >> n >> d;
	for(i=0; i<n; ++i){
		fc[i+1] = fc[i]*(i+1)%MOD;
		nv[i+1] = rwpw(fc[i+1]);
	}
	for(i=0; i<d; ++i){
		cin >> a[i];
	}
	dp[0][0] = 1ll;
	for(i=0; i<=d; ++i){
		for(j=0; j<=n; ++j){
			for(k=0; k<=a[i]; ++k){
				if(j+k>n){
					continue;
				}
				tmp = fc[n-k];
				mul_mod(tmp,nv[a[i]-k]);
				mul_mod(tmp,nv[n-a[i]]);
				mul_mod(tmp,nv[k]);
				mul_mod(tmp,dp[i][j]);
				add_mod(dp[i+1][j+k],tmp);
			}
		}
	}
	for(i=0; i<n; ++i){
		mul_mod(dp[d][n],(i+1));
	}
	cout << dp[d][n] << endl;
	return 0;
}


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

int main() {
    
  int N;
  cin >> N;
  ostringstream n;
  n << N%10;
  
  //if(N%10 == 3) cout << "bon" << endl;
  //else if(N%10 == )
  
  
  string hon = "0168";
    //bon
    if (n.str() == "3") {
        cout << "bon" << endl;
    }

    else if (hon.find(n.str()) != string::npos) {
       cout << "pon" << endl;
    }
    
    else cout << "hon" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


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

	if (S[2] == S[3] && S[4] == S[5]) { cout << "Yes"; }
	else { cout << "No"; }

	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>
#include <stdlib.h>

using namespace std;
int ceil(double x)
{
    return (int)(x + 0.9);
}
int binarySearch(int n, int* s, int q, int* t)
{
    int sum = 0;

    for (int i = 0; i < q; i++) {
	int mid = n / 2;
	int left = 0;
	int right = n;
	while (left != right) {
	    if (s[mid] == t[i]) {
		sum++;
		break;
	    }
	    if (s[mid] > t[i]) {
		right = mid;
		mid = (left + right) / 2;
	    }
	    if (s[mid] < t[i]) {
		left = mid;
		mid = (left + right) / 2;
	    }
	    if (left == mid || right == mid) {
		break;
	    }
	}
    }
    return sum;
}
int main()
{
    int n = 0;
    int q = 0;
    cin >> n;

    int* s = (int*)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++) {
	scanf("%d", &s[i]);
    }
    cin >> q;
    int* t = (int*)malloc(sizeof(int) * q);
    for (int i = 0; i < q; i++) {
	scanf("%d", &t[i]);
    }
    int sum = binarySearch(n, s, q, t);
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
    int n; scanf("%d",&n);
    n%=10;
    if(n==0||n==1||n==6||n==8) puts("pon");
    else if(n==3) puts("bon");
    else puts("hon");
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int n; cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        int x; cin >> x;
        if(i % 2 == 1 && x % 2 == 1) cnt++;
    }
    cout << cnt << '\n';
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

bool is_it_ACGT(char l) {
  if (l == 'A') return true;
  else if (l == 'C') return true;
  else if (l == 'G') return true;
  else if (l == 'T') return true;
  else return false;
}

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

    int n, m, ans;
  	n = S.size();
  
    vector<int> v(1,0);
  
    rep(i,n) {
      if (!(is_it_ACGT(S.at(i)))) {
        v.push_back(i+1);
      }
    }
    v.push_back(n+1);
  	
  	m = v.size();
  
    rep(i,m-1) {
      ans = max(ans,v.at(i+1)-v.at(i)-1);
    }
  
    cout << ans << endl;
  
    



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define rep(n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define max(a,b) (a>b)? a:b
#define min(a,b) (a<b)? a:b

#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(0)
const int mod=1e9+7;
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}

int main()
{
    string s;cin>>s;
    stack<char> ans;
    rep(s.size())
    {
        if(s[i]=='B')
        {
            if(!ans.empty())
            ans.pop();
        }
        else
        ans.push(s[i]);
    }
    string v="";
    while(!ans.empty())
    {
        v+=ans.top();
        ans.pop();
    }
    reverse(v.begin(),v.end());
    cout<<v<<endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int a[1000000];

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

    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);

    for (int i = n; i > 0; i -= 2)
        printf("%d ", a[i]);
    for (int i = 1 + n % 2; i <= n; i+=2)
        printf("%d ", a[i]);

    return 0;
}


Measured memory_bytes: 2816
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemB solver = new ProblemB();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemB {
		final int N = (int) (3e5 + 100);
		final int MOD = 998244353;
		int[] fact = new int[N];
		int[] inv = new int[N];
		int[] invFact = new int[N];

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			precalc();
			int n = in.nextInt();
			int a = in.nextInt();
			int b = in.nextInt();
			long k = in.nextLong();
			long ans = 0;
			for (long na = 0; na <= n; na++) {
				long nb = k - na * a;
				if (nb < 0) {
					continue;
				}
				if (nb % b != 0) {
					continue;
				}
				nb /= b;
				if (nb > n) {
					continue;
				}

				ans = (ans + (long) C(n, (int) na) * C(n, (int) nb)) % MOD;
			}
			out.println(ans);
		}

		private void precalc() {
			inv[1] = 1;
			for (int i = 2; i < N; i++) {
				inv[i] = (int) ((MOD - (MOD / i) * (long) inv[MOD % i] % MOD) % MOD);
			}
			fact[0] = 1;
			invFact[0] = 1;
			for (int i = 1; i < N; i++) {
				fact[i] = (int) (i * (long) fact[i - 1] % MOD);
				invFact[i] = (int) (inv[i] * (long) invFact[i - 1] % MOD);
			}
		}

		private int C(int n, int k) {
			if (k < 0 || k > n) {
				return 0;
			}
			long a = fact[n];
			long b = invFact[k] * (long) invFact[n - k] % MOD;
			return (int) (a * b % MOD);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}



Measured memory_bytes: 25680
function main() {
  var n = input[0];
  var maxv = -1000000000;
  var minv = input[1];
  for (j = 2; j <= n; j++) {
    maxv = Math.max(maxv, input[j] - minv);
    minv = Math.min(minv, input[j]);
  }
  console.log(maxv);
}

var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  input.pop();
  main();
});

Measured memory_bytes: 34880
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll mod=1000000007;
ll a[200005],b[200005];
int main()
{
  ll n;
  cin>>n;
  for(ll i=0;i<n;i++)
  cin>>a[i];
  b[0]=a[0];
  ll ans=0;
  ll i,j;
  for(i=1;i<n;i++)
  {
      b[i]=(b[i-1]+a[i])%mod;
  }
  for(i=1;i<n;i++)
  {
      ans=(ans+(a[i]*b[i-1])%mod)%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

int main(){
	dcl(p);
	set<int> a;
	rep(i,p){dcl(t);a.insert(t);}
	int ans=0;
	dcl(q);
	rep(i,q){dcl(t);ans+=a.count(t);}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 7792
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        int d;
        
        if(a > b){
            d = a;
            a = b;
            b = d;
        }
        if(b > c){
            d = b;
            b = c;
            c = d;
        }
        if(a > b){
            d = a;
            a = b;
            b = d;
        }
            System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 26136
#include<stdio.h>

int n,A[50];

int solve(int i, int m){
  if(m == 0)return 1;
  if(i >= n)return 0;
  int sol = solve(i + 1, m) || solve(i + 1,m - A[i]);
  return sol;
}

int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&A[i]);
  scanf("%d",&q);

  for(i = 0; i < q; i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2108
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

x = input_n
num = 100
cnt = 0
while x > num
  num = num + (num * 0.01).floor
  cnt += 1
end
puts cnt


Measured memory_bytes: 14372
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
#include <list>

using namespace std;


int main() {
    int n, flag{1}, count{0}, min_i;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < n; i++) {
        min_i = i;
        for (int j = i; j < n; j++)
            if (A[j] < A[min_i]) min_i = j;

        if(A[i]!=A[min_i])count++;
        swap(A[i], A[min_i]);

    }


    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i == n - 1) cout << endl;
        else cout << " ";
    }
    cout << count << endl;
}


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

int main()
{
    int r,g,b;
    cin>>r>>g>>b;
    int ans=(((r*10)+g)*10)+b;
    if(ans%4==0)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//
//  Stop. Otherwise...cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/7/25.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
#define int long long
const int N = 4e3+10;
const int mod = 998244353;
int n, k;
int pw[N], c[N][N];
inline int C(int a, int b) {
//    printf("C:%lld %lld %lld\n", a, b, c[a][b]);
    if (b>a||b<0) {
        return 0;
    }
//    printf("%lld %lld %lld\n", a, b, c[a][b]);
    return c[a][b];
}
inline int calc(int a, int b) {
    return C(a+b-1, a-1);
}
inline int work(int val, int n, int k) {
    int sum = 0;
    int lim = (val<=k+1?(val)>>1:(k)-(val>>1));
//    printf("lim:%lld %lld %lld\n", val, k, lim);
    for (int j=0; j<=lim; j++) { //可一个都不选
//        printf("%lld\n", j);
        sum = (sum+pw[j]*C(lim, j)%mod*calc(k-2*lim+j, n-j)%mod) % mod; //可重复选
    }
//    printf("%lld\n", sum);
    return sum;
}
signed main() {
//    freopen("mytestdata.in", "r", stdin);
    pw[0] = 1;
    for (int i=1; i<N; i++) {
        pw[i] = (pw[i-1]<<1) % mod;
    }
    c[0][0] = 1;
    for (int i=1; i<N; i++) {
        c[i][0] = 1;
    }
    for (int i=1; i<N; i++) {
        for (int j=1; j<=i; j++) {
            c[i][j] = (c[i-1][j-1]+c[i-1][j]) % mod;
        }
    }
    scanf("%lld%lld", &k, &n);
    for (int i=2; i<=2*k; i++) {
        int ans = 0;
        if (i&1) {
            ans = (ans+work(i, n, k))%mod;
        } else {
            ans = ((ans+work(i-1, n, k-1))%mod+work(i-1, n-1, k-1))%mod;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 124160
N,T = map(int,input().split())
CT = [[int(i) for i in input().split()] for j in range(N)]
TL = 0 #Time limit
CT.sort(key = lambda x:x[1])

while CT[TL][1] <= T:
    TL += 1
    if TL == N:
        break
if TL == 0:
    print("TLE")
    exit()

CT_sort =sorted(CT[:TL])
print(CT_sort[0][0])


Measured memory_bytes: 3060
S=sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a,i:=i+1]for a in t)[::-1]
_,r=zip(*l)
while k:
 *_,b=r;k-=1
 for t in S(l)[::-1]:
  if t[1]-b:t[t[0]<2<exit(print(-1))]-=1;r+=t[1],
print(len(r),*r)

Measured memory_bytes: 9376
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#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()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,t; cin >> n >> t;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        if(a[i+1]-a[i] >= t) ans += t;
        else ans += a[i+1] - a[i];
    }
    ans += t;
    cout << ans << endl;
}


Measured memory_bytes: 1792
N,*as=$<.read.split.map(&:to_i)

n = as[0]
ls = as.map {|a| n = n.gcd(a) }
n = as[-1]
rs = as.reverse.map {|a| n = n.gcd(a) }.reverse

# p [ls,rs]

max = [ls[-2],rs[1]].max
i = 0
while i < N-2
    n = ls[i].gcd(rs[i+2])
    max = n if max < n
    i += 1
end

puts max

Measured memory_bytes: 24556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;


int main(){
  int N, M;
  vector<int>P(100001), Y(100001);
  vector<int>year[100001];

  cin >> N >> M;
  for(int i=0; i < M; ++i){
    cin >> P[i] >> Y[i];
    year[P[i]].push_back(Y[i]);
  }

  for(int i=0; i<=N; ++i){
    sort(year[i].begin(), year[i].end());
  }

  for(int i=0; i<M; ++i){
    int x = lower_bound(year[P[i]].begin(), year[P[i]].end(),Y[i]) - year[P[i]].begin()+1;
    printf("%06d%06d\n", P[i], x);
  }
 
  return 0;
}




Measured memory_bytes: 7808
#include "bits/stdc++.h"
using namespace std;

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    
    long long left, right;
    left = c - a - b;
    right = 4 * a * b;

    if(left > 0 && left * left > right) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int x,i = 0;
  while(cin>>x,x) {
    i++;
    cout << "Case " << i << ": " << x << endl;
  }  
}



Measured memory_bytes: 3072
n = int(input())
s = ''
 
if n == 0:
    print(0)
    exit()
 
i = 0
while n != 0:
    if n % (2 ** (i+1)) != 0:
        s += '1'
        n -= (-2) ** i
    else:
        s += '0'
    i += 1
print(s[::-1])

Measured memory_bytes: 3060
x,y=z=[0,1].map{[0]*2e5}
`sed 1d`.split.map{|v|z[1&$.+=1][v.to_i]-=1}
a,b=x.sort
c,d=y.sort
p$..+x.index(a)!=y.index(c)?a+c:[a+=d||0,c+=b||0].min

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

#define sai(j,n) for(sei j=0;j<sei(n);++j)
#define hsai(j,n) for(sei j=sei(n)-1;j>=0;--j)
#define kan(j,m,n) for(sei j=m;j<sei(n);++j)
#define hkan(j,m,n) for(sei j=sei(n)-1;j>=sei(m);--j)
#define zen(v) (v).begin(),(v).end()
#define yu(v) v.erase(unique(zen(v)), v.end());
#define syutu(v) si(a, (v).size()) {cout << v[a];if(a != v.size()-1)cout << " ";else cout << endl;}
#define mug 10000000111;
#define yo 10000000711;
#define kyo 1e-9;

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

using namespace std;
typedef long long sei;
typedef long double syo;
typedef vector<sei> vs;
typedef vector<syo> vy;
typedef vector<vs> vvs;
typedef vector<vy> vvy;
typedef pair<sei, sei> ks;
sei max(sei a, int b) {return max(a, sei(b));}
sei max(int a, sei b) {return max(sei(a), b);}

sei S(sei N){
    sei s=0;
    sei m = 10;
    while(N != 0){
        s += N%m;
        N -= N%m;
        N /= 10;
//        cout << s << ' ' << N << ' ' << m << endl;
    }
    return s;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sei N;
    cin >> N;
    if(N%S(N)==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lb long double
#define eps 1e-9
using namespace std;
struct Po{lb x,y;}p1,p2,q1,q2;
int t;
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
lb operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
bool onsegment(Po x,Po y,Po z){
	if (x.x>y.x) swap(x,y);
	if (z.x<x.x-eps||z.x>y.x+eps) return 0;
	if (x.y>y.y) swap(x,y);
	if (z.y<x.y-eps||z.y>y.y+eps) return 0;
	return 1;
}
int main(){
	scanf("%d",&t);
	while (t--){
		get(p1);get(p2);get(q1);get(q2);
		lb d1=(p2-p1)*(q1-p1),d2=(p2-p1)*(q2-p1),d3=(q2-q1)*(p1-q1),d4=(q2-q1)*(p2-q1);
		if (d1*d2<-eps&&d3*d4<eps){puts("1");continue;}
		if (fabs(d1)<eps&&onsegment(p1,p2,q1)){puts("1");continue;}
		if (fabs(d2)<eps&&onsegment(p1,p2,q2)){puts("1");continue;}
		if (fabs(d3)<eps&&onsegment(q1,q2,p1)){puts("1");continue;}
		if (fabs(d4)<eps&&onsegment(q1,q2,p2)){puts("1");continue;}
		puts("0");
	}
	return 0;
}


Measured memory_bytes: 3212
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  long long x = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (i % 2 == 0) x += a[i];
    else x -= a[i];
  }
  cout << x << endl;
  long long tmp = x;
  for (int i = 1; i < n; i++) {
    tmp = 2 * a[i - 1] - tmp;
    cout << tmp << endl;
  }
}

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


Measured memory_bytes: 1664
#include <iostream>
#include <map>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N;
    cin >> N;
    map<int, long long int> mp;
    for(int n=2; n<=N; n++) {
        int tmp=n;
        for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
            while(tmp%itr->first==0) {
                itr->second++;
                tmp /= itr->first;
            }
        }
        if(tmp>1) {
            mp[tmp]++;
        }
    }
    
    long long int ans=1;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        ans *= (itr->second+1);
        ans %= MOD;
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 157 (https://atcoder.jp/contests/abc157)
// Problem: D: Friend Suggestions (https://atcoder.jp/contests/abc157/tasks/abc157_d)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

struct DSU {
    vi p;
    explicit DSU(int n) : p(n, -1) {}

    int find(int i) { return p[i] < 0 ? i : p[i] = find(p[i]); }
    bool same(int i, int j) { return find(i) == find(j); }
    int size(int i) { return -p[find(i)]; }
    bool join(int i, int j) {
        i = find(i), j = find(j);
        if (i == j) return false;
        if (p[i] > p[j]) swap(i, j);
        p[i] += p[j], p[j] = i;
        return true;
    }
};

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

    int n, m, k; cin >> n >> m >> k;
    DSU d(n);
    vi deg(n);
    rep(i, m) {
        int a, b; cin >> a >> b; --a, --b;
        d.join(a, b);
        deg[a]++;
        deg[b]++;
    }
    rep(i, k) {
        int a, b; cin >> a >> b; --a, --b;
        if (d.same(a, b))
            deg[a]++, deg[b]++;
    }

    rep(i, n)
        cout << (d.size(i) - 1 - deg[i]) << ' ';
    cout << '\n';

    return 0;
}

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

int p[100000];

int main()

{	
	int s=0, n;
	float max=0;
	cin >> n;
	for (int i=0;i<n;i++)
	{
		cin >>p[i];
		s=s+p[i];
	}
	max=p[0];
	for (int i=0;i<n;i++)
	{
		if(p[i]>max)
		max=p[i];
	}
	s=s-max+max/2;
	cout << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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 const INF = 1001001001;


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

int h,a;
cin >> h >> a;

cout << (h+a-1) / a;

return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split(" ")))

i = 0
cnt = 0
max = -1
while(i!=N-1):
  if H[i+1]<=H[i]:
    cnt += 1
  else:
    if max<cnt:
      max = cnt
    cnt = 0
  i += 1
if max<cnt:
  max = cnt
print(max)

Measured memory_bytes: 15020
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	int  n = rint;
	foreach(x; 1 .. 50001){
		int q = x * 108 / 100;
		if(n == q){
			x.writeln;
			return;
		}
	}
	":(".writeln;
	return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
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; }

int N, M;
vector<vector<int>> G;

// メモ化再帰
int dp[100100];
int dfs(int u)
{
    if(dp[u] != -1) return dp[u];

    int res = 0;
    for (auto nv : G[u]){
        chmax(res, dfs(nv)+1);
    }
    return dp[u] = res;

}

int main()
{

    int x, y;
    cin >> N >> M;
    G.assign(N, vector<int>());
    rep(i, M){
       cin >> x >> y;
       --x, --y;
       G[x].push_back(y);
    }

    rep(i,N){ 
        dp[i] = NIL;
    }

    int res = 0;
    rep(v, N) chmax(res, dfs(v));
    cout << res << endl;
    

    return 0;
}

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

int main(void){
  int N;
  double sum = 0;
  double x;
  char u[4];
  
  scanf("%d", &N);
  
  for(int cnt_n = 0; cnt_n < N; cnt_n++){
   scanf("%lf %s", &x, u);
    if(strcmp(u, "JPY") == 0){
      sum += x;
    }else if(strcmp(u, "BTC") == 0){
      sum += (x*380000);
    }
  }
  
  printf("%f\n", sum);
  
 return 0; 
}


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

int main(){ 
  int n;
  cin >> n;
  map<string,int> mp;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
    mx = max(mx, mp[s]);
  }
  vector<string> res;
  for (auto e : mp) {
    if (e.second == mx) res.emplace_back(e.first);
  }
  sort(res.begin(), res.end());
  for (auto e : res) cout << e << endl;
  return 0;
} 

Measured memory_bytes: 28660
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> list = new List<int[]>();
            while(true)
            {
                int[] i = new int[2];
                i = (Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray());
                if (i[0] == 0 && i[1] == 0) break;
                list.Add(i);
            }
            foreach(int[] i in list)
            {
                for(int j = 0; j<i[0];j++)
                {
                    for(int k = 0; k<i[1];k++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }
}


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

int main() {
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    cout << setprecision(10)<<W*H/2.0<<" ";
    if (W%2==0&&H%2==0&&W/2==x&&H/2==y)cout<<'1'<<endl;
    else cout << '0' <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

const int N = 1e5;
ll a[3];
int n , k;
string s;
map <char,int> c_to_i = {{'r',0} , {'s',1} , {'p',2}};
map <int,char> i_to_c = {{0,'r'} , {1,'s'} , {2,'p'}};
map <char,char> d = {{'r','p'} , {'s','r'} , {'p','s'}};
char c[N];

void Suhaib_Sawalha (){

    cin >> n >> k;
    for (int i = 0 ; i < 3 ; ++i)
        cin >> a[i];
    cin >> s;

    for (int i = 0 ; i < k ; ++i)
        c[i] = s[i];
    ll ans = 0;
    for (int i = k ; i < n ; ++i){
        if (d[s[i]] == c[i-k]){
            c[i] = s[i];
            if (i+k < n)
                c[i] = d[d[s[i+k]]];
        }
        else {
            c[i] = d[s[i]];
            ans += a[c_to_i[d[s[i]]]];
        }
    }

    ll ans2 = 0;
    for (int i = 0 ; i < k ; ++i){
        c[i] = d[s[i]];
        ans2 += a[c_to_i[d[s[i]]]];
    }
    for (int i = k ; i < n ; ++i){
        if (d[s[i]] == c[i-k]){
            c[i] = s[i];
            if (i+k < n)
                c[i] = d[d[s[i+k]]];
        }
        else {
            c[i] = d[s[i]];
            ans2 += a[c_to_i[d[s[i]]]];
        }
    }

    cout << max (ans,ans2);
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void PrintVector(const vector<int> &vec)
{
    for (auto val : vec)
        cout << val << " ";
    cout << endl;
}

int main()
{
    string s; cin >> s;
    vector<int> day(3, 0);
    int j = 0;
    rep(i, s.size())
    {
        if (s[i] != '/')
        {
            day[j] = day[j] * 10 + s[i] - '0';
        }
        else j++;
    }

    if (day[0] <= 2019 && day[1] <= 4 && day[2] <= 30)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
}

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

int main(void) {
    int h, w, selh, selw;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    cin >> selh >> selw;
    cout << (h - selh) * (w - selw) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define LCIN(n) long long(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    LL from,to,cost;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        cost = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);CIN(M);
    std::vector<Edge> Edges;
    REP(a,M){
        LCIN(A);LCIN(B);LCIN(C);
        Edge e(A-1,B-1,-C);
        Edges.push_back(e);
    }
    LL diff[N+10];
    for(int a = 0;a < N;a++){
        diff[a]=LINF;
    }
    diff[0]=0;
    for(int loop = 0;loop < N-1;loop++){
        for(Edge e:Edges){
            //cout<<diff[e.from]<<" "<<diff[e.to]<<" "<<e.cost<<endl;
            if(diff[e.from]==LINF)continue;
            if(diff[e.from]+e.cost < diff[e.to]){
                diff[e.to]=diff[e.from]+e.cost;
            }
        }
    }

    LL ans = diff[N-1];

    bool flag[N+10];
    for(int a = 0;a < N;a++){
        flag[a]=false;
    }

    for(int loop = 0;loop < N;loop++){
        for(Edge e:Edges){
            if(diff[e.from]==LINF)continue;
            if(diff[e.from]+e.cost < diff[e.to]){
                diff[e.to]=diff[e.from]+e.cost;
                flag[e.to]=true;
            }
            if(flag[e.from]){
                flag[e.to]=true;
            }
        }
    }
    if(flag[N-1]){
        cout<<"inf"<<endl;
    }else{
        cout<<-ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#define MAX_NUM (1000000007)

int main(void)
{
	int N, M;

	long long int ans;

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

	if (N < M){
		int temp = N;
		N = M;
		M = temp;
	}

	if (N - M >= 2){
		ans = 0;
	} else {
		long long int ansN = 1;
		int i;

		for (i = 2; i <= M; i++){
			ansN *= i;
			ansN %= MAX_NUM;
		}

		ans = ansN * ansN % MAX_NUM;
		if (N > M){
			ans *= N;
		} else {
			ans *= 2;
		}

		ans %= MAX_NUM;
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, A, B, ans;

int main()
{
	in >> N >> A >> B;

	for (int i = 1; i <= N; ++i)
	{
		int res = 0;
		auto n = i;
		while (n > 0)
		{
			res += n % 10;
			n /= 10;
		}
		if (A <= res && res <= B) { ans += i; }
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    cout << accumulate(a.begin(), a.end(), 0) - n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            List<Integer> a =  IntStream.range(0, sc.nextInt()).mapToObj(x->sc.nextInt()).collect(Collectors.toList());
            int q = sc.nextInt();
            for(int i = 0; i < q; i++) {
                int b = sc.nextInt();
                int e = sc.nextInt();            	
                List<Integer> sub = a.subList(b, e);
                Collections.reverse(sub);
                for(int j = b; j < e; j++) {
                	a.set(j, sub.get(j-b));
                }
            }
            System.out.println(String.join(" ", a.stream().map(String::valueOf).toArray(String[]::new)));
        }
    }
}


Measured memory_bytes: 38256
#include <bits/stdc++.h>
 #include <math.h>
using namespace std;
#define ll long long
#define pi 3.14159265359

int main(){
 int n;
  cin>>n;
  int sum=0;
  vector<int>d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  for(int i=0;i<n;i++){
for(int j=0;j<i;j++){
  sum+=d[i]*d[j];
}
  }
cout<<sum<<endl;
}
  

Measured memory_bytes: 256