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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

auto solve() {
    int N, x;
    cin >> N >> x;
    vi a(N);

    for (auto &&e:a) {
        cin >> e;
    }

    vector<vi> fix_k(N, a);
    FOR(r, 1, N) {
        REP(c, N) {
            fix_k[r][c] = min({fix_k[r][c], fix_k[r - 1][c], fix_k[0][(c - r + N) % N]});
        }
    }

    ll res = (1ll<<62);
    REP(i,N) {
        ll sum = accumulate(all(fix_k[i]), 0ll) + (ll)x * i;
        res = min(res, sum);
    }

    return res;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 16000
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[110][110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)scanf("%d",&b[i][j]);
		bool yet=true;
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				bool ok=true;
				for(int k=0;k<a;k++)if(b[i][j]>b[i][k]||b[i][j]<b[k][j])ok=false;
				if(ok&&yet){
					printf("%d\n",b[i][j]);yet=false;
				}
			}
		}
		if(yet)printf("0\n");
	}
}

Measured memory_bytes: 1036
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  map<string,int> m;
  REP(i,N){
    string s;
    cin>>s;
    sort(ALL(s));
    m[s]++;
  }
  lint ans=0;
  for(auto e:m){
    lint k=e.second;
    ans+=k*(k-1)/(lint)2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11136
N = int(input())
a = [[0]*N for _ in range(N)]
for i in range(N):
    *a[i], = map(int, input().split())

sums = [0]*(1<<N)
for s in range(1, 1<<N):
    for i in range(1, N):
        for j in range(i):
            if (s>>i & 1) & (s>>j & 1):
                sums[s] += a[i][j]

dp = [0]*(1<<N)
for s in range(1, 1<<N):
    t = s
    while t > 0:
        dp[s] = max(dp[s], dp[s & ~t] + sums[t])
        t = s & (t-1)

print(dp[-1])

Measured memory_bytes: 75092
#include <math.h>
#include <stdio.h>
#include <string.h>
int d, n, h[10001], ans = 0;
int main(void) {
    scanf("%d %d", &d, &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    for (int i = 0; i < n; i++) {
        ans = ans + h[i];
    }
    if (ans <= d) {
        printf("%d\n", d - ans);
    } else {
        printf("-1\n");
    }
}

Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mk make_pair
#define pb push_back
/*ll modexp(ll x,ll y){
    if(y==0)return 1;
    ll ans=modexp(x,y/2);
    ans=ans*ans;
    if(y&1)ans*=x;
    return ans;
}
int main(){
   ll a;cin>>a;
   ll ans=modexp(a,1)+modexp(a,2)+modexp(a,3);
   cout<<ans<<endl;
    return 0;
}*/
int main(){
    string s;
    string t;
    cin>>s>>t;
    int cnt=0;
    for(int  i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}
/*int main(){
    ll n,m,k;
    cin>>n>>m>>k;
     vector<ll> a;
     vector<ll> b;
     for(int i=0;i<n;i++){int x;cin>>x;a.pb(x);}
    for(int i=0;i<m;i++){int x;cin>>x;b.pb(x);}
    for(int i=1;i<n;i++)a[i]+=a[i-1];
    for(int i=1;i<m;i++)b[i]+=b[i-1];
    ll ans=-1;
    for(int i=0;i<m;i++){
     if(k>b[i]){
         ll val=0;
        if(upper_bound(a.begin(),a.end(),k-b[i])!=a.end())val= upper_bound(a.begin(),a.end(),k-b[i])-a.begin();
        else val=a.size();
        val+=(i+1);
        ans=max(val,ans);
     }   
    }
    cout<<ans<<endl;
    return 0;
}*/

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

#define ll long long

int main() {
    ll n,i,h=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    for(i=1;i<n;i++)
    {
        if(a[i]<a[i-1]) 
        { 
           h+=a[i-1]-a[i];
           a[i]=a[i]+(a[i-1]-a[i]);
        }
        else 
        {
           continue;
         }  
    }
    cout<<h;
    return 0;
}

Measured memory_bytes: 5184
def invert(p, q):
    for i, pi in enumerate(p): q[pi] = i

def sort_insertion(k, data, first, last):
    length = last - first
    if length <= 2:
        if length == 2 and data[first] - data[first + 1] >= k:
            data[first], data[first + 1] = data[first + 1], data[first]
        return
    for i in range(first + 1, last):
        v = data[i]
        for t in range(i - 1, first - 1, -1):
            if data[t] - v < k:
                t += 1
                break
        data[t + 1:i + 1] = data[t:i]
        data[t] = v

def sort_merge(k, data, first, last):
    if last - first < 10:
        sort_insertion(k, data, first, last)
        return

    middle = (first + last) // 2
    sort_merge(k, data, first, middle)
    sort_merge(k, data, middle, last)
    bounds = data[first:middle]
    for i in range(len(bounds) - 2, -1, -1):
        bounds[i] = min(bounds[i + 1], bounds[i])
    tmp = data[first:middle]

    first_len = middle - first
    head1 = 0
    head2 = middle
    for ohead in range(first, last):
        if head1 == first_len or head2 == last:
            data[ohead:ohead + first_len - head1] = tmp[head1:first_len]
            return
        elif bounds[head1] - data[head2] >= k:
            data[ohead] = data[head2]
            head2 += 1
        else:
            data[ohead] = tmp[head1]
            head1 += 1

n, k = (int(s) for s in input().split(' '))
p = [int(s) - 1 for s in input().split(' ')]

q = list(p)
invert(p, q)
sort_merge(k, q, 0, n)
invert(q, p)

for pi in p: print(pi + 1)


Measured memory_bytes: 61572
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
using namespace std;
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    int r = ceil((float)d / s);
    if (r <= t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,T;
  cin>>N>>T;
 
  vector<int> A(N);
  vector<int> B(N);
  for(int i=0;i<N;i++){
  cin>>A[i]>>B[i];
  }
   int b=1001;
  for(int i=0;i<N;i++){
  if(T>=B[i]){
  b=min(b,A[i]);
  }
  }
  if(b==1001){
  cout<<"TLE"<<endl;
  }else{
   cout<<b<<endl; 
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

//	文字列の判別
		if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[n][4];
    int dp[n][4];
    for (int i=0 ; i<n ; i++){
        for (int j=1 ; j<4 ; j++){
            cin >> arr[i][j];
        }
        if (i==0){
            dp[0][1] = arr[0][1];
            dp[0][2] = arr[0][2];
            dp[0][3] = arr[0][3];
        }
        else{
            dp[i][1] = arr[i][1] + max(dp[i-1][2],dp[i-1][3]);
            dp[i][2] = arr[i][2] + max(dp[i-1][1],dp[i-1][3]);
            dp[i][3] = arr[i][3] + max(dp[i-1][1],dp[i-1][2]);
        }
    }
    cout << max(dp[n-1][1],max(dp[n-1][2],dp[n-1][3])) << "\n";
    return 0;
}

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

#define INF 0x3FFFFFFF

using namespace std;

int counter[26][200000], dp[1 << 26], opt[200001];

int getHash(int idx) {
  int result = 0;
  for (int i = 0; i < 26; i++) if (counter[i][idx] & 1) result |= 1 << i;
  return result;
}

void update(int hash, int val) {
  if (dp[hash] == -1 || val < dp[hash]) dp[hash] = val;
}

int numberOfSetBits(int i) {
  i = i - ((i >> 1) & 0x55555555);
  i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
  return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}

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

  string s;
  cin >> s;
  int n = s.size();

  for (int i = 0; i < n; i++) {
    if (i) for (int j = 0; j < 26; j++) counter[j][i] = counter[j][i - 1];
    counter[s[i] - 'a'][i]++;
  }
  
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  opt[0] = 0;
  for (int i = 1; i <= n; i++) {
    opt[i] = INF;
    int thisHash = getHash(i - 1);
    if (numberOfSetBits(thisHash) <= 1) {
      opt[i] = 1;
    }
    for (int j = 0; j < 26; j++) {
      int otherHash = thisHash ^ (1 << j);
      int otherVal = dp[otherHash];
      if (otherVal != -1) {
        opt[i] = min(opt[i], otherVal + 1);
      }
    }
    update(thisHash, opt[i]);
  }

  cout << opt[n] << endl;
  return 0;
}


Measured memory_bytes: 283796
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string S;
  cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << " Sunny" << endl;
  }
}

Measured memory_bytes: 3616
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;
	



	cin >> a;
	if (a==25)
	{
		cout << "Christmas" << endl;
	}
	else if (a == 24)
	{
		cout << "Christmas Eve" << endl;
	}
	else if (a == 23)
	{
		cout << "Christmas Eve Eve" << endl;
	}
	else
	{
		cout << "Christmas Eve Eve Eve" << endl;
	}
	//cout << ans << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)

main :: IO ()
main = do
  [n,p] <- map read . words <$> getLine
  print $ query n p


factorsLess :: Int -> Int -> [(Int, Int)]
factorsLess n till = go2 n
  where
    go2 n | 2 > till = []
    go2 n | not $ testBit n 0 = (2,exponent2) : go (n `shiftR` exponent2) 3
          | otherwise         = go n 3
      where
        exponent2 = countTrailingZeros n
    go !n !p | n == 1 || p > till = []
    go !n !p | r /= 0 = go n (p+2)
             | otherwise = count q 1
      where
        (q,r) = divMod n p
        count !n1 !acc | r1 /= 0 = (p,acc) : go n1 (p+2)
                       | otherwise = count q1 (acc+1)
          where
            (q1,r1) = divMod n1 p 
                                    

query :: Int -> Int -> Int
query 1 p = p
query n p = product $ map (\(p,m) -> p ^ (m `div` n)) factors
  where
    pD = fromIntegral p :: Double
    nD = fromIntegral n :: Double
    factors = factorsLess p $ floor $ pD ** (1/nD)


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'

int main () {
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll n;
	// stops reading at the first non-numeric character, which is the newline
	cin >> n;

	ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		if (!(i % 3 == 0 || i % 5 == 0)) 
			sum += i;
	}

	cout << sum;

	return 0;
}


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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

vector<ll> all;
vector<ll> pate;

ll dfs(int N, ll X)
{
  ll ans = 0;
  dump(N, X);
  if (N == 0)
    return 1;
  if (X > 0) {
    X--;
  }
  if (X > 0) {
    if (all[N - 1] <= X) {
      ans += pate[N - 1];
      X -= all[N - 1];
    } else {
      ans += dfs(N - 1, X);
      X = 0;
    }
  }
  if (X > 0) {
    ans++;
    X--;
  }
  if (X > 0) {
    if (all[N - 1] <= X) {
      ans += pate[N - 1];
      X -= all[N - 1];
    } else {
      ans += dfs(N - 1, X);
      X = 0;
    }
  }
  if (X > 0) {
    X--;
  }
  dump(ans);
  return ans;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("d.1", "r", stdin);
  int N;
  ll X;
  cin >> N >> X;
  all.resize(N + 1);
  pate.resize(N + 1);
  all[0] = 1;
  pate[0] = 1;
  for (int i = 1; i <= N; i++) {
    all[i] = all[i - 1] * 2 + 3;
    pate[i] = pate[i - 1] * 2 + 1;
  }
  dumpv(all);
  dumpv(pate);
  cout << dfs(N, X) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
import itertools

K = list(map(int,readline().rstrip().decode('utf-8')))
D = int(read())

MOD = 10**9 + 7

Kcum = list(itertools.accumulate(K))

x = np.zeros(D,np.int64)
x[0] = 1
answer = 0
for kc,k in zip(Kcum[::-1],K[::-1]):
    for i in range(kc-k,kc):
        rest = (-i)%D
        answer += x[rest]
    y = np.zeros(D+10,np.int64)
    y[:D] = x
    y[10:] -= x
    np.cumsum(y,out=y) # 1-xで割る
    for d in range(D,D+10):
        y[d%D] += y[d]
    x = y[:D] % MOD

answer -= 1 # 0
if Kcum[-1]%D==0:
    answer += 1

answer %= MOD
print(answer)

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

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

    int ans = 0;
    for(int i=a;i<=b;++i){
        string s = to_string(i);
        bool is_palindromic = true;
        int left = 0, right = s.size()-1;
        while(left <= right){
            if(s[left] != s[right]){
                is_palindromic = false;
                break;
            }
            left++;
            right--;
        }
        if(is_palindromic)ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
int n;
int a[310];
double dp[310][310][310];

double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double ans = 0.0;
    if (i > 0) ans += rec(i-1, j, k) * i;
    if (j > 0) ans += rec(i+1, j-1, k) * j;
    if (k > 0) ans += rec(i, j+1, k-1) * k;
    ans += n;
    ans *= 1.0 / (i + j + k);

    return dp[i][j][k] = ans;
}

int main() {
    cin >> n;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a == 1) one++;
        else if (a == 2) two++;
        else three++;
    }
    memset(dp, -1, sizeof(dp));
    cout << setprecision(10) << rec(one, two, three) << endl;
}

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

using namespace std;

int main() {
    int n,i,a,b,c;
    string s;
    i=a=b=c=0;
    cin>>s;
    a=(a*10+(s[0]-48));
    a=(a*10+(s[1]-48));
    a=(a*10+(s[2]-48));
    a=(a*10+(s[3]-48));
    b=(b*10+(s[5]-48));
    b=(b*10+(s[6]-48));
    c=(c*10+(s[8]-48));
    c=(c*10+(s[9]-48));
    if(a<=2019 && b<=4 && c<=30)
      cout<<"Heisei"<<endl;
    else
      cout<<"TBD"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	int N = 0;
	std::cin >> N;
	std::vector<int> A(N);
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				int temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				ans++;
			}
		}
	}

	std::cout << A[0];
	for (int i = 1; i < N; i++) {
		std::cout << " " << A[i];
	}
	std::cout << std::endl;
	std::cout << ans << std::endl;

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 3064
def euclid(a, b):
  division = a if (a > b) else b
  divider = b if (a > b) else a
  reminder = 0
  while divider != 0:
    reminder = division % divider
    division = divider
    divider = reminder
  
  return division

K = int(input())

result = 0
for k in range(1, K + 1):
  for l in range(1, K + 1):
    for m in range(1, K + 1):
      gcd = euclid(euclid(k, l), m)
      result += gcd

print(result)


Measured memory_bytes: 69212
import java.util.Scanner;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int p=10000;
        int ans=10000;
        Map<Integer,Integer> map=new HashMap<>();
        int arr[] = new int[n];
        for(int i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
            map.put(arr[i],1);
        }

        for(int i=1000;i>=0;i--)
        {
            int k=i-x;
            if(k<0)
            {
                k=-k;
            }
            if((k<=p)&&map.get(i)==null)
            {
                ans=i;
                p=k;
            }
        }
        System.out.println(ans);

    }
}


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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	string cur = s.substr(0, n / 2);
	cur += s.substr(0, n / 2); 
	cout << (cur == s ? "Yes" : "No");
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
    int time[3][9]= {{0},{0}}, i, j;
    
    for (i = 0; i < 3; i++) {
        for (j = 0; j < 6; j++) {
            scanf("%d", &time[i][j]);
        }
    }
    
    for (i = 0; i < 3; i++) {
        if ((time[i][8] += time[i][5] - time[i][2]) < 0){
            time[i][8] += 60;
            time[i][7] -= 1;
        }
        if((time[i][7] += time[i][4] - time[i][1]) < 0){
            time[i][7] += 60;
            time[i][6] -= 1;
        }
        time[i][6] += time[i][3] - time[i][0];
    }
    
    for (i = 0; i < 3; i++)
        printf("%d %d %d\n", time[i][6], time[i][7], time[i][8]);
    
    return 0;
}

Measured memory_bytes: 600
from itertools import groupby


# RUN LENGTH ENCODING str -> tuple
def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


# RUN LENGTH DECODING tuple -> str
def runLengthDecode(L: "list[tuple]"):
    res = ""
    for c, n in L:
        res += c * int(n)
    return res


# RUN LENGTH ENCODING str -> list
def rle_list(S: str):
    grouped = groupby(S)
    res = ""
    for k, v in grouped:
        res += k
    return res


def main():
    ss = input()
    rle = rle_list(ss)
    ans = len(list(rle)) - 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9440
h,w,d,i,f;main(c){for(;scanf(f="%d %d\n",&h,&w)*h;c=printf(f,h-1,w))for(d=i=h*h+w*w;c;d++)for(h=d!=i?:h+1;c&&h<(w=sqrt(d-h*h));c=h*h+++w*w-d);}

Measured memory_bytes: 604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>

#define REP(i, s, e) for (ll i = s; i < e; ++i)

using namespace std;
using ll = long long;
using ld = long double;

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

    string S;
    ll K;
    cin >> S >> K;

    int count = 0;
    char num = 0;
    REP(i, 0, S.size())
    {
        if (S[i] != '1')
        {
            num = S[i];
            break;
        }

        ++count;
    }

    if (count >= K) cout << '1' << endl;
    else cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll weight[100005],value[100005];
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(j>=weight[i-1])
            dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);
            else
            dp[i][j]=dp[i-1][j];
            }
        }
    
    cout<<dp[n][w]<<endl;
}
    

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define ull unsigned long long int
using namespace std;
int main()
{
    ull k,a,b,i,j;
    cin>>a>>b>>k;
     if(b>k)
     {
         cout<<(a*k)/b<<endl;
     }
    else
    {
       cout<<((a*(b-1))/b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
n, m = map(int, input().split())
A = [0] * n
W = [0] * n
w = 0
for i in range(m):
	p, s = input().split()
	p = int(p) - 1
	if s == "AC" and A[p] == 0:
		A[p] = 1
		w += W[p]
	elif s == "WA" and A[p] == 0:
		W[p] += 1
print(sum(A), w)

Measured memory_bytes: 51416
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=map(int, input().split())
    ans=0
    for i in range(1,n+1):
        cnt=0
        for j in str(i):
            cnt+=int(j)
        if a<=cnt<=b:
            ans+=i
    print(ans)
resolve()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a[3] = { 1 };
	for (char b,c,d; cin >> b>>c>>d;) {
		switch (b + d) {
		case 'B' + 'C':
			swap(a[1], a[2]);
			break;
		case 'C' + 'A':
			swap(a[2], a[0]);
			break;
		case 'A' + 'B':
			swap(a[0], a[1]);
			break;
		}
	}
	if (a[0])cout << "A" << endl;
	else if (a[1])cout << "B" << endl;
	else cout << "C" << endl;
	

	return 0;
}

Measured memory_bytes: 1136
n = int(input().strip())
a = list(map(int, input().strip().split()))

box=[0]*n
ans=[]
for i in range(n,0,-1):
    sum_=0
    for j in range(1,n+1):
        if j*i>n:
            break
        sum_+=box[j*i-1]
    if sum_%2!=a[i-1]:
        box[i-1]=1
        ans.append(i)

print(len(ans))
print(' '.join(list(map(str,ans))))


Measured memory_bytes: 74204
#include <stdio.h>
#include <stdio.h>
#include <string.h>
int main()
{
int a,b,m,n,z,p;
while(~scanf("%d%d",&a,&b))
{

    z=a*b;
    m=a+b;
    n=a-(b);
    if(z>m&&z>n)
        printf("%d\n",z);
    else if(m>z&&m>n)
        printf("%d\n",m);
    else
        printf("%d\n",n);

}
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.io.*;

public class Main{
	public static boolean judge(char a, char b, int n){
		boolean flag = false;
		if( n < 0 ){
			n = 26+n;
		}
		int x = ( (int)(b-a) > 0 ) ? (int)(b-a) : (int)(a-b);
		if( x == n || x == 26-n ){
			flag = true;
		}
		return flag;
	}
	
	public static String decode(String s, int k){
		char[] temp = new char[s.length()];
		for(int i = 0; i < temp.length; i++){
			if( Character.isLetter(s.charAt(i)) ){
				if( (char)(s.charAt(i)+k) >= 'a' && (char)(s.charAt(i)+k) <= 'z' ){
					temp[i] = (char)(s.charAt(i)+k);
				} else if( (char)(s.charAt(i)+k) < 'a' ){
					temp[i] = (char)(s.charAt(i)+k+26);
				} else {
					temp[i] = (char)(s.charAt(i)+k-26);
				}					
			} else {
				temp[i] = s.charAt(i);
			}
		}
		String result = new String(temp);
		return result;
	}
	
	public static void main(String[] args){
		Scanner stdIn = null;
		String[][] s = new String[10000][];
		int index = 0;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.nextLine();
				s[index] = str.split(" ");
				int n = 0;
				for(int i = 0; i < s[index].length; i++){
					if( s[index][i].length() == 3 ){
						if( judge(s[index][i].charAt(0),s[index][i].charAt(1),12) && judge(s[index][i].charAt(1),s[index][i].charAt(2),3) ){
							n = 't'-s[index][i].charAt(0);
							break;
						}
					} else if( s[index][i].length() == 4 ){
						if( judge(s[index][i].charAt(0),s[index][i].charAt(1),12) && judge(s[index][i].charAt(1),s[index][i].charAt(2),7) && judge(s[index][i].charAt(3),s[index][i].charAt(2),19) ){
							n = 't'-s[index][i].charAt(0);
							break;
						} else if( judge(s[index][i].charAt(0),s[index][i].charAt(1),12) && judge(s[index][i].charAt(2),s[index][i].charAt(1),1) && judge(s[index][i].charAt(3),s[index][i].charAt(2),10) ){
							n = 't'-s[index][i].charAt(0);
							break;
						}
					}
				}
				for(int i = 0; i < s[index].length; i++){
					s[index][i] = decode(s[index][i], n);
				}
				index++;
			}
			for(int i = 0; i < index; i++){
				for(int j = 0; j < s[i].length-1; j++){
					System.out.print(s[i][j] + " ");
				}
				System.out.println(s[i][s[i].length-1]);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l),i##R=(r);i<=i##R;i++)
#define DOR(i,r,l) for(int i=(r),i##L=(l);i>=i##L;i--)
#define loop(i,n) for(int i=0,i##R=(n);i<i##R;i++)
#define sf scanf
#define pf printf
#define mms(a,x) memset(a,x,sizeof a)
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chkmax(A &x,const B y){if(x<y)x=y;}
template<typename A,typename B>inline void chkmin(A &x,const B y){if(x>y)x=y;}
const int N=25;
int n,d;
int a[N][N];
bool check(int x,int y){
	int dis=0;
	FOR(i,1,d)dis+=(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	int sq=(int)sqrt(dis);
	return sq*sq==dis;
}
int main(){
	sf("%d%d",&n,&d);
	FOR(i,1,n)FOR(j,1,d)sf("%d",&a[i][j]);
	int ans=0;
	FOR(i,1,n)FOR(j,i+1,n)
		ans+=check(i,j);
	pf("%d\n",ans);
	return 0;
}

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

int main(){
    std::string S;
    std::cin >> S;
    char current = 'R';
    int Rcnt = 0;
    int Lcnt = 0;
    std::vector< int > ans(S.size(), 0);
    for(int i=0; i<S.size(); i++){
        if(S[i] =='R'){
            Rcnt++;
        }else{
            Lcnt++;
        }
        
        if(i == S.size() - 1 || (S[i] =='L' && S[i+1] == 'R') ){
            int total = Rcnt + Lcnt;
            int odd = total / 2 + total % 2;
            int even = total / 2;
            if(Rcnt % 2){
                ans[i - Lcnt] = odd;
                ans[i - Lcnt + 1] = even;
            }else{
                ans[i - Lcnt] = even;
                ans[i - Lcnt + 1] = odd;
            }
            Rcnt = 0;
            Lcnt = 0;
        }
    }
    
    bool first = true;
    for(int i=0; i<ans.size(); i++){
        if(first){
            std::cout << ans[i];
            first = false;
        }else{
            std::cout << " " << ans[i];
        }
    }
    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 1024
n = int(input())
A = list(map(int,input().split()))
L_i = 0
R_i = n - 1
L = 0
R = 0
while L_i <= R_i:
  if L >= R:
    R += A[R_i]
    R_i -= 1
  else:
    L += A[L_i]
    L_i += 1
    
print(abs(L-R))

Measured memory_bytes: 26396
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	int N = 0;
	cin >> N;
	vector<int> nums;
	multiset<int> ord;
	for (int i = 0; i < N; ++i)
	{
		int a = 0;
		cin >> a;
		nums.push_back(a);
		ord.insert(a);
	}

	for (int a : nums)
	{
		int max = *(--ord.end());
		if (a == max)
		{
			max = *prev(ord.end(), 2);
		}

		cout << max << endl;
	}

}



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

int main(void) {
	int n, q, com, t, x, i;
	cin >> n >> q;
	vector<list<int> > ve(n);
	list<int>::iterator it;
	while (q--) {
		cin >> com >> t;
		switch (com) {
			case 0:
				cin >> x;
				ve[t].push_back(x);
				break;
			case 1:
				it = ve[t].begin();
				i = 0;
				while (it != ve[t].end()) {
					if (i++) cout << " ";
					cout << *it;
					it++;
				}
				cout << endl;
				break;
			case 2:
				cin >> x;
				ve[x].splice(ve[x].end(), ve[t]);
		}
	}
}


Measured memory_bytes: 18660
a = input()
b = len(a)
 
for i in range(b):
  if i % 2 == 0:
    if a[i] == 'R' or a[i] == 'U' or a[i] == 'D':
      continue
    else:
      print('No')
      exit()
  elif i % 2 == 1:
    if a[i] == 'L' or a[i] == 'U' or a[i] == 'D':
      continue
 
    else:
      print('No')
      exit()
      
print('Yes')

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

int main(){
  int n, t = 0;
  cin >> n;
  for(int i = 1;i <= 9;i++){
    if((n % i == 0) && (n / i <= 9))
      t = 1;
  }
 	if(t == 0) 
    cout << "No"  << endl; 
  else
    cout << "Yes" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
	long long h, w;
	cin >> h >> w;
	long long int ans = 0;
	ll rowm = (h % 2) ? h / 2 + 1 : h / 2;
	ll rowl = h - rowm;
	ll colm = (w % 2) ? w / 2 + 1 : w / 2;
	ll coll = w - colm;
	if (coll == 0 or rowl == 0) {
		cout << 1 << '\n';
		return;
	}
	ans = rowm * colm + rowl * coll;
	cout << ans << '\n';
}	
int main() {
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	solve();
 	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[202020];
ll mk[202020];
ll i, j, k;
int main(){
    scanf("%lld", &N);
    fornum(i,1,N){
        scanf("%lld", &A[i]);
        ++mk[A[i]];
    }
    fornum(i,0,N){
        printf("%lld\n", mk[i + 1]);
    }
    

    return 0;
}

Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

/* O(log n) */
struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v)
      return false;
    if (parent[u] > parent[v])
      swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool issame(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M), Y(M), Z(M);
  UnionFind U(N);
  rep(i, M) {
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;
    Y[i]--;
    U.unite(X[i], Y[i]);
  }

  set<int> s;
  rep(i, N) {
    int r = U.root(i);
      s.insert(r);
  }
  cout << s.size() << endl;
}

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

class Point{
public:
	Point(const int &xa, const int &ya):x(xa),y(ya){};
	Point() = default;
	int x, y;
};

class Line{
public:
	Line(const Point &&ap1, const Point &&ap2){
		if (ap1.y > ap2.y){
			p1 = ap1;
			p2 = ap2;
		}else{
			p1 = ap2;
			p2 = ap1;
		}
	}
	Point p1, p2;
	bool is_on_line(const Point &p){
		return (((p1.x - p2.x) * (p.y - p2.y) == (p1.y - p2.y) * (p.x - p2.x)) and ((p1.x - p.x) * (p2.x - p.x) <= 0) and ((p1.y - p.y) * (p2.y - p.y) <= 0));
	}
	int cross_line(const Point &p){
		if (is_on_line(p)){
			return 1000;//辺に接する
		}else if (p.y == p2.y){
			return 0;//下側の頂点を通る
		}else if ((p1.y - p.y) * (p2.y - p.y) <= 0 and ((p.y - p2.y) * (p1.x - p2.x) > (p1.y - p2. y) * (p.x - p2.x))){
			return 1;//上側の頂点か辺を通る
		}else{
			return 0;//交わらない
		}
	}
};
int fold(std::vector<Line> &lines, const Point &&p){
	int sum = 0;
	for (auto l : lines){
		sum += l.cross_line(p);
	}
	if (sum >= 1000){
		return 1;
	}else if (sum % 2 == 1){
		return 2;
	}else{
		return 0;
	}
}

int main(){
	int n;
	std::cin >> n;
	int sx, sy;
	std::cin >> sx >> sy;
	int px = sx, py = sy;
	std::vector<Line> lines;
	for (auto i = 1; i < n; ++i){
		int x, y;
		std::cin >> x >> y;
		lines.push_back(Line(Point(px, py), Point(x, y)));
		px = x; py = y;
	}
	lines.push_back(Line(Point(px, py), Point(sx, sy)));
	std::cin >> n;
	for (auto i = 0; i < n; ++i){
		int x, y;
		std::cin >> x >> y;
		std::cout << fold(lines, Point(x, y)) << "\n";
	}
}

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

int main()
{
    int h, w;

    while (true) {
        cin >> h >> w;

        if (h == 0 && w == 0) {
            return 0;
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
"use strict";

function main(input) {
    input = input.split(' ');
  	const K = parseInt(input[0]);
  	const S = parseInt(input[1]);

    let count = 0
    if(S < 0 || S > 3 * K) {
        //console.log("error")
    }
    else if(K < 2 || K > 2500) {
        //console.log("error")
    }
    else if(S === 3 * K) {
        count = 1
    } else {
        // X,Y,SからZを算出し、範囲内かどうか
        for(let i = 0; i <= K; i++) {
            for(let j = 0; j <= K; j++) {
                const Z = S - (i+j)
                if(Z >= 0 && Z <= K ) {
                    count ++
                }
            }
        }
    }
    console.log(count)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("No");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=1e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	
	void main()
	{
		char str[N];scanf("%s",str+1);int n=strlen(str+1);
		if(n&1) GG();
		fo(i,1,n) if(str[i]!=(i&1?'h':'i')) GG();
		puts("Yes");
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 23680
import sys
input = sys.stdin.readline

'''

'''

from math import floor

res = [0] * (10**4+1)

def a(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

def solve(n):
    global res

    count = 0
    limit = floor(n**0.5)+1

    for x in range(1, limit):
        for y in range(x, limit):
            for z in range(y, limit):
                #print(x, y, z)
                r = a(x, y, z)
                if r > n:
                    break
                elif x == y == z:
                    res[r] += 1
                elif x != y and y != z and x != z:
                    res[r] += 6
                else:
                    res[r] += 3
    
n = int(input())
solve(n)
for i in range(1, n+1):
    print(res[i])




Measured memory_bytes: 69852
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<vector<bool>> c(n, vector<bool>(n, false));
    printf("%d\n", (n*(n-1))/2-n/2);
    if (n%2 != 0) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (i == j || i+j == n || c[i-1][j-1]) continue;
                c[i-1][j-1] = c[j-1][i-1] = true;
                printf("%d %d\n", i, j);
            }
        }
    } else {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (i == j || i+j == n+1 || c[i-1][j-1]) continue;
                c[i-1][j-1] = c[j-1][i-1] = true;
                printf("%d %d\n", i, j);
            }
        }
    }
    return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define INF (ll)(1e10)
#define MAX (ll)(1e5 + 5)

ll dp[MAX];
ll n;
vi h;

ll solve(ll i)
{
    if (i < 0)
        return INF;

    if (dp[i] == -1)
        dp[i] = min(solve(i - 1) + llabs(h[i] - h[i - 1]), solve(i - 2) + llabs(h[i] - h[i - 2]));
    return dp[i];
}

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

    cin >> n;
    h.resize(n);

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

    memset(dp, -1, sizeof(dp));

    dp[0] = 0;
    dp[1] = llabs(h[1] - h[0]);

    cout << solve(n - 1) << "\n";
}


Measured memory_bytes: 3328
line = gets
data = line.split(" ")
h = data[0].to_i
w = data[1].to_i
def cmin(s1, s2)
  min = s1 * s2
  if s2 % 2 == 0
    (1..(s1/2)).each do |i|
      s3 = s1 - i
      diff = (s2 * i) - ((s2/2) * s3)
      min = diff.abs if min > diff.abs
    end
  else
    area = Array.new(3)
    (1..(s1/2)).each do |i|
      s3 = s1 - i
      area[0] = s2 * i
      if s3 % 2 == 0
        area[1] = s2 * (s3/2)
        area[2] = s2 * (s3/2)
      elsif s2 < s3
        area[1] = s2 * (s3/2)
        area[2] = s2 * (s3 - s3/2)
      else
        area[1] = (s2/2) * s3
        area[2] = (s2 - s2/2) * s3
      end
      diff = area.max - area.min
      min = diff if min > diff
    end
  end
  return min
end
if h % 3 == 0 or w % 3 == 0
  puts 0
else
  min = cmin(h, w)
  if h != w
    result = cmin(w, h)
    min = result if min > result
  end
  p min
end

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

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

    return 0;
}


Measured memory_bytes: 256
class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]for i in range(N)] 
        self.next = [[ j for j in range(N)]for i in range(N)]  
        self.e = {}
        for i in range(N):
            self.e[i] = []

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def printPath(self,start,goal):
        cur = start
        l = []
        while cur != goal:
            t = self.next[cur][goal]
            self.e[cur].append(t)
            #self.e[t].append(cur)
            cur = t
        return l

    def dumpPath(self):
        for i in range(self.N):
            for j in range(self.N):
                if i != j:
                    self.printPath(i,j)

    def WarshallFloyd_search(self):
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    if self.d[i][j] > self.d[i][k] + self.d[k][j]:
                        self.d[i][j] = self.d[i][k] + self.d[k][j]
                        self.next[i][j] = self.next[i][k]


        self.dumpPath() 
        for i in range(self.N):
            self.d[i][i] = 0
        return self.e
        return self.d


N,M = map(int,input().split())
W = WarshallFloyd(N)
for i in range(M):
    a,b,c = map(int,input().split())
    W.add(a-1,b-1,c)

l = W.WarshallFloyd_search()
ans = M*2
for i in range(N):
    ans -= len(set(l[i]))
print(ans//2)

Measured memory_bytes: 46812
n = int(input())
al = list(map(int, input().split()))
bl = [0]*(n+1)
cl = [0]*(n-1)

for i in range(n):
    bl[i+1] = al[i] + bl[i]

for j in range(1, n):
    cl[j-1] = abs(bl[j] - (bl[n] - bl[j]))

print(min(cl))

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

const int maxn = 1e6;
int n, a[maxn + 3];
char s[maxn + 3];

int main() {
	scanf("%d %s", &n, s), n--;
	bool flag = true;
	for (int i = 0; i <= n; i++) {
		a[i] = s[i] - '1';
		flag &= a[i] != 1;
	}
	if (flag) {
		bool ans = 0;
		for (int i = 0; i <= n; i++) {
			ans ^= (a[i] == 2) && ((i & n) == i);
		}
		puts(ans ? "2" : "0");
	} else {
		bool ans = 0;
		for (int i = 0; i <= n; i++) {
			ans ^= (a[i] & 1) && ((i & n) == i);
		}
		puts(ans ? "1" : "0");
	}
	return 0;
}

Measured memory_bytes: 5120