akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n, x[100007], y[100007], l[57], is[2], cnt;
int read()
{
	int num = 0, f = 1;
	char c = getchar();
	while ((c < '0' || c>'9') && c != '-')c = getchar();
	if (c == '-')f = -1, c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num * f;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
	{
		x[i] = read(), y[i] = read();
		is[(x[i] + y[i]) & 1] = 1;
	}
	if (is[0] && is[1]) { cout << -1 << endl; return 0; }
	if (is[0])l[++cnt] = 1;
	for (int i = 30; i >= 0; i--)l[++cnt] = 1 << i;
	cout << cnt << endl;
	for (int i = 1; i <= cnt; i++)cout << l[i] << ' ';
	cout << endl;
	for (int i = 1; i <= n; i++)
	{
		int a = x[i], b = y[i];
		for (int j = 1; j <= cnt; j++)
			if (abs(a) >= abs(b))
				if (a > 0)a -= l[j], putchar('R');
				else a += l[j], putchar('L');
			else
				if (b > 0)b -= l[j], putchar('U');
				else b += l[j], putchar('D');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
/*input
6
4 6 0 0 3 3
0 5 6 5 0 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int a[maxn],b[maxn];

vector<int> v;

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];

	int ans=0;

	REP(i,29){
		v.clear();
		REP(j,n) v.pb(a[j]&((1<<(i+1))-1));
		sort(ALL(v));

		ll cnt=0;
		REP(j,n){
			ll cur=b[j]&((1<<(i+1))-1);
			ll l=(1<<i)-cur,r=(1<<(i+1))-1-cur;
			if(l<0){
				l+=(1<<(i+1));
				r+=(1<<(i+1));
			}
			//cout<<l<<' '<<r<<'\n';
			if(r>=(1<<(i+1))){
				cnt+=v.end()-lower_bound(ALL(v),l);
				cnt+=upper_bound(ALL(v),r-(1<<(i+1)))-v.begin();
			}
			else{
				cnt+=upper_bound(ALL(v),r)-lower_bound(ALL(v),l);
			}
			//cout<<cnt<<'\n';
		}
		//cout<<i<<' '<<cnt<<'\n';
		if(cnt&1) ans|=(1<<i);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	int h,w,a,b;
    cin>>h>>w>>a>>b;
    vector<string> ans;
    string res;
    rep(i,a)res.push_back('1');
    rep(i,w-a)res.push_back('0');
    rep(i,b)ans.push_back(res);
    rep(i,w){
        if(res[i]=='0')res[i]='1';
        else res[i]='0';
    }
    rep(i,h-b)ans.push_back(res);
    int x=0;
    rep(i,h)cout<<ans[i]<<endl;
}

Measured memory_bytes: 4576
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	x := sc.ReadInt()
	if x >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
import queue

n, m = map(int, input().split())
link = [[] for i in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  link[a - 1].append(b - 1)
  link[b - 1].append(a - 1)

mark = [-1 for i in range(n)]

q = queue.Queue()
q.put(0)

while not q.empty():
  i = q.get()
  for j in link[i]:
    if j != 0 and mark[j] == -1:
      mark[j] = i
      q.put(j)

flag = True
for i in range(1, n):
  if mark[i] == -1:
    flag = False

if flag:
  print("Yes")
  for i in range(1, n):
    print(mark[i] + 1)
else:
  print("No")

Measured memory_bytes: 34380
{-# LANGUAGE BangPatterns, MagicHash #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce
                                 
query :: Int -> [(Int,Int)] -> Int
query n = snd . foldl' loop (Nothing,0) . sortOn snd
  where
    loop (Nothing,i) (_,b) = (Just b, i+1)
    loop (Just x, i) (a,b) | a < x = (Just x, i)
                           | otherwise = (Just b, i+1)
     
main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ls <- replicateM m $ (\(x:y:_)->(x,y)) . map read . words  <$> getLine
  putStrLn $ show $ query n ls

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    string out(m + 2, '#');
    cout << out << '\n'; 
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        cout << '#' << s << '#' << '\n';
    }
    cout << out << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3640
n = int(input())
a = list(map(int,input().split()))
bit = [0]*60
ans = 0
mod = 10**9+7
for i in a:
    cnt = 1
    while i:
        bit[-cnt] += i%2
        i //= 2
        cnt += 1
for i in range(60):
    ans += (n-bit[-1-i])*bit[-1-i] * (2**i) % mod
    ans %= mod
print(ans)

Measured memory_bytes: 122936
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

map<ll,ll> hb,wb,hb2,wb2;
map<pair<ll,ll>,ll> p;
int main(){
    ll h,w,H,W,M,ans=0;
    cin>>H>>W>>M;
    rep(i,0,M){
        cin>>h>>w;
        hb[h]++;
        wb[w]++;
        p[mp(h,w)]++;
    }
    ll hmax=0,wmax=0;
    bool f=false;
    for(auto i:hb)hmax=max(hmax,i.second);
    for(auto i:wb)wmax=max(wmax,i.second);
    for(auto i:hb){
        if(i.second==hmax)hb2[i.first]=1;
    }
    for(auto i:wb){
        if(i.second==wmax)wb2[i.first]=1;
    }
    for(auto i:hb2){
        if(f)break;
        if(i.second==1){
            for(auto j:wb2){
                if(j.second==1&&p[mp(i.first,j.first)]==0)f=true;
                if(f)break;
            }
        }
    }
    if(!f)hmax--;
    cout<<hmax+wmax;
}



Measured memory_bytes: 97236
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1000000000 + 7;
const int N = 100005;
int fac[N], ifac[N];
int pwr(int b, int e)
{
	int ans = 1;
	while (e)
	{
		if (e & 1)
			ans = (1LL * ans * b) % MOD;
		b = (1LL * b * b) % MOD;
		e >>= 1;
	}
	return ans;
}
void pre()
{
	fac[0] = ifac[0] = 1;
	for (int i = 1; i < N; ++i)
	{
		fac[i] = (1LL * i * fac[i - 1]) % MOD;
		ifac[i] = (1LL * pwr(i, MOD - 2) * ifac[i - 1]) % MOD;
	}
}
int ncr(int n, int r)
{
	if (r > n)
		return 0;
	int ans = fac[n];
	ans = (1LL * ans * ifac[r]) % MOD;
	ans = (1LL * ans * ifac[n - r]) % MOD;
	return ans;
}
int main(int argc, char const *argv[])
{
	pre();
	int n, k, ans = 0;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; ++i)
	{
		a[i] = (1LL * a[i] + MOD) % MOD;
	}
	for (int i = 0; i <= n - k; ++i)
	{
		ans = (1LL * ans + (1LL * ncr(n - i - 1, k - 1) * a[i]) % MOD) % MOD;  
	}
	ans = (MOD - ans) % MOD;
	for (int i = k - 1; i < n; ++i)
	{
		ans = (1LL * ans + (1LL * ncr(i, k - 1) * a[i]) % MOD + MOD) % MOD;  
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

int main() {
    ll n, k;
    cin >> n >> k;

    ll ret = 0;
    vector<ll> ans(k + 1);
    for (int i = k; i > 0; i--) {
        ans[i] = calc_pow(k / i, n);
        for (int j = i * 2; j <= k; j += i) {
            ans[i] -= ans[j];
            if (ans[i] < 0)ans[i] += MOD;
        }
        ret += ans[i] * i % MOD, ret %= MOD;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int kaga(int N){
	char str[200];
	sprintf(str,"%d",N);
	int tmp;
	tmp=strlen(str);
	for(int j=0;j+j<tmp;j++)if(str[j]!=str[tmp-j-1])return 0;
	return 1;
	return 1;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;;i++){
		if(kaga(n-i)){
			cout<<n-i<<endl;
			break;
		}
		if(kaga(n+i)){
			cout<<n+i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1200
#include<cstdio>
#include<cstring>

using namespace std;

char moji[10000][1000] = {{0}}; int mojis = 0;

int main(void)
{
	
	int i = 0;

	int m_cnt[1000] = {0},m_cnts = 0;
	int m_cntss = 0;

	char a[10000] = {0};
	scanf("%[^\n]",a);
	int as = strlen(a);

	int m_long = 0,m_longs;
	kitune:;//kariの初期化
	char kari[10000] = {0}; int karis = 0;
	while(i < as)
	{
		if(a[i] == ' ' || i == as - 1)
		{
			if(i == as -1) kari[karis] = a[i];
			int k_flag = 0;
			for(int j = 0;j < mojis;j++)
			{
				if(strcmp(&moji[j][0],kari) == 0) 
				{
					m_cnt[j]++;
					k_flag = 1;
					break;
				}
			}

			if(k_flag == 0)
			{
				strcpy(moji[mojis],kari);
				if(m_long < strlen(moji[mojis]))
				{
					m_long = strlen(moji[mojis]);
					m_longs = mojis;
				}
				mojis++;
			}
			i++;
			goto kitune;
		}
		else
		{
			kari[karis] = a[i];
			karis++;
			i++;
		}
	}

	for(int k = 0;k < mojis;k++)
	{
		if(m_cnts < m_cnt[k])
		{
			m_cnts = m_cnt[k];
			m_cntss = k;
		}
	}

	printf("%s %s\n",&moji[m_cntss][0],&moji[m_longs][0]);
	return 0;
}

Measured memory_bytes: 1032
#include <algorithm>
#include <iostream>
#include <map>
#include <stdio.h>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  map<ll, ll> Counter;
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ++Counter[a];
  }
  for (int i = 0; i < M; ++i) {
    int b, c;
    cin >> b >> c;
    Counter[c] += b;
  }
  vector<vector<ll>> V;
  for (auto pair : Counter) {
    V.push_back(vector<ll>{pair.first, pair.second});
  }
  sort(V.begin(), V.end());
  int cnt = 0;
  ll ans = 0;
  for (int i = V.size() - 1; i >= 0; --i) {
    ans += V[i][0] * min(V[i][1], (ll)(N - cnt));
    cnt += V[i][1];
    if (cnt >= N) {
      break;
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 26756
"use strict";
function Main(input) {
  const args = input.split(' ').map(m => parseInt(m));
  const N = args.shift();
  const K = args.shift()
  let aN = N;
  let rK = K;
  let counter = 1;
  let rate = 0;
  while (true) {
    if (aN >= rK) {
      const win = aN - rK + 1;
      rate += (win / (counter * N));
      aN = rK - 1;
    }
    if (rK === 1) {
      break;
    }
    rK = Math.ceil(rK / 2);
    counter = counter * 2;
  }

  console.log(rate);
}

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


Measured memory_bytes: 7372
# coding: utf-8
_, _, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
rx = X
ry = Y
for x in xs:
    if rx < x:
        rx = x
for y in ys:
    if ry > y:
        ry = y
print(['No War', 'War'][ry - rx < 1])

Measured memory_bytes: 3064
n = int(input())
ans = 0
a = 0
b = 0
both = 0

for i in range(n):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        both += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1
if a <= 0 or b <= 0:
    if a <= 0 and b <= 0:
        if both-1 > 0:
            ans += both-1
    else:
        ans += both
else:
    b -= 1
    a -= 1
    ans += both+1 + min(a,b)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1000050;
const int Mod=19930726;
char s[N];
int tong[30],le;
int main(){
  scanf("%s",s+1);le=strlen(s+1);ll ans=0;
  for(int i=le;i>=1;i--){
    ans+=i-1-tong[s[i]-'a'];tong[s[i]-'a']++;
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 384
ok = True

NM = [map(int, input().split())]
N, M = [list(i) for i in zip(*NM)]

l = [-1] * N[0]

if M[0] != 0:
    sc = [map(int, input().split()) for _ in range(M[0])]
    s, c = [list(i) for i in zip(*sc)]

    for i in range(M[0]):
        if l[s[i]-1] == -1:
            l[s[i]-1] = c[i]
        elif l[s[i]-1] != c[i]:
            ok = False
            break
        
if l[0] == 0 and N[0] >= 2:
    ok = False
elif l[0] == -1:
    if N[0] >= 2:
        l[0] = 1
    else:
        l[0] = 0
    
for i in range(1,N[0]):
    if l[i] == -1:
        l[i] = 0
    
ans = ""   
if ok:
    for i in range(len(l)):
        ans = ans + str(l[i])
    print(ans)
else:
    print("-1")

#print(M[0],N[0])
#print(s[0],c[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll n;
    string s;
    cin>>n;
    cin>>s;
    ll i,j,k,cnt=0;
    for(i=0;i<n-2;i++)
    {
        j=i+1;
        k=j+1;
        if(s[i]=='A' && s[j]=='B' && s[k]=='C')
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string jing=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==jing) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 512
A = []
B = []
n, m, l = map(int,input().split())
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(m):
    B.append(list(map(int,input().split())))

for i in range(n):
    C = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k] * B[k][j]
        C.append(c)
    print(*C)

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

int main(){
    int N,M,x,ans=0;
    int y[1000];
    cin >> N ;
    vector<string>  blue(N);
    for(int i = 0; i < N; i++){
        cin >> blue[i];
    }  
    cin >> M;
    vector<string> red(M);
    for (int i = 0; i < M; i++){
        cin >> red[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            if(blue[i] == blue[j]){
                x++;
            }
        }
        for(int j = 0; j < M; j++){
            if(blue[i] == red[j]){
                x = x - 1;
            }
        }
        if(ans < x){
            ans = x;
        }
        x = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int> II;

int main(int argc, char *argv[]) {
	int n, ans = 0, prev = -2e9;
	cin >> n;
	vector<II> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second;
	}
	v.push_back({ 2e9 + 2, 0 });
	sort(v.begin(), v.end());
	bool ni = false;
	for (int i = 0; i < n; ++i) {
		int cl = v[i].first - v[i].second;
		int cr = v[i].first + v[i].second;
		if (cr <= prev) {
			prev = cr;
		} else if (cl >= prev) {
			++ans;
			prev = cr;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:https://www.ioi-jp.org/joi/2014/2015-ho/2015-ho.pdf>
?????????============================================================

?????¢?????±??????????????????N(1<=N<=2000)????????????????????????????????????????????????
????????????1??????N?????§???????¨???????????????????????????????????????§i???????????????????????§?????????Ai?????????

??????N??????JOI????????¨IOI???????????§?¬??????????????????????

1.
?????? JOI ????????? N ????????????????\??????? 1 ??????????????§?????????

2.
????????????IOI ??????????????????????????? IOI ???????????¨ JOI ??????????????????????????????????????? 1 ??????????????£????????????
?????????????????£??????????????????????°?????????¨??????????????¢????????????????????????????????????????????????????????¨?????§?????????
??????????????????????????°????????¨?????????IOI ????????????????????????????????§???????????????????????§?????????
JOI ???????????????????????§?\????????????????????????§???????????¨?????§?????????

JOI ?????????????????????????????????????????????????????§?????????????¨?????????§???????????????
=================================================================
?§£??¬=============================================================
================================================================
*/
ll res = 0;
ll N;
vector<ll> A;
vector<vector<ll>> memo;
ll rec(int l, int r, int cur, bool first) {
	if (first) {
		return rec((l - 1 + N) % N, (r + 1) % N, 1, false) + A[l];
	}
	if (l == r) {
		if (cur == 0) {
			if (memo[l][r] != 0)return memo[l][r];
			else return memo[l][r] = A[l];
		}
		else {
			return 0;
		}
	}

	if (cur == 0) {
		ll& res = memo[l][r];
		if (res != 0)return res;
		res = max(res, rec((l - 1 + N) % N, r, 1, false) + A[l]);
		res = max(res, rec(l, (r + 1) % N, 1, false) + A[r]);
		return res;
	}
	else {
		if (A[l] > A[r]) {
			return rec((l - 1 + N) % N, r, 0, false);
		}
		else {
			return rec(l, (r + 1) % N, 0, false);
		}
	}
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> N;
	A.assign(N, 0);
	memo.assign(N, vector<ll>(N, 0));
	for (auto& in : A) cin >> in;
	ll res = 0;
	for (int i = 0; i < N;i++) {
		res = max(res, rec(i, i, 0, true));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 34276
#include<stdio.h>

int A[100000];

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

int main(void){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &A[i]);
    int ip = partition(A, 0, n);
    for(int i=0; i<n; i++){
        if(i == ip)
            printf("[%d]", A[i]);
        else
            printf("%d", A[i]);
        putchar(i < n - 1 ? ' ' : '\n');
    }
}



Measured memory_bytes: 2100
//40
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define INF ((1<<31)^~0)

vector<vector<int> > d;

int que(const vector<int> &d,int a,int b,int k,int l,int r){
  if(r<=a||b<=l){
    return INF;
  }else if(a<=l&&r<=b){
    return d[k];
  }else{
    return min(que(d,a,b,k*2+1,l,(l+r)/2)
	       ,que(d,a,b,k*2+2,(l+r)/2,r));
  }
}

int main(){
  for(int r,c,q;cin>>r>>c>>q,r|c|q;){
    vector<vector<int> > g;
    bool w=r<c;
    if(w){
      g=vector<vector<int> >(r,vector<int>(c));
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++){
	  cin>>g[i][j];
	}
      }
    }else{
      g=vector<vector<int> >(c,vector<int>(r));
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++){
	  cin>>g[j][i];
	}
      }
      swap(r,c);
    }
    int cc;
    for(cc=1;cc<c;cc*=2);
    d=vector<vector<int> >(r,vector<int>(cc*2-1,INF));
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
	int k=j+cc-1;
	d[i][k]=g[i][j];
	while(k>0){
	  k=(k-1)/2;
	  d[i][k]=min(d[i][k*2+1],d[i][k*2+2]);
	}
      }
    }
    while(q--){
      int r1,c1,r2,c2;
      if(w){
	cin>>r1>>c1>>r2>>c2;
      }else{
	cin>>c1>>r1>>c2>>r2;
      }
      int m=INF;
      for(int i=r1;i<=r2;i++){
	m=min(m,que(d[i],c1,c2+1,0,0,cc));
      }
      cout<<m<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 31452
#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;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
int n;
cin >> n;

bool p = false;

rep(i,10){
    rep(j,10){
        if(i*j == n) p = true;
    }
}

if(p) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,c;
	if(0<=A&&A<=23){
		if(0<=B&&B<=23)
		{
			scanf("%d%d",&A,&B);
			c=A+B;
			int f=c%24;
			printf("%d",f);
		}
		else
		{
			printf("Error");
		}	
	}
	else
	{
		printf("Error");
	}
}

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

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

using namespace std;

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

    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double sub_deg = 30.0 * H + 30.0 * M / 60.0 - 6.0 * M;
    cout << fixed << setprecision(10) << pow(A * A + B * B - 2.0 * A * B * cos(sub_deg * M_PI / 180.0), 0.5) << endl;
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
long long int tree[4*N]={0};
#define ff first
#define ss second
void update(long int node,long int l,long int r,long int ind,long long int val)
{
    if(l==r)
    {
        tree[node] = val;
    }
    else
    {
        long int mid = (l+r)/2;
        if(mid>=ind)
         update(2*node+1,l,mid,ind,val);
         else
         update(2*node+2,mid+1,r,ind,val);
         tree[node] = max(tree[2*node+1],tree[2*node+2]);
    }
}
long long int query(long int node,long int l,long int r,long int L,long int R)
{
    if(L>r || l>R)
    return 0;
    if(L<=l && R>=r)
    return tree[node];
    long int mid = (l+r)/2;
    return max(query(2*node+1,l,mid,L,R),query(2*node+2,mid+1,r,L,R));
}
long long int mod = 1e9+7;
bool compare(pair<long long int,long long int> a,pair<long long int,long long int> b)
{
    return a.ff>b.ff;
}
int main()
{
    long int t=1;
    // cin>>t;
    long int kk=0;
    while(t--)
    {
       long long int d,t,s;
       cin>>d>>t>>s;
       if(t*s>=d)
       cout<<"Yes"<<endl;
       else
       cout<<"No"<<endl;
    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct Seg{
  int n;
  vector<ll>node,lazy;
  vector<bool>lazyFlag;

  Seg(vector<ll>v){
    n=1;
    while(n<v.size())n*=2;
    node.resize(2*n-1,INF);
    lazy.resize(2*n-1,INF);
    lazyFlag.resize(2*n-1,false);
    for(int i=0;i<v.size();i++)node[n-1+i]=v[i];
    for(int i=n-2;i>=0;i--){
      node[i]=min(node[2*i+1],node[2*i+2]);
    }
  }
  ll operator[](int index){
    return node[n-1+index];
  }
  void eval(int k){
    if(lazyFlag[k]){
      node[k]=lazy[k];
      if(k<n-1){
        lazy[2*k+1]=lazy[2*k+2]=lazy[k];
        lazyFlag[2*k+1]=lazyFlag[2*k+2]=true;
      }
      lazyFlag[k]=false;
    }
  }
  ll getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    eval(k);
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return node[k];
    ll vl=getmin(a,b,2*k+1,l,(r+l)/2);
    ll vr=getmin(a,b,2*k+2,(r+l)/2,r);
    return min(vl,vr);
  }
  void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    eval(k);
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){
      lazy[k]=x;
      lazyFlag[k]=true;
      eval(k);
    }
    else{
      add(a,b,x,2*k+1,l,(l+r)/2);
      add(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=min(node[2*k+1],node[2*k+2]);
    }
  }
};

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

  int N,Q;
  cin>>N>>Q;
  vector<ll>S(N),T(N),X(N),D(Q);
  for(int i=0;i<N;i++)cin>>S[i]>>T[i]>>X[i]; for(int i=0;i<Q;i++)cin>>D[i];
  Seg seg(vector<ll>(Q,INF));
  vector<tuple<ll,ll,ll>>memo;
  for(int i=0;i<N;i++){
    int r=Q;
    int l=-1;
    int m;
    while(r-l>1){
      m=(r+l)/2;
      if(S[i]-X[i]>D[m])l=m;
      else r=m;
    }
    int r2=Q;
    int l2=r-1;
    int m2;
    while(r2-l2>1){
      m2=(r2+l2)/2;
      if(T[i]-X[i]-1>=D[m2])l2=m2;
      else r2=m2;
    }
    tuple<ll,ll,ll>a(X[i],r,r2);
    memo.push_back(a);
  }
  sort(rng(memo));
  reverse(rng(memo));
  for(auto it:memo)seg.add(get<1>(it),get<2>(it),get<0>(it));
  for(int i=0;i<Q;i++){
    ll res=seg.getmin(i,i+1);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 23012
#include<cstdio>
using namespace std;
#define N 605
#define mod 1000000007
int dp[N][N],n,m,a,b,t[N],s[N],su[N],as;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&a,&b),t[a]=b,t[b]=a;
	s[0]=1;for(int i=2;i<=n*2;i++)s[i]=1ll*s[i-2]*(i-1)%mod;
	for(int i=1;i<=n*2;i++)su[i]=su[i-1]+!t[i];
	for(int l=1;l<=n*2;l++)
	for(int i=1;i+l<=n*2;i++)
	{
		int j=i+l;
		int fg=1;
		for(int k=i;k<=j;k++)if((t[k]<i||t[k]>j)&&t[k])fg=0;
		if((su[j]^su[i-1])&1)fg=0;
		if(!fg)continue;
		int tp=s[su[j]-su[i-1]];
		for(int k=i;k<j;k++)tp=(tp-1ll*dp[i][k]*s[su[j]-su[k]]%mod+mod)%mod;
		dp[i][j]=tp;as=(as+1ll*tp*s[su[n*2]-su[j]+su[i-1]])%mod;
	}
	printf("%d\n",as);
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}
int main(){
  ll A,B;
  cin>>A>>B;
  ll C=gcd(A,B);
  ll ans=1;
  for(ll i=2;i*i<=C;i++){
    if(C%i==0){
      ans++;
      while(C%i==0){C/=i;}
    }
  }
  if(C>1){ans++;}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 10000000000
using namespace std;
using ll = long long;
int main()
{
    ll h;
    cin >> h;
    ll cnt = 1;
    ll ans = 1;
    h /= 2;
    while(h){
        h /= 2;
        cnt *= 2;
        ans += cnt;
    }
    cout << ans << endl;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2]<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string A; cin >> A;
    long long count[26] = {}, ans = 0;
    for (int i = 0; i < A.size(); i++) {
        count[A[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        ans += count[i] * (A.size() - count[i]);
    }
    cout << ans / 2 + 1 << endl;
    return 0;
}

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

const int INF = 1e9 + 7;

int main() {
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    // dp[i] - minimum cost of reaching stone i
    vector<int> dp(n, INF);
    for(int i=0; i<n; i++) cin>>a[i];
    dp[0] = 0;
    for(int i=0; i<n; i++)
        for(int j=1; i+j<n && j<=k; j++)
            dp[i+j] = min(dp[i+j], dp[i] + abs(a[i]- a[i+j]));
    cout<<dp.back()<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

main()
{
	int A,B,C,X,Y,x;
	scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
	if (X>Y){
		if ((A+B)>(2*C)){
			x=Y*2*C;
		}else{
			x=Y*(A+B);
		}
		if (A>(2*C)){
			x=x+(X-Y)*2*C;
		}else{
			x=x+(X-Y)*A;
		}
	}else{
		if ((A+B)>(2*C)){
			x=X*2*C;
		}else{
			x=X*(A+B);
		}
		if (B>(2*C)){
			x=x+(Y-X)*2*C;
		}else{
			x=x+(Y-X)*B;
		}
	}
	printf("%d",x);
}		

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

int main()
{
	int M, N, E = 0;
	cin >> M >> N;

	for (int i = 0, a; i < N; i++)
	{
		cin >> a;
		E += a;
	}
	if (M < E)
	{
		cout << -1;
	}
	else
	{
		cout << M - E;
	}
}

Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
#define LL long long int

int main()
{
    set <char> St;
    char a, b, c;
    cin >> a >> b >> c;
    St.insert(a);
    St.insert(b);
    St.insert(c);
    if(St.size() == 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

typedef long long ll;

const int maxn = 1e6 + 1e2;
int val[maxn];
int dp[maxn][2];
int n, a, b;

int dfs(int pos, int side){
	if(dp[pos][side] == -1){
		if(side == 0){
			dp[pos][side] = 0;
		} else {
			dp[pos][side] = 1000000000;
		}

		for(int i = pos; i < n - 1; i++){
			if(side == 0){
				dp[pos][side] = std::max(dp[pos][side], dfs(i + 1, !side));
			} else {
				dp[pos][side] = std::min(dp[pos][side], dfs(i + 1, !side));
			}
		}

		if(pos == 0){
			if(side == 0){
				dp[pos][side] = std::max(dp[pos][side], std::abs(val[n - 1] - b));
			} else {
				dp[pos][side] = std::min(dp[pos][side], std::abs(val[n - 1] - b));
			}
		} else {
			if(side == 0){
				dp[pos][side] = std::max(dp[pos][side], std::abs(val[n - 1] - val[pos - 1]));
			} else {
				dp[pos][side] = std::min(dp[pos][side], std::abs(val[n - 1] - val[pos - 1]));
			}
		}
	}

	return dp[pos][side];
}

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

	std::cin >> n >> a >> b;
	
	memset(dp, -1, sizeof(dp));

	for(int i = 0; i < n; i++){
		std::cin >> val[i];
	}

	std::cout << dfs(0, 0) << '\n';
}

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define MOD 1000000007
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

using namespace std;

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

	int a,b,c; cin>>a>>b>>c;

	cout<<max(0,c-a+b);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <queue>
#include <map>
#include <string>
const int INF = 99999999;
const int MIN = -0xffffff0;
using namespace std;

int main(){
    char s[5];
    cin >> s;
    int sum = 0;
    for(int i=1;i<=3;i++){
        if(sum == 2) continue;
        if(s[i] - s[i-1] == 0){
            if(++sum == 2) continue;
        }
        else sum = 0;
    }
    if(sum >= 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]", L: "List[int]"):
    if N == 1:
        print(1)
        return

    schedule = []
    for i in range(N):
        schedule.append((X[i]-L[i],X[i]+L[i]))
    
    schedule.sort(key= lambda x: x[1])

    ans = 0
    t = -10**10
    for i in range(N):
        if t <= schedule[i][0]:
            ans += 1
            t = schedule[i][1]
    
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    L = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        L[i] = int(next(tokens))
    solve(N, X, L)

if __name__ == '__main__':
    main()


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N;

int f(vector<int>& A,int num)
{
	int res = 0;
	FOR(i,0,A.size()){
		res += (A [i] - num) * (A [i] - num);
	}

	return res;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	vector<int> A(N);
	FOR(i,0,N){
		cin >> A [i];
	}

	int mn = INT_MAX;
	for(int i = -100;i <= 100;i++){
		mn = min(f(A,i),mn);
	}

	cout << mn << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int l = 0;
    int r = N;
    int ans = -1;
    while(l < r) {
      int med = (l + r) / 2;
      boolean[][] dp = new boolean[N][K + 1];
      dp[0][0] = true;
      if(med != 0 && a[0] < K + 1) dp[0][a[0]] = true;
      for(int j = 1; j < N; j++) {
        for(int k = 0; k < K + 1; k++) {
          if(med == j) {
            dp[j][k] = dp[j - 1][k];
          } else {
            if(k >= a[j]) {
              dp[j][k] = dp[j - 1][k] || dp[j - 1][k - a[j]];
            } else {
              dp[j][k] = dp[j - 1][k];
            }
          }
        }
      }
      boolean flg = false;
      for(int j = Math.max(0, K - a[med]); j < K; j++) {
        flg = flg || dp[N - 1][j];
      }
      if(flg) {
        r = med;
      } else {
        l = med + 1;
        ans = med;
      }
    }
    System.out.println(ans + 1);
  }
}

Measured memory_bytes: 176080
#include <iostream>
int main() {
	using namespace std;
	int k, n, max;
	cin >> k >> n;
	max = 0;
	int a, l=0;
	int f = -1;
	for (int i = 0; i<n; i++) {
		cin >> a;
		if (f == -1) {
			f = a;
		}
		if (max < (a - l)) {
			max = a - l;
		}
		l = a;
	}
	if (max < (f+(k-a))) {
		max = f + (k - a);
	}
	cout << (k - max);
	return 0;
}

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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    LL i,n,x,y,ans=0;
    cin >> n;
    for(i=2;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            x=0,y=1;
            while(n%i == 0)++x,n/=i;
            while(x >= y)
            {
                x-=y;
                ++y,++ans;
            }
        }
    }
    if(n > 1)++ans;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
	int N, i;
	int src_t, src_x, src_y;
	int dest_t = 0, dest_x = 0, dest_y = 0;
	int delta_t, delta_x, delta_y;
	int f;

	cin >> N;

	for (i = 0; i < N; i++){
		src_t = dest_t;
		src_x = dest_x;
		src_y = dest_y;

		cin >> dest_t;
		cin >> dest_x;
		cin >> dest_y;

		delta_t = dest_t - src_t;
		delta_x = dest_x - src_x;
		delta_y = dest_y - src_y;

		if (delta_x < 0) delta_x *= (-1);
		if (delta_y < 0) delta_y *= (-1);

		f = (delta_t - (delta_x + delta_y));

		if (f < 0 || f % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b), i++)
#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {

	string s;
	int w;

	cin >> s >> w;

	for (int i = 0; i < s.size(); i += w) {
		cout << s[i];
	}

	cout << endl;

	return 0;
}

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

int main(void) {
	string S;
	cin >> S;

	string ans = "Good";
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3])
		ans = "Bad";

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100002
using namespace std;
const int p=1e9+7;
struct Que{
	int c,w,id,f;
};
struct node{
	int to,c,w;
};
int n,m,fa[N][19],nc[N],len[N],dis[N],ans[N],sc[N],dep[N];
vector<node>s[N];
vector<Que>q[N];
void dfs1(int x,int f,int w){
	dep[x]=dep[f]+1;fa[x][0]=f;dis[x]=dis[f]+w;
	for(int i=0;i<(int)s[x].size();i++){
		int y=s[x][i].to;
		if(y==f)continue;
		dfs1(y,x,s[x][i].w);
	}
}
void dfs2(int x,int f){
	for(int i=0;i<(int)s[x].size();i++){
		int c=s[x][i].c,y=s[x][i].to,w=s[x][i].w;
		if(y==f)continue;
		nc[c]++;sc[c]+=w;
		dfs2(y,x);
		nc[c]--;sc[c]-=w;
	}
	for(int i=0;i<(int)q[x].size();i++){
		int c=q[x][i].c;
		ans[q[x][i].id]+=q[x][i].f*(dis[x]-sc[c]+nc[c]*q[x][i].w);
	}
}
int Up(int x,int step){
	for(int i=0;i<19;i++){
		if(step&(1<<i))x=fa[x][i];
	}
	return x;
}
int LCA(int x,int y){
	if(dep[x]>dep[y])swap(x,y);
	y=Up(y,dep[y]-dep[x]);
	if(y==x)return y;
	for(int i=18;i>=0;i--){
		if(fa[x][i]!=fa[y][i]){
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v,c,w;i<n;i++){
		scanf("%d%d%d%d",&u,&v,&c,&w);
		s[u].push_back((node)<%v,c,w%>);s[v].push_back((node)<%u,c,w%>);
	}
	dfs1(1,0,0);
	for(int j=1;j<19;j++)for(int i=1;i<=n;i++)fa[i][j]=fa[fa[i][j-1]][j-1];
	for(int i=1,x,y,u,v;i<=m;i++){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		int L=LCA(u,v);
		q[u].push_back((Que)<%x,y,i,1%>);q[v].push_back((Que)<%x,y,i,1%>);
		q[L].push_back((Que)<%x,y,i,-2%>);
	}
	dfs2(1,0);
	for(int i=1;i<=m;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 32372
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  if a[i]%2 == 0:
    if a[i]%3 == 0 or a[i]%5 == 0:
      continue
    else:
      print('DENIED')
      exit(0)
      
print('APPROVED')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int c1[3], c2[3], c3[3];
	for (int i = 0; i < 3; i++) {
		cin >> c1[i] >> c2[i] >> c3[i];
	}
	if (c1[0] - c2[0] == c1[1] - c2[1] && c1[1] - c2[1] == c1[2] - c2[2]) {
		if (c2[0] - c3[0] == c2[1] - c3[1] && c2[1] - c3[1] == c2[2] - c3[2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string s[52] = {}, yojo[52];
	int a, b, cnt = 0, yan;
	cin >> a >> b;
	for (int i = 1; i <= a; i++) {
		yojo[i] = "b";
		cin >> s[i];
		yojo[i] += s[i];
		yojo[i] += "b";
	}
	for (int i = 1; i <= a; i++) {
		for (int j = 1; j <= b; j++) {
			if (yojo[i][j] == '#') {
				cout << yojo[i][j];
			}
			else {
				if (yojo[i - 1][j - 1] == '#') {
					cnt++;
				}
				if (yojo[i - 1][j] == '#') {
					cnt++;
				}
				if (yojo[i - 1][j + 1] == '#') {
					cnt++;
				}
				if (yojo[i][j - 1] == '#') {
					cnt++;
				}
				if (yojo[i][j + 1] == '#') {
					cnt++;
				}
				if (yojo[i + 1][j - 1] == '#') {
					cnt++;
				}
				if (yojo[i + 1][j + 1] == '#') {
					cnt++;
				}
				if (yojo[i + 1][j] == '#') {
					cnt++;
				}
				cout << cnt;
			}
			cnt = 0;
		}
		cout << endl;
	}
	return 0;
}

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

int n, c ;
int d[33][33] ;
int g[505][505] ;

void getInput(){
    cin >> n >> c ;

    for(int i = 1 ; i <= c ; i++){
        for(int j = 1 ; j <= c ; j++){
            cin >> d[i][j] ;
        }
    }

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n; j++){
            cin >> g[i][j] ;
        }
    }
}

int main(){

    getInput() ;

    vector<pair<int, int> > points[3] ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n; j++){
            points[(i + j) % 3].push_back({i, j}) ;
        }
    }
///////////////////////////////////////////////////////////////
    vector<pair<int, int> > best3[3] ;

    for(int i = 0 ; i < 3 ; i++){
        vector<pair<int, int> > costs ; // cost, color

        for(int j = 1 ; j <= c ; j++){ // color select
            int cost = 0 ;
            for(auto p : points[i]){
                cost += d[g[p.first][p.second]][j] ;/////////
            }
            costs.push_back({cost, j}) ;
        }

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

        best3[i].push_back(costs[0]) ;
        best3[i].push_back(costs[1]) ;
        best3[i].push_back(costs[2]) ;
    }

    int ans = INT_MAX ;

    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            for(int k = 0 ; k < 3 ; k++){
                if(best3[0][i].second != best3[1][j].second && best3[1][j].second != best3[2][k].second && best3[2][k].second != best3[0][i].second)
                    ans = min(best3[0][i].first + best3[1][j].first + best3[2][k].first, ans) ;
            }
        }
    }

    cout << ans << endl ;

    return 0 ;
}

Measured memory_bytes: 3504
K = int(input())
from collections import deque

X = deque([1,2,3,4,5,6,7,8,9])

for i in range(1,K+1):
    ans = X.popleft()
    if ans%10!=0:
        temp = ans*10 + (ans%10)-1
        X.append(temp)

    temp = ans*10 + (ans%10)
    X.append(temp)
    
    if ans%10!=9:
        temp = ans*10 + (ans%10)+1
        X.append(temp)

print(ans)

Measured memory_bytes: 18648
o = input()
e = input()
out=''
for i in range(min(len(o),len(e))):
    out = out+o[i]+e[i]
    

if len(o)>len(e):
  out = out+o[len(o)-1]
elif len(o)<len(e):
  out = out+e[len(e)-1]
else:
  out=out
print(out)

Measured memory_bytes: 3064
N,L=gets.split.map &:to_i
A=gets.split.map &:to_i
i = (1...A.size).to_a.find{|i|A[i-1]+A[i]>=L}
unless i
  puts :Impossible
  exit
end
puts :Possible
1.upto(i-1){|i|p i}
(N-1).downto(i+1){|i|p i}
p i


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


using namespace std;

int main(){
  int N,A,B;

 cin >>N;

 A=floor(N/100);
 B=A*100+A*5;
 
 if(N<100){
 cout<<0;
 }
 else if(N>=2000){ 
  cout<<1;
 }
 else if (N<=B){
  cout<<1;
 }
 else {
 cout <<0;
}
return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

path = defaultdict(lambda: [])
N = int(input())
for _ in range(N-1):
    a, b = inpl()
    path[a].append(b)
    path[b].append(a)

inf = float('inf')
ctr = 1
now = {1}
distF = [inf for _ in range(N+1)]
distF[1] = 0
while True:
    for na in now.copy():
        na = now.pop()
        for nb in path[na]:
            if distF[nb] > distF[na] + 1:  
                distF[nb] = distF[na] + 1
                now.add(nb)
                ctr += 1
    if ctr >=  N:
        break
ctr = 1
now = {N}
distS = [inf for _ in range(N+1)]
distS[N] = 0
while True:
    for na in now.copy():
        na = now.pop()
        for nb in path[na]:
            if distS[nb] > distS[na] + 1:  
                distS[nb] = distS[na] + 1
                now.add(nb)
                ctr += 1
    if ctr >=  N:
        break
ctr = 0
for i in range(1,N+1):
    if distF[i] <=  distS[i]:
        ctr += 1
if 2*ctr > N:
    print('Fennec')
else:
    print('Snuke')

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

#define ll int64_t
using namespace std;
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    IOS

    ll a;
    double b;
    cin>>a>>b;
    ll bb=(b*100)+0.5;
    ll ans=bb*a;
    ans=ans/100;
    cout<<ans<<endl;

}

Measured memory_bytes: 3732