akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    string s; cin >> s;
    bool ans = false;
    rep(i,2) if(s[i] != s[i+1]) ans = true;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
// #define FNAME "template"

#include <bits/stdc++.h>
using namespace std;

typedef long long inte;
const int maxn = 200005;

#ifndef NDEBUG
#    define dprint(x) (cerr << (#x) << " = "<< (x) << endl)
#else
#    define dprint(x) (NULL)
#endif

template<typename T>
inline void readFig(T& x)
{
#   ifdef FTREAD
        static int c = 0;
        int op = 1;
        x = 0;
        while (!isdigit(c)) {
            if (c == '-')
                op = -1;
            c = getchar();
        }
        while (isdigit(c)) {
            x *= 10;
            x += c - '0';
            c = getchar();
        }
        x *= op;
#   else
        cin >> x;
#   endif
}

struct Edge {
    int u, v;
    inte w;
} edges[maxn * 2];

bool operator <(const Edge& a, const Edge& b)
{
    return a.w < b.w;
}

inte tra[maxn];

int par[maxn];
int getPar(int x)
{
    if (par[x] == x)
        return x;
    else 
        return par[x] = getPar(par[x]);
}

inline void solve()
{
    memset(tra, 0x3f, sizeof(tra));
    int N, Q;
    readFig(N); readFig(Q);
    for (int i = 1; i <= N; ++i)
        par[i] = i;
    for (int i = 1; i <= Q; ++i) {
        inte A, B, C;
        readFig(A); readFig(B); readFig(C);
        edges[i].u = A;
        edges[i].v = B;
        edges[i].w = C;
        tra[A] = min(tra[A], C + 1);
        tra[B] = min(tra[B], C + 2);
    }
    for (int i = 0; i < N * 2; ++i)
        tra[(i + 1) % N] = min(tra[(i + 1) % N], tra[i % N] + 2);
    for (int i = 0; i < N; ++i) {
        const int p = i + Q + 1;
        edges[p].u = i;
        edges[p].v = (i + 1) % N;
        edges[p].w = tra[i];
    }
    const int tot = N + Q;
    sort(edges + 1, edges + tot + 1);
    inte ans = 0;
    int cnt = 0;
    for (int i = 1; i <= tot; ++i) {
        if (getPar(edges[i].u) != getPar(edges[i].v)) {
            par[getPar(edges[i].u)] = getPar(edges[i].v);
            ans += edges[i].w;
            ++cnt;
        }
    }
    assert(cnt == N - 1);
    cout << ans << endl;
}

signed main()
{
#   ifdef FNAME
        freopen(FNAME".in", "r", stdin);
        freopen(FNAME".out", "w", stdout);
#   endif
#   ifndef FTREAD
    	ios::sync_with_stdio(false);
    	cin.tie(0);
#   endif

#   ifdef MULTEST
        int T;
        readFig(T);
        while (T--)
            solve();
#   else
        solve();
#   endif

#   ifdef FNAME
        fclose(stdin);
        fclose(stdout);
#   endif
    	return 0;
}



Measured memory_bytes: 18492
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b;
            var word = Console.ReadLine().Split(' ');
            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);
            if (n * a < b)
                Console.WriteLine(n * a);
            else if (n * a > b)
                Console.WriteLine(b);
            else if (n * a == b)
                Console.WriteLine(b);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"
#define cauto const auto

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
template<class A,class B> pair<A,B> operator+(const pair<A,B> &p,const pair<A,B> &q){ return {p.X+q.X,p.Y+q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator+=(const pair<A,B> &p,const pair<C,D> &q){ p.X+=p.X; q.Y+=q.Y; return p;}
template<class A,class B> pair<A,B> operator-(const pair<A,B> &p,const pair<A,B> &q){ return {p.X-q.X,p.Y-q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator-=(const pair<A,B> &p,const pair<C,D> &q){ p.X-=p.X; q.Y-=q.Y; return p;}
template<class A,class B> istream& operator>>(istream &is, pair<A,B> &p){ is>>p.X>>p.Y; return is;}
template<class T> T read(){ T re; cin>>re; return re;}
template<class T> T read(const T &dec){ T re; cin>>re; return re-dec;}
template<class T> vector<T> readV(const int sz){ vector<T> re(sz); for(auto &x:re) x=read<T>(); return re;}
template<class T> vector<T> readV(const int sz, const T &dec){ vector<T> re(sz); for(auto &x:re) x=read<T>(dec); return re;}
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cauto n=read<int>();
	cauto es=readV<pii>(n-1,{1,1});
	ll re=0;
	reps(i,1,n+1) re+=i*(n+1ll-i);
	for(auto [a,b]:es) re-=(min(a,b)+1ll)*(n-max(a,b));
	cout<<re NL;
  return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  if (b - a < 2 * k)
    for (int i = a; i <= b; i++)
      cout << i << endl;
  else
  {
    for (int i = a; i < a + k; i++)
      cout << i << endl;
    for (int i = b - k + 1; i <= b; i++)
      cout << i << endl;
  }
  return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  if(N>=M){
    cout << 0 << endl;
    return 0;
  }
  vector<int> X(M);
  for(int i=0;i<M;i++){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  priority_queue<int> L;
  for(int i=1;i<M;i++){
    L.push(X.at(i)-X.at(i-1));
  }
  int64_t sum=0;
  for(int i=0;i<N-1;i++){
    sum+=L.top();
    L.pop();
  }
  int64_t ans=X.back()-X.front()-sum;
  cout << ans << endl;
  return 0;
}


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

vector<int> a;

inline int maketwo(){
    sort(a.begin(),a.end(),greater<int>());
    int ans=0;
    rep(i,a.size()-1){
        if(a.at(i)==a.at(i+1)){
            ans=a.at(i);
            a.erase(a.begin()+i,a.begin()+i+2);
            break;
        }
    }
    return ans;
}
signed main(){
    int n; cin>>n;
    rep(i,n){
        a.push_back(0);
        cin>>a.at(i);
    }
    int ans1,ans2;
    ans1=maketwo(); ans2=maketwo();
    cout<<ans1*ans2<<endl;
}

Measured memory_bytes: 1400
N,K=map(int,input().split(" "))

ans=[0]*N

#print(ans)

for i in range(K):
  d=int(input())
  A=[int(_) for _ in input().split(" ")] 
  
  for j in range(d):
    ans[A[j]-1] += 1

#print(ans)
    
ans=ans.count(0)
print(ans)

Measured memory_bytes: 9188
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool x[5][5];
int a[5][5];
int main()
{
	rep(i,3) rep(j,3) cin>>a[i][j];
	int n,m;cin>>n;
	memset(x,false,sizeof(x));
	rep(k,n){
		cin>>m;
		rep(i,3) rep(j,3){
			if(a[i][j]==m) x[i][j]=true;
		}
	}
	string out="No";
	if(x[0][0] && x[0][1] && x[0][2]) out="Yes";
	if(x[1][0] && x[1][1] && x[1][2]) out="Yes";
	if(x[2][0] && x[2][1] && x[2][2]) out="Yes";
	if(x[0][0] && x[1][0] && x[2][0]) out="Yes";
	if(x[0][1] && x[1][1] && x[2][1]) out="Yes";
	if(x[0][2] && x[1][2] && x[2][2]) out="Yes";
	if(x[0][0] && x[1][1] && x[2][2]) out="Yes";
	if(x[0][2] && x[1][1] && x[2][0]) out="Yes";
	cout<<out<<endl;
}


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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll a, b;
	in a >> b;
	if (a < b)
	{
		out "a < b" en;
	}
	else if (a == b)
	{
		out "a == b" en;
	}
	else
	{
		out "a > b" en;
	}
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define per(i,n) for (int i=n-1; i>=0; --i)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
//ABC174F

//Fenwick tree (Binary Indexed Tree, BIT)

template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n=0): n(n), d(n+1) {}
    void add(int i, T x=1){//場所iにxを足す
        for(i++; i<=n; i+= i&-i){
            d[i] += x;
        }
    }
    T sum(int i){//場所i以下の和
        T x = 0;
        for(i++; i; i -= i&-i){
            x += d[i];
        }
        return x;
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    
    vi s(n,-1);
    vi st(n,-1);
    rep(i,n){
        int c;
        cin >> c;
        c--;
        if(s[c]!=-1)st[s[c]] = i;
        s[c] = i;
    }
    
    vector<vector<P>> lr(n);
    rep(i,q){
        int l,r;
        cin >> l >> r;
        l--;r--;
        lr[l].emplace_back(r,i);
    }
    
    BIT<int> bit(n);
    vi ans(q);
    
    per(i,n){
        if(st[i]!=-1 && st[i])bit.add(st[i]);
        for(P query: lr[i]){
            int r  = query.first;
            int qi = query.second;
            ans[qi] = r-i+1 - bit.sum(r);
        }
    }
    
    rep(i,q)cout<<ans[i]<<endl;
    
    return 0;
}

Measured memory_bytes: 33172
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;

const int INF = 10e8;

void RemainingTime(){

	int a, b;
	cin >> a >> b;
	cout << ((a + b) % 24) << endl;
}

int main() {
	RemainingTime();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;
const int maxN = 12;
const int maxM = 1000 + 5;

int n, m;
int a[maxM], c[maxM];

ll memo[maxM][1 << maxN];
bool calc[maxM][1 << maxN];

ll dp(int i, int bitmask){
    if(i >= m){
        if(bitmask == (1 << n) - 1){
            return 0;
        }
        return INF;
    }

    if(calc[i][bitmask]){
        return memo[i][bitmask];
    }

    ll res = INF;
    res = min(res, dp(i + 1, bitmask));
    res = min(res, dp(i + 1, bitmask | c[i]) + a[i]);

    calc[i][bitmask] = true;
    return (memo[i][bitmask] = res);
}

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

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int b;  cin >> a[i] >> b;
        for(int j = 0; j < b; j++){
            int x;  cin >> x;   x--;
            c[i] |= (1 << x);
        }
    }

    ll ans = dp(0, 0);
    if(ans >= INF){
        cout << "-1\n";
        return 0;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 36096
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,M,K,P,A,B,N;

    long double x;

    string S;

    ll ans=0;
    ll count=0;
    ll flag=0;
    ll temp=0;

vector<ll> aa;
    cin >>N>>K;
    ll d;
    rep(i,N){
        aa.push_back(0);
    }
rep(i,K){
    cin>>d;
rep(j,d){
    cin>>temp;
aa[temp-1]++;
}
}
rep(i,N){
    if(aa[i]==0){
ans++;
    }
}
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	string s;
	while(cin>>s){
		int sum=0,p=1,o=0;
		if(s[0]=='#')break;
		for(int i=s.size()-1;i>0;o++){
			if(o)p*=2;
			if(s[i]=='h')i-=5;
			else i-=4;
		}o=p;
		for(int i=s.size()-1,c=1;i>=0;c++,p/=2){
			if(s[i]=='h'){
				sum-=90*p;
				i-=5;
			}
			else {sum+=90*p;i-=4;}
		}
		while(sum%2==0&&o!=1){
			sum/=2;
			o/=2;
		}
		if(sum>=0)cout<<sum;
		else cout<<sum+90*o;
		if(o==1)cout<<endl;
		else cout<<'/'<<o<<endl;
	}
}

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

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

    int n;
    cin >> n;
    int a;
    cin >> a;
    a--;
    for (int i = 1; i < n; i++) {
        int b;
        cin >> b;
        if (b > a) b--;
        if (b < a) {
            cout << "No" << endl;
            return 0;
        }
        a = b;
    }
    cout << "Yes" << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int>B(N-1);
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }
  vector<int>A(N,1e9);
  for(int i=0;i<N-1;i++){
     A[i]= min(A[i],B[i]);
     A[i+1]= min(A[i+1],B[i]);
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += A[i];
  }
  cout << ans << endl;
    
}
      
    
      


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

int main(){
  int c1, c5, c10, c50, c100, c500;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
  int am;
  am = c1 + (c5 * 5) + (c10 * 10) + (c50 * 50) + (c100 * 100) + (c500 * 500);
  if (am >= 1000) {
      cout << 1 << endl;
  } else {
      cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int N,K;
    int ans;
    cin >> N >> K;
    ans = K;
    if(N > 1){
        for(int i = 2; i <= N; i++){
            ans *= (K-1);
        }
    }
    

    cout << ans << endl;


}

Measured memory_bytes: 504
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;
const int maxn=1e5+5;
typedef long long ll;
int a[105];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int flag=0;
    for(int i=1;i<=n;i++){
        if(a[i]%2==0&&(a[i]%3!=0&&a[i]%5!=0)){
            flag=1;
        }
    }
    if(flag){
        puts("DENIED");
    }
    else{
        puts("APPROVED");
    }

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int N,X;

    cin >> N >> X;

    int mini = 1000;

    for(int i = 0; i < N; i++){
        int m;
        cin >> m;

        mini = min(m, mini);
        X -= m;
    }

    cout << N + X/mini << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n,W;
    cin >> n >> W;
    intl w[n],v[n];
    rep(i,n)cin >> w[i] >> v[i];
    intl dp[n + 1][W + 1];
    m0(dp);
    rep(i,n){
        rep(j,W + 1){
            if(j < w[i])dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j],dp[i][j - w[i]] + v[i]);
        }
    }
    /*rep(i,n + 1){
        rep(j,W + 1)cout << dp[i][j] << " ";
        cout << endl;
    }*/
    cout << dp[n][W] << endl;
    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int A, B;
    cin >> A >> B;
    PRINT(max(0, A - 2 * B));
    return 0;
}

Measured memory_bytes: 256
S=input()

#ord('a')文字からアスキーコードを取得
#chr(97)アスキーコードから文字を取得
for i in range(26):
    c = chr(ord('a') + i)
    if S.count(c) == 0:
        print(c)
        exit(0)
print('None')


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

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

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    int k;
    cin >> k;

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1];
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 256
#78 素数

from math import sqrt

n = int(input())

ans = 0

for i in range(n):
    x = int(input())
    a = 1
    for z in range(2, int(sqrt(x))+1):
        if x % z == 0:
            a = 0
            break
    ans += a
print(ans)


Measured memory_bytes: 5672
package main

import (
	"fmt"
)

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

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	p := make([]int, n)
	apn := 0
	for i := 0; i < n; i++ {
		p[i] = l + i
		apn += p[i]
	}

	absa := 9999999
	ans := 0
	for i := 0; i < n; i++ {
		apnm := apn - p[i]
		if absa > abs(apn - apnm) {
			absa = abs(apn - apnm)
			ans = p[i]
		}
	}
	fmt.Println(apn - ans)
}

Measured memory_bytes: 512
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,k = map(int,input().split())
	print(k * ((k-1)**(n-1)))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 5268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int N,K;
    cin>>N>>K;
    vector<int> p(N);
    rep(i,N){
        cin>>p.at(i);
    }
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,K){
        ans+=p.at(i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

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

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

void solve() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int lr = 0;
  int rl = 0;
  int h = 0;
  rep2(i, 1, N) {
    char a = S[i - 1];
    char b = S[i];
    if(a == b) h++;
    else if(a == 'L') lr++;
    else rl++;
  }
  int k = 0;
  while(true) {
    if(k == K || lr == 0 || rl == 0) break;
    h += 2;
    lr--;
    rl--;
    k++;
  }
  if(k < K) {
    if(lr > 0 && (S[0] == 'L' || S[N - 1] == 'R')) h++;
    else if(rl > 0 && (S[0] == 'R' || S[N - 1] == 'L')) h++;
  }
  cout << h << endl;
}


Measured memory_bytes: 888
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/dp/tasks/dp_c
 * Vacation
 */
public class Main {
	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			int[] b = new int[n];
			int[] c = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
				c[i] = sc.nextInt();
			}

			int[] dpa = new int[n];
			int[] dpb = new int[n];
			int[] dpc = new int[n];
			for (int i = 0; i < n; i++) {
				if (i == 0) {
					dpa[i] = a[i];
					dpb[i] = b[i];
					dpc[i] = c[i];
				} else {
					dpa[i] = maxdp(Integer.MIN_VALUE, dpb[i-1]+a[i], dpc[i-1]+a[i]);
					dpb[i] = maxdp(Integer.MIN_VALUE, dpc[i-1]+b[i], dpa[i-1]+b[i]);
					dpc[i] = maxdp(Integer.MIN_VALUE, dpa[i-1]+c[i], dpb[i-1]+c[i]);
				}
			}

			int dp = maxdp(dpa[n-1], dpb[n-1], dpc[n-1]);
			System.out.println(dp);
		}
	}

	public static int maxdp(int a, int b, int c) {
		if (a < b) a = b;
		if (a < c) a = c;
		return a;
	}
}

Measured memory_bytes: 91260
#include<stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a == 3 && b == 2 || a == 2 && b == 3) {
		printf("1\n");
	}
	if (a == 2 && b == 1 || a == 1 && b == 2) {
		printf("3\n");
	}
	if (a == 1 && b == 3 || a == 3 && b == 1) {
		printf("2\n");
	}
	return 0;
}

Measured memory_bytes: 128
/*
AizuOnline A0069
Title
*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define min(x,y) (((x)>(y))?(y):(x))
int n,m,atari,d;
char amida[30][11];
int kudari[30];
int nobori[30];
//
main()
{
  int i,pos;

  while(EOF != scanf("%d ",&n) && n)
    {
      scanf("%d ",&m);
      scanf("%d ",&atari);
      scanf("%d ",&d);
      for(i=0;i<d;i++)
	scanf("%s",&(amida[i][0]));
#ifdef DEBUG
      printf("sPOS%d bar%d\n",m,d);
#endif
      pos=m;
      kudari[0]=pos;
      for(i=0;i<d;i++)
	{
	  if(pos > 1 && amida[i][pos-2]=='1')
	    --pos;
	  else if(pos < n && amida[i][pos-1]=='1')
	    ++pos;
	  //printf("POS%d\n",pos);
	  kudari[i+1]=pos;
	}
      //printf("POS%d ATA%d\n",pos,atari);
      if(pos == atari)
	{
	  printf("0\n");
	  goto END;
	}
      pos=atari;
      nobori[d]=pos;
      for(i=d-1;i>=0;i--)
	{
	  if(pos > 1 && amida[i][pos-2]=='1')
	    --pos;
	  else if(pos < n && amida[i][pos-1]=='1')
	    ++pos;
	  nobori[i]=pos;
	}
      
      for(i=0;i<=d;i++)
	{
	  int a,b,w;
#ifdef DEBUG2
	  printf("%d:%s %d %d \n",i,amida[i],kudari[i],nobori[i]);
#endif
	  a=kudari[i];
	  b=nobori[i];
	  if(a>b)
	    {w=a;a=b;b=w;}

	  if((b-a)==1)
	  {
#ifdef DEBUG2
	    printf("ab %d %d %c %c\n",a,b,amida[i][a-2],amida[i][b-2]);
#endif
	    if(((a == 1)||(amida[i][a-2] == '0')) &&
	       (amida[i][a-1]=='0') &&
	       ((b == n)||(amida[i][b-1] == '0')))
	      {
		printf("%d %d\n",i+1,a);
		goto END;
	      }
	  }
	}
      printf("1\n"); //cannot reach 
	END:
      ;
    }

return(0);
}

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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> g (h,vector<char> (w));
    queue<P> q;
    int dx[] = {1,0,-1,0};
    int dy[] = {0,1,0,-1};

    rep(i,h){
        rep(j,w){
            cin >> g[i][j];
            if(g[i][j] == '#'){
                q.push(P(i,j));
            }
        }
    }

    bool jud = true;

    while(!q.empty()){
        bool tmp = false;
        P p = q.front(); q.pop();

        rep(i,4){
            if(p.first + dx[i] <= -1 || p.first + dx[i] >= h) continue;
            if(p.second + dy[i] <= -1 || p.second + dy[i] >= w) continue;

            if(g[p.first + dx[i]][p.second + dy[i]] == '#') tmp = true;
        }

        if(!tmp){
            jud = false;
            break;
        }

    }

    if(jud) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
typedef long long int ll;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n; cin >> n;
	string ans = "";
	while(n > 0){
		int x = n%26;
		if(x == 0) x = 26;
		ans = string(1, x + 'a' - 1) + ans;
		if(n%26==0) n-=26;
		n/=26;
	}
	cout << ans << "\n";
}

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

int main()
{
	 ios::sync_with_stdio(false);
	 int N;
	 int i , j;
	 int flag=0;
	 while(cin>>N)
	 {
	 	flag=0;
	 	  for(i=0; i<25; i++)
	 	  {
  	     for(j=0;j<15;j++)
		 	  {
		 	  	 if(4*i+7*j==N)
		 	      {
		 	      	cout<<"Yes\n"; 
							 flag=1;
							 break; 
						} 		 
				 }
				 if(flag) break;
			 }
		 	 
			 if(i>=25)
			 cout<<"No\n";
	 	 
	 }
	 return 0;
}


Measured memory_bytes: 256
n = int(input())
k = 0
num_list = [0] * 12

for i in range(12):
    num_list[i] = 26**(i+1)
    if n <= sum(num_list[:i]):
        k = i
        break
'print(num_list)'
'''print('k=' , k)'''
diff = n - (sum(num_list[:k-1]) + 1)
'''print(diff)'''
ans = ['a']*(k)
arr = [0] * (k)

for i in range(len(ans)):
    
    arr[i] = diff // 26**(len(ans)-1-i)%26

    '''print('arr = ',i,' ', arr[i])'''
    '''print('ans = ',i,' ', ord(ans[i]))'''
    ans[i] = (chr((ord(ans[i]) + arr[i])))
    

print(''.join(ans))

Measured memory_bytes: 9172
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
    input! {
      a: i64,
      v: i64,
      b: i64,
      w: i64,
      t: i64,
    }
    let d = (a - b).abs();
    let x = v - w;

    println!("{}", if t * x >= d { "YES" } else { "NO" });
}


Measured memory_bytes: 2180
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using data_t = pair<ll, ll>;

ll N, T;
vector<data_t> data;

int main() {
    cin >> N;
    for (auto i = 0; i < N; i++) {
        ll a, b; cin >> a >> b;
        data.emplace_back(make_pair(a, b));
    }
    sort(data.begin(), data.end(), [](data_t a, data_t b) { return a.first< b.first; });
    sort(data.begin(), data.end(), [](data_t a, data_t b) { return a.second < b.second; });
    T = 0;
    for (const auto& item : data) {
        T += item.first;
        if (T > item.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int ans = A + B;
	ans = max(ans, A - B);
	ans = max(ans, A * B);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		int a = 0;
		for(var i=0;i<=10;i++){
			a += N / (int)Math.Pow(10,i) % 10;
		}
		string ans = "No";
		if(N%a == 0){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <stdio.h>

#define N 1000

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int res[ N + 1 ] = { 0 };
  int i, j;

  for ( j = 1; j <= N; ++j )
  {
    int d = j;

    for ( i = j + 1; ( d += i ) <= N; ++i )
    {
      ++res[ d ];
    }
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    printf ( "%d\n", res[ n ] );
  }

  return ( 0 );
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(const T x, const S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

// ???????????????????¨?
template<typename T> struct SkewHeap
{
public:
  struct Node
  {
    Node *left, *right;
    T v;
    Node() : left(NULL), right(NULL) {}
    Node(T v) : left(NULL), right(NULL), v(v) {}
  }* root;
  int cnt;
  SkewHeap(T v) : root(new Node(v)), cnt(0) {}

  Node* meld(Node* l, Node* r)
  {
    if(l == NULL) return r;
    if(r == NULL) return l;
    if(l->v < r->v) swap(l, r);
    l->right = meld(l->right, r);
    swap(l->left, l->right);
    return l;
  }

  inline void push(T x)
  {
    Node* n = new Node(x);
    root = meld(root, n);
    cnt += 1;
  }

  inline void pop()
  {
    Node* n = root;
    root = meld(root->right, root->left);
    delete n;
    cnt -= 1;
  }

  inline void pop(Node* root)
  {
    Node* n = root;
    root = meld(root->right, root->left);
    delete n;
  }

  inline T top(){ return root->v; }
  inline int size(){ return cnt; }
  inline bool empty(){ return !cnt; }
};

const int MAX_N = 1000000;
int n, q;
int a, v;
int cnt[MAX_N+1];

int main()
{
  SkewHeap<pii> heap = SkewHeap<pii>(mp(-INF, -INF));

  scanf(" %d %d", &n, &q);
  while(q--){
    scanf(" %d %d", &a, &v);
    cnt[a] += v;
    heap.push(mp(cnt[a], -a));

    while(!heap.empty()){
      pii popop = heap.top();
      if(cnt[-popop.second] == popop.first){
        printf("%d %d\n", -popop.second, popop.first);
        break;
      }
      heap.pop();
    }
  }

  return 0;
}

Measured memory_bytes: 8196
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String code = sc.nextLine().replace("\n", "");
        sc.close();

        for (int i = 1; i < code.length(); i++) {
            if (code.charAt(i - 1) == code.charAt(i)) {
                System.out.println("Bad");
                System.exit(0);
            }
        }
        System.out.println("Good");
    }
}


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

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

    string s;
    cin >> s;
    int len = s.length();
    int count = 0;
    for(int i = 0; i < len; i++) {
    	if(s[i] != s[len - 1 - i]) {
    		count++;
    	}
    }
    cout << count / 2 << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  r,s,p=LI()
  t=S()

  dp=[[0 for _ in range(n+1)]for __ in range(3)]

  for i in range(n):
    hyoka=t[i]

    dp[0][i+1]=max(dp[0][i],dp[1][i],dp[2][i])
    dp[1][i+1]=max(dp[0][i],dp[1][i],dp[2][i])
    dp[2][i+1]=max(dp[0][i],dp[1][i],dp[2][i])

    if i-k<0:
      if hyoka=='s':
        dp[0][i+1]+=r
      elif hyoka=='p':
        dp[1][i+1]+=s
      else:
        dp[2][i+1]+=p
    else:
      if hyoka=='s':
        if not (dp[0][i+1-k]>dp[1][i+1-k] and dp[0][i+1-k]>dp[2][i+1-k]):
          dp[0][i+1]+=r
      elif hyoka=='p':
        if not (dp[1][i+1-k]>dp[2][i+1-k] and dp[1][i+1-k]>dp[0][i+1-k]):
          dp[1][i+1]+=s
      else:
        if not (dp[2][i+1-k]>dp[0][i+1-k] and dp[2][i+1-k]>dp[1][i+1-k]):
          dp[2][i+1]+=p

  # for x in dp:
  #   print(x)
  
  return max(dp[0][n],dp[1][n],dp[2][n])

# main()
print(main())


Measured memory_bytes: 11252
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = Math.PI * r * r;
        double nagasa = 2 * Math.PI * r;
        
        System.out.print(String.format("%.6f %.6f", area,nagasa));
    }
}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

const int MAX_N = (int)1e5 + 10;
vector<bool> isPrime(MAX_N, true);

void eratosthenes(int N){
    rep(i, 2){
        isPrime[i] = false;
    }
    for(int i = 2 ; i * i < N ; i++){
        if(isPrime[i]){
            for(int j = 2 ; i * j < N ; j++){
                isPrime[i*j] = false;
            }
        }
    }
    return;
}

int main(){
    eratosthenes(MAX_N);
    vector<int> sum(MAX_N);
    sum[0] = 0;
    REP(i, 1, MAX_N){
        if(isPrime[i] && isPrime[(i+1)/2]){
            sum[i] = 1;
        }
        sum[i] += sum[i-1];
    }
    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

#define fast_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define show(x) cout << #x << " = " << x << '\n'
#define ll long long
#define ull unsigned long long
#define PI 3.1415926535897932384626433832795
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("-ffloat-store")


int main()
{
    fast_IO
    string str; cin >> str;
    cout << str;
    cout << (str.back() == 's' ? "es\n" : "s\n");
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if (x == 3 || x == 5 || x == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans;
    ans = a * b >= c * d ? a * b : c * d;
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
import java.util.*;


import java.io.*;
import java.math.BigInteger;


public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 51016
#include<stdio.h>

int main(void)
{
   int X,Y,W,H,r;
   
   scanf("%d", &W);
   scanf("%d", &H);
   scanf("%d", &X);
   scanf("%d", &Y);
   scanf("%d", &r);
   
   if(X<r){
      printf("No\n");}
      
   else if(Y<r){
      printf("No\n");}
      
   else if(r>W-X){
      printf("No\n");}
      
   else if(r>H-Y){
      printf("No\n");}
      
   else{
      printf("Yes\n");}
      
   return 0;
}


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

using namespace std;
int value[6] = {1, 5, 10, 50, 100, 500};

int returnCoinNum(int receive)
{
	int ret = 0;
	for (int i = 5; i >= 0; --i)
	{
		ret += receive / value[i];
		receive -= receive / value[i] * value[i];
	}
	return(ret);
}

void solve()
{
	int p;
	vector<int> coin(6);
	while (cin >> p)
	{
		for (int i = 0; i < 6; ++i)
		{
			cin >> coin[i];
		}
		if (p == 0)
		{
			break;
		}
		int minv = 1e9;
		for (int i = p; i <= p + 500; ++i)
		{
			int use = 0;
			int remain = i;
			for (int j = 5; j >= 0; --j)
			{
				int payable = min(remain / value[j], coin[j]);
				remain -= payable * value[j];
				use += payable;
			}
			if (remain != 0)
			{
				continue;
			}
			minv = min(use + returnCoinNum(i - p), minv);
		}
		cout << minv << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
const int NONE = -1;
template< typename T >
struct S
{
    long long node, prev;
    T cost;
    S(long long n, T c, long long p) : node(n), cost(c), prev(p) {}
    bool operator>(const S &s) const
    {
        return cost > s.cost;
    }
};

template< typename T >
class Dijkstra
{
    long long n;
    vector<map<long long, T> > G;

  public:
    vector<T> minc;
    vector<long long> prev;

    Dijkstra(vector<map<long long, T> > &G) : n(G.size()), G(G), minc(n, NONE), prev(G.size()) {}

    void solve(long long start)
    {
        minc.assign(n, NONE);
        priority_queue<S<T>, vector<S<T>>, greater<S<T>> > pq;
        pq.push(S<T>(start, 0, NONE));
        while (!pq.empty())
        {
            S<T> s = pq.top();
            pq.pop();
            if (minc[s.node] != NONE)
            {
                continue;
            }
            minc[s.node] = s.cost;
            prev[s.node] = s.prev;
            for (auto itr = G[s.node].begin(); itr != G[s.node].end(); ++itr)
            {
                pq.push(S<T>(itr->first, s.cost + itr->second, s.node));
            }
        }
    }

    void print()
    {
        for (int i = 0; i < n; i++)
        {
            cout << i << ":" << minc[i] << endl;
        }
    };

    vector<ll> path(ll last)
    {
        vector<ll> stack;
        stack.push_back(last);
        while(prev[stack.back()] != NONE){
            stack.push_back(prev[stack.back()]);
        }
        reverse(stack.begin(),stack.end());
        return stack;
    };
};

int main()
{
  // 整数の入力
  ll N,M;
  cin >> N >> M;
  vector<map<ll,ll>> G(N);
  for(int i = 0;i< M;i++){
    ll a,b;
    scanf("%lld%lld",&a,&b);
    a--;
    b--;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  Dijkstra<ll> dk(G);
  dk.solve(0);
  cout << "Yes" << endl;
  for(int i = 1;i< N;i++){
    cout << dk.prev[i] + 1 << "\n";
  }
  cout << flush;
  return 0;
}

Measured memory_bytes: 76488