akhauriyash/Code-Regression huggingface dataset:
n, a, b, c, d = map(int, input().split())
s = input()

if c < d:
    for i in range(b-1, d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, c-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    for bi in range(b-1,d):
        if s[bi-1] == s[bi] == s[bi+1] == '.':
            print('Yes')
            exit()

    print('No')

else:
    print('No')

Measured memory_bytes: 3512
N, A, B = map(int, input().split())
P = [int(a) - 1 for a in input().split()]
X = [0] * N
for i in range(N):
    pre = X
    X = [0] * N
    mi = pre[0]
    for j in range(N):
        mi = min(mi, pre[j])
        X[j] = mi + (A if j < P[i] else B if j > P[i] else 0)
print(min(X))

Measured memory_bytes: 50652
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
 
long long int gcd(long long int a, long long int b)
{
	if (a < b){
		long long int tmp = a;
		a = b;
		b = tmp;
	}
 
	if (b == 0) return a;
 
	long long int c = a % b;
	while (c != 0){
		a = b;
		b = c;
		c = a % b;
	}
 
	return b;
}
 
int main()
{
	int N = 0;
	std::cin >> N;
 
	std::vector<long long int> A(N + 1, 0);
	std::vector<long long int> M(N, 0);
	for (int i = 0; i < N; i++)
	{
		std::cin >> A[i + 1];
	}
 
	std::vector<long long int> L(N + 2, 0);
	std::vector<long long int> R(N + 2, 0);
	L[0] = 0;
	R[N + 1] = 0;
	for (int i = 1; i < N + 1; i++)
	{
		L[i] = gcd(L[i - 1], A[i]);
		R[(N + 1) -i] = gcd(R[(N + 1)- (i - 1)], A[(N + 1) - i]);
	}
 
	for (int i = 1; i < N + 1; i++) M[i - 1] = gcd(L[i - 1], R[i + 1]);
	std::sort(M.begin(), M.end(), std::greater<long long int>());
 
	std::cout << M[0] << std::endl;
 
	return 0;
}

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

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

    vector<vector<int>> abc(N + 1, vector<int>(3, 0));
    for (int i = 1; i <= N; i++)
    {
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }

    vector<vector<int>> ans(N + 1, vector<int>(3, 0));

    for (int i = 1; i <= N; i++)
    {
        ans[i][0] = max(
            ans[i - 1][1] + abc[i][0],
            ans[i - 1][2] + abc[i][0]);
        ans[i][1] = max(
            ans[i - 1][2] + abc[i][1],
            ans[i - 1][0] + abc[i][1]);
        ans[i][2] = max(
            ans[i - 1][0] + abc[i][2],
            ans[i - 1][1] + abc[i][2]);
    }
    cout << *max_element(ans[N].begin(), ans[N].end()) << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<ll,ll> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

vector<vector<int>> A(200000,vector<int>());

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        A[a].push_back(b);
        A[b].push_back(a);
    }

    vector<ll> dist(n, INF);
    queue<int> q;
    auto push = [&](int v, int d){
            if(dist[v] != INF)return;
            dist[v] = d;
            q.push(v);
        };
    push(0,0);
    while(!q.empty()){
        int t = q.front();q.pop();
        rep(i,A[t].size()){
            push(A[t][i],t);
        }
    }
    cout << "Yes"<<endl;
    rrep(i,n-1){
        cout<<dist[i]+1<< endl;
    }
    return 0;
}

Measured memory_bytes: 13008
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
#include<stdio.h>
using namespace std;

typedef long long ll;

int main(){
    int N;
    cin>>N;
    vector<ll> a(N);
    for (int i=0;i<N;i++){
        cin>>a[i];
    }

    vector<ll> data(N+1);
    ll ans=0;
    ll q=0;
    for (int i=0;i<N;i++){
        q+=(a[i]+1)/(N+1);
        data[(a[i]+1)%(N+1)]+=1;
    }
    ans=q*(N+1);

    for (ll r=1;r<N+1;r++){
        q+=data[N+1-r]-1;
        ll t=0;
      	ll zero=0;
        t=std::max(q,zero)*(N+1)+r;
        ans=std::min(ans,t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 1000000001
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){
	
	int n;
	cin>>n;
	cout<<"ABC"<<n<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;

int f(int b) {
	int x = b - k;
	int y = (n - k) / b;
	return x * y + min(x, n - (y * b + k) + 1);
}

signed main() {
	cin >> n >> k;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	
	int ans = 0;
	for (int b = k + 1; b <= n; b++) {
		ans += f(b);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    //a*500, b*100, c*50 = x

    int ans = 0;
    for(int i=0; i<a+1; i++){
        for(int j=0; j<b+1; j++){
            for(int k=0; k<c+1; k++){
                if( i*500 + j*100 + k*50 == x) ans++;
            }
        }
    }

    cout << ans << endl;
}

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

long long gcd(long long a, long long b) {
	if (a == 0) return b;
	if (b == 0) return a;
	if (a > b) return gcd(a%b, b);
	return gcd(a, b%a);
}

bool isPrime(long long  x) {
	for (long long  i=2; (i * i) < x + 2; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

long long fc(long long t) {
	set<long long> res;
	int c = 0;
	for (long long i=1; (i*i)<t+2; i++) {
		if (t % i == 0) {
			res.insert(i);
			res.insert(t/i);
			if (isPrime(i)) c++;
			if (i*i == t) continue;
			if (isPrime(t/i)) c++;
		}
	}
	return c;
}

int main() {
	
	long long a, b;
	cin >> a >> b;
	
	long long x = gcd(a, b);
	cout << fc(x) << endl;
	
	
}


Measured memory_bytes: 512
import math
a, b, x = list(map(float, input().split()))

# %%
# a, b, x = [3, 1, 8]
if x/a > a*b/2:
    # 台形
    y = 2*x/(a**2) - b
    # print(90-math.degrees(math.atan(   (a/(b-y))  )))
    print(90-math.degrees(math.atan2(a, b-y)))
else:
    # 三角形
    # print(90-math.degrees(math.atan( (2*x/(a*b)) / b  )))
    print(90-math.degrees(math.atan2(2*x/(a*b), b)))

Measured memory_bytes: 3060
#ABC144-E Gluttony
"""
消化コストの小さい人から食べにくさの大きいものを割り当てるのは確定。
問題は全員のコスト*食べにくさ　の合計ではなく、最もその値が大きい人の
スコアを最小化することである。

最大値の最小化は、最大値を決め打って二分探索。
コストの昇順と食べにくさの降順を対応させ、食べにくさ*need<=決め打った最大値
となるようなneedを求め、k -= max(0,-need+コスト)していく。
kが0未満になってしまった場合はその決め打った最大値は達成できない。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
lsta = list(map(int,readline().split()))
lstf = list(map(int,readline().split()))

lsta.sort()
lstf.sort(reverse=True)
def func(mid,k):
    for i in range(n):
        need = mid//lstf[i] #need以下にしないといけない
        k -= max(0,lsta[i]-need)
        if k < 0:
            return 0
    return 1

def binary_search(): #2分探索
    ok = 10**20
    ng = -1
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if func(mid,k):
            ok = mid
        else:
            ng = mid

    return ok

print(binary_search())


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

int main(){
    char b; cin >> b;

    if(b == 'A') put('T');
    else if(b == 'C') put('G');
    else if(b == 'G') put('C');
    else if(b == 'T') put('A');    
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP       (i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);

int keta(int a) {
	int ret = 0;
	while (a >= 10) {
		ret += (a % 10);
		a /= 10;
	}
	return ret + a;
}


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a <= keta(i) && keta(i) <= b)ans+=i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))

x = list(map(int, input().split()))

if 0 in x:
  K -= 1
  x.remove(0)
  
if K <= 0:
  print(0)
  exit()
if K == 1:
  print(min(abs(i) for i in x))
  exit()
  
px = [i for i in x if i > 0]
mx = [i for i in x if i < 0]


  
lp = len(px)
lm = len(mx)

mn = (abs(x[0]) + abs(x[len(x)-1])) * 2
if lp >= K:
  t = px[K-1]
  if t < mn:
    mn = t
if lm >= K:
  t = -mx[-K]
  if t < mn:
    mn = t
for i in range(max(lm-K+1, 0), min(lm,len(x)-K+1)):
  tm = -x[i]
  tp = x[i+K-1]
  t = min(tm, tp) * 2 + max(tm, tp)
  if t < mn:
    mn = t
  
print(mn)

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

int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for(auto i = 0; i < n; ++i){
		int x;
		cin >> x;
		ans += (min(x, abs(x - k)) * 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
(defn solve [a b cnt]
  (if (>= a b)
    (inc cnt)
    (solve
      (if (= cnt 0) (dec a) a)
      (- b a)
      (inc cnt))))

(let [a (int (read))
      b (int (read))]
  (println (if (= b 1) 0 (solve a b 0))))


Measured memory_bytes: 66716
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 1; i < (int)(n+1); i++)
#include <bits/stdc++.h>
using namespace std;
int divid2(int n){
    int c = 0;
    while(n%2 == 0 && n != 0){
        n/=2;
        c++;
    }
    return c;
}

int main(){
    int n,m1 = 1,m2 = 0,cnt = 0;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cnt = divid2(i);
        if(m2 < cnt){
            m1 = i;
            m2 = cnt;
        }
    }
    cout << m1 << endl;
}

Measured memory_bytes: 256
/**
    AUTHOR:Jun_SH
    TIME:2019/6/16
    PROBLEM:ABC130_f
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double inf=1e9+10;
long double pos[4][3];
long double cal(long double t){
    long double r[4];
    for(ll i=0;i<4;++i){
        r[i]=max({pos[i][0]+t,pos[i][1]-t,pos[i][2]});
    }
    return (r[0]+r[2])*(r[1]+r[3]);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    for(ll i=0;i<4;++i)
    for(ll j=0;j<3;++j)
        pos[i][j]=-inf;
    for(ll i=1;i<=n;++i){
        long double x,y;
        string d;
        cin>>x>>y>>d;
        if(d=="U"){
            pos[0][2]=max(pos[0][2],x);
            pos[1][1]=max(pos[1][1],-y);
            pos[2][2]=max(pos[2][2],-x);
            pos[3][0]=max(pos[3][0],y);
        }
        else if(d=="D"){
            pos[0][2]=max(pos[0][2],x);
            pos[1][0]=max(pos[1][0],-y);
            pos[2][2]=max(pos[2][2],-x);
            pos[3][1]=max(pos[3][1],y);
        }
        else if(d=="L"){
            pos[0][1]=max(pos[0][1],x);
            pos[1][2]=max(pos[1][2],-y);
            pos[2][0]=max(pos[2][0],-x);
            pos[3][2]=max(pos[3][2],y);
        }
        else if(d=="R"){
            pos[0][0]=max(pos[0][0],x);
            pos[1][2]=max(pos[1][2],-y);
            pos[2][1]=max(pos[2][1],-x);
            pos[3][2]=max(pos[3][2],y);
        }
    }
    long double ans=cal(0);
    for(ll i=0;i<4;++i){
        if(pos[i][2]-pos[i][0]>0)ans=min(ans,cal(pos[i][2]-pos[i][0]));
        if(pos[i][1]-pos[i][2]>0)ans=min(ans,cal(pos[i][1]-pos[i][2]));
        if(pos[i][1]-pos[i][0]>0)ans=min(ans,cal((pos[i][1]-pos[i][0])/2.0));
    }
    cout<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;

int main()
{
    cin >> N;
    string str; cin >> str;

    int cnt = 0, left = 0, right = 0;
    bool update = true;
    vector<char> current(str.begin(), str.end());
    vector<char> next;
    while (update) {
        if (current.size() < 2)
            break;
        next.clear();
        update = false;
        for (int i = 1; i < current.size(); ++i) {
            //cout << current.size() << " " << i << ", " << current[i] << endl;
            if (current[i-1] == '(' && current[i] == ')') {
                update = true;
                i++;
            } else {
                next.push_back(current[i-1]);
            }
            if (i == current.size()-1)
                next.push_back(current[i]);
        }
        current.assign(next.begin(), next.end());
        //for (auto n : next)
            //cout << n;
        //cout << endl;
    }

    for (auto n : next)
        if (n == '(')
            right++;
        else
            left++;
    
    for (int i = 0; i < left; ++i)  
        cout << '(';
    cout << str;
    for (int i = 0; i < right; ++i)
        cout << ')';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
typedef long double lb;
using namespace std;
int main(){
  string S;
  cin >> S;
  int SI = S.size();
  for(int i = SI - 1; i >= 0; i--){
    cout << S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    vector<int> va;
  	vector<int> vb;
  
    int a, b, m;
	cin >> a >> b >> m;

  	int aa, bb;
    for (int i = 0; i < a ; i++) {
    	cin >> aa; 
    	va.push_back(aa);
    }
    for (int i = 0; i < b ; i++) {
    	cin >> bb; 
    	vb.push_back(bb);
 	}

	int mina = *min_element(va.begin(), va.end());
	int minb = *min_element(vb.begin(), vb.end()); 
  	int ans = mina + minb;
  
  	int x, y, c;
    for (int i = 0; i < m ; i++) {
    	cin >> x >> y >> c;
      	ans = min(ans, va[x-1] + vb[y-1] - c);
 	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, x[55], y[55];
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
	long long ret = 1LL << 62;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					if (x[i] <= x[j] && y[k] <= y[l]) {
						int cnt = 0;
						for (int p = 0; p < N; p++) {
							if (x[i] <= x[p] && x[p] <= x[j] && y[k] <= y[p] && y[p] <= y[l]) cnt++;
						}
						if (cnt >= K) ret = min(ret, 1LL * (x[j] - x[i]) * (y[l] - y[k]));
					}
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int aj,as,ar,ae,bj,bs,br,be,S,T;

scanf("%d %d %d %d", &aj,&as,&ar,&ae);
scanf("%d %d %d %d", &bj,&bs,&br,&be);

S=aj+as+ar+ae;
T=bj+bs+br+be;

if(S>=T) printf("%d\n",S);
else printf("%d\n",T);

return 0;




}

Measured memory_bytes: 592
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    string S;
    cin >> N >> S;
    int x = 0, res = 0;
    REP(i, N) {
        if (S[i] == 'I') {
            x++;
            amax(res, x);
        } else {
            x--;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
     
int main(){
    const std::string wrong_word("Hoshino");
    const std::string right_word("Hoshina");
       
    int num;
    std::cin >> num;
    std::cin.ignore(); // ignore next newline character
         
    for(int i = 0; i < num; ++i){
        std::string str;
        std::getline(std::cin, str);
           
        std::size_t pos = str.find(wrong_word);
        while(pos != std::string::npos){
            str.replace(pos, wrong_word.length(), right_word);
            pos = str.find(wrong_word);
        }
           
        std::cout << str << std::endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    bool flag = false;
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            if(i*j==N) flag = true;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

// 0-indexed
template <class T>
struct BIT {
  int treesize;
  vector<T> lst;
  // constructor
  BIT(int newn = 0) : treesize(newn), lst(newn + 1, 0) {}
  // a_place += num
  void add(int place, T num) {
    ++place;
    while (place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
  }
  // sum between [0,place)
  T sum(int place) {
    T res = 0;
    while (place > 0) {
      res += lst[place];
      place -= place & -place;
    }
    return res;
  }
  // sum [l,r)
  T sum(int left, int right) { return sum(right) - sum(left); }
};

using P = pair<int, int>;

int n, m;
vector<int> res;
vector<P> v;
BIT<int> bit;

void solve();

int main() {
  cin >> n >> m;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first >> v[i].second;
    ++v[i].second;
  }
  sort(v.begin(), v.end(),
       [](P l, P r) { return (l.second - l.first) < (r.second - r.first); });
  bit = BIT<int>(m + 2);
  solve();
  for (auto p : res) cout << p << endl;
  return 0;
}

void solve() {
  for (int i = 1, id = 0; i <= m; ++i) {
    int now = 0;
    while (id < n && i > v[id].second - v[id].first) {
      bit.add(v[id].first, 1);
      bit.add(v[id].second, -1);
      ++id;
    }
    now = n - id;
    for (int j = 1; i * j <= m; ++j) now += bit.sum(i * j + 1);
    res.push_back(now);
  }
}

Measured memory_bytes: 6568
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  vector<int> w(n);
  vector<int> ws(n);
  rep(i,n){
    if(s[i]=='#') w[i]=1;
  }
  ws[0]=w[0];
  for(int i=1;i<n;i++){
    ws[i]=ws[i-1]+w[i];
  }
  vector<int> b(n);
  vector<int> bs(n);
  for(int i=n-1;i>=0;i--){
    if(s[i]=='.') b[i]=1;
  }
  bs[n-1]=b[n-1];
  for(int i=n-2;i>=0;i--){
    bs[i]=bs[i+1]+b[i];
  }
  int ans=min(bs[0],ws[n-1]);
  rep(i,n-1){
    chmin(ans,ws[i]+bs[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main(){

	int K, N;
	string S;

	cin >> S;
	cin >> K;

	N = S.length();

	set<string> d;
	for (int i = 0; i < N; i++){
		d.insert(S.substr(i,1));
	}
	for (int i = 0; i < N-1; i++){
		d.insert(S.substr(i, 2));
	}
	for (int i = 0; i < N - 2; i++){
		d.insert(S.substr(i, 3));
	}
	for (int i = 0; i < N - 3; i++){
		d.insert(S.substr(i, 4));
	}
	for (int i = 0; i < N - 4; i++){
		d.insert(S.substr(i, 5));
	}

	set<string>::iterator i = d.begin();
	for (int j = 1; j < K; j++){
		i++;
	}
	cout << *i << endl;

	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int k = 3;
int tab[k][k];
bool jj[k][k];

int main() {
	ios_base::sync_with_stdio(false);
	REP(i,k) REP(j, k) cin >> tab[i][j];
	int n;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		REP(i,k)REP(j,k) if(tab[i][j] == x) jj[i][j] = true;
	}
	REP(i, k) {
		bool ok = true;
		REP(j,k) if (!jj[i][j]) ok = false;
		if (ok) {
			printf("Yes\n");
			return 0;
		}
	}
	REP(i, k) {
		bool ok = true;
		REP(j, k) if (!jj[j][i]) ok = false;
		if (ok) {
			printf("Yes\n");
			return 0;
		}
	}
	bool ok = true;
	REP(i, k) if (!jj[i][i]) ok = false;
	if (ok) {
		printf("Yes\n");
		return 0;
	}
	ok = true;
	REP(i, k) if (!jj[2 - i][i]) ok = false;
	if (ok) {
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
}

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

int main(){
    int n;
    cin >> n;
    int array[n];
    for(int i = 0; i<n; i++){
        cin >> array[i];
    }
    sort(array, array+n);
    bool flag = true;
    int ans = 1;
    if(n%2==0){
        for(int i=0; i<n; i++){
            if(array[i] != i/2 * 2 + 1){
                flag = false;
                break;
            }
            if( (i+1)%2==0){
                ans = ans * 2 % 1000000007;
            }
        }
    }else{
        for(int i = 0; i<n; i++){
            if(array[i] != (1+i)/2 * 2){
                flag = false;
                break;
            }
            if( (i+1)%2==0){
                ans = ans * 2 % 1000000007;
            }
        }
    }
    if(!flag)ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793


int main(){
  int N, K; cin >> N >> K; ll ans = 0;
  for(int i=K; i<=N+1; i++){
      ans+=(ll)(N-i+1)*i%mod; ans%=mod;
      ans++; ans%=mod;
      //cout << (N-i+1)*i << endl;
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> p(n), q(n), a(n, 0);
    
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
    }
    for(int i=0;i<n;i++){
        a[i]+=i+1;
    }
    
    int indp=0, indq=0, ind=0;
    
    while(true){
        if(p==a)indp = ind;
        if(q==a)indq = ind;
        ind++;
        if(!next_permutation(a.begin(), a.end()))break;
    }
    
    cout<<abs(indp - indq)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int MOD;

template <class T>
vector<vector<T> > matrixProduct(const vector<vector<T> >& x, const vector<vector<T> >& y)
{
    int a = x.size();
    int b = x[0].size();
    int c = y[0].size();
    vector<vector<T> > z(a, vector<T>(c, 0));
    for(int i=0; i<a; ++i){
        for(int j=0; j<c; ++j){
            for(int k=0; k<b; ++k){
                z[i][j] += x[i][k] * y[k][j];
                z[i][j] %= MOD;
            }
        }
    }
    return z;
}

template <class T>
vector<vector<T> > matrixPower(const vector<vector<T> >& x, int k)
{
    int n = x.size();
    vector<vector<T> > y(n, vector<T>(n, 0));
    for(int i=0; i<n; ++i)
        y[i][i] = 1;

    vector<vector<T> > z = x;
    while(k > 0){
        if(k & 1)
            y = matrixProduct(y, z);
        z = matrixProduct(z, z);
        k >>= 1;
    }
    return y;
}

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

int main()
{
    for(int d=1; ; ++d){
        int n, l;
        cin >> n >> MOD >> l;
        if(n == 0)
            return 0;

        vector<vector<int> > cell(2*n+1, vector<int>(2*n+1, -1));
        for(int i=0; i<n-1; ++i){
            for(int j=0; j<n+i; ++j){
                cin >> cell[i+1][j+1];
            }
        }
        for(int i=0; i<n; ++i){
            for(int j=0; j<2*n-1-i; ++j){
                cin >> cell[i+n][i+j+1];
            }
        }

        n = 2 * n + 1;
        vector<vector<long long> > a(n*n, vector<long long>(n*n, 0));
        vector<vector<long long> > b(n*n, vector<long long>(1, 0));
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                if(cell[i][j] == -1){
                    cell[i][j] = 0;
                    continue;
                }

                b[i*n+j][0] = cell[i][j];
                for(int k=0; k<7; ++k){
                    int y = i + dy[k];
                    int x = j + dx[k];
                    a[i*n+j][y*n+x] = 1;
                }
            }
        }

        a = matrixPower(a, l);
        vector<vector<long long> > c = matrixProduct(a, b);

        long long ret = 0;
        for(int i=0; i<n*n; ++i)
            ret += c[i][0];
        cout << "Case " << d << ": " << ret << endl;
    }
}

Measured memory_bytes: 2132
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

N,A,B=map(int, input().split())

## Logic

ans = 0
for i in range(A,N+1):
    tmp = 0
    string = str(i)
    for j in range(0,len(string)):
        tmp += int(string[j])
    if A<=tmp & tmp<=B:
        ans += i


print(ans)





Measured memory_bytes: 65900
# E - Active Infants

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n

# 添字のリスト
p = list(range(n))
p.sort(key=lambda i: a[i])

# dp[j] = 位置jから幅iの区間に小さい方からi個を配置したときの最大うれしさ
dp = [0] * (n + 1)

for i in range(n):
    for j in range(n - i):
        dp[j] = max(dp[j]     + a[p[i]] * abs(p[i] - (j + i)),
                    dp[j + 1] + a[p[i]] * abs(p[i] - j))

print(dp[0])


Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i <= n / r; ++i)
	{
		for (int j = 0; j <= (n - i * r) / g; ++j)
		{
			if ((n - i * r - j * g) % b == 0)
				ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int A;
int B;
int C;
cin >> A >> B >> C;
int max = 0, mid, min = 100000;
int sum = A + B + C;

if (max < A){
max = A;
}

if (max < B){
max = B;
}
if (max < C){
max = C;
}

if (min > A){
min = A;
}
if (min > B){
min = B;
}
if (min > C){
min = C;
}
mid = sum - max - min;
cout << min <<" "<< mid <<" "<< max << endl;
return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

int euq(int a, int b) {return b ? euq(b, a%b) : a;}

int comb(int n, int k) {
    int a=1, b=1;
    k = min(k, n-k);
    vi ar, br;
    rep(i, k) {
        ar.pb(n-i);
        br.pb(i+1);
    }

    rep(i, ar.size()) {
        rep(j, br.size()) {
            int g = euq(ar[i], br[j]);
            ar[i] /= g; br[j] /= g;
        }
    }

    rep(i, ar.size()) a *= ar[i];
    rep(i, br.size()) b *= br[i];
    
    return a/b;
}

signed main() {
    int N, P;
    cin >> N >> P;

    int e=0, o=0;
    rep(i, N) {
        int a;
        cin >> a;
        if(a%2) o++;
        else e++;
    }

    int oc = 0;
    if(P) {
        for(int i=1; i<=o; i+=2) {
            oc += comb(o, i); 
        }
    } else {
        for(int i=0; i<=o; i+=2) {
            oc += comb(o, i);
        }
    }

    int res = 0;
    rep(i, e+1) {
        res += oc*comb(e, i);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
flag = False

for i in range(N+1):
    for j in range(N-i+1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            print(i, j, N-i-j)
            flag = True
            break
    if flag == True:
        break

if flag == False:
    print('-1 -1 -1')



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

using namespace std;

//#define FILE_IO

typedef long long LL;

const int NMAX = 2e5 + 5;

int N;
int a[NMAX], b[NMAX];

multiset<int> st;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d%d", &a[i], &b[i]);
        if(a[i] > b[i]) swap(a[i], b[i]);
    }

    int mxa = 0, mna = 1 << 30, mxb = 0, mnb = 1 << 30;
    for(int i = 1; i <= N; i++)
    {
        mxa = max(mxa, a[i]);
        mxb = max(mxb, b[i]);
        mna = min(mna, a[i]);
        mnb = min(mnb, b[i]);
    }

    LL ans = 1LL * (mxa - mna) * (mxb - mnb);

    int mn = min(mna, mnb), mx = max(mxa, mxb);
    bool ok = false;
    int cntmn = 0, cntmx = 0;
    int idmn = 0, idmx = 0;
    for(int i = 1; i <= N; i++)
    {
        if(a[i] == mn) cntmn++;
        if(b[i] == mx) cntmx++;
        if(a[i] == mn && b[i] == mx)    continue;
        ok = true;
        if(a[i] == mn)  idmn = i;
        if(b[i] == mx)  idmx = i;
    }
    if(cntmn > 1 || cntmx > 1) ok = true;

    if(!idmn)   for(int i = 1; i <= N; i++) if(a[i] == mn)  { idmn = i; break; }
    if(!idmx)   for(int i = 1; i <= N; i++) if(b[i] == mx && i != idmn) { idmx = i; break; }
    if(!idmx) { idmn = 0; for(int i = 1; i <= N; i++) if(b[i] == mx) { idmx = i; break; } for(int i = 1; i <= N; i++) if(a[i] == mn && i != idmx)  { idmn = i; break; } }

    if(!ok) { printf("%lld\n", ans); exit(0); }

    vector<int> ord;
    st.insert(b[idmn]); st.insert(a[idmx]);
    for(int i = 1; i <= N; i++)
        if(i != idmn && i != idmx)
        {
            ord.push_back(i);
            st.insert(a[i]);
        }
    sort(ord.begin(), ord.end(),
         [](int x, int y) { if(a[x] == a[y]) return b[x] < b[y]; return a[x] < a[y]; });

    int mnn = *(st.rbegin()) - *(st.begin());
    for(auto id: ord)
    {
        st.erase(st.find(a[id]));
        st.insert(b[id]);

        int val = *(st.rbegin()) - *(st.begin());
        mnn = min(mnn, val);
    }

    ans = min(ans, 1LL * mnn * (mx - mn));

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

    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  int sum = 0;
  for (int i = 0; i < 2; i++) {
    if (A > B) {
      sum += A;
      A--;
    } else {
      sum += B;
      B--;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        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")
    };
}
fn main() {
    input! {
        a: u32,
        b: u32,
    };
    println!(
        "{}",
        (a..b + 1)
            .filter(|n| {
                let c: Vec<_> = n.to_string().chars().collect();
                c[0] == c[4] && c[1] == c[3]
            })
            .count()
    );
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n;
    int d[2][1000];
    scanf("%d",&n);
    int cnt=0;
    int mode;
    mode=0;
    for(int i=0;i<n;i++){
        scanf("%d %d",&d[0][i],&d[1][i]);
        if(d[0][i]==d[1][i]){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt==3){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}



Measured memory_bytes: 1672
N, D = map(int,input().split())
K = [list(map(int,input().split()))for x in range(N)]
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    goukei=0
    for a,b in zip(K[i],K[j]):
      goukei += (a-b)**2
    ans += (goukei**0.5).is_integer()
print(ans)

Measured memory_bytes: 3188
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		for(int i = 0; i<N; i++){
				BigInteger sum = sc.nextBigInteger().add(sc.nextBigInteger());
					if(String.valueOf(sum).length() > 80){
						System.out.println("overflow");
					} else {
						System.out.println(sum);
					}
		}
		
	}
}

Measured memory_bytes: 18428
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n,l,m =0,cnt = 0;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n){
        if(i == 0)l = h[i];
        else{
            if(h[i] <= l){
                cnt++;
                l = h[i];
            }
            else{
                l = h[i];
                m = max(m,cnt);
                cnt = 0;
            }
        }
    }
    m = max(m,cnt);
    cout << m;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto a = vector<int>(n), b = vector<int>(n), c = vector<int>(n);
    for (auto i=0; i<n; ++i)
        cin >> a[i] >> b[i] >> c[i];
    auto dyn = vector<vector<int>>(3, vector<int>(n));
    dyn[0][0] = a[0];
    dyn[1][0] = b[0];
    dyn[2][0] = c[0];
    for (auto i=1; i<n; ++i) {
        dyn[0][i] = a[i] + max(dyn[1][i-1], dyn[2][i-1]);
        dyn[1][i] = b[i] + max(dyn[0][i-1], dyn[2][i-1]);
        dyn[2][i] = c[i] + max(dyn[0][i-1], dyn[1][i-1]);
    }
    cout << max(dyn[0][n-1], max(dyn[1][n-1], dyn[2][n-1])) << '\n';
}


Measured memory_bytes: 2944
#include <stdio.h>

int main(void)
{
    int t, h, m, s;

    scanf("%d", &t);
    h = t/3600;
    t = t%3600;
    m = t/60;
    s = t%60;

    printf("%d:%d:%d\n", h, m, s);

    return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5, INF = 1E9 + 7;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int n;
	cin >> n;
	int a, b;
	int cnt = 0;
	int ans = 0;
	for(int i=0;i<n;i++) {
		cin >> a >> b;
		if (a == b) {
			cnt++;
			ans = max(ans, cnt);
		}
		else {
			cnt = 0;
		}

	}
	cout << ((ans>=3)?"Yes":"No") << endl;
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3648
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){

  int x,a,b;
  cin>>x>>a>>b;
  cout<<(abs(a-x)>abs(b-x) ? "B" : "A");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   long double a;
   cin>>a;
   long double amnt = 100,ans = 0,k;
   while(amnt<a){
       k = floor(((0.01)*amnt));
       amnt+=k;
       ans++;
       //cout<<amnt<<endl;
   }
   cout<<ans<<endl;

    return 0;
}



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

int main() {
  string s, ss = "", head, tail;
  int q, t, f, l;
  char c;
  int flag = 0;
  cin >> s;
  cin >> q;
  rep(i,q) {
    cin >> t;
    if (t==1) flag = (flag+1) % 2;
    else if (t==2){
      cin >> f >> c;
      if ((flag+f)%2==1) head = c+head;
      else tail = tail+c;
    }
  }
  s = head + s + tail;
  if (flag==1) {
    l = s.size();
    rep(i,l) ss += s[l-i-1];
    cout << ss << endl;
  } else cout << s << endl;
}


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

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	vector<int> N(4, 0);
	Rep0(i, 4)
		cin >>N.at(i);
	Sort(N);
	if ((1==N.at(0))&&(4==N.at(1))&&(7==N.at(2))&&(9==N.at(3)))
		cout <<"YES" <<endl;
	else
		cout <<"NO" <<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())

lst = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        lst[i].append([x - 1, y])

ans = 0
for i in range(2 ** N):
    check = [-1] * N #1:正直者、0:不親切
    count = 0 #カウント用
    flag = True
    for j in range(N):
        if (i >> j) & 1: #正直者のとき
            if check[j] == 0: #矛盾しているとき
                flag = False
                break
            else:
                check[j] = 1

            # count += 1

            for x, y in lst[j]:
                if y == 1: #行き先が正直者
                    if check[x] != 0:
                        check[x] = 1
                    else: #矛盾しているとき
                        flag = False
                        break
                else: #y == 0
                    if check[x] != 1:
                        check[x] = 0
                    else:
                        flag = False
                        break
        else: #正直者でないとき
            if check[j] == 1:
                flag = False
                break
            else:
                check[j] = 0

        if flag == False:
            break
    if flag:
        tmp = 0
        for j in range(N):
            if (i >> j) & 1:
                tmp += 1
        # print (i)
        # print (check, flag)
        ans = max(ans, tmp)

print (ans)
# print (lst)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=200002;
int N, M, k;
vector<char> v;
int par[MX];
ll sz[MX];
int f(int x)
{
    if(x == par[x]) return x;
    return par[x]=f(par[x]);
}
void mer(int a, int b)
{
    a=f(a);
    b=f(b);
    if(a == b) return ;
    par[b]=a;
    sz[a]+=sz[b];
}
pair<int,int> arr[MX];
int main()
{
    scanf("%d", &N);
    for(int i=1; i<=N; i++)
    {
        scanf("%d", &arr[i].F);
        arr[i].S=i;
        arr[i].F=-arr[i].F;
        par[i]=i;
        sz[i]=0;

    }
    ll an=0;
    sort(arr+1, arr+1+N);
    for(int i=1; i<=N; i++)
    {
        int j=arr[i].S;
        arr[i].F*=-1;
        int L=1, R=1;
        if(j > 1 && sz[f(j-1)]) L=sz[f(j-1)]+1;
        if(j < N && sz[f(j+1)]) R=sz[f(j+1)]+1;
        an+=(ll)arr[i].F*L*R;
//        cout<<L<<" "<<R<<"\n";
        sz[j]=1;
        if(j > 1 && sz[f(j-1)]) mer(j, j-1);
        if(j < N && sz[f(j+1)]) mer(j, j+1);

    }
    cout<<an;

}


Measured memory_bytes: 4096