akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/

const int maxn=3e5+10;
vi g[maxn];
int n,m,s,t;
int vis[maxn];
ll dis[maxn];
void bfs(int s,int t)
{
    vis[s]=1;
    queue<int> q;
    q.push(s);
    ll c=0;
    dis[s]=0;
    while(!q.empty())
    {
        c++;
        ll u=q.front();
        q.pop();
        for(auto i:g[u])
        {
            if(!vis[i])
            {
                dis[i]=dis[u]+1;
                vis[i]=1;
                q.push(i);
                if(i==t)
                {
                    cout<<dis[i]/3<<"\n";
                    return;
                }
            }
        }
    }
    cout<<"-1"<<"\n";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    rep(i,1,m)
    {
        int u,v;cin>>u>>v;
        g[u+2*n].pb(v);
        g[u+n].pb(v+2*n);
        g[u].pb(v+n);

    }
    cin>>s>>t;
    bfs(s,t);

    return 0;

    /*check for long long or int*/
}


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


int main()
{
    // cout << "A.cpp" << endl;

    int A, B;
    int multi;

    // 入力
    scanf("%d %d", &A, &B);

    if( A <= 9 && B <= 9 ) {
        multi = A * B;
    }
    else {
        multi = -1;
    }

    cout << multi << endl;

    return 0;
}


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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            var num = 0;

            foreach(var c in s) {
                if(c == '1') {
                    num++;
                }
            }

            Console.WriteLine(num);

            Console.Out.Flush();
        }
    }
}


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

typedef struct{
  int cnt;
  int hi;
}SU;
int main(){
  int n,m,a;
  SU s[100],temp;
  while(1){
    cin>>n>>m;
    if(!(n || m))break;
    for(int i=0;i<m;i++){
      s[i].hi=i+1;
      s[i].cnt=0;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin>>a;
	if(a)s[j].cnt++;
      }
    }
    for(int i=0;i<m-1;i++){
      for(int j=0;j<m-1-i;j++){
	if(s[j].cnt<s[j+1].cnt){
	  temp=s[j];
	  s[j]=s[j+1];
	  s[j+1]=temp;
	}
      }
    }
    for(int i=0;i<m;i++){
      cout<<s[i].hi;
      if(i!=m-1)cout<<" ";
      else cout<<endl;
  }
  }
}

Measured memory_bytes: 1160
from math import factorial


def comb(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(r) * factorial(n - r))


N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
cnt = 0
cnt2 = 0
for i in range(N):
    if v[i] > v[A]:
        cnt += 1
    if v[i] == v[A]:
        cnt2 += 1
avg_max = sum(v[:A]) / A
print(avg_max)
ans = 0
if v[0] != v[A]:
    print(comb(cnt2, A-cnt))
else:
    for i in range(A, min(B+1, cnt2 + 1)):
        ans += comb(cnt2, i)
    print(ans)


Measured memory_bytes: 3064
using System;

class P2012
{
  public static void Main()
  {
    int e = Int32.Parse(Console.ReadLine());
    while(e!=0)
      {
	int min = e;
	for(int i=0; i*i*i<=e; i++)
	  {
	    int z = i*i*i;
	    for(int j=0; j*j<=e-z; j++)
	      {
		int y = j*j;
		if(e-z-y>=0)min = Math.Min(min,i+j+(e-z-y));	
	      }
	  }

	Console.WriteLine(min);

	e = Int32.Parse(Console.ReadLine());
      }
  }
}

Measured memory_bytes: 5764
// https://beta.atcoder.jp/contests/abc063
// status: [review]

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;
using ui64 = uint64_t;
using i64 = int64_t;

const int MAX_N = 100000;
i64 h[MAX_N];
i64 N, A, B;
i64 diff;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(4 5 3
8
7
4
2
)");
#endif
    stream >> N >> A >> B;
    for (int i = 0; i < N; ++i) stream >> h[i];
    diff = A - B;

    i64 left = 0, right = static_cast<i64>(1e9);
    while (1 < right - left) {
        auto mid = (right + left) / 2;

        // Aで攻撃する必要がある回数の総和
        i64 sum_a_attack = 0;
        for (auto hi : h) {
            auto extra_cost = hi - mid * B;
            if (0 < extra_cost) sum_a_attack += (diff + extra_cost - 1) / diff;
            if (mid < sum_a_attack) break;
        }

        if (mid < sum_a_attack) left = mid;
        else right = mid;
    }
    cout << right << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<int, int> mc1, mc2;
	mc1[INF] = 0;
	mc2[INF] = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if (i & 1) mc1[x]++;
		else mc2[x]++;
	}
	vector<pair<int, int>> v1, v2;
	for (auto& p : mc1) v1.emplace_back(p.second, p.first);
	for (auto& p : mc2) v2.emplace_back(p.second, p.first);
	sort(v1.rbegin(), v1.rend());
	sort(v2.rbegin(), v2.rend());
	int ans = 0;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (v1[i].second == v2[j].second) continue;
			ans = max(ans, v1[i].first + v2[j].first);
		}
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define f(x,y,z) for(int x = y ; x <= z ; x++)
#define fs(arr,n) for(int i = 1 ; i <= n ; i++) cin >> arr[i];
#define fsm(arr,n,m) for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) cin >> arr[i][j];
#define fp(arr,n) for(int i = 1 ; i <= n ; i++) cout << arr[i] << " ";
#define fpm(arr,n,m) for(int i = 1 ; i <= n ; i++){ for(int j = 1 ; j <= m ; j++) {cout << arr[i][j] << " ";} cout << "\n"}
#define N 100005
using namespace std;
long long int n,l,r,say;
int main() 
{
    fast_io();
    cin >> n >> l >> r;
    long long int t = n-2;
    if(r < l)
      cout << "0" ;
	else if(r == l)
		printf("1");
	else if( r != l && n==1)
		printf("0");
    else
        cout << (r*t - l*t) + 1;
    
    
    return 0;
}

Measured memory_bytes: 256
#写経
#https://atcoder.jp/contests/abc176/submissions/16141246

import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    deq = np.empty(H * W + 100, np.int64)
    dist[S] = 0
    deq[0], l, r = S, 0, 1
    while l < r:
        v, l = deq[l], l + 1
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not (0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dist[v]:
                continue
            dist[w] = dist[v]
            deq[l - 1], l = w, l - 1
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dist[v] + 1:
                    continue
                dist[w] = dist[v] + 1
                deq[r], r = w, r + 1
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans

H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))

Measured memory_bytes: 118524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		if(a>b&&a>c &&a==b+c
				||b>a&&b>c&&b==a+c
				||c>a&&c>a&&c==a+b)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21844
<?php

$n = getOneLine();
$h = getLineExploded(' ');

$max = 0;
$count = 0;
foreach ($h as $height) {
    if ($max <= $height) {
        $count++;
        $max = $height;
    }
}

println($count);




function println($str)
{
    echo $str . "\n";
}

function sprintlnFormat($format, $str)
{
    println(sprintf($format, $str));
}

function getOneLine()
{
    $str = trim(fgets(STDIN));
    return $str;
}

function getLineExploded($delimiter = ' ')
{
    $str = getOneLine();
    $ret = explode($delimiter, $str);
    return $ret;
}

Measured memory_bytes: 4856
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Queue;
import java.util.Scanner;

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

        while(true) {
            String str = scanner.next();
            if (str.equals("-")) break;

            int m = scanner.nextInt();

            for (int i = 0; i < m; ++i) {
                int h = scanner.nextInt();
                str = str.substring(h) + str.substring(0, h);
            }

            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26460
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

bool isPrime(int n){
  int ii;
  for(ii=2;ii<=sqrt(n);ii++){
    if(n % ii == 0){
      return false;
    }
  }
  return true;
}

set<int> makePrime(int n){
  int ii,kk;
  set<int> s;

  for(ii=2;ii<=n;ii++){
    if(isPrime(ii)){
      s.insert(ii);
    }
  }
  
  return s;
}

int main(){

  long ii,jj,kk,n,cnt,val;
  vector<int> a;
  set<int> s;

  //s = makePrime(100000000);

  //for(auto val : s){
  //  cout << val << endl;
  //}
  
  cin >> n;

  cnt = 0;

  for(ii=0;ii<n;ii++){
    cin >> val;
    if(isPrime(val)){
      cnt++;
    }
  }

  cout << cnt << endl;
   
  return 0;
}



Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::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; }
using namespace std;

int main() {
    int N; cin >> N;
    int x[N];
    rep(i, N) {
        int a; cin >> a;
        int t = 0;
        while (a % 2 == 0) {
            t++;
            a /= 2;
        }
        x[i] = t;
    }
    int ans = 0;
    rep(i, N) ans += x[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#18:55
l = int(input())
s = bin(l)[2:]
n = len(s)
m = 0
ans = []
for i in range(n-1):
  ans.append([i+1,i+2,0])
  ans.append([i+1,i+2,2**(n-2-i)])
  m += 2
#print(ans,m)
imp = 2 ** (n-1)
for i in range(n-1,0,-1):
  if s[i] == '1':
    ans.append([1,i+1,imp])
    m += 1
    imp += 2 ** (n-1-i)
print(n,m)
for x in ans:
  print(' '.join(list(map(str,x))))

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int A,B;
    scanf("%d %d", &A, &B);
    if(A!=3 && B!=3)
    {
        printf("3\n");
    }
    else if(A!=2 && B!=2)
    {
        printf("2\n");
    }
    else
    {
        printf("1\n");
    }
    return 0;
}


Measured memory_bytes: 128
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[105]={},ans=0,cnt=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    if(a[i]==a[i+1]) {
      ans++;
      a[i+1]=10000+cnt;
      cnt++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=99824453;

int main(){
    int k;cin>>k;
    string s;
    rep(i,k)s+="ACL";
    cout<<s<<endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//scanner
		Scanner sc = new Scanner(System.in);
        //int a = Integer.parseInt(sc.next());
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

		sc.close();

        int ans;

        if(b%a==0){
            ans = a + b;
        }else{
            ans = b - a;
        }

		System.out.println(ans);
		
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

int n, a, b, c, d;
char s[200005];
bool nec[200005] = {0}, nec2[200005] = {0};
void init(){
    n = read(), a = read(), b = read(), c = read(), d = read();
    scanf("%s", s);
}
void solve(){
    --a, --b, --c, --d;
    // 无连续
    bool flag = true;
    REP(i, b + 1, d){
        if (s[i] == s[i - 1] && s[i] == '#'){
            flag = false;
            break;
        }
    }
    if (!flag){
        printf("No\n");
        return ;
    }
    REP(i, a + 1, c){
        if (s[i] == s[i - 1] && s[i] == '#'){
            flag = false;
            break;
        }
    }
    if (!flag){
        printf("No\n");
        return ;
    }
    if (c > d){
        nec[a] = nec[c] = true;
        REP(i, a + 1, c){
            if (s[i] == '#'){
                nec[i + 1] = nec[i - 1] = true;
            }
        }
        nec2[b] = nec2[d] = true;
        REP(i, b + 1, d){
            if (s[i] == '#'){
                nec2[i + 1] = nec2[i - 1] = true;
            }
        }
        int cntb = 0;
        REP(i, b, d) if (nec2[i] || s[i] == '#') ++cntb;
        if (cntb == d - b + 1){
            // 全部必须
            bool flag2 = true;
            REP(i, a, c){
                if (nec2[i] && !nec[i]){
                    flag2 = false;
                    break;
                }
            }
            if (flag2){
                printf("No\n");
            }else {
                printf("Yes\n");
            }
        }else {
            printf("Yes\n");
        }
    }else {
        printf("Yes\n");
    }
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  ll N = S.length();
  ll ans = 0;

  for (ll bit = 0; bit < 1 << N - 1; ++bit) {
    ll sum = 0;
    ll tmp = S[0] - '0';
    REP(i, N - 1) {
      if (bit & (1 << i)) {
        sum += tmp;
        tmp = 0;
      }
      tmp = tmp * 10 + S[i + 1] - '0';
    }
    sum += tmp;
    ans += sum;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>depth(N, MOD);
	vector<int>ddepth(N, MOD);
	Calculate_Depth(edge, depth, 0);
	int index = 0;
	for (int i = 1; i < N; i++) {
		if (depth[index] < depth[i])index = i;
	}
	Calculate_Depth(edge, ddepth, index);
	int iindex = 0;
	for (int i = 1; i < N; i++) {
		if (ddepth[iindex] < ddepth[i])iindex = i;
	}
	for (auto &i : depth)i = MOD;
	Calculate_Depth(edge, depth, iindex);
	vector<int>dis(N, MOD);
	queue<int>Q;
	for (int i = 0; i < N; i++) {
		if (ddepth[iindex] == depth[i] + ddepth[i]) {
			dis[i] = 0;
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (dis[i] > dis[cn]) {
				Q.push(i);
				dis[i] = dis[cn] + 1;
				if (dis[i] == 2) {
					cout << "-1\n";
					return 0;
				}
			}
		}
	}
	vector<int>route;
	int c = index;
	route.push_back(c);
	while (c != iindex) {
		for (auto i : edge[c]) {
			if (depth[i] == depth[c] - 1) {
				c = i;
				break;
			}
		}
		route.push_back(c);
	}
	vector<int>ret;
	ret.push_back(1);
	int nx = 2;
	for (int i = 1; i < route.size() - 1; i++) {
		for (int j = 0; j < edge[route[i]].size() - 2; j++) {
			ret.push_back(nx + j + 1);
		}
		ret.push_back(nx);
		nx++;
		nx += edge[route[i]].size() - 2;
	}
	ret.push_back(N);

	reverse(route.begin(), route.end());
	vector<int>bag;
	bag.push_back(1);
	nx = 2;
	for (int i = 1; i < route.size() - 1; i++) {
		for (int j = 0; j < edge[route[i]].size() - 2; j++) {
			bag.push_back(nx + j + 1);
		}
		bag.push_back(nx);
		nx++;
		nx += edge[route[i]].size() - 2;
	}
	bag.push_back(N);
	for (auto i : min(ret, bag)) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

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

typedef long long ll;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << "\n";
}

Measured memory_bytes: 3620
while True:
    
    yama = input()
    if yama == "-":
        exit()
    
    m = int(input())
    h = [int(input()) for _ in range(m)]
    
    for i in h:
        tmp = yama[:i]
        yama = yama[i:]
        yama += tmp
        
    print(yama)


Measured memory_bytes: 5604
#include<stdio.h>
#include<string.h>
int dx[]={0,1,0,-1,0};
char m[14][8];	//ツ氾板閉コツつソツづ。ツづア
bool f[14][8];
int F(int x,int y,char t)
{
	if(m[y][x]-t||f[y][x])return 0;
	f[y][x]=1;
	int r=1,i;
	for(i=0;i<4;++i)r+=F(x+dx[i],y+dx[i+1],t);
	return r;
}
void G(int x,int y,char t)
{
	if(m[y][x]=='O')m[y][x]=0;
	else if(m[y][x]==t)
	{
		m[y][x]=0;
		for(int i=0;i<4;++i)G(x+dx[i],y+dx[i+1],t);
	}
}
int H(int t)
{
	return t&&strchr("RGBYP",t);
}
int I(int t)
{
	return H(t)||(t=='O');
}
int main()
{
	int i,j,s,x,n,c,d;
	for(scanf("%d",&n);n--;)
	{
		for(i=0;i<12;++i)scanf("%s",m[i+1]+1);
		for(s=0;;)
		{
			x=0;
			for(i=1;i<=12;++i)for(j=1;j<=6;++j)
			{
				memset(f,0,sizeof(f));
				if(c=m[i][j], H(c)&&F(j,i,c)>3)
					G(j,i,c),++x;
			}
			if(!x)break;
			++s;
			for(j=1;j<=6;++j)
			{
				for(;;)
				{
					x=0;
					for(i=11;i>0;--i)
					{
						c=m[i+1][j];
						d=m[i][j];
						if(!I(c)&&I(d))m[i+1][j]=d,m[i][j]=0,++x;
					}
					if(!x)break;
				}
			}
		}
		printf("%d\n",s);
	}
	return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int in,max,min;
  cin>>in;
  max=in;
  min=in;

  cin>>in;
  if(max<in)max=in;
  if(min>in)min=in;
  cin>>in;
  if(max<in)max=in;
  if(min>in)min=in;
  cout<<max-min<<endl;
}


Measured memory_bytes: 256
var
  a,b,c:longint;
begin
  readln(a);
  readln(b);
  readln(c);
  writeln(a,' ',b,' ',3*c-a-b);
  writeln(4*c-2*a-b,' ',c,' ',2*a+b-2*c);
  writeln(a+b-c,' ',2*c-b,' ',2*c-a);
end.

Measured memory_bytes: 128
S = input()
n = len(S)

ans = 'AC'

if S[0] != 'A':
    ans = 'WA'

cnt = 0
for i in range(1, n):
    if S[i] == 'C' and (i >= 2 and i <= n-2):
        cnt += 1
    elif S[i] >= 'a' and S[i] <= 'z':
        continue
    else:
        ans = 'WA'
if cnt != 1:
    ans = 'WA'

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

template <typename T>
T fib(int n){
    std::vector<T> fibs{1, 1}; // using C++11
    for (int i = 2; i <= n; i++){
        fibs.push_back(fibs[i - 2] + fibs[i - 1]);
    }
    return fibs[n];
}

int main(){
    int n;
    std::cin >> n;
    std::cout << fib<int>(n) << std::endl;
}

Measured memory_bytes: 3160
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


ll n,a,b;

int main() {
	cin>>n>>a>>b;
	if (a%2==b%2) cout<<abs(a-b)/2<<endl;
	else {
		if (a>b) swap(a,b);
		ll aa = 1, bb = b-a+1;
		ll ans = a+(bb-1-aa)/2;
		ans = min(ans, n-b+1+(-a+b-1)/2);
		cout<<ans<<endl;
	}
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(0) 
 
const ll mod = 1e9+7;
const ll maxn = 1e6+10;

int main()
{
	fast_cin;
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	a-=b;
	if(k%2)
		a*=-1;
	cout << a;
}	
 



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

signed main(){
  int n, K; std::cin >> n >> K;
  std::vector<int> a(n);
  for(int i = 0; i < n; i++) std::cin >> a[i];
  int low = 0, high = 1e9+1;
  while(high - low > 1){
    int mid = (high + low) / 2;
    int cnt = 0;
    for(int i = 0; i < n; i++){
      cnt += (a[i] - 1) / mid;
    }
    if(cnt <= K) high = mid;
    else low = mid;
  }
  std::cout << high << std::endl;
}

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

int main() {
  int n;
  cin>>n;
  while(n>=10){
    n%=10;
  }
  if(n==3){
    cout<<"bon"<<endl;
  }else if(n==0||n==1||n==6||n==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3612
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

int i,n;string s;
cin>>s;n=s.length();
int c=0;
for(i=0;i<n/2;i++)
{
	if(s[i]!=s[n-1-i]) c++;
}
cout<<c;


return 0;
}

Measured memory_bytes: 256
//10/05/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
class NumberTheory{
public:
    ll n;
    bool chk[99999995];
    ll GetMod(ll x,ll m);
    ll BigMod (ll b,ll p,ll m){if (p == 0) return 1;if (p%2 == 0){ll s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
    ll ModInv (ll b,ll m){return BigMod(b,m-2,m);}
    ll gcd(ll a,ll b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
    ll lcm(ll a,ll b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
    void sieve(ll x);
    bool IsPrime(ll x);
    bool IsPrime1(ll x){return !chk[x];}
};

/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;

ll mark[200005];

int main(){
    _fastio
    ll n,k;
    cin>>n>>k;
    ll a[n+10];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }

    ll cnt=1;
    ll now=a[1];
    k--;
    ll dif=n;
    ll ans=-1;
    while(1){
        //cout<<now<<' ';
        if(k==0){
            ans=now;
            break;
        }
        if(now==1||mark[now]>=1){
            dif=cnt-mark[now];
            break;
        }
        k--;
        mark[now]=cnt;
       // cout<<mark[now]<<en;
        cnt++;
        now=a[now];

    }

    if(k==0) cout<<ans<<en;
    else{
        k=k%dif;
        while(k){
            now=a[now];
            k--;
        }
        cout<<now<<en;
    }





    return 0;
}

void NumberTheory::sieve(ll x){
    for(ll i=2;i*i<=x;){
        if(chk[i]==0){
            for(ll j=i*i;j<=x;j+=i){
                chk[j]=1;
            }
        }
        if(i==2) i++;
        else i+=2;
    }
}
bool NumberTheory::IsPrime(ll x){
    bool f=true;
    for(ll i=2;i*i<=x;i++){
        if(!x%i){
            f=false;break;
        }
    }
}
ll GetMod(ll x,ll m){
    if(x>=0) return x%m;
    else{
        ll y=abs(x)/m;x+=(y*m+m+m);
        return x%m;
    }
}


Measured memory_bytes: 6788
c = list(input())
ans = 0
for i in range(len(c)):
    j = i
    count = 0
    judge = True
    while judge and j <= len(c)-1:
        # print("a")
        if ((c[j] == "A") or (c[j] == "C") or (c[j] == "G") or (c[j] == "T")):
            judge = True
            count += 1
            j += 1
        else:
            judge = False
    ans = max(ans,count)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int x, a, b;
/**********************************************/

int main(){
    cin >> x >> a >> b;
    x -= a;
    while(x - b >= 0){
        x -= b;
    }

    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;
const int maxn = 1e5 + 4;
const ll inf = 1e18;

ll n, dp[maxn][3], seg[4 * maxn], s[maxn];

ll get (int id, int L, int R, int l, int r) {
	if (L == l and R == r)
		return seg[id];
	int mid = (L + R) >> 1;
	ll ret = inf;
	if (mid > l)
		ret = min (ret, get (2 * id + 0, L, mid, l, min (mid, r)));
	if (mid < r)
		ret = min (ret, get (2 * id + 1, mid, R, max (l, mid), r));
	return ret;
}

void build (int id, int L, int R) {
	if (L + 1 == R) {
		seg[id] = s[R] - s[L];
		return;
	}
	int mid = (L + R) >> 1;
	build (2 * id + 0, L, mid);
	build (2 * id + 1, mid, R);
	seg[id] = min (seg[2 * id + 0], seg[2 * id + 1]);
}

ll mindiff (int l, int r) {
	if (r == l + 1)
		return inf;
	return get (1, 0, n - 1, l, r - 1);
}

int main() {
	ios_base::sync_with_stdio(false);
	ll a, b;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	if (n == 1) {
		return cout << 2 << endl, 0;
	}
	
	build (1, 0, n - 1);

	dp[0][0] = 1;
	dp[0][1] = 1;
	for (int i = 1; i < n; i++) {
		int lo = -1, hi = i;
		while (hi - lo > 1) {
			int mid = (lo + hi) >> 1;
			if (s[i] - s[mid] >= a)
				lo = mid;
			else
				hi = mid;
		}
		if (hi == i) {
			dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
		}
		else {
			if (mindiff (hi, i) >= b) {
				dp[i][0] = dp[hi][1];
			}
		}
		
		lo = -1, hi = i;
		while (hi - lo > 1) {
			int mid = (lo + hi) >> 1;
			if (s[i] - s[mid] >= b)
				lo = mid;
			else
				hi = mid;
		}
		if (hi == i) {
			dp[i][1] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
		}
		else {
			if (mindiff (hi, i) >= a) {
				dp[i][1] = dp[hi][0];
			}
		}
	}
	cout << (dp[n - 1][0] + dp[n - 1][1]) % mod << endl; 
}


Measured memory_bytes: 6528
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BMinesweeper {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, w;
	    in >> h >> w;
	    string s;
	    vector<vector<char>> g(h, vector<char>(w)), resg(h, vector<char>(w));

	    for(int i=0; i<h; i++){
	        in >> s;
	        for(int j=0; j<w; j++){
	            g[i][j] = s[j];
	        }
	    }

        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                int cnt = 0;
                if(g[i][j] == '#'){
                    resg[i][j] = '#';
                    continue;
                }
                for(int k=0; k<8; k++){
                    int dlx = j + dx[k];
                    int dly = i + dy[k];
                    if(dlx < 0 || dlx >= w || dly < 0 || dly >= h) continue;
                    if(g[dly][dlx] == '#') cnt++;
                }
                resg[i][j] = cnt + '0';
            }
        }

        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                out << resg[i][j];
            }
            out << endl;
        }
	}
};


int main() {
	BMinesweeper solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int N;
    int total = 0;
    cin >> N;
    vector<int> W;
    for (int i = 0; i < N; i++) {
        int w;
        cin >> w;
        W.push_back(w);
        total += w;
    }
    int subTotal = W[0];
    int lastNumber = W[0];
    int minDiff = total;
    
    for (int i = 1; i < N; i++) {
        int diff = abs(total - 2 * subTotal);
        if (diff < minDiff) {
            minDiff = diff;
        }
        subTotal += W[i];
        lastNumber = W[i];
    }
    cout << minDiff;
    return 0;
}


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

int main(){
    int x;cin >> x;
    int r;

    if (x == 3 || x == 5 || x==7) {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	int num[1000] = {0};
	int i = 0;
	for (i = 0; i <= n - 1; i++) { scanf("%d", &num[i]); }
	float ans;
	float temp = 0;
	for (i = 0; i <= n - 1; i++) { temp += ((float)1 / (float)num[i]); }
	ans = 1 / temp;
	printf("%g", ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    static Scanner scanner;

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

        long a=gl();
        long b=gl();
        long c=gl();
        long d=gl();


        if(a>=0 && c>=0) {
            System.out.println(b*d);
        } else if(a>=0 && d<0) {
        	System.out.println(a*d);
        } else if(c>=0 && b<0) {
        	System.out.println(c*b);
        } else if(a>=0) {
        	System.out.println(b*d);
        } else if(c>=0) {
        	System.out.println(b*d);
        } else {
        	System.out.println(Math.max(a*c, b*d));
        }
    }

    // 文字列として入力を取得
    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: 35832
import sys
def input(): return sys.stdin.readline().strip()


def main():
    s = input()
    l = len(s)
    ans = l - 2
    for i in range(2, l):
        if i % 2 != 0: continue
        ns = s[:l-i]
        even = True
        for j, c in enumerate(ns):
            if j >= (l - i) // 2: break
            if c != ns[(l - i) // 2 + j]:
                even = False
                break
        if even:
            ans = l - i
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62032
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int N;

vector<int> a(3001);
auto dp = make_vec<ll>(3001,3001); 
auto flg = make_vec<int>(3001,3001); 

// [i,j]が残っている状態において、
// 左右どちらかを取った場合における(自分の総得点)-(相手の総得点)の最大値
// つまり、[i,j]対する問の答えになる
// 注：a[i]-dp[i-1]で常にどちらの手番であっても(自分の総得点)-(相手の総得点)になる
ll rec(int i,int j){
    if(flg[i][j]) return dp[i][j];

    flg[i][j]=1;
    if(i==j) return dp[i][j] = a[i];
    
    return dp[i][j] = max(a[i]-rec(i+1,j),a[j]-rec(i,j-1));
}

int main(){

    cin >> N;

    REP(i,N) cin >> a[i+1];
    fill_v(flg,0);

    pl(rec(1,N))
    
    return 0;
}

Measured memory_bytes: 106112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
int main() {
	int a, b, c, d, e, f;
	std::cin >> a >> b >> c;
	if (a == b)std::cout << c << std::endl;
	if (c == b)std::cout << a << std::endl;
	if (a == c)std::cout << b << std::endl;
	 return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=18;

int n, m, k, u, v, x, y, t, a, b;
ll tav[MAXN], dp0[MAXN], dp1[MAXN], ans;
int par[LOG][MAXN], sz[MAXN], A[MAXN*2], N;
int stt[MAXN], fnt[MAXN], h[MAXN], timer=1;
vector<int> G[MAXN], G2[MAXN], vec[MAXN];

void dfs(int node){
	stt[node]=timer++;
	for (int v:G[node]) dfs(v);
	fnt[node]=timer;
}

int Lca(int x, int y){
	if (stt[x]>stt[y]) swap(x, y);
	if (fnt[y]<=fnt[x]) return x;
	for (int i=LOG-1; ~i; i--) if (stt[x]<stt[par[i][y]]) y=par[i][y];
	return par[0][y];
}

inline bool is_par(int x, int y){
	return stt[x]<=stt[y] && fnt[y]<=fnt[x];
}
inline bool cmp(int x, int y){
	return stt[x]<stt[y];
}
inline ll powmod(ll a, ll b){
	ll res=1;
	for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod;
	return res;
}
inline ll inv(ll a){
	return powmod(a, mod-2);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tav[0]=1;
	for (int i=1; i<MAXN; i++) tav[i]=tav[i-1]*2%mod;
	cin>>n;
	for (int i=1; i<=n; i++){
		cin>>par[0][i];
		G[par[0][i]].pb(i);
		h[i]=h[par[0][i]]+1;
		vec[h[i]].pb(i);
	}
	for (int j=1; j<LOG; j++) for (int i=1; i<=n; i++) par[j][i]=par[j-1][par[j-1][i]];
	dfs(0);
	ans=tav[n];
	for (int i=1; vec[i].size(); i++){
		N=0;
		for (int j:vec[i]) A[N++]=j;
		sort(A, A+N, cmp);
		for (int j=N-1; j; j--) A[N++]=Lca(A[j], A[j-1]);
		sort(A, A+N);
		N=unique(A, A+N)-A;
		sort(A, A+N, cmp);
		
		stack<int> stk;
		stk.push(A[0]);
		for (int j=1; j<N; j++){
			while (!is_par(stk.top(), A[j])) stk.pop();
			G2[stk.top()].pb(A[j]);
			stk.push(A[j]);
		}
		for (int j=N-1; ~j; j--){
			int v=A[j];
			if (h[v]==i) dp0[v]=dp1[v]=sz[v]=1;
			else{
				sz[v]=dp1[v]=0;
				ll mul=1, t0=0;
				for (int u:G2[v]){
					sz[v]+=sz[u];
					if (dp0[u]) mul=mul*dp0[u]%mod;
					else t0++;
				}
				for (int u:G2[v]) if (t0-(dp0[u]==0)==0)
					dp1[v]=(dp1[v] + mul*inv(dp0[u])%mod*dp1[u])%mod;
				dp0[v]=(tav[sz[v]]-dp1[v])%mod;
			}
			G2[v].clear();
		}
		ans=(ans + dp1[A[0]]*tav[n+1-sz[A[0]]])%mod;
	}
	if (ans<0) ans+=mod;
	cout<<ans<<"\n";
	
	return 0;
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  int sum = 0;
  rep(i, N) {
    sum += A[i];
  }

  int cnt = 0;
  rep(i, N) {
    if(4 * M * A[i] >= sum) {
      ++cnt;
    }
  }

  if(cnt >= M) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
import math
from functools import reduce

def lcm_base(x, y):
  return (x*y)//math.gcd(x, y)

def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)

def lcm_list(umbers):
  return reduce(lcm_base, numbers, 1)

n = int(input())
t = []
for i in range(n):
  t_ = int(input())
  t.append(t_)
  
print(lcm(*t))

Measured memory_bytes: 9540
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class CAlchemist {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<double> V(n);
    for (auto &v: V) cin >> v;

    priority_queue<double, vector<double>, greater<double>> U;

    for (const auto &v: V)
        U.push(v);

    while (U.size() > 1){
        double a = U.top(); U.pop();
        double b = U.top(); U.pop();
        U.push((a + b) / 2);
    }

    cout << setprecision(10) << U.top() << endl;
}
};

int main() {
	CAlchemist solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s(n);

    REP(i, n) cin >> s[i];

    sort(s.begin(), s.end());

    REP(i, n) cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 384