akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    int n,h,w,a,b,ans=0,k;
    cin >> n >> h >> w;
    rep(i,n){
        cin >> a >> b;
        if(a>=h&&b>=w) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, m, p = gi()
if p - n - m < 0:
	print("No")
	exit();
if 4 * (n * m) < (p - n - m) ** 2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int m,k;

int main()
{
    cin>>m>>k;
    if (m==0)
    {
        if (k==0)
            cout<<0<<' '<<0<<endl;
        else
            cout<<-1<<endl;
    }
    if (m==1)
    {
        if (k==0)
            cout<<0<<' '<<1<<' '<<1<<' '<<0<<endl;
        else
            cout<<-1<<endl;
    }
    if (m>1)
    {
        if (k>=(1<<m))
            cout<<-1<<endl;
        else
        {
            for (int i=(1<<m)-1; i>=0; --i)
                if (i!=k)
                    cout<<i<<' ';
            cout<<k<<' ';
            for (int i=0; i<=(1<<m)-1; ++i)
                if (i!=k)
                    cout<<i<<' ';
            cout<<k<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <math.h> 

using namespace std;



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

	long long n, k, i, j, ans, maxx, x, ct, s;
	cin >> n >> k;
	vector<long long> a(n), v;
	for (i = 0; i < n; i++) cin >> a[i];

	ans = 1LL << 61;

	for (i = 0; i < (1 << n); i++) {
		ct = 0;
		maxx = 0;
		s = 0;

		for (j = 0; j < n; j++) {
			if (a[j] > maxx) {
				maxx = a[j];
				ct++;
			}
			else if (i & (1 << j)) {
				x = maxx + 1 - a[j];
				s += x;
				ct++;
				maxx++;
			}
		}

		if (ct >= k) ans = min(ans, s);
	}

	cout << ans << "\n";


	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long UL;
const int Mod=1e9+7;
const int N=1e5+5;
const int INF=0x3f3f3f3f;
int V[N],A[N][1000];
void DFS(int i,int id){
	V[i]=id;
	for(int j=1;j<=A[i][0];++j){
		if(!V[A[i][j]]) DFS(A[i][j],id);
	}
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		A[a][++A[a][0]]=b;
		A[b][++A[b][0]]=a;
	}
	
	//Solve
	int id=0;
	for(int i=1;i<=n;++i){
		if(!V[i]) DFS(i,++id);
	}
	//
	cout<<id-1<<endl;
    return 0;
}


Measured memory_bytes: 344996
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if(x%y == 0) cout << -1 << endl;
    else cout << x << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, K;
  cin>>H>>W>>K;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  int ans[H][W];
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      ans[i][j] = -1;
    }
  }
  int num = 0;
  bool ari;
  for(int i=0;i<H;++i) {
    ari = false;
    for(int j=0;j<W;++j) {
      if(S[i][j]=='#') {
        num++;
        if(!ari) {
          for(int k=j-1;k>=0;--k) {
            ans[i][k] = num;
          }
        }
        ari = true;
      }
      if(ari) ans[i][j] = num;
    }
  }
  for(int j=0;j<W;++j) {
    for(int i=0;i<H;++i) {
      if(ans[i][j]==-1 && i>0) ans[i][j] = ans[i-1][j];
    }
  }
  for(int j=0;j<W;++j) {
    for(int i=H-1;i>=0;--i) {
      if(ans[i][j]==-1 && i<H-1) ans[i][j] = ans[i+1][j];
    }
  }
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}



Measured memory_bytes: 4136
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353
;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    fastio;
    ll a,b;
    cin>>a>>b;
    cout<<max(a*b,max(a-b,a+b));
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        char[] ch = sc.next().toCharArray();
        boolean flag = false;
        int sum=0;
        for (int i = ch.length - 1; i >= 1; i--) {
            if(ch[i]!='9'){
                flag=true;
            }
            sum+=9;
        }
        sum+=(ch[0]-'0');
        if(flag){
            sum--;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {n:usize,s:[String;n]}
    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;
    for c in s {
        match c.as_str() {
            "AC" => ac += 1,
            "WA" => wa += 1,
            "TLE" => tle += 1,
            _ => re += 1,
        }
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}


Measured memory_bytes: 7840
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(b<a){
		d=a;
		a=b;
		b=d;
	}
	else{
	}
	if(c<b){
		d=b;
		b=c;
		c=d;
	}
	else{
	}
	if(b<a){
		d=a;
		a=b;
		b=d;
	}
	else{
	}
	printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 2064
s = gets.chomp
cnt = 0
loop do
  s_r = s.reverse
  if s_r == s then
    puts cnt
    break
  end
  s.length.times do |i|
    if s[i] != s_r[i] then
      s[i] = s_r[i]
      cnt += 1
      break
    end
  end
end

Measured memory_bytes: 1788
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if (a%3==0||b%3==0||(a+b)%3==0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  char c;
  cin >> c;

  char ans = c + 1;

  cout << ans << endl;

  return 0;
}

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

int main(void){
  int x, a, b;
  scanf("%d", &x);
  scanf("%d", &a);
  scanf("%d", &b);

  if (x>=b-a) {
    if (b-a>0) {
      printf("safe");
    }else{
      printf("delicious");
    }
  }else if (x < b-a) {
    printf("dangerous");
  }

  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	ll first,second,third;
	Data()=default;
	Data(ll f,ll s,ll t):first(f),second(s),third(t){}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in(),K=in();
	ll sum = 0;
	for(ll b=1;b<=N;b++){
		ll p = N/b,q = N%b;
		sum += p*(max(0LL,b-K));
		sum += max(0LL,q-K+1LL);
	}
	if(!K) sum -= N;
	out(sum);
	
	return 0;
}


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

int n, k;
ll T[MAX];

int check(ll P) {
  int i = 0;
  for (int j = 0; j < k; j++) {
    ll s = 0;
    while (s + T[i] <= P) {
      s += T[i];
      i++;
      if (i == n) return n;
    }
  }
  return i;
}

int solve() {
  ll left = 0;
  ll right = 100000 * 10000;
  ll mid;
  while (right - left > 1) {
    mid = (left + right) / 2;
    int v = check(mid);
    if (v >= n)
      right = mid;
    else
      left = mid;
  }

  return right;
}

main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> T[i];
  ll ans = solve();
  cout << ans << endl;
}


Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
using namespace std;
#define ll long long


int main() {
	int n;
	cin >> n;
	pair<int, int> a[200010];
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		if (a[0].second == i) cout << a[1].first << endl;
		else cout << a[0].first << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
# include "iostream"
# include "cstdio" 

using namespace std;

int
    d,
    n;
    
long long
    mul=1ll; 

int main(){
    scanf("%d%d",&d,&n);     
    register int i;
    for(i=1;i<=d;i++){    
        mul*=100; 
    }
    printf("%lld",(n+(n==100))*mul);   
    return 0; 
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]


def enclose_field(field, outline="#"):
    """
    迷路等の外周をoutlineで埋めることで、IndexErrorを回避できます。
    [0, 0] → [1, 1]、[H-1, W-1] → [H, W]となります。
    """
    for i in range(len(field)):
        field[i] = [outline] + field[i] + [outline]
    field.append([outline] * (len(field[0])))
    field.insert(0, [outline] * (len(field[0])))
    return field


A = enclose_field(A, outline=".")
i = j = 1
while True:
    if A[i+1][j] == "#":
        A[i][j] = "."
        i += 1
        continue

    if A[i][j+1] == "#":
        A[i][j] = "."
        j += 1
        continue

    if i==H and j == W:
        A[i][j] = "."
        break

    print("Impossible")
    exit()

for a in A:
    if "#" in a:
        print("Impossible")
        break
else:
    print("Possible")

Measured memory_bytes: 3188
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int               long long
#define ff                first
#define ss                second
#define md                1000000007
#define md1               998244353
#define inf               1000000000000000
#define minf              -1000000000000000
#define pb                push_back
#define ppb               pop_back
#define in                insert
#define mkp               make_pair
#define mpll              map<ll,ll>
#define len(p)            (ll)p.size()
#define pll               pair<ll,ll>
#define all(v)            v.begin(),v.end()
#define mem(a,t)          memset(a,t,sizeof(a))
#define endl              "\n"
#define ar                array
#define vl                vector<ll>
#define vvl               vector<vl>
#define lb                lower_bound
#define ub                upper_bound
#define be()              begin()
#define en()              end()
#define vpll              vector<pair<ll,ll>>
#define f(i,yha,wha)      for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha)     for(ll i=wha;i>=yha;i--)
#define f0(n)             for(ll i=0;i<n;i++)
#define f1(n)             for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve()
{
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;

}

int32_t main()
{
    flash();
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3668
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n,c,k] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getContents
    print $ solve c k $ U.toList xs

solve :: Int -> Int -> [Int] -> Int
solve c k xs = go 0 $ sort xs
  where
    go !acc (x:xs) = go (acc+1) $ drop c (x:ys) ++ zs
      where
        xk = x + k
        (ys,zs) = span (<=xk) xs
    go acc _ = acc


Measured memory_bytes: 17804
extern crate proconio;
use proconio::input;

fn main() {
    input!{
        n: usize,
        p: [i32; n],
        q: [i32; n],
    };

    let ans = Calc::new(n);
    println!("{}", i32::abs(ans.solve(&p) - ans.solve(&q)));
  
}

struct Calc{
    n: usize,
    fact: Vec<i32>,
}

impl Calc{
    fn new(n: usize) -> Calc{
        let mut fact = Vec::new();
        let mut num: i32 = 1;
        for i in 0..n {
            fact.push(num);
            num *= (i+1) as i32;
        }
        Calc{ n, fact }
    }

    fn solve(&self, p: &[i32]) -> i32 {
        let n = self.n;
        let mut ans_p = 0;
        for i in 0..n-1 {
            let mut tp = 0;
            for j in i..n {
                if p[i] > p[j] {
                    tp += 1;
                }
            }
            ans_p += tp*self.fact[n-i-1];
        }
        ans_p
    }
}

Measured memory_bytes: 2156
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
  int N,T,A;
  cin >> N >> T >> A;
  double min_diff = 1000;
  int pos = -1;
  for( int i=0;i<N;i++ )
    {
      int h;
      cin >> h;
      if( min_diff > fabs(T-h*0.006-A) )
	{
	  pos = i;
	  min_diff = fabs(T-h*0.006-A);
	}
    }
  cout << pos+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll power(ll a,ll b,ll p)
{
	ll res=1;
	a%=p;
	while(b>0)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return(res);
}*/
/*void dfs(ll x)
{
	vis[x]=true;
	for(ll i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==false)
		dfs(v[x][i]);
	}
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		if(arr[mid]==s)
		return(mid);
		if(arr[mid]<s)
		l=mid+1;
		else
		r=mid-1;
	}
	return(-1);
}*/
 
void solve()
{
	ll a,b;
	cin>>a>>b;
	string s1,s2;
	string s3,s4;
	s3=to_string(a);
	s4=to_string(b);
	for(ll i=0;i<a;i++)
	s1+=s4;
	for(ll i=0;i<b;i++)
	s2+=s3;
	if(s1>s2)
	cout<<s2<<endl;
	else
	cout<<s1<<endl;
}
 
int main()
{
	IOS
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
    return(0);
}


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

#define MAXN 1005

vector<int> g[MAXN];
vector<vector<int>> cycles;
int par[MAXN];


void dfs(int u) {
	//$ cerr << u << endl;
	for(int v : g[u]) {
		if(par[v] == -1) {
			par[v] = u;
			dfs(v);
		} else {
			int cur = u;
			vector<int> cyc = {u};
			while(cur != v && par[cur] != -2) {
				cyc.push_back(par[cur]);
				cur = par[cur];
			}
			
			if(cyc.back() == v)
				cycles.push_back(cyc);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
	}
	
	
	for(int i = 0; i < n; i++) {
		memset(par, -1, sizeof par);
		par[i] = -2;
		dfs(i);
	}
	
	
	for(vector<int> v : cycles) {
		set<int> s(v.begin(), v.end());
		bool ok = true;
		for(int i = 0; i < (int) v.size(); i++) {
			int cnt = 0;
			for(int nei : g[v[i]]) {
				if(s.count(nei)) {
					cnt++;
				}
			}
			if(cnt > 1) {
				ok = false;
			}
			//$ cerr << v[i] << " : nei's = " << cnt << endl;
		}
		
		//$ cerr << endl;
		
		if(ok) {
			cout << v.size() << '\n';
			for(int i = 0; i < (int) v.size(); i++) {
				cout << v[i]+1 << '\n';
			}
			return 0;
		}
	}
	
	cout << -1 << endl;
}


Measured memory_bytes: 113580
n, m = map(int, input().split())
a = []
b = []
r = False
for i in range(n):
    s = input()
    a.append(s)
for i in range(m):
    s = input()
    b.append(s)

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            test = True
            if (b[k] != a[i+k][j:m+j]):
                test = False
                break
        if(test):
            r = True

if(r):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

#define F           first
#define S           second
#define pb          push_back
#define P           push


int main() {
    #ifdef LU_Serious
       // freopen("in.txt", "r", stdin);
    #endif /// LU_Serious

    int m, n, i;
    string s[105];
    while(cin >> n >> m) {
        for(i = 0; i < n; i++) {
            cin >> s[i];
        }
        for(i = 0; i < n; i++) cout << s[i] << endl << s[i] << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n,m;
ll h[111];
ll dpa[1000010],dpb[1000010];
ll na,nb;
ll ma[111],mb[111],da[111],db[111];

int main(){
	//cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    ll maxh=0;
    rep(i,n){
      cin>>h[i];
      maxch(maxh,h[i]);
    }
    cin>>m;
    na=0; nb=0;
    rep(i,m){
      string name,target;
      ll mp,dmg;
      cin>>name>>mp>>target>>dmg;
      if(target=="All"){
        ma[na]=mp; da[na]=dmg; na++;
      }else{
        mb[nb]=mp; db[nb]=dmg; nb++;
      }
    }
    rep(i,1000010)dpa[i]=dpb[i]=INF;
    dpa[0]=dpb[0]=0;
    rep(j,1000001)rep(i,na){
      if(dpa[j]==INF)continue;
      if(j+da[i]<=1000000)minch(dpa[j+da[i]],dpa[j]+ma[i]);
    }
    for(ll j=1000000;j>=0;j--)minch(dpa[j],dpa[j+1]);
    rep(j,1000001)rep(i,nb){
      if(dpb[j]==INF)continue;
      if(j+db[i]<=1000000)minch(dpb[j+db[i]],dpb[j]+mb[i]);
    }
    for(ll j=1000000;j>=0;j--)minch(dpb[j],dpb[j+1]);
    ll res=INF;
    rep(ah,maxh+1){
      ll sum=0;
      rep(i,n){
        sum+=dpb[max(h[i]-ah,0LL)];
      }
      minch(res,sum+dpa[ah]);
    }
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 18704
#include <cassert>
#include <cstdint>
#include <functional>
#include <vector>

template <typename Monoid> class SegmentTree {
public:
	using value_type = Monoid;
	using reference = value_type &;
	using const_reference = const value_type &;
	using container_type = std::vector<value_type>;
	using size_type = typename container_type::size_type;

private:
	const size_type size_, capacity;
	container_type tree;
	static size_type getsize(const size_type size) noexcept {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		tree[index] = tree[index << 1] + tree[index << 1 | 1];
	}

public:
	SegmentTree(const size_type size)
		: size_(size), capacity(getsize(size_)), tree(capacity << 1) {}
	void update(size_type index,
		const std::function<value_type(const_reference)> &f) {
		assert(index < size());
		index += capacity;
		tree[index] = f(tree[index]);
		while (index >>= 1)
			recalc(index);
	}
	void update(const size_type index, const_reference data) {
		update(index, [&data](const_reference x) { return data; });
	}
	value_type range(size_type begin, size_type end) const {
		assert(begin <= end);
		assert(begin <= size());
		assert(end <= size());
		value_type retL, retR;
		for (begin += capacity, end += capacity; begin < end;
			begin >>= 1, end >>= 1) {
			if (begin & 1)
				retL = retL + tree[begin++];
			if (end & 1)
				retR = tree[end - 1] + retR;
		}
		return retL + retR;
	}
	size_type search(const std::function<bool(const_reference)> &b) const {
		if (!b(tree[1]))
			return size();
		value_type acc;
		size_type i = 1;
		while (i < capacity)
			if (!b(acc + tree[i <<= 1]))
				acc = acc + tree[i++];
		return i - capacity;
	}
	const_reference operator[](const size_type index) const {
		assert(index < size());
		return tree[index + capacity];
	}
	size_type size() const noexcept { return size_; }
	bool empty() const noexcept { return !size_; }
};


#include<algorithm>
template <typename T> struct Mini {
	T a;
	Mini(const T &x = 2147483647) : a(x) {}
	Mini operator+(const Mini &o) const{ return Mini(std::min(a, o.a)); }
};
#include<iostream>
int main() {
	using M = Mini<int>;
	int n, q;
	std::cin >> n >> q;
	SegmentTree<M> T(n);
	while (q--) {
		int c, x, y;
		std::cin >> c >> x >> y;
		if (c)
			std::cout << T.range(x, y + 1).a << std::endl;
		else
			T.update(x, M(y));
	}
	return 0;
}


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

using namespace std;

inline bool cmp(const string &a, const string &b) {
  if(a.size() == b.size()) return a<b;
  return a.size()<b.size();
}

int main() {
  
  int N;
  while(cin >> N && N) {
    vector<string> vec(N);
    for(int i=0; i<N; i++) {
      cin >> vec[i];
    }

    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    N = vec.size();
    
    vector<bool> check(N, true);
    for(int i=0; i<N; i++)
      for(int j=0; j<N; j++) {
        if(i == j) continue;
        if(vec[i].find(vec[j]) != string::npos)
          check[j] = false;
      }
    
    vector<string> strs;
    for(int i=0; i<N; i++) {
      if(check[i]) strs.push_back(vec[i]);
    }
    
    N = strs.size();
    string next[12][12];
    for(int k=0; k<N; k++) {
      for(int l=0; l<N; l++) {
        if(k == l) continue;
        const string &s = strs[k], &t = strs[l];
        int const ssize = s.size(), tsize = t.size();
        next[k][l] = t;
        for(int i=0; i<ssize; i++) {
          bool ok = true;
          for(int j=0; j<ssize-i; j++) {
            if(j == tsize) { ok = false; break; }
            if(s[i+j] != t[j]) { ok = false; break; }
          }
          if(ok) {
            next[k][l] = t.substr(ssize-i);
            break;
          }
        }
      }
    }
    
    string dp[1<<11][11];
    
    for(int i=0; i<N; i++)
      dp[1<<i][i] = strs[i];
    
    for(int S=0; S<(1<<N); S++) {
      for(int i=0; i<N; i++) {
        if(!(S >> i & 1)) continue;
        if(dp[S][i].empty()) continue;
        for(int j=0; j<N; j++) {
          if(S >> j & 1) continue;
          if(dp[S|(1<<j)][j].empty()) dp[S|(1<<j)][j] = dp[S][i] + next[i][j];
          else dp[S|(1<<j)][j] = min(dp[S|(1<<j)][j], dp[S][i] + next[i][j], cmp);
        }
      }
    }
    
    string ans = dp[(1<<N)-1][0];
    for(int i=0; i<N; i++) {
      ans = min(ans, dp[(1<<N)-1][i], cmp);
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> g[100005];
int dp[100005];
void dfs(int u,int p) {
	dp[u]=0;
	int cnt=0;
	for(int i=0;i<(int)g[u].size();i++) {
		int v=g[u][i];
		if (v==p) continue;
		dfs(v,u);
		dp[u]+=dp[v];
		if (!dp[v]) cnt++;
	}
	dp[u]+=max(0,cnt-1);
}
int deg[100005];
int main() {
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	int rt=-1;
	for(int i=0;i<n;i++) if (rt==-1||deg[i]>deg[rt]) rt=i;
	if (deg[rt]<=2) {printf("1\n");return 0;}
	dfs(rt,-1);
	printf("%d\n",dp[rt]);
	return 0;
}

Measured memory_bytes: 12544
#include<stdio.h>
#include <stdlib.h>

int main(void){

	char ch[20],hc[20],i,j;

	gets(ch);

	for(i=0;i<20;i++){
		if(ch[i]=='\0'){
			break;
		}
	}

	for(j=i-1;j>=0;j--){
		printf("%c",ch[j]);
	}

	printf("\n");
	scanf("%d",&i);
	return 0;
}

Measured memory_bytes: 524
#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 3555;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, t, c;
	cin >> n;
	c = 1;
	for(int i = 1; i <= n; i++) {
		cin >> t;
		if(c==t) c++;
	}
	if(c==1) return cout << -1, 0;
	cout << n-c+1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c,k;
	cin>>a>>b>>c;
	k=b/a;
	if(k>=c)
	{
		cout<<c;
	}
	if(k<c)
	{
		cout<<k;
	}
	return 0;
}

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

int H, W;

int main() {
  cin >> H >> W;

  vector<vector<char>> grid(H, vector<char>(W));
  rep(i, H) rep(j, W) cin >> grid[i][j];

  vector<vector<int>> C(H, vector<int>(W, 0));

  rep(i, H) {
    int l = 1, r = 1;
    rep(j, W) {
      if (grid[i][j] == '#') l = 0;
      C[i][j] += l++;
      if (grid[i][W - 1 - j] == '#') r = 0;
      C[i][W - 1 - j] += r++;
    }
  }

  rep(j, W) {
    int u = 1, d = 1;
    rep(i, H) {
      if (grid[i][j] == '#') u = 0;
      C[i][j] += u++;
      if (grid[H - 1 - i][j] == '#') d = 0;
      C[H - 1 - i][j] += d++;
    }
  }

  int ans = 0;
  rep(i, H) rep(j, W) {
    if (grid[i][j] == '#') continue;
    ans = max(ans, C[i][j] - 3);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19968
from collections import Counter
s=input()

# sが26文字未満のとき
a_l=[chr(i) for i in range(ord("a"),ord("z")+1)]
if len(s)<26:print(s+sorted(set(a_l)-set(s))[0]);exit()

# sが26文字のとき
for i,x in enumerate(s[::-1]):
    l=[chr(i) for i in range(ord("a"),ord("z")+1) if ord(x)<i]
    for y in l:
        if Counter(s[:26-i-1]+y).most_common(1)[0][1]==1:
            print(s[:26-i-1]+y)
            exit()

print(-1)

Measured memory_bytes: 9292
/*  ex4_1
    person_A  */
#include<stdio.h>
#include<math.h>

int main(void){
    double treeNum,staffNum;
    //treeNumとstaffNumの値の取得
    scanf("%lf%lf",&treeNum,&staffNum);
    //最低限必要な監視員の数の出力
    //一人が監視できる木の最大本数で割って、余った場合は一人追加
    printf("%d\n",(int)ceil(treeNum/(2*staffNum+1)));
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <algorithm>

int n, k, ans = 0x7fffffff;
int a[100010];

int read() {
    int ret, f = 1;
    char ch;
    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);
    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');
    return ret * f;
}

void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int main() {
    n = read(), k = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    std::sort(a + 1, a + n + 1);
    for(int i = 1; i + k - 1 <= n; ++i) ans = std::min(ans, a[i + k - 1] - a[i]);
    print(ans);
    return 0;
}

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

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

    return 0;
}


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

#define MIN 1000000000

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(M);
    vector<int> d(M);

    int i,j,k;

    for(i=0;i<N;i++)cin >> a.at(i) >> b.at(i);
    for(i=0;i<M;i++)cin >> c.at(i) >> d.at(i);

    float min = (float)MIN;
    float distance;
    int min_index;

    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
            distance = fabs (a.at(i) - c.at(j)) + fabs( b.at(i) - d.at(j) );
            if( distance < min ){
                min = distance;
                min_index = j;
            }
        }
        cout << min_index + 1 << endl;
        min = (float)MIN;
    }

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<string.h>
#include<set>
#include<map>
#define LL long long
#define pr pair<int,int>
#define fr first
#define sc second
//#define mp make_pair
using namespace std;
LL read( ){LL sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) return -sum;return sum;}
void read(int &sum){sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) sum=-sum;}
void read(LL &sum){sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) sum=-sum;}
int main( )
{
  LL n=read( );
  cout<<n*n*n;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
using namespace std;
typedef long long ll;
const int N=100009;
ll ar[102][102];
ll ncr(ll n,ll r)
{
    if(r==1)return n;
    if(n==r) return 1;
    if(ar[n][r]!=0)
    {
        return ar[n][r];
    }
    ar[n][r]=ncr(n-1,r)+ncr(n-1,r-1);
    return ar[n][r];
}
int main()
{
    ll n,m,sum=0;
    cin>>n>>m;
    if(n>1) sum+=ncr(n,2);
    if(m>1) sum+=ncr(m,2);
    cout<<sum<<endl;
    return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,k;
	cin>>n>>k;
	if(n*2<k){
		cout<<0<<endl;
		return 0;
	}
	ll ans = pow(n/k,3);
	if(k%2==0){
		ans += pow(n/k+(n%k>=k/2), 3);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn 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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

set<ll> s;

void rec(ll n){
    s.insert(n);
    n*=10;
    if(n<1000000000){
        rec(n+3);
        rec(n+5);
        rec(n+7);
    }
}

bool exs(int n){
    int san=0;
    int go=0;
    int nana=0;
    while(n>0){
        int t=n%10;
        n/=10;
        if(t==3)san++;
        else if(t==5)go++;
        else if(t==7)nana++;
    }
    if(go>0&&san>0&&nana>0)return 1;
    else return 0;
}

int main(void) {

    int n;
    cin>>n;
    // vi v{3,5,7};
        
    // do{
    //     // rec(v[0]*100+v[1]*10+v[2]);
    // }while(next_permutation(all(v)));
    rec(3);
    rec(5);
    rec(7);
    int ans=0;
    for(auto it=s.begin();it!=s.end();it++){
        if(*it<=n){
            if(exs(*it))ans++;
        }
    }
    fin(ans);
}


Measured memory_bytes: 1664
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, t = ril()
ls = rils(n)

dp = [[0] * t for _ in range(n + 1)]
for i in range(n + 1):
    for t0 in range(t):
        a, b = ls[i - 1]
        if i == 0 or t0 == 0:
            continue
        elif a <= t0:
            dp[i][t0] = max(dp[i - 1][t0], dp[i - 1][t0 - a] + b)
        else:
            dp[i][t0] = dp[i - 1][t0]

res = set()
val = dp[n][t - 1]
t0 = t - 1
for i in reversed(range(n)):
    a, b = ls[i]
    if val <= 0:
        break
    if val == dp[i][t0]:
        continue
    else:
        res.add(i)
        val -= b
        t0 -= a

remaining = [v for i, (_, v) in enumerate(ls) if i not in res]
if len(remaining) > 0:
    print(dp[n][t - 1] + max(remaining))
else:
    print(dp[n][t - 1])

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

int main() {
 int A,B;
  cin>>A>>B;
  int j=0;
  for(int i=A;i<=B;i++){
    if(i%10==i/10000&&i%10000/1000==i%100/10){
      j++;
    }
  }
  cout<<j<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

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

const int MAXN = 3030;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}

int n, t, h;
double p[MAXN];
unordered_map<int, double> dp[MAXN];

double solve(int i, int h) {
	if(i == n) {
		if(h > n - h)
			return 1;
		return 0;
	}
	if(dp[i].count(h)) return dp[i][h];
	return dp[i][h] = p[i] * solve(i + 1, h + 1) + (1 - p[i]) * solve(i + 1, h);
}

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

	cout << setprecision(10) << fixed;

	cin >> n;

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

	cout << solve(0, 0) << endl;

	return 0;
}



Measured memory_bytes: 194176
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long;
using P = pair<int, int>;

// int A, F, H, I, J, K, L, M, N, S, T, U;
lint F, H, I, J, K, L, M, N, S, T, U;
// string S;
lint ans = 1;

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

	cin >> H;

	lint log = 0;
	while (H != 1) {
		H /= 2;
		log++;
	}

	rep (i, log) {
		ans += pow(2, i + 1);
	}

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

Measured memory_bytes: 256
#include<cstdio>

int main()
{
	int h, w;
	char mine[55][55];
	
	scanf("%d %d", &h, &w);
	for(int i = 0; i < h; i++)
		
			scanf("%s", mine[i]);
	
	
	int dir_h[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
	int dir_w[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
	char num[55][55];
	
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			num[i][j] = '0';
		
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			if(mine[i][j] == '#')
				num[i][j] = '#';
			
			else
				for(int k = 0; k < 8; k++)
					if(mine[i + dir_h[k]][j + dir_w[k]] == '#')
						num[i][j]++;
			
	
	
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j ++){
			printf("%c", num[i][j]);
			if(j == w - 1)
				printf("\n");
			}
}
			


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int a,b,c,j,i;
	while(scanf("%d %d",&a,&b)!=EOF){
		c=a+b;
		j=0;
		while(c!=0){
			c=c/10;
			j++;
		}
		printf("%d\n",j);
	}
	return 0;
}


Measured memory_bytes: 1980
import sys
from itertools import accumulate


def solve(n, x, m):
    eee = [d % m for d in ddd]
    acc = list(accumulate(eee))
    zero = [int(e == 0) for e in eee]
    zero_acc = list(accumulate(zero))
    loop, rem = divmod(n - 1, k)
    tot = x % m + acc[-1] * loop
    tot_zero = zero_acc[-1] * loop
    if rem > 0:
        tot += acc[rem - 1]
        tot_zero += zero_acc[rem - 1]
    dame = tot // m
    # print(n, x, m)
    # print(eee)
    # print(acc)
    # print(loop, rem)
    # print(tot, dame)
    return n - 1 - dame - tot_zero


k, q = map(int, input().split())
ddd = list(map(int, input().split()))
buf = []
for line in sys.stdin:
    n, x, m = map(int, line.split())
    buf.append(solve(n, x, m))
print('\n'.join(map(str, buf)))


Measured memory_bytes: 119132
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 0 ;
	ll mn = 1 ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		if(a==mn){
			mn++ ;
		}else{
			ans += (a-1)/mn ;
			mn = max(mn,2ll) ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int maxn = 404 * 404;
int u[maxn], s0[maxn], s1[maxn];
void init(){
  iota(u, u + maxn, 0);
}
int find(int x){
  if(x == u[x]) return x;
  return u[x] = find(u[x]);
}
int join(int x, int y){
  x = find(x);
  y = find(y);
  if(x ^ y){
    u[x] = y;
    s0[y] += s0[x];
    s1[y] += s1[x];
  	return 1;
  }
  return 0;
}
int main(){
  int n, w; cin >> n >> w;
  vector<string> grid(n);
  for(auto & i : grid) cin >> i;
  for(int i = 0; i < n; i++) for(int j = 0; j < w; j++) {
    if(grid[i][j] == '#') s0[i*w+j] = 1;
    else s1[i*w+j] = 1;
  }
  init();
  for(int i = 0; i < n; i++) for(int j = 0; j < w; j++) {
    for(int di: {-1, 0, 1}){
      for(int dj: {-1, 0, 1}){
        if(abs(di) + abs(dj) == 1){
          int ni = di + i, nj = dj + j;
          if(ni >= 0 && ni < n && nj >= 0 && nj < w){
            if(grid[i][j] != grid[ni][nj]){
              join(i*w+j,ni*w+nj);
            }
          }
        }
      }
    }
  }
  long long ans = 0;
  for(int i = 0; i < n * w; i++) if(find(i) == i){
    ans += 1ll * s0[i] * s1[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int A,B,C,D,E,K;
  
  cin>>A>>B>>C>>D>>E>>K;
  
  int lg=E-A;
  if (lg<=K){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(20);
    }
}INIT;

string s;
map<char, int> cnt;

int main(){
    cin >> s;
    REP(i, 4)cnt[s[i]]++;
    for(auto it = cnt.begin();it != cnt.end();it++){
        if(it->second != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    bool a['z'-'a'+1];
    for (int i = 0; i < 'z'-'a' + 1; i++)
        a[i] = false;

    for (int i = 0; i < s.size(); i++)
        a[(char)s[i]-'a'] = true;

    for (int i = 0; i < 'z'-'a' + 1; i++) {
        if (!a[i]) {
            cout << (char)('a' + i) << endl;
            goto end;
        }
    }

    cout << "None" << endl;

end:
    return 0;
}

Measured memory_bytes: 512
N=int(input())
T,A=map(int,input().split())
H=input().split()
for i in range(len(H)):
    H[i]=int(H[i])
minimum=0
for i in range(len(H)):
    H[i]=abs(T-(H[i]*0.006)-A)
    if(H[minimum]>H[i]):
        minimum=i
print(minimum+1)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;
const int MAX = 100001;

int main()
{
	bool allSame = true;
	vector<ll> odd(MAX), even(MAX);
	for (ll i = 0; i < MAX; i++) {
		odd[i] = 0;
		even[i] = 0;
	}
	ll n;
	cin >> n;
	int v,v1,v2;
	for (ll i = 0; i < n; i++) {
		cin >> v;
		if (i == 0) v1 = v;
		if (i == 1) v2 = v;
		if (i % 2 == 0) {
			even[v]++;
		}
		else {
			odd[v]++;
		}
	}
	ll oddMax = *max_element(odd.begin(), odd.end());
	ll evenMax = *max_element(even.begin(), even.end());
	if ((oddMax + evenMax) == n && v1 == v2) {
		cout << n - oddMax << endl;
		return 0;
	}
	std::vector<ll>::iterator oddMaxIt = std::max_element(odd.begin(), odd.end());
	std::vector<ll>::iterator evenMaxIt = std::max_element(even.begin(), even.end());
	size_t oddMaxIn = std::distance(odd.begin(), oddMaxIt);
	size_t evenMaxIn = std::distance(even.begin(), evenMaxIt);
	if (oddMaxIn == evenMaxIn) {
		odd.erase(odd.begin() + oddMaxIn);
		even.erase(even.begin() + evenMaxIn);
		ll oddSecondMax = *max_element(odd.begin(), odd.end());
		ll evenSecondMax = *max_element(even.begin(), even.end());
		if (oddSecondMax > evenSecondMax) {
			cout << n - evenMax - oddSecondMax << endl;
		}
		else {
			cout << n - evenSecondMax - oddMax << endl;
		}
		return 0;
	}
	cout << n - oddMax - evenMax << endl;
	return 0;
}

Measured memory_bytes: 1792