akhauriyash/Code-Regression huggingface dataset:
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int n;
vll a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll total = accumulate(ALL(a), 0LL);

    V< bitset<4000001> > dp(2);
    dp[0].set(0);
    for (int i = 0; i < n; i++) {
        dp[1] = dp[0] | (dp[0] << a[i]);
        swap(dp[0], dp[1]);
    }

    for (int i = (total + 1) / 2; i < total + 1; i++) {
        if (dp[0][i] == 1) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double s=w*h;
    cout<<fixed<<setprecision(6)<<s/2<<" ";
    if(x==w/2&&y==h/2)
        cout<<1;
    else
        cout<<0;
	return 0;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.size();

	// 偶数番目の要素を0に奇数番目を1に変える場合
	int countA = 0;
	for (int i = 0; i < n; i++)
	{
		
		if (i % 2 == 0)
		{
			if (s.at(i) == '1')
			{
				countA++;
			}
		}
		else
		{
			if (s.at(i) == '0')
			{
				countA++;
			}
		}
	}

	// 偶数番目の要素を1に奇数番目を0に変える場合
	int countB = 0;
	for (int i = 0; i < n; i++)
	{

		if (i % 2 == 0)
		{
			if (s.at(i) == '0')
			{
				countB++;
			}
		}
		else
		{
			if (s.at(i) == '1')
			{
				countB++;
			}
		}
	}

	cout << (countA < countB ? countA : countB) << endl;
}

Measured memory_bytes: 512
t = int(input())
dp = [[0 for i in range(3)] for j in range(t)]
for i in range(t):
    var = list(map(int, input().split()))
    for j in range(3):
        if i == 0:
            dp[i][j] = var[j]
        else:
            for k in range(3):
                if j != k:
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + var[j])
print(max(dp[-1]))


Measured memory_bytes: 24396
import java.util.Scanner;

public class Main{
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    double pi = Math.PI;
    double area = pi * r * r;
    double length = 2 * pi * r;
    System.out.printf("%f %f",area,length);
    sc.close();
  }
}


Measured memory_bytes: 28104
#include <stdio.h>
#include <string.h>
char s[301][302];
int n,hsrp[302][302],hsrs[302][302],hscp[302][302],hscs[302][302],pw[301],A,B;
inline void trans(int &a,int &b)
{
    a+=A;
    b+=B;
    if (a>n)
        a-=n;
    if (b>n)
        b-=n;
}
inline int row_hash(int r)
{
    int x1=r,y1=r,x2=r,y2=n;
    trans(x1,y1);
    trans(x2,y2);
    if (y1<=y2)
        return hsrp[x1][y2]-hsrp[x1][y1-1]*pw[y2-y1+1];
    else
        return hsrs[x1][y1]*pw[y2]+hsrp[x1][y2];
}
inline int column_hash(int c)
{
    int x1=c,y1=c,x2=n,y2=c;
    trans(x1,y1);
    trans(x2,y2);
    if (x1<=x2)
        return hscp[x2][y1]-hscp[x1-1][y1]*pw[x2-x1+1];
    else
        return hscs[x1][y1]*pw[x2]+hscp[x2][y1];
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
        scanf("%s",s[i]+1);
    pw[0]=1;
    for (int i=1;i<=n;++i)
        pw[i]=pw[i-1]*171;
    for (int i=1;i<=n;++i)
    {
        for (int j=1;j<=n;++j)
        {
            hsrp[i][j]=hsrp[i][j-1]*171+s[i][j];
            hscp[j][i]=hscp[j-1][i]*171+s[j][i];
        }
        for (int j=n;j>=1;--j)
        {
            hsrs[i][j]=hsrs[i][j+1]+pw[n-j]*s[i][j];
            hscs[j][i]=hscs[j+1][i]+pw[n-j]*s[j][i];
        }
    }
    int ans=0;
    for (A=0;A<n;++A)
        for (B=0;B<n;++B)
        {
            bool f=true;
            for (int i=1;f&&i<=n;++i)
                if (row_hash(i)!=column_hash(i))
                    f=false;
            ans+=f;
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1664
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

//累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod) {
  if (a % mod == 0) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (x * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return x;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  std::vector<std::vector<ll>> graph(n,std::vector<ll>());
  rep(i,1,n){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  std::vector<ll> start(n,LLONG_MAX),goal(n,LLONG_MAX);

  std::queue<ll> que;
  que.push(0);
  start[0]=0;

  while(que.size()){
    ll p=que.front();que.pop();

    rep(i,0,graph[p].size()){
      if(start[graph[p][i]]==LLONG_MAX){
        start[graph[p][i]]=start[p]+1;
        que.push(graph[p][i]);
      }
    }
  }

  que.push(n-1);
  goal[n-1] = 0;

  while (que.size()) {
    ll p = que.front();
    que.pop();

    rep (i, 0, graph[p].size()) {
      if (goal[graph[p][i]] == LLONG_MAX) {
        goal[graph[p][i]] = goal[p] + 1;
        que.push(graph[p][i]);
      }
    }
  }

  ll count=0;

  rep(i,0,n)if(start[i]<=goal[i])count++;

  if(count>n/2)std::cout<<"Fennec";
  else std::cout<<"Snuke";

  return 0;
}

Measured memory_bytes: 7936
#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 ll mod = 1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int sw=0;
	for(auto x:s) if(x=='9') sw=1;
	cout << (sw? "Yes":"No") <<"\n";
	return 0;
}

Measured memory_bytes: 256
use v6;

my ($a, $b) = get().chomp.split(' ');
if (0 < $a) {
	say 'Positive';
} elsif ($b < 0) {
	my $n = $b - $a;
	if ($n % 2 == 0) {
		say 'Negative';
	} else {
		say 'Positive';
	}
} else {
	say 'Zero';
}


exit;

Measured memory_bytes: 67232
N=int(input())
A=list(map(int, input().split()))
s=0
for i in range(N):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      s+=0
    else:
      s+=1
if s!=0:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 3060
import collections

N=int(input())
A=list(map(int,input().split()))

B=collections.deque([])
for i in range(N):
  if i%2==0:
    B.append(A[i])
  else:
    B.appendleft(A[i])
#print(B)
B=list(B)
#print(B)
if N%2==1:
  B=B[::-1]

print(" ".join(map(str,B)))

Measured memory_bytes: 30660
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
struct amd{
    int h;
    int p;
    int g;
};

int main(){
    int n,m,a,i;
    while(1){
        scanf("%d",&n);
        scanf("%d",&m);
        scanf("%d",&a);
        if(!n && !m && !a){break;}
        vector<amd> amida(m);
        for(i=0;i<m;i++){
            scanf("%d",&amida[i].h);
            scanf("%d",&amida[i].p);
            scanf("%d",&amida[i].g);
        } 
        sort(amida.begin(),amida.end(),[](const amd& x,const amd& y){return x.h>y.h;});
        int cpos=a,isp=0;
        for(i=0;i<m;i++){
            if(amida[i].p==cpos){
                cpos=amida[i].g;
            }
            else if(amida[i].g==cpos){
                cpos=amida[i].p;
            }
        }
        printf("%d\n",cpos);
    }
    return 0;    
}



Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    // ll ans = 0;
    ll l, r, n = 2019;

    cin >> l >> r;
    
    ll ans = 2019;
    for (ll i = l; i < min(r, l+n); i++) {
        for (ll j = i+1; j < min(r, l+n)+1; j++) {
            if (ans > (i*j) % n) {
                ans = (i*j) % n;
            }
        }
    }
    
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

uint64_t gcd(uint64_t a, uint64_t b) {
	uint64_t r;
	while (b > 0) {
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main(void) {
	uint64_t A, B;
	uint64_t i;
	uint64_t ayaneru;
	uint64_t yosinagasayuri = 0;
	if (scanf("%" SCNu64 "%" SCNu64, &A, &B) != 2) return 1;
	ayaneru = gcd(A, B);
	for (i = 2; i * i <= ayaneru; i++) {
		if (ayaneru % i == 0) {
			yosinagasayuri++;
			while (ayaneru % i == 0) ayaneru /= i;
		}
	}
	if (ayaneru > 1) yosinagasayuri++;
	/* 違う素因数の数 + 「1」 */
	printf("%" PRIu64 "\n", yosinagasayuri + 1);
	return 0;
}


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

using namespace std;
#define fordebug int hogeko;cin>>hogeko;
#define DEKAI 1000000007
#define INF 1000000000
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
#define int long long

signed main(){
	int n,k;
	cin>>n>>k;
	vector<int> v;
	lp(i,n){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int ans=INF;
	for(int i=0;i+k-1<n;i++){
		ans=min(ans,v[i+k-1]-v[i]);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1400
import java.util.*;

public class Main {

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

        for (int i = 0; i < s.length(); i++) {
            switch (i) {
                case 2:
                    System.out.print('1');
                    break;
                case 3:
                    System.out.print('8');
                    break;
                default:
                    System.out.print(s.charAt(i));
                    break;
            }
        }
    }
}


Measured memory_bytes: 21844
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    ll dp[100005] ={};
    int n, m;
    cin >> n >> m;
    map<int, int> a;
    REP(i, m) {
        cin >> tmp;
        a[tmp] ++;
    }
    dp[0] = 1;
    REP1(i, n){
        if(a[i] > 0){
            dp[i] = 0;
            continue;
        }
        if(i==1) dp[i] = 1;
        else{
            dp[i] = (dp[i-1] + dp[i-2]) % MODA;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 5760
N, D, A = map(int, input().split())

data = []
for _ in range(N):
	data.append(tuple(map(int, input().split())))

data.sort()

queue = []
i = 0
j = 0
total = 0
height = 0
while i < N:
	if j >= len(queue) or data[i][0] <= queue[j][0]:
		x, h = data[i]
		i += 1
		if height < h:
			count = (h - height + A - 1) // A
			total += count
			height += count * A
			queue.append((x + D * 2, count * A))
	else:
		height -= queue[j][1]
		j += 1

print(total)


Measured memory_bytes: 58612
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
total=sum(b)
for i in range(n):
    if i!=0 and a[i]-1==a[i-1]:
        total+=c[a[i]-2]
print(total) 

Measured memory_bytes: 3064
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
x,n=n1()

if n==0:
    print(x)
else:
    P=n1()
    if (not x in P):
        print(x)
    else:
        d=[]
        d2=[]
        for i in range(0,102):
            if (not i in P):
                d.append(i)
                d2.append(abs(x-i))

        a=min(d2)
        if (x-a) in d:
            print(x-a)
        else:
            print(x+a)

Measured memory_bytes: 9280
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int s, t, n = 0, p = 1;
	cin >> s >> t;
	if (t == 1) { n = 0; }
	else {
		for (; t > p; n++) {
			p--; p += s;
		}
	}
	cout << n;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    int x=a[0];
    while(a.size()>1){
        for(int i = 1; i < a.size(); i++) {
            a[i] %= x;
        }
        sort(a.begin(),a.end());
        reverse(a.begin(),a.end());
        while(true){
            int p=a.size()-1;
            if(a[p]==0){
                a.pop_back();
            }
            else break;
        }
        sort(a.begin(),a.end());
        x=a[0];
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
int a[maxn];
map <int, int> M;
set <int> s;
vector <int> v;
int main(){
	int n;
	cin>>n;
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		M[a[i]]++;
		s.insert(a[i]);
	}
	int ans= 0;
	for (set <int> :: iterator it= s.begin(); it!=s.end(); it++){
		int cur= *it;
		if (M[cur]%2==0) v.push_back(cur);
		else ans++;
	}
	if (v.size()%2==1) v.pop_back();
	cout<<ans+v.size()<<endl;

}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;


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

  map<int, int> m;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;

    m[a]++;
  }

  int ans = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    int x = itr->first, y = itr->second;

    if(x < y){
      ans += y-x;
    }else if(x > y){
      ans += y;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  long long a=0,b=0,c=0,d=0,m=0,n=0,p=0,q=0;
  long double v;
  cin >> a >> v;
  cout << setprecision(17) <<floor(a*v);
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int ans;

  if(n >= k){
    int mod = n % k;
    if(mod == 0) ans = 0;
    else ans = 1;
  }
  else ans = 1;

  cout << ans << endl;


}


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

int main(){
	int n,m;cin>>n>>m;
	int Max=m;
	rep(i,n){
		int a,b;cin>>a>>b;
		m+=a-b;
		if(m<0){puts("0");return 0;}
		Max=max(Max,m);
	}
	cout<<Max<<endl;
	return 0;
}

Measured memory_bytes: 3104
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
r = n%k
print(min(r,k-r))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;
    if(s[0]==s[1] && s[1]==s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main() {
  int n, x;
  scanf("%d", &n);
   
  for (int i = 1; i <= n; i++)
  {
    if(i % 3 == 0) {
      printf(" %d", i);
    } else {
        x = i;
      do {
        if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
      } while (x);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2708
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string x,y,z;
	int a,b;
	cin>>x>>y>>z;
	a=x.size()-1;
	b=y.size()-1;
	if(x[a]==y[0] && y[b]==z[0]) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	
	string s;
	ll i,j,l, a[mx];
	cin>>s;
	l= s.size();
	
	vl lt, rt;
	for(i=0; i<l; i++)
	{
	    a[i]= 0;
	    if(s[i]== 'L')
	    lt.pb(i);
	    else
	    rt.pb(-1 * i);
	}
	//reverse(rt.begin(), rt.end());
	sort(rt.begin(), rt.end());
	
	for(i=0; i< l; i++){
	    
	    if(s[i]=='R')
	    {
	        auto it= ub(lt.begin(), lt.end(), i);
            ll kk= (*it) - i;
            if(kk&1)
            a[(*it) -1]++;
            else
            a[(*it)]++;
            //cout<<kk<<" ";
            
	    }
	    else{
	        auto it= ub(rt.begin(), rt.end(), -1*i);
	        ll kk= i+ (*it);
	        if(kk&1)
	        a[-1*(*it) +1]++;
	        else
	        a[-1*(*it)]++;
	       /* cout<<*it<<" ";
	        break;*/
	    }
	    
	}
	for(i=0; i<l; i++)
	cout<<a[i]<<" ";
	
	
    return 0;
}























Measured memory_bytes: 2372
#include<stdio.h>
 
int main(void){
    int n,i,f,j;
 
    scanf("%d",&n);
 
    for(i = 1;i <= n;i++){
        f = 0;
        if(i % 3 == 0)
            f = 1;
        j = i;
        while(j > 0){
            if(j % 10 == 3){
                f = 1;break;
            }
            j /= 10;
        }
        if(f == 1)
            printf(" %d",i);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
def main():
    k = int(input())

    if k == 0:
        print(4)
        print(3, 3, 3, 3)
        return
    if k == 1:
        print(3)
        print(1, 0, 3)
        return
    if k <= 50:
        print(k)
        print(' '.join([str(k)]*k))
        return
    print(50)
    res = [50+k//50-k%50-1]*50
    for i in range(k%50):
        res[i] += 51
    print(' '.join([str(i) for i in res]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
Xlist = list(map(int, input().split()))
Xlist.sort()

a = sum(Xlist)/N

a_m = int(a)
a_p = a_m + 1

if a - a_m < a_p - a:
    p = a_m
else:
    p = a_p

ans = 0
for i in range(N):
    ans += (Xlist[i] - p)**2

print(ans)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
  char x;
  vector<int> s(4);
  for(int i = 0; i < 4; i++){
    cin >> x;
    s.at(i) = ctoi(x);
  }
  if(s.at(0) + s.at(1) + s.at(2) + s.at(3) == 7)
    cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
  else if(s.at(0) + s.at(1) + s.at(2) - s.at(3) == 7)
    cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
  else if(s.at(0) + s.at(1) - s.at(2) + s.at(3) == 7)
    cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
  else if(s.at(0) - s.at(1) + s.at(2) + s.at(3) == 7)
    cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
  else if(s.at(0) + s.at(1) - s.at(2) - s.at(3) == 7)
    cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
  else if(s.at(0) - s.at(1) - s.at(2) + s.at(3) == 7)
    cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
  else if(s.at(0) - s.at(1) + s.at(2) - s.at(3) == 7)
    cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
  else if(s.at(0) - s.at(1) - s.at(2) - s.at(3) == 7)
    cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int k;

	cin >> k;


	int ans = (k / 2) * (k / 2);
	if (k % 2 == 1) ans += k / 2;

	cout << ans NL;

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val H1 = sc.next().toInt()
        val M1 = sc.next().toInt()
        val H2 = sc.next().toInt()
        val M2 = sc.next().toInt()
        val K = sc.next().toInt()
        val S = H1 * 60 + M1
        val E = H2 * 60 + M2
        pw.println(E - S - K)
    }
}


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

int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l.begin(),l.end());
    int count=0;
    //一番小さい棒の番号
    for(int i=0;i<n-2;i++){
        //二番目に小さい棒の番号
        for(int j=i+1;j<n-1;j++){
            //三番目に小さい棒の番号
            for(int k=j+1;k<n;k++){
                if(l[i]+l[j]>l[k] && l[i] != l[j] && l[j] != l[k]){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)       sort((a).begin(), a.end()), (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
LL gcd(LL a, LL b)
{
	if (!a)return b; return gcd(b%a, a);
}
double intlog(double base, double x) {
	return (double)((double)log(x) / (double)log(base));
}

int main()
{

	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy" << endl;
	if (s == "Cloudy")
		cout << "Rainy" << endl;
	if (s == "Rainy")
		cout << "Sunny" << endl;
	
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
  string s,t;
  cin >> s >> t;
  string u;
  rep(i,t.size()) {
      u+=s[i];
      u+=t[i];
  }
  if (s.size()-t.size()==1) u+=s[s.size()-1];
  cout << u << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
vector<string> bit;


void subBin(string str, int n)
{
    if (n == 0){
        bit.push_back(str);
    }
    if (n > 0) {
        subBin(str + "0", n - 1);
        subBin(str + "1", n - 1);
    }
}
string toBin(int n){
    if(n == 1)return "1";
    else if(n == 0)return "0";

    return toBin(n/2)  + to_string(n%2);
}

long long gcd(long long a,long long b)
{
	if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}
int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    if(c < d){
        long long tmp = c;
        c = d;
        d = tmp;
    }
    a -= 1;
    long long lcm = c*d/gcd(c, d);
    long long min = (a/c + a/d - a/lcm);
    long long max = (b/c + b/d - b/lcm);

    cout << b - a - (max - min) << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 1e4 +2;
void Print(vector<int>&v)
{
    printf("Yes\n");
    for(int i=0; i<v.size(); i++)
    {
        printf("%d ",v[i]);
    }
    printf("\n");
}


void SOLVE(int cas)
{
    int n,x;
    scanf("%d %d",&n,&x);
    vector<int>a(2*n-1);
    if(x==1 ||x== 2*n-1)
    {
        printf("No\n");
        return;
    }
    int now = x;
    int pos = n-1;
    while(now<=2*n-1)
    {
        a[pos]=now;
        now++;
        pos= (pos+1)%(2*n-1);
    }
    now= x-1;
    pos= n-2;
    while(now>=1)
    {
        a[pos]=now;
        now--;
        pos= (pos-1 + 2*n-1)%(2*n-1);
    }
    Print(a);



}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<std::string> s){
    int ans = 0;
    int lastA = 0;
    int firstB = 0;
    int memo = 0;
    REP(i, N) {
        if(s[i][0] == 'B') firstB++;
        if(s[i][s[i].size()-1] == 'A') lastA++;
        if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') memo++;

        REP(j, s[i].size()-1) {
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }
    }

    if(memo == firstB && memo == lastA && memo != 0) ans--;
    cout << (ans + min(lastA, firstB)) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    solve(N, std::move(s));
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int l,r,d;
    cin>>l>>r>>d;
    int res = r/d - (l-1)/d;
    cout<<res<<endl;    
    
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll n;cin>>n;
  ll half = min(a*2,b);
  ll one = min(half*2,c);
  ll two = min(one*2,d);
  ll ans = (n/2)*two + (n%2)*one;
  print(ans);
  return 0;
}



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

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    faster();
    
    Int t = 1;
    while(t--)
    {
        Int n;
        cin>>n;
        Int a[n];
        Int i,j,k;
        
        Int csum[n+1];
        csum[0] = 0;
        for(i=0; i<n; i++) { cin>>a[i]; csum[i+1] = csum[i] + a[i]; }
        
        Int dp[n][n];
        memset(dp, 0, sizeof(dp));
        
        for(i= n-1; i>= 0; i--)
        {
            for( j = i+1; j <= n-1; j++ )
            {
                for( k = i; k<j; k++ )
                {
                    if ( dp[i][j] == 0  ) dp[i][j] = dp[i][k]  + dp[k+1][j] +  csum[j+1] - csum[i] ; else
                    dp[i][j] = min (  dp[i][j] , dp[i][k]  + dp[k+1][j] + csum[j+1] - csum[i] );   
                }
            }
        }
        cout<<dp[0][n-1]<<'\n';
    }
    
    
    
    return 0;
}

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

int main() {
	int score_a[] = { 0, 0, 0, 0, 0 };
	int score_b[] = { 0, 0, 0, 0, 0 };
	int cnt = 0;
	bool flg = true;
	
	while (flg) {
		int num;

		cin >> num;
		if ((cnt >= 5) || (num == 0)) {
			flg = false;
		}
		else {
			for (int i = 0; i < num; i++) {
				int a;
				int b;

				cin >> a >> b;
				if (a > b) {
					score_a[cnt] += a + b;
				}
				else if (b > a) {
					score_b[cnt] += a + b;
				}
				else {
					score_a[cnt] += a;
					score_b[cnt] += b;
				}
			}
			cnt++;
		}
	}
	for (int i = 0; i < cnt; i++) {
		cout << score_a[i] << " " << score_b[i] << endl;
	}

	//while (1);

	return 0;
}

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

int N;
double p[3000];
double dp[3001][3001];

int main(void){
    // Your code here!
    cin >> N;
    for(int i = 0; i < N; i++) cin >> p[i];
    
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = 0.0;
        }
    }
    dp[0][0] =1.0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= i; j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);
        }
    }
    
    
    
   double prob = 0.0;
    for(int i = (N+1)/2; i <= N; i++){
        prob += dp[N][i];
    }
    
    printf("%.9f\n", prob);

    
    
    
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

vi solve(int n,int a,int b);

vi solve(int n,int b)
{
	if(n==1)
		return {0,1};
	int i=__builtin_ctz(b);
	int s=(1<<i)-1;
	b=(b>>1&~s)|(b&s);
	int c=b^1;
	vi p;
	for(int x:solve(n-1,0,c))
		p.push_back((x&~s)<<1|(x&s));
	for(int x:solve(n-1,c,b))
		p.push_back((x&~s)<<1|1<<i|(x&s));
	return p;
}

vi solve(int n,int a,int b)
{
	vi res=solve(n,a^b);
	for(int& x:res)
		x^=a;
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,a,b;cin>>n>>a>>b&&n|a|b;){
		if(__builtin_popcount(a^b)%2==1){
			cout<<"YES"<<endl;
			vi res=solve(n,a,b);
			rep(i,res.size())
				cout<<res[i]<<"\n "[i+1<res.size()];
		}
		else{
			cout<<"NO"<<endl;
		}
	}
}


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

int main(){
  int N,X,cnt=0,L;
  cin>>N>>X;
  for(int i=0;i<N;i++){
    cin>>L;
    cnt+=L;
    if(cnt>X){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<N+1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		int x=i;
		if(x%3 == 0){
			printf(" %d",i);
			x=0;
		}
		while(x){
			if(x%10 == 3){
				printf(" %d",i);
				break;
			}
			x/=10;
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <unordered_map>
#define LL long long
#define VMAX 100000
using namespace std;

LL N,a[100010],K,p[100010],r[100010]; bool v[100010];

unordered_map<LL,LL> mp;
unordered_map<LL,bool> viz;
unordered_map<LL,pair<LL,LL>> mp2;

void sieve(){
    int i,j;
    for (i=2; i<=VMAX; i++)
        if (!v[i]){
            p[++K]=i;
            for (j=2*i; j<=VMAX; j+=i)
                v[j]=1;
        }
}

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

    sieve();

    LL i,t,put;
    LL val,rev,aux;
    for (i=1; i<=N; i++) cin >> a[i];

    LL res=0;
    for (t=1; t<=N; t++){
        if (mp2.count(a[t])){
            val=mp2[a[t]].first;
            rev=mp2[a[t]].second;
            a[t]=val,r[t]=rev;
            mp[a[t]]++;
            continue;
        }
        val=1,rev=1; aux=a[t];
        for (i=1; p[i]*p[i]<=a[t] && i<=K; i++)
            if (a[t]%p[i]==0){
                put=0;
                while (a[t]%p[i]==0) a[t]/=p[i],put++;
                if (put%3==1) val*=p[i],rev=rev*p[i]*p[i];
                else if (put%3==2) val=val*p[i]*p[i],rev*=p[i];
            }

        if (a[t]>1) val*=a[t],rev=rev*a[t]*a[t];
        a[t]=val,r[t]=rev;
        mp2[aux]=make_pair(val,rev);
        mp[a[t]]++;
    }

    for (i=1; i<=N; i++)
        if (!viz[a[i]]){
            viz[a[i]]=1,viz[r[i]]=1;
            if (a[i]==1) res++;
            else res+=max(mp[a[i]],mp[r[i]]);
        }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 24172
#include <iostream>

using namespace std;

int main(){
    char c[3][3];

    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++)
            cin >> c[i][j];
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N, M;
        long LCM;
        String S, T;
        StringBuilder partialStrOfS = new StringBuilder();
        StringBuilder partialStrOfT = new StringBuilder();

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

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            M = in.nextInt();
            S = in.next();
            T = in.next();
            LCM = (long)N/(long)gcd(N, M)*(long)M;

            for (int i = 0; i < N; i += LCM/M) {
                partialStrOfS.append(S.charAt(i));
            }
            for (int i = 0; i < M; i += LCM/N) {
                partialStrOfT.append(T.charAt(i));
            }

            if (partialStrOfS.toString().equals(partialStrOfT.toString())) {
                out.println(LCM);
            } else {
                out.println(-1);
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n, k;
    cin >> n >> k;
    int cnt = k;
    if(n==1){
        cout << k << endl;
        return 0;
    }

    for (int i = 0; i < n-1; i++)
    {
        cnt *= (k - 1);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
 
using namespace std;
 
int mod=1e9+7;
int main(){
    int N,M;
    cin >> N >> M;
    int s[N+1];
    for(int i=0;i<=N;i++){
        s[i]=0;
    }
    for(int i=0;i<M;i++){
        int a; cin >> a;
        s[a]=1;
    }
 
    int dp[N+1];
    dp[0]=1;
    for(int i=1;i<N+1;i++){
        dp[i]=0;
    }
    for(int i=0;i<N-1;i++){
        if(s[i]==0){
            dp[i+1]+=dp[i];
            dp[i+2]+=dp[i];
            dp[i+1]%=mod;
            dp[i+2]%=mod;
        }
    }
    if(s[N-1]==0){
            dp[N]+=dp[N-1];
            dp[N]%=mod;
        }
    cout << dp[N]<<endl;
  //cout << dp[2] << endl;
 
}

Measured memory_bytes: 4408
#include <iostream>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
using namespace std;
int main() {
	int N;
	cin >> N;
	switch (N) {
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;

	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;

	case 24:
		cout << "Christmas Eve" << endl;
		break;

	case 25:
		cout << "Christmas" << endl;
		break;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 1016
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	string str;
	int q;

	cin >> str;
	cin >> q;

	for (int i = 0; i < q; ++i) {
		string cmd,arg;
		int a,b;
		cin >> cmd >> a >> b;
		if(cmd=="replace"){
			cin >> arg;
			for (int j = 0; j < (b-a+1); ++j) {
				str[a+j] = arg[j];
			}
		}
		if(cmd=="reverse"){
			string tmp = str;
			for (int j = 0; j < (b-a+1); ++j) {
				str[a+j] = tmp[b-j];
			}
		}
		if(cmd=="print"){
			println(str.substr(a,b-a+1));
		}
//		println(str);
	}

	return 0;
}



Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main() {
  ll N,P;
  cin >> N >> P;
  ll tmpP=P;
  if(N==1) cout << P << endl;
  else{
  ll sq=(int)(sqrt((double)P)+1.0);
  vector<ll> a(sq);
  for(int i=2;i<sq;i++){
    if(tmpP==1)break;
    while(tmpP%i==0){
      tmpP=tmpP/i;
      a[i]++;
    }
  }
  ll ans=1;

  rep(i,sq){
    while(a[i]>=N){
      ans=ans*i;
      a[i]=a[i]-N;
    }
  }
  cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 8064