akhauriyash/Code-Regression huggingface dataset:
N = input()
jobs = []
for i in range(int(N)):
  t = input().split()
  t = [int(i) for i in t]
  jobs.append(t)

jobs.sort(key=lambda x: x[1])

time = 0
flag = 0
for  i in range(int(N)):
  time +=  int(jobs[i][0])
#  print(time)
 # print(jobs[i][1])
  if time > int(jobs[i][1]):
    flag = 1
    break
if flag == 0:
  print("Yes")
else:
  print("No")

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    VI permutation(N);
    iota(ALL(permutation), 1);

    int p_idx = -1;
    int q_idx = -1;
    int idx = 1;
    do {
        bool p = true;
        bool q = true;
        REP(i, N) {
            if(permutation[i] != P[i]) p = false;
            if(permutation[i] != Q[i]) q = false;
        }

        if(p) p_idx = idx;
        if(q) q_idx = idx;

        idx++;
    } while (next_permutation(ALL(permutation)));

    cout << abs(p_idx-q_idx) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int a, b, c;
    io.read(a, b, c);
    if(a == b + c || b == c + a || c == a + b) cout << "Yes";
    else cout << "No";
    return 0;
}

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

using namespace std;

int main()
{
    int n, value = 0;

    cin >> n;
    int v[n];
    int c[n];
    for (size_t i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (size_t i = 0; i < n; i++)
    {
        cin >> c[i];
    }

    for (size_t i = 0; i < n; i++)
    {
        if (v[i] < c[i])
        {
            continue;
        }
        else
        {
            value += v[i] - c[i];
        }
    }
    cout << value << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int a, b, c;

int main() {

	cin >> a >> b >> c;

	if (a < c && c < b) cout << "Yes" << endl;
	else if (a > c && c > b) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

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

S = []
N = []
while True:
    n,s = map(int,input().split(" "))
    if s == 0 and n == 0:
        break
    else:
        N.append(n)
        S.append(s)

for i in range(0,len(S)):
    sumMap = list(map(sum,list(itertools.combinations(range(0,10),N[i]))))
    print(sum([1 for j in range(0,len(sumMap)) if sumMap[j] == S[i]]))

Measured memory_bytes: 6736
N = int(input())
L = list(map(int,input().split()))

L.sort()
cnt = 0

for i in range(N):
    for j in range(N):
        for k in range(N):    
            if i < j < k and L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9204
M = 5.times.map { gets.to_i }

min_t = 9
min_idx = 0
5.times do |i|
  if M[i]%10 != 0 && min_t > M[i]%10
    min_t = M[i]%10
    min_idx = i
  end
end

ans = 5.times.map do |i|
  if i == min_idx || M[i]%10==0
    M[i]
  else
    10 - M[i]%10 + M[i]
  end
end

puts ans.inject(:+)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 long long n,a,b,my_time,check;
vector<pair<int, int>> pairs(200004);
bool bad;

int main(){
    cin>>n;

    for (int i=0; i<n; i++) {
        cin>>a>>b;
        pairs[i]={b,a};
        
    }
    sort(pairs.begin(),pairs.end());
    for (long long i=200004-n; i<200004; i++) {
        my_time+=pairs[i].second;
        check++;
        if (my_time>pairs[i].first) {
            bad=true;
            break;
        }
        
    }
    if (bad) {
        cout<<"No"<<endl;
    }else cout<<"Yes"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <map>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
//typedef pair<double, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
//const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


const double INF = 1000000.0;
const int MAX_V = 35;
struct edge{ int to,cost,rest;};
//typedef pair<int,int> P;
typedef pair<int, int> P;
typedef pair<double,T> PP;


int p,q,a,n;
int ans;

int check(int ss,int bb){
    if(p * bb == q * ss){
        return 0;
    }else if(p*bb > q*ss){
        return 1;
    }else{
        return -1;
    }
}

void dfs(int s,int b,int asum,int num,int x){
    int tmp = check(s,b);
    if(tmp == 0){ //same
        ans++;
        return;
    }else if(tmp == 1 && num != n){//continue
        for(int i = x;i <= a;i++){
            if(i * asum > a)break;
            dfs(s*i+b,b*i,asum*i,num+1,i);
        }
    }
    return;
}

int main(){
    while(true){
        cin >> p >> q >> a >> n;
        if(p + q + a + n == 0)break;
        ans = 0;
        for(int i = 1;i <= a;i++){
            dfs(1,i,i,1,i);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGuessTheNumber solver = new CGuessTheNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGuessTheNumber {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int a[] = new int[n];
            Arrays.fill(a, -1);
            if (n == 1 && m == 0) {
                out.println(0);
                return;
            }
            for (int i = 0; i < m; i++) {
                int p = in.nextInt() - 1;
                int q = in.nextInt();
                if (p >= n) {
                    out.println(-1);
                    return;
                }
                if (a[p] != -1 && a[p] != q) {
                    out.println(-1);
//                out.println("here" +a[p] +  " " + m);
                    return;
                }
                a[p] = q;
            }
            int ans = 0;
            int j = 0;

            for (int i = 0; i < n; i++) {
                if (a[i] == -1 && i == 0) a[i] = 1;
                if (a[i] == -1) a[i] = 0;
                ans = ans * 10 + a[i];
            }
            if (Integer.toString(ans).length() != n) {
                out.println(-1);
                return;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define INT long long
#define MOD 1000000007
#define OO 99999998765432100
using namespace std;
INT n, a[200020], sum, ans = OO;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>a[i];
        sum += a[i];
        if( i ) a[i]+=a[i-1];
    }
    for(int i = 0 ; i < n ; i++ )
    {
        ans = min( ans, abs((sum-a[i])-a[i]) );
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s=readln.chomp.to!(char[]);

  bool[char] map;
  foreach(c; s){
    if(c in map){
      writeln("no");
      return;
    }else{
      map[c]=true;
    }
  }
  writeln("yes");

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

# a, bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

# a, bの最小公倍数
def lcm(a, b):
    return int(a * b) // gcd(a,b)

# print(lcm(C, D))
A, B, C, D = l_inpl()
A -= 1
B_ans = B - (B // C + B // D - B // lcm(C, D))
# print(B_ans)
A_ans = A - (A // C + A // D - A // lcm(C, D))
# print(A_ans)
print(B_ans - A_ans)

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

int main(void){
    int N;
    cin>>N;
    
    double x;
    string s;
    
    double sum=0;
    for(int i=0;i<N;i++){
        cin>>x>>s;
        if(s=="JPY"){
            sum+=x;
        }else{
            sum+=x*380000.0;
        }
    }
    
    printf("%.7f",sum);
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:
int cnt[26];

int main(void){
	string s;
	cin >> s;
	for(auto &c:s) cnt[c-'a']^=1;
	bool ok=true;
	rep(i,26) if(cnt[i]) ok=false;
	if(ok)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int Distance(int a, int b){
  if(a-b>=0){
    return a - b;
  }else{
    return b - a;
  }
}


int main(int argc, char const *argv[])
{
  int aPos, bPos, cPos, dRange;

  scanf("%d %d %d %d", &aPos, &bPos, &cPos, &dRange);

  if(Distance(aPos, cPos) <= dRange){
    printf("Yes");
  }else if(Distance(aPos, bPos)<=dRange && Distance(bPos, cPos)<=dRange){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


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

int main(){
    int N, K;
    int AList[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> AList[i];
    }
    int cnt = 0;
    do{
        if(cnt == 0){
            N -= K;
        }else{
            N -= K-1;
        }
        cnt++;
    }while(N > 0);
    cout << cnt;
    return 0;
}

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

using namespace std;


int main()
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    long long int n_R = 0, n_G = 0, n_B = 0;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            n_R++;
        if (s[i] == 'G')
            n_G++;
        if (s[i] == 'B')
            n_B++;
    }

    long long int condition_1 = n_R*n_G*n_B;
    
    long long int non_condition_2 = 0;

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
    
            int k = 2*j - i;
            if (k < n)
                if (s[i] != s[j])
                    if (s[j] != s[k])
                        if (s[i] != s[k])
                            non_condition_2++;
        }

    long long int ans = condition_1 - non_condition_2; 

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main()

{
    ll a, b, k;
    cin >> a >> b >> k;
    ll c = a - k;
    if (c < 0)
    {
        a = 0;
        b -= -c;
        if (b < 0)
            b = 0;
    }
    else
    {
        a -= k;
    }
    cout << a << " " << b << endl;
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;
	int q; cin >> q;
	bool oppo = false;
	string z, y; // y beg, z end
	while (q--) {
		int t, f; cin >> t;
		char c;
		if (t == 1) {
			oppo = !oppo;
		} else {
			cin >> f >> c;
			if (f == 1) {
				if (!oppo) y.push_back(c);
				else z.push_back(c);
			} else {
				if (!oppo) z.push_back(c);
				else y.push_back(c);
			}
		}
	}
	if (!oppo) {
		reverse(y.begin(), y.end());
		cout << y << s << z;
	} else {
		reverse(z.begin(), z.end());
		reverse(s.begin(), s.end());
		cout << z << s << y;
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 1040
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N, Q;
	ll K;
	cin >> N >> K >> Q;
	vector<int>score(N);
	for (int i = 0; i < Q; i++) {
		int A;
		cin >> A;
		A--;
		score[A]++;
	}

	for (int i = 0; i < N; i++) {
		int s = K - (Q - score[i]);
		if (s <= 0)puts("No");
		else puts("Yes");
	}


	return 0;
}

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

ll cal(ll x){
    return x*(x+1)/2;
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        ans+=i*cal(n/i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var Nt = ReadInts();
            var list = new List<double>();
            for (int i = 0; i < Nt[0]; i++)
            {
                var xh = ReadDoubles();
                var a = xh[1] / xh[0];
                list.Add(a);
            }
            WriteLine(list.Max() * Nt[1]);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

int main()
{
	int n ;
	cin >> n ;
	string str ;
	cin >> str ;
	int len = str.length() ;
	if(n < len)
	{
		for(int i = 0 ; i < n ; i ++)
		cout << str[i] ;
		cout << "..." << endl ;
	}
	else if(n >= len)
	{
		cout << str << endl ;
	}

	return 0 ;
}

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

const int N = 55;

#define int long long

int n, m, x, y, way[N][N], A[N], B[N], ans;

bool chos[N];

main() {
  cin >> n;
  for(int i = 1; i <= n; ++ i) cin >> A[i];
  for(int i = 1; i <= n; ++ i) cin >> B[i];
  for(int i = 1; i <= 50; ++ i) chos[i] = 1;
  for(int i = 51; i >= 1; -- i) {
	memset(way, 0, sizeof(way));
	chos[i] = 0;
	for(int j = 0; j <= 50; ++ j) {
	  way[j][j] = 1;
	  for(int k = 1; k <= 50; ++ k) if(chos[k]) way[j][j % k] = 1;
	}
	
	for(int a = 0; a <= 50; ++ a) {
	  for(int b = 0; b <= 50; ++ b)
		for(int c = 0; c <= 50; ++ c) 
		  way[b][c] |= way[b][a] & way[a][c];
	}
	bool ok = 1;
	for(int j = 1; j <= n; ++ j) ok &= way[A[j]][B[j]];
	if(!ok) chos[i] = 1, ans += 1LL << i;
  }
  if(ans >= (1LL << 51)) ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		String S=sc.next(),T=sc.next();

		for(int i=0;i<N;i++) {
			System.out.print(S.charAt(i));
			System.out.print(T.charAt(i));
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
    int n; cin >>n;
    vector<ll> a(5);
    for(int i = 0; i < n; ++i){
        string s; cin >> s;
        if(s[0]=='M'){++a[0];}
        if(s[0]=='A'){++a[1];}
        if(s[0]=='R'){++a[2];}
        if(s[0]=='C'){++a[3];}
        if(s[0]=='H'){++a[4];}
    }
    ll ans=0;
    for(int i = 0; i < 5; ++i){
        for(int j = i+1; j < 5; ++j){
            for(int k = j+1; k < 5; ++k){
                ans += a[i]* a[j]* a[k];
             }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

using std::min;

static long
solve(int N, vector<int> &a)
{
  long count_a = 0;
  long count_b = 0;
  int sum_a = 0;
  int sum_b = 0;
  int sign_a = 1;
  int sign_b = -1;
  for (int n = 0; n < N; n++)
  {
    int val = a[n];
    sum_a += val;
    sum_b += val;
    if (sum_a * sign_a <= 0)
    {
      count_a += 1 - (sum_a * sign_a);
      sum_a = sign_a;
    }
    if (sum_b * sign_b <= 0)
    {
      count_b += 1 - (sum_b * sign_b);
      sum_b = sign_b;
    }
    sign_a = -sign_a;
    sign_b = -sign_b;
  }
  return min(count_a, count_b);
}

int
main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int n = 0; n < N; n++)
  {
    cin >> a[n];
  }
  cout << solve(N, a) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.14159265358979;
/******変数定義start******/
ll n, m;
vector<string> a, b;
/*******変数定義end*******/

ll solve(){
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    REP(i, n){
        cin >> a[i];
    }
    REP(i, m){
        cin >> b[i];
    }
    for(ll i = 0; i < n-m+1; i++){
        for(ll j = 0; j < n - m+1; j++){
            if(a[i].substr(j, m) == b[0]){
                ll count = 0;
                for(ll k = 0; k < m; k++){
                    if(a[i+k].substr(j, m) == b[k]){
                        count++;
                    }
                }
                if(count == m){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}
int main(){

    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return end;
}


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

int main()
{
	int n, m, k, a, ans=0;
	cin >> n >> m;
	int num[30];

	for (int i = 0;i < 30;i++) {
		num[i] = 0;
	}

	for (int i = 0;i < n;i++) {
		cin >> k;
		for (int j = 0;j < k;j++) {
			cin >> a;
			num[a-1]++;
		}
	}
	for (int i = 0;i < m;i++) {
		if (num[i] == n) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,m;
    cin>>n>>x>>m;
    int cnt=1,tota=0;
    int sum=0;
    while(1) {
        sum+=x;

        tota+=m;
        if(sum>=n) {

            break;
        }
    }
    cout<<tota<<endl;


}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL Mod = 924844033; // 2^21 * 3^2 * 7^2 g=5;
const LL N = 800010;
struct node{LL x,y,next;}edge[N]; LL len,first[N];
void ins(LL x,LL y){len++; edge[len].x=x; edge[len].y=y; edge[len].next=first[x]; first[x]=len;}

LL qpow(LL x,LL k,LL mo){LL s=1; while(k){if(k&1) s=(s*x)%mo; x=(x*x)%mo; k>>=1;} return s;}
/*
void check()
{

  LL x=Mod-1;
  for(LL i=2;i*i<=x;i++)
  {
    LL p=0;
    while(x%i==0) p++,x/=i;
    if(p) prLLf("%d^%d\n",i,p);
  }
  for(LL i=2;i;i++)
  {
    LL x=Mod-1; bool bk=true;
    for(LL j=2;j*j<=x;j++)
    {
      if(x%j==0)
      {
        if(qpow(i,j,Mod) == 1) bk=false;
        if(qpow(i,x/j,Mod) == 1) bk=false;
      }
    }
    if(bk){prLLf("%LLd\n",i); break;}
  }
}*/

inline LL read()
{
  char ch=getchar(); LL p=0; LL f=1;
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

LL siz[N];
void dfs(LL x,LL f)
{
  siz[x]=1;
  for(LL k=first[x];k!=-1;k=edge[k].next)
  {
    LL y=edge[k].y;
    if(y==f) continue;
    dfs(y,x); siz[x]+=siz[y];
  }
}

LL jc[N]; LL R[N];

void NFT(LL *a,LL n,LL fh)
{
  for(LL i=1;i<n;i++) if(R[i] > i) swap(a[R[i]],a[i]);
  for(LL i=1;i<n;i<<=1)
  {
    LL gn = qpow(5LL , (Mod-1) / (i<<1) ,Mod);
    for(LL j=0;j<n;j+=(i<<1))
    {
      LL g=1;
      for(LL k=0;k<i;k++,g=(g*gn)%Mod)
      {
        LL x=a[j+k]; LL y=a[j+k+i]*g%Mod;
        a[j+k] = (x+y)%Mod; a[j+k+i] = (x-y+Mod)%Mod;
      }
    }
  }
  if(fh==-1) reverse(a+1,a+n);
}

void NTT(LL *a,LL *b,LL n,LL m)
{
  m+=n; LL l=0; for(n=1;n<=m;n<<=1) l++;
  for(LL i=1;i<n;i++) R[i] = (R[i>>1]>>1) | ((i&1) << (l-1));

  NFT(a,n,1); NFT(b,n,1);
  for(LL i=0;i<n;i++) a[i] = (a[i]*b[i])%Mod;
  NFT(a,n,-1); LL ny = qpow(n,Mod-2,Mod);
  for(LL i=0;i<n;i++) a[i] = (a[i]*ny)%Mod;
}

LL a[N],b[N],c[N],n;

int main()
{

  //check();
  n=read(); len=0; memset(first,-1,sizeof(first));
  for(LL i=1;i<n;i++){LL x=read(),y=read(); ins(x,y); ins(y,x);}
  memset(siz,0,sizeof(siz)); dfs(1,0);

  jc[0]=1; for(LL i=1;i<=n;i++) jc[i] = (jc[i-1] * i)%Mod;
  
  for(LL i=0;i<=n;i++) a[i]=jc[i];
  for(LL i=2;i<=n;i++) c[n]++,c[siz[i]]--,c[n-siz[i]]--; c[n]++;
  for(LL i=0;i<=n;i++) a[i]=(a[i]*c[i]%Mod+Mod)%Mod,b[i]=qpow(jc[n-i],Mod-2,Mod);
  
  //a[1]=1; a[2]=2;
  //b[1]=1; b[2]=3;
  NTT(a,b,n,n);

  for(LL i=1;i<=n;i++) printf("%lld\n",a[n+i] * qpow(jc[i],Mod-2,Mod) % Mod);

  return 0;
}

Measured memory_bytes: 54656
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e6+5;

void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;
	cout<<string(x,'R')<<string(y,'U');
	cout<<string(x,'L')<<string(y,'D');
	x++,y++;
	cout<<'L'<<string(y,'U')<<string(x,'R')<<'D';
	cout<<'R'<<string(y,'D')<<string(x,'L')<<'U';
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>


int main() {
  int H, W;
  int j, k;
  char edge = '#', inside = '.';

  for (int i = 0; i < 300; i ++) {
    std::cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (j = 0; j < H; j ++) {
      for (k = 0; k < W; k ++) {
        if (k == 0 || k == W - 1 || j == 0 || j == H - 1) {
          std::cout << edge;
        } else {
          std::cout << inside;
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}




Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

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

  if( e-a <= k ){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }


  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define li long int
#define ull unsigned long long int

#define db double
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mii map<int,int>
#define nl "\n"
using namespace std;

int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    ll bal=100;
    ll year=0;
    while(x>bal)
    {
        bal=bal+bal/100;
        year++;
    }
    cout<<year<<nl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n;
ll a[DMAX];
ll dp[DMAX][5];
int main(){
	read(n);
	for(ll i=1;i<=n;i++){
		read(a[i]);
	}
	dp[2][1]=(-a[1])+(-a[2]);
	dp[2][0]=a[1]+a[2];
	for(ll i=3;i<=n;i++){
		dp[i][0]=max(dp[i-1][0],dp[i-1][1])+a[i];
		dp[i][1]=max(dp[i-1][0]-2*a[i-1],dp[i-1][1]+2*a[i-1])-a[i];
	}
//	for(ll i=1;i<=n;i++){
//		cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
//	}
	cout<<max(dp[n][0],dp[n][1])<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    const int n = s.length();
    vector<vector<int>> p(26);
    for(int i = 0; i < n; ++i){
        p[s[i] - 'a'].emplace_back(i);
    }
    for(int i = 0; i < 26; ++i){
        if(!p[i].size()){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
        p[i].emplace_back(n);
    }
    vector<ll> dp(n + 1, -1);
    dp[n] = 0;
    auto dfs = [&](auto&& self, int cur) -> int {
        if(dp[cur] != -1)   return dp[cur];
        int res = INF;
        for(int i = 0; i < 26; ++i){
            int next = *upper_bound(p[i].begin(), p[i].end(), cur);
            chmin(res, self(self, next));
        }
        return dp[cur] = res + 1;
    };
    dfs(dfs, 0);
    int len = *max_element(dp.begin(), dp.end());
    int cur = -1;
    string ans = "";
    while(len > 0){
        for(int i = 0; i < 26; ++i){
            if(cur == -1){
                if(dp[p[i][0]] != len){
                    cur = p[i][0];
                    ans += (char)(i + 'a');
                    --len;
                    break;
                }
            }
            else{
                int next = *upper_bound(p[i].begin(), p[i].end(), cur);
                if(dp[next] != len){
                    cur = next;
                    ans += (char)(i + 'a');
                    --len;
                    break;
                }
            }
        }
        if(cur == -1)   ++len;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6536
def main():
    n, a, b = list(map(int, input().split()))
    if (n == 1 and a != b) or (b < a):
        print(0)
        exit()
    mini = a * (n - 1) + b
    maxi = a + b * (n - 1)
    print(maxi - mini + 1)


if __name__ == '__main__':
    main()


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int m1 = H1 * 60 + M1;
    int m2 = H2 * 60 + M2;
    int ans = m2 - m1 - K;
    cout << ans << endl;
}

Measured memory_bytes: 3636
n=int(input())
a=list(map(int,input().split()))
mx=max(a)
d=mx
ans=0
if n==2:
  print(100,0)
  exit()
for i in a:
  if abs(i-mx/2)<d:
    d=abs(i-mx/2)
    ans=i
print(mx,ans)



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

typedef long long ll;
const int mod = 1e9 + 7;
ll N;

struct Edge {
    ll to, id;
};

vector<vector<Edge>> g;
vector<ll> ans;

void dfs(int v, int c = -1, int p = -1) {
    int k = 1;
    rep(i, g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u == p) continue;
        if (k == c) k++;

        ans[ei] = k; k++;
        dfs(u, ans[ei], v);
    }
}

int main() {
    cin >> N;
    g.resize(N);
    ans = vector<ll>(N - 1);

    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back((Edge){b, i});
        g[b].push_back((Edge){a, i});
    }

    dfs(0);

    ll mx = 0;
    rep(i, N) mx = max(mx, (ll)g[i].size());
    cout << mx << endl;

    rep(i, N - 1) {
        cout << ans[i] << endl;
    }
}

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

using namespace std;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[2] - a[0] << "\n";



  return 0;
}


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

#define ll long long

using namespace std;

int main(){

    string S;
    cin >> S;

    if(S == "SUN"){
        cout << '7' << endl;    
    }
    else if(S == "MON"){
        cout << '6' << endl;
    }
    else if(S == "TUE"){
        cout << '5' << endl;
    }
    else if(S == "WED"){
        cout << '4' << endl;
    }
    else if(S == "THU"){
        cout << '3' << endl;
    }
    else if(S == "FRI"){
        cout << '2' << endl;
    }
    else if(S == "SAT"){
        cout << '1' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

int main()
{
    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i < x + k; ++i) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int n;
	cin >> n;
	vector<ll>t(n, 0);
	for(int i = 0; i < n; i++){
		cin >> t[i];
	}
	int m; 
	cin >> m;
	vector<ll>p(m, 0), x(m, 0);
	for(int i = 0; i < m; i++){
		cin >> p[i] >> x[i];
	}
	for(int i = 0; i < m; i++){
		ll ans = 0;
		for(int j = 0; j < n; j++){
			if(j != p[i] - 1){
				ans += t[j];
			//	cout << t[j]<<" ";
			}else if(j == p[i] - 1){
				ans += x[i];
			//	cout << x[i] << " ";
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,N;
  cin >> N >> A;
  for (int X=0; X<=N; X+=500)
  if(N-X<=A){
    cout << "Yes" <<endl;
    return 0;
  }
  cout << "No"<< endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

def f(i, a):
    if i == N-1:
        return sum(list(map(int, a.split('+')))) 
    
    return f(i+1, a + S[i+1]) + f(i+1, a + '+' + S[i+1])

print(f(0, S[0]))

Measured memory_bytes: 3060
n = int(input()) - 1
a = list(map(int, input().split()))

count = 0
flag  = 1

while flag:
    flag = 0
    for i in range( n, 0, -1 ):
        if a[i] < a[i-1]:
            t = a[i]
            a[i] = a[i-1]
            a[i-1] = t
            count += 1
            flag = 1

print(*a)
print(count)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K, R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    
    string W = "";
    vector<bool> isWin(N, true);
    REP(i, N)
    {
        string s;
        if (T[i] == 'r') s = "p";
        else if (T[i] == 's') s = "r";
        else if (T[i] == 'p') s = "s";
        W += s;
    }

    for (ll i = 0; i + K < N; ++i)
    {
        if (W[i] == W[i + K])
        {
            if (isWin[i] && isWin[i + K])
            {
                W[i + K] = T[i + K];
                isWin[i + K] = false;
            }
        }
    }
    ll ans = 0;
    REP(i, N)
    {
        if (isWin[i])
        {
            if (W[i] == 'r') ans += R;
            else if (W[i] == 's') ans += S;
            else if (W[i] == 'p') ans += P;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
double ki(int x) {
	double a=(double)1 / 2 * x*(x + 1);
	return (double)a / x;

}

int main(){
    int N, K;
    cin>>N>>K;
	vector<int>p(N);
	
	rep(i, N) {
		cin>>p.at(i);
	}
	
	vector<int> Y(N+1);
    
	int sum = 0;
	rep(i, N) {
		sum += p.at(i);
		Y.at(i+1) = sum;
	}
    
	int max = 0;
	int index = 0;
	rep(i, N + 1) {
        if(i==N-K+1) break;
		if (Y.at(i + K) - Y.at(i) > max) {
			max = Y.at(i + K) - Y.at(i);
			index = i;
		}
	}
    
	double sum2 = 0;
	int count = 0;
	for (int i = index; count < K; i++) {
		sum2 += ki(p.at(i));
		count++;
	}
	cout<<fixed << setprecision(6)<<sum2<<endl;
    
    return 0;
}

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

set1 = {4,6,9,1}
set2 = {1,3,5,7,8,10,12}

if x == 2 and y == 2:
	print("Yes")
elif x in set1 and y in set1:
	print("Yes")
elif x in set2 and y in set2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class BEasyLinearProgramming {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.readLong(), b = in.readLong(), c = in.readLong(), k = in.readLong();
            long sum = 0;
            if (k <= a) {
                sum += k;
                k = 0;
            }
            if (k > a) {
                sum += a;
                k -= a;
            }
            if (k <= b) {
                k = 0;
            }

            if (k > b) {
                k -= b;
            }

            if (k <= c) {
                sum -= k;
                k = 0;
            }

            if (k > c) {
                sum -= k;

            }


            System.out.println(sum);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

int main()
{
    string s, p;
    cin >> s >> p;
    s = s+s;
    int n = s.find(p);
    if( n != string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
S = input()

year = int(S[0:4])
month = int(S[5:7])


if year > 2019:
    print('TBD')
elif year == 2019:
    if month >= 5:
        print('TBD')
    else:
        print('Heisei')
else:
    print('Heisei')

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


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

    int n,m,a,b;
    cin>>n>>m>>a>>b;
    int d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    stack<int> st;
    for(int i=0;i<n;i++){
        if(d[i] >= a) st.push(d[i]);
        else break;
    }
    if(n - st.size() < m){
        while(st.size()){
            int p = st.top();
            if(p <= b){
                st.pop();
            }
            else break;
        }
    }
    cout << st.size() << endl;

}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n;
    int a[100000] = {0};
    int ans[100001] = {0};
    int minus = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] > 0){
            ans[a[i]+1] += 1;
            ans[a[i]] += 1;
            ans[a[i]-1] += 1;
        }else{
            ans[a[i]+1] += 1;
            ans[a[i]] += 1;
            minus += 1;
        }
    }
    int str = 0;
    for(int i = 0; i < 100001; i++){
        if(str < ans[i])  str = ans[i];
    }
    cout << str << '\n';


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;

int main(){
    string word;
    string s;
    int count = 0;
    cin >> word;
   transform(word.begin(),word.end(),word.begin(),::tolower);
    do{
        cin >> s;
        if(s != "END_OF_TEXT"){
            transform(s.begin(),s.end(),s.begin(),::tolower);
        }
        if(s == word){
            count++;
        }
    }while(s != "END_OF_TEXT");
    cout << count << endl;  
}


Measured memory_bytes: 3124
// ボール: 区別あり, 箱：区別あり, 入れ方: 制限なし
#include <iostream>
using namespace std;
const int MOD = 1000000007;

int main() {
  
  int n, k; cin >> n >> k;
  long long ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= k;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3112