akhauriyash/Code-Regression huggingface dataset:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a=inp()
        a-=1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    h, w = map(int, input().split())
    maze = [tuple(input()) for _ in range(h)]
    # h,w = inpm()
    # maze = []
    # for _ in range(h):
    #     s = tuple(input())
    #     maze.append(s)
    ans = 0
    dx = (1,0,-1,0)
    dy = (0,1,0,-1)

    for sx in range(h):
        for sy in range(w):
            if maze[sx][sy] == '#':
                continue
            else:
                d = [[-1 for _ in range(w)] for _ in range(h)]
                que = deque()
                d[sx][sy] = 0
                que.append((sx,sy))
                M = 0
                while que:
                    (qx,qy) = que.popleft()
                    for i in range(4):
                        nx=qx+dx[i]
                        ny=qy+dy[i]
                        if nx>=0 and h>nx and ny>=0 and w>ny and maze[nx][ny]=="." and d[nx][ny]==-1:
                            d[nx][ny]=d[qx][qy]+1
                            if d[qx][qy]+1>M:
                                M= d[qx][qy]+1
                            que.append([nx,ny])
                ans = max(ans,M)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 47192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,y;
  	cin>>n>>y;
 	y/=1000;
  
  	for(ll i=0;i<n+1;i++){
		for(ll j=0;n-i-j>=0;j++){
			if(10*i+5*j+(n-i-j)==y){
				cout<<i<<" "<<j<<" "<<n-i-j<<endl;
              	return 0;
            }
        }
    }
  	
  	cout<<-1<<" "<<-1<<" "<<-1<<endl;
}



Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();

    let mut s = vec![0; n];

    fn roop(i: usize, up: usize, mut s: &mut Vec<usize>) {

        if i == s.len() {
            for i in s.iter() {
                print!("{}", ((97 + i) as u8) as char);
            }
            println!("");
        }
        else {
            for k in 0..up {
                s[i] = k;
                roop(i + 1, max!(up, k + 2), &mut s);
            }
        }

    }

    roop(0, 1, &mut s);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 5500
#include <stdio.h>
 
int main(void) {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x >= r && y >= r && (H - r) >= y && (W - r) >= x) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

ll n, k, i, a[maxN], j, dp[maxN], mn;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	dp[0] = 0;
	for (i = 1; i < n; i++){
		mn = INF;
		for (j = 1; j <= k; j++){
			if (i >= j){
				mn = min(mn, dp[i - j] + abs(a[i] - a[i - j]));
			}
		}
		dp[i] = mn;
	}
	cout << dp[n - 1] << endl;
	return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    --h[0];
    for (int i = 1; i < n; ++i) {
        if (h[i] - 1 >= h[i - 1])
            --h[i];

        if (h[i] < h[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3716
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

n = input()
for loop in range(n):
    A = map(int, raw_input().split())
    B = map(int, raw_input().split())
    cnt = 0
    for p in it.permutations(A):
        cnt += sum(p[i] + B[i] for i in range(9) if p[i] > B[i]) > 85
    ans = float(cnt) / 362880
    print "%.5f %.5f" % (ans, 1 - ans)


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

using namespace std;

typedef long long ll;

#define FOR(_i, _a, _b) for (int _i=_a; _i<_b; ++_i)

const int INF = 1e9+7;

int main()
{
    string s, t, ans;
    cin >> s >> t;
    vector <vector <int>> dp(s.size() + 1, vector <int> (t.size() + 1, 0));

    FOR(i, 1, s.size()+1)
    {
        FOR(j, 1, t.size()+1)
        {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1]==t[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
        }
    }

    int i = s.size();
    int j = t.size();
    while (i && j)
    {
        if (s[i-1] == t[j-1])
        {
            ans += s[i-1];
            --i; --j;
        }

        else if (dp[i-1][j] > dp[i][j-1])
            --i;
        else
            --j;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  ll a_max = *max_element(a.begin(), a.end());
  SORT(b);
  ll ans = 0;
  for(int i = n-1; i >= 0; i--){
    if(b[i] > a_max) {
      ans++;
      h -= b[i];
    }
    if(h <= 0) break;
  }
  if(h > 0) ans += (h + (a_max - 1)) / a_max;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
x, n = [int(i) for i in input().split()]
p = set() if n == 0 else set((int(i) for i in input().split()))
if x not in p:
  print(x)
  exit(0)
h = x + 1
l = x - 1
while True:
  if l not in p:
    print(l)
    exit(0)
  if h not in p:
    print(h)
    exit(0)
  h += 1
  l -= 1

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
map< pair<long long, long long>, int> M;
long long H, W, N, dap[10], a[100100], b[100100];
int main(){
   // freopen("input.txt", "r", stdin);
    long long i, j, k, l, i1;
    cin>>H>>W>>N;
    for(i=0; i<N; i++){
        long long x, y;
        cin>>a[i]>>b[i];
        M[make_pair(a[i], b[i])] = i+1;
    }
    for(i1=0; i1<N; i1++){
        for(i=-2; i<=0; i++){
            for(j=-2; j<=0; j++){
                int flag = 0;
                if(a[i1]+i <= 0 || b[i1]+j <= 0 || a[i1]+i+2 > H || b[i1]+j+2 > W) continue;
                int gs = 1;
                for(k=a[i1]+i; k<=a[i1]+i+2; k++){
                    for(l=b[i1]+j; l<=b[i1]+j+2; l++){
                        int m = M[make_pair(k, l)];
                        if(m != 0 && m != i1+1){
                            if(m < i1+1){
                                flag = 1;
                                break;
                            }
                            gs++;
                        }
                    }
                    if(flag) break;
                }
                if(!flag) dap[gs]++;
            }
        }
    }
    long long hap = 0;
    for(i=1; i<=9; i++){
        hap+=dap[i];
    }
    printf("%lld\n", (H-2)*(W-2)-hap);
    for(i=1; i<=9; i++){
        printf("%lld\n", dap[i]);
    }
}


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

int nxt[20][100000], rev[20][100000];

void construct(vector<int> &v, int l, int c[20][100000]){
    int n = v.size();
    for(int i = 0; i+1 < n; i++){
        c[0][i] = upper_bound(v.begin(),v.end(),v[i]+l)-v.begin()-1;
    }
    c[0][n-1] = -1;
    for(int k = 0; k+1 < 20; k++){
        for(int i = 0; i < n; i++){
            if(c[k][i] < 0)  c[k+1][i] = -1;
            else             c[k+1][i] = c[k][c[k][i]];
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++)  cin >> x[i];
    vector<int> y(n);
    for(int i = 0; i < n; i++)  y[i] = 1e9-x[n-1-i];
    int l;
    cin >> l;
    construct(x, l, nxt);
    construct(y, l, rev);
    auto f = [&](int a, int b, int c[20][100000])->int{
        int ret = 0, tmp = a;
        for(int k = 19; k >= 0; k--){
            int to = c[k][tmp];
            if(to >= 0 && to < b){
                tmp = to;
                ret += 1<<k;
            }
        }
        return ret+1;
    };
    int q;
    cin >> q;
    while(q--){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(a < b)   cout << f(a, b, nxt) << endl;
        else        cout << f(n-1-a, n-1-b, rev) << endl;
    }
    return 0;
}

Measured memory_bytes: 17280
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize
    }
    if n % 2 == 0 {
        println!("{}", n * (n - 2) / 2);
        for i in 1..n {
            for j in i + 1..n + 1 {
                if i + j == n + 1 {
                    continue;
                }
                println!("{} {}", i, j);
            }
        }
    } else {
        println!("{}", (n - 1) * (n - 1) / 2);
        for i in 1..n {
            for j in i + 1..n + 1 {
                if i + j == n {
                    continue;
                }
                println!("{} {}", i, j);
            }
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<typename tp>inline void chemn(tp &a,tp b){a>b?a=b:0;}
cs int mod=998244353;
inline int add(int a,int b){return (a+=b)>=mod?(a-mod):a;}
inline int dec(int a,int b){a-=b;return a+(a>>31&mod);}
inline int mul(int a,int b){static ll r;r=1ll*a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){(a+=b)>=mod?(a-=mod):0;}
inline void Dec(int &a,int b){a-=b,a+=a>>31&mod;}
inline void Mul(int &a,int b){static ll r;r=1ll*a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(int x){return (x<0)?x+mod:x;}
cs int N=100005;
int *f,ft[3][N],n,m,mx,lim;
int pw[N],vis[N],sg[N];
vector<int> e[N];
void dfs(int u){
	if(sg[u]!=-1)return;
	sg[u]=0;
	for(int &v:e[u])dfs(v);
	for(int &v:e[u])vis[sg[v]]=1;
	while(vis[sg[u]])sg[u]++;
	for(int &v:e[u])vis[sg[v]]=0;
	Add(f[sg[u]],pw[u]);
}
inline void fwt(int *f,int lim){
	for(int mid=1,a0,a1;mid<lim;mid<<=1)
	for(int i=0;i<lim;i+=mid<<1)
	for(int j=0;j<mid;j++)
	a0=f[i+j],a1=f[i+j+mid],f[i+j]=add(a0,a1),f[i+j+mid]=dec(a0,a1);
}
inline void ifwt(int *f,int lim){
	for(int mid=1,a0,a1;mid<lim;mid<<=1)
	for(int i=0;i<lim;i+=mid<<1)
	for(int j=0;j<mid;j++)
	a0=f[i+j],a1=f[i+j+mid],f[i+j]=add(a0,a1),f[i+j+mid]=dec(a0,a1);
	for(int i=0,iv=Inv(lim);i<lim;i++)Mul(f[i],iv);
}
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	pw[0]=1;
	for(int i=1,mt=(ll)(1e18)%mod;i<N;i++)pw[i]=mul(pw[i-1],mt);
	for(int t=0;t<3;t++){
		m=read();chemx(mx,m);
		for(int i=1;i<=m;i++){
			int u=read(),v=read();
			if(u>v)swap(u,v);
			e[u].pb(v);
		}
		f=ft[t];
		memset(sg,-1,sizeof(sg));
		for(int i=1;i<=n;i++)if(sg[i]==-1)dfs(i);
		for(int i=1;i<=n;i++)e[i].clear();
	}
	lim=1;
	while(lim*(lim/2)<mx)lim<<=1;
	fwt(ft[0],lim),fwt(ft[1],lim),fwt(ft[2],lim);
	for(int i=0;i<lim;i++)Mul(ft[0][i],mul(ft[1][i],ft[2][i]));
	ifwt(ft[0],lim);
	cout<<ft[0][0]<<'\n';
	return 0;
}

Measured memory_bytes: 8064
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[][] arr=new int[s[1]][];
		int a=0,b=0;

		for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}

		Array.Sort(arr,ca);
		
		for(int i=0;i<s[1];i++){
			if(arr[i][0]>b){
				b=arr[i][1]-1;
				a++;
			}
		}

		Console.WriteLine(a);
	}
	static int ca(int[] a,int[] b){
		if(a[1]>b[1]){return 1;}
		else if(a[1]<b[1]){return -1;}
		else{return 0;}
	}
}

Measured memory_bytes: 23372
n, m = gets.split(' ').map(&:to_i)
s = []
m.times do |i|
    k, *ary = gets.split(' ').map{ |x| x.to_i - 1 }
    s << ary
end

p = gets.split.map(&:to_i)

ans = 0
(0..n).each do |j|
    [*0...n].combination(j) do |num|
        ans += 1 if (0...m).all? { |i| (s[i] & num).size % 2 == p[i] }
    end
end
puts ans

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 

	int n;
	cin >> n;
	
	vector<ll> he(n);
	ll x = 0;
	for (int i = 0; i < n; ++i) {
		cin >> he[i];
	}
	for (int i = 1; i < n; ++i) {
		if (he[i] < he[i-1]) {
			x+= he[i-1] - he[i];
			he[i] += he[i-1] - he[i];
		}
	}
	
	cout << x << endl;
}

/*
int tt;
	cin >> tt;
	while (tt--) {
	
		
	}
*/


Measured memory_bytes: 4712
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [2, 1]
for _ in range(N - 1):
    L.append(L[-1] + L[-2])
print(L[-1])


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;
typedef pair<int,int> P;

int main(){
    S s;
    cin >> s;
    vc t;
    rp(i,s.size()){
        t.pb(s.at(s.size()-1-i));
    }
    while(t.size()){
        if(t.at(0)=='r'){
            if(t.at(1)=='e'){
                if(t.size()>=7&&t.at(2)=='m'&&t.at(3)=='a'&&t.at(4)=='e'&&t.at(5)=='r'&&t.at(6)=='d'){
                    rp(i,7){
                        t.erase(t.begin());
                    }
                    
                }elif(t.size()>=6&&t.at(2)=='s'&&t.at(3)=='a'&&t.at(4)=='r'&&t.at(5)=='e'){
                    rp(i,6){
                        t.erase(t.begin());
                    }
                }else{
                    cout << "NO" << endl;
                    return 0;
                }
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }elif(t.at(0)=='m'){
            if(t.size()>=5&&t.at(1)=='a'&&t.at(2)=='e'&&t.at(3)=='r'&&t.at(4)=='d'){
                rp(i,5){
                    t.erase(t.begin());
                }
            }else{
                cout << "NO" << endl;
            }
        }elif(t.at(0)=='e'){
            if(t.size()>=5&&t.at(1)=='s'&&t.at(2)=='a'&&t.at(3)=='r'&&t.at(4)=='e'){
                rp(i,5){
                    t.erase(t.begin());
                }
            }else{
                cout << "NO" << endl;
            }
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);

const int MAX = 2000010;

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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	COMinit();
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int ans = 0;
	for(int i=B;i<W;i++){
		ans += COM(H-A-1+i, H-A-1) * COM(A-1+W-1-i, A-1);
		ans %= MOD;
	}
	cout << ans<< endl;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 10;
bool prime[N + 7];
vector <long long> primes;
unordered_map <long long, long long> mp;
int main() {
    memset(prime, 1, sizeof(prime));
    prime[0] = prime[1] = 0;
    for ( int i = 4; i < N; i += 2 ) prime[i] = 0;
    for ( int i = 3; i * i < N; i += 2 ) {
        if ( prime[i] ) {
            for ( int j = i + i; j < N; j += i ) {
                prime[j] = 0;
            }
        }
    }
    primes.push_back(2LL);
    for( long long i = 3; i < N; i += 2 ) if( prime[i] ) primes.push_back(i);
    long long a, b;
    cin >> a >> b;
    set <long long> p;
    for ( int i = 0; i < primes.size(); ++i ) {
        if ( a <= 1 ) break;
        if ( a % primes[i] == 0 ) {
            p.insert(primes[i]);
            mp[primes[i]] += 1;
            while( a % primes[i] == 0 ) {
                a /= primes[i];
            }
        }
    }
    if ( a > 1 ) mp[a] += 1, p.insert(a);

    for ( int i = 0; i < primes.size(); ++i ) {
        if ( b <= 1 ) break;
        if ( b % primes[i] == 0 ) {
            p.insert(primes[i]);
            mp[primes[i]] += 1;
            while ( b % primes[i] == 0 ) {
                b /= primes[i];
            }
        }
    }
    if ( b > 1 ) mp[b] += 1, p.insert(b);
    long long cnt = 0;
    for ( auto it : p ) {
        if (mp[it] == 2) ++cnt;
    }
    cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    string s;
    cin >> s;
    rep(i, 0, 3)
    {
        if (s[i] == '1')
            cout << 9;
        else if (s[i] == '9')
            cout << 1;
        else
            cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int n;
    while(~scanf("%d",&n)){
    	int a[100];
    	memset(a,0,sizeof(a));
    	for(int i=1;i<=n;i++){
    		scanf("%d",&a[i]);
		}
		int count=0;
		for(int i=1;i<=n;i=i+2){
			if(a[i]%2!=0) count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#define endl "\n"
#define c0 ios_base :: sync_with_stdio(0); cin.tie (0);
#define s second
#define f first
#define ll long long
#define ull unsigned ll
using namespace std;

const int MaxN = 4e5 + 17;
//const ll INF = 1e9 + 17;
//const int MOD = 1e9 + 7;
//const double eps = 1e-3;
//const double pi = 3.14159265359;


int n, a[MaxN];
int main()
{
    #ifdef DEBUG
        freopen (".in", "r", stdin);
        freopen (".out", "w", stdout);
    #endif
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++ i)
        scanf ("%d", a + i);
    sort (a + 1, a + n + 1);
    printf ("%d", a[n] - a[1]);
    return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  string s, t;
  cin >> s >> t;
  vecll sv(s.size());
  vecll tv(t.size());

  forll(i, 0, s.size())
	sv[i] = s[i] - 'a';
  forll(i, 0, t.size())
	tv[i] = t[i] - 'a';

  sort(sv.begin(), sv.end());
  sort(tv.begin(), tv.end(), greater<ll>());

  forll(i, 0, min(s.size(), t.size())){
	if(sv[i] > tv[i]){
	  cout << "No" << endl;
	  return 0;
	}
	if(sv[i] < tv[i]){
	  cout << "Yes" << endl;
	  return 0;
	}
  }

  if (s.size() >= t.size())
	cout << "No" << endl;
  else
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    string S[N];
    int T[N];
    rep(i,N) cin >> S[i] >> T[i];
    string X;
    cin >> X;
    int ans=0;
    bool check=false;
    rep(i,N){
        if(check) ans+=T[i];
        if(S[i]==X) check=true;
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
// #define int long long

using namespace std;


//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
// vector<int> v(1000);

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  map<char,vector<long long>> dic;
  map<char,vector<long long>> origin_dic;
  map<char,int> check_dic;

  string s, t;
  cin>>s>>t;
  string a = "abcdefghijklmnopqrstuvwxyz";
  rep(i, a.length()) check_dic[a[i]] = 0;
  
  rep(i, s.length()){
    origin_dic[s[i]].push_back(i);
  }
//   cout << origin_dic['a'].size() << endl;

    rep(i, t.length()){
      if (origin_dic.count(t[i])==0){
        cout << -1 << endl;
        return 0;
      }
    }

  long long count=0;
  long long chousei;
  long long check=0;
  rep(i, t.length()){
    if (origin_dic[t[i]].size()==check_dic[t[i]]){
      rep(i, a.length()) check_dic[a[i]] = 0;
      count++;
    }else{
      while(check > origin_dic[t[i]][check_dic[t[i]]]){
        check_dic[t[i]]++;
        if (origin_dic[t[i]].size()==check_dic[t[i]]){
          rep(i, a.length()) check_dic[a[i]] = 0;
          count++;
          break;
        }
      }
    }
    check = origin_dic[t[i]][check_dic[t[i]]];
    check_dic[t[i]]++;
  }
  cout << count*s.length()+check+1 << endl;
  return 0;
}


Measured memory_bytes: 1728
# include "algorithm"
# include "iostream"
# include "cstdio"
# include "queue"

using namespace std;

const int maxm=1e3+10;

int X,Y,Z,K;
long long A[maxm],B[maxm],C[maxm];

priority_queue<pair<long long,int> > LH;

int main(){
	register int i,j;
	register pair<long long,int> Now;
	scanf("%d%d%d%d",&X,&Y,&Z,&K);
	for(i=1;i<=X;i++) scanf("%lld",&A[i]);
	for(i=1;i<=Y;i++) scanf("%lld",&B[i]);
	for(i=1;i<=Z;i++) scanf("%lld",&C[i]);
	sort(A+1,A+1+X);sort(B+1,B+1+Y);sort(C+1,C+1+Z);
	for(i=1;i<=X;i++){
		for(j=1;j<=Y;j++){
			LH.push(make_pair(A[i]+B[j]+C[Z],Z));
		}
	}
	for(i=1;i<=K;i++){
		Now=LH.top();LH.pop();
		printf("%lld\n",Now.first);
		if(Now.second==1) continue;
		LH.push(make_pair(Now.first-C[Now.second]+C[Now.second-1],Now.second-1));
	}
	return 0;
}

Measured memory_bytes: 18792
n=int(raw_input())
day=86400
time=10800
cur=0
cnt=[0]*(day*2+1)
for i in xrange(n):
    a,b=map(int,raw_input().split())
    cur=(cur+a)%day
    cnt[cur]+=1
    cnt[cur+day]+=1
    cur=(cur+b)%day
for i in xrange(day*2):
    cnt[i+1]+=cnt[i]
ans=0
for i in xrange(day):
    if i==0:
        ans=max(ans,cnt[i+time])
    else:
        ans=max(ans,cnt[i+time]-cnt[i-1])
print ans

Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;

void run() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> preW(n + 1), preR(n + 1);
    for (int i = 0; i < n; i++) {
        preW[i + 1] = preW[i] + (s[i] == 'W');
        preR[i + 1] = preR[i] + (s[i] == 'R');
    }
    int ans = preR[n];
    // rrr...wwww
    for (int i = 0; i < n; i++) {
        int L = preW[i + 1], R = preR[n] - preR[i + 1];
        ans = min(ans, max(L, R));
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    run();
    return 0;
}


Measured memory_bytes: 5180
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N = int(input())
evid = [[] for _ in range(N)]

for i in range(N):
  a = int(input())
  for _ in range(a):
    x, y = map(int, input().split())
    evid[i].append((x-1,y))
    
ans = 0
for bit in range(1<<N):
  cnt = 0
  ok = True
  for i in range(N):
    if not bit>>i & 1:
      continue
    for x, y in evid[i]:
      if y==1 and not bit>>x & 1:
        ok = False
        break
      if y==0 and  bit>>x & 1:
        ok = False
        break
    if ok:
      cnt += 1
    else:
      break
  else:
    ans = max(ans, cnt)
print(ans)    
      
    

Measured memory_bytes: 3064
import static java.lang.System.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public void solve() {
		int K = nextInt();
		int N = nextInt();
		int[] A = new int[N];
		int max = 0;

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

		for(int i=0;i<N;i++) {
			int len = A[i]-A[(i-1+N)%N];
			len = (len+K)%K;
			max = max(max,len);
		}
		out.println(K-max);
	}

	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

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

	double sqrt(double x) {
		return Math.sqrt(x);
	}

	double pow(double x, double y) {
		return Math.pow(x, y);
	}
	int max(int a,int b) {
		return Math.max(a, b);
	}

	public static void main(String[] args) {
		Main m = new Main();

		m.solve();
	}

	public void println(Object o) {
		out.println(o);
	}

}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    while(n--)
    {
        int l, r;
        cin >> l >> r;
        arr[l] += 1;
        arr[r + 1] -= 1;
    }
    for(int i = 1; i <= 1e5; i++)
        arr[i] += arr[i - 1];
    for(int i = 1; i <= 1e5; i++)
        arr[i] += arr[i - 1];
    cout << arr[100000];
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,bitsum=0;
    cin>>N;
    
    for(int i=0;i<N;++i){
        int A;
        cin>>A;
        bitsum|=A;
    }
    
    int count=0;
    while((bitsum&1)==0){
        ++count;
        bitsum>>=1;
    }
    
    cout<<count<<endl;
}


Measured memory_bytes: 256
n, a, b = [int(x) for x in input().split()]

p = 10 ** 9 + 7

binom = n # n choose 1
ans = 0 if a == 1 or b == 1 else n

# x^nを求める
def exp_by_sq(x, n):
    if n == 0:
        exp = 1
    elif n == 1:
        exp = x % p
    elif  n % 2 == 0:
        exp = exp_by_sq(x * x % p, n // 2)
    else:
        exp = x * exp_by_sq(x * x % p, (n - 1) // 2) % p
    return exp % p


def binomial_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    '''
    k = min(k, n-k)
    numer = n  # n * (n-1) * ... * (n- k + 1)
    inv = [0, 1]    # inv[i] : inverse of i mod p
    invfct_k = 1 # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p

    for i in range(2, k + 1):
        numer = numer * (n - i + 1) % p
        inv.append(( inv[p % i] * (p - p//i) ) % p ) # inverse of i
        invfct_k = invfct_k * inv[-1] % p

    if k == 0:
        return 1
    elif k == 1:
        return n
    else:
        return numer * invfct_k % p

ans = (exp_by_sq(2, n) - 1 - binomial_p(n, a, p) - binomial_p(n, b, p)) % p

print(ans)

Measured memory_bytes: 66672
#include<stdio.h>
#include<string.h>
int main(){
  int a,b,c,k;
  int i,j;
  
  scanf("%d %d %d %d",&a,&b,&c,&k);
  if(a>=k){
   printf("%d\n",k);
  }else if(a+b>=k&&a+b+c>k){
   printf("%d\n",a); 
  }else{
    printf("%d\n",a+a+b-k);
  }
  
 return 0; 
}



Measured memory_bytes: 1716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >>c;
    string ans = "No";
    if(a<c && c<b) ans = "Yes";
    if(b<c && c<a) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int h,a;
    cin >> h >> a;
    int res =h/a;
    if (h%a != 0) res++;
    cout << res;
    return 0;
}



Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  double x=0.0, y=0.0;
  int direction = 90;
  int distance,angle;
  char comma;
  while(true){
    cin >> distance >> comma >> angle;
    if(distance == 0 && angle == 0) break;

    x += distance * cos(direction * M_PI/180.0);
    y += distance * sin(direction * M_PI/180.0);
    direction -= angle;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int N_MAX = 100;
int main()
{
  int n,m,ss,tt,i,j,res=0;
  string st,s[N_MAX],t[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> s[i];
  cin >> m;
  for(i=0;i<m;i++)
    cin >> t[i];
  sort(s,s+n);
  sort(t,t+m);
  for(i=0,j=0;i<n;){
    ss=0; tt=0; st=s[i];
    for(;i<n&&s[i]==st;i++)
      ss++;
    for(;j<m;j++){
      if(t[j]<st)
        continue;
      if(t[j]==st)
        tt++;
      if(t[j]>st)
        break;
    }
    res=max(res,ss-tt);
  }
  cout << res << endl;
  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  string s, t;
  cin >> s >> t;
  REP(i, s.length()) {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    s.insert(0, &(s.back()));
    s.pop_back();
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
n=int(input())
a,b=1,[1]
for i in [0]*12:
    a=26*a+1
    b.append(a)
c=13-sorted(b+[n],reverse=True).index(n)
a=n-b[c-1]
s=''
for i in [0]*c:
    s=chr(a%26+97)+s
    a=a//26
print(s)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define maxn 105
using namespace std;
int n,b[maxn],pos[maxn];
int a[maxn];
int ans[maxn];
bool cmp(int i,int j)   {
    return b[i]<b[j]||(b[i]==b[j]&&i<j);
}
int main()  {
    scanf("%d",&n);
    for (int i=1;i<=n;++i)  scanf("%d",&b[i]),pos[i]=i;
    sort(pos+1,pos+n+1);
    for (int i=n;i;--i) {
        if (b[pos[i]]>i)    return puts("-1"),0;
        // cout<<i<<":"<<endl;
        int j=n,c=0;
        while (j) {
            if (c==pos[i]-b[pos[i]]&&!ans[j])    break;
            if (!ans[j])    ++c;
            --j;
        }
        if (!j) return puts("-1"),0;
        ans[j]=b[pos[i]];
    }
    for (int i=1;i<=n;++i)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  std::vector<int> a(3);
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  std::sort(a.begin(), a.end());
  printf("%d %d %d\n", a[0], a[1], a[2]);
}



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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    int value_max = abs(A[0]) + abs(A[N-1]);
    for(int i = 0; i < N -1; i++)value_max += abs(A[i] - A[i+1]);

    cout << value_max - abs(A[0]) + abs(A[1]) - abs(A[0] - A[1]) << endl;
    for(int i = 1; i < N-1; i++){
        cout << value_max - abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]) << endl;
    }
    cout << value_max - abs(A[N-1]) + abs(A[N-2]) - abs(A[N-1] - A[N-2]) << endl;


}

Measured memory_bytes: 1784
a[1<<17],m;main(n,v,i){for(;scanf("%d",&n)*n;){for(i=0;i++<n;a[m]++)scanf("%d",&v),a[m+=v!=m%2]|i%2||(a[v=m>1?m-2:m]+=a[m-1],a[m-1]=0,m=v);for(;m;a[m--]=0)n-=m%2*a[m];*a=!printf("%d\n",n);}}

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

int main()
{
	string ss;
	int num[100000];
	LL int final=0;
	int flag=0;
	LL int tot=0;
	cin>>ss;
	int n=ss.length();
	for(LL int i=0;i<n;i++)
	{
		if(ss[i]!='x')
		{
			num[final]=i;
			final++;
		}
	}
	LL int begin=0;
	if(final!=0)
	{
		final--;
	}
	else
	{
		cout<<0<<endl;
		return 0;
	}
	for(;begin<final;)
	{
		if(ss[num[begin]]!=ss[num[final]])
		{
			flag=1;
			break;
		}
		else
		{
			final--;
			begin++;
		}
	}
	if(flag==1)
		cout<<-1<<endl;
	else
	{
		//cout<<begin<<" "<<final<<endl;
		if(final==0)
		{
			cout<<abs(n-1-num[begin]-num[final])<<endl;
			return 0;
		}
		else
		{
			for(;final>0;)
			{
				tot+=abs(num[begin+1]-num[begin]-num[final]+num[final-1]);
				final--;begin++;
			}
			tot+=abs(n-1-num[begin]-num[final]);
			cout<<tot<<endl;
		}
	}
	return 0;
	
} 

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[4]={0};
  	int a,b,c,d,i,j;
  	scanf("%d",&a);
  	for(i=0;i<4;i++)
    {
		arr[i]=a%10;
      	a/=10;
    }
  	if(arr[0]==arr[1] || arr[1]==arr[2] || arr[2]==arr[3])
  	{
		printf("Bad");
  	}
  	else
  	{
		printf("Good");
  	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define I insert
#define bull bool
#define Max(a,b) ((b<a)?a:b)
#define Min(a,b) ((a<b)?a:b)

const LL N = 100005, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans;
string s;

LL getint(){
	char c = getchar();
	LL t = 0;
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		t = (t << 3) + (t << 1);
		t += c - '0';
		c = getchar();
	}
	return t;
}


int main(){
	/*/
	freopen ( "detectivein.txt", "r", stdin);
	freopen ( "detectiveout.txt", "w", stdout);
	/**/
	cin >> l >> r;
	cin >> n >> m;
	k = n*m/__gcd(n, m);
	t = - ( (l - 1) / n + (l - 1) / m - (l - 1) / (k));
	t += ( (r) / n + (r) / m - (r) / (k));
	t = r - l + 1 - t;
	cout << t << endl;
	
	return 0;
}
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

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

foreach ($input as $k => $v) {
	$as[$k+1] = (int)$v;
}

$result = [];
for ($i=0; $i < $n; $i++) { 
	$tmp = $n - $i;
	$tmp_a = $as[$tmp];
	if ($tmp * 2 > $n) {
		$result[$tmp] = $tmp_a;
	}else{
		$sum = 0;
		$j = 2;
		while ($tmp * $j <= $n) {
			$sum += $result[$tmp * $j];
			$j += 1;
		}
		if ($sum % 2 === $tmp_a) {
			$result[$tmp] = 0;
		}else{
			$result[$tmp] = 1;
		}
	}
}

$m = 0;
$box = [];
foreach ($result as $k => $v) {
	$m += $v;
	if ($v === 1) {
		$box[] = $k;
	}
}
echo $m . PHP_EOL;
echo implode(' ', $box);

Measured memory_bytes: 41448
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		int a[100], b[100], sa = 0, sb = 0;
		for (int i = 0;i < n;i++)
		{
			cin >> a[i];
			sa += a[i];
		}
		for (int i = 0;i < m;i++)
		{
			cin >> b[i];
			sb += b[i];
		}
		int ansa = -1, ansb = -1;
		for (int i = 0;i < n;i++)
		{
			for (int j = 0;j < m;j++)
			{
				if (sa - a[i] + b[j] == sb - b[j] + a[i])
				{
					int na = i + 1, nb = j + 1;
					if (ansa<0 || ansa + ansb>a[i] + b[j])
					{
						ansa = a[i], ansb = b[j];
					}
				}
			}
		}
		if (ansa < 0)cout << -1 << endl;
		else cout << ansa << " " << ansb << endl;
	}
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
long long  n,a[100001],num[100001],q;
long long sum;
int main()
{
	cin >> n;
	for (int i=1;i<=n;i++) 
	{
		cin >> a[i];
		num[a[i]]++;
		sum+=a[i];
	}
	cin >> q;
	while (q--)
	{
		int x,y;
		cin >> x >> y;
		sum+=(y-x)*num[x];
		num[y]+=num[x];
		num[x]=0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 5076