akhauriyash/Code-Regression huggingface dataset:
N,M=map(int,input().split())
p=list(map(int,input().split()))

class UnionFind():
  def __init__(self, x):
    self.x=x
    self.root=[-1]*(N+1)
    self.rnk=[0]*(N+1)
  
  def Find_root(self, x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.Find_root(self.root[x])
      return self.root[x]
    
  def Unite(self, x, y):
    x = self.Find_root(x)
    y = self.Find_root(y)
    if x==y:
      return
    elif self.rnk[x]>self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x]==self.rnk[y]:
        self.rnk[y]+=1
  
  def isSameGroup(self, x, y):
    return self.Find_root(x)==self.Find_root(y)
  
  def Count(self, x):
    return -self.root[self.Find_root(x)]

u=UnionFind(N)
for i in range(M):
  x,y=map(int,input().split())
  u.Unite(x,y)
ans=0
for i in range(N):
  if u.isSameGroup(i+1,p[i]):
    ans+=1
  else:
    continue
print(ans)
  

Measured memory_bytes: 14004
# -*- coding: utf-8 -*-
import numpy as np


def main():
    n = int(input())
    b = np.array(input().split(), dtype='int')
    a = np.zeros(n, dtype='int')

    for i in range(n - 1):
        if i == 0:
            a[i] = b[i]
            a[i + 1] = b[i]
        else:
            if a[i] > b[i]:
                a[i] = b[i]
            a[i + 1] = b[i]
    
    ans = np.sum(a)

    print(ans)

main()

Measured memory_bytes: 21388
n, m = map(int, raw_input().split())
lx, ly, lxx, lyy = [], [], [], []
for i in range(n):
	x, y = map(int, raw_input().split())
	lx.append(x)
	ly.append(y)

for i in range(m):
	x, y = map(int, raw_input().split())
	lxx.append(x)
	lyy.append(y)

for i in range(n):
	mi = 10000000000
	note = 0
	for j in range(m):
		if abs(lx[i] - lxx[j]) + abs(ly[i] - lyy[j]) < mi:
			mi = abs(lx[i] - lxx[j]) + abs(ly[i] - lyy[j])
			note = j + 1
	print note

Measured memory_bytes: 2692
N = int(input())
tmp = input().split()

A = [int(tmp[i]) for i in range(N)]

A.sort()


flag = 1
for i in range(N-1):
    if A[i] == A[i+1]:
        flag = 0
        break

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 25940
import scala.io.StdIn.{readLine, readInt}

object Main extends App {
  val n = readInt
  val sq = readLine.split(" ").map(_.toInt).toSeq

  @scala.annotation.tailrec
  def shiftOnly(sq: Seq[Int], n: Int): Int = {
    if (sq.count(_ % 2 == 1) == 0) {
      shiftOnly(sq.map(_ / 2), n + 1)
    } else n
  }

  val ans = shiftOnly(sq, 0)
  println(ans)
}

Measured memory_bytes: 25676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int sum = 0;
		
		for(int i = 1; i <= N; i++) {
			sum += i;
		}
		
		System.out.println(sum);
		
		scan.close();
	}

}


Measured memory_bytes: 22604
H,W,K = map(int,input().split())
L = []
for _ in range(H):
    l = list(input())
    L.append(l)
import copy
ans =0
for x in range(2 ** H):
    for y in range(2 ** W):
        c = copy.deepcopy(L)

        for i in range(H):
            if x & (1 << i):
                for yoko in range(W):
                    c[i][yoko] = '.'
        for j in range(W):
            if y & (1 << j):
                for tate in range(H):
                    c[tate][j] = '.'
        #count
        cnt = 0
        for i in range(H):
            for j in range(W):
                if c[i][j] == '#': cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 9264
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,val[1005],fac[1005];
LL ans;
int main()
{
    ans=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)val[i]=i;
    for(int i=2;i<=n;i++)
    {
        for(int j=2;j<=n;j++)
        {
            while(val[j]%i==0)
            {
                val[j]=val[j]/i;
                fac[i]++;
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
        //printf("%d %d\n",fac[i],i);
        ans*=(fac[i]+1);
        ans%=MOD;
    }
    printf("%lld",ans);
}


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

int N, X, count = 0;

void Bound(const vector<int>& L, int D, int i) {
  if (i >= N) return;
  int D_ = D + L[i];
  if (D_ <= X) count++;
  Bound(L, D_, ++i);
}

int main() {
  cin >> N >> X;
  vector<int> L(N);
  for (auto&& l : L)
    cin >> l;
  Bound(L, 0, 0);
  cout << count + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int in[n] = {};
    rep(i, 0, m) {
        int s, t;
        cin >> s >> t;
        g[s].push_back(t);
        in[t]++;
    }

    vector<int> ans;
    queue<int> que;
    rep(i, 0, n) {
        if (in[i] == 0) {
            que.push(i);
            ans.push_back(i);
        }
    }
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        for (auto next : g[now]) {
            in[next]--;
            if (in[next] == 0) {
                que.push(next);
                ans.push_back(next);
            }
        }
    }

    for (auto i : ans) cout << i << endl;
    return 0;
}



Measured memory_bytes: 3736
import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr: #あらかじめ各Aiの個数を数えておく
 cnt[val]+=1
sums=sum(arr) #あらかじめAiの総和を求めておく
q=int(input())
for _ in range(q):
 b,c=map(int,input().split())
 diff=(c-b)*(cnt[b]) #各クエリにおいて数列Aの総和は(値がBiである要素の個数)*(Ci-Bi)だけ変化する
 sums+=diff
 print(sums) 
 cnt[c]+=cnt[b] #値がCi,Biである要素の個数を更新する
 cnt[b]=0

Measured memory_bytes: 23992
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    from functools import reduce

    # 最小公倍数
    def lcm_base(x, y):
        return (x * y) // math.gcd(x, y)

    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)

    n = ni()
    a = na()

    lcm = a[0]
    for i in a:
        lcm = lcm // math.gcd(lcm, i) * i
    lcm %= MOD

    ans = 0
    for ai in a:
        ans += lcm * pow(ai, MOD - 2, MOD) % MOD
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 79360
import java.util.*;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        for (int i=0; i<N; i++) {
            B[i] = sc.nextInt();
        }

        int ans = solve2(N, A, B);

        System.out.println(ans);
    }

    private static int solve2(int N, int[] A, int[] B) {
        int count = 0;

        int[] C = new int[N];
        long sum = 0;
        long negative = 0;
        for (int i=0; i<N; i++) {
            C[i] = A[i] - B[i];
            sum += C[i];
            if (C[i] < 0) {
                negative += C[i];
                count++;
                C[i] = 0;
            }
        }
        if (sum < 0) return -1;
        Arrays.sort(C);

        for (int i=N-1; i>=0; i--) {
            if (C[i] == 0 || negative >= 0) break;

            negative += C[i];
            count++;
        }

        return count;
    }
}

Measured memory_bytes: 83720
use std::io;
use std::io::prelude::*;
use std::iter::repeat;

struct WeightedUnionFindTree(Vec<(usize, i64)>);
impl WeightedUnionFindTree {
    fn new(n: usize) -> WeightedUnionFindTree {
        WeightedUnionFindTree((0..n).zip(repeat(0)).collect())
    }

    fn diff(&mut self, n: usize) -> (usize, i64) {
        let p = self.0[n].0;
        if n != p {
            let (newp, d) = self.diff(p);
            self.0[n] = (newp, d + self.0[n].1);
        }
        self.0[n]
    }

    fn relate(&mut self, x: usize, y: usize, z: i64) {
        let (px, dx) = self.diff(x);
        let (py, dy) = self.diff(y);

        self.0[py] = (px, z - (dy - dx));
    }
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let line0 = lines.next().unwrap().unwrap();
    let n = line0.split_whitespace().next().unwrap().parse().unwrap();

    let mut wuft = WeightedUnionFindTree::new(n);

    for l in lines.map(Result::unwrap) {
        let mut words = l.split_whitespace();
        let com = words.next().unwrap().parse().unwrap();
        let x = words.next().unwrap().parse().unwrap();
        let y = words.next().unwrap().parse().unwrap();
        match com {
            0 => {
                let z = words.next().unwrap().parse().unwrap();
                wuft.relate(x, y, z);
            }
            1 => {
                let (px, dx) = wuft.diff(x);
                let (py, dy) = wuft.diff(y);
                if px == py {
                    println!("{}", dy - dx);
                } else {
                    println!("?");
                }
            }
            _ => (),
        }
    }
}



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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    long long m,n;
    long long ans;
    while(cin>>m>>n)
    {
        ans=3*m+n;
        cout<<ans/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * func bitExhaustiveSearch(n int, fn func(a []bool))
 *
 * Verified
 *	ALDS1_5_A: Exhaustive Search
 *	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=ja
 *
 * These codes are licensed under CC0.
 * https://creativecommons.org/publicdomain/zero/1.0/
 */

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Main

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	p := scanInts(n)
	q := scanInts(n)

	var a, b int
	cnt := 0

	permutationSearch(n, func(arr []int) {
		f := true
		for i := 0; i < n; i++ {
			if p[i] != arr[i]+1 {
				f = false
			}
		}

		if f {
			a = cnt
		}

		f = true
		for i := 0; i < n; i++ {
			if q[i] != arr[i]+1 {
				f = false
			}
		}

		if f {
			b = cnt
		}

		cnt++
	})

	fmt.Fprintln(wr, abs(a-b))

}

func permutationSearch(n int, fn func(a []int)) {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = i
	}
	swap := func(i, j int) { a[i], a[j] = a[j], a[i] }

	fn(a)
	for i := n - 2; i >= 0; i-- {
		if a[i] > a[i+1] {
			continue
		}
		for j := n - 1; j >= 0; j-- {
			if a[i] > a[j] {
				continue
			}
			swap(i, j)
			for k := i + 1; k < (n+i+1)/2; k++ {
				swap(k, n-(k-i))
			}
			fn(a)
			i = n - 1
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
  int n;
  bool cards[4][13];
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      cards[i][j] = false;
    }
  }

  cin >> n;
  for(int i = 0; i < n; i++){
    char suit;
    int rank;
    cin >> suit >> rank;
    switch(suit){
    case 'S':
      suit = 0;
      break;
    case 'H':
      suit = 1;
      break;
    case 'C':
      suit = 2;
      break;
    case 'D':
      suit = 3;
    }
    cards[suit][rank-1] = true;
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if(!cards[i][j]){
        char suit;
        switch(i){
        case 0:
          suit = 'S';
          break;
        case 1:
          suit = 'H';
          break;
        case 2:
          suit = 'C';
          break;
        case 3:
          suit = 'D';
        }
        cout << suit << ' ' << j+1 << endl;
      }
    }
  }
}

Measured memory_bytes: 3076
H, W = map(int, input().split())
grid = []
for i in range(H):
    row = list(input())
    grid.append(row)
row_flags = [1] * H
col_flags = [1] * W

for i in range(H):
    t = grid[i][0]
    if t != ".":
        continue
    for j in range(1, W):
        if grid[i][j] != t:
            break
    else:
        row_flags[i] = 0
for j in range(W):
    t = grid[0][j]
    if t != ".":
        continue
    for i in range(1, H):
        if grid[i][j] != t:
            break
    else:
        col_flags[j] = 0

for i in range(H):
    if not row_flags[i]:
        continue
    for j in range(W):
        if not col_flags[j]:
            continue
        print(grid[i][j], end="")
    print()


Measured memory_bytes: 4596
n = int(input())
h = list(map(int,input().split()))

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        #print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14480
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 基本的な演算
namespace BasicMath {
    // 二つの値の最大値を求める関数
    static Int Max(const Int a, const Int b);
    Int Max(const Int a, const Int b) {
        if (a >= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;


int main(void) {
    Int a, b, c;
    cin >> a >> b >> c;
    Int maxNum = Max(Max(a, b), c);
    cout << a + b + c - maxNum + maxNum * 10 << endl;
    return 0;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;
const int maxq=1005;

struct edge{int to,cap,cost,rev;};

int n,m,k;
int d[maxn];
int a[maxn];
int p1[maxn];
int p2[maxn];
bool inq[maxn];
vector<edge>G[maxn];

void add_edge(int u,int v,int c,int w) {
	G[u].pb(edge{v,c,w,int(G[v].size())});
	G[v].pb(edge{u,0,-w,int(G[u].size()-1)});
}

int mcmf(int s,int t) {
	int flow=0 , cost=0;
	while (1) {
		memset(d,0x3f,sizeof(d));
		d[s]=0; a[s]=max(0,k-flow);
		int qh=0,qt=0,q[maxq];
		q[qt++]=s; inq[s]=1;
		while (qh<qt) {
			int u=q[qh++];
			inq[u]=0;
			for (int i=0;i<G[u].size();i++) {
				edge e=G[u][i];
				if (d[e.to]>d[u]+e.cost && e.cap) {
					d[e.to]=d[u]+e.cost;
					a[e.to]=min(a[u],e.cap);
					p1[e.to]=u;
					p2[e.to]=i;
					if (!inq[e.to]) {
						q[qt++]=e.to;
						inq[e.to]=1;
					}
				}
			}
		}
		if (d[t]==INF || !a[t]) break;
		flow+=a[t];
		cost+=a[t]*d[t];
		for (int v=t,u=p1[t];v!=s;v=u,u=p1[u]) {
			int id=p2[v];
			G[u][id].cap-=a[t];
			id=G[u][id].rev;
			G[v][id].cap+=a[t];
		}
	}
	if (flow<k) return -1;
	else return cost;
}

int main() {
	cin>>n>>m>>k;
	for (int i=0;i<m;i++) {
		int u,v,c,w; cin>>u>>v>>c>>w;
		add_edge(u,v,c,w);
	}
	cout<<mcmf(0,n-1)<<'\n';
}


Measured memory_bytes: 3224
use std::io::Read;

fn solve(n: usize, x: u64, p: &Vec<u64>, l: &Vec<u64>) -> u64 {
    if x == 0 {
        0
    } else if n == 0 {
        1
    } else {
        // もし半分以上だったら
        if (l[n] + 1) / 2 <= x {
            p[n - 1] + 1 + solve(n - 1, x - (l[n] + 1) / 2, &p, &l)
        } else {
            solve(n - 1, x - 1, &p, &l)
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let x: u64 = itr.next().unwrap().parse().unwrap();
    let mut p: Vec<u64> = vec![1; 55];
    let mut l: Vec<u64> = vec![1; 55];
    for i in 0..n + 1 {
        p[i + 1] = p[i] * 2 + 1;
        l[i + 1] = l[i] * 2 + 3;
    }

    println!("{}", solve(n, x, &p, &l));
}


Measured memory_bytes: 4352
<?php
  
  list($n,$k) = explode(' ', trim(fgets(STDIN)));
  $h = explode(' ', trim(fgets(STDIN)));

  if ($k >= count($h)) {
    echo 0;
  } else {
    rsort($h);
    array_splice($h,0,$k);
	echo array_sum($h);
  }
  
?>

Measured memory_bytes: 31284
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
constexpr long long mod = 1e9 + 7;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        long long d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod );
    }
}
template<class T> T mod_nCr(T n, T r, T mod ) {
    T denom = 1;
    T numer = 1;
    for (T i = 1; i <= r; i++) numer = (numer * i) % mod;
    for (T i = n - r + 1; i <= n; i++) denom = (denom * i) % mod;
    return (denom * modpow(numer, mod - 2) % mod);
}

signed main(){
    fast_io();
    int N,A,B; cin >> N >> A >>B;
    string s; cin >> s;
    vector<bool>ok(N,false);
    int cnt = 0;
    int idx = 0;
    int bcnt = 0;
    for(auto c : s){
        if(cnt < A + B && c == 'a'){++cnt; ok[idx] = true;}
        if(cnt < A + B && c == 'b' && bcnt < B){ok[idx] = true; ++cnt; ++bcnt;}
        idx++;
    }
    for(auto b : ok){
        cout << (b ? "Yes" : "No") << el;
    }
}


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

  

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  if(N%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  string a=S.substr(0,N/2);
  string b=S.substr(N/2,N/2);
  
  bool can=true;
  for(int i=0;i<N/2;i++){
    if(a.at(i)!=b.at(i)){
      can=false;
      break;
    }
  }
  
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long  n,ans=0;
    cin >>n;
    vector<long long>dp(n+1);
    
    
    for(int i=1;i<=n+1;i++){
        for(int j=1;i*j<=n;j++){
            dp[i*j]++;
        }
    }
    
    
    
    for(int i=1;i<=n;i++){
        ans+=i*dp.at(i);
    }
    
    cout<<ans;
}


Measured memory_bytes: 81384
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int n;
char a[MAX];

int main(void) {
	// in = fopen("B.in", "rt");
	
	fscanf(in, "%s", a);
	n = (int)strlen(a);
	
	for (int r1 = -1; r1 < n; r1++) {
	    for (int r2 = r1; r2 < n; r2++) {
	        string str;
	        for (int i = 0; i < n; i++) {
	            if (i >= r1 && i <= r2)
	               continue;
	            str += a[i];
            }
            if (str == "keyence") {
                fprintf(out, "YES\n");
                return 0;
            }
        }
    }
    fprintf(out, "NO\n");
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

vector<ll>g[maxn];

bool used[maxn];
ll par[maxn];
ll gl[maxn];
ll dp[maxn];

void dfs(ll u, ll d) {
	used[u] = 1;
	gl[u] = d;
	dp[u] = d;
	for (ll v : g[u]) {
		if (used[v]) continue;
		par[v] = u;
		dfs(v, d + 1);
		dp[u] = max(dp[u], dp[v]);
	}
}


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	ll a, b; cin >> a >> b;
	for (ll i = 0; i < n - 1; i++) {
		ll u, v; cin >> u >> v;
		g[u].push_back(v); g[v].push_back(u);
	}
	ll root = b;
	dfs(root, 0);
	ll kek = a;
	ll glub = gl[kek];
	ll can_up = (glub - 1) / 2;
	for (ll i = 0; i < can_up; i++) {
		kek = par[kek];
	}
	cout << dp[kek] - 1 << endl;
	return 0;	
}

/*

*/

Measured memory_bytes: 20480
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string ss[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  cin >> s;
  int ii;
  REP(i, 7) {
    if(ss[i] == s) ii = i;
  }

  cout << (7 - ii) << endl;
}


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

string a,b;
int DP[3003][3003];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b;

    for(int i=1; i<=a.size(); i++)
        for(int j=1; j<=b.size(); j++)
        if(a[i-1]==b[j-1])
        DP[i][j]=DP[i-1][j-1]+1;
        else
        DP[i][j]=max({DP[i-1][j],DP[i][j-1],DP[i-1][j-1]});

    string ats;
    int r = a.size();
    int c = b.size();

    while(r > 0 && c > 0)
    {
        if(a[r-1]==b[c-1])
            ats+=a[r-1],r--,c--;
        else if(DP[r-1][c]==DP[r][c])r--;
        else c--;
    }

    reverse(ats.begin(),ats.end());
    cout<<ats;
}


Measured memory_bytes: 35456
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;
int r,s,p,n,k;

int dp(string S){
  vi dp[3];
  int N=S.size();
  rep(i,3)dp[i].resize(N+1);
  rep(i,N){
    if(S[i]=='r'){
      dp[2][i+1]=max(dp[2][i+1],max(dp[0][i],dp[1][i])+p);
      dp[0][i+1]=max({dp[0][i+1],dp[1][i],dp[2][i]});
      dp[1][i+1]=max({dp[1][i+1],dp[0][i],dp[2][i]});
    }
    if(S[i]=='s'){
      dp[0][i+1]=max(dp[0][i+1],max(dp[1][i],dp[2][i])+r);
      dp[1][i+1]=max({dp[1][i+1],dp[0][i],dp[2][i]});
      dp[2][i+1]=max({dp[2][i+1],dp[0][i],dp[2][i]});
 
    }
    if(S[i]=='p'){
      dp[1][i+1]=max(dp[1][i+1],max(dp[0][i],dp[2][i])+s);
      dp[0][i+1]=max({dp[0][i+1],dp[1][i],dp[2][i]});
      dp[2][i+1]=max({dp[2][i+1],dp[0][i],dp[1][i]});
     }
  }
  return max({dp[0][N],dp[1][N],dp[2][N]});
}

signed main(){
  cin>>n>>k>>r>>s>>p;
  string t;cin>>t;
  int ans=0;
  rep(i,k){
    string u;
    for(int j=i;j<n;j+=k)u.push_back(t[j]);
    ans+=dp(u);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5852
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    char c=s[0];
    vi a;
    a.pb(0);
    rep(i,n)if(s[i]!=c)c=s[i],a.pb(i);
    int t=a.size();
    rep(i,2*k+1)a.pb(n);
    int ans=0;
    rep(i,t){
        if(s[a[i]]=='1')ans=max(ans,a[i+2*k+1]-a[i]);
        else ans=max(ans,a[i+2*k]-a[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define ll      long long 
#define ld      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     10000000000000007
const int N=300004;

void run(){
    ll n,i,ans,x,y;
    cin>>n;
    ans=n;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            x=i;
            y=n/i;
            ans=min(ans,x+y-2);
        }
    }
    cout<<ans;
}
 
 
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}

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


int main(){
    int n;
    cin >> n;
    unordered_map<int, int> table;
    rep(i,n){
        int a;
        cin >> a;
        if(table[a]) table[a]--;
        else table[a]++;
    }
    int ans = 0;
    for(auto p : table){
        ans += p.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4388
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        char[] alp = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
        char[] w = Console.ReadLine().ToCharArray();
        bool f = true;
        for (int i = 0; i < alp.Length; i++)
        {
            if (w.Count(a => a == alp[i]) % 2 != 0)
            {
                f = false;
                break;
            }
        }
        Console.WriteLine(f ? "Yes" : "No");
    }
}

Measured memory_bytes: 11220
s=input()

ll=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

if len(s)!=26:
    l=list(s)
    for i in l:
        ll.remove(i)
    ll.sort()
    print(s+ll[0])
else:
    if s=="zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        l=[]
        for i in range(1,27):
            for j in l:
                if s[-i]<j:
                    print(s[0:26-i]+j)
                    import sys
                    sys.exit()
            l.append(s[-i])
            l.sort()
            

Measured memory_bytes: 38512
package main

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

func main() {
	_ = nextInt()
	a := nextIntArray()
	rmap := make([]int, 9)
	for _, ai := range a {
		if ai >= 3200 {
			rmap[8]++
		} else {
			rmap[ai/400]++
		}
	}

	under := 0
	for _, v := range rmap[:8] {
		if v > 0 {
			under++
		}
	}
	fmt.Println(max(1, under), under+rmap[8])
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func max(i, j int) int {
	if i < j {
		return j
	}
	return i
}


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

typedef long long ll;

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

	vector<pair<int, int>> pa;
	vector<vector<pair<int, int>>> c(n);
	for(int i=0; i<m; i++){
		int p,y;
		cin >> p >> y;
		p--;
		y--;
		pa.emplace_back(p,y);
		c[p].emplace_back(y,i);
	}

	for(int i=0; i<n; i++){
		sort(c[i].begin(), c[i].end());
		for(int j=0; j<c[i].size(); j++){
			pa[c[i][j].second].second = j;
		}
	}

	for(int i=0; i<m; i++){
		cout << setw(6) <<setfill('0') << pa[i].first+1 << setw(6) << setfill('0') << pa[i].second+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 9364
Program ABC119A

integer n,i
real otoshidama
real,allocatable::x(:)
character(3),allocatable::u(:)

read(*,*) n
allocate(x(n))
allocate(u(n))

do i=1,n
 read(*,*) x(i),u(i)
end do

otoshidama=0

do i=1,n
 if(u(i)=='JPY') then
  otoshidama=otoshidama+x(i)
 else
  otoshidama=otoshidama+x(i)*380000
 end if
end do

write(*,*) otoshidama

stop
end

Measured memory_bytes: 384
import numpy as np

S = list(map(str, input().rstrip()))

ans = np.zeros(len(S) + 1, dtype=np.int64)

# 左から、右から流す
for i, s in enumerate(S):
    if s == "<":
        ans[i+1] = max(ans[i+1], ans[i]+1)

ans = ans[::-1]

for i, s in enumerate(S[::-1]):
    if s == ">":
        ans[i+1] = max(ans[i+1], ans[i]+1)

print(ans.sum())

Measured memory_bytes: 38904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,num=0;
    set<int>w;
    for(int i=1; i*i<=1000000000; i++)
        w.insert(i*i);
    int a[15][15];
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            scanf("%d",&a[i][j]);
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
        {
            int ans=0;
            for(int k=0; k<m; k++)
                ans+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            if(w.find(ans)!=w.end())
                num++;
        }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int a = ceil(A / 0.08);
  int b = ceil(B / 0.1);
  if (a == b) {
    printf("%d\n", a);
  } else {
    if (a < b) {
      if ((int)(b * 0.08) == A) {
        printf("%d\n", b);
      } else {
        printf("-1\n");
      }
    } else if (a > b) {
      if ((int)(a * 0.1) == B) {
        printf("%d\n", a);
      } else {
        printf("-1\n");
      }
    }
  }
}

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

int main(void){
	long long n, m, ans = 0;
	cin >> n >> m;
	if(n == m/2){
		ans += n;
	}else if(n < m/2){
		ans += n;
		m -= 2*n;
		m /= 4;
		ans += m;
	}else if(n > m/2){
		ans += m/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
*/

// 素因数分解 pair.firstで素数、pair.secondで対応する指数
vector<pair<long long, long long> > prime_factorize(long long n) {
	vector<pair<long long, long long> > res;
	for (long long p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

const int MAX = 110000;

//二項係数を求める前処理 テーブルを作る　O(n)
// facは階乗
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

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

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

	int n;
	cin >> n;
	COMinit();
	vector<ll> a(n + 1);
	// 重複している点を探す
	vector<int> num(n + 1, 0);
	int doubleNum;
	rep(i, n + 1) {
		cin >> a[i];
		num[a[i]]++;
		if (num[a[i]] == 2) doubleNum = a[i];
	}
	// 一つだけ同じ数字が2つある
	// 長さi(1~n + 1)の部分列をそれぞれ書き下す

	// もし重複がなければ？
	// ans = (n + 1) C i

	vector<int> index;
	rep(i, n + 1) {
		if (a[i] == doubleNum)
			index.push_back(i);
	}

	int na, nb, nc;
	na = index[0];
	nb = index[1] - index[0] - 1;
	nc = n + 1 - index[1] - 1;

	Rep(length, 1, n + 2) {
		// 長さlengthの部分列
		ll ans;
		if (length == 1) {
			cout << n << endl;
			continue;
		}
		ans = COM(n - 1, length) % mod;
		// 左の点が入ってるとき
		ans += COM(n - 1, length - 1);
		ans %= mod;
		// 右の点が入っているとき
		  // nbの値がない場合はna, ncの値は被る
		ans += COM(n - 1, length - 1);
		ans %= mod;
		ans = (ans - COM(na + nc, length - 1) + mod) % mod;
		// 両方入っているとき
		ans += COM(n - 1, length - 2);
		ans %= mod;

		cout << ans << endl;
	}

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL n;
	cin >> n;

	LL let = 1;
	LL pw = 26;
	LL sum = 26;

	while (n > sum) {
		pw *= 26;
		let++;
		sum += pw;
	}

	LL excess = sum - n;
	excess = pw - excess-1;

	vector<char> ans(let, 'a');
	
	for (LL i = 0; i < let; ++i) {
		ans[let-1-i] = char('a'+excess%26);
		excess /= 26;
	}

	for (auto e : ans) {
		cout << e;
	}
	cout << "\n";
}

Measured memory_bytes: 3648
N,*as=$<.read.split.map(&:to_i)
as = as.map.with_index.sort_by {|a,i|-a}

arr = [0] * (N+1)

N.times do |i|
  a,idx = as[i]
  arr_ = [0] * (N+1)
  0.upto(i) do |j|
    # arr_[j+1] = [arr_[j+1],arr[j]+a*(idx-j).abs].max
    arr_[j+1] = arr[j]+a*(idx-j).abs
    arr_[j] = [arr_[j], arr[j]+a*(N-1-i+j-idx).abs].max
  end
  arr = arr_
end

puts arr.max


Measured memory_bytes: 42252
/*
!لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ
فَصَبْرٌ جَمِيلٌ
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define Tesla              file();
#define fr(x,y) for(int x=0; x<(y); ++x)
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	if (y == 1)return x;
	ll r = power(x, y / 2) % mod;
	return r%mod*r%mod*power(x, y % 2) % mod;
}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int main()
{
	Tesla
		int n; cin >> n;
	ll ans = 0;
	fr(i, n + 1)
	{
		if (i % 3 == 0 || i % 5 == 0)
			continue;
		ans += i;
	}
	cout << ans;
}

Measured memory_bytes: 3620
import sys
num = []
for i in sys.stdin:
    H, W = i.split()
    if H == W == '0':
        break
    num.append((int(H), int(W)))

for cnt in range(len(num)):
    for h in range(num[cnt][0]):
        for w in range(num[cnt][1]):
            if w == 0 or w == num[cnt][1] - 1 or h == 0 or h == num[cnt][0] - 1:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()

Measured memory_bytes: 9048
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	rep(i, S.length()) {
		string K;
		rep(j, S.length()) {
			K += S[(i + j) % S.length()];
		}
		if (K == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                    long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar_unlocked
#define gc                    getchar_unlocked
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
int flag[MX>>6];
#define ifc(i)                (flag[i>>6]&(1<<((i>>1)&31)))
#define isc(i)                (flag[i>>6]|=(1<<((i>>1)&31)))
#define chk(n)                (n==2||(n>2&&(n&1)&&!ifc(n)))
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
void sieve(){ int i,j,k; for(i=3;i<lmt;i+=2) if(!ifc(i)) for(j=i*i,k=i<<1;j<MX;j+=k) isc(j);}
void solve()
{
    string x,y;
    cin>>x>>y;
    int n=x.length(),m=y.length();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(x[i-1]==y[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
            else
            {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
            
        }
    }
    string ans="";
    int i=n,j=m;
    while(i>0 && j>0)
    {
        if(x[i-1]==y[j-1])
        {
            ans+=x[i-1];
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}
int main()
{
	int t;
    t=1;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    
    string a_st=to_string(a),b_st=to_string(b);
    string a_stt = a_st,b_stt = b_st;
    for(int i=0;i<b-1;i++){
        a_st += a_stt;
    }
    for(int i=0;i<a-1;i++){
        b_st += b_stt;
    }
    
    //cout << a_st << " " << b_st << endl;
    
    set<string> s;
    s.insert(a_st);
    s.insert(b_st);
    
    cout << *s.begin() << endl;

    return 0;
}


Measured memory_bytes: 256
#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>
#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;
//const long long MOD = 998244353;
using namespace std;
 

int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);
    printf("%d\n", 6-a-b);




    return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<pint> v;
int main()
{
	int n;
	lint x,y,rmax=0,rmin=1145141919,bmax=0,bmin=1145141919;
	cin>>n;
	rep(i,n){
		cin>>x>>y;
		if(x>y) swap(x,y);
		v.pb(mp(x,y));
		rmin=min(rmin,x);rmax=max(rmax,y);
		bmin=min(bmin,y);bmax=max(bmax,x);
	}
	if(n<2){
		cout<<0<<endl;return 0;
	}
	sort(All(v));
	lint out=(bmax-rmin)*(rmax-bmin),ma=v[n-1].fi,mi=1145141919;
	rep(i,n-1){
		ma=max(ma,v[i].se);
		mi=min(mi,v[i].se);
		out=min(out,(rmax-rmin)*(ma-min(v[i+1].fi,mi)));
	}
	cout<<out<<endl;
}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	if(k > n) k = n;
	for(int i = 0; i < n - k; ++i) ans += a[i];
	cout << ans;

	return 0;
}


Measured memory_bytes: 5184
// Last Change: 07/20/2019 21:37:35.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<int> a(N);
  for (auto &&e : a) {
    cin >> e;
  }

  vector<int> box(N);
  ll sumAll = 0;
  for (ll i = N; i >= 2; --i) {
    ll sum = 0;
    for (ll j = 2; j * i <= N; ++j) {
      sum += box[i * j - 1];
    }
    if (sum % 2 == a[i - 1]) {
      box[i - 1] = 0;
    } else {
      box[i - 1] = 1;
      ++sumAll;
    }
  }
  if (sumAll % 2 == a[0]) {
    box[0] = 0;
  } else {
    box[0] = 1;
    ++sumAll;
  }

  cout << sumAll << endl;
  for (ll i = 0; i < N; ++i) {
    if (box[i] == 1) {
      cout << i + 1 << ' ';
    }
  }
  cout << endl;
}


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

int main() {
  int n;
  scanf("%d", &n);
  bool ok = 1, x = 0, y = 0, t = 0;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int d = abs(b-x) + abs(c-y);
    int dt = a - t;
    if ( d > dt || (dt-d) % 2 == 1 ) ok = 0;
  }
  if (ok) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define mmm 1000000007
#define pb push_back

									//nestedcode

 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll n,p,k,kk,po,poo,r,t,z,ans = 0,ans1 = 0;
   cin>>n;
   if(n%2 == 1){
   	cout<<0;
   	return 0;
   }
   p = n;
   k = 1;
   po = 0;
   while(1){
   	if(p/k == 0){
   		break;
	   }
	   k=2*k;
	   po++;
   }
   
   kk = 5;
   poo= 0;
   while(1){
   	if(p/kk == 0){
   		break;
	   }
	   kk=5*kk;
	   poo++;
   }
   

   r = k/2;
   t = k;
   z = po-1;
   
   while(1){
   	if(r == 0){
   		break;
	   }
	   
	   ans+=z*((n/r) - (n/t));
	   r/=2;
	   t/=2;
	   z--;
   }
   
   
   ll prev = 0;
   r = kk/5;
   t = kk;
   z = poo;
  
   while(1){
   	if(r == 1){
   		break;
	   }
	   
	   //cout<<z<<" "<<r<<" "<<prev<<endl;
	   ans1+=(((n/r))/2);
	   //prev = ((n/r))/2 - prev;
	  
	   r/=5;
	//    cout<<prev<<" "<<r<<endl;
	   t/=5;
	  
   }
   
   cout<<min(ans,ans1);
   
   
 }   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B; cin>>N>>A>>B;
  if((N==1&&A!=B)||A>B){cout<<0<<endl; return 0;}
  if(N==1){cout<<1<<endl; return 0;}
  cout<<B*(N-1)+A-A*(N-1)-B+1<<endl;
}

Measured memory_bytes: 3560