akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#define INF 100000000
#define MOD 1000000007
using namespace std;



int main(){
    long long M;
    cin >> M;
    
    long long K;
    cin >> K;
    
    if(K==0){
        cout<<M*M<<endl;
        return 0;
    }
    
    long long ans=0;
    
    for(long long b=K+1; b<=M; b++){
        long long N=M;
        ans+=(b-K)*(N/b);
        N%=b;
        
        if(K<=N){
            ans+=N-K+1;
        }
      
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
r, c = gets.chomp.split.map(&:to_i)
last_line = Array.new(c + 1, 0)

r.times do
  columns = gets.chomp.split.map(&:to_i)
  columns.push(columns.sum)
  puts columns.join(" ")
  (0..c).each do |i|
    last_line[i] += columns[i]
  end
end

puts last_line.join(" ")



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

int main(void){
  int n;
  string s;
  vector<int> arr(2,0);
  cin >> n >> s;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R')arr[0]++;
    else arr[1]++;
  }
  if(arr[0] > arr[1])cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#coding:utf-8
a,b,c,d = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)
def func(start,end,n):
    ans = (end-start+1)//n
    bonus = (end-start+1)%n
    #print (ans,((start // n + 1) * n),start + bonus - 1)
    
    if ((start // n + 1) * n)  <= (start + bonus - 1):
        ans += 1
    #print (ans)
    return ans
cnt_c = func(a,b,c)
cnt_d = func(a,b,d)
cnt_cd = func(a,b,lcm(c,d))
print (b-a-(cnt_c + cnt_d - cnt_cd)+1)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
using namespace std;

signed main()
{
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    int num1 = K / 2, num2 = K - num1;
    cout << num1 * num2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    REP(i,0,k) {
        if (a >= b) b *= 2;
        else c *= 2;
    }
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] stick = new int[w];
        for(int i = 0; i < w; i++){
            stick[i] = i + 1;
        }
        for(int i = 0; i < n; i++){
            String input = sc.next();
            String[] aSt = input.split(",",0);
            int[] a = new int[2];
            a[0] = Integer.parseInt(aSt[0]);
            a[1] = Integer.parseInt(aSt[1]);
            int sw = stick[a[0] - 1];
            stick[a[0] - 1] = stick[a[1] - 1];
            stick[a[1] - 1] = sw;
        }
        for(int i = 0; i < w; i++){
            System.out.println(stick[i]);
        }
        sc.close();
    }
}


Measured memory_bytes: 25828
#                         author:  kagemeka 
#                         created: 2019-11-08 12:38:16(JST)
## internal modules
import sys
# import collections
import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, *a = (int(x) for x in sys.stdin.read().split())

    total_count = 0
    for i in range(n):
        current = a[i]
        count = 0
        for _ in range(math.floor(math.log(10 ** 9, 2)) + 1):
            if current % 2 == 0:
                current //= 2
                count += 1
            else:
                break
        total_count += count
    
    print(total_count)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 4084
from collections import defaultdict as ddict
n, d, x = map(int,raw_input().split(" "))
p = [map(int,raw_input().split(" ")) for i in range(d)]
for i in range(d-1):
	profit = ddict(int)
	for j in range(n):
		tmp = p[i+1][j] - p[i][j]
		if tmp > 0 and p[i][j] <= x and tmp > profit[p[i][j]]:
			profit[p[i][j]] = tmp
	dp = [0 for j in range(x+1)]
	for cost, prof in profit.iteritems():
		for j in range(cost,x+1):
			dp[j] = max(dp[j], dp[j-1], dp[j-cost]+prof)
	x += dp[x]
print x

Measured memory_bytes: 5576
import java.util.*

data class Edge(val to: Int, val dist: Int)

fun main(args : Array<String>) {
  val n = readLine()!!.toInt()
  val edges = Array(n) { mutableListOf<Edge>() }
  repeat(n - 1) {
    var (u, v, w) = readLine()!!.split(' ').map(String::toInt)
    u--
    v--
    w %= 2
    edges[u].add(Edge(v, w))
    edges[v].add(Edge(u, w))
  }
  val d = IntArray(n) { -1 }
  val q = ArrayDeque<Int>()
  d[0] = 0
  q.add(0)
  while (q.isNotEmpty()) {
    val cur = q.remove()
    for (e in edges[cur]) {
      if (d[e.to] != -1) continue
      d[e.to] = d[cur] xor e.dist
      q.add(e.to)
    }
  }
  d.forEach(::println)
}


Measured memory_bytes: 85088
import collections
N, M = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()][::-1] for _ in range(N)]
ng = set()
ans = float('inf')
for m in range(M):
    cnt = collections.defaultdict(int)
    for n in range(N):
        while True:
            if A[n][-1] in ng:
                A[n].pop()
            else:
                cnt[A[n][-1]] += 1
                break
    y = max(cnt, key=lambda x: cnt[x])
    ans = min(ans, cnt[y])
    ng.add(y)
print(ans)
# https://img.atcoder.jp/agc018/editorial.pdf


Measured memory_bytes: 4580
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j,(a,b) in enumerate(AB):
        if i==j: continue
        a,b = a-1,b-1
        if uf.is_same(a,b): continue
        uf.unite(a,b)
    if uf.size(0) != N:
        ans += 1
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    S = S;
    ll N = S.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, INF));
    dp[0][0] = 0;
    dp[0][1] = 1;
    rep(i, N) {
        ll d = S[i] - '0';
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + d);
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (d == 9 ? 1 : d + 1));
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - d - 1);
    }
    cout << dp[N][0] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 55964
n, k = map(int, input().split())
*h, = map(int, input().split())

dp = [float("inf")]*(n+1)
dp[0] = 0

for i in range(1, n):
    if i < k:
        dp[i] = min([dpj+abs(hj-h[i]) for dpj, hj in zip(dp[:i], h[:i])])
    else:
        dp[i] = min([dpj+abs(hj-h[i]) for dpj, hj in zip(dp[i-k:i], h[i-k:i])])

print(dp[n-1])


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

int main() {
  
  string S; cin >> S; int ans = 0;
  
  for (int i = 0; i < S.size() / 2; i++) {
    if (S.at(i) != S.at(S.size() - 1 - i)) ans++;
  }
  
  cout << ans << endl;
  
}

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

int main(){
  int n,m;
  long long k;
  cin >> n >> m >> k;
  long long a[n+1];
  long long b[m+1];
  int counta=0;
  int countb=0;
  long long timea=0;


  for(int i=1;i<=n;i++) {
    cin >> a[i];
  }

  for(int i=1;i<=n;i++){
    if(timea<=k-a[i]){
      timea +=a[i];
      counta =i;
    }
    else break;
  }


  for(int i=1;i<=m;i++) {
    cin >> b[i];
  }

  int j=1;
  long long count = counta;
  long long counti = counta;
  long long ans = counta;
  long long time = timea;
  long long timei = timea;

  while(timei<=k-b[j]&&j<=m){
    timei +=b[j];
    j++;
    counti ++;
  }
  ans = counti;
j=1;
  for(int i=counta;1<=i;--i){
     time -= a[i];
     count --;
     while((time<=k-b[j])&&j<=m){
       time +=b[j];
       j++;
       count ++;
     }
     ans = max(ans,count);
     if(j==m+1) break;
  }


  cout << ans <<endl;


}

Measured memory_bytes: 6704
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n,m;
string ans="";
int a,b,q;
ll x;
ll s[100005];
ll t[100005];
int main(int argc,char const* argv[])
{
  cin >> a >> b >> q;
  s[0]=-1e18,t[0]=-1e18,s[a+1]=1e18,t[b+1]=1e18;
  for(int i=1;i<=a;i++)
    {
      cin >> s[i];
    }
  for(int i=1;i<=b;i++)
    {
      cin >> t[i];
    }
  for(int i=0;i<q;i++)
    {
      ll ans=1e17;
      cin >> x;
      ll rightshine=*upper_bound(s,s+a+2,x);
      ll leftshine=*(upper_bound(s,s+a+2,x)-1);
      ll righttmple=*upper_bound(t,t+b+2,x);
      ll lefttmple=*(upper_bound(t,t+b+2,x)-1);
      ans=min(ans,abs(x-rightshine)+abs(rightshine-righttmple));
      ans=min(ans,abs(x-rightshine)+abs(rightshine-lefttmple));
      ans=min(ans,abs(x-leftshine)+abs(leftshine-righttmple));
      ans=min(ans,abs(x-leftshine)+abs(leftshine-lefttmple));
      ans=min(ans,abs(x-righttmple)+abs(righttmple-rightshine));
      ans=min(ans,abs(x-righttmple)+abs(righttmple-leftshine));
      ans=min(ans,abs(x-lefttmple)+abs(lefttmple-rightshine));
      ans=min(ans,abs(x-lefttmple)+abs(lefttmple-leftshine));
      cout << ans << endl;
    }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2816
/*
Let's play Amidakuji.

In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
	
						[picture]
	
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom.

Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
 */
 
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
 
int main() {
	int w; cin >> w;
	int n; cin >> n;
	int a,b;
	vector<int> ans(w);
	for (int i=0; i<w; i++)
		ans[i] = i+1;
	for (int i=0; i<n; i++) {
		scanf("%d, %d\n", &a, &b);
		swap(ans[a-1], ans[b-1]);
	}
	for (int i=0; i<w; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, mo;
    string s;
    cin >> n >> s >> k;

    mo = s[k - 1];
    for(int i = 0; i < n; i++) {
        if(s[i] != mo) s[i] = '*';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<vector<vector<int>>> a();
    // rep(i, n)
    // {
    //     int ai;
    //     cin >> ai;
    //     rep(j, ai)
    //     {
    //         cin >> a[i][j][0] >> a[i][j][1];
    //     }
    // }
    vector<int> a(5);
    rep(i, 5)
    {
        cin >> a[i];
    }
    int max_a = 0;
    int ans = 0;
    rep(i, 5)
    {
        if (a[i] % 10 != 0)
        {
            ans += a[i] + 10 - (a[i] % 10);

            if (max_a < 10 - (a[i] % 10))
            {
                max_a = 10 - (a[i] % 10);
            }
        }
        else
            ans += a[i];
    }

    ans -= max_a;

    cout << ans << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int n = in(), k = in();
    int num[100000];
    REP(i, n) num[i] = 0;
    REP(i, n){
        int a = in(), b = in();
        num[a - 1] += b;
    }
    int cnt = 0;
    REP(i, 100000){
        if(cnt + num[i] >= k){
            cout << i + 1 << endl;
            return 0;
        }
        else cnt += num[i];
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

template<class T>
bool chmin(T& a,T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    ll cnt1 = 0,cnt2 = 0;
    if(k % 2 == 1){
        for(int i = 1; i <= n; i++){
            if(i % k == 0){
                cnt1++;
            }
        }
    }else{
        for(int i = 1; i <= n; i++){
            if(i % k == 0){
                cnt1++;
            }else if(i % k == k/2){
                cnt2++;
            }
        }
    }
    cout << cnt1 * cnt1 * cnt1 + cnt2 * cnt2 * cnt2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int gcd(int a,int b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int n;long long sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
			{
				sum+=gcd(k,gcd(i,j));
			}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3656
import Control.Applicative
import Data.List

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve n = minimum $ unfoldr f 1
  where
    f i = if i * i > n then Nothing
          else if n `mod` i == 0 then Just (i + n `div` i - 2, i + 1)
               else f (i + 1)


Measured memory_bytes: 4112
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int n;
struct node
{
	int num,id,max;
}a[200005];
bool cmp(node x,node y)
{
	return x.num<y.num;
}
bool cmpp(node x,node y)
{
	 return x.id<y.id;
}
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	   cin>>a[i].num,a[i].id=i;
  sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)
	   if (a[i].num!=a[n].num)
		    a[i].max=a[n].num;
		 else
		    a[i].max=a[n-1].num;
	sort(a+1,a+n+1,cmpp);
	for (int i=1;i<=n;i++)
	   cout<<a[i].max<<endl;

	return 0;
}


Measured memory_bytes: 3968
import scipy.ndimage
import numpy as np

h,w = map(int, raw_input().split())

data = []

for a in range(h):
  q = raw_input()
  q = q.replace(".","1").replace("#","0")
  data.append( map(int,list(q)) )

A = np.array(data)
x = scipy.ndimage.morphology.distance_transform_cdt(A, metric='taxicab')
#print x
print np.max(x)

Measured memory_bytes: 50428
#include <bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
/*#define cin fin
#define cout fout
ifstream cin("input.in");ofstream cout("output.out");*/
int main() 
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long a[3];
    for(long i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
	cout<<abs(a[1]-a[0])+abs(a[2]-a[1]);
}

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

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String s = in.next();
        String s2 = in.next();
        int a = in.nextInt();
        int b = in.nextInt();
        String u = in.next();
        if(u.equals(s)){
            out.println((a-1) + " " + b);
        }
        else{
            out.println(a + " " + (b-1));
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 37068
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	int c = 0;
	while (n--) {
		int x;
		cin >> x;
		c |= (x & 1);
	}
	if (c) {
		cout << "first\n";
	} else {
		cout << "second\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const ll p = 924844033;
 
ll n, k;
ll dp[2005][2005][4];
ll s[2005][2005];
ll tot[2005], tot2[2005];
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;
    dp[0][0][0] = 1;
    s[0][0] = 1;
 
    for (int i = 1; i < 2003; ++i)
        for (int j = 0; j <= i+1; ++j) {
            dp[i][j][0] = (dp[i-1][j][0] + dp[i-1][j][1] + dp[i-1][j][2] + dp[i-1][j][3])%p;
            if (j > 0)
                dp[i][j][1] = (dp[i-1][j-1][0] + dp[i-1][j-1][1])%p;
            if (j > 0)
                dp[i][j][2] = (dp[i-1][j-1][0] + dp[i-1][j-1][2])%p;
            if (j > 1)
                dp[i][j][3] = dp[i-1][j-2][0];
            s[i][j] = (dp[i][j][0] + dp[i][j][1] + dp[i][j][2] + dp[i][j][3])%p;
        }

    tot[0] = 1;
    for (int i = 0; i < k; ++i) {
        int l = (n-1-i)/k;
        memset(tot2, 0, sizeof(tot2));
        for (int q = 0; q < 2005; ++q)
            for (int j = 0; j <= l+1; ++j)
                if (q+j < 2005)
                    tot2[q+j] = (tot2[q+j] + tot[q]*s[l][j])%p;
        for (int j = 0; j < 2005; ++j)
            tot[j] = tot2[j];
    }
    
    ll ans = 0, prod = 1;
    for (int i = n; i >= 0; --i) {
        ans = (ans + prod*tot[i])%p;
        prod = prod*(p-1)%p*(n-i+1)%p;
    }
 
    if (n%2 == 1)
        ans = (p-ans)%p;
 
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r; cin>>r;
    cout<<setp(12);
    cout<<(double)r*2*M_PI<<endl;
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    int n,x,t;cin>>n>>x>>t;
    int num=n/x;
    if(n%x)
        num++;
    cout<<num*t<<endl;
}

Measured memory_bytes: 3640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let mut a: Vec<(i64, usize)> = vec![];

    for i in 0..n{
        a.push((read_as_vec()[0], i));
    }
    a.sort_by_key(|x| -x.0);
    //println!("{:?}", a);

    for i in 0..n{
        if a[0].1 == i{
            println!("{}", a[1].0);
        }else{
            println!("{}", a[0].0);            
        }
    }
}


Measured memory_bytes: 10564
N=int(input())
a=input().split()
for i in range (0,N):
  a[i]=int(a[i])
count=0
for i in range(0,N):
  if a[i]!=i+1:
    count=count+1
if count==2:
  print('YES')
elif count==0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int[] array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k = scan.nextInt();
    
    System.out.println(array[k-1]);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <map>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<double> v(n);

    for(int i = 0; i < n; i++) cin >> v.at(i);

    while(v.size() > 1)
    {
        sort(v.begin(), v.end());
        double ave = (v.at(0) + v.at(1)) / 2.0;
        v.push_back(ave);
        v.erase(v.begin());
        v.erase(v.begin());
    }
    
    printf("%.10f\n", v.at(0));
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		long[] a=sc.La;
		int[][] h=new int[s[1]][];
		Array.Sort(a);
		for(int i = 0;i<s[1];i++) {
			h[i]=sc.Ia;
		}
		Array.Sort(h,(u,v)=>v[1]-u[1]);
		for(int i = 0,j=0;i<s[1];i++) {
			for(;j<s[0]&&h[i][0]>0&&a[j]<h[i][1];j++) {
				a[j]=h[i][1];
				h[i][0]--;
			}
		}
		Console.WriteLine("{0}",a.Sum());
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}


Measured memory_bytes: 30144
n, m = map(int,input().split())
a = list(map(int,input().split()))

i = 0
s = 0
sum = sum(a)

for i in range(n):
    if a[i]/sum >= 1/(4*m):
        s += 1

if s >= m:
    print('Yes')

else:
    print('No')


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> a(w);
    cout << "#";
    for (int i = 0; i < w; i++) cout << "#";
    cout << "#" << endl;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        cout << "#";
        cout << s;
        cout << "#" << endl;
    }
    cout << "#";
    for (int i = 0; i < w; i++) cout << "#";
    cout << "#" << endl;
}


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

int a[10010];

bool linear_search(int key, int  N)
{
	int i = 0;
	a[N] = key;
	while(a[i] != key)
		i++;
	return i != N;
}

int main ()
{
	int n, m, temp, cnt = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];	
	}
	cin >> m;
	
	for(int i = 0; i < m; i++)
	{
		cin >> temp;
		if(linear_search(temp, n))
			cnt++;
	}
	cout << cnt << endl;
	return 0;
} 


Measured memory_bytes: 3092
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

#define SSIZE 1000005

vector<ll>primes;

ll sieve[SSIZE+10];

void precompute()
{
	for(ll i=2;i*i<=SSIZE;i++)
	{
		if(sieve[i]==0)
		{
			for(ll j=2*i;j<=SSIZE;j+=i)
				sieve[j]=1;
		}
	}
	for(ll i=2;i<=SSIZE;i++)
	{
		if(sieve[i]==0)
			primes.eb(i);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	precompute();
	auto it=lower_bound(primes.begin(),primes.end(),n);
	cout<<(*it);
    return 0;
}


//252908XL

Measured memory_bytes: 9336
using System;
using System.Linq;

namespace ALDS1_1_B{
    class Sample{
        static void Main(string[] args){
            int[] nums = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(Gcd(nums[0], nums[1]));
        }
        static int Gcd(int num1, int num2){
            if(num1 < num2) {
                return Gcd(num2, num1);
            }

            while(num2 != 0){
                var remainder = num1 % num2;
                num1 = num2;
                num2 = remainder;
            }
            return num1;
        }
    }
}


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

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

    int n;
    cin >> n;
    if(n==1){
        puts("Hello World");
    }
    else{
        int a, b;
        cin >> a >> b;

        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val str = io.StdIn.readLine().split(' ').map(_.toInt)
    val a = str(0)
    val b = str(1)
    println(if ((a+b)>=10) "error"else (a+b).toString)
  }

  def judge(a: Int, b: Int): String = {
    if (a + b < 10) {
      (a + b).toString
    } else {
      "error"
    }
  }
}


Measured memory_bytes: 25552
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<functional>
#include<vector>
#include<math.h>
using namespace std;

long long int ketasuu(long long int a){
  long long int c=0;
  while(a!=0){
    a /=10;
    c++;
  }
  return c;
}

int main(){
  long long int n;
  cin>>n;
  long long int ans=n;
  for(long long int i=1;i<=sqrt(n);i++){
    if(n%i==0){
      ans=min(ans,max(ketasuu(i),ketasuu(n/i)));
    }
  }
  cout<<ans<<endl;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

ll calc_a2(ll k, ll a, ll b) {
    ll nk = k - a + 1;
    if (k < 0) return 0;

    ll ns = nk / 2;

    ll pub = b - a;
    if (pub <= 0) return 0;
    ll nb = ns * pub;

    ll tb = a + nb + (nk % 2);
    return tb;
}


int main() {
    ll k, a, b;
    cin >> k >> a >> b;

    ll a1 = k + 1;

    ll a2 = calc_a2(k, a, b);


    cout << max(a1, a2) << endl;
}


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

long long int n,a[100100],i,dp[100100];

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	for (i=1;i<n+1;i++) cin>>a[i];
	dp[1]=0;
	dp[2]=abs(a[1]-a[2]);
	if (n>2) for (i=3;i<n+1;i++)
	dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	cout<<dp[n];
}



Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    vector < int > A(N),B(N);
    REP(i,N) cin >> A[i] >> B[i];

    vector < pair < int, int > > ord;
    REP(i,N) ord.push_back(make_pair(B[i], A[i]));

    sort(ord.begin(), ord.end());
    reverse(ord.begin(), ord.end());

    ll p = 1e18;
    REP(i,ord.size()) {
        if (ord[i].second > p) {
            cout << "No" << endl;
            return 0;
        } else {
            p = min(p, (ll)ord[i].first) - ord[i].second;
            if (p < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    auto it=max_element(p.begin(),p.end());
    int index=it-p.begin();
    int sum=0;
    for(int i=0;i<p.size();i++)
    {
        if(i==index){
            sum+=p[i]/2;
        }
        else
        sum+=p[i];
    }
    cout<<sum;
}

Measured memory_bytes: 3588
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int a,b,h;
	cin>>a>>b>>h;
	
	cout<<(a+b)*h/2<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll l, n;
ll x[200000];
ll ord[200001];
ll rev[200001];

int main() {
    cin >> l >> n;
    rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(u,2) {
        vector<P> vec;
        for (int k = 0; k < n; k += max(1LL,n/500)) {
            int st = 0, en = n-1;
            int pos = 0;
            ll tmp = 0;
            int m = n-k;
            if (u == 0) {
                st += k;
                if (k > 0) {
                    pos = x[k-1];
                    tmp += x[k-1];
                }
            } else {
                en -= k;
                if (k > 0) {
                    tmp += l-x[n-k];
                    pos = x[n-k];
                }
            }
            rep(i,m) {
                if (i%2 == u) {
                    int sd = 0;
                    if (x[st] < pos) sd = l-pos+x[st];
                    else sd = x[st] - pos;
                    tmp += sd;
                    pos = x[st++];
                } else {
                    int ed;
                    if (x[en] < pos) ed = pos-x[en];
                    else ed = pos+l-x[en];
                    tmp += ed;
                    pos = x[en--];
                }
            }
            vec.push_back(P(tmp, k));
            if (ans < tmp) ans = tmp;
        }
        sort(vec.begin(), vec.end(), greater<P>());
        for (int v = 0; v < 1; v++) {
            for (int k = max(0,(int)vec[v].second-500); k < min(n,vec[v].second+500); k++) {
                int st = 0, en = n-1;
                int pos = 0;
                ll tmp = 0;
                int m = n-k;
                if (u == 0) {
                    st += k;
                    if (k > 0) {
                        pos = x[k-1];
                        tmp += x[k-1];
                    }
                } else {
                    en -= k;
                    if (k > 0) {
                        tmp += l-x[n-k];
                        pos = x[n-k];
                    }
                }
                rep(i,m) {
                    if (i%2 == u) {
                        int sd = 0;
                        if (x[st] < pos) sd = l-pos+x[st];
                        else sd = x[st] - pos;
                        tmp += sd;
                        pos = x[st++];
                    } else {
                        int ed;
                        if (x[en] < pos) ed = pos-x[en];
                        else ed = pos+l-x[en];
                        tmp += ed;
                        pos = x[en--];
                    }
                }
                if (ans < tmp) ans = tmp;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <fstream>
#define MAXSIZE 100010
#define MAXN 10
#define MAXND MAXN / 10
#define INF 99999999
#define MAXEDGE 1000000
#define MAXVERTEX 510
#define EPS 0.00001
#define PI 3.14159265
#define MOD 1000000009
#define nil NULL
typedef long long ll;
using namespace std;

int main() {
    int n, maxn = -1;
    
    cin >> n;
    if (n < 4) {
        printf("1");
    } else {
        for (int i = 2; i <= sqrt(n); i++) {
            int base = i;
            while (base <= n) {
                maxn = max(maxn, base);
                base *= i;
            }
        }
        cout << maxn;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, q = map(int,input().split())
A = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(q)]

# ACLに伴い0-indexedに直した
class Bit:  # Fenwick Tree と同じ
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, l, r):  # [l,r)の合計を求める
        # 内部的には[l+1,r+1)の合計つまり(rまでの合計-lまでの合計)
        s = 0
        while r > 0:
            s += self.tree[r]
            r -= r & -r
        while l > 0:
            s -= self.tree[l]
            l -= l & -l
        return s
  
    def add(self, i, x):  # i番目にxを足す
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

# Bitの内部状態をindex順に出力
def print_bit(B):
    n = B.size
    ANS = []
    for i in range(n):
        ANS.append(B.sum(i, i+1))
    print(*ANS)

B = Bit(n)
for i in range(n):
    B.add(i, A[i])

for i in range(q):
    if C[i][0] == 0:
        B.add(C[i][1], C[i][2])
    else:
        print(B.sum(C[i][1], C[i][2]))

Measured memory_bytes: 175888
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;
const int MOD = 1e9 + 7;

int n;
ll k;
int sol;

mat operator *(const mat &a, const mat &b){
    mat ret(a[0].size(), vector<int>(b[0].size(), 0));
    for (int i = 0; i < a[0].size(); i++)
        for (int j = 0; j < b[0].size() ;j++)
            for (int l = 0; l < min(a[0].size(), b[0].size()); l++)
                ret[i][j] = (ret[i][j]%MOD + ((ll)a[l][j]%MOD * b[i][l]%MOD)%MOD)%MOD;
    return ret;
}

int main(){

    cin >> n >> k;
    mat A(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> A[i][j];

    mat T = A;
    k--;
    while (k > 0){
        if (k & 1) A = A * T;
        k /= 2;
        T = T*T;
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            sol = (sol%MOD + A[i][j]%MOD)%MOD;

    cout << sol;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    string c;
    cin >> N >> c;
    set<int> red, white;
    int wc = 0;
    int rc = 0;

    rep(i, c.size()) {
        if (c[i] == 'R') {
            ++rc;
            red.insert(i);
        } else {
            ++wc;
            white.insert(i);
        }
    }

    if (rc == 0 || wc == 0) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    int leftWhite = *(white.begin());
    int rightRed = *(red.rbegin());
    while (leftWhite < rightRed) {
        ++ans;
        white.erase(leftWhite);
        red.erase(rightRed);
        white.insert(rightRed);
        red.insert(leftWhite);
        leftWhite = *(white.begin());
        rightRed = *(red.rbegin());
    }
    cout << ans << endl;

    return 0;
}


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

int main(void)
{
    using namespace std;

    while (true) {
        string n;
        cin >> n;
        if (n == "-") {
            break;
        }

        int m;
        cin >> m;
        for (int i = 0; i < m; i++) {
            int num;
            cin >> num;
            n = n.insert(n.size() ,n.substr(0,num)).erase(0, num);
        }
        cout << n << "\n";
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
const int maxn=500005;
int n,a[maxn],dp[maxn];
char s[maxn];
int main()
{
    scanf("%d%s",&n,s+1);
    for (int i=1;i<=n;++i) {
        a[i]=(s[i]=='0')?i:a[i-1];
        dp[i]=dp[i-1];
        if (s[i]=='1') {
            if (i>2&&s[i-1]=='0'&&s[i-2]=='1') {
                dp[i]=max(dp[i],dp[a[i-2]]+i-2-a[i-2]);
                dp[i]=max(dp[i],dp[a[i-2]+1]+i-3-a[i-2]);
            } else if (a[i]>1&&s[a[i]-1]=='1')
                dp[i]=max(dp[i],dp[a[i]-2]+i-a[i]);
        }
    }
    return cout<<dp[n]<<endl,0;
}


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

int main(){
  ll h, w;
  cin >> h >> w;
  if (h == 1 ||  w == 1) cout << 1 << endl;
  else cout << (h * w + 1) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256