akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    int Q;
    cin >> Q;
    int N = 100001;
    vector<int> a(N,0);
    vector<bool> b(N,false);
    vector<int> s(N+1,0);
    
    rep(i,0,N) {
        if (IsPrime(i)){
            b[i] = true;
        }
    }
    rep(i,0,N) {
        if (b[i]&&b[(i+1)/2]) {
            a[i]=1;
        }
    }
    rep(i,0,N) {
        s[i+1] = s[i] + a[i];
    }

    int ans[Q];
    int l,r;
    rep(i,0,Q) {
        cin >> l >> r;
        ans[i] = s[r+1]-s[l];
    }
    rep(i,0,Q) {
        cout << ans[i] << endl;
    }
 }



Measured memory_bytes: 1792
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n,m;
    while(cin>>n>>m){
        cout << ((n*(n-1))/2)+((m*(m-1))/2)<<endl;
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define LL			(long long)
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace SHENZHEBEI;
const ll N=110,mod=1e9+7;
ll f[N][N][N],a[N],ans,n;
int main(){
	n=read();
	For(i,1,2*n-1)a[i]=read();
	sort(a+1,a+2*n);	f[1][0][0]=1;
	For(i,2,n){
		ll	Add1=(a[n-i+1]!=a[n-i+2]),Add2=(a[n+i-1]!=a[n+i-2]);
		For(X,0,n*2)For(Y,0,n*2){
			ll x=X+Add1,y=Y+Add2,res=f[i-1][X][Y];
			rep(left,0,x)Add(f[i][left][y+1],res);
			rep(rigt,0,y)Add(f[i][x+1][rigt],res);
			Add(f[i][x][y],res);
		}
	}
	For(i,0,n*2)For(j,0,n*2)Add(ans,f[n][i][j]);
	writeln(ans);
}
/*
*/

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

string s,temp;
int f,n=5,l=2,r=1,len,flag;
int main()
{
    while(cin>>s)
    {
        s=s+"ooooo";
        f=0;flag=0;
        len=s.length();
        while(f<len&&!flag)
        {
            temp=s.substr(f,n);
            if(temp=="dream")
            {
                f+=n;
                temp=s.substr(f,n);
                if(temp=="erase"||temp=="dream");
                else if(temp=="erera"||temp=="erdre") f+=l;
                else if(temp=="ooooo"||temp=="erooo") f=len;
                else
                    flag=1;
            }
            else if(temp=="erase")
            {
                f+=n;
                temp=s.substr(f,n);
                if(temp=="dream"||temp=="erase");
                else if(temp=="rdrea"||temp=="reras") f+=r;
                else if(temp=="ooooo"||temp=="roooo") f=len;
                else
                    flag=1;
            }
            else
                flag=1;
        }
        if(flag)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const int MAX_K = 5;

set<string> ss;

int main()
{
    string s;
    int K;
    cin >> s >> K;

    REP (i, (int)s.length())
    {
        REP (j, MAX_K)
        {
            string tmp = s.substr(i, j + 1);
            ss.insert(tmp);
        }
    }

    set<string>::iterator itr = ss.begin();
    cout << *next(itr, K - 1) << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using lb=long double;
using db=double;
const ll mod=1e9+7;
const int maxn=2e5+7;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int temp;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        if(temp!=0)
        {
            a[temp-1]++;
            a[temp]++;
            a[temp+1]++;
        }
        else
        {
            a[temp]++;
            a[temp+1]++;
        }
    }
    int f=-1,ans=-1;
    for(int i=0;i<=100001;i++)
    {
        if(a[i]>ans)
        {
            ans=a[i];
            f=i;
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n, max_w = map(int, input().split())

w = []
v = []
for i in range(n):
    _w, _v = map(int, input().split())
    w.append(_w)
    v.append(_v)

total_v = sum(v)


INF = float('inf')
dp = [[INF] * (total_v + 1) for i in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(total_v + 1):
        if j >= v[i]:
            dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i + 1][j])
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])

for j in range(total_v, -1, -1):
    if dp[n][j] <= max_w:
        ans = j
        break

print(ans)

Measured memory_bytes: 311888
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
#define MAXN 200005

vector<int> g[MAXN];
map<int,int> mmm[MAXN];
ll sons[MAXN],h[MAXN],res[MAXN],mk[MAXN],c[MAXN];

void dfs(int u)
{
    mk[u]=1;
    h[u]=-1;
    int h2=-1;
    sons[u]=1;
    vector<int> s;
    for(auto v : g[u])
        if(!mk[v])
        {
            dfs(v);
            s.push_back(v);
            sons[u]+=sons[v];
            if(h[u]==-1 || sons[v]>sons[h2])
            {
                h[u]=h[v];
                h2=v;
            }
        }

    if(h[u]==-1)
    {
        h[u]=u;
        mmm[u][c[u]]=1;
        return ;
    }

    ll v=sons[h2]-mmm[h[h2]][c[u]];
    res[c[u]]-=(v*(v+1))/2;
    for(auto y : s)
    {
        if(y==h2)
            continue;
        ll v=sons[y]-mmm[h[y]][c[u]];
        res[c[u]]-=(v*(v+1))/2;
        for(auto pp : mmm[h[y]])
            mmm[h[u]][pp.first]+=pp.second;
    }

    mmm[h[u]][c[u]]=sons[u];
}

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

    ll n,u,v;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> c[i];
        c[i]--;
    }
    for(int i=0;i<n-1;i++)
    {
        cin >> u >> v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    for(int i=0;i<n;i++)
        res[i]=(n*(n+1))/2;

    dfs(0);

    for(int i=0;i<n;i++)
    {
        v=n-mmm[h[0]][i];
        res[i]-=(v*(v+1))/2;
    }

    for(int i=0;i<n;i++)
        db(res[i])

    return 0;
}


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

int main() {
	int n;cin>>n;
	vector<long long> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<long long> s(n+(n+1)/2);
	for(int i=0;i<s.size();i++){
		s[i]=a[(i*2)%n];
	}
	for(int i=1;i<s.size();i++){
		s[i]+=s[i-1];
	}
	long long sum=s[n-1];
//	for(int i=0;i<s.size();i++){
//		cout<<s[i]<<' ';
//	}cout<<endl;
	for(int i=0;i<n;i++){
		int idx=(n+1)/2+i/2+(n-1)/2*((i+1)%2);
		cout<<sum-2*(s[idx-1]-s[idx-(n+1)/2])<<endl;
	}

	return 0;
}


Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N; cin>>N;
  int W[N];
  int S=0;
  for(int i=0; i<N; i++){
    cin>>W[i];
    S+=W[i];
  }
  int s=S;
  int ans=INF;
  for(int i=0; i<N; i++){
    s-=W[i];
    int l=max(S-2*s, 2*s-S);
    ans=min(l, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n;
    vector <int> a,used;
    set<int> s;
    Problem(LL n):n(n),a(n),used(n){};

    void solve(){
        for(int i=0; i<n; ++i){
            cin >> a[i];
            a[i]--;
            if(a[i]==i)a[i]=1;
            else {
                a[i]=0;
                s.insert(i);
            }
        }
        s.insert(n);
        int ans =0;
        for(int i=0; i<n;++i){
            if(a[i]==0)continue;
            int lb = *s.lower_bound(i);
            int dist = lb-i;
            if(dist%2==0){
                ans += dist/2;
            }else{
                //if(i>0 and used[i-1]==0){
                    ans+=(dist+1)/2;
                //}else{
                    //ans+=(dist+1)/2;
                    //used[lb]=1;
                //}
            }
            i=lb;
        }

        cout <<ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 5760
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int N = in.nextInt();
        String s = in.next();
        int n = s.length();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = ((s.charAt(i)-'A')+N)%26;
        }
        for(int i=0;i<n;i++){
            out.write((char)('A'+a[i])+"");
        }
        out.write("\n");
    }
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 1000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans;
    }
    else ans = fast_exp(x, n - 1) * x;
    return ans;
}
ll a[N], b[N], c[N], o[N], z[N];
vector<int> tree[N];
ll solve(ll x, ll p)
{
    ll ans = 0;
    for(auto i:tree[x])
    {
        if(i != p)
        {
            a[i] = min(a[i], a[x]);
            ans += solve(i, x);
            o[x] += o[i];
            z[x] += z[i];
        }
    }
    if(b[x] != c[x])
    {
        if(b[x]) o[x]++;
        else z[x]++;
    }
    if(o[x] && z[x])
    {
        ans += 2 * a[x] * min(o[x], z[x]);
        ll y = min(o[x], z[x]);
        o[x] -= y;
        z[x] -= y;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, ans = 0, k;
        cin >> n;
        for(ll i = 2; i * i <= n; i++)
        {
            if(n % i == 0)
            {
                x = 0;
                while(n % i == 0)
                    x++, n /= i;
                ans += (sqrt(8 * x + 1) - 1) / 2;
            }
        }
        if(n > 1) ans++;
        cout << ans << "\n";
     }
     return 0;
}


Measured memory_bytes: 8336
#include <bits/stdc++.h>
	#define hell                         1000000007 
	#define M                            1000000007
	#define Maxi                      10000000000000000
	#define lcm(a,b)                     (a*b)/__gcd(a,b)
	#define ll                           long long
 
	#define vll                          vector<ll>
	#define vi                           vector<long long>
	#define pll                          vector< pair<ll,ll> >
	#define pb                           push_back
	//#define mp                           make_pair
	#define all(v)                       v.begin(),v.end()
	#define lbnd                         lower_bound
	#define ubnd                         upper_bound
	#define bs                           binary_search
	#define F                            first
	#define S                            second
	#define rep(i,a,b)                   for(i=a;i<b;i++)
	#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
	#define ret(x)                       return cout<<x,0;
	#define dbg(x)                       cout << #x << " is " << x << endl;
	//#define endl                           '\n'
 
 
	// Debug //
 
	#define trace(x)                 cerr << #x << ": " << x << endl;
	#define trace1(x)                cerr << #x << ": " << x << endl;
	#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
	#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
	#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
	#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
	#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
 
	using namespace std;
 	
	int main()
	{
 
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);cout.tie(NULL);
		

	 	ll n;
	 	cin>>n;
	 	ll a[n],i,j;
	 	ll b[n];
	 	map<ll,ll>m1;
	 	map<pair<ll,ll>,ll>m2;
	 	for(i=0;i<n;i++)
	 	{
	 		cin>>a[i];
	 	}
	 	for(i=1;i<=n;i++)
	 	{
	 		ll x;
	 		cin>>x;
	 		m1[i]=x;
	 	}
	 	for(i=1;i<n;i++)
	 	{
	 		ll x;
	 		cin>>x;
	 		m2[{i,i+1}]=x;
	 	}

	 	ll sum=0;
	 	sum+=m1[a[0]];
	 	//cout<<sum<<endl;
	 	ll pre;
	 	pre=a[0];
	 	for(i=1;i<n;i++)
	 	{
	 		ll val;
	 		val=a[i];
	 		sum+=m1[val];
	 		//cout<<val<<" "<<pre<<endl;
	 		if(val-pre==1)
	 		{
	 			sum+=m2[{pre,val}];
	 		}
	 		//cout<<sum<<endl;
	 		pre=val;
	 	}
	 	cout<<sum<<endl;
 
		return 0;
		}
	 	


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,n,t;
    scanf("%d",&n);
    if(n>=500)
    {
        a=n/500;
        n=n%500;
        b=a*1000;
        n=n/5;
        c=n*5;
        t=c+b;
        printf("%d\n",t);
    }
    else
    {
        a=n/5;
        b=a*5;
        printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
const int MM = 220000;
lli m,n,k,p1,p2,p3,p,f,a[MM];
string s,s1,s2;
set<lli> g[MM];
int main(){
    fio;
        // Have you solved the problem completely?
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>p1>>p2;
        g[p1-1].insert(p2-1);
        g[p2-1].insert(p1-1);
    }
    if (g[0].find(n-1) != g[0].end()) {
        cout<<"POSSIBLE";
        return 0;
    }
    for(lli u : g[0])
    {
        if(g[u].find(n-1) != g[u].end())
        {
            cout<<"POSSIBLE";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 29312
//
//  main.cpp
//  A
//
//  Created by Yoshinao Itakura on 2020/08/22.
//  Copyright © 2020 Yoshinao Itakura. All rights reserved.
//


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
using namespace std;

int main(int argc, const char * argv[]) {
    int N, X, T;
    cin >> N >> X >> T;
    int number = (N+X-1)/X ;
    cout <<T*number << endl;
    return 0;
}


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

using namespace std;

#define ll long long

signed main() {
	int n, k; cin >> n >> k;
	map<int, vector<int>> idx;
	int acc = 0; idx[0].push_back(0);
	for (int i = 1; i <= n; ++i) {
		int ai; cin >> ai;
		acc += ai - 1;
		idx[acc %= k].push_back(i);
	}
	ll ans = 0;
	for (auto& e : idx) {
		for (int i = 0; i < e.second.size(); ++i) {
			auto iter = lower_bound(e.second.begin() + i, e.second.end(), e.second[i] + k);
			ans += distance(e.second.begin() + i, iter) - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22144
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    res = 0
    prev = None
    for a in A:
        res += B[a-1]
        if prev == a-1:
            res += C[a-2]
        prev = a
    print(res)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import sys
from collections import Counter
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    D = Counter(A)

    dup = set()
    for k, v in D.items():
        if v > 1:
            dup.add(k)

    judge = [False] * (A[-1] + 1)
    res = 0
    for a in A:
        if judge[a]:
            continue
        else:
            if a not in dup:
                res += 1
            for i in range(a, A[-1] + 1, a):
                judge[i] = True

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38400
import sys
from sys import stdin, stdout

rem=10**9+7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())

n=input()
ans=[1 for i in range(n+1)]
pos={}
for i in range(1,n+1):
    x=take()[0]
    pos[x]=i
for i in range(n-1,0,-1):
    if pos[i]<pos[i+1]:
        ans[i]=ans[i+1]+1
#print(ans)
print n-max(ans)

Measured memory_bytes: 37252
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val count = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        count[a[i]] = (count[a[i]] ?: 0) + 1
    }
    val ok = BitSet(1000005)
    for (i in 0 until n) {
        ok[a[i]] = true
    }
    a.sort()
    var ans = 0
    for (i in 0 until n) {
        if (ok[a[i]] && count[a[i]]!! == 1) {
            ans++
        }
        if (ok[a[i]]) {
            var j = 1
            while (a[i] * j < 1000005) {
                ok[a[i] * j] = false
                j++
            }
        }
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 72616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, k; cin >> n >> k;
  int r, s, p; cin >> r >> s >> p;
  string t; cin >> t;
  vector<char> v[k];
  rep(i, t.size()){
    v[i % k].push_back(t[i]);
  }
  map<char, int> m;
  m['r'] = p; m['p'] = s; m['s'] = r;
  ll ans = 0;
  rep(i, k){
    rep(j, v[i].size()){
      if(j == 0){
        ans += m[v[i][j]];
      }
      else{
        if(v[i][j-1] == v[i][j]){
          v[i][j] = 'c';
        }
        else{
          ans += m[v[i][j]];
        }
      }
    }
  }
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 5364
import numpy as np
import math

N = int(input())

c = np.zeros((10, 10), dtype=int)
d = np.zeros((10, 10), dtype=int)

for n in range(1, N+1):
    k = math.floor(math.log10(n)) + 1
    #print('桁数: ', k)
    i = n// (10 ** (k-1))
    #print('1番大きな桁の数: ', i)
    j = n%10
    #print('1の位の数: ', j)
    c[i][j] += 1
    d[j][i] += 1

ans = np.sum(c*d)
print(ans)

Measured memory_bytes: 20912
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e3+5 ;

int n ,m ,u[N][N] ,l[N][N] ,r[N][N] ,d[N][N] ;
char str[N][N] ;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%s",str[i]);
        int cur = 0 ;
        for(int j=0;j<m;++j){
            if(str[i][j]=='#') cur = 0 ;
            else ++cur ;
            l[i][j] = cur ;
        }
        cur = 0 ;
        for(int j=m-1;j>=0;--j){
            if(str[i][j]=='#') cur = 0 ;
            else ++cur ;
            r[i][j] = cur ;
        }
    }
    for(int j=0;j<m;++j){
        int cur = 0 ;
        for(int i=0;i<n;++i){
            if(str[i][j]=='#') cur = 0 ;
            else ++cur ;
            u[i][j] = cur ;
        }
        cur = 0 ;
        for(int i=n-1;i>=0;--i){
            if(str[i][j]=='#') cur = 0 ;
            else ++cur ;
            d[i][j] = cur ;
        }
    }
    int ans = 0 ;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(str[i][j]=='#')continue ;
            int cur = u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3 ;
            ans = max(ans,cur);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 66944
#include<bits/stdc++.h>
#define PI 3.1415926535898
using namespace std;
int main()
{
	double h,m,a,b;
	cin>>a>>b>>h>>m;
	printf("%.10f",sqrt((a*cos(PI/6.0*(h+m/60))-b*cos(PI/30.0*m))*(a*cos(PI/6.0*(h+m/60))-b*cos(PI/30.0*m))+(a*sin(PI/6.0*(h+m/60))-b*sin(PI/30.0*m))*(a*sin(PI/6.0*(h+m/60))-b*sin(PI/30.0*m))));
	return  0;
} 

Measured memory_bytes: 4100
X,Y = map(int,input().split())

prize=0

kingaku = {1:300000, 2:200000, 3:100000 }

if X in kingaku:
    prize +=  kingaku[X]

if Y in kingaku:
    prize +=  kingaku[Y]
    
if X == 1 and Y == 1:
    prize += 400000
print(prize)

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

#define debug(val) "[ " << #val " : " << (val)
#define space " "
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define pi pair<int , int >
#define ff first
#define ss second
#define INF 2000000000
#define delta 0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};
const int Mod = 1000 * 1000 * 1000 + 7 ;
vll mul_mat(vll a , vll b) {
    vll res(2 , vl(2,0)) ;
    int n = 2 ;
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                res[i][j] += a[i][k] * b[k][j] ;
                res[i][j] %= Mod ;
            }
        }
    }

    return res ;
}

void solve() {
    int n ;
    cin >> n ;
    int d ;
    cin >> d;
    int ans = 0 ;
    for(int i=0;i<n;i++){
        ll x , y ;
        cin >> x >> y ;
        long double  res = sqrt(x * x + y * y ) ;
        if(res <d || abs(res - d ) <= delta ) ans ++ ;

    }
    cout << ans ;
}


int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}

Measured memory_bytes: 3676
from operator import itemgetter


n, m = map(int, input().split())

if m == 0:
    print(0, 0)
    exit()

l = []
for i in range(m):
    p, s = map(str, input().split())
    l.append([int(p), s])
l.sort(key = itemgetter(0))

numAC = 0
numWA = 0
countWA = 0
AC = False
last = l[0][0]

for i in range(m):
    if last == l[i][0]:
        if AC:
            continue
        elif l[i][1] == "AC":
            numAC += 1
            numWA += countWA
            AC = True
        else:
            countWA += 1
    else:
        last = l[i][0]
        AC = False
        if l[i][1] == "AC":
            numAC += 1
            AC = True
        else:
            countWA = 1

print(numAC, numWA)

Measured memory_bytes: 23628
#include <iostream>
using namespace std;
int main()
{
	
	char line1[3], line2[3];
	cin >> line1;
	cin >> line2;
	int counter = 0;
	for (int i = 0; i < 3; i++) {
		if (line1[i] == line2[i])counter++;
	}
	std::cout << counter;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::cmp::min;
// use itertools::Itertools;

#[fastout]
fn main() {
  input!{
    n: usize,
    m: usize,
    x: u32,
    ca: [(u32, [u32;m]);n]
  };
  let end = 1 << n;

  let mut bit = 1;
  let mut ans = std::u32::MAX;
  while bit & end == 0 {
    let mut xs = vec![0; m];
    let mut c = 0;
    for i in 0..n {
      if bit & 1 << i != 0 {
        c += ca[i].0;
        for j in 0..m {
           xs[j] += ca[i].1[j];
        }
      }
    }
    if xs.iter().all(|_x| _x >= &x) {
      ans = min(ans, c);
    }
    bit += 1;
  }
  if ans < std::u32::MAX {
    println!("{}", ans);
  } else {
    println!("-1");
  }
}


Measured memory_bytes: 2212
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
		int sum = a+b;
		int valLen = String.valueOf(sum).length();
		System.out.println(valLen);
		}

	}

}


Measured memory_bytes: 26112
H, W = map(int, input().split())
a = []
for i in range(H):
    b = input()
    if "#" in b:
        a.append(b)
field = []
for j in range(W):
    c = ''
    for k in range(len(a)):
        c += a[k][j]
    if "#" in c:
        field.append(c)

length = len(field[0])
result = []
for k in range(length):
    newfield = ''
    for l in range(len(field)):
        newfield += field[l][k]
    print(newfield)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==(b+c)){
     printf("Yes\n");
    }
    else if(b==(a+c)){
      printf("Yes\n");
    }

    else if(c==(a+b)){
      printf("Yes\n");
    }
    else{
           printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class DGatheringChildren {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.nextLine();
            char c = 'R';
            List<Integer> cnt = new ArrayList<>();
            int temp = 0;
            for (char ch : str.toCharArray()) {
                if (ch == c) {
                    temp++;
                } else {
                    cnt.add(temp);
                    temp = 1;
                    c = c == 'R' ? 'L' : 'R';
                }
            }
            cnt.add(temp);
            int[] res = new int[str.length()];
            int r = 0;
            for (int i = 0; i < str.length() - 1; i++) {
                if (str.charAt(i) == 'R' && str.charAt(i + 1) == 'L') {
                    int tot = cnt.get(2 * r) + cnt.get(2 * r + 1);
                    if ((tot & 1) == 0) {
                        res[i] = tot / 2;
                        res[i + 1] = tot / 2;
                    } else {
                        if ((cnt.get(2 * r) & 1) == 0) {
                            res[i] = tot / 2;
                            res[i + 1] = tot / 2 + 1;
                        } else {
                            res[i] = tot / 2 + 1;
                            res[i + 1] = tot / 2;
                        }
                    }
                    r++;
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i : res) {
                sb.append(i).append(" ");
            }
            out.println(sb);
        }

    }

    static class Scanner {
        private BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



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

using vll = std::vector<long long>;

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<long long> a_sum(n + 1);
	std::vector<vll> lr(n, vll(n + 1, 1LL << 60));
	for (int i{}; i < n; i++)
	{
		scanf("%lld", &a_sum[i + 1]);
		a_sum[i + 1] += a_sum[i];
	}
	for (int i{}; i < n; i++)
		lr[i][i + 1] = 0;
	for (int size{2}; size <= n; size++)
		for (int left{}; left + size <= n; left++)
			for (int mid{left + 1}; mid < n; mid++)
				lr[left][left + size] = std::min(lr[left][left + size], lr[left][mid] + lr[mid][left + size] + a_sum[left + size] - a_sum[left]);
	printf("%lld\n", lr[0][n]);

	return 0;
}

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



int main() {
	int N;
  	double T,A;
  	cin >> N >> T >> A;
  
  //平均気温
  double t[N];
  for (int i = 0;i<N;i++){
  double H;
  cin >> H;
    t[i] =T-H*0.006;
  }
    
    int ans = 0;
  
  for (int i=1;i<N;i++){
  //絶対値求めてiからのほうが近ければ更新
   if(abs(A -t[i])<abs(A-t[ans]))
     ans=i;
     }
  cout <<ans+1<<endl;
    }
 

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int k,n,i,dif,diff;
  int sum=0;
  scanf("%d", &k);
  scanf("%d", &n);
  int a[n];
  for(i=0;i<n;i++){
  scanf("%d", &a[i]);
  }
  dif=a[1]-a[0];
  for(i=1;i<n-1;i++){
    diff=a[i+1]-a[i];
    if(dif<diff){
    dif=diff;
    }
  }
  diff=(k-a[n-1])+(a[0]);
  if(dif<diff){
  dif=diff;
  }
  sum=k-dif;
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 2496
import qualified Data.ByteString.Char8 as BC
import Data.IORef
import Control.Monad
import Data.Maybe(fromJust)

main :: IO()
main = BC.getContents >>= solve.map (fst.fromJust.BC.readInt).tail.BC.lines >>= print

solve :: [Int] -> IO Int
solve (x:y:xs) = do
                  a <- newIORef (y - x)
                  b <- newIORef (min x y)
                  forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                  readIORef a

Measured memory_bytes: 5836
from numba import njit
N = int(input())
L = list(map(int, input().split()))
L.sort()

@njit
def solve(L):
    cnt = 0
    for i in range(N-2):
        a = L[i]
        for j in range(i+1, N-1):
            b = L[j]
            for k in range(j+1, N):
                cnt += a+b > L[k]
    return cnt
print(solve(L))

Measured memory_bytes: 111400
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,v[100010];
    double ans;
    cin>>n;
    rep(i,n){
        cin>>v[i];
    }
    sort(v,v+n);
    ans=(double)(v[0]+v[1])/2;
    rep2(i,2,n){
        ans=(double)(ans+(double)v[i])/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        public void Start()
        {
            var line = int.Parse(Console.ReadLine());
            Console.ReadLine();
            Console.ReadLine();
            Console.ReadLine();
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());

            if(e-line <= k){
                Console.WriteLine("Yay!");
            } else {
                Console.WriteLine(":(");
            }
        }

        List<List<int>> IntInit()
        {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<int>> array = new List<List<int>>();

            for (int i = 0; i < maxindex; i++)
            {
                array.Add(new List<int>(
                Console.ReadLine().Split(' ').Select(int.Parse)));
            }

            return array;
        }
    }
}




Measured memory_bytes: 11092
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod, range;
	vector<int> fac, ifac;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	void set_mod(int _mod){mod = _mod;}
	int add(int x,int y){return (x+y)%mod;}
	int sub(int x,int y){return (x-y+mod)%mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int x,int y){
		int r = 1;
		while(1){
			if(y&1)r=mul(r,x);
			if(y>>=1)x=mul(x,x);else
				break;
		}
		return r;
	}
};
/*####*/

modular_arithmetic ma;
int c[333][333];
int N,K,m;
int tree[333][333];
int forest[333][333];
int sum[333][333];
void addto(int&x,int y){
	x = ma.add(x,y);
}

int main(){
	scanf("%d%d%d",&N,&K,&m);
	ma.set_mod(m);
	for(int i=0; i<333; i++)
	for(int j=0; j<=i; j++)
		c[i][j] = j==0||j==i?1:ma.add(c[i-1][j],c[i-1][j-1]);
	for(int len=1; len<=N; len++){
		for(int x=1; x<=K; x++){
			if(len==1)tree[len][x] = 1;else
				tree[len][x] = ma.sub(sum[len-1][K], sum[len-1][x-1]);
		}
		for(int x=1; x<=K; x++){
			forest[len][x] = tree[len][x];
			for(int i=1; i<len; i++)
				addto(forest[len][x], ma.mul(ma.mul(tree[i][x], c[len][i]), ma.sub(sum[len-i][K], sum[len-i][x])));
			sum[len][x] = ma.add(sum[len][x-1], forest[len][x]);
		}
	}
	printf("%d\n",sum[N][K]);
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>


using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int C, K;
	cin >> C >> K;
	int ans = 0;
	int wait = -1;
	int cap = 0;
	vi T(N);
	REP(i, N)cin >> T[i];
	so(T);
	REP(i, N) {
		if (wait < T[i] || cap == C) {
			ans++;
			wait = K + T[i];
			cap = 0;
		}
		cap++;
	}
	cout << ans << endl;
	system("pause");
	return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    ll n, k;
    cin >> n >> k;

    // 処理
    cout << k * pow(k - 1, n - 1) << endl;

    // 出力

    return 0;
}


Measured memory_bytes: 384