akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
ll dp[20][180][2][200];
ll k,n;
ll getsum(ll a,vector<ll>&digitA)
{
    ll s=0;
    while(a)
    {
        digitA.pb(a%10);
        s+=a%10;
        a/=10;
    }
    return s;
}
ll Superb(ll indx,ll sum,ll cond,vector<ll>&digitA,ll mid)
{
    if(indx==-1)
    {
        return (sum%k==0&&mid%k==0);
    }
    if(dp[indx][sum][cond][mid]!=-1&&cond!=1)return dp[indx][sum][cond][mid];
    ll kk=(cond)?digitA[indx]:9;
    ll total=0;
    for(ll i=0; i<=kk; i++)
    {
        ll newcond=(i==digitA[indx])?cond:0;
        total+=Superb(indx-1,(sum+i)%k,newcond,digitA,(mid*10+i)%k);
    }
    if (!cond)
        dp[indx][sum][cond][mid] = total;
    return total;
}
ll first(ll n,ll m)
{
    memset(dp,-1,sizeof dp);
    vector<ll>digitA;
    getsum(m,digitA);
    ll ans1=Superb(digitA.size()-1,0,1,digitA,0);
    vector<ll>digitB;
    getsum(n,digitB);
    ll ans2=Superb(digitB.size()-1,0,1,digitB,0);
    ll r=ans1-ans2;
    return r;
}
int main()
{
    ll n;
    cin>>n;
    ll s=0,kk=n;
    while(kk)
    {
        s+=kk%10;
        kk/=10;
    }
    if(n%s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

public class Po
{
    public int x { get; set; }
    public int y { get; set; }
    public int n { get; set; }
}
public class Re
{
    public bool result { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var dxp = new int[] { -1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2 };
        var dyp = new int[] { 2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1 };
        var dxs = new int[] { -1, -1, -1, 0, 1, 1, 1, 0, 0 };
        var dys = new int[] { -1, 0, 1, 1, 1, 0, -1, -1, 0 };
        while (true)
        {
            var st = new Stack<Po>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var py = int.Parse(line[0]);
            var px = int.Parse(line[1]);
            if (px == 0 && py == 0) break;
            var n = int.Parse(Console.ReadLine().Trim());
            var sc = new Po[n];
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var t = Array.ConvertAll(line2, int.Parse);
            for (int i = 0; i < n; i++)
                sc[i] = new Po { y = t[2 * i], x = t[2 * i + 1] };
            var map = new int[10, 10];
            var p = new Po { x = px, y = py, n = 0 };
            st.Push(p);
            var re = new Re();
            goDfs(map, sc, st, dxs, dys, dxp, dyp  ,re);
            Console.WriteLine(re.result ? "OK" : "NA");
        }
    }
    public static void goDfs(int[,] map, Po[] sc, Stack<Po> st, int[] dxs, int[] dys, int[] dxp, int[] dyp  ,Re re)
    {
        while (st.Count() > 0)
        {
            var p = st.Pop();
            if (p.n == sc.Length) { re.result = true; return; }
            writeMap(map, sc, p.n, dxs, dys);
            for (int i = 0; i < 12; i++)
            {
                var nx = p.x + dxp[i];
                var ny = p.y + dyp[i];
                if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10 && map[nx, ny] == 1)
                    st.Push(new Po { x = nx, y = ny, n = p.n + 1 });
            }
        }
    }
    public static void writeMap(int[,] map, Po[] sc, int n, int[] dxs, int[] dys)
    {
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++) map[i, j] = 0;
        for (int i = 0; i < 9; i++)
        {
            var nx = sc[n].x + dxs[i];
            var ny = sc[n].y + dys[i];
            if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) map[nx, ny] = 1;
        }
    }
}

Measured memory_bytes: 10108
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll s;cin >> s;
  ll x = (ll)sqrt(s);
  if(x*x==s){
      cout << "0 0 " << x << " 0 0 " << x << endl;
      return 0;
  }else{
      x++;
  }
  ll del = x*x-s;
  FOR(i,1,1e9){
      if(del%i!=0)continue;
      if(del/i<1e9){
          cout << "0 0 " << x << " " << i << " " << del/i << " " << x << endl;
          return 0;
      }
  }


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>

using namespace std;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    set<int> g;
    for(int i=0; i<N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1) {
            for(int i=0; i<H; i++) {
                for(int j=x-1; j>=0; j--) {
                    g.insert(i*W+j);
                }
            }
        } else if(a==2) {
            for(int i=0; i<H; i++) {
                for(int j=x; j<W; j++) {
                    g.insert(i*W+j);
                }
            }
        } else if(a==3) {
            for(int i=y-1; i>=0; i--) {
                for(int j=0; j<W; j++) {
                    g.insert(i*W+j);
                }
            }
        } else {
            for(int i=y; i<H; i++) {
                for(int j=0; j<W; j++) {
                    g.insert(i*W+j);
                }
            }
        }
    }
    cout << W*H - g.size() << endl;
}


Measured memory_bytes: 768
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let l = read_t_in_line::<i32>();
    let (n, q) = (l[0], l[1]);
    let s = read_line().chars().collect::<Vec<char>>();
    let mut sums = vec![0 ; (n + 1) as usize];
    sums[0] = 0;
    for i in 0..(n-1) {
        if s[i as usize] == 'A' && s[(i+1) as usize] == 'C' {
            sums[(i+1) as usize] = sums[i as usize] + 1;
        }
        else{
            sums[(i+1) as usize] = sums[i as usize] ;
        }
    }
    sums[n as usize] = sums[(n-1) as usize];

    for _ in 0..q {
        let tmp = read_t_in_line::<i32>();
        let (l,r) = (tmp[0]-1, tmp[1]-1);
        let mut ans = sums[(r + 1) as usize] - sums[l as usize];
        if sums[(r+1) as usize] > sums[r as usize] {
            ans -= 1;
        }
        println!("{}", ans);
    }
    
}


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

using namespace std;

int main(int argc, char **argv)
{
    int n,l;
    cin>>n>>l;
    string s;
    vector<string> vec;
    for(int i = 0;i < n;i++){
        cin>>s;
        vec.push_back(s);
    }
    sort(vec.begin(),vec.end());
    for(int i = 0 ; i <  n;i++){
        cout<<vec[i];
    }
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

// 1-indexed
// example: Bit::new(n, |x, y| *x += *y, 0)
struct Bit<T, F> {
    n: usize,
    dat: Vec<T>,
    op: F,
    unit: T,
}

impl<T: Clone, F: Fn(&mut T, &T)> Bit<T, F> {
    #[allow(dead_code)]
    fn new(n: usize, op: F, unit: T) -> Self {
        Bit {
            n: n,
            dat: vec![unit.clone(); n + 1],
            op: op,
            unit: unit,
        }
    }
    #[allow(dead_code)]
    fn from_vec(mut v: Vec<T>, op: F, unit: T) -> Self {
        let n = v.len();
        let mut dat = vec![unit.clone()];
        dat.append(&mut v);
        for i in 1..n {
            let j = i as i32;
            let b = (j & -j) as usize;
            let x = dat[i].clone();
            op(&mut dat[i + b], &x);
        }
        Bit {
            n: n,
            dat: dat,
            op: op,
            unit: unit,
        }
    }
    fn operate(&mut self, k: usize, a: &T) {
        let mut k = k;
        while k <= self.n {
            (self.op)(&mut self.dat[k], &a);
            let l = k as i32;
            k += (l & -l) as usize;
        }
    }
    fn accum(&self, k: usize) -> T {
        let mut k = k;
        let mut sum = self.unit.clone();
        while k > 0 {
            (self.op)(&mut sum, &self.dat[k]);
            let l = k as i32;
            k -= (l & -l) as usize;
        }
        sum
    }
}

fn main() {
  input! {
    n: usize,
    h: [usize; n],
    a: [i64; n]
  }
  let mut bit = Bit::new(n, |x, y| *x = cmp::max(*x, *y), -1e18 as i64);
  bit.operate(1, &0);
  for i in 0 .. n {
    let current = bit.accum(h[i]);
    bit.operate(h[i], &(current + a[i]));
  }
  println!("{}", bit.accum(n));
}


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

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

    vector<bool> check(4, false);
    int N = S.size();
    for (int i = 0; i < N; i++) {
        if (S[i] == 'N') check[0] = true;
        if (S[i] == 'W') check[1] = true;
        if (S[i] == 'S') check[2] = true;
        if (S[i] == 'E') check[3] = true;
    }

    if (check[0] == check[2] && check[1] == check[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import math

N,D = list(map(int, input().split()))
list_X = []
ans = 0

for i in range(N):
    Xi = list(map(int, input().split()))
    list_X.append(Xi)

for i in range(N-1):
    for j in range(i+1,N):
        
        list_of_squares = [(list_X[i][k]-list_X[j][k])**2 for k in range(D)]
        sum_of_squares = sum(list_of_squares)
        distance = math.sqrt(sum_of_squares)

        if distance.is_integer() == True:
            ans+=1
        
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const ll INF = 1e10;
const ll MOD = 1e9 + 7;
const ll MAX_N = 3e3 + 10;
ll dp[MAX_N][MAX_N];

int main(){
    ll i, j;
    ll N;
    cin>>N;
    vll A(N);
    for(auto &e: A)cin>>e;
    bool odd = (N%2 == 1);

    for(i = 0; i<N; i++){
        if(odd){
            dp[i][i] = A[i];
        }
        else{
            dp[i][i] = -A[i];
        }
        // cout<<dp[i][i]<<endl;
    }
    for(i = 1; i < N; i++){
        for(j = 0; j < N - i; j++){
            if(i%2 == N%2){
                dp[j][j + i] = min(dp[j][j + i - 1] - A[j + i], dp[j + 1][j + i] - A[j]);
                // cout<<dp[j][j + i]<<endl;
            }
            else{
                dp[j][j + i] = max(dp[j][j + i - 1] + A[j + i], dp[j + 1][j + i] + A[j]);
                // cout<<dp[j][j + i]<<endl;
            }
        }
    }
    cout<<dp[0][N - 1]<<endl;

    return 0;
}

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

int main() {
	int N;
	cin >>N;
	vector <int> A(N);

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

	int max;
	int second_max;

	
	vector <int> B(N);
	copy(A.begin(), A.end(), back_inserter(B));

	sort(B.begin(), B.end(), greater<int>());
	max = B[0];
	second_max = B[1];

	for (int i = 0; i < N; i++) {
		if (A[i]==max) {
			cout << second_max << endl;
		}
		else {
			cout << max << endl;
		}
	}
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
#define pt pair<double,double>
#define x first
#define y second
const double INF=1e7;
pt p[100010];
double pw2(double d){return d*d;}
double dist(pt a,pt b){return sqrt(pw2(a.x-b.x)+pw2(a.y-b.y));}
bool cmp(pt a,pt b){return a.y<b.y;}
double closest(int l,int r)
{
  if(l==r) return INF;
  int mid=(l+r)/2,pp=l,qq=mid+1;
  double midline=p[mid].x;
  double ret=min(closest(l,mid),closest(mid+1,r));
  vector<pt> slab;
  inplace_merge(p+l,p+mid+1,p+r+1,cmp);
  for(int i=l;i<r;i++)if(p[i].y>p[i+1].y)cout<<"ERROR\n";
  //conquer
  for(int i=l;i<=r;i++)
    if(abs(p[i].x-midline)<ret)
      slab.push_back(p[i]);
  for(int i=0;i<slab.size();i++)
    for(int j=i+1;j<slab.size() && abs(slab[i].y-slab[j].y)<ret;j++)
      ret=min(ret,dist(slab[i],slab[j]));
  return ret;
}
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>p[i].x>>p[i].y;
  sort(p+1,p+n+1);
  cout<<fixed<<closest(1,n)<<endl;
  return 0;
}

Measured memory_bytes: 7912
import sys
readline = sys.stdin.readline
from collections import deque

def main():
    N = int(readline())
    que = []
    for val in ['357', '375', '537', '573', '735', '753']:
        if int(val) <= N:
            que.append(val)
    res = set(que)
    que = deque(que)
    while que:
        pre = que.popleft()
        for p in ['3', '5', '7']:
            for i in range(len(pre)+1):
                next = pre[:i] + p + pre[i:]
                if int(next) <= N and next not in res:
                    que.append(next)
                    res.add(next)

    print(len(res))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000000
#define mod 2019

int main(){
	ll w,h,x,y;cin>>w>>h>>x>>y;

	if((x==0 && y==0)||(x==0 && y==h)||(x==w && y==h)||(x==w && y==0)){printf("%.12f %d\n",(w+.0)*h/2.0,0);return 0;}
	
	if(2*x==w && 2*y==h){printf("%.12f %d\n",(w+.0)*h/2.0,1);return 0;}

	printf("%.12f %d\n",(w+.0)*h/2.0,0);
	return 0;
}

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

int main(){ 
string s,t;
cin>>s>>t;
int a=0;
for(int i=0; i<s.size(); i++){
if(s[i]==t[i]){
a++;
}
}
if(a==s.size()){  
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}

}



Measured memory_bytes: 3628
fun main(args: Array<String>){
	val n = readLine()!!.toInt()
	val array = readLine()!!.split(" ")
	val b = Array(array.size){
		array[it].toInt()
	}
	
	var result = b[0] + b[n-2]
	for( i in 1 until n-1 )
		result += Math.min(b[i],b[i-1])
	
	println(result)
}


Measured memory_bytes: 38012
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
const int maxn=1e5+5;
int vis[maxn*2],vis2[maxn*2];
struct node
{
    int a,b;
} p[maxn];
set<int>s;
set<int>::iterator it;
bool cmp(node &x,node &y)
{
    return x.b>y.b || (x.b==y.b && x.a < y.a);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        scanf("%d%d",&p[i].a,&p[i].b);
    }
    for(int i=1;i<=m;i++)
        s.insert(i);
    sort(p+1,p+1+n,cmp);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(s.size()==0)break;
        it=s.lower_bound(p[i].a);
        if(it!=s.end())
        {
            sum+=p[i].b;
            s.erase(s.find(*it));
        }
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 5760
import math
H,W = map(int,input().split())

while (H!=0 or W!=0):
    for i in range(H):
        if(i==0 or i==H-1):
            print(W*"#")
        else:
            print("#"+(W-2)*"."+"#")
            
    print()
    H,W = map(int,input().split())

Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
int a[4][4];
int main(){
    cin>>a[1][1]>>a[1][2]>>a[2][2];
    a[1][3]=a[2][2]*3-a[1][1]-a[1][2];
    a[3][1]=a[2][2]*3-a[1][3]-a[2][2];
    a[3][3]=a[2][2]*3-a[1][1]-a[2][2];
    a[2][1]=a[2][2]*3-a[1][1]-a[3][1];
    a[2][3]=a[2][2]*3-a[2][1]-a[2][2];
    a[3][2]=a[2][2]*3-a[1][2]-a[2][2];
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++)
            cout<<a[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
int a[maxn];
bool b[maxn];
int main()
{
    int n;
    ll k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        b[i] = 0;
    }
    int now = 1;
    queue<int> q;
    while (b[now] == 0)
    {
        b[now] = 1;
        q.push(now);
        now = a[now];
    }
    while (q.front() != now && k > 0)
        k--, q.pop();
    if (k == 0)
    {
        printf("%d\n", q.front());
        return 0;
    }
    vector<int> v;
    while (!q.empty())
    {
        v.push_back(q.front());
        q.pop();
    }
    int len = v.size();
    k = k % len;
    printf("%d\n", v[k]);
    return 0;
}

Measured memory_bytes: 5924
import sys
def is_pal(s):
    #print(s,'s')
    i,j=0,len(s)-1
    while i<=j:
        if s[i]==s[j]:
            i+=1
            j-=1
        else:
            return False
    return True
s=sys.stdin.readline()[:-1]
n=len(s)
if n%2!=0:
    if is_pal(s[:n//2]) and is_pal(s[n//2+1:]) and is_pal(s):
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

int main(){
	int n;
	cin >> n;
	vector<int> vc(n);
	for (int i=0;i<n;i++){
		cin >> vc.at(i);
	}
	bool flag = true;
	int ans = 0, tmp = 0;
	while (flag == true){
		flag = false;
		for (int j=n-1;j>0;j--){
			if (vc.at(j) < vc.at(j-1)){
				tmp = vc.at(j);
				vc.at(j) = vc.at(j-1);
				vc.at(j-1) = tmp;
				ans++;
				flag = true;
			}
		}
	}
	for (int i=0;i<n;i++){
		if (i!=n-1){
			cout << vc.at(i) << " ";
		}
		else{
			cout << vc.at(i) << endl;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3120
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int64

readIntArray ()

readIntArray ()
|> Array.fold (fun x y ->
    if y = 0L then 0L
    else if x <= -1L || x > 1000000000000000000L / y then -1L
    else x * y) 1L
|> fun x -> if x > 1000000000000000000L then -1L else x
|> printfn "%d"


Measured memory_bytes: 43496
S=input()
T=input()
s=0
flag1=False
for i in range(len(S)-len(T)+1):
    flag2=True
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!='?':
            flag2=False
    if flag2==True:
        flag1=True
        s=i
if flag1==False:
    print('UNRESTORABLE')
else:
    for i in range(len(S)):
        if i>=s and i-s<len(T):
            print(T[i-s],end='')
        elif S[i]=='?':
            print('a',end='')
        else:
            print(S[i],end='')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll mod = 1000000007;
int dp[maxn];
int vis[maxn];
int main()
{
    int n,m;
    memset (dp,0,sizeof(dp));
    memset (vis,0,sizeof(vis));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int temp;
        scanf("%d",&temp);
        vis[temp]=1;
    }
    int falg=0;
    for(int i=2;i<=n;i++){
        if(vis[i]&&vis[i-1]){
            falg=1;
            break;
        }
    }
    if(falg){
        cout<<0<<endl;
    }
    else{
        dp[0]=1;dp[1]=1;
        for(int i=2;i<=n;i++){
            if(vis[i-1]){
                dp[i]=dp[i-2];
            }
            else if(vis[i-2]){
                dp[i]=dp[i-1];
            }
            else{
                dp[i]=(dp[i-1]+dp[i-2])%mod;
            }
        }
        printf("%d\n",dp[n]);
    }
}


Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private fun solve() {
    val n = nextInt()
    val a = Array(n) { nextInt() }
    val b = Array(n) { nextInt() }
    val aa = Array(n) { a[it] xor a[(it + 1) % n] }
    val bb = Array(n) { b[it] xor b[(it + 1) % n] }
    val s = Array(3 * n + 1) { -1 }
    for (i in 0 until n) {
        s[i] = bb[i]
        s[n + 1 + i] = aa[i]
        s[2 * n + 1 + i] = aa[i]
    }
    val pi = Array(s.size) { 0 }
    for (i in 1 until pi.size - 1) {
        var j = pi[i - 1]
        while (j > 0 && s[i] != s[j]) {
            j = pi[j - 1]
        }
        if (s[i] == s[j]) ++j
        pi[i] = j
        if (j == n && i > 2 * n - 1) {
            val k = i % n
            val x = a[k] xor b[0]
            println("$k $x")
        }
    }
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 111108
#include<stdio.h>



int main(){

int a[10];
int i,max,j,k,l;

for( i=0; i<10; i++ ){

	scanf("%d",&a[i]);
	
}

max=-1;

for( i=0; i<10; i++ ){
	if( max<a[i] ){	//iテァツ閉ェテ・ツ慊ーテ」ツ?ョテ・ツ?、テ」ツ??テァツ渉セテ・ツ慊ィテ」ツ?ョテヲツ慊?・ツ、ツァテ・ツ?、 テ」ツつ暗」ツつ甘」ツつづ」ツ?甘」ツ?甘」ツ?催」ツ?妥」ツつ古」ツ?ー
		 max=a[i];	//maxテ」ツ?ョテ・ツ?、テ」ツつ津ヲツ崢エテヲツ鳴ー
		 j=i;	//テ、ツスツ陛ァツ閉ェテ・ツ慊ーテ」ツ?ョテ・ツ?、テ」ツ?ォテヲツ崢エテヲツ鳴ーテ」ツ?療」ツ?淌」ツ?凝」ツつ津ィツィツ佚ゥツ個イテ」ツ?療」ツ?ヲテ」ツ?甘」ツ??
	}
}


a[j]=-1;

printf("%d\n",max);

max=-1;

for( i=0; i<10; i++ ){
	if( max<a[i] ){
		max=a[i];
		k=i;

	}
}

a[k]=-1;

printf("%d\n",max);

max=-1;

for( i=0; i<10; i++ ){
	if( max<a[i] ){
		max=a[i];
		l=i;

	}
}


printf("%d\n",max);

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string a,b,c;
	cin >> a >> b >> c;
	cout << char(toupper(a[0])) << char(toupper(b[0])) << char(toupper(c[0])) << endl;
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    vector<ll> dp(W + 1);
    for (int i = 0; i < n; i++)
    {
        for (int j = W; j >= w[i]; j--)
        {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[W];
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

type Restaurant struct {
	idx int
	city string
	point int
}

type Restaurants []Restaurant

func (p Restaurants) Len() int {
	return len(p)
}

func (p Restaurants) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Restaurants) Less(i, j int) bool {
	if p[i].city != p[j].city {
		return p[i].city < p[j].city
	} else {
		return p[j].point < p[i].point
	}
}

func main()  {
	var n int

	fmt.Scan(&n)

	res := make(Restaurants, 0, n)

	for i := 0; i < n; i++ {
		var city string
		var point int
		fmt.Scan(&city, &point)

		res = append(res, Restaurant{idx: i+1, city: city, point:point})
	}

	sort.Sort(res)
	for _, v := range res {
		fmt.Println(v.idx)
	}
}


Measured memory_bytes: 512
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

int main()
{

    int n;

    cin>>n;

    string str;

    cin>>str;

    int ans=0;
    for(int i=0;i<n-1;i++){
        map<char,int>occ1;
        map<char,int>used;
        int cnt1=0,cnt2=0;
        for(int k=0;k<=i;k++){
             if(!occ1[str[k]])
                cnt1++;
             occ1[str[k]]++;
        }
         for(int j=i+1;j<n;j++){
             if(occ1[str[j]]&&!used[str[j]])
                cnt2++,used[str[j]]=1;

         }

          ans=max(ans,min(cnt1,cnt2));
    }

    cout<<ans;


    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


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

int main() {

  int K;
  cin >> K;

  queue<int64_t> q;

  for (int i = 1; i < 10; i++)
      q.push(i);

  for (int i = 0; i < K-1; i++) {
      int64_t x=q.front();
      if(x%10!=0) {
          q.push(10*x+x%10-1);
      }
      q.push(10*x+x%10);
      if(x%10!=9) {
          q.push(10*x+x%10+1);
      }
      q.pop();
  }

  cout << q.front() << endl;
}

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

int c[3][3];
bool ans;

int main(){

  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>c[i][j];


  for(int a1=0;a1<=100;a1++){
    for(int a2=0;a2<=100;a2++){
      for(int a3=0;a3<=100;a3++){
        if(c[0][0]-a1==c[0][1]-a2&&c[0][0]-a1==c[0][2]-a3)
          if(c[1][0]-a1==c[1][1]-a2&&c[1][0]-a1==c[1][2]-a3)
            if(c[2][0]-a1==c[2][1]-a2&&c[2][0]-a1==c[2][2]-a3)
              ans = true;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] v = new int[N];
		for (int i = 0; i < N; i++) {
			v[i] = sc.nextInt();
		}
		Arrays.sort(v);
		double ans = v[0];
		for (int i = 1; i < N; i++) {
			ans = (ans + v[i]) / 2;
		}
		System.out.println(ans);
	}
	
	static int gcd(int a, int b) {
		if (a < b) return gcd(b, a);
		if (b == 0) {
			return a;
		} else {
			return gcd(b, a % b);
		}
	}

}

class FastScanner {
    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;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        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() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
int n,m;
const int maxn = 102000;
const int p = 1000000007;
namespace get_apart {
	int q[maxn],cnt;
	void work (int x) {
		for (int i = 2;i <= sqrt (x);i ++)
			if (x % i == 0) {
				cnt ++;
				while (x % i == 0) {
					q[cnt] ++;
					x /= i;
				}
			}
		if (x != 1)
			q[++ cnt] = 1;
	}
} using namespace get_apart;
long long C[maxn][50];
void pre_work () {
	C[0][0] = C[1][0] = C[1][1] = 1;
	for (int i = 0;i <= n;i ++) {
		C[i][0] = 1 ;
		if (i <= 40) C[i][i] = 1;
	}
	for (int i = 2;i <= n + 40;i ++)
		for (int j = 1;j <= min(i + 1,40);j ++) {
			C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
			C[i][j] %= p;
		}
}
int main () {
	n = read(); m = read();
	get_apart :: work (m);
	pre_work ();
	long long ans = 1;
	for (int i = 1;i <= cnt;i ++) {
		ans *= C[q[i] + n - 1][q[i]];
		ans %= p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//---------------------------------------------------------------------------//
ll n,sum=0,b;
ll a[51];
ll dp[100][100][5000];
int main(){
        cin>>n>>b;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }
        dp[0][0][0]=1;
        for(int i=0; i<n; i++) {
                for(int j=0; j<n; j++) {
                        for(int s=0; s<5000; s++) {
                                if(dp[i][j][s]==0) continue;
                                dp[i+1][j][s]+=dp[i][j][s];
                                dp[i+1][j+1][s+a[i]]+=dp[i][j][s];
                        }
                }
        }
        for(int i=1; i<=n; i++) {
                sum+=dp[n][i][i*b];
        }
        cout<<sum<<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
 int main(void){
   int A,B,C,D,L,R;
   cin >> A >> B >> C >> D;
   L=A+B;
   R=C+D;
   
   if(L>R){
     cout << "Left" << endl;
   }
   else if (R>L){
     cout << "Right" << endl;
   }
   else {
     cout << "Balanced" << endl;
   }
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int t1,t2,a1,a2,b1,b2;
  cin>>t1>>t2>>a1>>a2>>b1>>b2;
  Int x=t1*a1+t2*a2;
  Int y=t1*b1+t2*b2;

  if(x==y) drop("infinity");

  if(x<y){
    swap(a1,b1);
    swap(a2,b2);
    swap(x,y);
  }

  assert(x>y);

  auto check=
    [&](Int L){
      return L*__int128(x-y)+t1*a1<=t1*b1;
    };

  auto check2=
    [&](Int L){
      return L*__int128(x-y)+t1*a1==t1*b1;
    };

  if(!check(0)) drop(0);

  Int L=0,R=1e18;
  while(L+1<R){
    Int M=(L+R)>>1;
    if(check(M)) L=M;
    else R=M;
  }
  cout<<L*2+!check2(L)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int N, K; cin >> N >> K;

    cout << (ll) (K * pow((K - 1), N - 1)) << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    static boolean solve(int i, int m, int n, int A[]) {
        if(m == 0) return true;
        if(i >= n) return false;
        return solve(i + 1, m, n, A) || solve(i + 1, m - A[i], n, A);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A,S;
        A = new int[n]; 
        for(int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
        int j = sc.nextInt();
        S = new int[j];
        for(int i = 0; i < j; i++) {
            S[i] = sc.nextInt();
        }
        for(int i = 0; i < j; i++) {
            if(solve(0, S[i], n, A)) System.out.println("yes");
            else System.out.println("no");
        }
        sc.close();
    }
}


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

char gg[10];
bool check(int a){
	sprintf(gg, "%d", a);
	return gg[0]==gg[4] && gg[1]==gg[3];
}

int main(){
	int a,b,r=0;
	scanf("%d %d", &a, &b);
	a--;
	while(a++ < b){
		r += check(a);
	}
	printf("%d\n", r);
}

Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name=br.readLine();
		int num;
		int compare;

		while(true){

			try{
				StringTokenizer st=new StringTokenizer(name," ");
				int a=Integer.parseInt(st.nextToken());
				int b=Integer.parseInt(st.nextToken());
				compare=a*b;
				num=a+b+a+b;
				System.out.println(compare+" "+num);
				name=br.readLine();
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 23948
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n;
  map<int, int> d;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    d[x]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    if (d[x] <= 0) {
      cout << "NO" << endl;
      return 0;
    } else {
      d[x]--;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 11648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<list>

int main () {
    std::string s;
    int q;
    std::cin >> s >> q;

    std::vector<std::pair<std::pair<int, int>, char>> w(q);
    std::list<char> sl;

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

    for (int i = 0; i < q; i++)
     {
         std::cin >> w[i].first.first;

            if (w[i].first.first == 2)
            {
                std::cin >> w[i].first.second >> w[i].second;
            }
     }

     int cnt = 0;
     for (int i = 0; i < q; i++)
     {
         if (w[i].first.first == 2)
         {
             if(cnt % 2 == 0) {
             if (w[i].first.second == 1)
             {
                 sl.push_front(w[i].second);
             }
             else
             {
                 sl.push_back(w[i].second);
             }
             } else {
                 if (w[i].first.second == 2)
                 {
                     sl.push_front(w[i].second);
                 }
                 else
                 {
                     sl.push_back(w[i].second);
                 }
             }
         }
         else
         {
             cnt++;
         }
     }

    std::string ans = "";
    if(cnt%2) {
        for (auto itr = sl.rbegin(); itr != sl.rend(); itr++) {
            ans += *itr;
        }
    } else {
        for (auto itr = sl.begin(); itr != sl.end(); itr++)
        {
            ans += *itr;
        }
    }
    

    std::cout << ans << std::endl;

}

Measured memory_bytes: 12804
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
using namespace std;

char t;
string a, b, c;

int main()
{
    cin >> a >> b >> c;
    t = *a.begin();
    a.erase(0,1);
    while (1) {
        if (t == 'a') {
            if (a.size() == 0) {
                pf("A\n");
                return 0;
            }
            t = *a.begin();
            a.erase(0, 1);
        }
        else if (t == 'b') {
            if (b.size() == 0) {
                pf("B\n");
                return 0;
            }
            t = *b.begin();
            b.erase(0, 1);
        }
        else if (t == 'c') {
            if (c.size() == 0) {
                pf("C\n");
                return 0;
            }
            t = *c.begin();
            c.erase(0, 1);
        }
    }
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//


signed main(){
    string s;
    cin>>s;
    if(s.size()>=6){
        if(s[2]==s[3]&&s[4]==s[5]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import heapq

n=int(input())
l=list(map(int,input().split()))
q=[10**9]

for item in l:
    heapq.heappush(q,10**9-item)

lmax=10**9-heapq.heappop(q)

sa=10**10
while True:
    a=10**9-heapq.heappop(q)
    if sa>abs(a+(-lmax//2)):
        sa=abs(a+(-lmax//2))
        ans2=a
        continue
    break

print(lmax,ans2)
    


Measured memory_bytes: 14424
#include "stdio.h"
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

int mySize = 1;
vector<ll> val;
vector<ll> lazy;

void lazyPropagate(int p) {
    val[p] += lazy[p];
    if (p < mySize - 1) {
        lazy[(p * 2) + 1] += lazy[p];
        lazy[(p * 2) + 2] += lazy[p];
    }
    lazy[p] = 0;
}

void add(int l1, int r1, int l2, int r2, int k, int x) {
    if (r1 <= l2 || r2 <= l1) {
        lazyPropagate(k);
        return;
    }
    if (l1 <= l2 && r2 <= r1) {
        lazy[k] += x;
        lazyPropagate(k);
        return;
    }
    int mid = (l2 + r2) / 2;
    lazyPropagate(k);
    add(l1, r1, l2, mid, (k * 2) + 1, x);
    add(l1, r1, mid, r2, (k * 2) + 2, x);
    val[k] = min(val[(k * 2) + 1],val[(k * 2) + 2]);
}

void add(int l1, int r1, int x) {
    add(l1, r1, 0, mySize, 0, x);
}

ll getMin(int l1, int r1, int l2, int r2, int k) {
    if (r1 <= l2 || r2 <= l1) {
        return __LONG_LONG_MAX__;
    }
    if (l1 <= l2 && r2 <= r1) {
        lazyPropagate(k);
        return val[k];
    }
    int mid = (l2 + r2) / 2;
    lazyPropagate(k);
    ll sl = getMin(l1, r1, l2, mid, (k * 2) + 1);
    ll sr = getMin(l1, r1, mid, r2, (k * 2) + 2);
    return min(sl,sr);
}

ll getMin(int l1, int r1) {
    return getMin(l1, r1, 0, mySize, 0);
}

int main(){
    int n,q,command,l,r,value;
    scanf("%d %d",&n,&q);
    for(;mySize < n;mySize <<= 1);
    val = vector<ll>(mySize * 2,0);
    lazy = vector<ll>(mySize * 2,0);
    
    for(int i = 0;i < q;++i){
        scanf("%d" "%d" "%d",&command,&l,&r);
        // add(s,t,x): as,as+1,...,at にxを加算する。
        if(command == 0){
            scanf("%d",&value);
            add(l,r + 1,value);
            // find(s,t) : report the minimum value in as,as+1,...,at.
        }else{
            printf("%lld\n",getMin(l,r + 1));
        }
    }
}



Measured memory_bytes: 8524
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
// clang-format on

int main() {
    llint n, k;
    cin >> n >> k;
    vector<vector<llint>> v(2, vector<llint>(n + 2, 0));
    REP(i, n) {
        cin >> v[0][i];
    }
    bool flag;
    REP(i, k + 1) {
        flag = true;
        v[(i + 1) % 2] = vector<llint>(n + 2, 0);
        //    cout << "UNKO" << endl;
        REP(j, n) {
            if(v[i % 2][j] < n) {
                flag = false;
            }
            v[(i + 1) % 2][max(j - v[i % 2][j], 0ll)]++;
            v[(i + 1) % 2][min(j + v[i % 2][j] + 1, n + 1)]--;
        }
        REP(j, n) {
            v[(i + 1) % 2][j + 1] += v[(i + 1) % 2][j];
        }
        if(flag) {
            break;
        }
    }
    REP(i, n - 1) {
        cout << v[(k) % 2][i] << " ";
    }
    cout << v[(k) % 2][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 7644
#include <stdio.h>

long gcd(long a, long b) {
	if (a == b)
		return a;
	else if (a > b)
		return (gcd(a - b, b));
	else
		return (gcd(a, b - a));
}

int main(void){
	long a, b, lcm;
	scanf("%ld%ld", &a, &b);

	lcm = a * b / gcd(a, b);

	printf("%ld", lcm);
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

bool possible(ll A, ll B, ll K) {
  if (K <= 1000) {
    vector<ll> a, b;
    for (int i = 1; (int)a.size() < K; i++) {
      if (i != A) a.push_back(i);
    }
    for (int i = 1; (int)b.size() < K; i++) {
      if (i != B) b.push_back(i);
    }
    REP(i, K) {
      if (a[i] * b[K-i-1] >= A*B) return false;
    }
    return true;
  } else {
    for (ll i = K/2 - 400; i <= K/2 + 400; i++) {
      ll Ai = i + (i >= A ? 1 : 0);
      ll Bi = K + 1 - i + 1;
      if (Bi <= B) Bi--;
      if (Ai*Bi >= A*B) return false;
    }
    return true;
  }
}

ll solve(ll A, ll B) {
  ll lo = 0;
  ll hi = A + B + 10;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (possible(A, B, mid)) lo = mid; else hi = mid;
  }
  return lo;
}


int main2() {
  int Q = nextInt();
  REP(_, Q) {
    ll A = nextInt();
    ll B = nextInt();
    if (A == B) {
      cout << 2*A - 2 << endl;
    } else {
      if (A > B) swap(A, B);
      cout << solve(A, B) << endl;
    }
  }
  return 0;
}

int main() {
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
def p(x):
  return bin(x).count('1')

def f(x):
  if x == 0:
    return 0
  return f(x%p(x)) + 1

N = int(input())
X = input()
cnt = X.count('1')
x = int(X,2)
a = x % (cnt + 1)
if cnt != 1:
  b = x % (cnt - 1)

for i in range(N):
  if X[i] == '0':
    k = (a + pow(2,N-i-1,cnt+1))%(cnt+1)
  else:
    if cnt == 1:
      print(0)
      continue
    k = (b-pow(2,N-i-1,cnt-1))%(cnt-1)
  print(f(k)+1)

Measured memory_bytes: 9528