akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=list(input())
N=len(S)
K=INT()

for i in range(N):
    toA=(ord('z')+1-ord(S[i]))%26
    if K>=toA:
        S[i]='a'
        K-=toA

K%=26
S[-1]=chr((ord(S[-1])-97+K)%26+97)
print(''.join(S))


Measured memory_bytes: 4156
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long n;
    cin>>n;
    long long S[200001];
    int i,k;
    long long ans=-1000000001;
    
    for(i=0;i<n;i++)
    {
        cin>>S[i];
    }
    long long minimum=S[0];
    
    
    for(i=1;i<n;i++)
    {
        ans=max(ans,S[i]-minimum);
        minimum=min(minimum,S[i]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4652
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) {return (n==0)?1:10*TEN(n-1);}
template<class T> using V = vector<T>;

int main() {
    int n;
    ll W;
    cin >> n >> W;
    V<ll> w(n), v(n);
    ll cnt[4] = {};
    V<ll> vs[4];
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        cnt[w[i]-w[0]]++;
        vs[w[i]-w[0]].push_back(v[i]);
    }
    sort(begin(vs[0]), end(vs[0]), greater<ll>());
    sort(begin(vs[1]), end(vs[1]), greater<ll>());
    sort(begin(vs[2]), end(vs[2]), greater<ll>());
    sort(begin(vs[3]), end(vs[3]), greater<ll>());
    ll ans = 0;
    for (int a = 0; a <= cnt[0]; a++) {
        for (int b = 0; b <= cnt[1]; b++) {
            for (int c = 0; c <= cnt[2]; c++) {
                for (int d = 0; d <= cnt[3]; d++) {
                    ll wsm = 0;
                    wsm += a * (w[0] + 0);
                    wsm += b * (w[0] + 1);
                    wsm += c * (w[0] + 2);
                    wsm += d * (w[0] + 3);
                    if (W < wsm) continue;
                    ll vsm = 0;
                    for (int i = 0; i < a; i++) {
                        vsm += vs[0][i];
                    }
                    for (int i = 0; i < b; i++) {
                        vsm += vs[1][i];
                    }
                    for (int i = 0; i < c; i++) {
                        vsm += vs[2][i];
                    }
                    for (int i = 0; i < d; i++) {
                        vsm += vs[3][i];
                    }
                    ans = max(ans, vsm);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,time=(map(int,input().split()))
c=[]
t=[]
for i in range(n):
    C,T=map(int,input().split())
    c.append(C)
    t.append(T)
#print(c)
#print(t)
if min(t)>time:
    print("TLE")
else:
    for i in range(len(t)):
        if t[i]>time:
            c[i]=max(c)


    #print(c)
    if len(c)==1:
        print(c[0])
    elif len(c)==2:
        if c[0]>=c[1]:
            print(c[1])
        else:
            print(c[0])
    else:
        print(min(c))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

ll LCM(ll a,ll b){
    ll A=a;
    ll B=b;
    while(a%b!=0){
        ll t=a%b;
        a=b;
        b=t;
    }
    return A*(B/b);
}

ll GCD(ll a,ll b){
    while(a%b!=0){
        ll t=a%b;
        a=b;
        b=t;
    }
    return b;
}

signed main(){
    int N;
    cin>>N;
    ll ans=1;
    while(N--){
        ll a;
        cin>>a;
        ans=LCM(ans,a);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    string ans;
    if(x<1200){
        ans = "ABC";
    }else{
        ans = "ARC";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long a, b;
  cin >> a >> b;
  int k;
  cin >> k;
  set<long long> s;
  for (long long i = a; i < a + k && i <= b; i++)
    s.insert(i);
  for (long long i = b; i > b - k && i >= a; i--)
    s.insert(i);
  auto it = s.begin();
  for (; it != s.end(); it++)
    cout << *it << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
k = Array.new(n, 0)
st = Array.new(n, 0)
m.times {
  s, c = gets.split.map(&:to_i)
  if st[s-1] != 0 && k[s-1] != c
    puts -1
    exit
  end
  if s == 1 and c == 0 and n > 1
    puts -1
    exit
  end
  k[s-1] = c
  st[s-1] = 1
}
if n > 1 && k[0] == 0
  k[0] = 1
end
puts k.join('')


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b;
  cin>>r>>g>>b;
  if(g%2==0){
    if(b%4==0){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }else{
    if(b%4==2){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

bool comp_p(tuple<string, ll, ll> lhs, tuple<string, ll, ll> rhs) {
  if ((get<0>(lhs) != get<0>(rhs)))
    return get<0>(lhs) < get<0>(rhs);
  else
    return get<1>(lhs) > get<1>(rhs);
}

int main() {
  ll N;
  cin >> N;
  vector<tuple<string, ll, ll>> location_and_score(N);
  string loc;
  ll score;
  for (int i = 0; i < N; i++) {
    cin >> loc >> score;
    location_and_score[i] = make_tuple(loc, score, i + 1);
  }
  sort(location_and_score.begin(), location_and_score.end(), comp_p);
  for (int i = 0; i < N; i++) {
    cout << get<2>(location_and_score[i]) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

l = list(int(i) for i in range(1,n+1))
test = []
cnt = 0
for i in itertools.permutations(l,n):
	i = list(i)
	cnt += 1
	if p == i:
		cntp = cnt
	if q == i:
		cntq = cnt

print(abs(cntp - cntq))


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<char>> S(2*N, vector<char>(2*N));
    rep(i,N) {
        rep(j,N) {
            cin >> S[i][j];
            S[i+N][j] = S[i][j+N] = S[i+N][j+N] = S[i][j];
        }
    }

    int cnt = 0;
    rep(k,N) {
        bool ok = true;
        rep(i,N) {
            rep(j,N) {
                if (S[k+i][j] != S[k+j][i]) ok = false;
            }
        }
        if (ok) cnt += (N-k); 
    }
    rep(k,N) {
        if (k == 0) continue;
        bool ok = true;
        rep(i,N) {
            rep(j,N) {
                if (S[i][k+j] != S[j][k+i]) ok = false;
            }
        }
        if (ok) cnt += (N-k); 
    }

    cout << cnt << endl;
}

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

int N;
int A[300010];

signed main(){
	cin>>N;
	REP(i,N*3){
		cin>>A[i];
	}
	sort(A,A+N*3);
	int sum=0;
	int cnt=0;
	for(int i=N*3-2;cnt<N;i-=2){
		sum+=A[i];
		cnt++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 2560
//ABC144_A問題
#include <stdio.h>
int main(int argc, char const *argv[]) {
    int x,y;
    scanf("%d %d",&x,&y);

    if(x<10&&y<10){
        printf("%d", x*y);
    }else{
        printf("-1\n");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    int pos=1,res=0;
    for(int i=0;i<1e6;i++){
        res++;
        pos=a[pos];
        if(pos==2){
            cout<<res<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;

  vector< vector<int> > G(n);
  for(int i=1;i<n;i++){
    int p;
    cin>>p;
    p--;
    G[p].emplace_back(i);
  }

  vector<int> dp(n);
  MFP([&](auto dfs,int v)->void{
        if(G[v].empty()){
          dp[v]=0;
          return;
        }
        vector<int> us;
        for(int u:G[v]){
          dfs(u);
          us.emplace_back(dp[u]);
        }
        sort(us.rbegin(),us.rend());
        int &res=dp[v];
        res=us[0]+1;
        for(int i=0;i<(int)us.size();i++)
          chmax(res,us[i]+i+1);
      })(0);

  cout<<dp[0]<<endl;
  return 0;
}


Measured memory_bytes: 14976
/*Author : Kartik Bansal
 *Date : 07/09/19
*Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define tra(a) for(auto it : a )cout<<it<<" " ;
#define all(v) v.begin() , v.end()
#define vi  vector<int>
#define vll  vector<long long >
#define vpp vector<pair<int , int >>
#define inf INT_MAX
#define minf INT_MIN
#define ss second
#define ff first
int main()
{
       ios::sync_with_stdio(0) ;
       cin.tie(0) ; cout.tie(0) ;
		 
 			  int a ,b ; 
 			  cin>>a>>b ; 
 			  FOR(i , 1e5)
 			  {
 			  		int x = (i+1)*0.08 , y = (i+1) * 0.1 ;
 			  		if(x== a  &&  y== b)
 			  			{
 			  				cout<<i+1 ; 
 			  				return 0 ; 
 			  			}  
 			  }
 			  cout<< -1 ; 

 			    

  return 0 ;
}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
flag = 1
for i in range(n):
    if(li[i] % 2 == 0):
        if((li[i] % 3 == 0) or(li[i] % 5 == 0)):
            #print(li[i])
            #flag=1
            continue
        else:
            #print(li[i])
            flag=0
    


if(flag == 1):
    print('APPROVED')
else:
    print('DENIED')


#これで通ってくれない....

Measured memory_bytes: 3060
num = [x for x in input().split()]
ans = 0
if num[0] == num[1]:
  ans = ans + 1
if num[0] == num[2]:
  ans = ans + 1
if num[1] == num[2]:
  ans = ans + 1

if ans == 1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
size = gets.to_i
d = {}

size.times do
  sp = gets.chomp.split(" ")
  if sp[0] == "insert"
    d[sp[1].to_sym] = nil
  else
    if d.has_key?(sp[1].to_sym)
      puts 'yes'
    else
      puts 'no'
    end
  end
end


Measured memory_bytes: 80068
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int A[100001];
int B[100001];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0;i<n;++i)
		scanf("%d", &A[i]);
	B[1] = abs(A[0]-A[1]);
	for(int i=2;i<n;++i)
		B[i] = min(abs(A[i] - A[i - 1]) + B[i - 1], abs(A[i] - A[i - 2]) + B[i - 2]);
	printf("%d\n", B[n - 1]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int sum=0;
  int arr1[n], arr2[n];
  for(i=0; i<n; i++)
  cin>>arr1[i];
  for(i=0; i<n; i++)
  cin>>arr2[i];
  for(i=0; i<n; i++)
  {
    if(arr1[i]-arr2[i]>0)
    sum+=arr1[i]-arr2[i];
  }
  cout<<sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<string>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)


ll c_ij[10][10] = {0};

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

	for(int i = 1; i <= N; i++){
		
		int waru_kazu = 100000;
		while(waru_kazu >= 1){

			int saizyoui = i / waru_kazu;
			
			if(saizyoui != 0){
				int saikai = i % 10;
				//cout<<"i = "<<i<<endl;
				//cout<<saizyoui<<","<<saikai<<endl;
				c_ij[saizyoui][saikai]++;
				break;
			}
			waru_kazu = waru_kazu / 10;	
		}
	}


	ll ans = 0;

	REP(i,10){
		REP(j,10){
			ans += c_ij[i][j] * c_ij[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;

// 1,1 12 21 156 631


}



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

#define MAX 500000
#define INF 2000000000

int L[MAX/2+2];
int R[MAX/2+2];
int picks=0;

void merge(int A[],int lo,int hi,int mid)
{
    int n1=mid-lo; //??¨??????????????°
    int n2=hi-mid; //??¨??????????????°
    for(int i=0;i<n1;i++) L[i]=A[lo+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1]=R[n2]=INF;
    int i=0,j=0;

    //????§???????
    for(int k=lo;k<hi;k++)
    {
        if(L[i]<=R[j]) A[k]=L[i++];
        else A[k]=R[j++];
        picks++;
    }
    return;
}

void mergeSort(int A[],int lo,int hi)
{
    if(hi-lo>1) //??????????°?????????????????´??????¶???
    {
       //int mid=(hi-lo)/2;
        int mid=(hi+lo)/2;
        mergeSort(A,lo,mid);
        mergeSort(A,mid,hi);
        merge(A,lo,hi,mid);
    }
    return ;
}
int main()
{
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
    mergeSort(A,0,n);
    for(int i=0;i<n;i++)
    {
        cout<<A[i];
        if(i==n-1) cout<<endl;
        else cout<<' ';
    }
    cout<<picks<<endl;
}

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

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

	int N;
	cin >> N;
	int a[N];

	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	
	int mx = -1;
	int mn = 9999;
	
	for (int i = 0; i<N; i++)
	{
		mn = min (mn,a[i]);
		mx = max (mx, a[i]);
	}
	cout << (mx - mn) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> Cells(H, vector<bool>(W, true));
    
    int h, w;
    cin >> h >> w;
    
    for(int i = 0; i < W; i++){
        Cells[h-1][i] = false;
    }

    for(int i = 0; i < H; i++){
        Cells[i][w-1] = false;
    }
    
    int ans = 0;
    for(int i = h; i < H; i++){
        for(int j = w; j < W; j++){
            if(Cells[i][j] == true) ans++;
        }cout << endl;
    }
    
    
    cout << ans << endl;
}


Measured memory_bytes: 3196
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int N = 1012345;
int num[N];

void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) 
			num[j]++;
	}
	int ans = 0;
	for (int i = 1; i < n; i++)
		ans += num[i];
	cout << ans;
}

int32_t main() {
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    if(A[0]) {cout << -1 << endl; exit(0);}
    ll ans = 0;
    rep(i, N-1){
        if(A[i]+1 == A[i+1]) continue;
        elif(A[i] >= A[i+1]) ans += A[i];
        else {cout << -1 << endl; exit(0);}
    }
    ans += A[N-1];
    cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+1;
long long n,m,x,y,z,f[N],l=1,r=1,w,A[N],B[N],C[N],t;
int main()
{
    scanf("%lld %lld %lld",&n,&m,&x);
    printf("%lld %lld %lld\n",x,n,m);
}



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

using namespace std;

int main(){
	int first, second, tgt, tgt_c;

	cin >> tgt;

	for(first=1; first<=9; first++){
		for(second=1; second<=9; second++){
			tgt_c = first * second;
			if(tgt_c == tgt){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int L, R, d;
  int count = 0;
  cin >> L >> R >> d;
  for (int i = L; i <= R; i++)
  {
    if (i % d == 0)
    {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      ll x; 
      cin >> x;
      for(ll i = -200; i<=200; i++){
            int ok = 0;
            for(ll j = -200; j <= 200; j++){
                  if((i*i*i*i*i) - (j*j*j*j*j) == x){
                        cout << i << " " << j;
                        ok = 1;
                        break;
                  }
            }
            if(ok) break;
      }
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;


int main(){  
    string s1;
    cin>>s1;
    if(s1[0] >= 'a' && s1[0] <= 'z'){
    cout << "a" << endl;

//文字が英大文字かどうか判定
    }else if(s1[0] >= 'A' && s1[0] <= 'Z'){
    cout << "A" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class RollingHash:
    def __init__(self, s: str, base=1007, mod=10 ** 9 + 7):
        self.mod = mod
        length = len(s)
        self.pw = [1] * (length + 1)
        self.h = [0] * (length + 1)
        
        v = 0
        for i in range(length):
            self.h[i + 1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(length):
            self.pw[i + 1] = v = v * base % mod
    
    def query(self, left, right):
        return (self.h[right] - self.h[left] * self.pw[right - left]) % self.mod


def solve():
    N = int(rl())
    S = input()
    
    rh = RollingHash(S)
    
    def check(t):
        dist = dict()
        for i in range(N - t + 1):
            h = rh.query(i, i + t)
            if h in dist:
                if t <= i - dist[h]:
                    return True
            else:
                dist[h] = i
        return False
    
    ok, ng = 0, N // 2 + 1
    while 1 < ng - ok:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42352
# x = int(input())
k,n = map(int, input().split())
a = list(map(int, input().split()))
b=[0]*(len(a)-1)
c=[0]*(len(a)-1)
mx =0 
index =0
flag = True
for i in range(len(a)-1):
    if i==0 :
        mae = (k-a[-1])+a[0]
        ushiro = a[1]-a[0]
        if mx < mae:
            mx = mae
            index =i
            flag =True
        elif mx < ushiro:
            mx = ushiro
            index = i
            frag =False
    else:
        mae = a[i]-a[i-1]
        ushiro = a[i+1] - a[i]
        if mx < mae:
            mx = mae
            index =i
            flag =True
        elif mx < ushiro:
            mx = ushiro
            index = i
            frag =False

print(k-mx)

Measured memory_bytes: 78668
from collections import deque

N = 3
N2 = 9

dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
dirc = ['u', 'l', 'd', 'r']

class Puzzle:
    def __init__(self, f=None, space=None, path=None):
        if f is None:
            self.f = []
        else:
            self.f = f
        self.space = space
        self.path = path

    def __lt__(self, p):
        for i in range(N2):
            if self.f[i] == p.f[i]:
                continue
            return self.f[i] > p.f[i]
        return False


def isTarget(p):
    for i in range(N2):
        if p.f[i] != (i + 1):
            return False
    return True


def bfs(s):
    q = deque()
    dic = {}
    s.path = ''
    q.append(s)
    dic[tuple(s.f)] = True

    while len(q) != 0:
        u = q.popleft()
        if isTarget(u):
            return u.path
        sx = u.space // N
        sy = u.space % N
        for r in range(4):
            tx = sx + dx[r]
            ty = sy + dy[r]
            if tx < 0 or ty < 0 or tx >= N or ty >= N:
                continue
            v = Puzzle(u.f[:], u.space, u.path)
            v.f[u.space], v.f[tx * N + ty] = v.f[tx * N + ty], v.f[u.space]
            v.space = tx * N + ty
            key = tuple(v.f)
            if key not in dic:
                dic[key] = True
                v.path += dirc[r]
                q.append(v)

    return 'unsolvable'


if __name__ == '__main__':
    p = Puzzle()
    for i in range(N):
        line = [int(v) for v in input().split()]
        for j in range(N):
            if line[j] == 0:
                line[j] = N2
                p.space = i * N + j
        p.f.extend(line)

    ans = bfs(p)
    print(len(ans))


Measured memory_bytes: 52324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

void func(int n, int m, vector<int>res) {
  if (n == 0) {
    rep(i, res.size()) {
      cout << res[i];
      if (i == res.size() - 1) cout << endl;
      else cout << " ";
    }
    return;
  }

  FORR(i, m, 1) {
    if (i > n) continue;
    res.push_back(i);
    func(n-i, i, res);
    res.pop_back();
  }
}

int main() {
  int n;
  vector<int> res;
  while (cin >> n, n) {
    func(n, n, res);

  }

  
  return 0;
}


Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String str = br.readLine();
			System.out.println(str.replace("Hoshino", "Hoshina"));
		}

	}

}

Measured memory_bytes: 16956
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << (N-2)*180 << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    string s;
    scan(s);

    int n = s.length.to!int;

    string[] a = [""];

    for (int i = 0; i < n; i++) {
        if (s[i] == 'A') {
            a.back ~= 'A';
        }
        else if (s[i] == 'B') {
            if (i < n - 1 && s[i + 1] == 'C') {
                a.back ~= 'B';
                i++;
            }
            else {
                a ~= "";
            }
        }
        else {
            a ~= "";
        }
    }

    debug {
        writeln(a);
    }

    long ans;

    foreach (si ; a) {
        ans += solve(si);
    }

    writeln(ans);
}


long solve(string s) {
    if (s.empty) {
        return 0;
    }

    long ans;
    long ac;

    foreach (ch ; s) {
        if (ch == 'A') {
            ac++;
        }
        else {
            ans += ac;
        }
    }

    return ans;
}
















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

using namespace std;
using ll = long long;

int main() {
    ll N, M;
    cin >> N >> M;

    ll output = 0;
    if (N >= 3 && M >= 3) {
        output = N * M - (N + M + N + M - 4);
    } else if (N == 2 || M == 2) {
        output = 0;
    } else if (N > 1 || M > 1) {
        output = N + M - 1 - 2;
    } else {
        output = 1;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3532
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
static const long long INF = 9999999999999999;

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

	int n_person, n_food;
	cin >> n_person >> n_food;

	vector<int> foods(n_food,0);
	
	FOR(i, 0, n_person) {
		int num_foods;
		cin >> num_foods;

		FOR(j, 0, num_foods) {
			int i_food;
			cin >> i_food;
			foods[i_food - 1]++;
		}
	}

	//cout << "foods:" << endl;
	//FOR(i, 0, n_food) cout << foods[i] << endl;

	int count = 0;
	FOR(i, 0, n_food) {
		if (foods[i] == n_person) count++;
	}

	//cout << "count:" << endl;
	cout << count;

}

Measured memory_bytes: 256
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

int32_t main(){
    int d, t, s;
    cin >> d >> t >> s;
    if( s*t >= d )cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3616
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        Console.WriteLine((a * b) + " " + (2 * (a + b)));
        Console.Read();
    }
}

Measured memory_bytes: 9116
n, a, b = map(int, input().split())
m = int(1e9) + 7
ans = (pow(2, n, m) -1) % m
val = 1
val2 = 1
for i in range(a):
    val = (val * (n - i)) % m
    val2 = (val2 * (i + 1)) % m
ans -= ((val % m) * (pow(val2, m-2, m)))
#print(((val % m) * (pow(val2, m-2, m))))
ans %= m
val = 1
val2 = 1
for i in range(b):
    val = (val * (n - i)) % m
    val2 = (val2 * (i + 1)) % m
ans -= ((val % m) * (pow(val2, m-2, m)))
#print(((val % m) * (pow(val2, m-2, m))))
print(ans % (int(1e9) + 7))

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> ar(N);
  for(int i = 0; i < M; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    ar[x].push_back(y);
  }
  vector<int> dp(N, -1);
  vector<bool> vis(N);
  function<void(int)> dfs = [&](int u) {
    vis[u] = true;
    dp[u] = 0;
    for(auto x : ar[u]) {
      if(dp[x] == -1) dfs(x);
      dp[u] = max(dp[u], 1 + dp[x]);
    }
  };
  for(int i = 0; i < N; ++i) {
    if(!vis[i]) dfs(i);
  }
  cout << *max_element(dp.begin(), dp.end()) << '\n';
  return 0;
}


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

int main()
{
    vector<int> dH = {1, 0, -1, 0};
    vector<int> dW = {0, 1, 0, -1};
    int H, W;
    cin >> H >> W;

    vector<vector<char>> map(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> map[i][j];
        }
    }

    int Hs, Ws;
    int ans = 0;

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (map[i][j] == '#')
                continue;
            vector<vector<int>> list(H, vector<int>(W, -1)); //距離を記録
            queue<pair<int, int>> que;                       //保留用
            list[i][j] = 0;
            que.push(make_pair(i, j));
            while (!que.empty())
            {
                pair<int, int> now = que.front();
                que.pop();

                for (int i = 0; i < 4; i++)
                {
                    int Hs = now.first + dH[i];
                    int Ws = now.second + dW[i];

                    if (Hs == -1 || Hs == H || Ws == -1 || Ws == W) //範囲外
                        continue;
                    if (list[Hs][Ws] != -1 || map[Hs][Ws] == '#') //探索済み
                        continue;
                    list[Hs][Ws] = list[now.first][now.second] + 1;
                    que.push(make_pair(Hs, Ws));
                    ans = max(ans, list[Hs][Ws]);
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; ++i) cin >> s[i] >> t[i];
  string name;
  cin >> name;
  int i;
  for (i = 0; i < n && s[i] != name; ++i);
  int ret = 0;
  for (++i; i < n; ++i) ret += t[i];
  cout << ret << '\n';
  return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
using namespace std;

int main() {
    long long a, b, c, d, e, n;
    cin >> n >> a >> b >> c >> d >> e;
    long long s = min(a, b);
    s = min(s, c);
    s = min(s, d);
    s = min(s, e);
    long long ans = ((n + s - 1) / s) + 4;
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0; i < s.length()-1; i++) {
			char a = s.charAt(i);
			if(a == 'A') {
				char b = s.charAt(i+1);
				if(b == 'C') {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 23636
N = int(input())

if N % 2 == 1:
    print(0)
else:
    beki5 = 1
    sum0 = 0
    while 1:
        beki5 = beki5 * 5
        if beki5 > N:
            break
        else:
            sum0 += N//(beki5*2)
    print(sum0)
a = 0


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

ll n, k, res;

int main ()
{
  scanf("%lld%lld", &n, &k);
  res = n %= k;
  res = min(res, min(n, k - n));
  printf("%lld\n", res);
  return 0;
}


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

using namespace std;

int main()
{
	int n,i,ev=0,c;
	cin>>n;
	for(i=0;i<n;i++)
	  {
	  	cin>>c;
	  	if(c%2==0)
	  	   ++ev;
	  }
         cout<<(long long )(pow(3,n)-pow(2,ev))<<'\n';
         return 0;
}	

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

int main(){
    int N, M, Q;
    vector<vector<int>> ans(510,vector<int>(510,0));

    cin >> N >> M >> Q;
    rep(i, M){
        int L, R; cin >> L >> R; L--; R--;
        ans[L][R]++;
    }

    rep(i, N) rep1(j, N-1) ans[i][j] += ans[i][j-1]; 
    rep(j, N) {for(int i=N-1; i>=0; i--) ans[i][j] += ans[i+1][j];}

    rep(query, Q){
        int p, q; cin >> p >> q; p--; q--;
        cout << ans[p][q] << endl;
    }

}

Measured memory_bytes: 1920
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 505
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,prime[MAX<<1],vst[10005];
void pre(int up)
{
	for(int i=2;;i++)
	{
		if(!vst[i])
		{
			prime[++prime[0]]=i;
			if(prime[0]==up) break;
		}
		for(int j=1;j<=prime[0];j++)
		{
			if(i*prime[j]>10000) break;
			vst[i*prime[j]]=1;
			if(!(i%prime[j])) break;
		}
	}
}
long long gcd(long long a,long long b)
{
	if(a<b) swap(a,b);
	while(b)
	{
		a%=b;
		swap(a,b);
	}
	return a;
}
long long lcm(long long a,long long b)
{
	if(!a||!b) return a|b;
	return a/gcd(a,b)*b;
}
long long a[MAX][MAX];
int main()
{
	n=read();
	if(n==2) return printf("4 7\n23 10"),0;
	pre((n&1)?n*2:n*2-1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!((i+j)&1))
				a[i][j]=1ll*prime[(i+j)/2]*prime[n+(i-j)/2+(n+1)/2];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j)&1)
				a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			printf("%lld ",a[i][j]);
		putchar('\n');
	}
	return 0;
}


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

int main(){

const int MAX_NO=100000;
int m[MAX_NO],f[MAX_NO],r[MAX_NO];
char hyouka[MAX_NO];
int a=0;
int b=0;

for(int i=1;i<2000000000;i++){
b++;
b--;
b++;
b--;
}

for(int i=1;i<MAX_NO;i++){

cin>>m[i]>>f[i]>>r[i];
a++;

if(m[i]==-1 && f[i]==-1 && r[i]==-1){
goto aa;
}

if(m[i]==-1 || f[i]==-1){
hyouka[i]='F';
}

else if((m[i]+f[i])>=80){
hyouka[i]='A';
}
else if((m[i]+f[i])>=65){
hyouka[i]='B';
}

else if((m[i]+f[i])>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])>=30 && r[i]<50){
hyouka[i]='D';
}
else if((m[i]+f[i])>=30 && r[i]>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])<30){
hyouka[i]='F';
}

}

aa:;

for(int i=1;i<a;i++){

cout<<hyouka[i]<<endl;

}

return 0;
}

Measured memory_bytes: 1172
#include <iostream>
using namespace std;
 
int main(){
    //入力を受け取る
    int N, X, T;
    cin >> N >> X >> T;
 
    //たこ焼きを焼く回数を求める
    int times = (N + X - 1) / X;
 
    //答えを求める
    int ans = times * T;
 
    //答えを出力する
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	char a, b;
	cin >> a >> b;
	
	if(a=='H')
		cout << b;
	else
	{
		if(b=='H')
			cout << 'D';
		else
			cout << 'H';
	}
	
	return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define INF (1e9)
#define M 666001
using namespace std;
int P,d[6],c[6]={1,5,10,50,100,500};
int f,ans,sum,z[M];
 
int cal(int x){
  int res=0;
  for(int i=5;i>=0;i--)
    res+=x/c[i],x=x%c[i];
  return res;
}
 
int cal2(int x){
  int res=0;
  for(int i=5;i>=0;i--){
    int p=min(x/c[i],d[i]);
    res+=p;
    if(p)x-=p*c[i];
  }
  if(!x)return res;
  return -1;
}
 
int main(){
  for(int i=0;i<M;i++)
    z[i]=cal(i);
  while(1){
    cin>>P;
    f=sum=0;
    for(int i=0;i<6;i++){
      cin>>d[i],sum+=d[i]*c[i];
      if(d[i])f=1;
    }
    if(!f)break;
    ans=INF;
    for(int i=P;i<=sum;i++){
      int r=cal2(i);
      if(r!=-1)ans=min(ans,r+z[i-P]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5688
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int cnt=0;
    string s;
    cin>>s;
    char pv=s[0];
    for (int i=1; i<s.size(); i++)
    {
        if (pv!=s[i]) { cnt++; pv=s[i]; }
    }
    cout<<cnt<<endl;
    return 0;
}


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

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

using namespace std;

string S;
size_t cur=0;

int val[3];

int mul[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int add[3][3]={{0,1,2},{1,1,2},{2,2,2}};


int formula(){
	if(isdigit(S[cur]))
		return S[cur++]-'0';
	if(isupper(S[cur]))
		return val[S[cur++]-'P'];

	int res=0;
	if(S[cur]=='-'){
		cur++;
		res=2-formula();
	}else{
		if(S[cur]=='(') cur++;
		int a=formula();
		char op=S[cur++];
		int b=formula();
		if(S[cur]==')') cur++;
		if(op=='*')
		res=mul[a][b];
		if(op=='+')
		res=add[a][b];
	}
	return res;
}

int calc(){
	int res=0;
	rep(i,3)rep(j,3)rep(k,3){
		cur=0;
		val[0]=i,val[1]=j,val[2]=k;
		res+=(2==formula());
	}
	return res;
}

int main(void){
	while(cin >> S){
		if(S==".") break;
		cout << calc() << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None


root = None

def insert(key):
    global root
    x = root #Tの根
    y = None #親を設定
    while x is not None:
        y = x
        if key < x.key:
            x = x.left #左の子へ移動
        else:
            x = x.right  #右の子へ移動

    if y is None: #Tが空の場合
        root = Node(key)
    elif key < y.key:
        y.left = Node(key) #keyをyの左の子にする
    else:
        y.right = Node(key) #keyをyの右の子にする

# def find(key):
#     x = root
#     while x and key != x.key:
#         x = x.left if key < x.key else x.right
#     return x is None

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None # result が None ⇒ false

def inorder(node):
    return   inorder(node.left) + " "+ str(node.key) + inorder(node.right) if node else ''
def preorder(node):
    return   " " + str(node.key) + preorder(node.left) + preorder(node.right) if node else ''
input()
for e in sys.stdin:
    if e[0] == "i":
        insert(int(e[7:]))
    elif e[0] == 'f':
        if find(int(e[5:])):
            print("no")
        else:
            print("yes")
        # print(['yes','no'][find(int(e[5:]))])
    else:
        print(inorder(root))
        print(preorder(root))


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

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

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  ll x;
  cin >> x;
  int a = 0;
  int b = 0;
  for (ll i = 0; i < 1000; i++) {
    for (ll j = -1000; j < 1000; j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        //cout << i * i * i * i * i - j * j * j * j * j << endl;
        a = i;
        b = j;
        break;
      }
    }
    if (a && b) break;
  }
  cout << a << ' ' << b << endl;
}


Measured memory_bytes: 3572