akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n;cin>>n;
  set<int> st;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    st.insert(a);
  }
  if(st.size()==n){
    puts("YES");
  }else{
    puts("NO");

  }
  
  return 0;
}


Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/04  Problem: Nagoya_univ_contest_17_h  / Link: http://arc077.contest.atcoder.jp/tasks/arc077_c  ----- */
/* ------問題------

snuke 君は明るさを m 段階に切り替えられる照明を買いに来ました。
この照明の 明るさは 1 以上 m 以下の整数で表され、 リモコンに付いた 2 種類のボタンで明るさを切り替えます。
1 つめのボタンは「順送り」ボタンで、 明るさを 1 増やすことができます。
ただし、ボタンを押す前の明るさが最大の m である場合には、 明るさは 1 になります。
2 つめのボタンは「お気に入り」ボタンで、 購入時に決めたお気に入りの明るさ x に切り替えることが出来ます。
snuke 君はお気に入りの明るさ x を、できるだけ効率的に明るさが切り替えられるように設定しようと考えました。
snuke 君は今後 n−1 回明るさを切り替える予定で、i 回目には明るさ ai から 明るさ ai+1 に切り替えようと計画しています。
最初、明るさは a1 です。 ボタンを押す回数の合計が最小になるようにお気に入りの明るさ x を決めた時の ボタンを押す回数を求めて下さい。

-----問題ここまで----- */
/* -----解説等-----

こどふぉでみたよね
WAしないで

----解説ここまで---- */




LL N, M;
LL ans = 0LL;
LL a[100005];

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

	cin >> N >> M;

	FOR(i, 0, N) {
		cin >> a[i];
		a[i]--;
	}

	VL data(3 * M);
	ans = 0;
	FOR(i, 0, N - 1) {
		LL A = a[i], B = a[i + 1];
		if (B < A)B += M;
		ans += B - A;
		if (A + 1 < B) {
			data[A + 2] += 1;
			data[B + 1] += -(B + 1 - (A + 2) + 1);
			data[B + 2] += B + 1 - (A + 2);
		}
	}

	FOR(i, 0, SZ(data) - 1) {
		data[i + 1] += data[i];
	}
	LL maxc = -1;

	FOR(i, 0, SZ(data) - 1) {
		data[i + 1] += data[i];
	}
	FOR(i, 0, M) {
		data[i + M] += data[i];
	}

	//FOR(i, 0, SZ(data)) {
	//	cout << setw(3) << setfill('.') << data[i] << " ";
	//}
	//cout << endl;

	FOR(i, M, 2 * M)maxc = max(maxc, data[i]);

	printf("%lld\n", ans - maxc);

	return 0;
}

Measured memory_bytes: 3328
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int total = 0;

	total = 800*n - 200*(n/15);

	cout << total << endl;

	return 0;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,k,i,j,x;
    cin>>n>>k;
    long long int A[n],result[n]={0};
    for(i=0;i<n;i++){
        cin>>A[i];
    }
    result[0]=0;
    for(i=1;i<n;i++){
        x=INT_MAX;
        for(j=1;j<=k;j++){
            if(i-j<0)
            break;
            x=min(x,result[i-j]+abs(A[i]-A[i-j]));
        }
        result[i]=x;
    }
    cout<<result[n-1];
    return 0;
}


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

using namespace std;

int a[100000 + 5] = {};

int main() {
    int n;//客の数
    int t;//営業時間
    cin >> n >> t;

    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        a[l]++;
        a[r]--;
    }

    int ans = a[0];
    for (int i = 1; i <= t; ++i) {
        a[i] += a[i - 1];
        ans = max(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3512
import java.util.Scanner;

public class Main {

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

	    int a=gi();
	    int b=gi();
	    int c=gi();
	    
	    
	    //System.out.print(f);
	    if ((a<=c && c<=b)|| (b<=c && c<=a)) {
	    	System.out.print("Yes");
	    }else {
	    	System.out.print("No");
	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35556
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(true){
    int n,x;
    cin>>n>>x;
    if(n==0 and x==0)return 0;
    int cnt=0;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            for(int k=j+1; k<=n; k++){
                if(i+j+k==x)cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    }
    return 0;
}


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

using ll = int64_t;
#define int ll

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int a, b, x;
  std::cin >> a >> b >> x;
  auto calc = [&x](int n) {
    if (n == -1)
      return (int)0;
    else
      return n / x + 1;
  };
  print(calc(b) - calc(a - 1));
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = LSS()

    cnt = len(set(S))
    if cnt == 3:
        print('Three')
    else:
        print('Four')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9980
#include<stdio.h>
#include<string.h>
int main()
{
    char str[200],st1[200],st2[200];
    int len,i,j,k;
    while(gets(str))
    {
        len=strlen(str);
       // printf("%d\n",len);
        while(len>=0)
        {
            len-=2;
            for(i=0,j=0;i<(len)/2;i++,j++)
                st1[j]=str[i];
            st1[j]=0;
            for(i=len/2,j=0;i<len;i++,j++)
                st2[j]=str[i];
            st2[j]=0;
           // printf("%s %s\n",st1,st2);
            if(strcmp(st1,st2)==0)
                break;
        }
        len=strlen(st1);
        printf("%d\n",len*2);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
from collections import deque
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def bfs():
    visited[0] = True
    ans[0] = counter[0]
    deq = deque()
    deq.append(0)
    while deq:
        v = deq.popleft()
        for nv in edge[v]:
            if visited[nv] is True:
                continue
            visited[nv] = True
            ans[nv] = ans[v] + counter[nv]
            deq.append(nv)


N, Q = inpl()

edge = [[] for i in range(N)]
for i in range(N - 1):
    a, b = inpl()
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

counter = {k: 0 for k in range(N)}
for i in range(Q):
    p, q = inpl()
    counter[p - 1] = counter.get(p - 1, 0) + q

ans = [0 for i in range(N)]
visited = [False for i in range(N)]

bfs()

print(" ".join(list(map(str, ans))))


Measured memory_bytes: 136304
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};


int main(){
    int n;cin >> n;
    vector<int> a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        c[i] = i+1;
    }
    int A = 0,B = 0;
    int C = 0;
    do{
        bool f = false;
        for (int i = 0; i < n; i++) {
            if(c[i]!=a[i]) f = true;
        }
        if(!f) A = C;
        bool ff = false;
        for (int i = 0; i < n; i++) {
            if(c[i]!=b[i]) ff = true;
        }
        if(!ff) B = C;
        C++;
    }while(next_permutation(ALL(c)));
    cout << abs(A-B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything 42

signed main(){
	cout<<fixed<<setprecision(7);
	int n;
	
	cin>>n;
	
	cout<<n<<":";
	for(int i = 2; i * i <= n; i++){
		while(n%i==0){
			n/=i;
			cout<<" "<<i;
		}
	}
	if(n!=1)cout<<" "<<n;
	cout<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(){
  int i, j, n, N, card[4][13];
  char str,d;
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      card[i][j] = 1;
    }
  }
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%c", &d);
    scanf("%c" "%d", &str, &n);
    if(str=='S')
    card[0][n-1] = 0;
    else if(str=='H')
    card[1][n-1] = 0;
    else if(str=='C')
    card[2][n-1] = 0;
    else if(str=='D')
    card[3][n-1] = 0;
  }
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(card[i][j]){
        if(i==0){
          printf("S %d\n", j+1);
        }
        else if(i==1){
          printf("H %d\n", j+1);
        }
        else if(i==2){
          printf("C %d\n", j+1);
        }
        else if(i==3){
          printf("D %d\n", j+1);
        }
      }
    }
  }
  return 0;
}



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

int main(){
	string A,B,C;
  	cin >> A >> B >> C;
	int turn = 'a';
	bool res =true;
  	while(res){
    	if(turn == 'a'){
        	if(A.size() ==0){
            	cout << 'A' << endl;
              	res = false;
            }
          	else{ 
             	turn=A[0];
              	A.erase(0,1);
            }
        }
      	if(turn == 'b'){
        	if(B.size() ==0){
            	cout << 'B' << endl;
              	res = false;
            }
          	else{ 
             	turn=B[0];
              	B.erase(0,1);
            }
        }
      	if(turn == 'c'){
        	if(C.size() ==0){
            	cout << 'C' << endl;
              	res = false;
            }
          	else{ 
             	turn=C[0];
              	C.erase(0,1);
            }
        }
    }
  	
}


Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def cmb(n, k, mod, fac, ifac):
    # nCkを計算する
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n):
    # 階乗テーブル、逆元の階乗テーブルを作成する
    fac = [1, 1] # 階乗テーブル
    ifac = [1, 1] # 逆元の階乗テーブル
    inverse = [0, 1] # 逆元テーブル 0の階乗は1 0の逆元は0

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

X, Y = lr()
MOD = 10 ** 9 + 7
if (X+Y)%3 != 0 or X > 2 * Y or Y > 2 * X:
    print(0)
    exit()
if X < Y:
    X, Y = Y, X
# Xが大きい
total_time = (X+Y)//3
x_time = (X - Y + total_time) // 2
# total_time C i_time
fac, ifac = make_tables(MOD, total_time)
answer = fac[total_time] * ifac[x_time] * ifac[total_time - x_time] % MOD
print(answer)
# 44

Measured memory_bytes: 82448
n = gets.to_i
a = gets.split.map(&:to_i)

x = 0
n.times do |i|
    if i%2 == 0 then
        x += a[i]
    else
        x -= a[i]
    end
end

ans = [x]
rain = x
(n-1).times do |i|
    rain = (a[i] - rain/2) * 2
    ans << rain
end

print(ans * " ")
    



Measured memory_bytes: 14084
# -*- coding: utf-8 -*-

abcd = list(input())
abcd = list(map(int,abcd))

ans = ""

def dfs(i, num, s):
    global ans
    if i == len(abcd):
        if num == 7:
            s += "=7"
            ans = s
        return

    dfs(i + 1, num + abcd[i], s + "+" + str(abcd[i]))
    dfs(i + 1, num - abcd[i], s + "-" + str(abcd[i]))

    return

dfs(1,abcd[0],str(abcd[0]))

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

int n, a[101000];

bool work()
{
    int x = 0, y = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] > 1)
            if (a[i] & 1)
                x++;
            else
                y++;
    if (y & 1)
        return 1;
    if (x >= 2 || x == 0)
        return 0;
    int g = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] > 1)
        {
            if (a[i] & 1)
                a[i]--;
            g = __gcd(g, a[i]);
        }
    for (int i = 1; i <= n; i++)
        if (a[i] > 1)
            a[i] /= g;
    return !work();
}

int main()
{
    n = read();
    for (int i = 1; i <= n; i++)
        a[i] = read();
    printf(work() ? "First" : "Second");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int ans=0,n;
int main(){
	n=read();
	for(int i=1;i<=n;++i)ans+=read()-1;
	printf("%d",ans);
	return 0;
}

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

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int n;cin>>n;
	rep(i,1,10){
		rep(j,1,10){
			if(i*j==n){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int p = 37; // TODO

void pri(vector<int> &x){
  for(int el:x){
    cout << el + 1 << " ";
  }
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n = p * p + p + 1;
  int k = p + 1;
  cout << n << " " << k << "\n";
  R(i,p)R(j,p){
    vector<int> pom;
    R(l,p){
      pom.PB((i * l + j) % p * p + l);
    }
    pom.PB(p * p + i);
    pri(pom);
  }
  R(i,p){
    vector<int> pom;
    R(j,p){
      pom.PB(j * p + i);
    }
    pom.PB(p * p + p);
    pri(pom);
  }
  vector<int> pom;
  R(i,p + 1){
    pom.PB(p * p + i);
  }
  pri(pom);
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

bool isok_1(ll index, ll key, vector<ll> &vec) {
  if (vec[index] > key) return true;
  else return false;
}

bool isok_2(ll index, ll key, vector<ll> &vec) {
  if (vec[index] < key) return true;
  else return false;
}

ll binary_search_1(ll key, vector<ll> &vec) {
  ll ng = -1, ok = vec.size();
  
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (isok_1(mid, key, vec)) ok = mid;
    else ng = mid;
  }
  return ok;//keyより大きいの最小のindex
}

ll binary_search_2(ll key, vector<ll> &vec) {
  ll ok = -1, ng = vec.size();
  
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (isok_2(mid, key, vec)) ok = mid;
    else ng = mid;
  }
  return ok;//keyより小さいの最大のindex
}


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(all(a));
  sort(all(c));
  
  ll ans = 0;
  /*rep(i, n) {
    int A = a[i];//最上段のサイズ
    int b_ = binary_search_1(A, b);//Aより大きい最小のbのindex
    if (b_ == -1) break;
    for (int j = b_; j < n; j++) {
      int B = b[j];//中段のサイズ
      int c_ = binary_search_1(B, c);//Bより大きい最小のcのindex
      if (c_ == -1) break;
      ans += n - c_;
    }
  }*/
  
  rep(i, n) {
    ll B = b[i];
    ll a_ = binary_search_2(B, a);//a[0]からa[a_]までok
    if (a_ == n) break;
    ll c_ = binary_search_1(B, c);//c[c_]からc[n-1]まで
    if (c_ == -1) break;
    
    ans += (a_ + 1) * (n - c_);
  }
  
  cout << ans << endl;
  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

template<typename T> using V = vector< T >;
using Vi = V<int>;

int main(){
    int n;
    cin>>n;
    Vi p(n),q(n),r(n);
    REP(i,n) cin>>p[i];
    REP(i,n) cin>>q[i];
    REP(i,n) r[i] = i+1;

    int j = 0;
    int a = 0;
    int b = 0;
    do {
        if(r==p) a=j;
        if(r==q) b=j;
        j++;
    } while (next_permutation(ALL(r)));

    cout<<abs(a-b)<<endl;

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	int a;
	cin>>a;
	cout<<"ABC"<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define SIZE 30
using std::vector;
using std::cin;
using std::cout;
using std::endl;

 
 
int main() {
	std::cin.tie(0);std::ios::sync_with_stdio(false);
	int a,b,c;
	
	cin >> a;
	cin >> b;
	cin >> c;
	int a_,b_,c_;
	
	int cn=0;
	for(;;){
		
		if(a%2==0&&b%2==0&&c%2==0){
			cn++;
		}else{
		
			cout << cn;
			return 0;
		}
		if(cn>10000){cout<<"-1";return 0;}
		c_=(a+b)/2;
		b_=(a+c)/2;
		a_=(b+c)/2;
		a=a_,b=b_,c=c_;
	}
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;

ll qpow(ll x,ll n,int mod)
{
    ll sum=1;
    while(n){
        if(n&1) sum=sum*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return sum;
}
int ans(int x)
{
    if(x==0) return 0;
    int kk=__builtin_popcount(x);
    return 1+ans(x%kk);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    int one=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1') one++;
    }
    int p1=0,p2=0;
    for(int i=0;i<n;i++){
        if(one!=1){
            p1=(p1*2+s[i]-'0')%(one-1);
        }
        p2=(p2*2+s[i]-'0')%(one+1);
    }
    for(int i=0;i<n;i++){
        if((s[i]=='1'&&one==1)){
            cout<<0<<endl;
        }
        else if(s[i]=='1'){
            cout<<1+ans((p1-qpow(2,n-i-1,one-1)+(one-1))%(one-1))<<endl;
        }
        else if(s[i]=='0'){
            cout<<1+ans((p2+qpow(2,n-i-1,one+1)+(one+1))%(one+1))<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3704
import math

while True:
    num = int(input())
    if num == 0:
        break
    
    scores = list(map(int, input().split()))
    average = sum(scores) / num
    
    variance = 0
    for i in range(num):
        variance += (scores[i] - average)**2
    variance = variance / num  
    
    standard_d = math.sqrt(variance)
    print(f"{standard_d:.10f}")
    


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

int prime[100010];
bool isprime[100010];
bool isprime2[100010];

int sieve(int n){
  int p = 0;
  for(int i = 0;i <= n;i++){
    isprime[i] = true;
  }
  isprime[0] = false;
  isprime[1] = false;
  for(int i = 2;i <= n;i++){
    if(isprime[i] == true){
      prime[p++] = i;
      for(int j = 2*i;j <= n;j += i){
        isprime[j] = false;
      }
    }
  }
}


int main(){
  int q;
  cin >> q;
  int l[q],r[q];
  for(int i = 0;i < q;i++){
    cin >> l[i] >> r[i];
  }
  sieve(100000);
  vector<int> like2017;
  for(int i = 2;i <= 100000;i++){
    if(isprime[i] == true && i <= 2*i-1){
      if(isprime[2*i-1] == true){
        like2017.push_back(2*i-1);
      }
    }
  }
  
  
  for(int i = 0;i < q;i++){
    cout << (upper_bound(like2017.begin(),like2017.end(),r[i]) - like2017.begin()) - (lower_bound(like2017.begin(),like2017.end(),l[i]) - like2017.begin()) << endl;
  }
}

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

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    int res = INF;
    for (int x = 1; x <= 100; x++) {
        int curr = 0;
        for (int i = 0; i < n; i++) {
            curr += (arr[i] - x) * (arr[i] - x);
        }
        res = min(res, curr);
    }
    cout << res << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{

  ll n,T,c[1010],t[1010];
  ll min=1e15;

  cin>>n>>T;
  rep(i,n)cin>>c[i]>>t[i];
  rep(i,n){
    if(t[i]<=T&&c[i]<min)min=c[i];
  }
  if(min==1e15){
    cout<<"TLE"<<endl;
    return 0;
  }
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 3648
use std::collections::HashMap;
use std::cmp::Ordering;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

pub trait BinarySearch<T> {
    fn upper_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    let a: Vec<i64> = read_vec();
    let n: usize = a[0] as usize;
    let m: i64 = a[1];

    let a: Vec<i64> = read_vec();
    let mut accum = vec![0i64; n];
    accum[0] = 0;

    for i in 1..n {
        accum[i] = (accum[i - 1] + a[i - 1]) % m;
    }
    let accum = accum;
    let sum = accum[n - 1] + a[n - 1];

    // println!("accum {:?}", accum);

    let mut rev_accum = vec![0i64; n + 1];
    rev_accum[n] = 0;
    rev_accum[n-1] = a[n-1] % m;

    for i in (0..n-1).rev() {
        rev_accum[i] = (rev_accum[i + 1] + a[i]) % m;
    }
    let rev_accum = rev_accum;

    // println!("rev_accum {:?}", rev_accum);

    let mut map = HashMap::new();
    for i in 0..n + 1 {
        (*map.entry(rev_accum[i]).or_insert(vec![])).push(i);
    }

    // println!("map {:?}", map);

    let mut ans: usize = 0;
    for i in 0..n {
        // println!("{:?}", ans);
        let res: i64 = (sum - accum[i] + m) % m;
        let matched: &Vec<usize> = map.entry(res).or_insert(vec![]);
        ans += matched.len() - matched.upper_bound(&(i));

        /*
        println!("i:{3} :res:{0} len:{1} upper:{2}",
                 res, matched.len(), matched.upper_bound(&i), i);
        println!("{:?}", matched);
        */

    }
    println!("{:?}", ans);
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

template <int N>
class Pow {
  private:
    vector<ll> table;
  public:
    Pow(int size) : table(size + 1){
        table[0] = 1;
        for (int i = 1; i <= size; ++i){
            table[i] = table[i - 1] * N;
        }
    }
    ll operator () (int i){return table[i];}
};

int main()
{
    scanInt(L);
    const int N = static_cast<int>(floor(log2(L))) + 1;
    Pow<2> pow2(N + 1);
    vector<tuple<int, int, int>> edges; edges.reserve(60);
    REP(i, N - 1){
        edges.emplace_back(i + 1, i + 2, 0);
        edges.emplace_back(i + 1, i + 2, pow2(i));
    }
    int used = pow2(N - 1);
    RREP(i, N - 1){
        if (L < used + pow2(i)) continue;
        edges.emplace_back(i + 1, N, used);
        used += pow2(i);
    }
    cout << N << " " << edges.size() << endl;
    for (auto& e : edges){
        cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << endl;
    }
}

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


public class Main {
    public static void main(String[] args) {

    	try{
    		InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int i=0;
			while(true){
				String buf = br.readLine();
				int x = Integer.parseInt(buf);
				if(x == 0) break;
				i++;
				System.out.println("Case "+i+": "+x);
    		}


    	} catch(IOException e) {
    		System.err.println(e);
		}
    }
}

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

int main(){
    int a,b,c,t;
    cin>>a>>b>>c;
    
    if(a>b){t=a;a=b;b=t;}
    if(a>c){t=a;a=c;c=t;}
    if(b>c){t=b;b=c;c=t;}
    
    cout<<a<<" "<<b<<" "<<c<<endl;
}



Measured memory_bytes: 3104
#coding:utf-8
n = int(input())
w = list(map(int, input().split()))
min = abs(w[0] - sum(w[1:n]))

for t in range(1,n):
    s1 = sum(w[0:t])
    s2 = sum(w[t:n])

    if abs(s1-s2) < min:
        min = abs(s1-s2)

print(min)

Measured memory_bytes: 3060
N = int(input())
nums = list(map(int, input().split()))
upper = True
lower = True
before = nums[0]
answer = 0
for i, num in enumerate(nums):
  if before < num:
    lower = False
  elif before > num:
    upper = False
  before = num
  if not upper and not lower:
    answer += 1
    upper = True
    lower = True
print(answer+1)

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<int> lgcd(N), rgcd(N);
  lgcd[0] = A[0];
  REP(i, N-1){
    lgcd[i+1] = gcd(lgcd[i], A[i+1]);
  }
  rgcd[N-1] = A[N-1];
  for(int i = N-1; i > 0; i--){
    rgcd[i-1] = gcd(rgcd[i], A[i-1]);
  }
  int ans = max(lgcd[N-2], rgcd[1]);
  FOR(i, 1, N-1){
    ans = max(ans, gcd(lgcd[i-1], rgcd[i+1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s, t;
  cin >> s >> t;
  int ns = s.size(), nt = t.size();
  for (int i = ns - nt; i >= 0; i--) {
    bool succ = true;
    for (int j = 0; j < nt; j++)
      if (s[i + j] != '?') succ &= (s[i + j] == t[j]);
    if (succ) {
      for (int j = 0; j < nt; j++) s[i + j] = t[j];
      for (int j = 0; j < ns; j++)
        if (s[j] == '?') s[j] = 'a';
      cout << s << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream> 
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x;
	scanf("%d",&x);
	if (x >= 30) {
		printf("Yes");
	} 
	else
		printf("No");
	return 0;
}
/*
4
8 3
2 3 2 1 3 3 2 1
6 3
2 3 2 3 2 3
8 3
2 3 2 1 3 3 2 1
12 4
1 2 3 4 4 3 2 1 2 4 1 3

*/

Measured memory_bytes: 3232
_ = readLine()
let As = readInts()
print(As.enumerated().filter { !($0+1).isMultiple(of: 2) && !$1.isMultiple(of: 2) }.count)


// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}


Measured memory_bytes: 8332
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int N;
int p[31];
inline void rote1() {
    swap(p[13],p[18]);
    swap(p[7],p[22]);
    swap(p[8],p[23]);
    swap(p[9],p[24]);
    swap(p[10],p[12]);
}
inline void rote2() {
    swap(p[15],p[16]);
    swap(p[1],p[28]);
    swap(p[2],p[29]);
    swap(p[3],p[30]);
    swap(p[19],p[21]);
}
inline void rote3() {
    swap(p[10],p[21]);
    swap(p[1],p[24]);
    swap(p[4],p[27]);
    swap(p[7],p[30]);
    swap(p[16],p[18]);
}
inline void rote4() {
    swap(p[12],p[19]);
    swap(p[3],p[22]);
    swap(p[6],p[25]);
    swap(p[9],p[28]);
    swap(p[13],p[15]);
}
bool ok(vector<int> vec) {
    int t=p[vec[0]];
    rep(i,vec.size()) if(t!=p[vec[i]]) return false;
    return true;
}
bool ok() {
    bool res=true;
    res&=ok({21,20,19});
    res&=ok({16,17,18});
    res&=ok({10,11,12});
    res&=ok({15,14,13});

    res&=ok({1,2,3,4,5,6,7,8,9});
    res&=ok({22,23,24,25,26,27,28,29,30});
    return res;
}

int dfs(int cnt) {
    if(ok()) return cnt;
    if(cnt>7) return INF;
    int res=INF;

    rote1();
    res=min(res,dfs(cnt+1));
    rote1();

    rote2();
    res=min(res,dfs(cnt+1));
    rote2();

    rote3();
    res=min(res,dfs(cnt+1));
    rote3();

    rote4();
    res=min(res,dfs(cnt+1));
    rote4();
    return res;
}

void solve() {
    rep(i,30) cin>>p[i+1];

    cout<<dfs(0)<<endl;
}

int main() {
    cin>>N;
    while(N-->0) solve();
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int numOfOdds = (N + 1) / 2;

	double ans = (double)numOfOdds / (double) N;
	// 出力の桁数を細かくする
	cout << fixed << setprecision(10) << ans << "\n";


	return 0;
}


Measured memory_bytes: 256
'use strict'

function main(s) {

  const n = s.split('\n')[0];

  let ans = 0;

  for (let i = 1; i <= (n.length / 2 - 1); i++) {
    const sliced = n.slice(0, -2 * i);
    const len = sliced.length;

    const head = sliced.slice(0, len / 2);
    const rest = sliced.slice(len / 2);

    if (head === rest) {
      ans = len;
      break;
    }
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
import sys

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

S = list(map(int, input()))

if S[-1] in [2,4,5,7,9]:
    print('hon')
elif S[-1] in [0,1,6,8]:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int a;
	string b;
	cin>>a>>b;
	int realB=0;
	if(b[0]-'0'){
		realB=(b[0]-'0');
	}
	
	realB*=10;
	realB+=(b[2]-'0');
	realB*=10;
	realB+=(b[3]-'0');

	int r=a*realB;
	r=r/100;
	cout<<r<<endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll H, W, h, w;
  cin >> H >> W >> h >> w;

  if (H % h == 0 && W % w == 0)
    FINALANS("No");

  bool swapped = false;
  if (W % w == 0)
  {
    swap(H, W), swap(h, w);
    swapped = true;
  }

  vector<vector<ll>> ans(H, vector<ll>(W));
  for (ll i = 0; i < H; i++)
  {
    ll a = 1e6;
    ll b = a * (w - 1) + 1;

    for (ll j = 0; j < W; j++)
    {
      ans.at(i).at(j) = ((j + 1) % w == 0) ? -b : a;
    }
  }

  cout << "Yes" << endl;
  if (swapped)
  {
    for (ll i = 0; i < W; i++)
    {
      for (ll j = 0; j < H; j++)
      {
        cout << ans.at(j).at(i) << ((j == H - 1) ? '\n' : ' ');
      }
    }
  }
  else
  {
    for (ll i = 0; i < H; i++)
    {
      for (ll j = 0; j < W; j++)
      {
        cout << ans.at(i).at(j) << ((j == W - 1) ? '\n' : ' ');
      }
    }
  }
}

Measured memory_bytes: 4224
#include <stdio.h>
#define PI 3.141592653589

int main(){
	double r;
	double area, perim;
	
	scanf("%lf", &r);
	area = r*r*PI;
	perim = 2*r*PI;

	printf("%f %f\n", area, perim);
	return 0;
}

Measured memory_bytes: 1076
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,0,n){
        int a;
        cin >> a;
        m[a]++;
    }

    int ans = 0;
    for(auto i:m){
        if(i.sd >= i.ft)ans += max(0,i.sd-i.ft);
        else ans += i.sd;
    }
    P(ans);
	
	return  0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int x; cin >> x;
    if(x == 7 || x == 5 || x == 3){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.Map as M
import Data.Maybe (fromJust)
import Data.Char (intToDigit)

pair::[Char]->(Char,Char)
pair x = (head x,last x)

solve::Int->Int->M.Map (Char,Char) Int->Int
solve i j m = case M.lookup (intToDigit i,intToDigit j) m of
              Just x -> x
              Nothing -> 0

main = do
  n <- readLn
  let hash = M.fromListWith (+) $ map (\x -> (pair x,1)) $ map show [1..n]
  print $ sum [(solve i j hash)*(solve j i hash) | i <- [1..9], j <- [1..9]]

Measured memory_bytes: 19836
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll n,i,ans=0; cin>>n;
    vector<string>s;
    unordered_map<string,ll>str;
    for(i=0;i<n;i++){
        string st; cin>>st;
        sort(st.begin(),st.end());
        if(str.find(st)!=str.end()){
            str[st]++;
        }else{
            str[st]=1;
            s.push_back(st);
        }
    }
    for(i=0;i<s.size();i++) ans+=((str[s[i]]*(str[s[i]]-1))/2);
    cout<<ans<<"\n";
}

Measured memory_bytes: 16024
N = input()
flag = True
if N[0] == '1':
  for i in range(1,len(N)):
    if N[i] != '9':
      flag = False
      break
  if not flag:
    print(9*(len(N)-1))
  else:
    print(1+9*(len(N)-1))
else:
  for i in range(1,len(N)):
    if N[i] != '9':
      flag = False
      break
  if not flag:
    print(9*(len(N)-1)+int(N[0])-1)
  else:
    print(9*(len(N)-1)+int(N[0]))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll mod = 1000000007;

//等差数列
ll sum(ll l, ll r) {
  return (l+r)*(r-l+1)/2;
}

int main() {
  int n,k;
  cin >> n >> k;
  ll ans = 0;
  for (int i=k; i <= n+1; i++) {
    ll l = sum(0,i-1);
    ll r = sum(n-i+1,n);
    ans += r-l+1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    long long int A,B,m=INT_MAX;
    cin>>A>>B;
    vector<long long int>v,v1;
    if((B-A)>=672){
        cout<<0<<endl;
    }else{
        
   for(long long int i=A;i<=B;i++ ){
       for(long long int j=i+1;j<=B;j++){
            m=min(m,(i*j)%2019);    
       }
   }
   cout<<m%2019<<endl;
   }
   
}


Measured memory_bytes: 256