akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int N,f = 0;
  cin >> N;
  for(int i = 1; i<10 ; i++)
  {
      if(N % i == 0 && N/i < 10)
      {
          f = 1;
          break;
      }
  }
  if(f==1) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}



Measured memory_bytes: 256
n,x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
ans = 0
for i in 1..n-1
  if a[i-1]+a[i]>x&&a[i-1]<=x
    ans += (a[i-1]+a[i])-x
    a[i] = a[i]-(a[i-1]+a[i]-x)
  elsif a[i-1]+a[i]>x&&a[i-1]>x
    ans += (a[i-1]+a[i])-x
    a[i] = 0
  end
end

puts ans
    


Measured memory_bytes: 8588
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  long x;
  cin>>x;
  long ans = LONG_MAX;
  while(x >= 100){
    ans = min<long>(ans, abs(x%1000-753));
    x /= 10;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void dp(int,int,int);
int ans,s;

int main(){
	int n;
	while(1){
		ans = 0;
		scanf("%d %d",&n,&s);
		if(!n && !s) break;
		dp(0,n,0);
		printf("%d\n",ans);
	}
	return 0;
}

void dp(int sum,int n,int m){
	int i;
	if(m > 9){
		if(!n && sum == s) ans++;
		return;
	}
	dp(sum + m,n - 1,m + 1);
	dp(sum,n,m + 1);
	return;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
from sys import stdin

d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N = d_in()
A_list = ds_in()

ans = 0
s, e = 0, 0
sum_As = A_list[s]
while e < N-1:
    if (sum_As & A_list[e+1]) != 0:
        ans += (e - s + 1)
        sum_As -= A_list[s]
        s += 1
        if s > e:
            e = s
            sum_As = A_list[s]
    else:
        sum_As += A_list[e+1]
        e += 1
ans += (e - s + 1) * (e - s + 2) // 2
print(ans)


Measured memory_bytes: 24228
#include <iostream>
#include <algorithm>

using namespace std;

bool check(int year)
{
  if(year%400 == 0 || (year%4 == 0 && year%100 != 0))
    return true;

  return false;
}

int main()
{
  int a, b;
  bool flg = false;

  while(cin>>a>>b && a+b){
    if(flg) cout << endl;

    flg = false;
    for(int year = a; year <= b; ++year){
      if(check(year)){
	cout << year << endl;
	flg = true;
      }
    }

    if(!flg) cout << "NA" << endl;
    flg = true;
  }
}

Measured memory_bytes: 1156
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

ll dp[120][2][500];

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  dp[0][1][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      for (int a = 0; a <= 9; ++a) {
        if (a == 0) {
          dp[i + 1][(s[i] == '0')][j] += dp[i][1][j];
          dp[i + 1][0][j] += dp[i][0][j];
        } else if (a < s[i] - '0') {
          dp[i + 1][0][j + 1] += dp[i][1][j];
          dp[i + 1][0][j + 1] += dp[i][0][j];
        } else if (a == s[i] - '0') {
          dp[i + 1][1][j + 1] += dp[i][1][j];
          dp[i + 1][0][j + 1] += dp[i][0][j];
        } else {
          dp[i + 1][0][j + 1] += dp[i][0][j];
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    cout << n * n * n;
}

Measured memory_bytes: 256
N=int(input())
S_list=[]
for n in range(N):
    S_list.append(input())
    
S_list=sorted([sorted(s) for s in S_list])   
count_list=[]
tmp_count=0
for n in range(N-1):
    left=S_list[n]
    right=S_list[n+1]
    if left==right:
        tmp_count+=1
    else:
        count_list.append(tmp_count+1)
        tmp_count=0
count_list.append(tmp_count+1)
count_list=[c*(c-1)//2 for c in count_list]
print(sum(count_list))

Measured memory_bytes: 32600
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int h,w,flag,i,j;
	char a,b;
	a='#';
	b='.';
	
	while (1) {
		cin >> h >> w;
		if (h==0&&w==0) {
			break;
		}
		
		for (i=0;i<h;i++) {
			for (j=0;j<w;j++) {
				flag=i+j;
				if ( flag % 2 == 0 ) {
					cout << a;
				}else{
					cout << b;
				}
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 1152
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Control.Arrow
import Control.Monad

divisibles :: [Int] -> VU.Vector Int
divisibles nums = VU.create $ do
            vec <- VUM.replicate (m + 1) 0
            forM_ nums $ \factor -> do
                alreadyMulted <- VUM.read vec factor
                VUM.modify vec (+ 1) factor
                when (alreadyMulted < 1) $ do
                forM_ [factor*2, factor*3 .. m] $ \mult -> do
                    VUM.modify vec (+ 1) mult
            return vec
        where
            m = maximum nums + 1

main = do
  let readInt = fmap (second B.tail) . B.readInt
  [n] <- map read . words <$> getLine
  pss <- VU.unfoldrN n readInt <$> B.getLine
  let ps = sort $ VU.toList pss
  let ans = divisibles ps
--   putStrLn $ show ans
  let asnss = filter (\x -> ans VU.! x == 1) $ ps
  putStrLn $ show $ length asnss


Measured memory_bytes: 35824
#include <stdio.h>
int n, a[12], b[12];
int main() {
    while(true) {
        scanf("%d", &n);
        if(n == 0) break;
        for(int i = 0; i < n; i++) scanf("%d", &a[i]);
        int ret = 0;
        while(true) {
            for(int i = 0; i < n; i++) {
                b[i] = 0;
                for(int j = 0; j < n; j++) {
                    if(a[i] == a[j]) {
                        b[i]++;
                    }
                }
            }
            bool flag = true;
            for(int i = 0; i < n; i++) {
                if(a[i] != b[i]) {
                    flag = false;
                }
                a[i] = b[i];
            }
            if(flag) break;
            ret++;
        }
        printf("%d\n", ret);
        for(int i = 0; i < n; i++) {
            if(i) printf(" ");
            printf("%d", a[i]);
        }
        printf("\n");
    }
    return 0;
}

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

int main() {
  int N;
  scanf("%d",&N);
  long long int L[N+1];
  L[0]=2;
  L[1]=1;
  for (int i=2; i<=N; i++) {
    L[i]=L[i-1]+L[i-2];
  }
  printf("%lld\n",L[N]);
  return 0;
}


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	total := 0
	minus := 0
	for i := 0; i < N; i++ {
		if A[i] < 0 {
			minus++
			A[i] = -A[i]
		}
		total += A[i]
	}
	mi := A[0]
	for i := 1; i < N; i++ {
		if A[i] < mi {
			mi = A[i]
		}
	}
	if minus%2 == 0 {
		fmt.Fprintln(wtr, total)
	} else {
		fmt.Fprintln(wtr, total-2*mi)
	}
}


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

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

const int MAXR=12;
const int MAXC=10001;
bool S[MAXR][MAXC];

int main()
{
        int r,c;
        while(cin>>r>>c&&(r|c))
        {
                rep(y,r) rep(x,c) cin>>S[y][x];

                int ans=0,res,v;
                rep(i,(1<<r))
                {
                        rep(y,r) if((i>>y)&1) rep(x,c) S[y][x]=!S[y][x];

                        res=0;
                        rep(x,c){ v=0; rep(y,r){ v+=S[y][x]?1:0; } res+=max(v,r-v); }
                        ans=max(ans,res);

                        rep(y,r) if((i>>y)&1) rep(x,c) S[y][x]=!S[y][x];
                }

                cout<<ans<<endl;
        }
        return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  long long n;
  cin >> n;
  long long y = 100;
  int year = 0;
  while(y<n){
    y = (long long)((double)(y) * 1.01);
    year++;
  }
  cout << year << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<P> a(n);
	for(int i = 0; i < n; i++) {
		ll x,y;cin>>x>>y;
		a[i] = mp(x,y);
	}
	sort(ALL(a));
	cout << (a[0].fs - 1) + (a[n - 1].fs - a[0].fs + 1) + a[n - 1].sc<< endl;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll N;
ll T[100005];
ll A[100005];

PLL RT[100005];
PLL RA[100005];
ll ans = 1;

const ll mod = 1e+9 + 7;

ll common_range(int i) {
	ll p = max(RT[i].first, RA[i].first);
	ll q = min(RT[i].second, RA[i].second);
	if (p <= q) {
		return q - p + 1;
	} else {
		return 0;
	}
}


void solve() {
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			// 確定
			RT[i].first = T[i];
			RT[i].second = T[i];
			continue;
		} 

		if (T[i - 1] < T[i]) {
			// 確定
			RT[i].first = T[i];
			RT[i].second = T[i];
		} else {
			// 未確定
			RT[i].first = 1;
			RT[i].second = T[i];
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (i == N - 1) {
			// 確定
			RA[i].first = A[i];
			RA[i].second = A[i];
			continue;
		}

		if (A[i] > A[i + 1]) {
			// 確定
			RA[i].first = A[i];
			RA[i].second = A[i];
		} else {
			// 未確定
			RA[i].first = 1;
			RA[i].second = A[i];
		}
	}

#if 0
	for (int i = 0; i < N; i++) {
		printf("%lld %lld\n", RT[i].first, RT[i].second);
	}
	cout << "---" << endl;
	for (int i = 0; i < N; i++) {
		printf("%lld %lld\n", RA[i].first, RA[i].second);
	}
#endif


	// check
	for (int i = 0; i < N; i++) {
		ll r = common_range(i);
		ans *= r;
		ans %= mod;
	}

	cout << ans << endl;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	solve();
	return 0;
}




Measured memory_bytes: 4992
def m():
    N, C = map(int, input().split())
    s = []
    t = []
    c = []
    for i in range(N):
        x, y, z = map(int, input().split())
        s.append(x)
        t.append(y)
        c.append(z)

    TIME = 100002
    recod = [[0 for _ in range(1, TIME+1)] for _ in range(1, C+2)]
    for n in range(N):
        for k in range(s[n], t[n]+1):
            recod[c[n]][k] = 1

    recodcnt = 1
    for n in range(TIME):
        tmp = 0
        for g in range(1, C+1):
            if recod[g][n] == 1:
               tmp += 1
        recodcnt = max(tmp, recodcnt)
    return recodcnt


print(m())

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

Measured memory_bytes: 3060
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(std::string S) {
  bool result;

  bool c1 = S.at(0) == 'A';
  bool c2 = false;
  int p;
  for (int i = 2; i < sz(S) - 1; i++) {
    if (S.at(i) == 'C') {
      if (c2) {
        c2 = false;
        break;
      } else {
        p = i;
        c2 = true;
      }
    }
  }

  bool c3 = true;
  rep(i, sz(S)) {
    if (i == 0 || i == p) {
      continue;
    } else {
      c3 = c3 && islower(S.at(i));
    }
  }

  result = c1 && c2 && c3;

  if (result) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

// 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)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int solve(int ans, int start, int stop, int sum) {
	int i, c = 0;
	for (i = start; i < stop; i++) {
		if (stop != 10)
			c += solve(ans, i + 1, stop + 1, sum + i);
		else if ((sum + i) == ans)
			return c + 1;
	}
	return c;
}
int main() {
	int num, ans;
	while(1) {
		scanf(" %d %d", &num, &ans);
		if (num == 0 && ans == 0)
			break;
		printf("%d\n", solve(ans, 0, 10 + 1 - num, 0));
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    std::int64_t r, d, x;
    std::cin >> r >> d >> x;
    for (auto i : boost::irange(0, 10)) {
        x = r * x - d;
        out(x);
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


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

using namespace std;

int main(){
	char s[20];
	scanf("%s",s);
	int n=strlen(s);
	if(n>=4){
		if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
			puts("Yes");return 0;
		}
	}
	puts("No");
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N, M, S, T;
	cin >> N >> M;
	vector<vector<int>> edges(N);
	vector<vector<int>> dp(N, vector<int>(3, INF));
	REP(i, M) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		edges[u].push_back(v);
	}
	cin >> S >> T;
	S--; T--;

	queue<pair<int, int>> q;
	q.push({ 0,S });
	dp[S][0] = 0;

	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int dist = p.first;
		int pos = p.second;
		for (auto next : edges[pos]) {
			int ndist = dist + 1;
			if (dp[next][ndist % 3] <= ndist)continue;
			dp[next][ndist % 3] = ndist;
			q.push({ ndist,next });
		}
	}
	if (dp[T][0] == INF)cout << -1 << endl;
	else cout << dp[T][0] / 3 << endl;
	return 0;
}


Measured memory_bytes: 11136
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    if (X[i] - X[i-1]) * A >= B:
        ans += B
    else:
        ans += (X[i] - X[i-1]) * A
print(ans)

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

int main()
{
	int y, m, d;
	char c1, c2;
	cin >> y >> c1 >> m >> c2 >> d;
	if (m <= 4) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>
#include <iomanip>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
#define print(x) cout<<x<<endl;
const ll MOD = 1e9 + 7;
const int N = 1e5+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....

signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        b=b*b;
        int ans=0;
        for(int i=0;i<a;i++){
            int x,y;
            cin>>x>>y;
            int add=x*x+y*y;
            if(add<=b){
                ans++;
            }
        }
        cout<<ans;
    }
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y;
  cin >> X >> Y;
  if(Y % 2 ==1){
    cout << "No" <<endl;
  }
  else if(X*2 <= Y && Y <= X*4){
    cout << "Yes" <<endl;
  }
  else{
  cout << "No" <<endl;
  }
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
int ijk[200][20];
int v[200][20];
vector<pair<int,int> >g[200];
int main(){
	int a,b,c,d,e;
	while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&e),b){
		d--;e--;
		for(int i=0;i<200;i++)g[i].clear();
		for(int i=0;i<c;i++){
			int p,q,r;
			scanf("%d%d%d",&p,&q,&r);
			p--;q--;
			g[p].push_back(make_pair(q,r));
			g[q].push_back(make_pair(p,r));
		}
		for(int i=0;i<b;i++){
			for(int j=0;j<=a;j++){
				v[i][j]=0;
				ijk[i][j]=999999999;
			}
		}
		ijk[d][a]=0;
		priority_queue<pair<int,pair<int,int> > >Q;
		Q.push(make_pair(0,make_pair(d,a)));
		while(Q.size()){
			int cost=-Q.top().first;
			int at=Q.top().second.first;
			int nk=Q.top().second.second;
			Q.pop();
			if(v[at][nk])continue;
			for(int i=0;i<g[at].size();i++){
				if(!v[g[at][i].first][nk]&&ijk[g[at][i].first][nk]>cost+g[at][i].second){
					ijk[g[at][i].first][nk]=cost+g[at][i].second;
					Q.push(make_pair(-ijk[g[at][i].first][nk],make_pair(g[at][i].first,nk)));
				}
				if(nk&&!v[g[at][i].first][nk-1]&&ijk[g[at][i].first][nk-1]>cost+g[at][i].second/2){
					ijk[g[at][i].first][nk-1]=cost+g[at][i].second/2;
					Q.push(make_pair(-ijk[g[at][i].first][nk-1],make_pair(g[at][i].first,nk-1)));
				}
			}
		}
		int ret=999999999;
		for(int i=0;i<=a;i++)ret=min(ret,ijk[e][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    char[] t = sc.next().toCharArray();

    // 辞書順で s′ < t′となるようにできるか。
    // 辞書順が最も小さいs'と辞書順が最も大きいt'を比べる
    Arrays.sort(s);
    String s2 = String.valueOf(s);
    Arrays.sort(t);
    String t2 = new StringBuilder(String.valueOf(t)).reverse().toString();

    System.out.println(s2.compareTo(t2) < 0 ? "Yes" : "No");
  }
}


Measured memory_bytes: 23252
import java.util.*;
import java.io.*;

public class Main {
	static long[] a;
	static long[] p;
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] p = na(n);
		int result = 0;
		
		Arrays.sort(p);
		result += p[n - 1] / 2;
		for(int i = 0; i < n - 1; i++) {
			result += p[i];
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

int main() {
  int n,k;
  cin>>n>>k;
  if(k%2==1){
    cout<<(long)(pow((int)(n/k),3));
  }else{
    cout<<(long)(pow((int)(n/k),3)+pow((int)(((int)(n/(k/2))+1)/2),3));
  }
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            var s = e - a;
            if (s > k)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }
    }
}


Measured memory_bytes: 13140
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

# from s(s) to t with limited depth d of graph e
# s is assumed to be an array [s1] or [s1,s2]
def count(g,s,d)
	arrsize = (d+2)/2
	maxarr = Array.new(arrsize){0}
	def makearr(g,s,nott,maxarr)
		stack = [] # stack
		f = Array.new(g.size){false} # is searched flag
		# tr = Array.new(g.size){nil}
		# init
		dmax = 0
		emax = s # e of dmax
		f[s]=true
		enext = E[s].reject{|e| e == nott}
		# evaluation
		if(enext.size > maxarr[0])
			maxarr[0] = enext.size
		end
		# next edge push
		enext.each{|v|
			# tr[v]=s
			stack.push([v,1]) #v,d to v
		} 
		while(!stack.empty?)
			curv,curd = stack.pop
			dputs "(curv,curd) = (#{curv},#{curd})"
			f[curv]=true
			enext = E[curv].reject{|e| f[e]}
			# evaluation
			if(enext.size > maxarr[curd])
				maxarr[curd] = enext.size
			end
			# next edge push
			enext.each{|v|
				# tr[v]=curv
				stack.push([v,curd+1])
			}
		end
	end
	case s.size
	when 1
		makearr(g,s[0],s[0],maxarr)
	when 2
		dputs "first makearr"
		makearr(g,s[0],s[1],maxarr)
		dputs "second makearr"
		makearr(g,s[1],s[0],maxarr)
	end
	maxarr[-1]=1
	dpp maxarr
	return s.size*maxarr.inject(1){|prod,n| prod*n}
end
# returns diameter and central edge(s)
def diameter(g)
	def farthest(g,s)
		stack = [] # stack
		f = Array.new(g.size){false} # is searched flag
		tr = Array.new(g.size){nil}
		# init
		dmax = 0
		emax = s # e of dmax
		tr[s]=s
		f[s]=true
		E[s].each{|v|
			tr[v]=s
			stack.push([v,1]) #v,d to v
		} 
		while(!stack.empty?)
			curv,curd = stack.pop
			f[curv]=true
			if(dmax < curd)
				dmax = curd
				emax = curv
			end
			dputs "(curv,curd) = (#{curv},#{curd})"
			E[curv].each{|v|
				if !f[v]
					tr[v]=curv
					stack.push([v,curd+1])
				end
			}
		end
		return [dmax,emax,tr]
	end
	# diameter by two execute
	d,e,tr = farthest(g,0)
	dputs "d = #{d}"
	dputs "e = #{e}"
	dpp tr
	d,e,tr = farthest(g,e)
	dputs "d = #{d}"
	dputs "e = #{e}"
	dpp tr
	# trace 
	etr = e
	len = 0
	centd = d/2
	offs = d%2
	cente = []
	while(true)
		etr = tr[etr]
		len += 1
		if(len == centd)
			cente << etr
		elsif(len == centd+offs)
			cente << etr
			break
		elsif(len > centd+offs)
			break
		end
	end
	return [d, cente]
end

N,_=gets.chomp.split(' ').map{|n| n.to_i}
if(N==2)
	puts "1 2"
	exit(0)
end
E = Array.new(N){[]}
1.upto(N-1){
	p=gets.chomp.split(' ').map{|n| n.to_i}
	p[0]-=1
	p[1]-=1
	E[p[0]].push(p[1])
	E[p[1]].push(p[0])
}
d,s = diameter(E)
dpp s
mind = count(E,s,d)
if s.size == 1
	# center of the generated tree is the center or the center + neibor
	E[s[0]].each{|sn|
		tmp = count(E,[s[0],sn],d)
		dputs "count #{s[0]},#{sn} is #{tmp}"
		mind = tmp if tmp < mind
	}
end
puts "#{(d+2)/2} #{mind}"


Measured memory_bytes: 4220
n = int(input())
p = list(map(int, input().split()))
l = [0] * n
for i in range(n):
    l[p[i] - 1] = i
a = [3 * 10 ** 4 * (i + 1) for i in range(n)]
b = [3 * 10 ** 4 * (n - i) + l[i] for i in range(n)]
print(*a)
print(*b)

Measured memory_bytes: 12260
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <iomanip>

using ll = long long;

using namespace std;

const double PI = acos(-1);

typedef complex<double> Comp;

bool is_pow_of2(int n) {
	int a = 1;
	while (n >= a) {
		if (n == a) {
			return true;
		}
		a <<= 1;
	}
	return false;
}


vector<Comp> fft(vector<Comp> v) {
	int n = v.size();
	assert(is_pow_of2(n));

	for (int j = 1, i = 0; j < n - 1; j++) {
		for (int k = n >> 1; k >(i ^= k); k >>= 1);
		if (j < i) swap(v[i], v[j]);
	}

	for (int m = 2; m <= n; m <<= 1) {
		double deg = (-1) * 2 * PI / m;
		Comp r(cos(deg), sin(deg));
		for (int i = 0;i < n;i += m) {
			Comp w(1, 0);
			for (int j = i, k = i + m / 2;k < i + m;j++, k++) {
				Comp t1 = v[j], t2 = w*v[k];
				v[j] = t1 + t2, v[k] = t1 - t2;
				w *= r;
			}
		}
	}
	return v;
}

vector<Comp> ifft(vector<Comp> v) {
	int n = v.size();
	assert(is_pow_of2(n));
	for (int j = 1, i = 0; j < n - 1; j++) {
		for (int k = n >> 1; k >(i ^= k); k >>= 1);
		if (j < i) swap(v[i], v[j]);
	}
	for (int m = 2; m <= n; m <<= 1) {
		double deg = 2 * PI / m;
		Comp r(cos(deg), sin(deg));
		for (int i = 0;i < n;i += m) {
			Comp w(1, 0);
			for (int j = i, k = i + m / 2;k < i + m;j++, k++) {
				Comp t1 = v[j], t2 = w*v[k];
				v[j] = t1 + t2, v[k] = t1 - t2;
				w *= r;
			}
		}
	}
	for (int i = 0; i < n;++i) v[i] *= 1.0 / n;
	return v;
}

vector<Comp> convolution(vector<Comp> P, vector<Comp> Q) {
	P = fft(P), Q = fft(Q);
	for (int i = 0;i < P.size();i++) P[i] *= Q[i];
	return ifft(P);
}


int main() {
    int N;
    cin >> N;
    int len = 1;
    while(N > len) {
        len *= 2;
    }

    int size = len*len*4;
    vector<Comp> a(size), b(size);
    ll total = 0;
    ll zero_cnt = 0;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            int c;
            cin >> c;
            zero_cnt += c*(c-1)/2;
            a[i*(2*len) + j] = c;
            b[(N-i)*(2*len) + N-j] = c;
        }
    }
    total += zero_cnt;
    auto t = convolution(a, b);
    vector<ll> v(N*N*2);
    for(int i=-N+1; i<=N-1; ++i) {
        for(int j=-N+1; j<=N-1; ++j) {
            v[i*i + j*j] += t[(N-i)*(2*len) + N + j].real() + 0.1;
        }
    }
    
    double d = 0;
    for(int i=0; i<v.size(); ++i) {
        if(v[i] > 0) {
            d += sqrt(i) * v[i]/2;
            if(i != 0) {
                total += v[i] / 2;
            }
        }
    }
    cout << fixed << setprecision(10) << d / total << endl;
    int cnt = 0;
    if(zero_cnt > 0) {
        cout << "0 " << zero_cnt << endl;
        cnt++;
    }
    for(int i=1; i<v.size(); ++i) {
        if(cnt == 10000) {
            break;
        }
        if(v[i] > 0) {
            cout << i << " " << v[i] / 2 << endl;
            cnt++;
        }
    }
}


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

n = int(input())
a = [int(x) for x in input().split()]

# スタート＋
if a[0] <= 0:
    A1 = 1
    ans1 = abs(a[0]) + 1
else:
    A1 = a[0]
    ans1 = 0
for i in range(1, n):
    nextA = A1 + a[i]
    if (A1 > 0 and nextA < 0) or (A1 < 0 and nextA > 0):
        A1 = nextA
    elif nextA == 0 and A1 > 0:
        ans1 += 1
        A1 = -1
    elif nextA == 0 and A1 < 0:
        ans1 += 1
        A1 = 1
    elif A1 > 0:
        ans1 += abs(nextA) + 1
        A1 = -1
    else:
        ans1 += abs(nextA) + 1
        A1 = 1

# スタート-
if a[0] >= 0:
    ans2 = abs(a[0]) + 1
    A2 = -1
else:
    A2 = a[0]
    ans2 = 0
for i in range(1, n):
    nextA = A2 + a[i]
    if (A2 > 0 and nextA < 0) or (A2 < 0 and nextA > 0):
        A2 = nextA
    elif nextA == 0 and A2 > 0:
        ans2 += 1
        A2 = -1
    elif nextA == 0 and A2 < 0:
        ans2 += 1
        A2 = 1
    elif A2 > 0:
        ans2 += abs(nextA) + 1
        A2 = -1
    else:
        ans2 += abs(nextA) + 1
        A2 = 1

print(min(ans1, ans2))




Measured memory_bytes: 59120
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	function Dice(labels){
		this.t = labels[0];
		this.s = labels[1];
		this.e = labels[2];
		this.w = labels[3];
		this.n = labels[4];
		this.b = labels[5];
	}
	Dice.prototype.roll = function(dir){
		var temp;
		if(dir == "N"){
			temp = this.t;
			this.t = this.s;
			this.s = this.b;
			this.b = this.n;
			this.n = temp;
		}
		else if(dir == "S"){
			temp = this.t;
			this.t = this.n;
			this.n = this.b;
			this.b = this.s;
			this.s = temp;
		}
		else if(dir == "W"){
			temp = this.t;
			this.t = this.e;
			this.e = this.b;
			this.b = this.w;
			this.w = temp;
		}
		else if(dir == "E"){
			temp = this.t;
			this.t = this.w;
			this.w = this.b;
			this.b = this.e;
			this.e = temp;
		}
	};

	var dice = new Dice(lines[0].split(" "));
	lines[1].split("").forEach(dice.roll.bind(dice));
	console.log(dice.t);
}

Measured memory_bytes: 15552
#include <stdio.h>

int main(void)
{
	int i,N,K[100],P[100],a[100];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d %d",&K[i],&P[i]);	
		if(P[i]>K[i]){
			a[i]=K[i];
		}
		else if(K[i]%P[i]==0){
			a[i]=P[i];
		}
		else{
			a[i]=K[i]%P[i];
		}
	}
	for(i=0;i<N;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	int m=n,sum=0;
	while(m){
		sum+=m%10;
		m/=10;
	}
	if(n%sum==0)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
L = []
for i in range(N):
 L.append(0)
for i in range(Q):
 a = int(input()) - 1
 L[a] += 1
for i in range(N):
 print("Yes" if K - Q + L[i] > 0 else "No")

Measured memory_bytes: 51104
#include <iostream>  
#include <algorithm>  
#include <functional>  
#include <vector>  
#include <map>
#include <string>
#include <queue>
#include <deque> 
#include <cmath>
using namespace std;
#define _USE_MATH_DEFINES
#include <math.h>
int main(){
	int n;
	while(scanf("%d",&n)){
		if(n==0) break;
		long long int sum=0;
		int i;
		int a[10005];
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
			sum+=a[i];
		}
		sort(a+1,a+n+1);
		sum=sum/n;
		int pos=upper_bound(a+1,a+n+1,sum)-a;
		printf("%d\n",pos-1 );
	}
	return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 10000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    IOS
    lli k,x;
    cin>>k>>x;
    for(lli start = x - (k-1);start<=(x+(k-1));start++)
    	cout<<start<<" ";
    return 0;
}




Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Ord
main = readLn >>= flip replicateM getLine >>= putStrLn . solve . fmap sort

solve :: [String] -> String
solve xs
    | b && c = m : solve next
    | b = [m]
    | c = solve next
    | otherwise = []
    where
        m = head $ minimumBy (comparing head) xs
        (next, b, c) = check m xs

check :: Char -> [String] -> ([String], Bool, Bool)
check m ((x : xs) : xss)
    | m == x = (xs : ys, b, not (null xs) && c)
    | otherwise = ((x : xs) : ys, False, c)
    where
        (ys, b, c) = check m xss
check _ _ = ([], True, True)


Measured memory_bytes: 1148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int mod=998244353;
int n;
int x[205],y[205],p[205];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&x[i],&y[i]);
    p[0]=1;
    for(int i=1;i<=n;i++)
        p[i]=(p[i-1]*2)%mod;
    int ans=p[n]-n-1;
    for(int i=1;i<=n;i++)
	{
        for(int j=1;j<i;j++)
		{
            int cnt=0;
            for(int k=1;k<j;k++)
			{
                if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))
                    cnt++;
            }
            ans=(ans-p[cnt]+mod)%mod;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string n;
    cin >> n;

    if(n[n.size()-1]=='3'){
        cout << "bon";
    }
    else if(n[n.size()-1]=='0'||n[n.size()-1]=='1'||n[n.size()-1]=='6'||n[n.size()-1]=='8'){
        cout << "pon";
    }
    else{
        cout << "hon";
    }

    return 0;
}

Measured memory_bytes: 3628
import math
N, D = map(int, input().split())
X = []
for _ in range(N):
    X.append([int(x) for x in input().split()])

count = 0
for i in range(N):
    for j in range(i+1, N):
        dist = 0
        for k in range(D):
            dist += abs(X[i][k] - X[j][k]) ** 2

        if math.sqrt(dist).is_integer():
            count += 1
        
print(count)

Measured memory_bytes: 3064
/**
*    author:  y_takano
*    created: 22.06.2020 14:33:44
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  string s, p;
  int flg = 0;

  getline(cin, s);
  getline(cin, p);

  s += s;

  REP(i, s.size()- p.size())
  {
      if (flg == 1)
      {
          break;
      }
      
      REP(j, p.size())
      {
        if (s[i + j] == p[j])
        {
            if (j == p.size() - 1)
            {
              flg = 1;
              break;
            }
        }
        else
        {
            break;
        }
      }
  }

  if (flg == 1)
  {
      cout << "Yes" << '\n';
  }
  else
  {
      cout << "No" << '\n';
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll dp[410][410], v[410][410], b[410];

ll f(int l, int r) {
  if (l == r) return 0;
  if (v[l][r]) return dp[l][r];
  v[l][r] = 1;
  ll res = 1e18;
  for (int i = l; i < r; ++i)
    res = min(res, f(l, i) + f(i + 1, r) + b[r + 1] - b[l]);

  return dp[l][r] = res;
}

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) b[i + 1] = b[i] + a[i];

  cout << f(0, n - 1) << endl;
  return 0;
}

Measured memory_bytes: 6164
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
using namespace std;
template<typename V,typename Weight>
class Dijekstra {
private:
	struct edge {
		Weight dist;V node;V prev;
		bool operator<(edge const& a) const {
			return dist < a.dist;
		}
		bool operator>(edge const& a) const {
			return dist > a.dist;
		}
	};
	vector<V> trace;
	vector<vector<pair<V,Weight>>> E;
	V sz;
public:
	Weight inf = numeric_limits<Weight>::max();
	vector<Weight> D;
	Dijekstra(V v) :
		E(v),sz(v),D(v,inf),trace(v,numeric_limits<V>::max()) {}

	void addEdgeDirected(V from,V to,Weight dis){
		E[from].push_back(make_pair(to,dis));
	}
	void addEdgeUndirected(V from,V to,Weight dis){
		E[from].push_back(make_pair(to,dis));
		E[to].push_back(make_pair(from,dis));
	}

	V size() {return sz;}
	Weight & operator[] (V n) { if (0 <= n && n < sz) return D[n];} 

	void dijekstra(V start){
		priority_queue<edge,vector<edge>,greater<edge>> que;
		D[start] = 0;
		//trace[start] = start;
		que.push(edge{0,start,start});
		Weight d;V v,prev;
		while(!que.empty()){
			edge cur = que.top();que.pop();
			d = cur.dist;v = cur.node;prev = cur.prev;
			if (D[v] < d) continue; //既により最適が見つかっている
			D[v] = d;trace[v] = prev;
			for(pair<V,Weight> e : E[v]){
				if (D[e.first] <= d + e.second) continue;
				que.push(edge{d+e.second,e.first,v});
			}
		}
	}

	vector<V> show_trace(V start,V goal){ // startからgoalの最短距離上のノード
		vector<V> ret;
		for (V node = goal;node != start;node = trace[node]) ret.push_back(node);
		ret.push_back(start);
		return ret; // 配列の先頭がgoal,末尾がstart
	}
};


int main(void){
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	Dijekstra<long,long> dij(V);

	REP(i,E){
		cin >> s >> t >> d;
		dij.addEdgeDirected(s,t,d);
	}

	dij.dijekstra(R);
	REP(i,V) {
		if (dij[i] == dij.inf) cout << "INF" << endl;
		else cout << dij[i] << endl;
	}
		
	return 0;
}





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

using namespace std;

int main(void)
{
    unsigned long int N;
    cin >> N;
    stack<char> st;
    while(N != 0){
        N--;
        st.push('a' + N % 26);
        N /= 26;
    }
    while(!st.empty()){
        cout << st.top();
        st.pop();
    }
    cout << endl;
        return 0;
}


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

void solve()
{    
    string a;
    cin >> a;
    for (int c=0;c<a.size();c++)
        if (a[c]=='?')
            cout << 'D';
        else cout << a[c];
    cout << endl;

}

int main ()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
      
     int t;
   //  cin >> t;
     t=1;
     for (int tt=1;tt<=t;tt++)
     {
         solve();

     }

    return 0;
     
     
     
     
 }


Measured memory_bytes: 3792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <bitset>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<ll> a(n);
    int i;
    ll sum=0;    // 全てのa[i]のxor
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
        sum^=a[i];
    }

    for(i=0; i<n; i++) {
        a[i] &= ~sum;    // 全てのa[i]のxorが0であるbitだけを見る形の a[i] を用意
    }

    int curr=0;
    int k;
    for(k=59; k>=0; k--) {
        for(i=curr; i<n; i++) {
            if(a[i] & ((ll)1<<k)) break;      // このbitが立っているa[i]を見つける
        }
        if(i<n) {
            swap(a[curr], a[i]);              // swapして掃き出し
            for(i=0; i<n; i++) {
                if(i!=curr && (a[i] & ((ll)1<<k))) {
                    a[i]^=a[curr];
                }
            }
            curr++;
        }
    }

    ll ans=0;
    for(i=0; i<n; i++) {
        ans ^= a[i];
    }
    ans *= 2;

    ans += sum;      // 全てのa[i]のxorが1であるbitはそのまま答に加算

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  S = S + "XXX";

  ll longest = 0;
  REP(i, A - 1, C) {
    if (S[i] == '#') {
      longest++;
      if (longest > 1) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      longest = 0;
    }
  }
  longest = 0;
  REP(i, B - 1, D) {
    if (S[i] == '#') {
      longest++;
      if (longest > 1) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      longest = 0;
    }
  }

  if (C < D) {
    cout << "Yes" << endl;
  } else {
    REP(i, B - 1, D) {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

int main()
{
    int n,k,sc;
    double ans=0.0,temp;
    cin>>n>>k;

    for(int i=1;i<=n;i++){
        sc=i;
        temp=double(1.0/n);

        while(sc<k){
            temp*=0.5;
            sc*=2;
        }
        ans+=temp;
    }
    cout <<setprecision(12)<<ans<<endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		W = in.readLine();
		String[] ws = W.split(" ");
		long[] H = new long[ws.length];
		String ans = "Yes";
		for(int i=0;i<ws.length;i++){
			H[i]=Long.parseLong(ws[i]);
			if(i==0){

			}else if(i==1){
				if(H[i-1] >= H[i]){
					H[i-1] = H[i-1]-1;
				}
			}else{
				if(H[i-1] >= H[i]){
					if(H[i-2] < H[i-1]){
						H[i-1]=H[i-1]-1;
					}
				}
			}
			if(i!=0 && H[i-1] > H[i]){
				ans="No";
				break;
			}
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 49108
N = int(input())
if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 61964