akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  std::string S;
  std::cin >> S;
  std::cout << (S[0] == '7' || S[1] == '7' || S[2] == '7' ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3624
from fractions import gcd


def lcm(a, b):
    return a // gcd(a, b) * b


A, B, C, D = map(int, input().split())

L = lcm(C, D)
numB = B - (B // C + B // D - B // L)
numA_1 = (A - 1) - ((A - 1) // C + (A - 1) // D - (A - 1) // L)
print(numB - numA_1)


Measured memory_bytes: 5716
n, k = map(int, (input().split()))
r, s, p = map(int, (input().split()))
t = input()

d = {'r': p, 's': r, 'p': s}
ans = 0

for i in range(k):
    last = ''
    j = i
    while j < n:
        if t[j] != last:
            ans += d[t[j]]
            last = t[j]
        else:
            last = ''
        j += k

print(ans)

Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    var sC = mutableMapOf<Char,Char>()
    var tC = mutableMapOf<Char,Char>()
    var result = "Yes"

    run loop@{
        for(i in s.indices){
            if(sC.containsKey(s[i]) && sC[s[i]] != t[i]){
                result = "No"
                return@loop
            }
            if(tC.containsKey(t[i]) && tC[t[i]] != s[i]){
                result = "No"
                return@loop
            }
            sC[s[i]] = t[i]
            tC[t[i]] = s[i]
        }
    }

    println(result)

}

Measured memory_bytes: 35560
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        
            String T = sc.nextLine();
            
            for(int i=0;i<T.length();i++){
                
          	  if( Character.isUpperCase( T.charAt( i ) ) ) {	
                
          		  System.out.print(Character.toLowerCase( T.charAt( i )) );
                
				}else if (Character.isLowerCase( T.charAt( i ) )){
                
          			  System.out.print(Character.toUpperCase( T.charAt( i )) );
                
            	}else{
                   System.out.print( T.charAt( i ));
              }
            }
                        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26936
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    FOR(i,a,b+1){
        string s=to_string(i);
        string t=s;
        reverse(all(t));
        if(s==t){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <bitset>
#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 all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr const ll MAX = 15;
constexpr int nx[4] = {1,0,-1,0};
constexpr int ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
class Ford_Fulkerson{
    private:
        struct edge{
            ll to,cap,rev;
        };
        ll siz;
        vector<vector<edge>> edges;
        vector<bool> done;
    public:
        Ford_Fulkerson(ll n){
            edges.resize(n);
            done.assign(n,0);
            siz = n;
        }
        void add_edge(ll from,ll to,ll cap){
            edges[from].push_back((edge){to,cap,(ll)edges[to].size()});
            edges[to].push_back((edge){from,0,(ll)edges[from].size()-1});
        }
        ll dfs(ll v,ll t,ll f){
            if (v == t) return f;
            done[v] = true;
            for(auto &e:edges[v]){
                if (e.cap > 0 && !done[e.to]){
                    ll d = dfs(e.to,t,min(f,e.cap));
                    if (d > 0){
                        e.cap -= d;
                        edges[e.to][e.rev].cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }
        ll max_flow(ll s,ll t){
            ll flow = 0;
            while(true){
                done.assign(siz,0);
                ll f = dfs(s,t,INF);
                if (f == 0) return flow;
                flow += f;
            }
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll v,e;
    cin >> v >> e;
    Ford_Fulkerson g(v);
    ll from,to,c;
    rep(i,e){
        cin >> from >> to >> c;
        g.add_edge(from,to,c);
    }
    PRINT(g.max_flow(0,v-1));
}



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

int main() {
  string s, t;
  cin >> s >> t;
  int i;
  for (i = 0; i < s.length() + 2; i++) {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    s.push_back(s.at(0));
    s.erase(s.begin());
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main(void) {
    unsigned long int n, k;
    scanf("%ld %ld", &n, &k);
    unsigned long int ans;

    n = n % k;
    ans = (n <= k-n) ? n : k-n;

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

    return 0;
}

Measured memory_bytes: 128
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let r: usize = itr.next().unwrap().parse().unwrap();
    println!("{}", 3 * r * r);
}


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

int main() {
	int n; cin >> n;
	vector<char> s(n); rep(i,n) cin >> s[i];
	vector<char> t(n); rep(i,n) cin >> t[i];

	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

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

using namespace std;

const long long maxv=100000;
const long long oo=LLONG_MAX;
long long N,W;
unsigned long long w[103],v[103];
unsigned long long F[103][maxv+1];

void Enter()
{
    //freopen("INPUT.TXT","r",stdin);
  //  freopen("OUTPUT.TXT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>N>>W;
    for(long long i=1; i<=N; ++i)
        cin>>w[i]>>v[i];
}


int main()
{
    Enter();
    memset(F,0,sizeof(F));
    for(long long i=0; i<=N; ++i) {
        for(long long j=0; j<=maxv; ++j) {
            F[i][j]=oo;
        }
    }
        F[0][0]=0;
    for(long long i=0; i<=N; ++i) {
        for(long long j=0; j<=maxv; ++j) {
            if (F[i][j]==oo) continue;
            if (F[i][j]+w[i+1]<=W)
                F[i+1][j+v[i+1]]=min(F[i][j]+w[i+1],F[i+1][j+v[i+1]]);
            F[i+1][j]=min(F[i+1][j],F[i][j]);
        }
    }
    for(long long j=maxv; j>=1; --j) {
        if (F[N][j]!=oo)
        {
            cout<<j;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 80896
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A[2] - A[0] << endl;
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;

  int a[n][m];
  int b[m];

  int i, j;
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(i = 0; i < m; i++){
    cin >> b[i];
  }

  int result = 0;
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      result += a[i][j] * b[j];
    }
    cout << result << endl;
    result = 0;
  }
}



Measured memory_bytes: 3136
#include <stdio.h>
#include <math.h>
#define Lim 1000000007

int main( void ){
	int H,W,K;
	int pat[63][10]={0};
	int i,j,b,flg,cnt=0;
	unsigned long count[10]={0,1,0,0,0,0,0,0,0,0},count2[10];
	
	scanf("%d%d%d",&H,&W,&K);
	for(i=0;i<pow(2,W-1);i++){
		b=i;
		flg=1;
		for(j=1;j<9;j++){
			pat[cnt][j]=b%2;
			b=b/2;
			if( pat[cnt][j]==1 && pat[cnt][j-1]==1 ){
				flg=0;
				j=9;
			}
		}
		if( flg==1 ) cnt++;
	}

	for(i=0;i<H;i++){
		for(j=0;j<10;j++) count2[j]=0;
		for(j=0;j<cnt;j++){
			for(b=1;b<9;b++){
				if( pat[j][b]==1 ) count2[b+1]+=count[b];
				else if( pat[j][b-1]==1 ) count2[b-1]+=count[b];
				else count2[b]+=count[b];
				count2[b]=count2[b]%Lim;
			}
		}
		for(j=0;j<10;j++) count[j]=count2[j];
	}
	printf("%ld\n",count[K]%Lim);
	return 0;
}

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

using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back

int di[] = {1,-1,1,-1};
int dj[] = {1,1,-1,-1};

void color(int n, int d, vi &color) {
	bool vis[n*n];
	fill(vis,vis+n*n,0);
	vi dx,dy;
	for (int x = 0; x*x<=d; x++) {
		int y = int(sqrt(d-x*x));
		if (x*x+y*y==d)
			dx.pb(x),dy.pb(y);
	}
	function<void(int,int,int)> dfs = [&](int i, int j, int v) {
		color[i*n+j] = v; vis[i*n+j] = 1;
		f(z,0,dx.size()) {
			f(k,0,4) {
				int ni = i+di[k]*dx[z], nj = j+dj[k]*dy[z];
				if (IN(ni,0,n-1) && IN(nj,0,n-1) && !vis[ni*n+nj])
					dfs(ni,nj,v^1);
			}		
		}
	};
	f(i,0,n) f(j,0,n) if (!vis[i*n+j]) dfs(i,j,0);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; cin >> n;
	n*=2;
	int d1,d2; cin>>d1>>d2;
	vi c1(n*n),c2(n*n);
	color(n,d1,c1); color(n,d2,c2);
	stringstream ss;
	f(mask,0,4) {
		vi pos;
		f(i,0,n*n) if (c1[i]+(c2[i]<<1) == mask)
			pos.pb(i);
		if (pos.size() >= n*n/4) {
			f(i,0,n*n/4)
				ss << (pos[i]/n) << " " << (pos[i]%n) << endl;
			break;
		}
	}
	cout << ss.str();

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 39412
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int n,a,b;
   cin>>n>>a>>b;
   int ans=0;
   for(int i=1;i<=n;i++){
      int m=i;
      int dsum=0;
      while(m>0){
         dsum += m%10;
         m/=10;
      }
      if(dsum>=a && dsum<=b)ans+=i;
   }
   cout<<ans<<endl;
   
   



}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n, i, q;
		List<String> list = new ArrayList<String>();

		n = scan.nextInt();

		for (i = 0; i < n; i++) {
			q = scan.nextInt();

			switch (q) {
			case 0:
				list.add(scan.next());
				break;
			case 1:
				System.out.println(list.get(scan.nextInt()));
				break;
			case 2:
				list.remove(list.size()-1);
				break;
			default:
				continue;
			}
		}
		
		scan.close();
	}
}


Measured memory_bytes: 124304
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll mem[100010];
bool l[100010];
int main(){
    int n, m;
    while(cin>>n>>m){
        ll ans=0;
        int x;
        for(int i=0; i<m; ++i){
            scanf("%d",&x);
            l[x]=1;
        }
        mem[n]=1;
        ll mod=1e9+7;
        for(int i=n-1; i>=0; --i){
            if(l[i])
                continue;
            mem[i]=mem[i+1]+mem[i+2];
            mem[i]%=mod;
        }
        cout<<mem[0]<<endl;
    }
  return 0;
}




Measured memory_bytes: 1152
int main(){
  int n;
  double **X,**Y;
  int i,j;
  scanf("%d",&n);
  X=malloc((n+1)*sizeof(double *));
  for(i=0;i<=n;i++) X[i]=malloc(sizeof(double)*(pow(4,i)+1));
  Y=malloc((n+1)*sizeof(double *));
  for(i=0;i<=n;i++) Y[i]=malloc(sizeof(double)*(pow(4,i)+1));
  
  X[0][0]=0.0;
  X[0][1]=100.0;
  Y[0][0]=0.0;
  Y[0][1]=0.0;

  double cos60,sin60;
  cos60=0.5;
  sin60=pow(3,0.5)/2;
 
  int k,stop;
  for(i=1;i<=n;i++){
    k=0;
    stop=pow(4,i-1);
    for(j=0;j<stop;j++){
      X[i][4*j]=X[i-1][j];
      Y[i][4*j]=Y[i-1][j];
      X[i][4*j+1]=X[i][4*j] + (X[i-1][j+1]-X[i-1][j])/3;
      Y[i][4*j+1]=Y[i][4*j] + (Y[i-1][j+1]-Y[i-1][j])/3;
      X[i][4*j+2]=X[i][4*j+1] +cos60*(X[i-1][j+1]-X[i-1][j])/3 -sin60*(Y[i-1][j+1]-Y[i-1][j])/3;
      Y[i][4*j+2]=Y[i][4*j+1] +sin60*(X[i-1][j+1]-X[i-1][j])/3 +cos60*(Y[i-1][j+1]-Y[i-1][j])/3;
      X[i][4*j+3]=X[i][4*j] + 2*(X[i-1][j+1]-X[i-1][j])/3;
      Y[i][4*j+3]=Y[i][4*j] + 2*(Y[i-1][j+1]-Y[i-1][j])/3;
    }
    X[i][4*stop]=100.0;
    Y[i][4*stop]=0.0;
  }
  

  for(i=0;i<=pow(4,n);i++) printf("%lf %lf\n",X[n][i],Y[n][i]);
  return 0;
}



Measured memory_bytes: 2140
import sys
import math as mas

a=[]
for t in sys.stdin:
	i=int(t)
	if i:a.append(i)
	else:
		print(a[-1])
		a.pop()

#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

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

using namespace std;

const int N = 3001;

int n;
int arr[N];
long long dp[N][N][2];

long long rec(int i, int j, int t){
  if(i > j) return 0;
  long long& ijt = dp[i][j][t];
  if(ijt != -1) return ijt;
  if(t == 0) ijt = max(rec(i + 1, j, 1 - t) + arr[i], rec(i, j - 1, 1 - t) + arr[j]);
  else ijt = min(rec(i + 1, j, 1 - t) - arr[i], rec(i, j - 1, 1 - t) - arr[j]);
  return ijt;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  memset(dp, -1, sizeof dp);
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long ans = rec(0, n - 1, 0);
  cout << ans << "\n";
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>m;
    si a;
    mii ma;
    c=0;
    while(m--)
    {   string s;
        cin>>x>>s;
        if(s=="AC")
        {
           if(!a.count(x)) a.insert(x);
        }
        else
        {
            if(!a.count(x))ma[x]++;
        }
        

    }
    
    for(auto p:ma)
    {
        if(a.count(p.ff))c+=p.ss;
    }
    
    cout<< sz(a)<<" "<<c <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,r,l) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(_typeof_((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

const int MOD=1000000007;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
void printFrequency(vector<int> v) 
{ 
    unordered_map<int, int> M; 
  
     
    for (int i = 1; i<v.size(); i++) { 
  
        if (M.find(v[i]) == M.end()) { 
            M.insert(make_pair(v[i], 1)); 
        } 
 
        else { 
            M[v[i]]++; 
        } 
    } 

}
void add_self(int &a, int b){
  a+=b;
  if(a>=MOD){
    a-=MOD;
  }
}

void sub_self(int &a, int b){
  a-=b;
  if(a<0){
    a+=MOD;
  }
}

int search(vi x,int n,int i){
  int l=0,h=n-1,mid;
  while(l<=h){
    mid=(l+h)/2;
    if(x[mid]<i){
      l=mid+1;
    }else{
      h=mid-1;
    }
  }
  return l;
}
bool check9(string s){
    for(int i=0;i<s.size();i++) if(s[i]!='9') return 0;
    return 1;
}
void swap(int &a,int &b){
    int c=a;
    a=b;
    b=c;
}
const int INF=-2000;
const ll INF_=1e13;
void solve(){
   long long n;
  cin>>n;
  vector<long long> v(n);
  long long ans;
  cin>>ans;
  v[0]=ans;
  for(int i=1;i<n;i++)
  {
    cin>>v[i];
  	ans=(ans^v[i]);
  }
  for(int i=0;i<n;i++)
    cout<<(ans^v[i])<<" ";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

  int t;
//   cin>>t;
t=1;
  while(t--){
      solve();
  }
}

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

using namespace std;

const int MAX { 200010 };

vector<int> adj[MAX];

int distA[MAX], distB[MAX];

void dfs(int u, int d, int p, int *dist)
{
    dist[u] = d;

    for (auto v : adj[u])
        if (v != p)
            dfs(v, d + 1, u, dist);
}

int solve(int N, int a, int b)
{
    dfs(a, 0, 0, distA);
    dfs(b, 0, 0, distB);

#ifdef DEBUG
    cout << "dists : " << endl;
    for (int u = 1; u <= N; ++u)
        cout << distA[u] << (u == N ? '\n' : ' ');

    for (int u = 1; u <= N; ++u)
        cout << distB[u] << (u == N ? '\n' : ' ');
#endif
    int ans = 0;

    for (int u = 1; u <= N; ++u)
        if (distA[u] < distB[u])
            ans = max(ans, distB[u]);

    return ans - 1;
}

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

    int N, u, v;
    cin >> N >> u >> v;

    for (int i = 0; i < N - 1; ++i)
    {
        int a, b;
        cin >> a >> b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    auto ans = solve(N, u, v);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i = 1; i < s.size(); ++i)
        if (s[i] == s[i - 1])
            return cout << "Bad", 0;
    cout << "Good";
}


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

namespace TYC
{
	typedef long long ll;
	
	const int N = 1 << 18 | 5, mod = 998244353;

	int n, A[N], B[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	int inv(const int x) { return x == 1 ? 1 : int((ll)inv(mod % x) * (mod - mod / x) % mod); }

	void FWT(int *a)
	{
		for (int len = 1; len < n; len <<= 1)
			for (int i = 0; i < n; i += len << 1)
				for (int k = 0; k < len; k++)
				{
					int x = a[i + k], y = a[i + len + k];
					a[i + k] = (x + y) % mod;
					a[i + len + k] = (x - y + mod) % mod;
				}
	}

	void IFWT(int *a)
	{
		static const int INV2 = (mod + 1) >> 1;
		for (int len = 1; len < n; len <<= 1)
			for (int i = 0; i < n; i += len << 1)
				for (int k = 0; k < len; k++)
				{
					int x = a[i + k], y = a[i + len + k];
					a[i + k] = int((ll)(x + y) * INV2 % mod);
					a[i + len + k] = int((ll)(x - y + mod) * INV2 % mod);
				}
	}

	void work()
	{
		n = 1 << read();
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum = (sum + (A[i] = read())) % mod;
		for (int i = 0, tmp = inv(sum); i < n; i++)
			A[i] = int((ll)A[i] * tmp % mod);
		A[0] = (A[0] - 1 + mod) % mod;
		for (int i = 0; i < n; i++)
			B[i] = mod - 1;
		B[0] = (n - 1 + mod) % mod;
		FWT(A), FWT(B);
		sum = 0;
		for (int i = 1; i < n; i++)
		{
			A[i] = i == 0 ? B[i] : int((ll)B[i] * inv(A[i]) % mod);
			sum = (sum + A[i]) % mod;
		}
		A[0] = sum;
		IFWT(A);
		for (int i = 0; i < n; i++)
			printf("%d\n", (A[i] - A[0] + mod) % mod);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int a[2][8]={
	{2,10,3,9,4,8,6,12},
	{6,2,10,3,9,4,8,12}
};
int n,i;
int main(){
	cin>>n;
	if(n==3){
		puts("2 5 63");
		return 0;
	}
	for(i=0;i<n;i++){
		cout<<a[n&1][i&7]<<' ';
		a[n&1][i&7]+=12;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define PMAX 1000000000
int w[100000],wmax;
int f(int p,int n,int k){
    int now=p,count=1;
    int i;
 
    if(p<wmax) return 0;
    for(i=0;i<n;i++){
	if(now>=w[i]){
	    now-=w[i];
	}else{
	    count++;
	    now=p-w[i];
	}
    }
    if(count>k) return 0;
    else return 1;
}
    
int main(void){
    int n,k,i;
    int left,right,mid;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
	scanf("%d",&w[i]);
	if(w[i]>wmax) wmax=w[i];
    }

    left=1;right=PMAX;
    while(left<right){
	mid=(left+right)/2;
	if( f(mid,n,k) ) right=mid;
	else left=mid+1;
    }

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

Measured memory_bytes: 984
#include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
using namespace std;

int main(){
    int a[4] = {6000,4000,3000,2000},n,m;
    
    
    rep(i,0,4){
        cin >> n >> m;
        a[n-1] *= m;
        cout << a[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXV=1000;
const int MAXE=2000;
const ll INF=1e18;

struct edge{
    int from,to;
    ll cost;
};

int n,m;
ll p;
vector<edge> es(MAXE);
vector<ll> d(MAXV,INF);

int main(){
    int v,e,r;cin>>v>>e>>r;
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        es[i]=edge{s,t,d};
    }
    d[r]=0;
    for(int i=0;i<v;i++){
        for(int j=0;j<e;j++){
            edge ed=es[j];
            if(d[ed.from]!=INF&&d[ed.to]>d[ed.from]+ed.cost){
                d[ed.to]=d[ed.from]+ed.cost;
                if(i==v-1){
                    cout<<"NEGATIVE CYCLE"<<endl;
                   return 0;
                }
            }
        }
    }
    for(int i=0;i<v;i++){
        if(d[i]==INF) cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def bfs(maze, H, W, sh, sw, gh, gw):
    visited = [[-1] * W for _ in range(H)]
    visited[sh][sw] = 0

    q = deque([(sh, sw)])

    while q:
        h, w = q.popleft()

        if h == gh and w == gw:
            return visited[gh][gw]

        for dh, dw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            nh = h + dh
            nw = w + dw
            if 0 <= nh < H and 0 <= nw < W:
                if visited[nh][nw] == -1 and maze[nh][nw] == ".":
                    visited[nh][nw] = visited[h][w] + 1
                    q.append((nh, nw))

    return -1


def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    white = 0
    for h in range(H):
        for w in range(W):
            if S[h][w] == ".":
                white += 1

    dist = bfs(S, H, W, 0, 0, H - 1, W - 1)
    if dist == -1:
        print(-1)
        return

    ans = white - (dist + 1)
    print(ans)


if __name__ == "__main__":
    main()


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


int main() {
	string s; cin >> s;
	int N = 0, W = 0, S = 0, E = 0;
	for (char c : s) {
		if (c == 'N')N++;
		if (c == 'W')W++;
		if (c == 'S')S++;
		if (c == 'E')E++;
	}
	if (N == 0 && S >= 1)puts("No");
	else if (N >= 1 && S == 0)puts("No");
	else if (W == 0 && E >= 1)puts("No");
	else if (W >= 1 && E == 0)puts("No");
	else puts("Yes");
	return 0;
}

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

std::bitset<2000010> dp;

using namespace std;

int main()
{
  int N;
  cin >> N;
  
  vector<int> A;
  int a,sum = 0;
  for (int i = 0; i < N; i++) {
      cin >> a;
      A.push_back(a);
      sum += a;
  }
  
  dp[0] = true;
  for (int i = 0; i < N; i++) {
      dp |= dp << A[i];
  }
  
  int ans;
  for (int k = sum / 2; k >= 0; k--) {
      if (dp[k]) {
          ans = k;
          break;
      }
  }
  
  cout << sum - ans << endl;
  return 0;  
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,m,o=1,hd[N],out[N],f[N],st[N],idx,a[N],cnt,dep[N],fm[N],fa[N];
struct edge{int u,v,t;}e[N];
struct Edge{int v,nt,id;}E[N<<1];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
bool uni(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy)return f[fx]=fy,true;
	return false;
}
void adde(int u,int v,int id){
	E[o]=(Edge){v,hd[u],id};hd[u]=o++;
	E[o]=(Edge){u,hd[v],id};hd[v]=o++;
}
void dfs(int u,int F){
	st[u]=++idx;if(out[u])a[++cnt]=u;
	for(int i=hd[u];i;i=E[i].nt){
		int v=E[i].v;
		if(v==F)continue;
		dep[v]=dep[u]+1;
		fm[v]=E[i].id;
		fa[v]=u;
		dfs(v,u);
	}
}
void update(int u,int v){
	if(dep[u]<dep[v])swap(u,v);
	for(;dep[u]>dep[v];e[fm[u]].t^=1,u=fa[u]);
	for(;u!=v;e[fm[u]].t^=1,e[fm[v]].t^=1,u=fa[u],v=fa[v]);
}
bool cmp(int x,int y){return st[x]<st[y];}
int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;++i)f[i]=i;
	for(int i=1,u,v;i<=m;++i){
		scanf("%d%d",&u,&v);
		e[i]=(edge){u,v,0};out[u]^=1;
		if(uni(u,v))adde(u,v,i);
	}
	for(int i=1;i<=n;++i)if(find(i)==i)dfs(i,0);
	int fg=0;
	//sort(a+1,a+cnt+1,cmp);
	for(int i=1;i<=cnt;i+=2){
		if(find(a[i])!=find(a[i+1])){fg=1;break;}
		update(a[i],a[i+1]);
	}
	if(fg)puts("-1");else{
		for(int i=1;i<=m;++i)
		if(!e[i].t)printf("%d %d\n",e[i].u,e[i].v);
		else printf("%d %d\n",e[i].v,e[i].u);
	}
	return 0;
}

Measured memory_bytes: 12672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = k-q;
		}
		for(int i = 0; i < q; i++) {
			int cnum = sc.nextInt()-1;
			a[cnum]+=1;
		}
		for(int i:a) {
			if(i > 0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 76672
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{
  int N, M; cin >> N >> M;
  vector<pair<int, int>> arr(N);
  rep(i, 0, N) cin >> arr[i].first >> arr[i].second;
  vector<vector<int>> works(100001);
  rep(i, 0, N){
    works[arr[i].first].push_back(arr[i].second);
  }

  priority_queue<int> pq;
  ll ans = 0;
  repe(i, 1, M){

    for(auto x: works[i]){
      pq.push(x);
    }

    if(!pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
}


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

int main(){
	ll n; string s; cin >> n >> s;
	ll q; cin >> q;
	while(q--){
		ll k; cin >> k;
		ll m=0,c=0,cnt=0;
		ll ans = 0;
		rep(i,k-1){
			if(s[i]=='M') m++;
			if(s[i]=='C') cnt += m, c++;
		}
		rep(i,n){
			if(i+k<=n) if(s[i+k-1]=='C') c++, cnt += m;
			if(i+k<=n) if(s[i+k-1]=='M') m++;
			if(s[i]=='D') ans += cnt;
			if(s[i]=='M') m--, cnt -= c;
			if(s[i]=='C') c--;
		}
		cout << ans << endl;
	}
}

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

#define rep(i,a,b) for(int i=a;i<(b);i++)
#define trav(a,x) for(auto & a :x)
#define all(x) begin(x),end(x)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector<pii>
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;


const int M=1e9+7;

/*
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;    
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
*/


void solve()
{ 

int n;
cin>>n;

int arr[n+1];
int ans;

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

if(i==0)
ans=arr[i];
else
ans=ans^arr[i];
}

for(int i=0;i<n;i++)
cout<<(ans^arr[i])<<" ";

}

int main() 
{   
    ios::sync_with_stdio(0);
	cin.tie(0);
  
   int test=1;
   //cin>>test;
   while(test--)
    {
	  solve();
	  cout<<"\n";
    }
  return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  ll sum = a + b;
  ll ans = min(n % sum, a);
  if (n > a)
  {
    ans += a * ((n / sum));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
struct node {
	int l, r;
}a[100000 + 20];

bool cmp(node a, node b) {
	if (a.r == b.r) {
		return a.l < b.l;
	}
	return a.r < b.r;
}

int main() {
	int n, m, i;
	scanf("%d %d", &n, &m);
	for (i = 0; i < m; ++i) {
		scanf("%d %d", &a[i].l, &a[i].r);
	}

	int mn = a[0].r;
	for (i = 0; i < m; ++i) {
		mn = min(a[i].r, mn);
	}

	sort(a, a + m, cmp);

	int now = mn, ans = 1;
	for (i = 1; i < m; ++i) {
		if (a[i].l >= now) {
			now = a[i].r;
			ans++;
		}
	}

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	int k; cin >> k;
	int x = max(a, max(b, c));
	int ans = x;
	for(int i=0;i<k;i++){
		ans *= 2;
	}
	cout << a+b+c+ans-x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> lovedCount(M, 0);

    for (size_t i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (size_t j = 0; j < K; j++) {
            int a;
            cin >> a;
            lovedCount[a - 1]++;
        }
    }

    cout << count(lovedCount.begin(), lovedCount.end(), N) << endl;
}

Measured memory_bytes: 256
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const N = arr[0];
    const K = arr[1];
    const h = line[1].split(" ").map(Number);
    console.log(h.reduce((pre, cur) => pre + (K <= cur ? 1 : 0), 0));
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 36848
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    String end = n.substring(n.length()-1);
    int num = Integer.parseInt(end);
    
    switch(num){
      case 3:
        System.out.println("bon");
        break;
      case 0:
      case 1:
      case 6:
      case 8:
        System.out.println("pon");
        break;
      default:
        System.out.println("hon");
    }
  }
}


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

#define fer( a , b , c ) for( register int a = b ; a <= c ; a ++ )
#define der( a , b , c ) for( register int a = b ; a >= c ; a -- )

  using namespace std ;

inline int read(){
	int sum = 0 , f = 1 ;
	char ch = getchar() ;
	while( ch < '0' || ch > '9' ){
		if( ch == '-' ){
			f = -1 ;
		}
		ch = getchar() ;
	}
	while( ch >= '0' && ch <= '9' ){
		sum = ( sum << 1 ) + ( sum << 3 ) + ( ch ^ 48 ) ;
		ch = getchar() ;
	}
	return sum * f ;
}

int n ;
long long ans = 0 ;

signed main(){
    n = read() ;
    fer( i , 1 , n ){
        if( n % i == 0 ){
            ans += n / i - 1 ;
        }
        else{
            ans += n / i ;
        }
    }
    printf( "%lld" , ans ) ;
	return 0 ;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();
		String[] splitT = T.split("", 0);
		int score = 0;

		ArrayList<String> modT = new ArrayList<String>();
		for (int i = 0; i < K; i++) {
			for (int j = i; j < N; j += K) {
				modT.add(splitT[j]);
			}
			String remind = null;
			for (String mod : modT) {
				switch (mod) {
				case "s":
					if(mod.equals(remind)){
						remind +=" ";
						continue;
					}
					score += R;
					remind = mod;
					continue;
				case "p":
					if(mod.equals(remind)){
						remind +="a";
						continue;
					}
					score += S;
					remind = mod;
					continue;
				case "r":
					if(mod.equals(remind)){
						remind +=" ";
						continue;
					}
					score += P;
					remind = mod;
					continue;
				}
			}
			modT.clear();
		}

		System.out.println(score);
	}
}


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

int main() {
	string a, s, c;
	cin >> a >> s >> c;
	
	string A="A";
	string C="C";
	s = s.substr(0, 1);
	
	cout << A+s+C;
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int h[12], w[12];
  int i, j, k;
  int num = 0;

  while ( (h[num-1] != 0) || (w[num-1] != 0) ) {
    scanf("%d %d", &h[num], &w[num]);
    ++num;
  }

  for ( k = 0; k < num; ++k ) {
    for ( i = 0; i < h[k]; ++i ) {
      for ( j = 0; j < w[k]; ++j ) {
        if ( (i*j == 0) || ( i == h[k]-1 ) || (j == w[k]-1) ) {
          printf("#");
        } else {
          printf(".");
        }
      }
      putchar('\n');
    }
    if ( k != num-1 ){
      putchar('\n');
    }
  }

  return 0;

}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int mod = 1000000007;

int main(){
    string s; cin >> s;
    bool t = true;
    rep(i,3){
        if (s[i] == '7'){
            cout << "Yes" << endl;
            t = false;
            break;
        }
    }
    if (t) cout << "No" << endl;
}


Measured memory_bytes: 3624
n,m=map(int,input().split())
a=[0]*m;b=[0]*m
for i in range(m):a[i],b[i]=map(int,input().split())
r=[False]*n
r[0]=True
c=0
def sol(x):
    global c
    if all(r):c+=1;
    else:
        for i in range(m):
            if a[i]==x and r[b[i]-1]==False:
                r[b[i]-1]=True
                sol(b[i])
                r[b[i]-1]=False
            if b[i]==x and r[a[i]-1]==False:
                r[a[i]-1]=True
                sol(a[i])
                r[a[i]-1]=False
sol(1)
print(c)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

ll ans = 0;
void dfs(int i, int c) {

}

int main() {
	char s[11];
	scanf("%s", s);

	char list[] = "ACTG";
	int ans = 0;
	int cnt = 0;
	REP(i, strlen(s)) {
		REP(j, strlen(list)) {
			if (s[i] == list[j]) {
				cnt++;
				break;
			}
			if (j == strlen(list) - 1) {
				ans = Max(ans, cnt);
				cnt = 0;
			}
		}
	}
	ans = Max(ans, cnt);
	PRINTD(ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>

using namespace std;

int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if(S.length()<=K){
        cout << S;
    }else{
        cout << S.erase(K) << "...";
    }
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=100010;
ll a,b,d,e,x,y,z,k,m,n,h,w,l,q,ans=0;
vl v,v1,v2;
ll xmax,xmin,ymax,ymin;
char c;
string s1,s2;
ll solve(void){
    xmax=h;
    xmin=1;
    ymax=w;
    ymin=1;
    for(ll i=n-1;i>-1;i--){
        if(v2[i]==4)ymin=fmaxl(ymin-1,1);
        if(v2[i]==3)ymax=fminl(ymax+1,w);
        if(v2[i]==2)xmin=fmaxl(xmin-1,1);
        if(v2[i]==1)xmax=fminl(xmax+1,h);

        if(v1[i]==4)ymax=ymax-1;
        if(v1[i]==3)ymin=ymin+1;
        if(v1[i]==2)xmax=xmax-1;
        if(v1[i]==1)xmin=xmin+1;
        if(ymax<1)return -1;
        if(ymin>w)return -1;
        if(xmax<1)return -1;
        if(xmax>h)return -1;
        if(xmax<xmin)return -1;
        if(ymax<ymin)return -1;
        
        
        //cout<<xmax<<xmin<<ymax<<ymin<<endl;
    }
    
    //cout<<xmax<<xmin<<ymax<<ymin<<endl;

    if(xmin<x+1&&x-1<xmax&&ymin<y+1&&y-1<ymax)return 1;
    return -1;
}
int main(){
    cin>>h>>w>>n;
    cin>>x>>y;
    cin>>s1>>s2;
    rep(i,n){
        if(s1[i]=='U')v1.push_back(1);
        if(s2[i]=='U')v2.push_back(1);
        if(s1[i]=='D')v1.push_back(2);
        if(s2[i]=='D')v2.push_back(2);
        if(s1[i]=='L')v1.push_back(3);
        if(s2[i]=='L')v2.push_back(3);
        if(s1[i]=='R')v1.push_back(4);
        if(s2[i]=='R')v2.push_back(4);
    }
    
    if(solve()==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3956
#include <stdio.h>
#include <string.h>
const int N = 1300;
int main()
{
	char str[N];
	while(fgets(str, 1300, stdin))
	{
		int sum = 0;
		if(str[0] == '0')
		{
			break;
		}
		for(int i = 0;i < strlen(str)-1;i++)
		{
			sum += str[i] - '0';
		}
		printf("%d\n", sum);
	}
	return 0;
 } 


Measured memory_bytes: 2668
N, M, V, P = map(int, input().split())
A = [int(i) for i in input().split()]

A.sort()

s = [A[0]]
for i in range(1, N) :
  s.append(A[i] + s[-1])

def check(m) :
  if m >= N - P :
    return True
  if A[m] + M < A[N - P] :
    return False

  rest = M * (V - P)
  x = A[m] + M
  for i in range(N - P + 1) :
    if i == m :
      continue
    rest -= min(x - A[i], M)
  return rest <= 0

ng, ok = -1, N
while ok - ng > 1 :
  m = (ok + ng) // 2
  if check(m) :
    ok = m
  else :
    ng = m

print(N - ng - 1)


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

int main(){
	map<int, int> m, r;
	int a[6], n, x, y;
	int d[6][6]={{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},
		{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
	for(int i = 0;i < 6;i++){cin >> a[i];m[a[i]] = i;r[i] = a[i];}
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x >> y;
		int tmp = d[m[x]][m[y]];
		cout << r[tmp-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3088
K,Q = map(int,input().split())
D = list(map(int,input().split()))
NXM = [tuple(map(int,input().split())) for i in range(Q)]

for N,X,M in NXM:
    ds = [d%M for d in D]
    a,b = divmod(N-1,K)
    s = 0
    z = 0
    for i,d in enumerate(ds):
        if i==b:
            sb = s
            zb = z
        if d==0:
            z += 1
        s += d
    x = (X + s*a + sb)//M - X//M
    y = z*a + zb
    print(N-1-x-y)

Measured memory_bytes: 68824
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    char c1 = s1[0] - 'a' + 'A';
    char c2 = s2[0] - 'a' + 'A';
    char c3 = s3[0] - 'a' + 'A';
    cout << c1 << c2 << c3 << endl;
    re0;
}

Measured memory_bytes: 256