akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int main(void)
{
  ll n,cn,ans=0;
  scanf("%lld",&n);
  cn=n;
  if(n==1){
    printf("0");
    return 0;
  }
  for(ll i=2;i*i<=cn;i++){
    if(n%i==0){
      ll cnt=0;
      while(n%i==0){
        cnt++;
        n/=i;
      }
      ll k=1;
      while((cnt-k)>=0){
        ans++;
        cnt-=k;
        k++;
      }
    }
  }
  if(n>1) ans++;
 
  printf("%lld\n",ans);
  return 0;

}

Measured memory_bytes: 1732
S = input()

if S[0] == "A":
    if S[2:-1].count("C") == 1:
        Ssorted = sorted(S)
        if "Z" < Ssorted[2]:#大文字<小文字
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 2940
N=int(input())
A=list(map(int,input().split()))

route=[0]+A+[0]
dis=0

for i in range(1,N+2):
    dis+=abs(route[i]-route[i-1])

for j in range(1,N+1):
    if (route[j-1]<=route[j] and route[j]<=route[j+1]) or (route[j+1]<=route[j] and route[j]<=route[j-1]):
        print(dis)
    elif (route[j-1]<=route[j+1] and route[j+1]<=route[j]) or (route[j]<=route[j+1] and route[j+1]<=route[j-1]):
        print(dis-abs(route[j+1]-route[j])*2)
    else:
        print(dis-abs(route[j-1]-route[j])*2)



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

using namespace std;

#define rep(i,x,n) for(int i=x;i<n;i++)
#define repe(i,x,n) for(int i=x;i<=n;i++)
#define repn(i,x,n) for(int i=x;i>=n;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define F first
#define S second
#define mod 1000000007

typedef long long ll;

const double PI=3.14159265;

vector<double>x,y,r;
vector<vector<pair<int,double>>>grph; //index=from,pair.first=to,pair.second=weight
vector<double>wt;
vector<int>vis;

double dijkstra(int src,int dest)
{
	priority_queue<pair<double,int>>q; // total weight from start till cur,index of node
	q.push(make_pair(0,src));
	while(!q.empty())
	{
		int nd=q.top().second;
		q.pop();
		for(int i=0;i<grph[nd].size();i++)
		{
			int child=grph[nd][i].first;
			if(vis[child])continue;
			if(wt[nd]+grph[nd][i].second<wt[child])
			{
				wt[child]=wt[nd]+grph[nd][i].second;
				q.push(make_pair(-wt[child],child));
			}
		}
		vis[nd]=1;
	}
	return wt[dest];
}

bool incrcl(double xp,double yp,double xc,double yc,double rc)
{
	if(xp>xc+rc)return false;
	if(xp<xc-rc)return false;
	if(yp>yc+rc)return false;
	if(yp<yc-rc)return false;
	double tmpx=rc*cos(45.0*PI/180.0)+xc;
	double tmpy=rc*sin(45.0*PI/180.0)+yc;
	if(yp>tmpy)return false;
	if(yp<2*yc-tmpy)return false;
	if(xp>tmpx)return false;
	if(xp<2*xc-tmpx)return false;
	return true;
}

double mx(double v1,double v2)
{
	if(v1>v2)return v1;
	else return v2;
}

double getDist(int i,int j)
{
	return mx(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-(r[i]+r[j]));
}

void updt(int n)
{
	vis.clear();vis.resize(n);
	x.clear();x.resize(n);
	y.clear();y.resize(n);
	r.clear();r.resize(n);
	grph.clear();grph.resize(n);
	wt.clear();wt.resize(n);fill(all(wt),1e18); wt[0]=0;
	//par.clear();par.resize(n);fill(all(par),-1);
}

int main()
{
	ios::sync_with_stdio(false);
	double xs,ys,xt,yt;
	while(cin>>xs>>ys>>xt>>yt){
		int n;
		cin>>n;

		updt(n+2);

		x[0]=xs;y[0]=ys;r[0]=0; //xs,ys
		x[n+1]=xt;y[n+1]=yt;r[n+1]=0; //xt,yt

		rep(i,1,n+1){
			cin>>x[i]>>y[i]>>r[i];

			if(incrcl(x[0],y[0],x[i],y[i],r[i]))x[0]=x[i],y[0]=y[i],r[0]=r[i];
			if(incrcl(x[n+1],y[n+1],x[i],y[i],r[i]))x[n+1]=x[i],y[n+1]=y[i],r[n+1]=r[i];
		}
		rep(i,0,x.size()){
			rep(j,0,x.size()){
				if(i==j)continue;
				double dist=getDist(i,j);
				grph[i].push_back(make_pair(j,dist));
				grph[j].push_back(make_pair(i,dist));
			}
		}
		double res=dijkstra(0,n+1);
		cout<<fixed<<setprecision(10)<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 38512
#include<iostream>
using namespace std;
int main()
{
	int N=123456*2+100;
	bool a[300000]={0};
	for(int i=2;i<N;i++)
	{
		if(a[i]==0)
		{
			for(int j=2;i*j<N;j++)
			{
				a[i*j]=1;
			}
		}
	}
	for(;;)
	{
		int n,ans=0;
		cin>>n;
		if(n==0)break;
		for(int i=n+1;i<=n*2;i++)
		{
			ans+=(int)a[i];
		}
		cout<<n-ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3316
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n, sum = 0, ans = 0, p;
  scanf("%lld", &n);
  ll x[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld", &x[i]);
    sum += x[i];
  }
  p = sum / n;
  sum %= n;
  if(sum * 2 > n) p++;
  for(i = 0; i < n; ++i) ans += (x[i] - p) * (x[i] - p);
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=100010;
int n;
char s[maxn];
int main(){
    scanf("%s",s);
    n=strlen(s);
    bool ok=0;
    for(int i=1;i<=n;i++)if(s[i]!='0')ok=1;
    if(!ok){printf("%d",n);return 0;}
    for(int i=(n>>1)+(n&1);i<n;i++)if(s[i]!=s[n-i-1]||s[i]!=s[i-1]){printf("%d",i);return 0;}
    printf("%d",n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n,k,s;
    cin >> n >> k >> s;
    int res;
    if(s==1000000000)res=s-1;
    else res=s+1;
    rep(i,n){
        if(k){
            cout << s << ' ';
            k--;
        }
        else cout << res << ' ';
    }
    


}

/*



 */



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B; cin >> A >> B;
	cout << (A + B) % 24 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import io
import math
import string
# solution

sys.setrecursionlimit(100001)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v):
    ret = True
    for u, d in es[v]:
        if x[u] == None:
            x[u] = x[v] + d
            ret = ret and dfs(u)
        elif x[u] != x[v] + d:
            return False
    return ret

N, M = map(int, input().split())
es = [[] for i in range(N+1)]
for i in range(M):
    L, R, D = map(int, input().split())
    es[L].append((R, D))
    es[R].append((L, -D))
x = [None for i in range(N+1)]
flag = True
for v in range(1, N+1):
    if x[v] == None:
        x[v] = 0
        if dfs(v) == False:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

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

int main(){
    int l,r;
    int ans = 2019*2019;
    cin >> l >> r;
    int left = 0, right = 2018;
    if(r-l < 2019){
        left = l%2019;
        right = r%2019;
        if(left > right){
            cout << 0 << endl;
            return 0;
        }
        else{
            for(int i = left; i <= right; ++i){
                for(int j = i+1; j <= right; ++j){
                    ans = min(ans,i*j%2019);
                }
            }
        }
        cout << ans << endl;
    }
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0 0\n'):
  N,M=map(int,e.split())
  k,p=1,0
  S=[int(r()) for _ in[0]*N]
  for d in[int(r())for _ in[0]*M]:
   p+=d if N<=p+d else d+S[p+d]
   if N<=p+1:break
   k+=1
  print(k)
if'__main__'==__name__:s()


Measured memory_bytes: 5648
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<complex>
using namespace std;

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

typedef complex<double> P;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

bool IsIntersectLL(P a,P b,P c,P d){
  return abs(cross(b-a, d-c)) > EPS || // non-parallel
    abs(cross(b-a, c-a)) < EPS;   // same line
}
bool IsIntersectSS(P a1, P a2, P b1, P b2) {
  return ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 &&
    ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0;
}
P IntersectionLL(P a1, P a2, P b1, P b2) {
  P a = a2 - a1; P b = b2 - b1;
  double A = cross(b, b1-a1);
  double B = cross(b, a);
  if( abs(A) < EPS && abs(B) < EPS ) return a1; // same line
  return a1 + a * A / B;
}

bool SeeAll( const vector<P> &polygon, P p ) {
  int N = polygon.size() - 1;
  for(int i = 0; i < N; i++) {
    int count = 0;
    for(int j = 0; j < N; j++) {
      if( IsIntersectSS( p, polygon[i], polygon[j], polygon[j+1]) )
        count++;
    }
    if( count != 2 ) return false;
  }
  return true;
}

int main() {
  for(int N; scanf("%d", &N), N; ) {
    vector<P> polygon;
    REP(n, N) {
      int x, y;
      scanf("%d%d", &x, &y);
      polygon.push_back( P(x,y) );
    }

    polygon.push_back( polygon[0] );

    int ans = 0;
    for(int i = 0; i < N; i++){
      for(int j = i+1; j < N; j++){
        if( IsIntersectLL( polygon[i], polygon[i+1], polygon[j], polygon[j+1] ) ){
          P can = IntersectionLL(polygon[i], polygon[i+1], polygon[j], polygon[j+1]);

          for(int k = 0; k < 10; k++) {
            if( SeeAll( polygon, can + polar(0.00001, 2 * PI / k) ) ) {
              ans = 1;
              goto END;
            }

          }

        }
      }
    }

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

Measured memory_bytes: 940
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0, i##_len=(N); i<i##_len; i++)
#define RREP(i, N) for(int i=1, i##_len=(N); i<i##_len; i++)
#define REPP(i, N) for(int i=0, i##_len=(N); i<=i##_len; i++)
#define RREPP(i, N) for(int i=1, i##_len=(N); i<=i##_len; i++)
#define P(x) cout << (x) << '\n'
#define pb push_back
using ll = long long;
using namespace std;

int N;
ll ans;

int main() {
    cin >> N;
    int A[N+1]; REP(i, N+1) cin >> A[i];
    int B[N]; REP(i, N) cin >> B[i];
    REP(i, N) {
        ll ee = min({A[i], B[i]});
        ans += ee;
        B[i] -= ee;
        ee = min({A[i+1], B[i]});
        ans += ee;
        A[i+1] -= ee;
    }
    P(ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for(int i = (a), i##end = (b); i <= i##end; ++ i)
#define CLR(i, a) memset(i, a, sizeof(i))
#define REPD(i, a, b) for(int i = (a), i##end = (b); i >= i##end; -- i)
#define LOG(x) std::cerr << #x << ":" << x << '\n'
#define DBG(...) fprintf(stderr, __VA_ARGS__)
#define OK fprintf(stderr, "Passing %s in LINE [%d]\n", __FUNCTION__, __LINE__)
#define gc getchar
#define pc putchar
#define endl '\n'
typedef long long LL;
typedef double DB;
inline LL rd() {
	char ch = gc(); LL ret = 0, sgn = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') sgn = -1;
		ch = gc();
	}
	while(ch <= '9' && ch >= '0') 
		ret = ret * 10 + ch - '0', ch = gc();
	return ret * sgn;
}
/**************************************************************/

const int N = 1e4 + 3, LG = 60;
const LL INF = 1ll << 60;

LL qx[N], qy[N], bot, rem;
int n;
int ind;
bool f[N][LG + 3][3], vis[N][LG + 3][3];

bool ifValid(LL x) {
	bool ret = 0;
	REP(i, 1, n) if(qx[i] <= x) {
		LL u = qy[i] - bot, v = x - qx[i];
		ret ^= ((u | v) == u);
	}
	return ret;
}

int upa[LG + 3], upb[LG + 3];

bool Dp(int pos, int tr, bool lim) {
	// assert(tr <= 2);
	if(pos < 0) {
		// if(tr == 0) OK;
		return (tr == 0);
	}
	if(!lim && vis[ind][pos][tr]) return f[ind][pos][tr];
	// LOG(tr);
	int up = lim ? upa[pos] : 1;
	up = min(up, upb[pos]); 

	bool ret = 0;
	REP(i, 0, up) {
		int ntr = (tr + 3 - ((LL)i * (1ll << pos) % 3) % 3) % 3;
		bool nlim = lim & (i == upa[pos]);
		ret ^= Dp(pos - 1, ntr, nlim);
	}

	if(!lim) {
		vis[ind][pos][tr] = 1;
		f[ind][pos][tr] = ret; 
	}
	return ret;
}

inline bool __main__(LL all, LL ql, LL qr, LL trem) {
	// assert(ql <= qr);
	if(ql > qr) return 0;
	// assert(ql >= 0 && qr >= 0);
	REP(i, 0, LG) {
		upb[i] = (all >> i) & 1;
		upa[i] = (qr >> i) & 1;
	}
	bool ret = Dp(LG, trem, 1);
	if(ql > 0) {
		REP(i, 0, LG) upa[i] = ((ql - 1) >> i) & 1;
		ret ^= Dp(LG, trem, 1);
	}
	return ret;
}

bool Calc_sz(LL L, LL R) {
	// assert(L <= R);
	bool ret = 0;
	REP(i, 1, n) {
		LL tl = max(qx[i], L) - qx[i], tr = min(qx[i] + qy[i] - bot, R) - qx[i];
		int trem = (rem - qx[i] % 3 + 3) % 3;
		ind = i;
		ret ^= __main__(qy[i] - bot, tl, tr, trem);	
	}
	return ret;
}

int main() {
	n = rd();
	bot = INF;
	LL ll = INF, rr = -INF;
	REP(i, 1, n) {
		qx[i] = rd(), qy[i] = rd();
		// LOG(qx[i]), LOG(qy[i]);
		bot = min(qy[i], bot);
		ll = min(ll, qx[i]), rr = max(rr, qx[i]);
	}
	-- bot;
	// LOG(ll), LOG(rr);
	// Calc_sz(ll, rr);
	for(rem = 0; !Calc_sz(ll, rr) && rem < 3; ++ rem) ;
	// LOG(rem);
	LL l = ll, r = rr;
	while(l < r) {
		LL mid = l + r >> 1;
		if(Calc_sz(l, mid)) r = mid;
		else l = mid + 1; 
	}
	// puts("Heghlu' meH QaQ jajvam"), exit(0);
	// OK;
	static LL pw[LG + 3];
	pw[0] = 1;
	REP(i, 1, LG) pw[i] = pw[i - 1] << 1ll;
	LL resl = l, resr = l;
	REPD(k, LG, 0) {
		if(ifValid(resl - pw[k])) resl -= pw[k];
		if(ifValid(resr + pw[k])) resr += pw[k];
	}
	printf("%lld %lld\n", resl, bot + (resr - resl));
	return 0;
}









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

const int N=2e5+20,MOD=1e9+7;

int n,zero,p[N];
long long a,b,ans=1;
map <pair <long long,long long>,pair <int,int>> m;

int main()
{
	p[0]=1;
	for(int i=1;i<N;i++) p[i]=(p[i-1]*2)%MOD;

	scanf("%d",&n);
	while(n--)
	{
		scanf("%lld%lld",&a,&b);

		if(a==0 and b==0)
		{
			zero++;
			continue;
		}

		long long g=__gcd(a,b);
		a/=g,b/=g;
		if(b<0) a*=-1,b*=-1;
		if(a<=0) m[{b,-a}].second++;
		else m[{a,b}].first++;
	}

	for(auto i:m)
	{
		auto pr=i.second;
		ans*=(p[pr.first]+p[pr.second]-1ll)%MOD;
		ans%=MOD;
	}

	ans=(ans+zero-1)%MOD;
	if(ans<0) ans+=MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 17016
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int H,W,X;
char s[10][10];
char s2[10][10];

signed main(){
	cin>>H>>W>>X;
	REP(i,H){
		cin>>s[i];
	}
	int ans=0;
	REP(Bit,1<<H){
		REP(Bit2,1<<W){
			REP(i,H){
				REP(j,W){
					s2[i][j]=s[i][j];
				}
			}
			bool F[10]={},F2[10]={};
			REP(i,H){
				if(Bit&(1<<i)){
					F[i]=1;
				}
			}
			REP(i,W){
				if(Bit2&(1<<i)){
					F2[i]=1;
				}
			}
			REP(i,H){
				if(F[i]==1){
					REP(j,W){
						s2[i][j]='1';
					}
				}
			}
			REP(i,W){
				if(F2[i]==1){
					REP(j,H){
						s2[j][i]='1';
					}
				}
			}
			int cnt=0;
			REP(i,H){
				REP(j,W){
					if(s2[i][j]=='#'){
						cnt++;
					}
				}
			}
			if(cnt==X){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  int N;
  cin >> N;
  long long ans = 1; //初期値
  
  long long res[N] = {}; //素因数の数を入れるバケット(i番目の箱には素因数i+1の個数が入る)
  FOR(i,1,N+1) {
    int X = i;
    for(int j=2; j*j <= i; j++) {
      if(X%j != 0) continue;
      long long ex = 0; //指数
      while (X%j == 0) { //割れるだけ割る
        ex++;
        X /= j;
      }
      res[j-1] += ex;
    }
    if(X != 1) res[X-1]++;
  }
    
  //FOR(i,0,N) cout << res[i] << endl;
  FOR(i,1,N) { //バケットの最初を除いて考える(1は素因数でないので考えない)
    if (res[i] > 0) {
      ans *= res[i]+1;
      ans %= 1000000007;
    }
  }
      
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#!/usr/bin/env python3

def main():
    *N, = map(int, open(0).read().split())
    X = N[1:]
    N = N[0]

    P = []
    for i in range(1, 101):
        p = 0
        for j in range(0, N):
            p += (i - X[j])**2
        P.append(p)
    print(min(P))


main()

Measured memory_bytes: 3060
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod =  1000000007;
const int LIM = 100005;


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define ss second
#define ff first
 
int fpow(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b){
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n){
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt[6], sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************


int32_t main()
{     fio;
      cin>>n;
      while(n--){
            cin>>s;
            if(s=="AC")cnt[0]++;
            if(s=="WA")cnt[1]++;
            if(s=="TLE")cnt[2]++;
            if(s=="RE")cnt[3]++;
      }
      cout<<"AC x "<<cnt[0];nl;
      cout<<"WA x "<<cnt[1];nl;
      cout<<"TLE x "<<cnt[2];nl;
      cout<<"RE x "<<cnt[3];
     
}


Measured memory_bytes: 3704
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	

	int A, B, C;
	cin >> A >> B >> C;

	cout << C << " " << A << " " << B;










}





Measured memory_bytes: 256
x1, x2, x3, x4, x5 = map(int, input().split())
if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
   string N;
   cin>> N;
    int S,x;
    S=0;
    x=0;
     for(unsigned int i=0;i<N.size();i++){
        S += N.at(i)-'0';
         x += (N.at(i)-'0')*pow(10,N.size()-i-1);
     }

 if(x%S==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
      
    }
    
 
   
    
}
//なんで-48を入れなきゃ合わないのかわからない(unsigned int  math.hの影響？)
//入力例を入れたときは違う結果が出てたのにＡＣななった理由がわからない
//unsigned intは０も範囲内？

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

#ifdef local
	#include "debug/debug.h"
#endif


#ifndef local
	#define deb(x...) ;	
#endif

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------


void solve()
{
	string s;
	cin >> s;
	int sum = 0;
	for (char x:s) sum += x - '0';
	if (sum % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	// cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <stdlib.h>

struct iro
{
    char A[200];
};
/*
int compare4(const void *a, const void *b)
{
    return ((struct iro *)a)->A[4] - ((struct iro *)b)->A[4];
}

int compare3(const void *a, const void *b)
{
    return ((struct iro *)a)->A[3] - ((struct iro *)b)->A[3];
}

int compare2(const void *a, const void *b)
{
    return ((struct iro *)a)->A[2] - ((struct iro *)b)->A[2];
}

int compare1(const void *a, const void *b)
{
    return ((struct iro *)a)->A[1] - ((struct iro *)b)->A[1];
}

*/
int compare0(const void *a, const void *b)
{
    int h;
    h= ((struct iro *)a)->A[0] - ((struct iro *)b)->A[0];
    if(h!=0)
        return h;
    else
    {
        int y = 1;
        while (h == 0)
        {
            h = ((struct iro *)a)->A[y] - ((struct iro *)b)->A[y];
            y++;
            if(y==20)
                return h;
        }
    }
    return h;
}

int main()
{
    int n, l;
    scanf("%d %d", &n, &l);
    struct iro I[1000];
    int i = 0;
    while (i < n)
    {
        scanf("%s", I[i].A);
        i++;
    }
    /*
    qsort(I, n, sizeof(struct iro), compare5);
    qsort(I, n, sizeof(struct iro), compare4);
    qsort(I, n, sizeof(struct iro), compare3);
    qsort(I, n, sizeof(struct iro), compare2);
    qsort(I, n, sizeof(struct iro), compare1);*/
    qsort(I, n, sizeof(struct iro), compare0);

    i = 0;
    int log;
    while (i < n)
    {
        log = 0;
        while (log < l)
        {
            printf("%c", I[i].A[log]);
            log++;
        }
        i++;
    }
    printf("\n");
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll k, x;
	cin >> k >> x;
	if (500 * k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return(0);
}

Measured memory_bytes: 3592
s = list(input())
n = int(input())
for i in range(n):
    d = input().split(" ")
    if d[0] == "replace":
        a = int(d[1])
        b = int(d[2])
        c = list(d[3])
        k = 0
        for j in range(a, b+1):
            s[j] = c[k]
            k += 1
    elif d[0] == "reverse":
        a = int(d[1])
        b = int(d[2])
        c = list(s)
        k = b
        for j in range(a, b+1):
            s[j] = c[k]
            k -= 1
    else:
        a = int(d[1])
        b = int(d[2])
        for j in range(a, b+1):
            print(s[j],end="")
        print("")

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



int main(){
    int n;
    int h[100005];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[100005];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i]=min((dp[i-2]+abs(h[i-2]-h[i])),(dp[i-1]+abs(h[i-1]-h[i])));
    }
    
     cout<<dp[n-1]<<endl;
    return 0;
}




Measured memory_bytes: 1024
def abc_exp(a,b,c):
	print(str(a) + ' ' + str(b) + ' ' + str(c) )
	
def exchange(a,b,remain):
	while True:
		if remain >= 4 and a - 4 >= 0:
			b = b + 8
			a = a - 4
			remain = remain - 4
		else: 
			break
	return a,b
	

N,Y = map(int,input().split())

a = int(Y/10000)
b = int((Y - a * 10000)/5000)
c = int((Y - a * 10000 - b * 5000)/1000)

max_bills = int(Y/1000)

if (max_bills < N) or (N < a + b + c):
	print('-1 -1 -1')
	
else:
	remain = N - a - b - c
	a = a - (remain % 4)
	b = b + 2 * (remain % 4)
	a , b = exchange(a,b,remain)
	remain = N - a - b - c
	
	if b - remain/4 >= 0:
		b = b - int(remain / 4)
		c = c + int(remain / 4) * 5
		abc_exp(a,b,c)
	
	else:
		print('-1 -1 -1')


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n,h;
	cin>>h>>n;
	int a[n],b[n],maxi=0;
	rep(i,n){
		cin>>a[i]>>b[i];
		maxi = max(a[i],maxi);
	}
	
	int dp[h+maxi+1];
	rep(i,h+maxi+1)dp[i]=mod;
	dp[0]=0;
	rep(i,h){
		rep(j,n){
			dp[i+a[j]] = min(dp[i]+b[j],dp[i+a[j]]);
		}
	}

	int ans=mod;
	for(int i=h;i<h+maxi+1;i++){
		ans=min(ans,dp[i]);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3628
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200005
#define INF 0x3f3f3f3f
int main(){
	LL X=read(),Y=read();
	puts(fabs(X-Y)>1?"Alice":"Brown");
	return 0;
}//

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ans += (s == "E869120");
    }
    cout << ans << endl;

}


Measured memory_bytes: 3208
#include<stdio.h>
main(){
    int N,K,blood[101],family[101],tmp,i,j,x;
    while(1){
         scanf("%d %d", &N, &K);
         if(N==0&&K==0)
         break;
        tmp=1;
        for(i=0;i<K;i++)
            scanf("%d",&blood[i]);
        for(i=0;i<N;i++){
            for(j=0;j<K;j++){
                scanf("%d",&x);
                blood[j]-=x;
                if(blood[j]<0)
                tmp=0;
            }
        }
        if(tmp==0)
        printf("No\n");
        else
        printf("Yes\n");
    }
}

Measured memory_bytes: 1008
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;
    int data[N];
    rep(i, N)
    {
        cin >> data[i];
    }
    sort(data, data + N, greater<int>());
    int ans = 0;
    rep(i, K)
    {
        ans += data[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
#define lc(x) x<<1
#define rc(x) x<<1|1
using namespace std;
const int N=3e5+5;
int w,h,n,ans,L,R;
int mx[N*4],tag[N*4];
struct node{int x,y;node(int _x=0,int _y=0):x(_x),y(_y){};}p[N],a[N],b[N]; 
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void modify(int x,int l,int r,int v)
{
	if(L<=l&&r<=R){mx[x]+=v;tag[x]+=v;return;}
	int mid=(l+r)>>1;
	if(L<=mid)modify(lc(x),l,mid,v);
	if(R>mid)modify(rc(x),mid+1,r,v);
	mx[x]=max(mx[lc(x)],mx[rc(x)])+tag[x];
}
bool cmp(node a,node b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
void work()
{
	memset(mx,0,sizeof(mx));
	memset(tag,0,sizeof(tag));
	sort(p+1,p+n+1,cmp);
	int l=0,r=0;
	for(int i=1;i<=n-1;i++)
	{
		if(p[i].y<=h/2)
		{
			int nxt=i-1;
			while(l&&a[l].y<p[i].y)
			{
				L=a[l].x;R=nxt;nxt=a[l].x-1;
				modify(1,1,n,a[l].y-p[i].y);l--; 
			}
			if(nxt!=i-1)a[++l]=node(nxt+1,p[i].y);
		}
		else
		{
			int nxt=i-1;
			while(r&&b[r].y>p[i].y)
			{
				L=b[r].x;R=nxt;nxt=b[r].x-1;
				modify(1,1,n,p[i].y-b[r].y);r--;
			}
			if(nxt!=i-1)b[++r]=node(nxt+1,p[i].y);
		}
		a[++l]=node(i,0);b[++r]=node(i,h);
		L=i;R=i;modify(1,1,n,h-p[i].x);
		ans=max(ans,mx[1]+p[i+1].x);
	}
}
int main()
{
	w=read();h=read();n=read();
	for(int i=1;i<=n;i++)p[i].x=read(),p[i].y=read();
	p[++n]=node(0,0);p[++n]=node(w,h);work();
	for(int i=1;i<=n;i++)swap(p[i].x,p[i].y);
	swap(w,h);work();
	printf("%d",ans*2);
	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  string v[h];
  for(int i=0;i<h;i++){
      cin >> v[i];
    }
  
  for(int i=0;i<h;i++){
    for(int k=0;k<2;k++){
      for(int j=0;j<w;j++){
        cout << v[i][j];
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    cut = 1 if len(s)%2==1 else 2
    scut = s[:-cut]
    # print(scut)

    while scut[:len(scut)//2] != scut[len(scut)//2:]:
        cut += 2
        scut = s[:-cut]

    ans = len(scut)
    print(ans)


main()

Measured memory_bytes: 74544
n = int(input())
a = [0]
for i in range(n):
  a.append(int(input()))
a.append(0)

l = [0] * (n+2)
l[0] = 0
for i in range(1,n+1):
  l[i] = max(l[i-1], a[i])

r = [0] * (n+2)
r[n] = 0
for i in range(n,0,-1):
  r[i] = max(r[i+1], a[i])

for i in range(1,n+1):
  print(max(l[i-1],r[i+1]))

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

#define ll long long int
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cout<<#x<<" = "<<x<<'\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

int main() {_
	int n, k;
	cin >> n >> k;
	int mi = 1;
	int ma = n-k + 1;
	if(k == 1) {
		cout<<"0\n";
	}
	else {
		cout<<ma-mi<<'\n';
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

vector<int> graph[MAX_N];
bool is_visited[MAX_N];
ll K;
ll ans;

void dfs(int node) {
    is_visited[node] = true;
    ll rest = node == 0 ? K - 1 : K - 2;
    for (int i = 0; i < graph[node].size(); i++) {
        if (is_visited[graph[node][i]]) continue;
        if (rest == 0) ans = 0;
        ans = (ans * rest) % MOD;
        rest--;
        dfs(graph[node][i]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N >> K;
    ans = K;
    int a, b;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(i, 1, 9) {
        REP(j, 1, 9) {
            if(i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


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

int main(){
  int n,t;
  cin >> n >> t;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int mx = 0,mcost = 0;
  map<int,int> mp;
  for (int i = n - 1; i >= 0; i--) {
    mx = max(mx,a[i]);
    int v = abs(mx - a[i]);
    mp[v]++;
    mcost = max(mcost,v);
  }
  cout << mp[mcost] << endl;
  return 0;
}

Measured memory_bytes: 5376
import java.util.*;

public class Main{

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

    int n = sc.nextInt();
    int m = sc.nextInt();

    PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());

    for(int i=0; i<n; i++){
      int a = sc.nextInt();
      pq.add(a);
    }
    //System.out.println(pq);

    for(int i=0; i<m; i++){
      int s = pq.poll();
       s = s/2;
      pq.add(s);
    }
    //System.out.println(pq);
    int si = pq.size();
    long sum = 0;
    for(int i=0; i<si; i++){
      long ll = pq.poll();
      sum += ll;
    }
    System.out.println(sum);

  }

}

Measured memory_bytes: 61976
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;

int score(int r,int s,int p,char t, bool iswin){
    int score;
    if(iswin){
        if (t=='r') score = p;
        if (t=='s') score = r;
        if (t=='p') score = s;
    }else{
        score = 0;
    }
    return score;
}

int main(){
    int n,k,r,s,p; cin>>n>>k>>r>>s>>p;
    string t; cin>>t;
    int total = 0;
    vector<bool> iswin(n);
    rep(0,i,n){
        if(i<k){
            iswin[i] = true;
        }else{
            if(t[i]==t[i-k]&&iswin[i-k]==true){
                iswin[i] = false;
            }else{
                iswin[i] = true;
            }
        }
        total += score(r,s,p,t[i],iswin[i]);
    }
    cout << total << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		System.out.println(scan.next().substring(0, 1) + scan.next().substring(0, 1) + scan.next().substring(0, 1));
		
		scan.close();

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <random>

using namespace std;

vector<string> seat;

void init(int N)
{
	default_random_engine eng{ random_device{}() };
	uniform_int_distribution<> dist;
	using param_t = decltype(dist)::param_type;

	const string sel0[2] = { "Male", "Female" };
	const string selm[2] = { "Vacant", "Female" };
	const string self[2] = { "Vacant", "Male"};

	seat.resize(N);
	seat[0] = sel0[dist(eng, param_t{ 0, 1 })];
	
	for (int i = 1; i + 1 < N; ++i) {
		if (seat[i - 1] == "Vacant") {
			seat[i] = sel0[dist(eng, param_t{ 0, 1 })];
		}
		else if (seat[i - 1] == "Male") {
			seat[i] = selm[dist(eng, param_t{ 0, 1 })];
		}
		else if (seat[i - 1] == "Female") {
			seat[i] = self[dist(eng, param_t{ 0, 1 })];
		}
	}
	seat[N - 1] = "Vacant";
	for (int i = 0; i < N; ++i) {
		cout << i << ":" << seat[i] << endl;
	}
}

//#define TEST
string query(int i)
{
	cout << i << endl;
	string s;
#ifdef TEST
	s = seat[i];
	cout << "[input] " << s << endl;
#else
	cin >> s;
#endif
	return s;
}

void solve_e(int l, int u, string s);
void solve_o(int l, int u, string s);

void solve(int l, int u, const string &s)
{
	if ((u - l + 1) % 2 == 0) {
		solve_e(l, u, s);
	}
	else {
		solve_o(l, u, s);
	}
}

void solve_e(int l, int u, string s)
{
	int m = (l + u) / 2;
	auto x = query(m);
	if (x == "Vacant") {
		return;
	}
	if ((m - l) % 2 == 0) {
		if (x == s) {
			solve_e(m, u, x);
		}
		else {
			solve_o(l, m, s);
		}
	}
	else {
		if (x == s) {
			solve_e(l, m, s);
		}
		else {
			solve_o(m, u, x);
		}
	}
}

void solve_o(int l, int u, string s)
{
	int m = (l + u) / 2;
	auto x = query(m);
	if (x == "Vacant") {
		return;
	}
	if ((m - l) % 2 == 0) {
		if (x == s) {
			solve_o(m, u, x);
		}
		else {
			solve_o(l, m, s);
		}
	}
	else {
		if (x == s) {
			solve_e(l, m, s);
		}
		else {
			solve_e(m, u, x);
		}
	}
}

void solve(int N)
{
	auto x = query(0);
	if (x == "Vacant") {
		return;
	}
	int m = N / 2;
	auto y = query(m);
	if (y == "Vacant") {
		return;
	}

	if (x == y) {
		if (m % 2 == 0) {
			solve(m, N, y);
		}
		else {
			solve(0, m, x);
		}
	}
	else {
		if (m % 2 == 0) {
			solve(0, m, x);
		}
		else {
			solve(m, N, y);
		}
	}
}

int main()
{
	int N;
	cin >> N;
#ifdef TEST
	init(N);
#endif
	solve(N);
}


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

int main() {
  int n,f = 0,g = 0;
  cin >> n;
  string a,b;
  for(int i = 0;i < n;i++){
    cin >> a >> b;
    for(int k = 0;k < 100;k++){
      if(a[k] > b[k]){
        f += 3;
        break;
      }
      if(a[k] < b[k]){
        g += 3;
        break;
      }
      if(a == b){
        f += 1;
        g += 1;
        break;
      }
    }
  }
  cout << f << " "<< g << endl;
}


Measured memory_bytes: 3176
x, k, d = map(int, input().split())
x = abs(x)
mod = x % d
max_move = x - k * d

if mod < max_move:
    res = max_move
else:
    rest = k - x // d
    if rest % 2 == 0:
        res = mod
    else:
        res = abs(mod - d)

print(res)

Measured memory_bytes: 9180
fun main(args: Array<String>) {
  val (H, W) = readInts()
  val C = (0..9).map { readInts() }
  val A = (1..H).map { readInts() }

  val dp = Array(10) { Int.MAX_VALUE / 2 }
  dp[1] = 0
  fun dfs(n: Int) {
    for (i in 0..9) {
      if (dp[i] > dp[n] + C[i][n]) {
        dp[i] = Math.min(dp[i], dp[n] + C[i][n])
        dfs(i)
      }
    }
  }
  dfs(1)

//  println(dp.joinToString())
  println(A.flatten().filter { it != -1 }.sumBy { dp[it] })
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 41712
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll ans = 700; string s; cin >> s;
  
  rep(i,3){
    if(s[i] == 'o') ans += 100;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	bool ans = false;
	if(n % 10 == 7) ans = true;
	if(n / 10 % 10 == 7) ans = true;
	if(n / 100 % 10 == 7) ans = true;
	cout << (ans ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <array>
#include <vector>

using namespace std;

int main() {
	vector <array <int, 2>> sets;
	array <int, 2> pusher;
	int h = 0;
	int w = 0;
	int counter = 0;

	while (true) {
		cin >> h >> w;
		if ((h == 0) && (w == 0)) {
			break;
		}
		pusher[0] = h;
		pusher[1] = w;
		sets.push_back(pusher);
		counter++;
	}
	for (auto set : sets) {
		for (int i = 0; i < set[0]; i++) {
			for (int a = 0; a < set[1]; a++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3116
#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
using ll=long long;
const ll MOD=1000000007;

int main()
{
  ll N,K,min,max,count=0;
  cin >> N >> K;
  rep(i,N-K+2)
  {
    min=(K+i)*(K+i-1)/2;
    max=(K+i)*(2*N-K-i+1)/2;
    count+=(max-min+1)%MOD;
  }
  cout<<count%MOD<<endl;
  return 0;
}  
  

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while( !S.empty() ){
        int u = S.top(); S.pop();
        for( int i=0; i<G[u].size(); i++){
            int v = G[u][i];
            if(color[v] == NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id = 1;
    for(int i=0; i<n; i++) color[i] = NIL;
    for(int u=0; u<n; u++){
        if(color[u] == NIL) dfs(u, id++); //それぞれの連結な部分グラフに番号（色）を与える
    }
}

int main(){
    int s, t, m, q;

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for(int i=0; i<q; i++){
        cin >> s >> t;
        if(color[s] == color[t]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }

    return 0;
}


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

int main(void) {
    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        printf("%d\n", R);
    } else {
        printf("%d\n", R + (100 * (10 - N)));
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n m
p1 y1
...
pm ym

n 10^5 pres
m 10^5 cities
pi n
yi 10^9
 */
typedef pair<int,int> P;
int n,m,p[100000],y[100000];
vector<P> pres[100000]; //(year, city)

int main(){
  cin>>n>>m;
  REP(i,m){
    cin>>p[i]>>y[i];
    pres[p[i]-1].push_back(P(y[i],i));
  }

  ll ans[m];
  REP(i,n){
    sort(pres[i].begin(), pres[i].end());
    REP(j,pres[i].size()){
      int city = pres[i][j].second;
      ans[city] = (ll)(i+1)*pow(10,6) + (ll)j+1;
    }
  }

  REP(i,m){
    printf("%012lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  int k,a,b;
  cin >> k >> a >> b;
  int work = k;
  while(work < a){
    work += k;
  }

  if(a <= work && work <= b){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3604