akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
-- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Int
getIntTuple = (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector

main = do
  s <- getLine
  q <- getInt
  qq <- V.replicateM q $ getLine
  putStrLn . ans $ solve qq s

ans (b,s,first,end) = if b then sFinal  else reverse sFinal
  where
    sFinal = first ++ s ++ (reverse end)

solve qq s = V.foldl' check (True, s, [], []) qq
  where
    check (b,s',first, end) x
      | length x == 1 = operateT1 (b,s', first, end)
      | otherwise = operateT2 (b,s', first, end) (x !! 2) (x !! 4)


operateT1 (b,s,first,end) = (not b,s,first,end)

operateT2 :: (Bool,String,String,String) -> Char -> Char -> (Bool, String, String, String)
operateT2 (b,s,first,end) f c  = case f of '1' -> if b then operateF1 else operateF2
                                           '2' -> if b then operateF2 else operateF1
                                           _ -> undefined
  where
    -- operateF1 = (b, c `BS.cons` s)
    operateF1 = (b, s, c:first, end)
    -- operateF2 = (b, s `BS.snoc` c)
    operateF2 = (b, s, first, c:end)


Measured memory_bytes: 100988
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#define MAXN 500

int s[MAXN + 1][MAXN + 1];

int main() {
    long long n;
    std::cin >> n;
    int k = 1;
    while (k * (k - 1) / 2 < n)
        k++;
    if (n != k * (k - 1) / 2)
        std::cout << "No";
    else {
        std::cout << "Yes\n";
        std::cout << k << "\n";
        int i = 1;
        int j = 1;
        for (int t = 1; t <= n; t++) {
            s[i][j] = t;
            if (i + 1 <= k - 1)
                i++;
            else {
                j++;
                i = j;
            }
        }
        i = 1;
        j = 2;
        for (int t = 1; t <= n; t++) {
            s[i][j] = t;
            if (j + 1 <= k)
                j++;
            else {
                i++;
                j = i + 1;
            }
        }
        for (int i = 1; i < k + 1; i++) {
            std::cout << k - 1 << " ";
            for (int j = 1; j < k; j++)
                std::cout << s[j][i] << " ";
            std::cout << "\n";
        }
    }
}


Measured memory_bytes: 2304
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int S, W;
    cin >> S >> W;
    if(W >= S)
        COUT("unsafe");
    else
        COUT("safe");
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;
//ll n,s;

int main(){
ll n;
ll x;
ll ans=1e16;
cin>>n>>x;
ll a[n+5];
ll b[n+5];
	for(ll i=1;i<=n;++i)cin>>a[i],b[i]=a[i];
	for(ll i=0;i<n;++i)
	{
		ll now=i*x;
		for(ll j=1;j<=n;++j)
			b[j]=min(b[j],a[j>i?j-i:j-i+n]);
		for(ll j=1;j<=n;++j)
			now+=b[j];
		ans=min(ans,now);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

struct edge {
    int from, to; ll cost;
    edge(int s, int t, ll c) :from(s), to(t), cost(c) {};
    bool operator<(edge x) {
        return cost < x.cost;
    }
};

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<vector<edge>> g(n);
    FOR(i, 0, m) {
        int l, r; ll c;
        cin >> l >> r >> c;
        --l, --r;
        g[l].emplace_back(l, r, c);
    }
    FOR(i, 0, n - 1)g[i + 1].emplace_back(i + 1, i, 0);

    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
    que.emplace(0, 0);
    VL dis(n, LLINF);
    dis[0] = 0;
    while (!que.empty()) {
        ll cost; int now;
        tie(cost, now) = que.top(); que.pop();
        if (dis[now] < cost)continue;
        for (edge next : g[now]) {
            if (chmin(dis[next.to], dis[now] + next.cost)) {
                que.emplace(dis[next.to], next.to);
            }
        }
    }
    cout << (dis[n - 1] == LLINF ? -1 : dis[n - 1]) << "\n";
}


Measured memory_bytes: 9336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define PI 2*acos(0.0)
#define boost ios::sync_with_stdio(false);cin.tie(0)
int main()
{
 boost;
  ll a,b,c,n,sum=0;
  cin>>a>>b>>c>>n;
  if(a>=n) { cout<<n<<endl; return 0; }
  else {
      sum+=a;
      n-=a;
  }
  if(b>=n) { cout<<sum<<endl; return 0; }
  else {
      n-=b;
      sum-=(n);
      cout<<sum<<endl;
  }
  return 0;
  
}

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

const int INF = 1e8;

int n, m; // 頂点の数、辺の数

struct edge {int from, to, cost;}; // 辺の始点・終点・重み

vector<vector<int>> adj_matrix; // 隣接行列
vector<vector<edge>> adj_list; // 隣接リスト

vector<int> dist;
vector<bool> visited;

void dijkstra(int start) {
    dist.resize(n);
    visited.resize(n);
    rep(i, n) {
        if (i == start) dist[i] = 0;
        else dist[i] = INF;
        visited[i] = false;
    }
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
    pq.push({dist[start], start});
    while (not pq.empty()) {
        int cur = pq.top().second;
        pq.pop();
        visited[cur] = true;
        for (edge e : adj_list[cur]) {
            // int adj = e.to;
            if (visited[e.to] == false) {
                if (dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                    pq.push({dist[e.to], e.to});
                }
            }
        }
    }
}

void solve_ALDS1_12_C() {
    cin >> n;
    adj_list.resize(n);
    rep(i, n) {
        int u, k;
        cin >> u;
        cin >> k;
        rep(j, k) {
            edge e;
            e.from = u;
            cin >> e.to;
            cin >> e.cost;
            adj_list[e.from].push_back(e);
        }
    }
    dijkstra(0);
    rep(i, n) {
        cout << i << " " << dist[i] << endl;
    }
}

int main() {
    // cin >> n;
    // cin >> m;
    // adj_matrix.resize(n, vector<int>(n, INF));
    // rep(i, n) {
    //     adj_matrix[i][i] = 0;
    // }
    // adj_list.resize(n);
    // rep(i, m) {
    //     edge e;
    //     cin >> e.from;
    //     cin >> e.to;
    //     cin >> e.cost;
    //     adj_matrix[e.from][e.to] = e.cost;
    //     adj_list[e.from].push_back(e);
    // }
    solve_ALDS1_12_C();
}


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

int main(int argc, char *argv[])
{
  int point, sum = 0;
  vector<int> v1, v2;
  
  for (int i = 0; i < 4; i++) {
    cin >> point;
    v1.push_back(point);
  }
  for (int i = 0; i < 2; i++) {
    cin >> point;
    v2.push_back(point);
  }

  sort(v1.begin(), v1.end(), greater<int>());
  sort(v2.begin(), v2.end(), greater<int>());
  
  for (int i = 0; i < 3; i++) {
    sum += v1[i];
  }
  sum += v2[0];

  cout << sum << endl;;
  
  return 0;
}


Measured memory_bytes: 3164
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#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
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

  string x;
	cin >> x;
  if (x == "ABC") {
    cout << "ARC" << "\n";
  } else {
    cout << "ABC" << "\n";
  }
}


Measured memory_bytes: 3100
#include <stdio.h>
#define S 8
#define NOT_FREE 1
#define FREE 0
 
void putQueen(int);
void printBoard(void);
 
int row[S]={0};
int col[S]={0};
int dpos[2*S-1]={0};
int dneg[2*S-1]={0};
int a[S][S];
 
int main(){
 
  int i,j,r,c,k;
 
  for(i=0;i<S;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
 
  for(i=0;i<2*S-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
 
  scanf("%d",&k);
 
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    a[r][c]=NOT_FREE;
  }
 
  putQueen(0);
 
  return 0;
 
}
void putQueen(int i){
 
  int j;
 
  if(i==S){
    printBoard();
    return;
  }
 
  for(j=0;j<S;j++){
    if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+S-1]==NOT_FREE)
      continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+S-1]=NOT_FREE;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+S-1]=FREE;
 
  }
}
 
void printBoard(void){
 
  int i,j;
 
  for(i=0;i<S;i++){
    for(j=0;j<S;j++){
      if(a[i][j]==NOT_FREE && row[i]!=j) return;
    }
  }
 
  for(i=0;i<S;i++){
    for(j=0;j<S;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
import sys 
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
# 入力
N = int(readline())
edge = [[] for _ in range(N+1)]
for i in range(N-1):
    x,y = map(int,readline().split())
    edge[x].append(y)
    edge[y].append(x)

#dfs
#total すべての合計,white どの頂点を白としたときの合計 
def dfs(x,par):
    total,white = 1,1
    for y in edge[x]:
        if y == par:
            continue
        w,t = dfs(y,x)
        total *= w; total%=MOD
        white *= t; white%=MOD
    total += white
    total %= MOD
    return white,total

# 出力
print(dfs(1,0)[1])       

Measured memory_bytes: 943364
#include <stdio.h>

int main(){
     int n;
     scanf("%d",&n);
     int a[n],b[n],c[n-1];

    for (int i = 0; i <n ; ++i) {
        scanf("%d",&a[i]);
    }

    for (int i = 0; i <n ; ++i) {
        scanf("%d",&b[i]);
    }

    for (int i = 0; i <n-1 ; ++i) {
        scanf("%d",&c[i]);
    }
    int ans=0;
    for (int j = 0; j <n ; ++j) {
        ans+=b[a[j]-1];
        if(j>0)
        if(a[j]==a[j-1]+1)
            ans+=c[a[j-1]-1];
    }
    printf("%d",ans);
}

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

int n, k, s;

int main(){
  cin >> n >> k >> s;
  int num = 999999733;
  
  rep(i, n){
    if(i < k){
      cout << s;
    }else if(i == k){
      cout << 1000000001 - s;
    }else{
      cout << num;
    }
    cout << " ";
  }
  cout << endl;
  //cout << res << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int N;
	cin>>N;
	int p,max,ans;
	cin>>max;
	ans=1;
	for(int i=0;i<N-1;i++){
		cin>>p;
		if(max>=p){
			ans++;
			max=p;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = gets.to_i

abc = "abcdefghijklmnopqrstuvwxyz".split("")

n26 = n.to_s(26)

num1 = "1" * n26.size
num2 = "1" * (n26.size - 1)

n2 = nil
len = 0

if n >= num1.to_i(26) then
	n2 = n - num1.to_i(26)
	len = num1.size
else
	n2 = n - num2.to_i(26)
	len = num2.size
end

n_str = n2.to_s(26)

if n_str.size < len then
	n_str = "0" * (len - n_str.size) + n_str
end

result = ""

n_str.split("").each{ |x|
	result += abc[x.to_i(26)]
}

puts result

Measured memory_bytes: 14356
INF = 2e10


def main():
    n, m = map(int, input().split())

    mat = [[INF] * n for i in range(n)]
    for i in range(n):
        mat[i][i] = 0
    for i in range(m):
        s, t, c = map(int, input().split())
        mat[s][t] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                if mat[j][i] == INF:
                    continue
                if mat[i][k] == INF:
                    continue
                mat[j][k] = min(mat[j][k], mat[j][i] + mat[i][k])

    for i in range(n):
        if mat[i][i] < 0:
            print('NEGATIVE CYCLE')
            return

    for i in range(n):
        for j in range(n):
            if j > 0:
                print(' ', end="")
            if mat[i][j] == INF:
                print('INF', end="")
            else:
                print(mat[i][j], end="")
        print()


main()



Measured memory_bytes: 6812
n, k = map(int,input().split())
 
ans = 0
for select in range(k, n + 2):
    min_ = select * (select - 1) / 2
    max_ = select * (2 * n - select + 1) / 2
    ans += (max_ - min_ + 1)
print(int(ans % (10**9 + 7)))


Measured memory_bytes: 9176
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int H, W;
	int count = 0;
	char tmp;
	cin >> H >> W;
	vector<vector<int>> grid(H, vector<int>(W, -1));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> tmp;
			if (tmp == '#')
			{
				grid[i][j] = 1;
				count++;

				if (i != 0)
				{
					if (grid[i - 1][j] == 1)
					{
						grid[i - 1][j] = 0;
						grid[i][j] = 0;
						count -= 2;
					}
					else if (grid[i - 1][j] == 0)
					{
						grid[i][j] = 0;
						count--;
					}
				}

				if (j != 0)
				{
					if (grid[i][j - 1] == 1 && grid[i][j] == 1)
					{
						grid[i][j - 1] = 0;
						grid[i][j] = 0;
						count -= 2;
					}
					else if (grid[i][j - 1] + grid[i][j] == 1)
					{
						grid[i][j] = 0;
						grid[i][j - 1] = 0;
						count--;
					}
				}
			}
		}
	}

	cout << (count == 0 ? "Yes" : "No") << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll solve(ll h){
if(h==1)return 1;

return (2*solve(h/2)+1);


}

int main()
{
    ll h;cin>>h;
   cout<<solve(h);
    return 0;
}


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

struct grid{
  char g[12][12];
  int turn;
};

void fill(grid &gr,char cell,char color,int fx,int fy){
  if(gr.g[fy][fx] != cell){
    return;
  }
  gr.g[fy][fx] = color;
  fill(gr,cell,color,fx+1,fy);
  fill(gr,cell,color,fx-1,fy);
  fill(gr,cell,color,fx,fy+1);
  fill(gr,cell,color,fx,fy-1);
}

bool check(grid &gr,char cell,int x,int y){
  bool flag = 1;
  for(int i=1;i<=y;i++){
    for(int j=1;j<=x;j++){
      if(cell != gr.g[i][j]){
        flag = 0;
        break;
      }
    }
  }
  return flag;
}

int main(){
  while(1){
    int x,y;
    cin >> x >> y;
    if(x==0 && y==0)
      break;
    grid first;
    for(int i=1;i<=y;i++){
      for(int j=1;j<=x;j++){
          cin >> first.g[i][j];
      }
    }

    first.turn = 0;
    queue<grid> q;
    q.push(first);

    while(1){
      grid G = q.front();
      q.pop();
      char cell;
      cell = G.g[1][1];
      if(check(G,cell,x,y)){
        cout << G.turn << endl;
        break;
      }
      if(cell != 'R'){
        grid tmp = G;
        tmp.turn = tmp.turn+1;
        fill(tmp,cell,'R',1,1);
        q.push(tmp);
      }
      if(cell != 'G'){
        grid tmp = G;
        tmp.turn = tmp.turn+1;
        fill(tmp,cell,'G',1,1);
        q.push(tmp);
      }
      if(cell != 'B'){
        grid tmp = G;
        tmp.turn = tmp.turn+1;
        fill(tmp,cell,'B',1,1);
        q.push(tmp);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 40172
import numpy as np
from numba import jit

@jit('i2[:](i2,i2,i2[:])')
def solve(n,k,A):
    l,r=0,0
    for i in range(k):
        B=np.zeros(n+1,dtype=np.int64)
        for x,y in enumerate(list(A)):
            l=max(0,x-y)
            r=min(n,x+y+1)
            B[l]+=1
            B[r]-=1
        A=np.cumsum(B[:-1])
        if A[A==n].size==n:
            break
    return A
n,k=map(int,input().split())
a=list(map(int,input().split()))
A=np.array(a)
X=solve(n,k,A)
print(*X,sep=' ')

Measured memory_bytes: 138008
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

ll keta(ll a){
    ll n=10;
    for(ll i=1;i<15;i++){
        if(n>a){return i;}
        n*=10;
    }
    return E;
}


int main(){
    ll n;
    cin>>n;
    ll mx=-E;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){mx=i;}
    }
    cout<<keta(n/mx)<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 256
from itertools import permutations
n,m=map(int,input().split())
side=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  side[a].append(b)
  side[b].append(a)
route=[i for i in range(2,n+1)]
ans=0
for x in permutations(route):
  x=list(x)
  x.insert(0,1)
  for i in range(n-1):
    if x[i+1] not in side[x[i]]:
      break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#ifdef __cplusplus
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF (1 << 30)
#define INF_NEG (INF * -1)
#define INF_LONG (1LL << 62)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
int StrLen(char *s) { for(int ptr = 0;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
int StrDel(char *s, int n) { int l = StrLen(s); s[l - n + 1] = '\0'; return l - n; }

int NumDigits(int i){ char s[20]; return sprintf(s, "%d", i); }
int NumDigitsLL(long long l){ char s[30]; sprintf(s, "%lld", l); return strlen(s); }

int is1stAns = 1;
#ifdef __cplusplus
template <class T> 
void print(T t) { if (is1stAns) cout << t, is1stAns = 0; else cout << " " << t; }
#else
void printI(int    i) { if (is1stAns) printf(  "%d", i), is1stAns = 0; else printf(  " %d", i); }
void printL(ll     l) { if (is1stAns) printf("%lld", l), is1stAns = 0; else printf(" %lld", l); }
void printD(double d) { if (is1stAns) printf("%.9f", d), is1stAns = 0; else printf(" %.9f", d); }
void printC(char   c) { if (is1stAns) printf(  "%c", c), is1stAns = 0; else printf(  " %c", c); }
void printS(char  *s) { if (is1stAns) printf(  "%s", s), is1stAns = 0; else printf(  " %s", s); }
#endif

void PrintOneBlock(char *left, int len, int firstL)
{
    rep(i, firstL - 1) printI(0);
    int numChild = len / 2;
    if (len % 2){ // 長さが奇数の場合、どちらかを１つ増やす
        if (firstL % 2){ // L が奇数番目から始まる場合、左を１増やす
            printI(numChild + 1); printI(numChild);
        } else {
            printI(numChild); printI(numChild + 1);
        }
    } else {
        printI(numChild); printI(numChild);
    }
    rep(i, len - firstL - 1) printI(0);
}

int SolveOneBlock(char *src, char *left)
{
    /*
     *  src の左側から [R+L+] な文字列を切り取る
     *  戻り値は切り取った文字数
     */

    int ptr;
    for (ptr = 0; src[ptr] == 'R'; ++ptr)
        ;
    int firstL = ptr; // 切り取った文字列の中の最初の 'L' の位置
    for (; src[ptr] == 'L'; ++ptr)
        ;
    strncpy(left, src, ptr);
    left[ptr] = '\0';

    PrintOneBlock(left, ptr, firstL);

    return ptr;
}

#define MAX_S_LEN 100100

int main()
{
    char *S = (char *)malloc(MAX_S_LEN); // 入力用
    char *L = (char *)malloc(MAX_S_LEN); // 左側切り取り用
    scanf("%s", S);

    char *src = S;
    while(src[0]){
        src += SolveOneBlock(src, L); // [R+L+] のブロックに切り分けて解答
    }
    puts("");

    free(L);
    free(S);
    return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  int ans = 1;
  
  ans *= k;
  for (int i=0; i<n-1; i++)
    ans *= k-1;
  
  cout << ans << endl;
}
        


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d", $n);
fscanf(STDIN,"%s", $s);
$half_n = $n / 2;
echo $n % 2 === 0 && substr($s, 0, $half_n) === substr($s, $half_n, $half_n) ? 'Yes' : 'No';
?>

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>

using namespace std;

class UnionFind {
    vector<int> par;
    vector<int> sizes;
public:
    UnionFind(int n) : par(n), sizes(n, 1) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
       if (x == par[x]) return x;
       return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sizes[find(x)];
    }
};

bool xord(pair< int, pair<int, int> > v1, pair< int, pair<int, int> >v2) {
    return v1.second.first < v2.second.first;
}
bool yord(pair< int, pair<int, int> > v1, pair< int, pair<int, int> >v2) {
    return v1.second.second < v2.second.second;
}

void solve(int n, vector< pair< int, pair<int, int> > > V) {
    vector< pair<int, pair <int, int> > > E;
    vector< pair<int, pair<int, int> > > V1 = V;
    vector< pair<int, pair<int, int> > > V2 = V;
    sort(V1.begin(), V1.end(), xord);
    sort(V2.begin(), V2.end(), yord);
    for (int i = 0; i < n-1; i++) {
        pair<int, pair <int, int> > tmp;
        tmp.first = V1[i+1].second.first - V1[i].second.first;
        tmp.second.first = V1[i].first;
        tmp.second.second = V1[i+1].first;
        E.push_back(tmp);
    }
    for (int i = 0; i < n-1; i++) {
        pair<int, pair <int, int> > tmp;
        tmp.first = V2[i+1].second.second - V2[i].second.second;
        tmp.second.first = V2[i].first;
        tmp.second.second = V2[i+1].first;
        E.push_back(tmp);
    }
    sort(E.begin(), E.end());
    int min_cost = 0;
    UnionFind uf(n);
    for (int i = 0; i < E.size(); i++) {
        if (!uf.same(E[i].second.first, E[i].second.second)) {
            min_cost += E[i].first;
            uf.unite(E[i].second.first, E[i].second.second);
        }
    }
    std::cout << min_cost << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    vector< pair<int, pair<int, int> > > V(n);
    for (int i = 0; i < n; i++) {
        V[i].first = i;
        std::cin >> V[i].second.first >> V[i].second.second;
    }
    solve(n, V);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

#define pb push_back

typedef long long ll;

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

	int n, m;
	cin >> n >> m;
	
	vector<vector<int>> adj(n);
	for (int i = 0; i < n; i++) {
		vector<int> v;
		adj.pb(v);
	}
	
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	int parent[n];
	fill(parent, parent + n, -1);
	queue<int> q;
	q.push(0);
	
	while (!q.empty()) {
		int head = q.front(); q.pop();
		for (int nbr : adj[head]) {
			if (parent[nbr] == -1) {
				q.push(nbr);
				parent[nbr] = head;
			}
		}
	}
	
	for (int i = 1; i < n; i++) {
		if (parent[i] == -1) {
			cout << "No\n";
			return 0;
		}
	}
	
	cout << "Yes\n";
	for (int i = 1; i < n; i++) {
		cout << (parent[i] + 1) << '\n';
	}
	
    return 0;
}

Measured memory_bytes: 12416
import  math
a,b = map(int,input().split())

price_8=100*a/8
price_10=100*b/10

if(math.floor(price_8+12.5)>price_10 and math.floor(price_10+10)>math.ceil(price_8)):
    print(max(int(price_10), math.ceil(price_8)))
else:
    print(-1)

Measured memory_bytes: 3060
S=input()
flag=True
if len(S)%2!=0:
    flag=False
for i in range(len(S)):
    if i%2==0:
        if S[i]!='h':
            flag=False
    else:
        if S[i]!='i':
            flag=False
if flag==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define ALL(n) begin(n), end(n)

int main()
{
    int H, W;
    cin >> H >> W;
    vector<char> c(W + 2, '#');
    rep2(i, -1, H + 1)
    {
        if (i < 0 || i >= H)
            rep(j, W + 2) cout << c.at(j);
        else
        {
            string s;
            cin >> s;
            cout << '#' << s << '#';
        }
        cout << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define intpow(a, n) (int)pow((long double) a, (long double) n)
#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    bool can = true;
    if(a > 8 || b > 8){
        can = false;
    }
    cout << (can ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
// fflush(stdout); to flush after every print ;,use \n in interactive prob;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k,s,a[200000],i,j,p;
cin>>n>>k>>s;
for(i=0;i<=2*n;i++)
{
    a[i]=0;
}

for(i=1;i<=k;i++)
{
    a[i]=s;
}
for(i=k+1;i<=n;i++)
{
    a[i]=1000000000;
    if(s==1000000000)
    {
        a[i]=1;
    }
}

for(i=1;i<=n;i++)
{
    cout<<a[i]<<" ";
}
cout<<endl;

return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(0);
 
	ll x, y;
	cin >> x >> y;
	if (x % y == 0) {cout << -1;}
	else {cout << x;}
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  string s;
  cin >> n;
  cin >> s;
  ll r = 0, g = 0, b = 0;
  REP(i, n) {
    if (s[i] == 'R') r++;
    else if(s[i] == 'G')
      g++;
    else
      b++;
  }
  ll ans = r * g * b;
  FOR(i, 0, n-3) {
    FOR(j, i+1, n-2) {
      if (s[i] == s[j]) continue;
      int k = j * 2 - i;
      if (k >= n || s[k] == s[i] || s[k] == s[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3632
#include<stdio.h>

int GCD(int x, int y) {
	if (y == 0)
		return x;
	else
		return GCD(y, x%y);
}

int main()
{
	int x, y, g;
	scanf("%d %d", &x, &y);
	g = GCD(x, y);
	x = x / g;
	y = y / g;
	printf("%d\n", 1 + (x + y - 1)*g);
	return 0;
}

Measured memory_bytes: 2736
def main():
  n, k = map(int, input().split())
  
  plst = []
  xlst = []
  ylst = []
  dlst = []
  
  for i in range(n):
    x1,y1,d1,x2,y2,d2 = map(int, input().split())
    plst.append((x1,y1,d1,x2,y2,d2))
    xlst.append(x1)
    xlst.append(x2)
    ylst.append(y1)
    ylst.append(y2)
    dlst.append(d1)
    dlst.append(d2)
  
  xlst = list(set(xlst))
  ylst = list(set(ylst))
  dlst = list(set(dlst))
  
  xlst.sort()
  ylst.sort()
  dlst.sort()

  lx = len(xlst)
  ly = len(ylst)
  ld = len(dlst)
  
  xdic = {}
  ydic = {}
  ddic = {}
  
  for i, v in enumerate(xlst):
    xdic[v] = i
  for i, v in enumerate(ylst):
    ydic[v] = i
  for i, v in enumerate(dlst):
    ddic[v] = i
  
  new_map = [[[0] * ld for _ in range(ly)] for _ in range(lx)]
  
  for p in plst:
    x1, y1, d1, x2, y2, d2 = p
    x1, y1, d1, x2, y2, d2 = xdic[x1], ydic[y1], ddic[d1], xdic[x2], ydic[y2], ddic[d2]
    for x in range(x1, x2):
      for y in range(y1, y2):
        for d in range(d1, d2):
          new_map[x][y][d] += 1
  
  ans = 0
  for i in range(lx - 1):
    xlsti = xlst[i]
    xlsti1 = xlst[i + 1]
    x = xdic[xlsti]
    for j in range(ly - 1):
      ylstj = ylst[j]
      ylstj1 = ylst[j + 1]
      y = ydic[ylstj]
      for z in range(ld - 1):
        dlstz = dlst[z]
        dlstz1 = dlst[z + 1]
        d = ddic[dlstz]
        if new_map[x][y][d] >= k:
          ans += (xlsti1 - xlsti) * (ylstj1 - ylstj) * (dlstz1 - dlstz)
  print(ans)

main()


Measured memory_bytes: 14320
n = int(input())
s = input()
ans = 0
for i in range(1000):
    x = str(i)
    if len(x) == 1: x = '0'*2+x
    elif len(x) == 2:x = '0'+x
    res = 0
    mae = -1
    for e in x:
        for i in range(n):
            if s[i] == e and i > mae:
                res+=1
                mae = i
                break
    if res == 3:
        ans+=1
        
print(ans)
        
    
    

Measured memory_bytes: 44060
#include<stdio.h>
int main(void){
  int i,j,s=0;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      s=i*j;
      printf("%dx%d=%d\n",i,j,s);
    }
  }
  return 0;
}

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

int main() {
	string s;
	string worst = "zyxwvutsrqponmlkjihgfedcba";
	bool okey = true;
	int n, i, j;
	vector<int> v(26);
	cin >> s;
	n = s.size();
	if (s == worst) {
		cout << -1;
	}
	else {
		for (i = 0; i < n; i++)
			v[s[i] - 'a']++;
		if (n < 26) {
			for (i = 0; i < 26; i++)
				if (v[i] == 0) {
					s.push_back('a' + i);
					break;
				}
			cout << s;
		}
		else {
			i = 25;
			while (1) {
				if (s[i] == 'z') {
					i--;
					s.resize(i + 1);
					continue;
				}
				else {
					s[i]++;
				}

				okey = true;
				for (j = 0; j < i; ++j) {
					if (s[j] == s[i])
						okey = false;
				}
				if (okey) {
					break;
				}
			}
			cout << s;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from collections import *
from contextlib import *
from functools import *
from itertools import *

a,b,c = [int(x) for x in input().strip().split()]

#if a%4 == b%4 and a%4 == c%4:
#    print(-1)
#    raise SystemExit

n = 0
while 1:
    if a%2 or b%2 or c%2:
        break
    a, b, c = (b+c)//2, (c+a)//2, (a+b)//2
    n += 1
    if n > 10000:
        print(-1)
        raise SystemExit
print(n)


Measured memory_bytes: 4044
x, n = map(int, input().split())

if n == 0:
    P = []
else: 
    P = list(map(int, input().split()))

for i in range(1, 100):
    if x - i not in P:
        dif_mis = x-i
        break

for i in range(0, 100):
    if x + i not in P:
        dif_pls = x+i
        break

if (x-dif_mis)**2 > (x-dif_pls)**2:
    print(dif_pls)
else:
    print(dif_mis)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
   ll n,k ; cin>>n>>k ;
   vector<ll> A(n),B(n) ;
   rep(i,n) {
     cin>>A[i] ;
   A[i]-- ;
   }
   rep(i,n) cin>>B[i] ;
   vector<ll> s(n),ans(n) ;
   rep(i,n){
     ll cnt=0 ;
     ll now= i ;
     ll po=0 ;
     rep(ww,n+1){
       cnt++ ;
     now= A[now] ;
     po+= B[now] ;
     if(now==i) break ;
     }
     ll qo=po ;


     if(qo<0){
      now=i ;
      po=0 ;
      ll bns= -INF ;
      rep(ww,min(k,cnt)){
        now=A[now] ;
        po+=B[now] ;
        chmax(bns,po) ;
        
      }
      ans[i]=bns ;
     } 

     else{
     if(k<=cnt){
       now=i ;
      po=0 ;
      ll bns= -INF ;
      rep(ww,min(k,cnt)){
        now=A[now] ;
        po+=B[now] ;
        chmax(bns,po) ;
        
      }
      ans[i]=bns ;
     }
      else{
        ans[i]= ((k/cnt)-1)*qo ;
        
       now=i ;
      po=0 ;
      ll bns= 0 ;
      rep(ww,(k%cnt)+cnt){
        now=A[now] ;
        po+=B[now] ;
         chmax(bns,po) ;
        
      }
      ans[i]+=bns ;
      }
     }


   }

   ll lp=-INF ;
   rep(i,n) chmax(lp,ans[i]) ;
   cout<<lp<<endl;
   
   return 0 ;
 }



Measured memory_bytes: 3776
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    else:
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7 #出力の制限
N = 3000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

p,k = map(int,input().split())

#print(cmb(2,0,mod))
for j in range(1,k+1):
    print((cmb(k-1,j-1,mod)*cmb(p-k+1,j,mod))%(10**9+7))

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;





int main() {
    int x; cin>>x;
    int sen = 0;
    sen = x/500;
    x = x - sen * 500;
    int go = x/5;
    int ans = 1000 * sen + 5 * go;
    cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    s = IS()
    n = len(s)
    if n%2==1:
        print('No')
        return None
    for i in range(0, n, 2):
        if s[i:i+2] != 'hi':
            print('No')
            return None
    print('Yes')

if __name__ == '__main__':
    main()

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

const ll INF=LLONG_MAX/2;

int main(){
  int N; cin>>N;
  vector<ll> a(N);
  ll odd=0,even=0,ma=-INF;
  int cnt=0;
  rep(i,N){
    cin>>a[i];
    if(a[i]>0){
      if((i+1)%2) odd+=a[i];
      else even+=a[i];
    }
    cnt+=a[i]<0?1:0;
    ma=max(ma,a[i]);
  }
  if(N==cnt){
    cout<<ma<<endl;
    cout<<N-1<<endl;
    while(a[0]!=ma){
      cout<<1<<endl;
      a.erase(a.begin());
    }
    while(a.size()>1){
      cout<<a.size()<<endl;
      a.pop_back();
    }
    return 0;
  }
  vector<int> ans;
  if(odd<even){
    ans.push_back(1);
    a.erase(a.begin());
    if((N-1)%2==0){
      ans.push_back(a.size());
      a.pop_back();
    }
  }else{
    if(N%2==0){
      ans.push_back(a.size());
      a.pop_back();
    }
  }
  while(a[0]<0){
    ans.push_back(1); ans.push_back(1);
    a.erase(a.begin());
    a.erase(a.begin());
  }
  while(a[a.size()-1]<0){
    ans.push_back(a.size());
    a.pop_back();
    ans.push_back(a.size());
    a.pop_back();
  }
  while(a.size()>2){
    if(a[2]>0){
      ans.push_back(2);
      a.erase(a.begin());
      a.erase(a.begin()+1);
    }else{
      ans.push_back(3);
      a.erase(a.begin()+3);
      a.erase(a.begin()+1);
    }
  }
  if(a.size()==2){
    ans.push_back(2);
  }
  cout<<max(odd,even)<<endl;
  cout<<ans.size()<<endl;
  rep(i,ans.size()) cout<<ans[i]<<endl;
  return 0;
}


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

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

    int a, b, c;
    cin >> a >> b >> c;
 
    int n_max = max(a, max(b, c));
    int sum_diff = n_max-a + n_max-b + n_max-c;
 
    if(sum_diff%2 == 0) cout << sum_diff/2 << endl;
    else cout << (sum_diff+3)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define NL              print("\n");
#define debug(a)        cout<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
map <ll,ll> vis;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    cin>>n>>k;
    if(k==1 || n==0)
    {
        cout<<"0\n";
        return 0;

    }
    else
    {
        n=n%k;
        cout<<min(n,k-n)<<endl;
    }
}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int N = int.Parse(imp[0]);  //コードの個数
            int M = int.Parse(imp[1]);  //コードの項数
            int C = int.Parse(imp[2]);
            int count = 0;
            int Aisum = 0;

            var impB = Console.ReadLine().Split(' ');


            for (int i = 0; i < N; ++i) 
            {
                var Ai = Console.ReadLine().Split(' ');

                for (int j = 0; j < M; ++j)
                {
                    Aisum += int.Parse(Ai[j]) * int.Parse(impB[j]);
                }

                if (Aisum + C > 0)
                {
                    count += 1;
                    Aisum = 0;
                }
                else
                {
                    Aisum = 0;
                }
              //  Console.Write(Aisum);
            }
           Console.Write(count);

           // System.Threading.Thread.Sleep(1000);
        }
    }
}


Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func main() {
	X := make([]int, 5)
	fmt.Scan(&X[0], &X[1], &X[2], &X[3], &X[4])
	min := 10
	sum := 0
	for i := 0; i < 5; i++ {
		t := (X[i] % 10)
		if t != 0 && t < min {
			min = t
		}
		if t == 0 {
			sum += X[i]
		} else {
			sum += X[i] + 10 - t
		}
	}
	sum -= (10 - min)
	
	fmt.Println(sum)

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,x,L,d;
signed main(){
  cin >> n >> x;
  d=0;
  for(int i=1;i<=n;i++){
    cin >> L;
    d+=L;
    if(d<=x);
    else{
      cout << i << endl;
      return 0;
    }
  }
  cout << n+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
struct a{
  string s;
  li x;
};

void longestpallindrome(string s)
{
  li i,j,k;
  li n=s.length();
  bool table[n][n];
  memset(table,0,sizeof(table));
  for(i=0;i<n;i++)
  table[i][i]=1;
  li maxlength=1;
  li start=0;
  for(i=0;i<n-1;i++)
  {
    if(s[i]==s[i+1])
    {
      table[i][i+1]=1;
      if(maxlength<2)
      {maxlength=2;
      start=i;
       }
    }
  }
  for(k=3;k<=n;k++)
  {
    for(i=0;i<n-k+1;i++)
    {
      li j=i+k-1;

      if(table[i+1][j-1]&&s[i]==s[j])
      {
        table[i][j]=1;
        if(k>maxlength)
        {
          maxlength=k;
          start=i;
        }
      }
    }
  }
  cout<<s.substr(start,maxlength);
}

int main()
{
fast_io
double n;
cin>>n;
n=(n*1.0)/(3*1.0);
double x=n*n*n;
cout<<fixed<<setprecision(12)<<x;
return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;

  string SS;
  if (S.size() <= K) {
    SS = S;
  }
  else {
    for (int i = 0; i < K; ++i) {
      SS.push_back(S.at(i));
    }
    SS += "...";
  }

  cout << SS << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, flag=0;
    string s;
    cin >> n >> s;
    if (n%2==0) {
        for (int i=0; i<n/2; i++) {
            if (s[i]==s[i+n/2]) {
                flag++;
            }
        }
        if (flag==n/2) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256