akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;


bitset<2000001> bt;
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
//  cout << 2000 << endl;
//  for(int i = 0;i < 2000;i++){
//    cout << rand() % 2000 + 1 << ' ';
//  }
//  return 0;
  int n;
  cin >> n;
  int a[n];
  int s = 0;
  for(int i = 0;i < n;i++)
    cin >> a[i], s += a[i];
  bt[0] = 1;
  for(int i = 0;i < n;i++)
    bt |= (bt << a[i]);
  for(int i = (s + 1) / 2;i <= s;i++){
    if(bt[i]){
      cout << i;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1152
import Control.Applicative

main = do
  	[a,b] <- words <$> getLine
	putStrLn $ fx a b

trump = ["2","3","4","5","6","7","8","9","10","11","12","13","1"]

fx a b 
	| (f a) > (f b) = "Alice" 
	| (f a) < (f b) = "Bob"
	| otherwise = "Draw"

f a = ff 0 a

ff n a = if (trump !! n) == a then n else ff (n+1) a

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
 ll n;
 cin>>n;
for(ll i=1;i<=9;i++)
{
    if(n%i==0)
    {
        if(n/i<=9)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
}
cout<<"No"<<endl;
return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;
int prime[100205];
vector < int > v ;
vector < int > :: iterator it ;
void seive()
{
    int x = 100100;
    prime[0]=1;
    prime[1]=1;
    for(int i=4;i<=x;i+=2){prime[i]=1;}
    for(int i=3;i*i<=x;i+=2)
    {
        if(prime[i]==0)
        {
            for(int j=i+i;j<=x;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    v.push_back(2);
    for(int i=3;i<=x;i+=2)
    {
        if(prime[i]==0){v.push_back(i);}
    }
}
int main()
{
    seive();
    int p ;
    cin >> p ;
    it=lower_bound(v.begin(),v.end(),p);
    cout << *it << endl;
    return 0;
}


Measured memory_bytes: 768
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string a, b, c;
    cin >> a >> b >>c;
    cout << (char)(a[0]-'a'+'A') << (char)(b[0]-'a'+'A') << (char)(c[0]-'a'+'A') << endl;
    //cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    if N  % 1000 == 0:
        print(0)
    else:
        print(1000 - (N  % 1000))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 10920
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	double D,T,S;
	cin>>D>>T>>S;
	if( D <= T*S){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}



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

int main(){
  ll i=0,N,T;
  string ss;
  cin>>ss;
  cin>>T;
  while(ss[i]=='1')i++;
  if(T>i){
    cout<<ss[i]<<endl;
  }else{
    cout<<"1"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int i,j,k,n,ans=0;
cin>>n;
for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
        for(k=1;k<=n;k++){
           ans+=__gcd(__gcd(i,j),k); 
        }
    }
}cout<<ans;
    return 0;}

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int lookat = 1, c = 0;
    vector<int> nums;   // 1-0-1-0-1
    for (int i = 0; i < n; ++i) {
        if (s[i] == '0' + lookat) {
            ++c;
        } else {
            nums.push_back(c);
            lookat = 1 - lookat;
            c = 1;
        }
    }
    if (c > 0) nums.push_back(c);
    
    if (nums.size() % 2 == 0) nums.push_back(0);

    int ans = 0;
    int left = 0, right = 0, tmp = 0; // [left, right) の sum
    for (int i = 0; i < nums.size(); i += 2) {
        int nextLeft = i, nextRight = min(i + 2 * k + 1, (int)nums.size());

        while (left < nextLeft) {
            tmp -= nums[left];
            ++left;
        }

        while (right < nextRight) {
            tmp += nums[right];
            ++right;
        }
        ans = max(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int card[4][13]={};
    for(int i=0;i<n;i++){
        string suit;
        int num;
        cin>>suit>>num;
        if(suit=="S") card[0][num-1]=1;
        if(suit=="H") card[1][num-1]=1;
        if(suit=="C") card[2][num-1]=1;
        if(suit=="D") card[3][num-1]=1;
    }
    string str[4]={"S","H","C","D"};
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card[i][j]==1)continue;
            cout<<str[i]<<" "<<j+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void) {

	int a, b, num = 0;

	cin >> a >> b;

	for (int i = a; i <= b; i++)
	{
		string tmp = to_string(i);

		if (tmp[0] == tmp[4] && tmp[1] == tmp[3])num++;
	}

	cout << num << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{

  int n;
  int sum;
  char str[][100] = {
    {"deficient number\0"},
    {"abundant number\0"},
    {"perfect number\0"}
  };

  while(cin >> n && n){
    sum = 1;
    for(int i = 2; i*i < n; i++){
      if(!(n%i)) sum += i + n / i;
    }
    if(n!=1){
      if(sum == n){ cout << str[2] << endl; }
      if(sum >  n){ cout << str[1] << endl; }
      if(sum <  n){ cout << str[0] << endl; }
    }
    else          { cout << str[0] << endl; }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int n,m,b[111][111],k,p;
char a[111][111];
int main()
{
    FAST_IO;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    for(int i=0;i<n;i++)
    {
        k=0;
        for(int j=0;j<m;j++)
            if(a[i][j]=='.')
                k++;
        if(k==m)
        {
            for(int j=0;j<m;j++)
                b[i][j]=1;
        }
    }
    for(int i=0;i<m;i++)
    {
        k=0;
        for(int j=0;j<n;j++)
            if(a[j][i]=='.')
                k++;
        if(k==n)
            for(int j=0;j<n;j++)
                b[j][i]=1;
    }
    for(int i=0;i<n;i++)
    {p=0;
        for(int j=0;j<m;j++)
        {

            if(b[i][j]==0)
            {
                p=1;
                cout<<a[i][j];
            }


        }
        if(p==1)
        cout<<endl;
    }
}


Measured memory_bytes: 384
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

getKaiNum :: [[Int]] -> Int -> Int -> Int
getKaiNum [] a b = 0
getKaiNum (x : xs) a b = m + getKaiNum xs a b
  where
    [s, t] = map show x
    n = read (s ++ t ++ reverse s) :: Int
    m = if n >= a && n <= b then 1 else 0

main = do
  [a, b] <- getIntList
  let xs = sequence [[10 .. 99], [0 .. 9]]
  print $ getKaiNum xs a b


Measured memory_bytes: 1020
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ", 0);
		int r = Integer.parseInt(inputs[0]);
		int D = Integer.parseInt(inputs[1]);
		int x = Integer.parseInt(inputs[2]);
		for(int i = 0; i < 10; i++) {
			x = r * x - D;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 21716
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())

ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)


Measured memory_bytes: 9184
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	sta0 := 0
	sta1 := 0
	ct := 0
	for i := range s {
		if s[i] == '0' {
			if sta1 > 0 {
				ct++
				sta1--
			} else {
				sta0++
			}
		} else {
			if sta0 > 0 {
				ct++
				sta0--
			} else {
				sta1++
			}
		}
	}

	fmt.Println(ct * 2)
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    int d, n, ans;
    cin >> d >> n;
    switch (d)
    {
        case 0:
        if (n < 100) cout << n << endl;
        else cout << 101 << endl;
        break;

        case 1:
        if (n < 100) cout << 100 * n << endl;
        else cout << 10100 << endl;
        break;

        case 2:
        if (n < 100) cout << 100 * 100 * n << endl;
        else cout << 1010000 << endl;
        break;
    }
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct UnionFind {
  vector<ll> par, siz;
  UnionFind(ll n):par(n),siz(n,1) {
    for (ll i = 0; i < n; ++i) par[i] = i; //すべて根として初期化
  }
  ll root(ll x) {
    if (par[x] == x) return x;
    else return par[x] = root(par[x]);
  }
  void merge(ll x, ll y) {
    ll rx = root(x);
    ll ry = root(y);
    if (rx == ry) return;
    if (siz[rx] < siz[y]) swap(rx, ry);
    par[rx] = ry;
    siz[ry] += siz[rx];
  }
  bool same(ll x, ll y) { return root(x) == root(y);}
  ll size(ll x) { return siz[root(x)]; }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  ll a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];
  ll ans = 0;
  rep(i,n-1) {
    if (a*(x[i+1]-x[i]) >= b) ans+= b;
    else ans += a*(x[i+1]-x[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
 /* ll t;cin>>t;
    while(t--)
    {*/
      ll m,n,z,i,s=0, flag=0;cin>>n>>m;
     ll a[n];
     for(i=0;i<n;i++)
     {
       cin>>a[i];
       s+=a[i];
     }
     z=ceil(1.0*s/(4*m));
    
     //cout<<z;
     for(i=0;i<n;i++)
     {
     if(a[i]>=z)
      flag++;
      //else break;
      }
      if(flag>=m)
      cout<<"Yes";
      else
      cout<<"No";}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

# 地点iでの平均気温T_ave = T - Hi * 0.006
# abs(A - T_ave)が最小になるような地点の番号iを求める

# 平均気温T_aveを求めるループ
T_ave = []
diffArray = []
minDiff = 1200000
j_min = 0
for j in range(len(H)):
    T_ave.append(T - H[j]*0.006)
    diffArray.append(abs(A - T_ave[j]))
    if diffArray[j] < minDiff:
        minDiff = diffArray[j]
        j_min = j
# print(diffArray)
print(j_min + 1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <bitset>
#include <algorithm>

using namespace std;

int n;
vector<bitset<10>> f;
vector<array<int, 11>> p;

long long dfs(int now, bitset<10> bits){
    if(now == 10){
        if(bits.count() == 0) return -1e9;
        long long res = 0;
        for(int i = 0; i < n; i++){
            res += p[i][bitset<10>(bits & f[i]).count()];
        }
        return res;
    }
    long long res = dfs(now + 1, bits);
    bits[now] = true;
    res = max(res, dfs(now + 1, bits));
    bits[now] = false;
    return res;
}

int main(){
    cin >> n;
    f.resize(n);
    p.resize(n);
    for(auto&& i : f){
        for(int j = 0; j < 10; j++){
            short num;
            cin >> num;
            i[j] = num;
        }
    }
    for(auto&& i : p){
        for(auto&& j : i){
            cin >> j;
        }
    }
    cout << dfs(0, 0) << "\n";
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int N = 30;
int n;
bool in[N];

int main()
{
  rep(i, N){
    cin >> n;
    in[n - 1] = true;
  }

  rep(i, N) if(!in[i]) cout << i + 1 << endl;

  return 0;
}

Measured memory_bytes: 1160
using System;

namespace A___One_out_of_Three
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = input[0];
            var b = input[1];
            var c = input[2];
            if(a==b)
            {
                Console.WriteLine(c);
            }
            else if(a==c)
            {
                Console.WriteLine(b);
            }
            else
            {
                Console.WriteLine(a);
            }
        }
    }
}

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

int t[10][10],a[5];

int check(int k){
	if(k==0)return t[0][a[k]];
	return t[check(k-1)][a[k]];
}

int main(void){
	int cnt=0;
	rep(i,10)rep(j,10)cin>>t[i][j];
	rep(n,10000){
		bool flag=false;
		int d=1000;
		a[0]=n;
		rep(k,4){
			a[k+1]=a[k]%d;
			a[k]/=d;
			d/=10;
		}
		a[4]=check(3);

		/* Altering one single digit */
		rep(k,5){
			int tmp=a[k];
			rep(i,10){
				if(i==tmp)continue;
				a[k]=i;
				if(check(4)==0)flag=true;
			}
			a[k]=tmp;
		}

		/* Transposing two adjacent digits */
		rep(k,4){
			if(a[k]==a[k+1])continue;
			swap(a[k],a[k+1]);
			if(check(4)==0)flag=true;
			swap(a[k],a[k+1]);
		}

		if(flag)cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;

vector <pair <int, int>> graf[100005];
int val[100005];
bool visited[100005];

int mn, mx;
int a[200005];
int b[200005];
int c[200005];

void dfs(int v){
    visited[v] = 1;
    mn = min(mn, val[v]);
    mx = max(mx, val[v]);
    for(auto c : graf[v]){
        if(visited[c.first]) continue;
        val[c.first] = val[v] + c.second;
        dfs(c.first);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        cin >> a[i] >> b[i] >> c[i];
        graf[a[i]].push_back({b[i], c[i]});
        graf[b[i]].push_back({a[i], -c[i]});
    }
    for(int i=1; i<=n; i++){
        if(!visited[i]){
            dfs(i);
        }
    }
    for(int i=1; i<=m; i++){
        if(val[b[i]] - val[a[i]] != c[i]){
            cout << "No\n";
            return 0;
        }
    }
    if(mx-mn <= 1000000000) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 13568
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  string x,y; cin >> x >> y;
  if (x<y){cout << "<";}
  else if (x==y){cout << "=";}
  else {cout << ">";}

  return 0;
}


Measured memory_bytes: 256
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$a = (int)$input[0];
$b = (int)$input[1];
$c = (int)$input[2];
$d = (int)$input[3];

if ($c === 1 || $d === 1) {
	echo 0;
	exit();
}

if ($a % $c === 0) {
	$c_min = $a;
}else{
	$c_min = $a + ($c - ($a % $c));
}
if ($b % $c === 0) {
	$c_max = $b;
}else{
	$c_max = $b - ($b % $c);
}
$c_cnt = (int)(($c_max-$c_min) / $c) + 1;

if ($a % $d === 0) {
	$d_min = $a;
}else{
	$d_min = $a + ($d - ($a % $d));
}
if ($b % $d === 0) {
	$d_max = $b;
}else{
	$d_max = $b - ($b % $d);
}
$d_cnt = (int)(($d_max-$d_min) / $d) + 1;

$gcd = gcd(max($c, $d), min($c, $d));
$cd = (int)($gcd * ($c / $gcd) * ($d / $gcd));
if ($a % $cd === 0) {
	$cd_min = $a;
}else{
	$cd_min = $a + ($cd - ($a % $cd));
}
if ($b % $cd === 0) {
	$cd_max = $b;
}else{
	$cd_max = $b - ($b % $cd);
}
$cd_cnt = (int)(($cd_max-$cd_min) / $cd) + 1;

echo $b+1-$a-$c_cnt-$d_cnt+$cd_cnt;



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

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,n,l[1000];
    cin>>n;
    for(i=0; i<2*n; i++)
    {
        cin>>l[i];
    }
    j=n*2;
    sort(l,l+j);
    long long sum=0;
    for(i=0; i<2*n; i+=2)
    {
        sum+= min(l[i],l[i+1]);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
ans(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Measured memory_bytes: 6520
fun main(args: Array<String>) {
    val s = readLine()!!
    val n = readLine()!!.toInt()
    val sc = s.count()
    var l = mutableListOf<String>()
    for (i in 0 until sc){
        for(j in 0 until sc - i){
            if(j <= n){
                l.add(s.substring(i .. i + j))
            }
        }
    }
    var al = l.toSet().sorted()
    println(al[n - 1])
}

Measured memory_bytes: 40800
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

dp = [[0] * (K + 1) for i in range(N + 1)]
sdp = [[0] * (K + 1) for i in range(N + 1)]

dp[0][0] = 1
for j in range(len(dp[0])):
  sdp[0][j] = 1
  
for i in range(1, N + 1):
  for j in range(K + 1):
    dp[i][j] = sdp[i - 1][j]
    if j - A[i - 1] - 1 >= 0:
      dp[i][j] -= sdp[i - 1][j - A[i - 1] - 1]
    dp[i][j] %= DIV
  sdp[i][0] = dp[i][0]
  for j in range(1, K + 1):
    sdp[i][j] = sdp[i][j - 1] + dp[i][j]
    sdp[i][j] %= DIV
    
print(dp[N][K])

Measured memory_bytes: 222888
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9656
import java.util.*;
import java.io.*;
import java.math.*;
 class Main
{
	public static void main(String[] args)throws IOException {
		BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
		Scanner in= new Scanner(System.in);
int n=Integer.parseInt(br.readLine());
String s=br.readLine();
for(int i=0;i<s.length();i++)
{
	char c=s.charAt(i);
	int each= n+c;
	if(each>=91)
	{
		each=each-26;
	}
	System.out.print((char)each);

}
}
}


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

using namespace std;
int main(void){
    // Your code here!
    int n,h;
    cin>>n>>h;
    int s[n],t[n];
    int at=0;
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i];
        at=max(at,s[i]);
    }
    sort(t,t+n);
    reverse(t,t+n);
    int l=0;
    while(at<t[l] && l<n){
        h-=t[l];
        //cout<<h<<endl;
        if(h<=0){
            cout<<l+1<<endl;
            return 0;
        }
        l++;
    }
    //cout<<h<<endl;
    cout<<(h-1)/at+l+1<<endl;
    
}


Measured memory_bytes: 1024
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                print(i,j,H_0)
                exit()
print(info[0][0],info[0][1],info[0][2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
const int   N=                   1e6+7;

const int MAXR = 1000005;
ll         tests=          1;

using namespace std;
ll binarySearch(ll l, ll r,ll k)
{
	if (r >= l) {
		ll mid = l + (r - l) / 2;
		if (mid*(mid+1)==k)
			return 1;
		if (mid*(mid+1)>k)
			return binarySearch( l, mid - 1,k);
		return binarySearch(mid + 1, r, k);
	}
	return 0;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
int MaxSubArraySumReturn(int a[], int  n) //negative thakle o kaaj korbe in O(n)
{
 
    int sum = 0, best = 0;
   for(ll i=0;i<n;i++)
    {
        sum = max(a[i], a[i] + sum);
        best = max(best, sum);
    }
    return best;
 
}
ll totalDigits(ll n) 
{ 

    ll number_of_digits = 0; 
    for (ll i = 1; i <= n; i *= 10) 
        number_of_digits += (n - i + 1); 
  
    return number_of_digits; 
} 

int main()
{
 
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
  #endif
ll x,y;
cin>>x>>y;
cout<<x*y;
}


    




Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	string S;
	cin >> S;
	for (int i = 1; i < 4; i++)
	{
		if (S[i] == S[i - 1])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
import math
l=int(input())
n=int(math.log2(l))+1
m=0
ed=[]
for i in range(n,1,-1):
  if l%2:
    ed.append([1,i,l-1])
    m+=1
    l-=1
  m+=2
  ed.append([i-1,i,0])
  ed.append([i-1,i,l//2])
  l=l//2

print(n,m)
for i in ed:
  print(i[0],i[1],i[2])

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 998244353;
 
// code begins here

int main(){
    fast;
    
    ll n;
    cin>>n;
    
    vector<ll> cnt(n+1);
    
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            cnt[j]++;
        }
    }
    
    ll ans = 0;
    
    for(ll i=1;i<=n;i++)
        ans += i*(cnt[i]);
    
    cout<<ans<<endl;
        
    
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int i;
    int ans;
    for(i = 0; i < 1500; i++){
        if(i*8/100 == a && i*10/100 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=605;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,Mod,N,F[2][MAXN],ans;pint o[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),Mod=read();
	Rep(i,0,n-1){
		int r1=0,r2;for(;r1*r1+i*i<n*n;r1++);
		for(r2=r1;r2<2*n-1&&(r2+1)*(r2+1)+i*i<=4*n*n;r2++);
		o[++N]=mk(r1,r2+1);
	}Rep(i,n,2*n-1){
		int r=0;for(;r<2*n-1&&(r+1)*(r+1)+i*i<=4*n*n;r++);
		o[++N]=mk(r+1,0);
	}sort(o+1,o+N+1);
	Rep(i,0,n){
		int now=0,s1=0,s2=0;memset(F[now],0,sizeof(F[now])),F[now][0]=1;
		Rep(j,1,N){
			now^=1,memset(F[now],0,sizeof(F[now]));
			if(!o[j].sec){
				int mx=min(i,s1),u=o[j].fir-s2;
				Rep(k,0,mx)if(F[now^1][k])F[now][k]=1ll*F[now^1][k]*(u-k)%Mod;
				s2++;
			}else{
				int mx=min(i,s1),u=o[j].fir-s2,v=o[j].sec-i-n-s1;
				Rep(k,0,mx)if(F[now^1][k])F[now][k+1]=(F[now][k+1]+1ll*F[now^1][k]*(u-k))%Mod,F[now][k]=(F[now][k]+1ll*F[now^1][k]*(v+k))%Mod;
				s1++;
			}
		}ans=(ans+1ll*(i&1?Mod-1:1)*F[now][i])%Mod;
	}cout<<ans<<"\n";
	return 0;
}




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

int main(){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n==0 && m==0)
      break;
    int a[n], t, max=-1;
    for(int i=0; i<n; i++){
      cin >> a[i];
    }
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        if(i!=j){
            t = a[i] + a[j];
            if(max<t && t<=m){
              max = t;
            }
        }
      }
    }
    if(max==-1){
      cout << "NONE" << endl;
    }else{
      cout << max << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3084
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum() 
{
 int p, data = 0;char ch = 0;
 while ((ch != ' - ') && ch<'0' || ch>'9') ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
 if (ch == '- ')p = -1, ch = getchar();
 else p = 1;
 while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
 return data * p;
}
//E-mail 374656045@qq.com
int num[100001];
int dp[100001];
class solve {
private:int N; int len = 1; int temp;
public:
	solve()
	{
		cin >> N;
		cin >> num[0];//对边界元素处理能使得接下来的程序更一体
		dp[1] = num[0];
		forup(i, 1, N)
		{
			cin >> num[i];
			if (num[i] > dp[len])dp[++len] = num[i];//注意ai包括0，程序要更复杂一点
			else
			{
				*BinarySearch(dp+1,len, num[i]) = num[i];
			}
		}//10的9次方还在int型整数的范围内
		cout << len << endl;
	}
	inline int* BinarySearch(int*A,int bound,int key)//在升序排列的数组中找到第一个比key大的数
	{//bound表示界限，从A开始的bound个长度的范围内搜索,这个参数带来了很强的灵活性，
		int left = 0; int right = bound;//使得传参方便，bound是长度，A[bound]指向A的边界后一位
		int need;
		while (left < right)
		{
			int mid = (left + right) / 2;
			if (A[mid] == key)return A + mid;
			if (A[mid] < key)
			{
				left = mid + 1;//细节
			}
			if (A[mid] > key)
			{
				need =mid;
				right = mid;
			}
		}
		return A + need;
	}
};
int main(void)
{
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	solve solution;
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;
	
}



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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
T getSum(std::vector<T>& v) {
	T ret = 0;
	for (T& x : v) ret += x;
	return ret;
}

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	Yn(A == B && B == C);

	return 0;
}

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

int main() {
    long long int n,s=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
        ;
        else
        s=s+i;
    }
    cout<<s;

	return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

tmp = 0
while True:
    if N <= tmp:
        print(tmp - N)
        break
    else:
        tmp += 1000




Measured memory_bytes: 10852
#include <stdio.h> 
int main(){
  int A,B;
  scanf("%d%d",&A,&B);
  int x,y,z;
  x = A + B;
  y = A - B;
  z = A * B;
  if(x >= y && x >= z){
  printf("%d\n",x);
  }else if(y >= z && y >= x){
  printf("%d\n",y);
  }else{
  printf("%d\n",z);
  }    
}

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

int main() {
  int n; cin >>n;
  vector<double>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  double kotae=0;
  if(n==2){
    kotae=(a[0]+a[1])/2;
    cout<<fixed<<setprecision(12)<<kotae<<endl;
    return 0;
  }
  sort(a.begin(),a.end());
  double tmp=(a[0]+a[1])/2;
  for(int i=2;i<n;i++){
    kotae=(a[i]+tmp)/2;
    tmp=kotae;
  }
  cout<<fixed<<setprecision(12)<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using hash_t = unsigned long long;
const hash_t b = 10007;

struct rolloing_hash {
    int n;
    vector<hash_t> pow, hash;
    
    rolloing_hash() {}
    
    rolloing_hash(const string &s) {
        set(s);
    }
    
    void set(const string &s) {
        n = s.size();
        calc_pow();
        calc_hash(s.c_str());
    }

    void calc_pow() {
        pow.resize(n + 1); pow[0] = 1;
        for (int i = 0; i < n; i++) {
            pow[i + 1] = pow[i] * b;
        }
    }
    
    void calc_hash(const char *s) {
        hash.resize(n + 1);
        hash[0] = 0;
        for (int i = 0; i < n; i++) {
            hash[i + 1] = s[i] + hash[i] * b;
        }
    }
    
    hash_t get(int i) const {
        return hash[i]; 
    }
    
    hash_t get(int i, int j) const {
        return get(j) - get(i) * pow[j - i];
    }
};

using RH = rolloing_hash;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a = n % 2 == 0 ? 2 : 1;
    int b = n % 2 == 0 ? n / 2 - 1 : n / 2;
    int c = b + a;
    int d = n - a;
    RH rh(s);
    int ans = n;
    while (a < b) {
        hash_t A = rh.get(0, a);
        if (rh.get(b, c) == A && rh.get(d, n) == A && rh.get(a, b) == rh.get(c, d)) {
            ans = min(ans, b);
        }
        a += 2;
        b -= 1;
        c += 1;
        d -= 2;
    }
    if (ans != n) {
        cout << "Love " << s.substr(0, ans) << '!';
    } else {
        cout << "mitomerarenaiWA";
    }
    cout << '\n';
}

Measured memory_bytes: 19904
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const int N = 5050, mo = 1e9+7, inv2 =(mo+1)/2;
const ll MOD=7LL*mo*mo;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}

int fac[N],ifac[N];
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}

int n,p[N],f[N],sz[N],a[N],m,dp[N][N],mi[N];bool ck[N];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main() {
	iniC(N-1);read(n);rep(i,1,n)read(p[i]),f[i]=i;
	rep(i,1,n)if(p[i]>=1)f[find(i)]=find(p[i]);
	rep(i,1,n)sz[find(i)]++,ck[find(i)]|=p[i]<=0;
	int lft=0;
	rep(i,1,n)if(sz[i]&&ck[i])a[++m]=sz[i];else if(sz[i])lft++;
//	rep(i,1,m)cerr<<a[i]<<' ';cerr<<endl;
	dp[0][0]=1;
	rep(i,0,m-1)rep(j,0,i)if(dp[i][j])
		add(dp[i+1][j],dp[i][j]),
		add(dp[i+1][j+1],1ll*dp[i][j]*a[i+1]%mo);
	mi[0]=1;rep(i,1,m)mi[i]=1ll*mi[i-1]*(n-1)%mo;
	int res=1ll*lft*power(n-1,m)%mo;
	rep(s,2,m)res=(res+1ll*dp[m][s]*fac[s-1]%mo*mi[m-s])%mo;
	rep(i,1,m)add(res,1ll*(a[i]-1)*mi[m-1]%mo);
//	cerr<<res<<endl;
	int tot=1ll*n*power(n-1,m)%mo;sub(tot,res);res=tot;
	cout<<res;
	return 0;
}


Measured memory_bytes: 70724
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,k;
  cin >> a >> b >> k;
  
  if(k>a+b){
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  
  if(k<=a){
    cout << a-k << " " << b << endl;
    return 0;
  }
  
  cout << 0 << " " << b-(k-a) << endl;
  
  
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int h, n, a, sum = 0;
	cin >> h >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		sum += a;
	}
	if (h <= sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
//#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=1e6+5;
int mp[N]={0};


void solve()
{
  
  int k;
  cin>>k;
  int x=7;
  
  int ct=0,ans=-1;
  while(1)
  {
    ct++;
    x%=k;
    //cout<<x<<endl;
    if(x==0)
    {
      ans=ct;
      break;
    }

    if(mp[x])
      break;
    mp[x]=1;
    x*=10;
    x+=7;
  }
  cout<<ans;
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

// 二分探索（改）
// judge を満たすような下限を求める
// left:[X] 定義域の下限
// right:[X] 定義域の上限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X left, X right, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (right - left > eps) {
        X mid = (right + left) / 2;
        if (judge(mid) == lower) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return lower ? right : left;
}

const i64 INF = 1e16;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<i64> s(A), t(B), x(Q);
    for (auto &d : s) cin >> d;
    for (auto &d : t) cin >> d;
    for (auto &d : x) cin >> d;
    sort(WHOLE(s)), sort(WHOLE(t));

    auto f = [&](vector<i64> &array, i64 pos) -> pair<i64, i64> {
        i64 r = BinSearch<int>(-1, array.size(), [&](int k) -> bool {
            return array[k] > pos;
        });

        if(r >= array.size()) {
            return {array[r - 1], INF};
        } else if(r == 0) {
            return {-INF, array[r]};
        } else {
            return {array[r - 1], array[r]};
        }
    };

    for (int q = 0; q < Q; q++) {
        i64 ans = INF;
        for(int b = 0; b < 2; b++) {
            i64 l, r, ll, lr, rl, rr;
            tie(l, r) = f(b ? s : t, x[q]);

            tie(ll, lr) = f(b ? t : s, l);
            tie(rl, rr) = f(b ? t : s, r);
            ans = min({ans,
                       abs(l - x[q]) + min(abs(l - ll), abs(l - lr)),
                       abs(r - x[q]) + min(abs(r - rl), abs(r - rr))
            });
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3712