akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
from math import factorial

def count_combinations(n, r):
    return factorial(n) // (factorial(r) * factorial(n-r))

n = int(input())
s = []
for _ in range(n):
    s.append(input())

t = [''.join(sorted(str)) for str in s]
c = Counter(t)
ll = [i for _, i in c.items() if i > 1]
cnt = 0
for i in ll:
    cnt += count_combinations(i, 2)

print(cnt)


Measured memory_bytes: 26912
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    T = list(map(int, input().split()))
    total = sum(T)
    M = int(input())

    for _ in range(M):
        P, X = map(int, input().split())
        print(total - T[P-1] + X)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string sa,sb;
int f[3030][3030],pos[3030][3030][2];
void output(int i,int j)
{
	if(!i || !j)
		return ;
	output(pos[i][j][0],pos[i][j][1]);
	if(sa[i-1]==sb[j-1])
		cout<<sa[i-1];
	return ;	
}
int main()
{
	cin>>sa>>sb;
	for(int i=1;i<=sa.size();i++)
	{
		for(int j=1;j<=sb.size();j++)
		{
			if(sa[i-1]==sb[j-1])
			{
				f[i][j]=f[i-1][j-1]+1;
				pos[i][j][0]=i-1,pos[i][j][1]=j-1;
			}
			else
			{
				f[i][j]=max(f[i-1][j],f[i][j-1]);
				if(f[i-1][j]>f[i][j-1])
					pos[i][j][0]=i-1,pos[i][j][1]=j;
				else
					pos[i][j][0]=i,pos[i][j][1]=j-1;
			}
		}
	}
	output(sa.size(),sb.size());
	cout<<endl;
	return 0;
}

Measured memory_bytes: 110264
N = int(input())
def summ(X):
  a = X//10000
  b = (X - a*10000)//1000
  c = (X - a*10000 - b*1000)//100
  d = (X - a*10000 - b*1000 - c*100)//10
  e = X - a*10000 - b*1000 - c*100 - d*10
  return a+b+c+d+e
X = []
for A in range(1,N):
  B = N-A
  C = summ(A) + summ(B)
  X.append(C)
print(min(X))

Measured memory_bytes: 3864
#include<iostream>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  int C=A+B;
  if(A%3!=0 && B%3!=0 && C%3!=0)
    {
      cout<<"Impossible"<<endl;
    }else{
    cout<<"Possible"<<endl;
  }
  return 0;
}


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

int n, ga, gb, gc;
vector<int> l(8);

int dfs(int a, int b, int c, int ct, int m)
{
    if (ct == n)
    {
        if (a && b && c)
            return abs(a - ga) + abs(b - gb) + abs(c - gc) + (m - 3) * 10;
        else
            return 100000000;
    }
    int r;
    r = min(dfs(a + l.at(ct), b, c, ct + 1, m + 1), dfs(a, b + l.at(ct), c, ct + 1, m + 1));
    r = min(r, dfs(a, b, c + l.at(ct), ct + 1, m + 1));
    r = min(r, dfs(a, b, c, ct + 1, m));
    return r;
}

int main()
{
    cin >> n >> ga >> gb >> gc;
    for (int i = 0; i < n; i++)
        cin >> l.at(i);
    cout << dfs(0, 0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> A(N+1);
    for (int i = 1; i <= N; i++){
        cin >> A[i];
    }

    vector<long long> ans(N+1);
    long long back1 = A[1], back2 = A[2]-A[1], front1 = A[N], front2 = A[N-1]-A[N];

    ans[2] += back1;
    ans[3] += back2;
    bool even = true; // iが偶数の時がtrue
    for (int i = 4; i <= N; i++){
        if (even){
            back1 = back1 - A[i-2] + A[i-1];
            ans[i] += back1;
            even = false;
        } else {
            back2 = back2 - A[i-2] + A[i-1];
            ans[i] += back2;
            even = true;
        }
    }

    ans[N] += front1;
    ans[N-1] += front2;

    even = false; // iが偶数の時がtrue
    for (int i = N-2; i >= 1; i--){
        if (even){
            front2 = front2 - A[i+1] + A[i];
            ans[i] += front2;
            even = false;
        } else {
            front1 = front1 - A[i+1] + A[i];
            ans[i] += front1;
            even = true;
        }
    }

    for (int i = 1; i <= N; i++){
        cout << ans[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 2432
module Main where

import Control.Applicative
import Numeric

main :: IO()
main = loop

loop :: IO()
loop =do
  {[h, w] <- getInts
  ; if h == 0 && w == 0 then done
    else do
     {putStrLn $ unlines $ frame h w
     ; loop
     }
  }
  
tedge :: Int -> String
tedge n = replicate n '#'

mbody :: Int -> String
mbody n = case n of
          0 -> []
          1 -> "#"
          _ -> "#" ++ replicate (n-2) '.' ++ "#"

frame :: Int -> Int -> [String]
frame h w  = case h of
          0 -> []
          1 -> [tedge w]
          _ -> [tedge w] ++ replicate(h-2) (mbody w) ++ [tedge w]
          

--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords . map show

getDoubles :: IO[Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""

done :: IO()
done = return ()



Measured memory_bytes: 4240
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut vec: Vec<i32> = line.split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect();
    vec.sort();
    println!("{} {} {}", vec[0], vec[1], vec[2]);
}


Measured memory_bytes: 5036
#include<stdio.h>
int main(void){
  int s,d,i;
  
  while(scanf("%d",&d)!=EOF){
    s=0;
    for(i=1;i*d<600;i++){
      s+=i*d*i*d*d;
    }
    printf("%d\n",s);
  }
  return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  ll M = input();
  
  ll sum = 0;
  for(int i=0;i<M;i++){
    sum += input();
  }
  ll ret = max(N-sum, (ll)-1);
  output(ret);

  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n), sum(n);
	ll st = 0;
	//multiset<int>sum;
	rep(i, n)
	{
		cin >> a[i];
		st += a[i];
		sum[i] = st;
		//sum.insert(st);
	}
	int cnt = 1;
	ll ans = 0;
	sort(all(sum));
	rep(i, n-1)
	{
		/*if(sum[i]==0){
			ans++;
		}*/
		if (sum[i] == sum[i + 1])
		{
			cnt++;
		}
		else if (cnt > 1)
		{
			if(sum[i]==0){
				cnt++;
			}
			ans += (ll)(cnt - 1) * cnt / 2;
			cnt = 1;
		}
		else
		{
			if (sum[i] == 0)
			{
				ans += cnt;
			}
			cnt = 1;
		}
		/*cout<<cnt<<" ";
		cout<<ans<<" ";
		cout << sum[i] << endl;*/
	}
	if (cnt > 1)
	{
		if(sum[n-1]==0){
				cnt++;
		}
		ans += (ll)(cnt - 1) * cnt / 2;
		//cnt = 1;
	}
	if(cnt==1&&sum[n-1]==0){
		ans++;
	}
	cout << ans << endl;
	//cout<<cnt<<endl;
}


Measured memory_bytes: 3328
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

----------
-- main --
----------
main :: IO ()
main = specialTrains

specialTrains :: IO ()
specialTrains = do
  [a, b, c, d] :: [Int] <- getLineSpc
  let ab = a + b
      cd = c + d
  if ab > cd
    then
    putStrLn "Left"
    else if ab == cd
    then
    putStrLn "Balanced"
    else
    putStrLn "Right"

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define INF             1e9
#define INFL            8e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define READ            freopen("D:\\moidda CPP\\alu.txt", "r", stdin)
#define WRITE           freopen("D:\\moidda CPP\\vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pff;

const int MAX = 1e3 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAX_VALUE = 200 + 2;
const int MOD = 1e9 + 7;
const double PY = acos(-1.0);
const double EPS = 1E-9;

#define int long long

int32_t main()
{
//#ifndef ONLINE_JUDGE
//    READ;
//    WRITE;
//#endif

    FASTIO;

    int n;
    cin >> n;
    vector<int> a(n+1);
    ll sum = 0;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        int mn = min(a[i-1], a[i]);
        a[i] -= mn;
        a[i-1] -= mn;
        sum += mn;
        mn = a[i]/2;
        sum += mn;
        a[i] -= mn*2;
    }
    cout << sum;

    return 0;
}


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

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

  bool contain7= false;
  while(N > 0){
    int tail= N % 10;
    if(tail==7){
      contain7= true;
      break;
    }

    N= (N- tail)/10;
  }

  string ans= (contain7) ? "Yes" : "No";
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
T = [*?a..?z, ?., ??, ?!, ?\ ].each_slice(5).to_a.transpose.freeze
$<.each do |l|
  l.chomp!
  unless l.size.even? && /\A[1-9]*\z/ =~ l
    puts 'NA'
    next
  end
  f, rs = true, []
  l.each_char.each_slice(2) do |as|
    i, j = as.map {|a| a.to_i - 1 }
    if i < 6 && j < 5
      rs << T[j][i]
    else
      f = false
      break
    end
  end
  puts f ? rs.join : 'NA'
end

Measured memory_bytes: 8712
#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(0);
	ios::sync_with_stdio(false);

	ll n, k;
	cin >> n >> k;

	vector<ll> h(n);
	rep(i, n) cin >> h[i];

	sort(h.begin(), h.end(), greater<ll>());

	ll ans = 0;
	for(int i = min(n, k); i < n; i++){
		ans += h[i];
	}

	cout << ans << endl;
}


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

  int main(){

  int W, H;
  cin>>W>>H;
 
  int x, y, r;
  cin>>x>>y>>r;

  if( x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H ) 
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main() {
	int k;
	string s;
	set<string> a;

	cin >> s >> k;
	for(int i = 0; i < s.size(); i++)
		for(int j = 1; j <= k && i + j <= s.size(); j++)
			a.insert(s.substr(i, j));

	auto it = a.begin();
	advance(it, k - 1);
	cout << *it << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {


  int R[MAX], n;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}

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

int main(){
	int n;
	cin>>n;
	long long ret=1;
	bool stop = false;
	bool zero=false;
	const long int d=1e18;
	for(int i=0;i<n;i++){
		long int x; cin>>x;
		if(x==0){
			zero=true;
			break;
		}
		if(ret>(d/x)){
			stop=true;
		}
	//	cout<<ret<<" "<<x<<endl;
		ret = ret * x;
	}
	if(zero){
		cout<<0<<endl;
	}
	else if(stop) cout<<-1<<endl;
	else cout<<ret<<endl;
	
	return 0;
	
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N;cin >> N;
	vector<ll>a(N), b(N), c(N);
	ll k = 0;
	ll itra = 0, itrb = 0;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
	}
	b[0] = a[0];c[N - 1] = a[N - 1];
	for (int i = 1;i < N-1;i++) {
		b[i] = b[i - 1] + a[i];
		c[N - 1 - i] = c[N - i] + a[N - i-1];
	}
	b[N - 1] = 999999999;c[0] = 99999999999;
	ll ans = abs(b[0] - c[1]);
	for (int i = 1;i < N - 1;i++) {
		if (ans > abs(b[i] - c[i + 1]))ans = abs(b[i] - c[i + 1]);
	}
	cout << ans << endl;
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int a[m];
  for (int i = 0; i < m; i++) cin >> a[i];
  
  int l = 0;
  for (int i = x; i >= 0; i--) {
    for (int j : a) {
      if (i == j) l++;
    }
  }
  
  int r = 0;
  for (int i = x; i <= n; i++) {
    for (int j : a) {
      if (i == j) r++;
    }
  }
  
  cout << min(l, r) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include <climits>
using namespace std;
int A, B, C;
int main() {
    cin >> A >> B >> C;
    if((A==5&&B==7&&C==5)||(A==7&&B==5&&C==5)||(A==5&&B==5&&C==7))cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, k = ns()
    pos = []
    for _ in range(n):
        x, y = ns()
        pos.append((x, y))

    ans = INF
    for tmp in itertools.combinations_with_replacement(pos, 4):
        xl = max(tmp, key=lambda t: t[0])[0]
        xs = min(tmp, key=lambda t: t[0])[0]
        yl = max(tmp, key=lambda t: t[1])[1]
        ys = min(tmp, key=lambda t: t[1])[1]

        cnt = 0
        for xi, yi in pos:
            if xs <= xi <= xl and ys <= yi <= yl:
                cnt += 1
        if cnt >= k:
            ans = min(ans, (xl - xs) * (yl - ys))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74512
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int kaijo(int x)
{
    int ans = 1;
    rep(i, 1, x + 1) ans *= i;
    return ans;
}

string n_shin(int x, int n)
{
    string s;
    while (x > 0)
    {
        s += to_string(x % n + 1);
        x /= n;
    }
    while (s.size() < n)
    {
        s += '0';
    }
    s.reserve();
    //cout << s << endl;
    return s;
}

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    string s[n];
    rep(i, 0, n)
    {
        cin >> s[i];
        m[s[i]]++;
    }
    int ans = 0;
    for (auto x : m)
    {
        ans = max(ans, x.second);
    }
    for (auto x : m)
    {
        if (ans == x.second)
            cout << x.first << endl;
    }
}



Measured memory_bytes: 26752
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI = 3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cinll(a);
	cinll(b);
	cinll(k);

	ll aux = a;
	a = max(0LL, a - k);
	k -= min(aux, k);
	b = max(0LL, b - k);

	cout << a << " " << b << endl;

}

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



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

struct P
{
    long long x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[1111115];
int l[1];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=998244353,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
//priority_queue<P> q;
queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[222253];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}



int main()
{
    scanf("%lld %lld",&x,&y);
    z=y;
    if(x==1)
    {
        printf("%lld",y);
        return 0;
    }
    for(long long i=2;i*i<=z;i++)
    {
        for(;y%i==0;y/=i,o[i]++);
    }
    if(y<1000000) o[y]++;
    long long p=1;
    for(long long i=2;i*i<=z;i++)
    {
        for(;o[i]>=x;o[i]-=x,p*=i);
    }
    printf("%lld",p);
}





Measured memory_bytes: 2304
#Problm A

X = int(input())

if X >= 400 and X <= 599:
    print(8)
elif X >= 600 and X <= 799:
    print(7)
elif X >= 800 and X <= 999:
    print(6)
elif X >= 1000 and X <= 1199:
    print(5)
elif X >= 1200 and X <= 1399:
    print(4)
elif X >= 1400 and X <= 1599:
    print(3)
elif X >= 1600 and X <= 1799:
    print(2)
elif X >= 1800 and X <= 1999:
    print(1)

Measured memory_bytes: 61660
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<list>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int n;
    cin >> n;
    int a[n];
    int minus = 0;
    ll sum = 0;
    int minn = inf;
    rep(i, n) {
        cin >> a[i];
        if (a[i] < 0) minus++;
        sum += (ll)abs(a[i]);
        minn = min(minn, abs(a[i]));
    }
    //cout << sum << " " << minus << " " << minn << endl;
    if (minus % 2 == 0) {
        cout << sum << endl;
        return 0;
    } else {
        cout << sum - (ll)2 * minn << endl;
    }
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var a = S.Select(c => (int)(c - '0')).ToArray();
		int mi = 999999999;
		int N = a.Length;
		for(int i=0;i<N;i++){
			int j = i + 1;
			int k = j + 1;
			if(k >= N) continue;
			int diff = Math.Abs(a[i] * 100 + a[j] * 10 + a[k] - 753);
			if(diff < mi){
				mi = diff;
			}
		}
		Console.WriteLine(mi);
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11348
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        if(m>=0)System.out.println(n*(n-1)/2+m*(n-1));
        else if(n+m>0)System.out.println(n*(n-1)/2+m*n);
        else System.out.println(n*(n-1)/2+m*n-(n+m-1));
    }
}


Measured memory_bytes: 21716
/* 
    ex2_2:Plumber2
    Acro
*/
#include <stdio.h> 

int main(void){
    int num, hp, i, j;
    scanf("%d %d", &num, &hp);
    int depth[num], coins[num], dp[num+1][hp+1];
    for (i = 0; i < num; i++)
    {
        scanf("%d %d", &coins[i], &depth[i]);
    }
    for ( j = 0; j <= hp; j++)
    {
        dp[0][j] = 0;
    }
    for ( i = 0; i < num; i++)
    {
        for ( j = 0; j <= hp; j++)
        {
            if (j < depth[i])
            {
                dp[i+1][j] = dp[i][j];
            }
            else
            {
                dp[i+1][j] = dp[i][j-depth[i]] + coins[i];
                if (dp[i+1][j] < dp[i][j])
                {
                    dp[i+1][j] = dp[i][j];
                }
                
            }
        }
    }
    printf("%d\n",dp[num][hp]);
    return 0;
}


Measured memory_bytes: 5680
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        
        string sdash = Console.ReadLine();
        string t = Console.ReadLine();
        bool ok=true;
        var list = new List<string>();
        
        for(int i=0;i<sdash.Length - t.Length +1 ;i++)
        {
            string test = sdash.Substring(i,t.Length);
            ok=true;
            for(int j=0;j<t.Length;j++)
            {
                if(test[j]=='?')
                    continue;
                if(test[j]!=t[j])
                {
                    ok=false;
                    break;
                }
            }
            
            if(ok)
                list.Add(sdash.Substring(0,i) + t + sdash.Substring(i+t.Length));
        }
        
        
        if(list.Count==0){
            Console.WriteLine("UNRESTORABLE");
            return;
        }
        
        list.Sort();
        Console.WriteLine(list[0].Replace('?','a'));
    }
}


Measured memory_bytes: 11488
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, i = 0;
    
    cin  >> a >> b >> c;
    
    while(a <= b)
    {
        if(c % a == 0)
            i++;
        
        a++;
    }
    
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 3132
#include"bits/stdc++.h"
using namespace std;
int n;
string A;
bool open[(int)2e5+5];
int main(){
  cin>>n>>A;
  long long ans=1;
  int x = 0;
  const long long MOD=1e9+7;
  if(A[0]!='B') {cout<<0; return 0;}
  for(int i=0;i<2*n;++i){
    if(i==0||( (A[i]!=A[i-1]&&open[i-1]) || (A[i]==A[i-1]&&!open[i-1]) )){
      open[i]=1;++x;
    }else{
      ans*=x;
      ans%=MOD;
      --x;
    }
  }
  if(x) {cout<<0; return 0;}
  for(int i=1;i<=n;++i) ans*=i, ans%=MOD;
  cout << ans << '\n';
}


Measured memory_bytes: 772
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

int main() {
    ll a=1, b=1;
    int n; cin>>n;
    while(n--) {
        ll x, y;
        cin>>x>>y;
        
        ll c1 = (a + x - 1) / x;
        ll c2 = (b + y - 1) / y;
        ll c = max(c1, c2);
        a = x * c;
        b = y * c;
    }
    cout<<a+b<<endl;
}

Measured memory_bytes: 256
def bra(st):
    cc = 0
    res = st
    for le in st:
        if le == "(":
            cc += 1
        elif le == ")":
            cc -= 1
            if cc < 0:
                res = "(" + res
                cc = 0
    if cc == 0:
        return res
    else:
        res += ")" * cc
        return res

N = int(input())
S = input()
print(bra(S))

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    cout << max(0LL,n-2*m) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    while(n) {
        if (n%10 == 7) {
            puts("Yes");
            return 0;
        }
        n /= 10;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3640
N,M=map(int, input().split())
N_str = []
M_str = []
for i in range(N):
  n=str(input())
  N_str.append(n)
for i in range(M):
  m=str(input())
  M_str.append(m)

equal = False
  
for i in range(N-M+1):
  for k in range(N-M+1):
    each_equal = True
    for l in range(M):
      each_equal = each_equal and (N_str[i+l][k:k+M] == M_str[l])
    equal = equal or each_equal

print(["No","Yes"][equal])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

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

int main() {
  string o, e; cin >> o >> e;
  REP(i, e.size()) cout << o[i] << e[i];
  if (o.size() != e.size()) cout << o[o.size()-1];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
//#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
long double N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	long double A, B, C, K, res = 0;
	cin >> N >> K;
	vector<long double>vec(N);
	if (N >= K) {
		res += (N - K) / N;
	}
	if (N >= K) {
		C = K;
	}
	else {
		C = N;
	}
	for (int i = 1; i <= C;i++) {
		A = 1 / N;
		B = i;
		while (1) {
			if (B >= K) {
				break;
			}
			A /= 2;
			B *= 2;
		}
		res += A;
	}
	cout <<std::fixed<< setprecision(9) << res << endl;
}


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

int main(){
    int r, D;
    int x[11];
    
    cin >> r >> D >> x[0];
    
    for (int i = 0; i < 10; i++){
        cout << r * x[i] - D << endl;
        x [i + 1] = r * x[i] - D;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;

const int N=300005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}

int l,r,n,a[N];
ll ans=0;

int main(){
	scanf("%d",&n);n*=3;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	l=1,r=n;
	for(int i=1;i<=n/3;i++){
		ans+=a[r-1];
		l++;r-=2;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1408
mod = 10 ** 9 + 7

N, *X = map(int, open(0).read().split())

s = 0
ans = 1
for x in X:
    if x < 2 * s + 1:
        ans *= (s + 1)
    else:
        s += 1
        ans *= s
    ans %= mod

print(ans)

Measured memory_bytes: 14028
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x;
  cin >> x;
  int last = 1;
  int ans = 1;

  for(int i = 1;i < x;i++)
  {
    for(int j = 2;j <= 10;j++)
    {
      if(pow(i,j) > x)
      {
        break;
      }
      else
      {
        last = pow(i,j);
      }
    }
    ans = max(ans,last);
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  int n=s.size();
  bool ans=1;
  for(int i=0;i<n/2;i++){
    int g=n-i-1;
    if(s[i]!=s[g])ans=0;
  }
    int d=n/2-1;
  for(int i=0;i<=d/2;i++){
    int g=d-i;
    if(s[i]!=s[g])ans=0;
  }
  d+=2;
  for(int i=d;i<=(n-1+d)/2;i++){
    int g=n-1-i;
    if(s[i]!=s[g])ans=0;
  }
  if(ans){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

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

H = list(map(int, input().split()))

ans = 0
count = 0

for i in range(1,N):
    if H[i-1] >= H[i]:
        count += 1
    else:
        if count > ans:
            ans = count
        count = 0

if count > ans:
    ans = count

print(ans)

Measured memory_bytes: 15020
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#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 ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


int main(void){
    int n, m;
    cin >> n >> m;
    int a[50][50], b[50][50];
    REP(i, n) {
        string s;
        cin >> s;
        REP(j, n) {
            a[i][j] = (s[j]=='.') ? 0 : 1;
        }
    }
    REP(i, m) {
        string s;
        cin >> s;
        REP(j, m) {
            b[i][j] = (s[j]=='.') ? 0 : 1;
        }
    }
    
    REP(i, n-m+1) {
        REP(j, n-m+1) {
            bool same = true;
            REP(x, m) {
                REP(y, m) {
                    //cout << a[i+x][j+y] << "," << b[x][y] << endl;
                    if(a[i+x][j+y] != b[x][y]) {
                        same = false;
                        break;
                    }
                }
                if(!same) break;
            }
            if(same) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll W,a,b;
  cin>>W>>a>>b;
if(abs(b-a)<=W) {
cout<<0<<endl;
return 0;
}
  if(a<b) {
cout<<b-a-W<<endl;
  }
  else {
cout<<a-b-W<<endl;
  }
}

  
  
  
  


Measured memory_bytes: 3556
def resolve():
    s = input()
    count = 0
    i = 0
    while i < len(s):
        if i+1 == len(s) or s[i] != s[i+1] :
            count += 1
            i += 1
        elif i + 3 <= len(s):
            count += 2
            i += 3
        else:
            count += 1
            i += 3
    print(count)
resolve()

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
long long n,m,f[20][20][20][20],a[25];
long long dfs(int l,int r,int x,int y)
{
	if(r-l<=1)return 0;
	long long ans=1e18;
	for(int i=l+1;i<=r-1;i++)
	ans=min(ans,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
	return ans; 
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<a[1]+a[n]+dfs(1,n,1,1)<<endl;
 } 

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

const int maxN = 105;

int n;
char s[maxN + 1];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);

	if(n & 1) { puts("No"); return 0; }

	for(int i = 1; i <= n; i += 2)
		if(s[i] != 'h' || s[i + 1] != 'i') { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e : a)cin >> e;
    vector<ll> dp(n+1);
    ll sum = a[0]; 
    for(int i = 2 ; i <= n ; i++){
        if(i % 2 == 0) {
            dp[i] = max(a[i-1] + dp[i-2], sum);
        } 
        else {
            dp[i] = max(a[i-1] + dp[i-2], dp[i-1]);
            sum += a[i-1];
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 6336
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}
	sort.Ints(a)
	println(abs(a[len(a)-1] - a[0]))
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for (int i = 0; i < n; i++) {
			String r = sc.next();
			if ("AC".equals(r)) {
				ac = ac+1;
			} else if ("WA".equals(r)) {
				wa = wa+1;
			} else if ("TLE".equals(r)) {
				tle = tle+1;
			} else if ("RE".equals(r)) {
				re = re+1;
			}
		}
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
		sc.close();
	}
}

Measured memory_bytes: 58624