akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int[] dice_num,dice_num2;
    	dice_num = new int[10];
    	dice_num2 = new int[10];
    	int i;
    	for(i = 0; i < 6; i++){
    		dice_num[i] = scan.nextInt();
    	}
    	String dir_word = scan.next();
    	String dir_array[] = dir_word.split("");
    	for(i = 0; i < dir_word.length(); i++){
    		if(dir_array[i].equals("S")){
    			dice_num2[0] = dice_num[4];
    			dice_num2[1] = dice_num[0];
    			dice_num2[2] = dice_num[2];
    			dice_num2[3] = dice_num[3];
    			dice_num2[4] = dice_num[5];
    			dice_num2[5] = dice_num[1];
    		}
    		else if(dir_array[i].equals("W")){
    			dice_num2[0] = dice_num[2];
    			dice_num2[1] = dice_num[1];
    			dice_num2[2] = dice_num[5];
    			dice_num2[3] = dice_num[0];
    			dice_num2[4] = dice_num[4];
    			dice_num2[5] = dice_num[3];
    		}
    		else if(dir_array[i].equals("N")){
    			dice_num2[0] = dice_num[1];
    			dice_num2[1] = dice_num[5];
    			dice_num2[2] = dice_num[2];
    			dice_num2[3] = dice_num[3];
    			dice_num2[4] = dice_num[0];
    			dice_num2[5] = dice_num[4];
    		}
    		else if(dir_array[i].equals("E")){
    			dice_num2[0] = dice_num[3];
    			dice_num2[1] = dice_num[1];
    			dice_num2[2] = dice_num[0];
    			dice_num2[3] = dice_num[5];
    			dice_num2[4] = dice_num[4];
    			dice_num2[5] = dice_num[2];
    		}
    			dice_num[0] = dice_num2[0];
    			dice_num[1] = dice_num2[1];
    			dice_num[2] = dice_num2[2];
    			dice_num[3] = dice_num2[3];
    			dice_num[4] = dice_num2[4];
    			dice_num[5] = dice_num2[5];
    	}
    		System.out.println(dice_num[0]);
    	}
}
    




		

	

Measured memory_bytes: 26332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=3005;
int a[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,ans=0;
  cin>>n;
  rep(i,1,n+1) cin>>a[i],ans+=a[i]-1;
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {1,0,-1,0,1,1,-1,-1};
int row[] = {0,1,0,-1,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};


int n;

vvll dp(3005,vll(3005,-1));

vll nums(3005);

ll getSol(int i , int j, bool f)
{
    if(i == j)
    {
        if(f)
            return nums[i];

        return -nums[i];
    }

    if(dp[i][j] != -1)
        return dp[i][j];

   ll ans;
   if(f)
        ans = max(nums[i]+getSol(i+1,j,!f), nums[j]+ getSol(i,j-1,!f));
   else
        ans = min(getSol(i+1,j,!f)-nums[i], getSol(i, j-1,!f)-nums[j]);

   return dp[i][j] = ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios::sync_with_stdio(0);
    //cin.tie(0);

    cin >> n;

    for(int i = 0 ; i < n; ++i)
        cin >> nums[i];

    cout << getSol(0,n-1,1);

    return 0;
}


Measured memory_bytes: 74452
#include<stdio.h>
int main(void)
{
    int a, b, i, j, d;

    scanf("%d%d", &a,&b);
    d = 0;
    for(i=1;i<=a;i++){
       for(j=1;j<=a;j++){
          if(i = j)
            d = d + 1;
          if((i == a) && (b < j))
            d = d - 1;
       }
    }
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int H,W;
    while(1){
        cin>>H>>W;
        if( H==0 && W==0) break;
        for(int i =0; i < H; ++i){
            for (int j = 0; j < W ; ++j) {
                if(i+j == 0 or (i+j)%2 == 0)
                        cout<<"#";
                else{
                    cout<<".";
                }
                }
                    cout<<endl;
            }
        cout<<endl;
        }
    return 0;}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

int N,X;

using namespace std;


int main()
{
	cin>>N;
	cin>>X;
	N=10*N+X;
	cin>>X;
	N=10*N+X;
	if(N%4==0)
		cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,ll>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  int n; cin >> n;
  int a[n],b[n],c[n];
  FOR(i,0,n-1) cin >> a[i];
  FOR(i,0,n-1) cin >> b[i];
  FOR(i,0,n-1) cin >> c[i];

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  ll ans = 0;

  FOR(i,0,n-1){
    ll positionA = lower_bound(a,a+n,b[i]) - a;
    ll positionC = n - (upper_bound(c,c+n,b[i]) - c);
    // cout << positionA << " " << positionC << endl;
    ans += positionA * positionC;
  }

  cout << ans << endl;

  
}




Measured memory_bytes: 1408
n,m = map(int,input().split())
s=[0]*m
c=[0]*m
for i in range(m):
    s[i],c[i]=map(int,input().split())
ans=[]
judge=False
if n ==1:
    for j in range(10):
        j = str(j)
        for l in range(m):
            if int(j[s[l]-1])==c[l]:
                pass
            else:
                break
        else:
            ans.append(int(j))
            judge=True

else:
    for j in range(10**(n-1),10**n):
        j=str(j)
        for l in range(m):
            if int(j[s[l]-1])==c[l]:
                pass
            else:
                break
        else:
            ans.append(int(j))
            judge=True
if judge:
    print(min(ans))
else:
    print('-1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  Vll a(7); cin >> a;
  ll ans = 0;

  ans += a[1];

  ll x = a[0]%2 + a[3]%2 + a[4]%2;

  if (x == 0 || x == 3) ans += a[0] + a[3] + a[4];
  else {
    if (x == 2 && a[0] > 0 && a[3] > 0 && a[4] > 0) {
      --a[0];
      --a[3];
      --a[4];
      ans += 3;
    }
    ans += a[0]/2*2 + a[3]/2*2 + a[4]/2*2;
  }
  
  cout << ans << endl;
  return 0;
}


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    string S;
    ll ans=0;
    cin >> S;
    ll N = S.size();
    map<ll, ll> c;
    ll fac=1;
    ll cur=0;
    c[cur]+=1;
    rep(i, N){
        ll add = S[N-i-1] - '0';
        cur = (cur+fac*add) % 2019;
        fac = (fac*10) % 2019;
        c[cur]+=1;
    }
    for(pair<ll, ll> p : c){
        ans += p.second*(p.second-1)/2;
    }
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<LL> count(26,0);
  for(int i=0;i<n;i++){
    count[s[i]-'a']++;
  }
  LL ans=1;
  for(int i=0;i<26;i++){
    ans=ans*(count[i]+1)%MOD;
  }
  ans=(ans+MOD-1)%MOD;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using lint = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

class segment_tree {
private:

	int size;
	vector<int>dat;
	int identity;

	int query_sub(int a, int b, int k, int l, int r) const {
		if (r <= a || b <= l) return identity;
		if (a <= l && r <= b) return dat[k];
		int vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}

public:

	segment_tree(int size_, int identity)
		:identity(identity)
	{
		int x = 1;
		while (size_ > x) x <<= 1;
		size = x;
		dat.resize(2 * size - 1, identity);
	}

	void update(int i, int x) {
		i += size - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}

	// [a, b)
	int query(int a, int b) const { return query_sub(a, b, 0, 0, size); }

	const int& operator[](size_t index) const { return dat[index + size - 1]; }
	int& operator[](size_t index) { return dat[index + size - 1]; }
};

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

	segment_tree seg(n, 10000000);

	rep(i, n) {
		int a;
		scanf("%d", &a);
		seg.update(i, a);
	}

	rep(i, n) {
		const int a = seg[i];

		lint cnt1, cnt2;

		int l = -1, r = i;
		while (abs(r - l) > 1) {
			int mid = l + (r - l) / 2;
			if (seg.query(mid, i + 1) == a) r = mid;
			else l = mid;
		}

		cnt1 = i - r + 1;

		l = i, r = n;
		while (abs(r - l) > 1) {
			int mid = l + (r - l) / 2;
			if (seg.query(i, mid + 1) == a) l = mid;
			else r = mid;
		}

		cnt2 = l - i + 1;

		sum += cnt1 * cnt2 * a;
	}

	cout << sum << endl;
}

Measured memory_bytes: 5368
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	// アルファベットの配列
	public static String[] alphabet_all = { "a", "b", "c", "d", "e", "f", "g",
			"h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
			"u", "v", "w", "x", "y", "z" };

	public static void main(String[] args) {

		// アルファベットbeanのリスト
		ArrayList<alphabet> alpha_beans = new ArrayList<alphabet>();
		// 各アルファベットのbeanを作る
		for (String val : alphabet_all) {
			//
			alphabet hoge = new alphabet(val);
			alpha_beans.add(hoge);
		}

		// ファイル入力
		Scanner sc = new Scanner(System.in);

		//

		while (sc.hasNext()) {
			String input_sentence = sc.nextLine();

			// 入力文字を1文字ずつに変換
			char ch[] = input_sentence.toCharArray();

			// 入力文字列がある分、まわす
			for (int i = 0; i < ch.length; i++) {

				// それぞれのアルファベットについて
				for (alphabet val : alpha_beans) {

					// 入力文字の一文字ずつとアルファベットの文字(大文字も小文字は区別しない)が一致したら
					if (val.getString().equals(
							String.valueOf(ch[i]).toLowerCase())) {
						// 一致したアルファベットの数字を増やす
						val.setNumber(1);

					}
				}
			}
		}

		// 出力
		for (alphabet val : alpha_beans) {
			//
			System.out.println(val.getString() + " : " + val.getNumber());
		}
	}
}

// 各アルファベットクラス
class alphabet {
	//
	private int number = 0;
	private String alphabet = "";

	// コンストラクタ
	alphabet(String a) {
		alphabet = a;
	}

	// セッター
	public void setNumber(int n) {
		number = n + number;
	}

	// ゲッター
	public int getNumber() {
		return number;
	}

	public String getString() {
		return alphabet;
	}
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define LLINF 1000000000000000000

using namespace std;

// 自作した二分探索
int my_binary_search(ll *data, int size, ll key)
{
  int ng = -1;
  int ok = size;

  while (abs(ok - ng) > 1)
  {
    int mid = (ok + ng) / 2;

    if (data[mid] < key)
    {
      ng = mid;
    }
    else
    {
      ok = mid;
    }
  }
  return ok;
}

int main()
{
  int a, b, q;
  cin >> a >> b >> q;
  ll s[100002], t[100002];
  ll result[100000];
  s[0] = -LLINF;
  s[a + 1] = LLINF;
  t[0] = -LLINF;
  t[b + 1] = LLINF;

  for (int i = 1; i <= a; i++)
  {
    cin >> s[i];
  }
  for (int i = 1; i <= b; i++)
  {
    cin >> t[i];
  }

  ll x = 0;
  REP(k, q)
  {
    cin >> x;
    int u[2], v[2];
    u[1] = my_binary_search(s, a + 2, x);
    u[0] = u[1] - 1;
    v[1] = my_binary_search(t, b + 2, x);
    v[0] = v[1] - 1;

    result[k] = LLINF;
    REP(i, 2)
    {
      REP(j, 2)
      {
        ll d = min(abs(x - s[u[i]]) + abs(s[u[i]] - t[v[j]]), abs(x - t[v[j]]) + abs(t[v[j]] - s[u[i]]));
        if (d < result[k])
        {
          result[k] = d;
        }
      }
    }
  }

  REP(i, q)
  {
    cout << result[i] << endl;
  }
}


Measured memory_bytes: 3712
#include <stdio.h>

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

    if(n<=2){
        printf("1\n");
        return 0;
        }

    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    //FtR

    int d, ans=1;
    //d==1 => incr., d==-1 => decr., d==0 => default.

    if(a[0]<a[1]){ d=1; }
    else if(a[0]>a[1]){ d=-1; }
    else{
        d==0;
        }

    for(int i=1; i<n-1; i++){
        if(d==0&&a[i]==a[i+1]){
        }
        else if(d>=0&&a[i]<=a[i+1]){
            d=1;
        }
        else if(d<=0&&a[i]>=a[i+1]){
            d=-1;
        }
        else{
            ans++;
            d=0;
        }
    }

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


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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int (i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int (i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int (i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}
string alphabet() { return "abcdefghijklmnopqrstuvwxyz"; }

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

	vector<int> r, g, b;
	repeat(i, S.length()) {
		string s = S.substr(i, 1);

		if (s == "R") r.push_back(i+1);
		else if (s == "G") g.push_back(i+1);
		else if (s == "B") b.push_back(i+1);
	}

	ll result = r.size() * g.size() * b.size();
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
				int k = (2*j) - i;

				if(k>=N) break;

				if((S[i] != S[j]) && (S[j] != S[k]) && (S[i] != S[k])) result--;
		}
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3668
K,S = map(int, input().split())
ret = 0
for A in range(S+1):
    if A > K: continue
    for B in range(S+1-A):
        if B > K:continue
        # print(A,B,S-A-B)
        if S-A-B <= K: 
            # print(A,B,S-A-B)
            ret += 1
print(ret)

Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
q = int(input())

ls = [0]*q
rs = [0]*q

for i in range(q):
  l, r = map(int, input().split())
  ls[i] = l
  rs[i] = r

n = max(rs)
ass = []
is_prime = [True]*(n+1)
is_prime[0] = False
is_prime[1] = False

is_like = [0]*(n+1)
  
for i in range(2, n+1):
  if not is_prime[i]:
    continue
  if i%2 == 1 and is_prime[(i+1)//2] == True:
    is_like[i] = 1
  for j in range(i*2, n+1, i):
    is_prime[j] = False

from itertools import accumulate
cum_like = list(accumulate(is_like))

#print(cum_like)
for i in range(q):
  r = rs[i]
  l = ls[i]
  print(cum_like[r]-cum_like[l-1])


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

int main(void) {
    int r, g, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> r >> g >> b;
    cout << ((r * 100 + g * 10 + b) % 4 == 0? "YES" : "NO") << "\n";
    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,T;
  	cin >> A >> B >> T;
	cout << T / A * B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int a,b,c,temp;
 
    scanf("%d %d %d",&a,&b,&c);
 
    if(a>b){
        temp = a;
        a = b;
        b = temp;
     }

    if(b>c){
        temp = b;
        b = c;
        c = temp;
    }
 
    if(a>b){
        temp = a;
        a = b;
        b = temp;
     }

    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int N, M;
vector<int> G[1010];
vector<int> bfs(int s) {
    vector<int> dist(N, INF), pre(N, -1);
    queue<int> q;
    dist[s] = 0;
    q.push(s);
    while(q.size()) {
        int v = q.front(); q.pop();
        for (auto u: G[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    // cout << s <<": ";
    // rep(i, N) cout << dist[i] << " ";
    // cout << endl;
    pair<int, int> best(INF, -1);
    rep(v, N) {
        if (v == s) continue;
        for(auto u: G[v]) {
            if (u == s) {
                best = min(best, make_pair(dist[v], v));
            }
        }
    }
    // cout << s << " " << best.first << endl;
    if (best.first == INF) return vector<int>(N+1);
    int v = best.second;
    vector<int> res;
    while(v != -1) {
        res.push_back(v);
        v = pre[v];
    }
    return res;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
    }
    vector<int> ans(N + 1);
    rep(i, N) {
        vector<int> now = bfs(i);
        if (now.size() < ans.size()) ans = now;
    }
    if (ans.size() == N + 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for(auto v: ans) {
        cout << v + 1 << endl;
    }



    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<long long> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());

    long long ans = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
            ans += max(k - (j + 1), 0);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

string func(ll n, string c) {
    string s = "";
    while (n > 0) {
        s += c;
        n--;
    }
    return s;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string S = "";

    ll y = ty-sy;
    ll x = tx-sx;

    S += func(y, "U");
    S += func(x, "R");
    S += func(y, "D");
    S += func(x, "L");

    y++;
    x++;

    S += "L";
    S += func(y, "U");
    S += func(x, "R");
    S += "D";
    S += "R";
    S += func(y, "D");
    S += func(x, "L");
    S += "U";

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    /* let [n, d] = lines[0].split(' ').map( _ => parseInt(_)) */
    let n = parseInt(lines[0])
    let ac = 0, wa = 0, tle = 0, re = 0

    for(let i = 0; i < n; i++) {
        let s = lines[i+1]
        if(s == 'AC') {
            ac++
        } else if (s == 'WA') {
            wa++
        } else if (s == 'TLE') {
            tle++
        } else {
            re++
        }
    }


    console.log(`AC x ${ac}`);
    console.log(`WA x ${wa}`);
    console.log(`TLE x ${tle}`);
    console.log(`RE x ${re}`);
});

Measured memory_bytes: 40876
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    j = input()
    if j == "AC":
        ac += 1
    elif j == "WA":
        wa += 1
    elif j == "TLE":
        tle += 1
    else:
        re += 1
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int N, W;
  cin >> N >> W;
  int n[N], w[N], dp[N + 10][W + 10] = {0};
  rep(i, N) cin >> n[i] >> w[i];
  rep(i, N) rep(j, W + 1) dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, N) rep(j, W + 1) {
    if (dp[i][j] >= 0) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (w[i] + j <= W)
        dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i][j] + n[i]);
    }
  }
  int ans = 0;
  rep(j, W + 1) ans = max(ans, dp[N][j]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7364
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18)+1;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	ll l = -inf, r = inf;

	while (l + 1 < r) {
		//cout << l <<" "<< r << endl;
		ll x = (l + r) / 2;
		bool ok = [&] {
			ll tot = 0;

			rep(i, n) {
				if (a[i] < 0) {
					int l = -1, r = n;
					while (l + 1 < r) {
						int c = (l + r) / 2;
						if (a[c] * a[i] < x) r = c; else l = c;
					}
					tot += n - r;
				}
				else {
					int l = -1, r = n;
					while (l + 1 < r) {
						int c = (l + r) / 2;
						if (a[c] * a[i] < x) l = c; else r = c;
					}
					tot += r;
				}
				if (a[i] * a[i] < x) tot--;
			}
			tot /= 2;
			//cout << tot << endl;
			return tot < k;
		}();
		if (ok) l = x; else r = x;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 4784
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

const int MX = 202;
const ll MOD = 998244353;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct vec
{
	int x, y;
	
	vec (const int &x0 = 0, const int &y0 = 0) : x(x0), y(y0) {}
	vec operator + (const vec &t) const {return vec(x+t.x, y+t.y);}
	vec operator - (const vec &t) const {return vec(x-t.x, y-t.y);}
};

int crs(const vec &a, const vec &b)
{
	return a.x*b.y - a.y*b.x;
}

int dot(const vec &a, const vec &b)
{
	return a.x*b.x + a.y*b.y;
}

int n;
vec pot[MX];
ll pw2[MX];

void input()
{
	read(n);
	for(int i=1; i<=n; i++) read(pot[i].x), read(pot[i].y);
}

void work()
{
	pw2[0] = 1;
	for(int i=1; i<=n; i++) pw2[i] = pw2[i-1]*2 % MOD;
	ll ans = pw2[n] - n - 1;
	for(int i=1; i<=n; i++)
	{
		for(int j=i+1; j<=n; j++)
		{
			int cnt = 0;
			for(int k=j+1; k<=n; k++)
			{
				if(crs(pot[k]-pot[i], pot[j]-pot[i]) == 0)
				{
					cnt++;
				}
			}
			ans = (ans + MOD - pw2[cnt]) % MOD;
		}
	}
	printf("%lld\n", ans);
}

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

Measured memory_bytes: 256
import Control.Applicative

main = do
    n <- read <$> getLine
    as <- (map read . words) <$> getLine
    putStrLn  $ show $ solve n as

solve :: Int -> [Int] -> Int
solve n as = 
    let sas = fromIntegral $ sum as
        fn = fromIntegral n
        mean = round $ sas / fn
    in sum $ map ((^2) . (mean-)) as

Measured memory_bytes: 1020
def check(x,y):
    global an1,at1,an2,at2
    if y < at1:
        an1,at1 = x,y
    elif y < at2:
        an2,at2 = x,y

an1, at1, an2, at2 = 0, 1000, 0, 1000
for i in range(3):
    n1, t1, n2, t2 = 0, 1000, 0, 1000
    for j in range(8):
        n, t = map(float, raw_input().split())
        if t < t1:
            check(n2,t2)
            n1,t1,n2,t2 = n,t,n1,t1
        elif t < t2:
            check(n2,t2)
            n2, t2 = n, t
        else:
            check(n,t)
    print "%d %4.2f"%(int(n1), t1)
    print "%d %4.2f"%(int(n2), t2)
print "%d %4.2f"%(int(an1), at1)
print "%d %4.2f"%(int(an2), at2)

Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int prime[246913];
vector<int> pp;

void pccheck(){
	pp.push_back(2);
	prime[2]++;
	for(int i=3;i<246913;i++){
		int flag=0;
		for(int j=0;j<pp.size()&&sqrt(i)>=pp[j];j++){
			if(i%pp[j]==0){
				flag=1;
				break;
			}
		}
		if(flag==0){
			pp.push_back(i);
			prime[i]=1;
		}
	}
	for(int i=1;i<246913;i++){
		prime[i]=prime[i-1]+prime[i];
	}
	return ;
}
int main(){
	pccheck();
	while(1){
		cin>>n;
		if(n==0)break;
		cout<<prime[2*n]-prime[n]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4252
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.math;

alias Tuple!(double, "x", double, "y", double, "r") Circle;

double dist(Circle a, Circle b) {
  return sqrt(pow((a.x - b.x), 2) + pow((a.y - b.y), 2));
}

int is_overlap(Circle a, Circle b) {
  double d = dist(a, b);
  if (d > a.r + b.r) return 0;
  else if (d + b.r < a.r) return 2;
  else if (d + a.r < b.r) return -2;
  else return 1;
}

void main() {
  uint n = readln.chomp.to!(uint);
  foreach(t; 0..n) {
    double[] line = readln.chomp.split(" ").map!(to!(double)).array;
    auto c1 = Circle(line[0], line[1], line[2]);
    auto c2 = Circle(line[3], line[4], line[5]);
    is_overlap(c1, c2).writeln;
  }
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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

int const MOD = 1e9+7;

void solve(){
    int n;
    cin >> n;
    int ans = n/2;
    ans += (n&1);
    cout << ans << endl;
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();
    //
    solve();
    return 0;
}


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

int main()
{
    bool b[10] {0};
    for(int i = 0; i < 4; i++){
        int n;
        cin >> n;
        b[n] = true;
    }
    if(b[1] && b[9] && b[7] && b[4]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
def factorize(n):
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  return fct

def getpattern(x):
  pattern = 0
  d = 0
  for i in range(1, 1000000):
    d += i
    if x < d:
      break
    pattern += 1
  return pattern

n = int(input())
f = factorize(n)
fu = set(factorize(n))
r = 0
for fui in fu:
  r += getpattern(f.count(fui))
print(r)

Measured memory_bytes: 9196
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
int t,s,n;
cin>>n>>t>>s;
if(t*s>=n)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
int main()
{
     
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3640
n, m = gets.chomp.split(' ').map(&:to_i)
list = gets.chomp.split(' ').map(&:to_i).sort.reverse

#          1, 2, 3, 4, 5, 6, 7, 8, 9
COST = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

MIN = -1_000_000_000

memo = Array.new(n / 2 + 1) { MIN }
memo[0] = 0
cost_map = list.map { |i| [i, COST[i]] }.to_h

def dp(n, cost_map, memo)
  ans = cost_map.values.map do |cost|
    x = n - cost
    next MIN if x < 0
    memo[x] + 1
  end.max
  memo[n] = ans
end

2.upto(n).each do |i|
  dp(i, cost_map, memo)
end

chars = []
x = n
memo[n].downto(1).each do |i|
  list.each do |c|
    exp_digit = memo[x] - 1
    co = x - cost_map[c]
    next if co < 0
    if memo[co] == exp_digit
      chars << c
      x -= cost_map[c]
      break
    end
  end
end

puts chars.join


Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int main() {
    int n;
    while (cin >> n && n) {
        int cnt = 0;
        for (int i=2; i<1000; ++i) {
            for (int a=1; a<1000; ++a) {
                if (((a + a + i - 1) * i) % 2 == 0 && ((a + a + i - 1) * i) / 2 == n) {
                    cnt ++;
                    break;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

long long tpow(int n, int b){
    if (n == 0) return 1;
    else return b*tpow(n-1, b);
}

int main(){
    string S; cin >> S;
    long long sum = 0;
    for (int i = 0; i < S.size(); i++){
        for (int j = 0; j < S.size()-i-1; j++){
            sum += (int(S[i])-48)*tpow(S.size()-2-j, 2)*tpow(j, 10);
        }
        sum += (int(S[i])-48)*tpow(i, 2)*tpow(S.size()-i-1, 10);
    }
    cout << sum << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    
    int x;
    cin>>x;
    x ^= 1;
    out(x);
    
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
static const double pi = 3.141592653589793;
typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-8;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)


namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

D dot(P a, P b) {
  return (conj(a)*b).X;
}

D cross(P a, P b) {
  return (conj(a)*b).Y;
}

bool isecLS(P a1, P a2, P b1, P b2) {
  return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecLP(P a1, P a2, P b) {
  return abs(ccw(a1, a2, b)) != 1;  // return EQ(cross(a2-a1, b-a1), 0); と等価
}


char hyou[610][610];
int H, W;
vector<pair<double, P>> points;

int cntrose(int x, int y) {
	int r = (int)(hyou[y][x] == '#') + (int)(hyou[y][x + 1] == '#') + (int)(hyou[y + 1][x] == '#') + (int)(hyou[y + 1][x + 1] == '#');
	return r;
}

int isL(P a) {
	int x = (int)(a.real());
	int y = (int)(a.imag());
	if (hyou[y][x] == '.' and hyou[y + 1][x + 1] == '.'){
		if(hyou[y][x + 1] == '#') return -1;
		else return 1; 
	} else if (hyou[y][x] == '#' and hyou[y + 1][x + 1] == '#'){
		if(hyou[y][x + 1] == '#') return 1;
		else return -1;
	} 
	else return 0;
}

int main() {
	cin >> H >> W;
	for(int h = H + 1; h >= 0; h--) {
		for(int w = 0; w <= W + 1; w++) {
			if(w == 0 and h == 0) continue;
			if (h == 0 or h == H + 1 or w == 0 or w == W + 1) {
				hyou[h][w] = '.';
			} else {
				cin >> hyou[h][w];
			}
		}
	}
	for(int w = 0; w <= W; w++) {
		for(int h = 0; h <= H; h++) {
			if(cntrose(w,h) % 2){
				P a = P(w, h);
				points.push_back(make_pair(arg(a), a));
			}
		}
	}
	
	int ans = 0, cnt = 1;
	sort(points.begin(), points.end());
	rep(i, points.size()){
		cnt += isL(points[i].second);
		if (i + 1== points.size() or abs(points[i].first - points[i + 1].first) > EPS) ans = max(ans, cnt);
	}
	cout << ans << endl;
}
	
	



Measured memory_bytes: 9696
N,D=map(int,input().split())
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
for i in range(N):
    X[i],Y[i]=map(int,input().split())
total = 0
dissquare = D**2
for x,y in zip(X,Y):
    if abs(x)>D or abs(y)>D:
        continue
    else: 
        if (x**2+y**2)<=dissquare:
            total+=1
print(total)

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

k = int(input())


a, b = map(int, input().split())

if k==1:
    print("OK")
elif a%k == 0:
    print("OK")
elif abs(a-b) + a%k >= k:
    print("OK")
# elif a//k != b//k:
#     print("OK")
else:
    print("NG")


Measured memory_bytes: 9172
n = int(input())
a = [int(x) for x in input().split()]
b = []
stack = []
a.reverse()
for i in range(n):
    if i%2 == 0:
        b.append(a[i])
    else:
        stack.append(a[i])
for i in range(len(stack)):
    b.append(stack.pop())

print(" ".join(map(str, b)))


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int playerNum, lifePt, quizNum;
    
    cin >> playerNum >> lifePt >> quizNum;
    
    int winner[quizNum];
    for(int i = 0; i < quizNum; i++) cin >> winner[i];
    
    int players[playerNum] = {0};
    
    if(quizNum < lifePt){
        for(int i = 0; i < playerNum; i++) cout << "Yes" << endl;
    }
    else{
        for(int i = 0; i < quizNum; i++) players[winner[i] - 1]++;
        for(int i = 0; i < playerNum; i++){
            players[i] > quizNum - lifePt ? cout << "Yes" << endl : cout << "No" << endl;
        }
    }
    
	return 0;
}

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

int main() {
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];

  sort(A.begin(), A.end());
  cout << (A[1] - A[0]) + (A[2] - A[1]) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k,r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  int ans=0;
  rep(i,t.size() ){
    if(i-k < 0){
      	if(t[i]=='r') ans+=p;
	else if(t[i]=='s') ans+=r;
	else if(t[i]=='p') ans+=s;
    }
    else if(i-k >= 0){
      if(t[i]!=t[i-k]){
	if(t[i]=='r') ans+=p;
	else if(t[i]=='s') ans+=r;
	else if(t[i]=='p') ans+=s;
      }else{
	if(t[i]!='#') t[i]='#';
      }
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int n, y; cin >> n >> y;
	int a = -1, b = -1, c = -1;
	for (int i = 0; i <= n; i ++)
		for (int j = 0; j <= n; j ++) {
			int k = n - i - j;
			if (k < 0) continue;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				a = i; b = j; c = k;
			}
		}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

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

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

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

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

long long N;
void solve() {
  cin >> N;
  //まず奇数か判定
  if (N % 2 == 1) {
    cout << 0 << endl;
    return;
  } else {
    long long n = N/2;
    long long sum = 0;
    long long divisor = 5;
    while(true){
      long long quotient = n / divisor;
      sum += quotient;
      if(quotient == 0){
        cout << sum <<endl;
        return;
      }
      divisor *= 5;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(h);lin(a);
  if(h%a==0)
    cout<<h/a;
  else
    cout<<h/a+1;
}

Measured memory_bytes: 256
r,c = map(int,raw_input().split())
a = [map(int,raw_input().split()) for _ in range(r)]
b = [0 for _ in range(c)]

for i in range(r) :
    s = 0
    for j in range(c) :
        s = s + a[i][j]
        b[j] = b[j] + a[i][j]
    a[i].append(s)
    print ' '.join(map(str,a[i]))
b.append(sum(b))
print ' '.join(map(str,b))

Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=2e5+5;
#define inf 1e18+8
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

signed  main()
{
    fastio;
    float r;cin>>r;
    float ans=2*22*r/7;
    cout<<ans;
  
    
}

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

bool check(int i, const string& s, int n) {
	char c[3];
	for (int j = 0; j < 3; j++) {
		c[2 - j] = '0' + (i % 10);
		i /= 10;
	}
	int index = 0;
	for (char ch : s) {
		if (ch == c[index]) index++;
		if (index == 3) break;
	}
	return index == 3;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < 1000; i++) {
		if (check(i, s, n)) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
char a[50][50], b[50][50];
int main()
{
	string s;
	cin >> s;
	int a = 10000000, b = -1;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A')a = min(a, i);
		if (s[i] == 'Z')b = max(b, i);
	}
	printf("%d\n", b - a + 1);
}

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

int main(){
  int N;
  cin>>N;
  vector<ll> sum(N+1,0);
  for(int i=1;i<=N;i++){
    ll A;
    cin>>A;
    sum.at(i)=sum.at(i-1)+A;
  }
  sort(sum.begin(),sum.end());

  ll ans=0;
  ll num=0;
  bool flag=false;
  for(int i=0;i<N+1;i++){
    if(!flag){
      flag=true;
      num++;
    }else{
      if(sum.at(i-1)==sum.at(i)){
        num++;
      }else{
        ans+=num*(num-1)/2;
        num=1;
      }
    }
  }
  ans+=num*(num-1)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792