akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


bool comp1(pair<ll,ll>& a,pair<ll,ll>& b){
    return a.F<b.F;
}


bool comp2(pair<ll,ll>& a,pair<ll,ll>& b){
    return a.F>b.F;
}

void solve(){  
    ll a,b,n;
    cin>>a>>b>>n;
    if(n>=b)
    n=b-1;
    ll ans=0;
    for(ll i=1;i<=a;i++){
        ll cur=(i*n)/b;
        ans=max(ans,cur);
    }
    cout<<ans;
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
    
   while(test--)
   solve();
}

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



Measured memory_bytes: 3652
n = int(input())
an = [int(input()) for num in range(n)]

answer = False
count = 1
index = 1
while(True):
  if count > len(an):
    break
  if an[index-1] == 2:
    answer = True
    break
  index = an[index-1]
  count += 1

if answer :
  print(count)
else :
  print(-1)  

Measured memory_bytes: 12936
#include <stdio.h>

void swap(long a, long b){
  long c;
  c=a;
  a=b;
  b=c;
  return;
}

long gcm(long a, long b){
  long newa, newb;
  if(a<b) swap(a,b);
  while(b){
    newa=b;
    newb=a%b;
    a=newa;
    b=newb;    
  }  
  return a;
}

long countdiv(long all, long b, long c){
  long divc=all/c;
  if(b%c < all%c) divc++;
  return divc++;  
}

int main()
{
  long a,b,c,d;
  scanf("%ld%ld%ld%ld", &a, &b, &c, &d);
  long all=b-a+1;
  long divc=countdiv(all,b,c);
  long divd=countdiv(all,b,d);
  long divcd=countdiv(all,b,c*d/gcm(c,d)); 
  printf("%ld\n", all-divc-divd+divcd);
  return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty rnd(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int k; cin >> k;
	string s; cin >> s;

	int n = s.size();
	for (int i = 0; i < min(k, n); i++) cout << s[i];
	if (s.size() > k) cout << "...";
	cout << "\n";
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

void Main()
{
  ll n, t; cin >> n >> t;
  vll T(n); rep(i, n) cin >> T[i];
  ll ans = n * t;
  for(ll i = 1;i < n;i++)
  {
    if(T[i - 1] + t > T[i])
    {
      ans -= abs(T[i - 1] + t - T[i]);
    }
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACookieExchanges solver = new ACookieExchanges();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACookieExchanges {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] arr = new int[3];
            arr[0] = in.nextInt();
            arr[1] = in.nextInt();
            arr[2] = in.nextInt();
            Arrays.sort(arr);
            if (arr[0] == arr[1] && arr[1] == arr[2]) {
                if (arr[0] % 2 == 0) {
                    out.println(-1);
                } else {
                    out.println(0);
                }
                return;
            }
            int cnt = 0;
            while (arr[0] % 2 != 1 && arr[1] % 2 != 1 && arr[2] % 2 != 1) {
                int temp1 = (arr[0] + arr[1]) / 2;
                int temp2 = (arr[0] + arr[2]) / 2;
                int temp3 = (arr[1] + arr[2]) / 2;
                arr[0] = temp1;
                arr[1] = temp2;
                arr[2] = temp3;
                Arrays.sort(arr);
                cnt++;
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 23508
/*input

*/

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i < b;i++)
#define rrep(i,b,a) for(int i=b ; i > a ; i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define check1(a) cerr << a << endl
#define check2(a,b) cerr << a << "|" << b << endl
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
/*----------------------------------------------*/
const int MAX = (int)2e5 + 10;
int n;
int arr[MAX];
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    rep(i,0,n){
    	cin >> arr[i];
    }
    vector<ll> pref;
    pref.pb(0);
    rep(i,0,n){
    	pref.pb(pref.back()+arr[i]);
    }
    ll sum = pref.back();
    ll diff = (ll)1e18;
    rep(i,1,n){
    	ll z1 = pref[i];
    	ll z2 = sum-pref[i];
    	// check2(z1,z2);
    	diff = min(diff,abs(z2-z1));
    }
    cout << diff;
}


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;


class Program
{

    static void Main(string[] Args) {
        var list = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();

        int Result = 0;
        if(list[0] + list[1] < list[2]) {
            Result += list[0] + list[1] + 1;
        } else {
            Result += list[2];
        }
        Result += list[1];
        WriteLine(Result);

        ReadLine();
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cmath>

#define calc(x, y) (M_PI*(y-x)/180.0)

using namespace std;

double a, b, c, d;

double solve()
{
  double s = calc(a, 90.0), t = calc(c, 90.0), u = cos(calc(b, d));

  return acos(cos(s)*cos(t)+sin(s)*sin(t)*u);
}

int main()
{
  while(cin>>a>>b>>c>>d && !(a == -1 && b == -1 && c == -1 && d == -1)){
    a = 6378.1*solve();
    int p = 0;
    if((a-(int)a)*10 >= 5) p = 1;
    cout << (int)a+p << endl;
  }
	
  return 0;
}

Measured memory_bytes: 0
def main():
    n = int(input())
    p = n * 25 // 27
    a, b = int(p * 1.08), int((p + 1) * 1.08)
    if a == n:
        print(p)
    elif b == n:
        print(p + 1)
    else:
        print(":(")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[1005];
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int sum=0;
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++){
        sum+=a[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3764
class Combination:
    def __init__(self, n_max=10**6, mod=10**9+7):
        # self._n_max = n_max
        self._fac, self._finv, self._inv = [0]*n_max, [0]*n_max, [0]*n_max
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        for i in range(2, n_max):
            self._fac[i] = self._fac[i - 1] * i % MOD
            self._inv[i] = MOD - self._inv[MOD%i] * (MOD // i) % MOD
            self._finv[i] = self._finv[i - 1] * self._inv[i] % MOD
    def com(self, n, r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[r] * self._finv[n - r] % MOD) % MOD


MOD = 10**9+7
# comb.com(10,3)
comb = Combination(10**5+1, MOD)
n,k = map(int, input().split())
al=list(map(int, input().split()))  
al.sort(reverse=True)

fmax = 0
for i,a in enumerate(al):
    cnt = comb.com(n-i-1,k-1)
    fmax += cnt*a
    fmax%=MOD

al.sort()
fmin = 0
for i,a in enumerate(al):
    cnt = comb.com(n-i-1,k-1)
    fmin += cnt*a
    fmin%=MOD

ans = fmax-fmin
ans%=MOD
print(ans)

Measured memory_bytes: 85156
import math
a,b,x=map(int,input().split())
if a*a*b>=2*x:
  print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
  s=a*a*b-x
  print(math.degrees(math.atan(2*s/(a*a*a))))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <utility>
using namespace std;

int partition(int a[], int p, int r);

int main(void)
{
	int n;
	cin >> n;
	int *a = new int[n];

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

	int q = partition(a, 0, n - 1);

	cout << a[0];
	for (int i = 1; i < n; i++) {
		cout << " ";
		if (i == q) cout << "[" << a[i] << "]";
		else cout << a[i];
	}
	cout << endl;

	return 0;
}

int partition(int a[], int p, int r)
{
	int x = a[r];
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (a[j] <= x) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}

Measured memory_bytes: 3500
import sys
mod = 10 ** 9 + 7
sys.setrecursionlimit(mod)
input = sys.stdin.readline

def root(v):
    if v == par[v]:
        return v
    par[v] = root(par[v])
    return par[v]

def unite(u, v):
    u = root(u)
    v = root(v)
    if u == v:
        return
    if rank[u] < rank[v]:
        u, v = v, u
    par[v] = u
    if rank[u] == rank[v]:
        rank[u] += 1

def same(u, v):
    return root(u) == root(v)

def kruskal(edges):
    tree = [[] for _ in range(N)]
    used = [False] * M
    weight = 0
    for i, (w, u, v) in enumerate(edges):
        if same(u, v):
            continue
        unite(u, v)
        weight += w
        tree[u].append((w, v))
        tree[v].append((w, u))
        used[i] = True
    return weight, tree, used

def dfs(v=0, p=-1, d=0, w=0):
    parent[0][v] = p
    depth[v] = d
    max_w[0][v] = w
    for w, u in T[v]:
        if u == p:
            continue
        dfs(u, v, d+1, w)

def lca(u, v):
    if depth[u] > depth[v]:
        u, v = v, u
    tmp = 0
    while depth[v] > depth[u]:
        diff = depth[v] - depth[u]
        k = diff.bit_length() - 1
        tmp = max(tmp, max_w[k][v])
        v = parent[k][v]
    if u == v:
        return tmp
    for k in range(logN-1, -1, -1):
        if parent[k][u] != parent[k][v]:
            tmp = max(tmp, max_w[k][u], max_w[k][v])
            u = parent[k][u]
            v = parent[k][v]
    return max(tmp, max_w[0][u], max_w[0][v])

def modpow(x, p):
    if p == 0:
        return 1
    elif p == 1:
        return x % mod
    if p % 2 == 1:
        return x * modpow(x, p-1) % mod
    return modpow(x * x % mod, p // 2) % mod

N, M = map(int, input().split())
logN = (N - 1).bit_length()
X = int(input())
E = [tuple()] * M
for i in range(M):
    u, v, w = map(int, input().split())
    E[i] = (w, u-1, v-1)
E = sorted(E, key=lambda x: x[0])
par = list(range(N))
rank = [1] * N
W, T, F = kruskal(E)
depth = [0] * N
parent = [[0] * N for _ in range(logN+1)]
max_w = [[0] * N for _ in range(logN+1)]
dfs()
for k in range(logN):
    for v in range(N):
        if parent[k][v] < 0:
            parent[k+1][v] = -1
            max_w[k+1][v] = max_w[k][v]
        else:
            parent[k+1][v] = parent[k][parent[k][v]]
            max_w[k+1][v] = max(max_w[k][v], max_w[k][parent[k][v]])

le = 0
eq = 0
ge = 0
for i, (w, u, v) in enumerate(E):
    s = W
    if not F[i]:
        s += (w - lca(u, v))
    if s < X:
        le += 1
    else:
        if s == X:
            eq += 1
        else:
            ge += 1
ans = 0
if eq != 0:
    if le == 0:
        ans = (modpow(2, eq) - 2) * modpow(2, ge) % mod
    else:
        ans = 2 * (modpow(2, eq) - 1) * modpow(2, ge) % mod
print(ans)

Measured memory_bytes: 4596
import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();
			long ac = a*c;
			long ad = a*d;
			long bc = b*c;
			long bd = b*d;
			long max = Math.max(ac, Math.max(ad, Math.max(bc, bd)));
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 35664
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
    	String[] sai = br.readLine().split(" ");
    	Integer q = Integer.parseInt(br.readLine());
    	int[] newsai = new int[6];
    	int a =  0;
    	
    	for (int i = 0; i < 6; i++)
    	{
    		newsai[i] = Integer.parseInt(sai[i]);
    	}
    	
    	for (int i = 0; i < q; i++)
    	{
    		String[] order = br.readLine().split(" ");
    		int ue = Integer.parseInt(order[0]);
    		int mae = Integer.parseInt(order[1]);
    		
    		if (ue == newsai[2] || ue == newsai[3]) //????????¢??????????¨??????????????¢????
    		{
    			a = newsai[1];
    			newsai[1] = newsai[2];
    			newsai[2] = newsai[4];
    			newsai[4] = newsai[3];
    			newsai[3] = a;
    		}
    		
    		while (true) //????????¢????????¢????????£???????????????
    		{
    			if (ue ==newsai[0])
    				break;
    			a = newsai[0];
    			newsai[0] = newsai[1];
    			newsai[1] = newsai[5];
    			newsai[5] = newsai[4];
    			newsai[4] = a;
    		}
    		while (true)
    		{
    			if (mae ==newsai[1])
    				break;
    			a = newsai[1];
    			newsai[1] = newsai[2];
    			newsai[2] = newsai[4];
    			newsai[4] = newsai[3];
    			newsai[3] = a;
    		}
    		System.out.println(newsai[2]);
    	}
    	
	}
}

Measured memory_bytes: 24520
open Batteries

module IntSet = Set.Make (struct
  let compare = Pervasives.compare

  type t = int
end)

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f n acc = function
  | [] -> if n = 0 then acc else acc - 1
  | x :: rest -> if n >= x then f (n - x) (acc + 1) rest else acc

let () =
  let _, x = read_two () in
  let a = read_list () |> List.sort compare in
  let ans = f x 0 a in
  print_int ans;
  print_newline ()


Measured memory_bytes: 1280
N = gets.to_i
MOD = 10 ** 9 + 7
as = gets.split.map(&:to_i)
lcm = as.reduce(1) do |acc, a|
  acc.lcm(a)
end
ans = 0
as.each do |a|
  ans = (ans + (lcm / a) % MOD) % MOD
end
puts ans

Measured memory_bytes: 75516
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)
	m := make(map[int]*struct {
		ac, p int
		ok    bool
	}, N)

	var p, ac int
	for i := 0; i < M; i++ {
		var a int
		var b string
		fmt.Scanf("%d %s\n", &a, &b)
		if _, e := m[a]; !e {
			m[a] = &struct {
				ac, p int
				ok    bool
			}{}
		}
		if m[a].ok {
			continue
		}
		if b == "AC" {
			m[a].ac += 1
			m[a].ok = true
		} else {
			m[a].p += 1
		}
	}
	for _, v := range m {
		if !v.ok {
			continue
		}
		p += v.p
		ac += v.ac
	}
	fmt.Println(ac, p)

}


Measured memory_bytes: 9088
#include <stdio.h>
int main(void){
    int S;
    scanf("%d",&S);
    int h,m,s;
    
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    
    
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 1996
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  string s; cin >> s;
  ll n = s.size()/2 - 1;
  while(true){
    if(s.substr(0,n) == s.substr(n,n)) break;
    n--;
  }
  cout << 2*n << endl;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int M = cin.nextInt();
        int[] flag = new int[N];
        for (int i = 0; i < M; i++)
        {
            int K = cin.nextInt();
            for (int j = 0; j < K; j++)
            {
                int a = cin.nextInt();
                flag[a - 1] |= (1 << i);
            }
        }

        int ans = 0;
        int start = 0;
        for (int i = 0; i < M; i++)
        {
            start |= cin.nextInt() << i;
        }

        for (int i = 0; i < (1 << N); i++)
        {
            int now = start;
            for (int j = 0; j < N; j++)
            {
                if ((i >> j) % 2 == 0) continue;
                now ^= flag[j];
            }
            if (now == 0)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
	int n;cin>>n;
	string ans="APPROVED";
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;
		if(x%2==0 && x%3!=0 && x%5!=0)
		{
			ans="DENIED";
			break;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  	string S, T;
  	cin >> S >> T;
  	int NS=S.length();
  	int NT=T.length();
  	int count=NT;
  	for(int i=0;i<=NS-NT;i++){
      	int tmp=0;
      	for(int j=0;j<NT;j++){
          	if(S[i+j]!=T[j]) tmp++;
        }
      	count=min(count, tmp);
    }
  	cout << count << endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void){
   
    int a,b;
    cin>>a>>b;

    if(0<a && a < 10){
        if(0<b && b<10){
            cout<<a*b<<endl;
        }else{
            cout<<-1<<endl;
        }
    }
    else{
        cout<<-1<<endl;
    }
    


//   cout<< <<endl;

    return 0;
}

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

int main() {
    string s;
    cin>>s;
    if(s.size()>=6)
    {
    	if(s[2]==s[3] && s[4]==s[5])
    	{
    		cout<<"Yes"<<endl;
    		
    	}
    	else
    	cout<<"No"<<endl;
    }
    else
    cout<<"No"<<endl;	
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();

    let mut cutted = true;
    let mut is_increasing = true;

    let mut ans = 1;
    for i in 1..n {
        if cutted {
            if a[i] == a[i - 1] {
                continue;
            } else {
                cutted = false;
                is_increasing = a[i] > a[i - 1];
            }
        } else {
            if is_increasing && a[i] < a[i - 1] || !is_increasing && a[i] > a[i - 1] {
                ans += 1;
                cutted = true;
            }
        }
    }

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

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()
}


Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int main()
{
    int A, B, C, X;
    int counter = 0;
    cin >> A >> B >> C >> X;
    for (int n_a=0; n_a<A+1; n_a++) {
        for (int n_b=0; n_b<B+1; n_b++) {
            for (int n_c=0; n_c<C+1; n_c++) {
                //cout << n_a << n_b << n_c << endl;
                if((500*n_a+100*n_b+50*n_c==X)) counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    double l;
    cin >> l;
    double ans;
/*
    if ( ans%3 == 0 ) {
        ans = pow((l/3), 3);
    } else {

    }*/
    ans = pow(l, 3)/27;
    cout << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main(void)
{
  string a, b;
  cin >> a >> b;

  if (a.size() < b.size()) printf("LESS");
  else if (a.size() > b.size()) printf("GREATER");
  else if (a.size() == b.size()) {
    if (a == b) {
      printf("EQUAL");
    }else{
      for (int i = 0; i < a.size(); i++) {
        if (a[i] > b[i]) {
          printf("GREATER");
          break;
        }else if (a[i] < b[i]) {
          printf("LESS");
          break;
        }else if (a[i] == b[i]) {
          i++;
        }
      }
    }
  }


  return 0;
}


Measured memory_bytes: 256
import numpy as np
H, W = map(int, input().split())
a = np.array([list(input()) for _ in range(H)])

row_ind = np.where(np.all(a==['.']*(np.shape(a)[1]) ,axis=1))
a = np.delete(a, row_ind, axis=0)

col_ind = np.where(np.all(a==[['.']]*(np.shape(a)[0]), axis=0))
a = np.delete(a, col_ind, axis=1)

for i in range(np.shape(a)[0]):
    print(''.join(a[i,:]))

Measured memory_bytes: 12516
import copy

while True:
    n = int(input())
    if n == 0:
        break
    h = list(map(int, input().split()))

    for i in range(n+1):
        k = copy.deepcopy(h)
        kanade = k.pop(i)
        res = []
        for j in range(n-1):
            res.append(k[j+1] - k[j])
    
        if all([1 if x == res[0] else 0 for x in res]):
            print(kanade)
            break

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


int main() {
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+') {
        cout << (a + b) << endl;
    } else {
        cout << (a - b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math

def main():
    H = int(input())
    x = math.log2(H)
    if(float.is_integer(x)):
        res = math.pow(2,x+1)-1
    else:
        res = math.pow(2,math.floor(x)+1)-1
    print(int(res))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <cstdio>

int main()
{
  int N;

  scanf("%d", &N);

  for (int i = 0; i * 4 <= N; i++)
  {
    for (int j = 0; j * 7 <= N; j++)
    {
      if (i * 4 + j * 7 == N)
      {
        printf("Yes\n");
        return 0;
      }
    }
  }

  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[n];
		for (int i=0;i<n;i++)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		int count=0;
		long sum=0;
		for (int i=0;i<n;i++) {
			sum+=a[i];
			if (sum==x || (i!=n-1 && sum<x)) count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      int k;
      cin>>k;
      cout<<a[k-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long llong;

using namespace std;

int main () {
  llong coord;
  cin >> coord;

  llong ans = 0;
  for (llong i = 1 << 17; i > 0; i /= 2) {
    llong cur = ans + i;
    if (cur * (cur + 1) / 2 < coord) {
      ans = cur;
    }
  }

  cout << ans + 1 << endl;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const deque<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> inline void chmax(T& a, const T b){a=max(a,b);}
template <class T> inline void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int A,B; cin >> A >> B;
	for(int i = 1; i <= 200000; ++i) {
		double x = i;
		int C = x*0.08;
		int D = x*0.10;
		corner(C==A && D == B, i); 
	}
	cout << -1 << endl;

	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int a, b;
  
  a = (A * (A - 1)) / 2;
  b = (B * (B - 1)) / 2;
  
  cout << a + b << endl;
}


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


int main(){
  long long n;
  cin >> n;
  int keta=1;
  long long a=n;
  bool ha=true;
  long long c;
  while(1){
    if(a/10==0){
      c=a;
      break;
    }else{
      if(a%10!=9) ha=false;

      a=a/10;
      keta++;
    }
  }
  long long ans;
  if(ha==true){
    ans=c+9*(keta-1);
  }else{
    ans=c+9*(keta-1)-1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int aa[200001], bb[200001];
int main() {
	int n, a, sum = 0; cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		if (a != h) {
			sum++;
		}
	}
	if (sum == 0 || sum == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int Z;
int W;
int A[2000];
int main(){
  int res;
  rd(N);
  rd(Z);
  rd(W);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  if(N==1){
    res = abs(A[0] - W);
  }
  else{
    res =max_L(abs(A[N-2] - A[N-1]), abs(A[N-1] - W));
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, Z, W, A[2000];
// {
//   int res;
//   rd(N,Z,W,A(N));
//   if(N==1) res = abs(A[0] - W);
//   else     res = max(abs(A[N-2] - A[N-1]), abs(A[N-1] - W));
//   wt(res);
// }


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

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

void dump(const vector<int> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

int main()
{
	REP(i, 51){
		int m, f, r;
		cin >> m >> f >> r;

		if(m == -1 && f == -1 && r == -1)
			break;
		
		if(m == -1 || f == -1){
			cout << "F" << endl;
		}
		else if(m + f >= 80){
			cout << "A" << endl;
		}
		else if(m + f >= 65){
			cout << "B" << endl;
		}
		else if(m + f >= 50){
			cout << "C" << endl;
		}
		else if(m + f >= 30){
			if(r >= 50){
				cout << "C" << endl;
			}
			else{
				cout << "D" << endl;
			}
		}
		else{
			cout << "F" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3116
def bellman_ford(vertex_num, start, edges, inf = Float::INFINITY)
  dist = Array.new(vertex_num, inf)
  dist[start] = 0
  vertex_num.times do |i|
    update = false
    edges.each do |e|
      if dist[e.to] > dist[e.from] + e.cost
        dist[e.to] = dist[e.from] + e.cost
        update = true
        dist[e.to] = -inf if i == vertex_num - 1
      end
    end
    break unless update
  end
  dist
end



Edge = Struct.new(:from, :to, :cost)
v, e, r = gets.split.map(&:to_i)
edges = []
e.times do
  s, t, d = gets.split.map(&:to_i)
  edges << Edge.new(s, t, d)
end
dist = bellman_ford(v, r, edges)
if dist.any? { |d| d == -Float::INFINITY }
  puts "NEGATIVE CYCLE"
else
  puts dist.map { |x| x == Float::INFINITY ? "INF" : x }
end



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

int main() {

  int a=0, b=0;
  string op;

  while(1) {

    cin >> a >> op >> b;

    if(op=="+") {

      cout << a+b << endl;
    
    } else if(op=="-") {

      cout << a-b << endl;
    
    } else if(op=="*") {

      cout << a*b << endl;
    
    } else if(op=="/") {

      cout << a/b << endl;
    
    } else if(op=="?") {

      break;
    
    }

  }
  
  return 0;
}


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

int main(){
    int a,b,c,ans;
    cin >> a >> b >> c;
    ans = c - a + b;
    if(ans < 0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector< vector<int> > vv32;
typedef vector< vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1000000007;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

// if needed
void solve()
{

}

int main()
{
    //variables
    string s,t;
    ll k;
    ll flag=0;
    //inputs
    cin>>s>>k;
    t = s;
  

    // logic
    char a,b;	
    ll ans=0,ans1=0;    
    ll num=0;
    if(s.length()==1)
    {
        cout<<k/2;
        return 0;
    }
    for(ll i=1;i<s.length();i++)
    {
        if(s[i]!=s[i-1])
        {
            flag=1;
        }
    }
    for(ll i=0;i<s.length();i++)
    {
        if(i==0)
        {
            a=t[i];
        }
        else
        {
            b=t[i];
        }
        if(i>0)
        {
            if(b==a)
            {
                ans+=1;
                a = '\0';
            }
            else
            {
                a=b;
            }
            
        }
    }
    t = s+s;
    for(ll i=0;i<t.length();i++)
    {
        if(i==0)
        {
            a=t[i];
        }
        else
        {
            b=t[i];
        }
        if(i>0)
        {
            if(b==a)
            {
                ans1+=1;
                a = '\0';
            }
            else
            {
                a=b;
            }
            
        }
    }
    if(k==1)
    {
        cout<<ans;
        return 0;
    }
    if(flag==0)
    {
        if(s.length()%2==0)
        {
            cout<<ans*k;
        }
        else
        {
            cout<< ans*k + k/2;    
        }
        return 0;
    }
    if(ans1==2*ans)
    {
        cout<<ans*k;
    }
    else
    {
        cout<<ans*k+ k-1;
    }
    

    // cout<<ans;

	return 0;
}


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

using namespace std;

long long int t=0,f=0,n,h,k=0,p[1010];
char a[1010];

int main(){

cin >> n;
for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]=='0')f+=1;
}
//cout << f;
cin >> h;
k=0;
int j=0;
if(f>=h){
while(1){
    if(k==h)break;
    if(a[j]=='0'){
        a[j]='1';
        k+=1;
    }
    j++;
}
}
else if(f<h){
    for(int j=0;j<n;j++)if(a[j]=='0'){a[j]='1';p[j]=1;}
    for(int i=(n-1);i>=0;i--){
        if(p[i]==0){
        a[i]='0';
        t+=1;
        }
        if(t==(h-f))break;
    }
}
for(int y=0;y<(n-1);y++){
    cout << a[y];
}
cout << a[n-1] << endl;
return 0;
}

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

//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    int n,W;
    cin>>n>>W;
    
    vector<vector<int>> dp(n+1,vector<int>(W+1));
    vector<int> v(n),w(n);
    rep(i,n)cin>>v.at(i)>>w.at(i);
    
   
   rep(i,W+1)dp.at(0).at(i)=0;
   
   for(int i=0;i<n;i++){
       for(int j=1;j<=W;j++){
         if(w.at(i)<=j)dp.at(i+1).at(j)=max(dp.at(i).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
         else dp.at(i+1).at(j)=dp.at(i).at(j);
       }
        
   }
   
    cout<<dp.at(n).at(W)<<endl;
}
  




Measured memory_bytes: 6756
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

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

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

vector<int> p;

void init(int n){
    p.resize(n);
    for(int i = 0; i < n; i++)  p[i] = i;
}

int findSet(int x){
    if(p[x] != x){
        p[x] = findSet(p[x]);
    }
    return p[x];
}

void unite(int a, int b){
    int pa = findSet(a), pb = findSet(b);
    p[pa] = pb;
}

bool same(int a, int b){
    return findSet(a) == findSet(b);
}

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

    init(n+m+2);

    for(int i = 1; i <= n; i++){
        int k, l;
        cin >> k;

        for(int j = 0; j < k; j++){
            cin >> l;
            unite(i, n+l);
        }
    }

    for(int i = 2; i <= n; i++){
        if(!same(1, i)){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    double L; cin >> L;

    cout << fixed << setprecision(15);
    cout << pow(L / 3, 3) << endl;
    return 0;
}

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

#define vc vector
#define pb push_back
#define pf push_front
#define pr pair
#define mp make_pair
#define fi first
#define se second
#define uset unordered_set
#define umap unordered_map
#define str string
#define pq priority_queue
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define forr(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a) forn(i, 0, a)
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.end()
#define len(x) (int)x.size()
#define last(x) x[len(x)-1]
#define forall(i, x) for(auto &i : x)
#define endl '\n'

#define int long long
#define pii pr<int, int>
#define vi vc<int>

const int MAX = 1E6;

inline void fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

int trace(int x, int *p){
    if(p[x] == x) return x;
    int y = trace(p[x], p);
    p[x] = y;
    return y;
}

signed main()
{
    fastio();
    int n, m, k; cin >> n >> m >> k;
    int p[n], s[n], ans[n], f[n];
    rep(i, n){
        p[i] = i;
        s[i] = 1;
        f[i] = 0;
    }
    rep(i, m){
        int x, y; cin >> x >> y;
        f[--x]++; f[--y]++;
        int xx = trace(x, p), yy = trace(y, p);
        if(xx == yy) continue;
        if(s[xx] < s[yy]) swap(xx, yy);
        p[yy] = xx; s[xx] += s[yy];
    }
    rep(i, n) ans[i] = s[trace(i, p)] - f[i] - 1;
    rep(i, k){
        int x, y; cin >> x >> y;
        if(trace(--x, p) == trace(--y, p)){
            ans[x]--; ans[y]--;
        }
    }
    rep(i, n) cout << ans[i] << " ";
}


Measured memory_bytes: 3968
n = int(input())
data = [int(input()) for i in range(n)]
base_max = max(data)
if data.count(base_max) > 1:
    for j in range(n):
        print(base_max)
else:
    tmp = data.index(base_max)
    for k in range(n):
        if k != tmp:
            print(base_max)
        else:
            data.sort()
            print(data[-2])


Measured memory_bytes: 12688