akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def MI(): return map(int, input().split())


def LI_(): return [int(x) - 1 for x in input().split()]


def main():
    import sys
    sys.setrecursionlimit(5*(10**5))
    N, M = MI()
    edge = [[] for _ in range(N)]
    for _ in range(M):
        x, y = LI_()
        edge[x].append(y)

    def go_to_leaf(n):
        if dp[n] >= 0:
            return dp[n]
        ret = 0
        for y in edge[n]:
            ret = max(go_to_leaf(y) + 1, ret)
        dp[n] = ret
        return ret

    dp = [-1] * N
    ans = 0
    for i in range(N):
        ans = max(ans, go_to_leaf(i))
    print(ans)

    """start = 0
    while rev_edge[start]:
        start = rev_edge[start][0]
    stack = set([start])
    ans = 0
    for _ in range(N + 1):
        tmp = []
        print(stack)
        while stack:
            now = stack.pop()
            tmp.extend(edge[now])
        if not tmp:
            print(tmp)
            break
        stack = set(tmp)
        ans += 1
    print(ans)"""


if __name__ == '__main__':
    main()


Measured memory_bytes: 67248
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
total = sum(A)
th = total/4/M
Asorted = sorted(A, reverse=True)
flag = 0
for i in range(M):
  if(Asorted[i] < th):
    flag = 1
if(flag==0):
  print("Yes")
else:
  print("No")

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

int main(){
	// sengen
	map<int , int> mp;
	int n;
	// nyuryoku
	cin >> n;
	for(int i=0;i<n;i++){
		int k;
		cin >> k;
		mp[k]++;
	}
	// keisan
	int mx=0;
	for(auto x:mp){
		mx = max(mx,x.second);
	}
	// syutsuryoku
	if(mx == 1){
		cout << "YES";
	}else{
		cout << "NO";
	}
}

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

int main(){
    vector<ll> data(6);
    rep(i,6) cin >> data[i];
    ll v = *min_element(data.begin(),data.end());
    cout << 4+(data[0]+v-1)/v << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    int x;
    cin >> x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll X;
    cin >> X;
    ll lim = pow(10, 4);
    for(ll B = -lim; B <= lim; B++){
        for(ll A = B + 1; A <= lim; A++){
            ll ans = pow(A, 5) - pow(B, 5);
            if(ans > X) break;
            else if(ans == X){
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
int main(void)
{
	int n;
	int sum;

	scanf("%d", &n);
	if (n >= 100000) {
		sum = 100000 - 10000 + 1000 - 100 + 9;
	}
	else if (n >= 10000) {
		sum = 909 + n - 9999;
	}
	else if (n >= 1000) {
		sum = 1000 - 100 + 9;
	}
	else if (n >= 100) {
		sum = 9 + n - 99;
	}
	else if (n >= 10) {
		sum = 9;
	}
	else {
		sum = n;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
n = int(input())

h = [int(i) for i in input().split(" ")]
dp = [float("inf")]*n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, len(h), 1):
  dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]), dp[i-2]+abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 53640
// problem: "https://atcoder.jp/contests/abc147/tasks/abc147_e"

#include<bits/stdc++.h>
#define p 6401*2

using namespace std;

int minD(vector<vector<int>>&A,vector<vector<int>>&B,int h,int w)
{
    vector<vector<int>>D(h,vector<int>(w,0));
    int i,j;
    for(i=0;i!=h;i++)
        for(j=0;j!=w;j++)
            D[i][j] = abs(A[i][j]-B[i][j]);

    vector<vector<vector<bool>>>V(h,vector<vector<bool>>(w,vector<bool>(p,false)));
    int k;

    V[0][0][D[0][0]] = true;
    for(i=0;i!=h;i++)
    {
        for(j=0;j!=w;j++)
        {
            if(i-1 >= 0)
            {
                for(k=0;k!=p;k++)
                {
                    if(V[i-1][j][k])
                    {
                        V[i][j][abs(D[i][j]-k)] = true;
                        V[i][j][abs(D[i][j]+k)] = true;
                    }
                }
            }

            if(j-1 >= 0)
            {
                for(k=0;k!=p;k++)
                {
                    if(V[i][j-1][k])
                    {
                        V[i][j][abs(D[i][j]-k)] = true;
                        V[i][j][abs(D[i][j]+k)] = true;
                    }
                }
            }
        }
    }

    for(k=0;k!=p;k++)
        if(V[h-1][w-1][k])
            break;

    return k;
}

int main()
{
    int h,w;
    cin>>h>>w;

    int i,j;
    vector<vector<int>>A(h,vector<int>(w,0));
    for(i=0;i!=h;i++)
    {
        for(j=0;j!=w;j++)
        {
            int x;
            cin>>x;
            A[i][j] = x;
        }
    }

    vector<vector<int>>B(h,vector<int>(w,0));
    for(i=0;i!=h;i++)
    {
        for(j=0;j!=w;j++)
        {
            int x;
            cin>>x;
            B[i][j] = x;
        }
    }

    cout<<minD(A,B,h,w);        // define

    return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int X;
  cin>>X;
  int joy;
  int ia,ib,ic;
  ia=X/500*1000;
  ib=X%500;
  ic=ib/5*5;
  joy=ia+ic;
  cout<<joy<<endl;
}
 
  
  

Measured memory_bytes: 256
h,w,d=map(int,input().split())
b=[0]*(h*w)
for i in range(h):
  for j,s in enumerate(input().split()):b[int(s)-1]=(i,j)
a=[0]*(h*w+d)
for i in range(d,h*w):a[i]=a[i-d]+abs(b[i][0]-b[i-d][0])+abs(b[i][1]-b[i-d][1])
for i in range(int(input())):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])

Measured memory_bytes: 14248
#include<stdio.h>
#include<stdbool.h>

int main(void){
int X,Y;
  scanf("%d%d",&X,&Y);
  
  int count=0;
  for(int i=0;i<X;i++){
  if (4*X-2*i-Y==0) count++;
  }
  
  if(2*X-Y==0) count++;
  
  if(count>0) printf("Yes");
  else printf("No");
  
return 0;
}

Measured memory_bytes: 1728
#include<iostream>

using namespace std;

int calc(int a,int s,int n){
  int c=0;
  if(a==-1) return 0;
  if(n==0){
    if(s==0) return 1;
    else return 0;
  }
  for(int i=a;i>=0;i--){
    c+=calc(i-1,s-i,n-1);
  }
  return c;
}

int main(){

  int n,k,s;
  int c;

  while(1){
    cin>>n>>k>>s;
    if(n==0&&k==0&&s==0) break;
    cout<<calc(n,s,k)<<endl;
  }
}

Measured memory_bytes: 1160
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


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

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    int d;
    cin>>n>>d;

    if(n>=10) cout<<d<<endl;
    else
        cout<<d+100*(10-n)<<endl;

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
D = {}
cnt = 0
for i in range(N):
    s = ''.join(sorted(S[i]))
    if s in D:
        cnt += D[s]
        D[s] += 1
    else:
        D[s] = 1
print(cnt)


Measured memory_bytes: 24976
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n,k;
      cin>>n>>k;
      deque<lint> que;
      rep(i,n){
          lint x;
          cin>>x;
          que.push_front(x);
      }
      lint ans=-INF;
      lint t=min(n,k);
      rep(i,t+1){
          rep(j,t+1){
              if(i+j>t)continue;
              deque<lint> que2=que;
              priority_queue<lint,vector<lint>,greater<lint>> a;
              rep(l,j){
                  a.emplace(que2.front());
                  que2.pop_front();
              }
              rep(h,i){
                a.emplace(que2.back());
                que2.pop_back();
              }
              lint comp=0;
              rep(d,k-i-j){
                  if(a.empty())break;
                  if(a.top()<0){
                      a.pop();
                  }
              }
              while(!a.empty()){
                  comp+=a.top();
                  a.pop();
              }
              //cout<<i<<" "<<j<<" "<<comp<<endl;
              ans=max(ans,comp);
          }
      }
    cout<<ans<<endl;
  }

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

int main(){
	ll a,b,k;
	cin >> a >> b >> k;
	
	ll taka = max(a-k,ll(0));
	ll temp = min(b+a-k,b);
	
	cout << taka << endl;
	cout << max(ll(0),temp) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define eps (1>>25)
#define INF (1<<25)
#define MOD 1000000007

int main(){
  int n;
  pair<int,int> t[100000];
  int now=0,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i].second>>t[i].first;
  }
  sort(t,t+n);
  for(int i=0;i<n;i++){
    if(t[i].second>now){
      ans++;
      now=t[i].first;
    }
    else continue;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,x[100],y[100],h[100];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i] >> y[i] >> h[i];
	for(int i = 0;i <= 100;i++){
		for(int j = 0;j <= 100;j++){
			int mi = INF,ma = 0,mii = INF;
			for(int k = 0;k < n;k++){
				int d = h[k] + abs(i - x[k]) + abs(j - y[k]);
				if(h[k]){
					chmin(mi,d);
					chmax(ma,d);
				}else chmin(mii,d);
			}
			if(mi == ma && ma <= mii){
				printf("%lld %lld %lld\n",i,j,mi);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
namespace combinatorics
{
	int *fac;
	int *ifac;
	int __Tmod;
	inline int add(int a,int b)
	{
		return (a+b)%__Tmod;
	}
	inline int sub(int a,int b)
	{
		return (a-b+__Tmod)%__Tmod;
	}
	inline int mult(int a,int b)
	{
		return (1LL*a*b)%__Tmod;
	}
	inline int fastpow(int basic,int x)
	{
		if(x==0) return 1;
		int res=1;
		while(x)
		{
			if(x&1)	res=mult(res,basic);
			basic=mult(basic,basic);
			x>>=1;
		}
		return res;
	}
	inline int inv(int x)
	{
		return fastpow(x,__Tmod-2);
	}
	void init(int n,int tmod)
	{
		__Tmod=tmod;
		fac=new int[n+5];
		ifac=new int[n+5];
		fac[0]=1;
		for(int i=1;i<=n;i++)
		{
			fac[i]=mult(fac[i-1],i);
		}
		ifac[n]=inv(fac[n]);
		for(int i=n-1;i>=0;i--)
		{
			ifac[i]=mult(ifac[i+1],i+1);
		}
	}
	inline int C(int n,int m)
	{
		return mult(mult(fac[n],ifac[m]),ifac[n-m]);
	}
	inline int Cat(int x)
	{
		return mult(C(x*2,x),inv(x+1));
	}
};
using namespace combinatorics;

#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
const int inf=1039074182;
const int mod=1e9+7;
const ll llinf=1LL*inf*inf;
using namespace std;
int n;
ll a[200005];
ll b[200005];

struct s4
{
	int a[5];
};

map <pair<ll,ll>,s4> m;

int quadrant(ll x,ll y)
{
	if(y==0 && x>0) return 1;
	if(x==0 && y>0) return 2;
	if(y==0 && x<0) return 3;
	if(x==0 && y<0) return 4;
	if(x>0 && y>0) return 1;
	if(x<0 && y>0) return 2;
	if(x<0 && y<0) return 3;
	if(x>0 && y<0) return 4;
}

void zjhua(ll &x,ll &y)
{
	if(x==0 || y==0)
	{
		x=1;
		y=0;
	}
	else
	{
		while(!(x>0 && y>0))
		{
			ll tx=y,ty=-x;
			x=tx,y=ty;
		}
		ll g=__gcd(x,y);
		x/=g;
		y/=g;
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	quickcin;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	int zero=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==0 && b[i]==0)
		{
			zero++;
			continue;
		}
		ll x=a[i],y=b[i];
		zjhua(x,y);
		m[mp(x,y)].a[quadrant(a[i],b[i])]++;
	}
	int res=1;
	init(0,mod);
	for(auto tmp:m)
	{
		s4 o=tmp.second;
		int a=o.a[1],b=o.a[2],c=o.a[3],d=o.a[4];
		int ways=sub(add(fastpow(2,(a+c)),fastpow(2,(b+d))),1);
		res=mult(res,ways);
	}
	res=sub(res,1);
	res=add(res,zero);
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

int main()
{
   long long n;
   cin>>n;
   bitset<1000010> is_on;
   long long sum=0;
   for(int i=3;i<=n;i+=3)
   {
      if(!is_on[i])
         sum-=i;
         is_on[i]=1;
   }

   for(int i=5;i<=n;i+=5)
   {
      if(!is_on[i])
         sum-=i;
      is_on[i]=1;
   }
   cout<<(n*(n+1))/2+sum<<endl;


   return 0;

}


Measured memory_bytes: 3748
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

const double pi = acos(-1);

pair <double, double> rotate(int x, int y, int degree, double d) {
   double theta = (2 * pi / 360) * degree;
   double x_ = x * cos (theta) - y * sin(theta);
   double y_ = x * sin (theta) + y * cos(theta);
   x_ *= d;
   y_ *= d;
   return {x_, y_};
}

const double eps = 1e-3;

int near(double x) {
   for(int i = (int)(x - 2); i < (int)(x + 2); i++) {
      if(abs(i - x) < eps) {
         return i;
      }
   }
   return 0;
}
void solve() {
   double x1, x2, y1, y2;
   cin >> x1 >> y1 >> x2 >> y2;

   int x = x2 - x1;
   int y = y2 - y1;

   auto p3 = rotate(x, y, 45, sqrt(2));
   auto p4 = rotate(x, y, 90, 1);

   double x3 = p3.first + x1;
   double y3 = p3.second + y1;

   double x4 = p4.first + x1;
   double y4 = p4.second + y1;

   cout << fixed << setprecision(3) << endl;
   cout << near(x3) << " " << near(y3) << " " << near(x4) << " " << near(y4) << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 4068
n = gets.to_i
a_array = gets.split(' ').map(&:to_i).sort

alice_point = 0
bob_point = 0

loop do
  break if a_array.empty?
  alice_point += a_array.pop
  break if a_array.empty?
  bob_point += a_array.pop
end

puts (alice_point - bob_point).abs


Measured memory_bytes: 1788
n,t=map(int,input().split())
ans=0
a=list(map(int,input().split()))
if n==1:
    print(t)
else:
    for i in range(1,n):
        if a[i]-a[i-1]>t:
            ans+=t
        else:
            ans+=a[i]-a[i-1]
        if i==n-1:
            ans+=t
    print(ans)


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


void solve(long long A, long long B){
  int c=0;
  for(auto i=A;i<B+1;++i){
    string a = to_string(i);
    if(a[0] == a[4] && a[1] == a[3])c++;
  }
  cout << c << endl;

}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	void run() {

		for (; sc.hasNextLine();) {

			char[] in = sc.nextLine().toCharArray();

			String ans = "";

			for (int i = 0; i < in.length; i++) {

				if (in[i] == '@') {

					char rep = in[i + 2];

					int count = in[i+1] - '0' ;

					for (int j = 0; j < count; j++) {

						ans += rep;

					}

					i+=2;

				}else{

					ans += in[i];

				}

			}

			System.out.println(ans);

		}

	}

	



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 11000
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int a = getInt();
  const int b = getInt();
  printf("%d %d\n", min(a, b), max(0, a + b - n));
  return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back

int
main(void){
	int n; cin >> n;
	vector<ll> vec(n);
	for(int i = 0; i < n; i++){
		cin >> vec[i];
	}
	sort(vec.rbegin(), vec.rend());
	int it = 0;
	vector<ll> arr;
	while(it < vec.size()){
		if(it + 1 >= vec.size()) break;
		if(vec[it] == vec[it + 1]){
			arr.pb(vec[it]);
			it += 2;
		}
		else it += 1;
	}
	if(arr.size() <= 1){
		cout << 0;
		return 0;
	}
	
	cout << arr[0] * arr[1];
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s.size()==26)
    {
        if (s=="zyxwvutsrqponmlkjihgfedcba") cout << -1;
        else
        {
            int m[200];
            for(int i=0;i<=200;i++)
                m[i]=0;
            m[int(s[s.size()-1])]=1;
            string c;
            c="";
            int dem=97;
            for(int i=s.size()-2;i>=0;i--)
            {
                for(int j=int(s[i])+1;j<=122;j++)
                {
                    if (m[j]==1)
                    {
                        for(int k=0;k<i;k++)
                        {
                            cout <<s[k];
                        }
                        cout <<char(j);
                        return 0;
                    }
                }
                m[int(s[i])]=1;
            }
        
            
        }
    }
    else
    {
        int m[200];
        for(int i=0;i<=200;i++)
            m[i]=0;
        for(int i=0;i<s.size();i++)
        {
            m[int(s[i])]=1;
        }
        cout << s;
        for(int i=97;i<=122;i++)
        {
            if(m[i]==0)
            {
                cout << char(i);
                break;
            }
        }
        
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c;cin>>a>>b>>c;
  if(c-b==b-a){
    P("YES");
  }else{
    P("NO");
  }
  return 0;
}


Measured memory_bytes: 256
five_hun = int(input())
hun = int(input())
fifty = int(input())
yen = int(input())
count = 0

for i in range(five_hun + 1):
    for j in range(hun + 1):
        for k in range(fifty + 1):
            if i * 500 + j * 100 + k * 50 == yen:
                count += 1

print(count)

Measured memory_bytes: 3060
from collections import Counter


class UnionFindTree:
    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


N, K, L = map(int, input().split())

utf1 = UnionFindTree()
utf2 = UnionFindTree()
for i in range(N):
    utf1.make(i+1)
    utf2.make(i+1)

for i in range(K):
    p, q = map(int, input().split())
    utf1.unite(p, q)
for i in range(L):
    r, s = map(int, input().split())
    utf2.unite(r, s)

pairs = [(utf1.find(i+1), utf2.find(i+1)) for i in range(N)]
counts = Counter(pairs)
print(" ".join([str(counts[k]) for k in pairs]))


Measured memory_bytes: 145496
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4.2")
#include <bits/stdc++.h>

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI h(n);
	rep(i, n) cin >>h[i];
	int ans =0;
	rep2(i, 1, 101){
		bool ren=false;
		rep(j, n){
			if(h[j] >=i && !ren){ ans++; ren=1;}
			if(h[j] < i && ren){ ren = 0;}
		}
	}
	
	cout << ans <<"\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
#define eps 1e-15
#define f first
#define s second
typedef long long ll;
int main()
{
    fastIO
    int x;
    cin>>x;

    x==1?cout<<0:cout<<1;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

map<ll, ll> prime_factorization(ll n){
    map<ll,ll> ret;
    for(ll i=2;i*i<n;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}

vector<ll> all_divs(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long X;
    // X は正の整数
    cin >> X;
    //A^5 - B^5 = (A-B) * (A^4 + A^3*B + A^2*B^2 + A * B^3 + B^4)
    //後半は対称式なのでA,Bの入れ替わりは調べなくていい
    
    /*
    vector<ll> all = all_divs(X);
    for(const auto& a:all)
    {
        cerr << a << ":" << X / a << endl;
        for(size_t A=0;A<10; A++)
        {
        }
        // A - B = a
        // r = X / a;
    }
    */
    //if(pow(A,5) - pow(B,5) == X ) cout << "OK" << endl;
    //cerr << pow(A,4) + pow(A,3) * B + pow(A, 2) * pow(B, 2) + A*pow(B, 3) + pow(B,4) << endl;
    //A, Bの組で作れる値は限られている
    const int max_num = 200;
    vector<ll> elem(max_num);
    for(size_t i=0;i<=max_num; i++)
    {
        elem[i] = pow(i, 5);
        //cerr << elem[i] << endl;
    }
    //Aループ+
    for(int i=0;i<=max_num; i++)
    {
        //Bループ+
        for(int j=0;j<=max_num; j++)
        {
            if(elem[i] - elem[j] == X)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
        //Bループ-
        for(int j=0;j<=max_num; j++)
        {
            if(elem[i] + elem[j] == X)
            {
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }
    //Aループ-
    for(int i=0;i<=max_num; i++)
    {
        //Bループ+
        for(int j=0;j<=max_num; j++)
        {
            if(-elem[i] - elem[j] == X)
            {
                cout << -i << " " << j << endl;
                return 0;
            }
        }
        //Bループ-
        for(int j=0;j<=max_num; j++)
        {
            if(-elem[i] + elem[j] == X)
            {
                cout << -i << " " << -j << endl;
                return 0;
            }
        }
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  string s ;
  cin >> s;
  int p=-1 ;
  int q=-1 ;
  int len =s.size() ;
  rep(i,len){
   if(s[i]=='C'){
     p=i ;
     break ;
   } 
  }
  for(int i=len-1;i>=0;i--){
    if(s[i]=='F'){
      q=i;
      break ;
    }     
  }
  if(p!=-1&&q!=-1&&p<q)
  cout <<"Yes"<<endl ;
  else
  
  cout <<"No"<<endl ; 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(true){
int a = scan.nextInt();
char op = scan.next().charAt(0);
int b = scan.nextInt();

if(op == '?'){break;}

if(op == '+'){System.out.println(a + b);}

if(op == '-'){System.out.println(a - b);}

if(op == '*'){System.out.println(a * b);}

if(op == '/'){System.out.println(a / b);}
}}}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int sx, sy, tx, ty; std::cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  rep(i, dx) std::cout << 'R';
  rep(i, dy) std::cout << 'U';
  rep(i, dx) std::cout << 'L';
  rep(i, dy+1) std::cout << 'D';
  rep(i, dx+1) std::cout << 'R';
  rep(i, dy+1) std::cout << 'U';
  std::cout << 'L' << 'U';
  rep(i, dx+1) std::cout << 'L';
  rep(i, dy+1) std::cout << 'D';
  std::cout << 'R' << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
const long long INF = (1ull<<63) - 1;

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ans = -INF;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] h = new long[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextLong();
		}
		sc.close();

		Arrays.sort(h);

		long min = h[K - 1] - h[0];

		for (int i = K; i < N; i++) {
			long val = h[i] - h[i - K + 1];
			min = Math.min(min, val);
		}

		System.out.println(min);
	}
}


Measured memory_bytes: 60276
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int N;
  cin >> N;

  vector<pair<long,long> >point(N);
  for(int i=0;i<N;i++){
    cin >> point[i].first;
    cin >> point[i].second;
  }

  /*for(int i=0;i<N;i++){
    cout << point[i].first << " " << point[i].second << endl;
  }
  */



  if(N == 1 || N == 2)
  cout << 1 << endl;
  else{
    long n = N * N;
    //cout << n << endl;

  long m = 0;
  vector<pair<long,long> >distance(n);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      long x = point[i].first - point[j].first;
      long y = point[i].second - point[j].second;
      //cout << x << " " << y << endl;
      distance[m].first = x;
      distance[m].second = y;
      m++;
    }
  }

  /*for(int i=0;i<n;i++){
    cout << distance[i].first << " " << distance[i].second << endl;
  }
  */

  sort(distance.begin(),distance.end());

  /*for(int i=0;i<n;i++){
    cout << distance[i].first << " " << distance[i].second << endl;
  }
  */


  long p = distance[0].first;
  long q = distance[0].second;
  long ans = 0;
  long now = 0;
  long same = 0;

  while(1){
    while(p == distance[now].first && q == distance[now].second){
      same++;
      now++;
      if(p == 0 && q == 0)
      same--;
      if(now == n - 1)break;
    }
    p = distance[now].first;
    q = distance[now].second;
    if(ans < same)
    ans = same;
    if(now == n - 1)
      break;
    same = 0;
  }

  cout << N - ans << endl;
}

  return 0;
}


Measured memory_bytes: 256
def main():
    N, K = list(map(int, input().split(' ')))
    ans = (N // K)**3  # 0 mod K
    if K % 2 == 0:
        ans += ((N - K//2) // K + 1)**3  # K//2 mod K
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

void Main()
{
  ll n; cin >> n;
  map<str, ll> ans;
  rep(i, n)
  {
    str s;
    cin >> s;
    if(!ans.count(s)) ans[s];
  }
  fin(ans.size());
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 19212
#include<stdio.h>

int main(){
    int N;
    int p[11];
    int i,j;
    int max = 0;
    int sum = 0;

    scanf("%d", &N);

    for(i=0; i<N; i++){
        scanf("%d", &p[i]);
        if(max<p[i]){
            max = p[i];
        }
        sum = sum + p[i];
    }
    printf("%d", sum-max/2);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,b,s=0;
    cin>>n>>b;
    long long a[n];
    for(int i=0;i<n;i++)
     cin>>a[i];
     
    sort(a,a+n);
    
    for(int i=0;i<b;i++)
      s=s+a[i];
      
    cout<<s;
    return 0;
}

Measured memory_bytes: 3600
import re

s = input()
key = 'keyence'
ans = 'NO'
for i in range(len(key)):
    k1 = key[:i + 1]
    k2 = key[i + 1:]
    
    k1_temp = [m.span() for m in re.finditer(k1, s)]
    for j in range(len(k1_temp)):
        k2_temp= [m.span() for m in re.finditer(k2, s)]
        for k in range(len(k2_temp)):
            if k1_temp[j][1] == k2_temp[k][0]:
                ans = 'YES'
                break
            if  k1_temp[j][0] == 0 and k2_temp[k][1] == len(s):
                ans = 'YES'
                break
print(ans)


Measured memory_bytes: 9840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int max = Integer.MAX_VALUE;
		int subS = 0;

		for (int i = 0; i < S.length() - 2; i++) {
			subS = Integer.valueOf(S.substring(i, i + 3));
			if (Math.abs(753 - subS) < max) max = Math.abs(753 - subS);
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<pair<ll,ll>> A(N);
    REP(i,N){
        cin >> A[i].second;
        cin >> A[i].first;
    }
    ll now = 0;
    bool miss = 0;
    sort(A.begin(),A.end());
    REP(i,N){
        now += A[i].second;
        if(now > A[i].first)miss = 1;
    }
    if(miss){
        cout <<"No"<< "\n";
    }else{
        cout <<"Yes"<< "\n";
    }
}

Measured memory_bytes: 3328
@s=0..<>-1;@y=map-$t+($t=$_),glob<>;map{@s=@s[@s];@s[$_-1,$_]=@s[$_,$_-1]for<>;@y=@y[@s]if$'>>$_&1}<>!~($/=$")..59;print$z+=$_,$"for@y

Measured memory_bytes: 51956
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
using v = vector<ll>;
using p = pair<ll,ll>;
int main(){
    ll n; cin >> n;
    auto ba = vector<p>(n,make_pair(0,0));
    for(auto &i:ba) cin >> i.second >> i.first;
    sort(ba.begin(),ba.end());
    ll sum=0;
    for(auto i:ba){
        if(sum+i.second<=i.first){
            sum+=i.second;
        }else{
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  int K,A,B;cin>>K>>A>>B;
  bool flag=false;
  for(int i=A;i<=B;++i){
    if(i%K==0) flag=true;
  }
  if(flag) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <list>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

int solve(int n, string& s){
    V t(n);
    transform(s.begin(), s.end(), t.begin(), [](char c){return (int) c;});
    t.insert(t.begin(), 0);
    partial_sum(t.begin(), t.end(), t.begin(), [](int x, int c){return (c == 'I') ? x + 1 : x - 1;});
    return *max_element(t.begin(), t.end());
}

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

    int n;
    string s;
    cin >> n >> s;
    cout << solve(n, s) << endl;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    const NMAX: usize = 10_000;
    const XMAX: usize = 100;

    let mut ans = vec![0; NMAX + 1];
    for x in 1..=XMAX {
        for y in 1..=XMAX {
            for z in 1..=XMAX {
                let res = x * x + y * y + z * z + x * y + y * z + z * x;
                if res > NMAX { continue; }
                ans[res] += 1;
            }
        }
    }

    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    for i in 1..=n {
        println!("{}", ans[i]);
    }
}

Measured memory_bytes: 2092
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	DiceCtrl dc = new DiceCtrl();

    	for(int i = 0; i < 6; i++) {
    		dc.numList[i] = sc.nextInt();
    	}
    	
    	String ctrl = sc.next();
    	char[] ctrlList = ctrl.toCharArray();
    	
    	for(int i = 0; i < ctrlList.length; i++) {
    		switch(ctrlList[i]) {
    			case 'E' :
    				dc.ctrlE();
    				break;
    			case 'N' :
    				dc.ctrlN();
    				break;
    			case 'S' :
    				dc.ctrlS();
    				break;
    			case 'W' :
    				dc.ctrlW();
    				break;
    		}
    	}
    	System.out.println(dc.numList[0]);
    }
}
class DiceCtrl {
	public int[] numList = new int[6];
	private int tmp = 0;
	
	void ctrlE() {
		tmp = numList[0];
		numList[0] = numList[3];
		numList[3] = numList[5];
		numList[5] = numList[2];
		numList[2] = tmp;
	}
	void ctrlN() {
		tmp = numList[0];
		numList[0] = numList[1];
		numList[1] = numList[5];
		numList[5] = numList[4];
		numList[4] = tmp;
	}
	void ctrlS() {
		tmp = numList[0];
		numList[0] = numList[4];
		numList[4] = numList[5];
		numList[5] = numList[1];
		numList[1] = tmp;
	}
	void ctrlW() {
		tmp = numList[0];
		numList[0] = numList[2];
		numList[2] = numList[5];
		numList[5] = numList[3];
		numList[3] = tmp;
	}
}

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

const int MAX = 1000;
int main() {
	int N, a[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	sort(a, a+N);
	cout << a[N - 1] - a[0];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

i<jの時a_i<=a_jであるとするよ
この時、a_1からa_Nまでの家の間に全ての家があるわけだ
ならa_1からa_Nまで移動すれば全ての家を通れるね
*/

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> num(26, 0);
    for (ll i = 0; i < N; i++) {
        string P;
        cin >> P;
        num[P[0] - 'A']++;
    }

    ll ans = 0;
    for (ll i = 0; ; i++) {
        sort(num.begin(), num.end(), greater<ll>());

        for (ll j = 0; j < K; j++) {
            if (num[j]-- == 0) {
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
    }
}

Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    D = [int(x) for x in input().split()]
    M = int(input())
    T = [int(x) for x in input().split()]

    c = collections.Counter(D)

    for t in T:
        if c[t] <= 0:
            print("NO")
            return
        else:
            c[t] -= 1

    print("YES")



    

if __name__ == '__main__':
    main()



Measured memory_bytes: 44832
#include <iostream>

int main() {
  int n;
  int m;
  int l;
  std::cin >> n >> m >> l;

  long int *a = new long int[n * m];
  long int *b = new long int[m * l];
  long int *c = new long int[n * l];

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      std::cin >> a[i * m + j];
    }
  }
  for(int i = 0; i < m; ++i) {
    for(int j = 0; j < l; ++j) {
      std::cin >> b[i * l + j];
    }
  }
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < l; ++j) {
      c[i * l + j] = 0;
    }
  }

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      for(int k = 0; k < l; ++k) {
        c[i * l + k] += a[i * m + j] * b[j * l + k];
      }
    }
  }

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < l; ++j) {
      if(j == l - 1) {
        std::cout << c[i * l + j] << std::endl;
      }
      else {
        std::cout << c[i * l + j] << " ";
      }
    }
  }

  delete[] a;
  delete[] b;
  delete[] c;

  return 0;
}

Measured memory_bytes: 3152
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 300

	int anX[10000];

int main() {

	int i=0;
	int j=0;
	int nNumber=0;
	int nOpe=0;
	int nTemp=0;

	// read line 1
    scanf("%d", &nNumber);
	// read line 2
	for(i=0; i<nNumber; i++) {
        scanf("%d", &anX[i]);
	}
	for(i=0; i<nNumber; i++) {
		nTemp=anX[i];
        while(nTemp%2==0){
			nTemp=nTemp/2;
			nOpe++;
		}
	}

	printf("%d\n",nOpe);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

ll h[100010];
ll dp[100010];

int main() {
  int N;
  cin >> N;
  REP(i, N) cin >> h[i];
  REP(i, N) dp[i] = INF;

  dp[0] = 0;

  for (int i = 1; i < N; i++) {
     chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));

    if (i > 1)  chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    // cout << i << "/" << dp[i] << endl;
  }

  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ccin cin>>akioi>>aknoi>>akcsp
#define ii i--
#define iii i>=1
#define iiii i=akioi
#define akioioi akioiioi-=2
ll akioi;
double aknoi,akcsp,ans;
int main()
{
    ccin;
    double akioiioi=akioi*2;
    for(ll iiii;iii;ii) 
	{
        ans+=aknoi;
		ans+=(akioiioi-1)/2*akcsp;
        double aknoinoi=aknoi+(aknoi*2+akcsp*5)/akioiioi;
        double akcspcsp=akcsp+4*akcsp/akioiioi;
        akcsp=akcspcsp;
		aknoi=aknoinoi;
		akioioi;
    }
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 256