akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i,n) {
        cin >> h[i];
    }
    int ans = 1;
    for (int i = 1; i < n; ++i) {
        bool ok = true;
        for (int j = 0; j < i; ++j) {
            if (h[j] > h[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

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

int main(){
  li n; cin >>n;
  li a=n/500,b=(n%500)/5;
  print(1000*a+5*b);
}





Measured memory_bytes: 3632
import           Data.List

toWeekNumber s = case findIndex (== s) weekList of
  Just n  -> n
  Nothing -> error $ "toWeekNumber: invalid string: " ++ show s
  where weekList = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]

main = (7 -) . toWeekNumber <$> getLine >>= print


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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(0);
}

bool compare(int &a, int &b) {
	return a > b;
}

ll numOfDigits(ll n) {
	if (!n)
		return 1;
	return (ll) (log10(n)) + 1;
}

ull POW(ll a, ll b);

/*

 */

ll BN();

int main() {
	JULEE_DO_THE_THING;
	//freopen("test cases\\.txt", "r", stdin) ;
    int n, h; cin>>n>>h;
    vecint v(n+1);
    ll mx = IMIN;
    for(int i=1; i<=n; i++){
        int a, b; cin>>a>>b;
        mx = max(mx, (ll)a);
        v[i] = b;
    }
    sort(v.begin()+1, v.end());
    ll sum = 0;
    for(int i=1; i<n+1; i++){
        sum += v[i];
    }
    ll mn = LLMAX;
    for(int i=0; i<=n; i++){
        sum -= v[i];
        ll x;
        if(h>=sum)x = (h-sum)/mx + ((h-sum)%mx !=0);
        else x = 0;
        mn = min(mn, x + n-i);
    }
    cout<<mn;
	return 0;
}

ll BN() {
	ll low = 0;
	ll up = 0;
	ll ans = 0;
	while (low <= up) {
		ll mid = ((low + up) / 2);
		if (mid) {
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

ull POW(ll a, ll b) {
	ull res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N;
    cin>>N;
    cout<<N*N*N<<endl;
}


Measured memory_bytes: 3156
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)

for i in range(1,n+1):
    t[i],x[i],y[i]=map(int,input().split())
    
yn=""
for i in range(n):
    ti=t[i+1]-t[i]
    d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if d>ti or ti%2!=d%2:
        yn="No"
        break
    
if yn=="No":
    print("No")
else:
    print("Yes")
    

Measured memory_bytes: 11636
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    
    static int n;
    static ArrayList<Integer>[] g;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        
        for(int i=0; i<n-1; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            g[a].add(b);
            g[b].add(a);
        }
        
        ArrayDeque<Integer> q = new ArrayDeque<>();
        q.addLast(0);
        int[] color = new int[n];
        Arrays.fill(color, -1);
        color[0] = 0;
        while(q.size()!=0){
            int now = q.removeLast();
            for(int next : g[now]){
                if(color[next] == -1){
                    q.addLast(next);
                    color[next] = color[now]^1;
                }
            }
        }
        
        int[] cnt = new int[2];
        for(int i=0; i<n; i++){
            cnt[color[i]]++;
        }
        
        String[] ans = new String[n];
        int[] used = new int[3];
        if(cnt[0]<=n/3 || cnt[1]<=n/3){
            for(int i=0; i<n; i++){
                if(color[i] == (cnt[0]<cnt[1] ? 0:1)){
                    ans[i] = (used[2]+1)*3 + "";
                    used[2]++;
                }else{
                    for(int j=0; j<3; j++){
                        if(used[j]*3+j+1<=n){
                            ans[i] = used[j]*3+j+1 + "";
                            used[j]++;
                            break;
                        }
                    }
                }
            }
        }else{
            for(int i=0; i<n; i++){
                if(used[color[i]]*3+color[i]+1<=n){
                    ans[i] = used[color[i]]*3+color[i]+1 + "";
                    used[color[i]]++;
                }else{
                    ans[i] = (used[2]+1)*3 + "";
                    used[2]++;
                }
            }
        }
        
        System.out.println(String.join(" ", ans));
    }
}


Measured memory_bytes: 130852
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cnt1[100005],cnt2[100005];

signed main()
{   
    int N; cin>>N;
    REP(i,N){
        int t; cin>>t;
        if(i%2==0)
            cnt1[t]++;
        else
            cnt2[t]++;
    }
    
    vector<pint> v1,v2;
    for(int i=1;i<=100000;i++) v1.push_back(pint(cnt1[i],i));
    for(int i=1;i<=100000;i++) v2.push_back(pint(cnt2[i],i));
    sort(ALL(v1),greater<pint>());
    sort(ALL(v2),greater<pint>());

    int ans;
    pint X=v1[0],x=v1[1];
    pint Y=v2[0],y=v2[1];
    if(X.second!=Y.second)
        ans=N-(X.first+Y.first);
    else
        ans=N-max(X.first+y.first,x.first+Y.first);
    cout<<ans<<endl;

}


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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b, ans = 0;
   cin >> a >> b;
   cout << a % b << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

ll calc(vector<ll>&v){
    
    ll n=v.size();
    if(n<=1)return 0;
    vector<ll>b(v.begin(),v.begin()+n/2);
    vector<ll>c(v.begin()+n/2,v.end());
    /*
    if(n==5){
        for(auto x:b)cout<<x<<" ";cout<<endl;
        for(auto x:c)cout<<x<<" ";cout<<endl;
    }
     */
    ll res=calc(b)+calc(c);
    /*
    if(n==5){
        for(auto x:b)cout<<x<<" ";cout<<endl;
        for(auto x:c)cout<<x<<" ";cout<<endl;
    }
     */
    for(ll x:b){
        res+=lower_bound(c.begin(),c.end(),x)-c.begin();
    }
    sort(v.begin(),v.end());
    return res;
}


int main(){fastio
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,0,n-1)cin>>a[i];
    cout<<calc(a)<<endl;
    
    return 0;
}


Measured memory_bytes: 7744
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

#define mod 1000000007

using namespace std;

long long pow8[1000001], pow9[1000001], pow10[1000001];

int main()
{
    int N, i, sequences;

    scanf("%d", &N);

    pow8[0] = pow9[0] = pow10[0] = 1;
    for(i = 1; i <= N; ++i){
        pow8[i] = pow8[i - 1] * 8 % mod;
        pow9[i] = pow9[i - 1] * 9 % mod;
        pow10[i] = pow10[i - 1] * 10 % mod;
    }

    sequences = (pow10[N] - pow8[N] + mod) % mod;
    for(i = 1; i <= N; ++i)
        sequences = (sequences - (2 * (pow8[i - 1] * pow9[N - i] % mod) % mod) + mod) % mod;

    printf("%d", sequences);

    return 0;
}


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

#define vl vector<ll>
#define vs vector<string>
#define vll vector< vector<ll> >
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define tll tuple<ll, ll, ll>
#define vp vector< pair<ll,ll> >
#define vt vector< tuple<ll, ll, ll> >
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
#define NN 2020202

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//cout << setprecision(12) << ans << endl;

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

  if (s == "SAT"){
    cout << 1 << endl;
    exit(0);
  }
  if (s == "SUN"){
    cout << 7 << endl;
    exit(0);
  }
  if (s == "MON"){
    cout << 6 << endl;
    exit(0);
  }
  if (s == "TUE"){
    cout << 5 << endl;
    exit(0);
  }
  if (s == "WED"){
    cout << 4 << endl;
    exit(0);
  }
  if (s == "THU"){
    cout << 3 << endl;
    exit(0);
  }
  if (s == "FRI"){
    cout << 2 << endl;
    exit(0);
  }


  //cout << ans << endl;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  x = int(input())
  
  ans = 0
  while ans*(ans+1)/2 < x:
    ans += 1
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n, a1, a2;
	cin >> n >> a1 >> a2;

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

	if (n == 1) {
		cout << abs(a[0] - a2) << endl;
		return 0;
	}

	vector<vector<int>> res(2, vector<int>(n - 1));
	
	res[0][n - 2] = abs(a[n - 2] - a[n - 1]);
	res[1][n - 2] = abs(a[n - 2] - a[n - 1]);
	for (int i = n - 3; i >= 0; --i) {
		res[0][i] = max(res[0][i + 1], min(res[1][i + 1], abs(a[i] - a[n - 1])));
		res[1][i] = min(res[1][i + 1], max(res[0][i + 1], abs(a[i] - a[n - 1])));
	}

	int ans = max(res[0][0], abs(a[n - 1] - a2));
	cout << ans << endl;	

	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi x(n), l(n);
    rep(i, n) cin >> x[i] >> l[i];
    vpii r(n);
    rep(i, n) {
        r[i].first = x[i] + l[i];
        r[i].second = x[i] - l[i];
    }
    VSORT(r);
    int ans = 0, t = -INF;
    rep(i, n) {
        if (t <= r[i].second) {
            ++ans;
            t = r[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())

frr = []

for i in range(n):
    frr.append([int(s) for s in input().split(" ")])

prr = []

for i in range(n):
    prr.append([int(s) for s in input().split(" ")])

# n = 2
#
# frr = [
#     [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
#     [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
# ]
#
# prr = [
#     [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
#     [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]
# ]


res = []
for i in range(1,2 ** 10):
    count = [0 for s in range(n)]

    mask = []
    for j in range(10):
        m =  i >> j & 1
        mask.append(m)
        if m == 1:
            for k in range(n):
                if frr[k][j] == 1:
                    count[k] = count[k] + 1

    mm = []
    for index,c in enumerate(count):
        mm.append(prr[index][c])

    res.append(sum(mm))

print(max(res))




Measured memory_bytes: 3064
#include<stdio.h>

int main() {
    char num[1001];
    int i, sum;
    
    while(1) {
        scanf("%s", num);
        if (num[0] == '0') {
            break;
        }
        sum = 0;
        
        for (i=0; num[i] !='\0'; i++) { //\0はnullの部分
            sum += num[i] - '0';
        }
        printf("%d\n", sum);

    }
    
    return 0;
}



Measured memory_bytes: 2044
for e in iter(input, "0 0"):
    H, W = map(int, e.split())

    for h in range(H):
        for w in range(W):
            if (h+w)%2 == 0:
                print ("#", end="")
            else:
                print (".", end="")
        print ("\n", end="")

    print("")


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

int	main() {
	int N;
	int b;

	cin >> N;
	vector<int> vec(N);
	vector<int> flag(N);
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		vec.at(i) = a;
	}
	b = 1;
	for (int i = 0; i < N; i++)
	{
		b = vec.at(b - 1);
		if (b == 2)
		{
			cout << i + 1 << endl;
			return (0);
		}
		if (flag.at(b - 1) == 1)
		{
			cout << -1 << endl;
			return (0);
		}
		flag.at(b - 1) = 1;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x / d > k) {
        cout << x - k * d << endl;
        return;
    }
    ll n = x / d;
    k -= n;
    x -= n * d;
    cout << (k & 1 ? abs(x - d) : x) << endl;
}

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


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstring>
#include<functional>
#include<cmath>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)

using namespace std;

int main(){
	string a;
	cin >> a;
	if(a == "A") a = "T"; else if(a == "T") a = "A"; else if(a == "G") a = "C"; else a = "G";
	cout << a << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n,a;
  cin>>n>>a;
  vector<int> vec(n);
  rep(i,n){
    scanf("%d", &vec[i]);
  }
  rep(i,n) vec[i] -= a;

  long dp[2][2*50*51];

  long *now=dp[0], *old=dp[1];
  fill(dp[0], dp[2], 0);

  #define NOW(x) now[(x) + 50*50]
  #define OLD(x) old[(x) + 50*50]
  rep(i,n){
    for(int j=-50*n; j<=50*n; j++){
      NOW(j) = OLD(j);
      if(j-vec[i]>=-50*n && j-vec[i]<=50*n) NOW(j) += OLD(j-vec[i]);
    }
    NOW(vec[i])++;
    swap(now, old);
  }

  cout<< OLD(0)<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int memo[10001],color[10001];
stack<int> numb;
vector<int> connect[10001],rconnect[10001];

void dfs(int i){
  if(memo[i]!=0) return;
  memo[i]=1;
  lp(j,connect[i].size()){
    dfs(connect[i][j]);
  }
  numb.push(i);
  return;
}

void rdfs(int i,int j){
  if(memo[i]!=1) return;
  memo[i]=2;
  color[i]=j;
  lp(k,rconnect[i].size()){
    rdfs(rconnect[i][k],j);
  }
  return;
}

int main(){
  int v,e;
  cin>>v>>e;
  lp(i,e){
    int a,b;
    cin>>a>>b;
    connect[a].push_back(b);
    rconnect[b].push_back(a);
  }
  for(int i=0;i<v;i++){
    if(memo[i]==0) {
      dfs(i);
    }
  }
  int j=0;
  for(int i=0;i<v;i++){
    int x=numb.top();
    numb.pop();
    if(memo[x]==1) {
      rdfs(x,j);
      j++;
    }
  }
  int q;
  cin>>q;
  lp(i,q){
    int a,b;
    cin>>a>>b;
    if(color[a]==color[b]) cout<<"1"<<endl;
    else cout<<"0"<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 4496
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int c=0;c<n;c++){
    int a,b;
    cin>>a>>b;
    if(a<=5){
      for(int i=0;i<=abs(a-b);i++){
	if(i)cout<<" ";
	cout<<(a<b?a+i:a-i);
      }
      cout<<endl;
    }else{
      if(a<b){
	int f=0;
	for(int i=a;i<=9;i++){
	  if(i!=a)cout<<" ";
	  cout<<i;
	  if(i==b){
	    f=1;
	    break;
	  }
	}
	if(!f){
	  for(int i=5;i>=b;i--){
	    if(i!=5)cout<<" ";
	    cout<<i;
	  }
	}
	cout<<endl;
      }else{
	for(int i=a;i<=9;i++){
	  if(i!=a)cout<<" ";
	  cout<<i;
	}
	for(int i=-5;abs(i)!=b;i++){
	  cout<<" "<<abs(i);
	}
	cout<<" "<<b<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define vd vector<double>
using namespace std;

void manhattan(vd &xi, vd &yi) {
    double dist = 0.0;
    for (size_t i = 0; i < xi.size(); i++)
        dist += abs(xi[i] - yi[i]);
    cout << fixed << setprecision(7) << dist << endl;
}

void euclidean(vd &xi, vd &yi) {
    double dist = 0.0;
    for (size_t i = 0; i < xi.size(); i++)
        dist += abs(xi[i] - yi[i]) * abs(xi[i] - yi[i]);
    cout << fixed << setprecision(7) << sqrt(dist) << endl;
}

void p3(vd &xi, vd &yi) {
    double dist = 0.0;
    for (size_t i = 0; i < xi.size(); i++)
        dist += abs(xi[i] - yi[i]) * abs(xi[i] - yi[i]) * abs(xi[i] - yi[i]);
    cout << fixed << setprecision(7) << cbrt(dist) << endl;
}

void chevshev(vd &xi, vd &yi) {
    double _max = -100.0;
    for (size_t i = 0; i < xi.size(); i++)
        _max = max(_max, abs(xi[i] - yi[i]));
    cout << fixed << setprecision(7) << _max << endl;
}

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

    int n;
    cin >> n;

    vd xi(n), yi(n);
    for (int i = 0; i < n; i++) {
        cin >> xi[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> yi[i];
    }

    manhattan(xi, yi);
    euclidean(xi, yi);
    p3(xi, yi);
    chevshev(xi, yi);
}


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

const int INF = 1<<28;

struct Edge {
  int to, cost, cap, rev; 
  Edge(int to, int cost, int cap, int rev)
    : to(to), cost(cost), cap(cap), rev(rev) {}
  Edge() {}
};

typedef vector<vector<Edge> > Graph;

void addEdgeF(int from, int to, int cost, int cap, Graph &g) {
  g[from].push_back(Edge(to,cost,cap,g[to].size()));
  g[to].push_back(Edge(from,-cost,0,(int)g[from].size()-1));
}

typedef pair<int,int> Pair;

int minCostFlow(int s, int t, int f, Graph g) {
  int V = g.size();
  vector<int> h(V), dist(V), prevv(V), preve(V);
  int res = 0;
  fill(h.begin(), h.end(), 0);
  while(f > 0) {
    priority_queue<Pair, vector<Pair>, greater<Pair> > que;
    fill(dist.begin(), dist.end(), INF);
    dist[s] = 0;
    que.push(Pair(0, s));
    while(!que.empty()) {
      Pair p = que.top(); que.pop();
      int v = p.second;
      if(dist[v] < p.first) continue;
      for(int i = 0; i < g[v].size(); ++i) {
        Edge&e = g[v][i];
        int tmp = dist[v] + e.cost + h[v] - h[e.to];
        if(e.cap > 0 && dist[e.to] > tmp) {
          dist[e.to] = tmp;
          prevv[e.to] = v;
          preve[e.to] = i;
          que.push(Pair(dist[e.to], e.to));
        }
      }
    }
    if(dist[t] == INF) {
      return -1;
    }
    for(int v = 0;v < V; ++v) h[v] += dist[v];

    int d = f;
    for(int v = t; v != s; v = prevv[v]) {
      d = min(d, g[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * h[t];
    for(int v = t; v != s; v = prevv[v]) {
      Edge &e = g[prevv[v]][preve[v]];
      e.cap -= d;
      g[v][e.rev].cap += d;
    }
  }
  return res;
}

int editDist(const string &a, const string &b) {
  int n = a.size();
  int m = b.size();
  vector<vector<int> > dp(n+1, vector<int>(m+1, INF));
  dp[0][0] = 0;
  for(int i = 0; i <= n; ++i) {
    for(int j = 0; j <= m; ++j) {
      // change
      if(i < n && j < m) {
        dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (a[i] != b[j]));
      }
      // delete
      if(i < n) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j] + 1);
      }
      if(j < m) {
        dp[i][j+1] = min(dp[i][j+1], dp[i][j] + 1);
      }
    }
  }
  return dp[n][m];
}

int main() {
  int N, M;
  cin >> N >> M;
  cin.ignore();
  map<string,int> num;
  for(int i = 0; i < N; ++i) {
    string s;
    getline(cin, s);
    stringstream ss(s);
    while(ss >> s) {
      num[s] += 1;
    }
  }

  vector<string> text;
  for(map<string,int>::iterator it = num.begin();
      it != num.end(); ++it) {
    text.push_back(it->first);
  }
  vector<string> dict(M);
  for(int i = 0; i < M; ++i) {
    cin >> dict[i];
  }

  int n = text.size();
  int m = dict.size();
  Graph g(n+m+2);
  int src = g.size()-1;
  int dst = src - 1;
  for(int i = 0; i < n; ++i) addEdgeF(src, i, 0, 1, g);
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      addEdgeF(i, n+j, editDist(text[i], dict[j]) * num[text[i]], 1, g);
    }
  }
  for(int j = 0; j < m; ++j) addEdgeF(n+j, dst, 0, 1, g);

  cout << minCostFlow(src, dst, n, g) << endl;
  return 0;
}

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

int main(){
  int N,tmp;
  set<int> st;

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    st.insert(tmp);
  }

  cout << st.size() << endl;
  /*/
  for(int i = 0; i < N; i++){
    cout << d[i] << endl;
  }
  /*/

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  vi a(2);
  vi b(2);
  cin >> a[0] >> a[1];
  cin >> b[0] >> b[1];
  ll ans = LLONG_MIN;
  for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) ans = max(ans, 1LL * a[i] * b[j]);
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 3648
program abc133b
  implicit none
  integer :: n, d, i, j, s, ans
  integer,dimension(:,:),allocatable :: x

  read *, n, d
  allocate(x(d,n))
  read *, x
  ans = 0
  do j = 2,n
     do i = 1,j-1
        s = sum((x(:,i)-x(:,j))**2)
        If (s == nint(sqrt(dble(s)))**2) ans = ans + 1
     end do
  end do
  print *, ans
end program abc133b


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const ll AMAX=100100;
const ll INF=1e10;

ll d[AMAX],color[AMAX];
vector<pair<ll,ll>> M[AMAX];
ll n;

void dijk(ll s){
  
  rep(i,n){
    d[i]=INF;
    color[i]=0;
  }
  d[s]=0;
  
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> p;
  p.push({0,s});
  
  pair<ll,ll> u;
  while(!p.empty()){
    u=p.top(); p.pop();
    color[u.second]=2;
    
    if(d[u.second]<u.first) continue;
    
    for(auto v:M[u.second]){
      if(color[v.first]!=2){
        if(d[u.second]+v.second<d[v.first]){
          d[v.first]=d[u.second]+v.second;
          color[v.first]=1;
          p.push({d[v.first],v.first});
        }
      }
    }
  }

}

int main(){
  ll m,r;
  cin>>n>>m>>r;
  
  ll a,b,w;
  rep(i,m){
    cin>>a>>b>>w;
    M[a].push_back({b,w});
  }
  
  dijk(r);
  
  rep(i,n){
    if(d[i]!=INF) cout<<d[i]<<endl;
    else cout<<"INF"<<endl;
  }
      
  return 0;
}


Measured memory_bytes: 20156
#include<stdio.h>
int main()
{
     while(1)
     {
          int i,ans = 0;
          char x[1001];
          scanf("%s",x);
          if(x[0] == '0') break;
          for(i = 0; x[i] != '\0'; i++) ans += x[i] -'0';
          printf("%d\n",ans);
     }
     return 0;
      
}

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

int main()
{
    long long n;
    cin>>n;
    vector<long long> vec(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    sort(vec.rbegin(),vec.rend());
    long long a=vec[0];
    long long b;
    long long sum=0;
    queue<long long> q;
    // q.push(a);
    int c=0;
    for(int i=1;i<n;i++)
    {
        if(i==1)
        {
           sum+=a;
            q.push(vec[i]);
            a=vec[i];
           continue;
        }
        sum+=a;
        q.push(vec[i]);
        c++;
        if(c==2)
        {
            q.pop();
            a=q.front();
            c=0;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5628
#include <stdio.h>
#include <string.h>

int main()
{
	int i,j;
	int n,k=0;
	char str[51];
	int alpha1[51] = { 0 };
	int alpha2[51] = { 0 };

	scanf("%d", &n);
	scanf("%s", &str);
	check(str, alpha1);
	
	for (i = 1; i < n; i++) {
		scanf("%s", &str);
		for (j = 0; j < 51; j++) {
			alpha2[j] = 0;
		}
		check(str, alpha2);
		for (j = 'a'; j <= 'z'; j++) {
			if (alpha1[j - 'a'] > alpha2[j - 'a']) {
				alpha1[j - 'a'] = alpha2[j - 'a'];
			}
		}

	}

	for (i = 'a'; i <= 'z'; i++) {
		for (j = 0; j < alpha1[i - 'a']; j++) {
			printf("%c", i);
			k = 1;
		}
	}

	if (k == 0) {
		printf("\n");
	}


	getchar();
	getchar();

	return 0;
}

int check(char *str, int *alpha)
{
	int i;
	i = strlen(str);
	for (i = 0; i < strlen(str); i++) {
		alpha[str[i] - 'a']++;
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  int a;
  float b,c;
  while(~scanf("%d,%f,%f",&a,&b,&c)){
    float bmi = b/c/c;
    if(bmi>=25-1e-12){
      cout<<a<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1228
//
//  c.cpp
//  scs
//
//  Created by Mohammadreza Raddanipour on 1/9/19.
//  Copyright © 2019 Mohammadreza Raddanipour. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

const int MXN = 1e5 + 20;
int n;
int abc[MXN][3];
int dp[MXN][3];

int main () {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    for (int i = 1; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i - 1][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i - 1][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i - 1][2];
    }
    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	int hon[] = {2, 4, 5, 7, 9};
	for (int i = 0; i < 5; ++i) {
		if (n % 10 == hon[i]) {
			cout << "hon";
			return 0;
		}
	}
	int pon[] = {0, 1, 6 ,8};
	for (int i = 0; i < 4; ++i) {
		if (n % 10 == pon[i]) {
			cout << "pon";
			return 0;
		}
	}
	cout << "bon";
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			if (N == 0) break;
			int[] d = new int[N];
			for (int i = 0; i < N; ++i) {
				d[i] = sc.nextInt();
			}
			int[] m = new int[M];
			for (int i = 0; i < M; ++i) {
				m[i] = sc.nextInt();
			}
			int cur = 0;
			for (int i = 0; i < M; ++i) {
				cur += m[i];
				if (cur >= N - 1) {
					System.out.println(i + 1);
					break;
				}
				cur += d[cur];
				if (cur >= N - 1) {
					System.out.println(i + 1);
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 12000
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN         PIC X(3).
01 a          PIC 9(1).
01 b          PIC 9(1).
01 n          PIC 9(1).
01 i          PIC 9(2).
01 ans        PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
    MOVE b TO n
  ELSE
    MOVE a TO n
    MOVE b TO a
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL n < i
    MOVE a TO ans(i:1)
  END-PERFORM.
  DISPLAY ans(1:n).
  STOP RUN.


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


Measured memory_bytes: 2620
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n;
    cin >> n;

    for (auto a : irange(1L, 10L)) {
        for (auto b : irange(1L, 10L)) {
            if (n == a * b) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    readline = sys.stdin.readline

    mod = 10 ** 9 + 7

    h, w = map(int, readline().split())
    a = [readline().rstrip() for _ in range(h)]

    dp = [[0] * w for _ in range(h)]
    dp[0][0] = 1

    for r in range(h):
        for c in range(w):
            if a[r][c] == '#': continue
            if r > 0:
                dp[r][c] += dp[r - 1][c]
            if c > 0:
                dp[r][c] += dp[r][c - 1]
            dp[r][c] %= mod

    print(dp[h - 1][w - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 51184
N = int(input())
A = [int(_) for _ in input().split()]
B = [abs(a) for a in A]
absmaxv = -1
absmaxi = -1
for i, v in enumerate(B):
    if v > absmaxv:
        absmaxi, absmaxv = i, v
print(2 * N)
if A[absmaxi] > 0:
    print(absmaxi + 1, 1)
    print(absmaxi + 1, 1)
    for i in range(1, N):
        print(i, i + 1)
        print(i, i + 1)
else:
    print(absmaxi + 1, N)
    print(absmaxi + 1, N)
    for i in range(N, 1, -1):
        print(i, i - 1)
        print(i, i - 1)


Measured memory_bytes: 3064
#include <cstdio>
using namespace std;

int main(){
	bool prime[1000000];
	int n, p, res;
	
	while(true){
		scanf("%d", &n);
		if(n == 0) break;
		
		p = 2; res = 0;
		for(int i = 0; i < 1000000; i++) prime[i] = true;
		for(int i = 0; i < n; i++){
			while(!prime[p]) p++;
			res += p;
			for(int j = p; j < 1000000; j += p){
				prime[j] = false;
			}
			p++;
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 2004
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int a[100001],f[100001];

int main(){
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;++i)
		scanf("%d",&a[i]);
	f[2]=abs(a[1]-a[2]);
	for(int i=3;i<=N;++i){
		f[i]=min(f[i-1]+abs(a[i-1]-a[i]),f[i-2]+abs(a[i-2]-a[i]));
	}
	printf("%d\n",f[N]);
	return 0;
}

Measured memory_bytes: 1024
n, m = [int(x) for x in input().split()]
items = tuple(int(x) for x in input().split())
threshould = sum(items) / 4 / m
chosen = 0
for i in items:
    if i >= threshould:
        chosen += 1
    if chosen >= m:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string,int>ma; 
int main()
{
	int n;
	scanf("%d",&n);
	char last;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		int len=s.length();
		if(i!=1)
		{
			if(s[0]!=last)
			{
				printf("No");
				return 0;
			}
		}
		last=s[len-1];
		if(ma[s]) 
		{
			printf("No");
			return 0;
		}
		else ma[s]=1;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	string s,t="ACTG";
	cin>>s;
	ll maxi=-1,hoge=0;
	for(int i=0;i<s.length();i++){
		ll pt=i;
		hoge=0;
		bool flag=true;
		while(flag){
			bool flag2=false;
			for(int k=0;k<t.length();k++){
				if(t[k]==s[pt])flag2=true;
				if(flag2)break;
			}
			if(flag2)hoge++;
			if(!flag2||pt==s.length()-1)break;
			pt++;
		}
		maxi=max(maxi,hoge);
	}
	cout<<maxi<<endl;

}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int n, a[333];

int main(){
    n = read();
    for (int i = 1; i <= n; i++){
        int x = read(), y = read();
        if (x == y)
            a[i] = 1;
    }
    for (int i = 3; i <= n; i++)
        if (a[i] && a[i-1] && a[i-2]){
            puts("Yes");
            return 0;
        }
    puts("No");
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <functional>
#include <iterator>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define SZ(x) ((int)x.size())
#define openfile {freopen("inp.txt","rt",stdin);freopen("out.txt","wt",stdout);}
#define debug 0

template <typename T> inline void next_int(T &x) {
	x = 0; char c; bool neg = false;
	while (!isdigit(c = getchar())) if (c == '-') neg = true;
	do x = x*10 + c - 48; while (isdigit(c = getchar()));
	if (neg) x = -x;
}

template <typename T> inline void write_int(T x, char last = 0) {
	if (x < 0) putchar('-'), x = abs(x);
	char tmp[20]; int cnt = 0;
	while (x >= 10) tmp[cnt++] = x % 10 + 48, x /= 10;
	tmp[cnt] = x + 48;
	FORD(i, cnt, 0) putchar(tmp[i]);
	if (last) putchar(last);
}

const ll base = (int)1e9+7;
ll n, dp[65][2][2][2];

int getbit(ll x, int idx) { return (x >> idx) & 1; }

ll solve(int i, int j, int k, int l) {
	if (i > 60) {
		if (!j) return !k && !l;
		return 0;
	}
	if (dp[i][j][k][l] != -1) return dp[i][j][k][l];
	ll &ret = dp[i][j][k][l];
	ret = 0;
	//0 and 0
	int nj = 0, nk = k, nl = l;
	if (j) {
		nj = 0;
		if (getbit(n, i) == 1) nk = k, nl = 0;
		else nk = 1, nl = l;
	} else {
		nj = 0;
		if (getbit(n, i) == 0) nk = k, nl = l;
		else nk = 0, nl = 0;
	}
	ret += solve(i + 1, nj, nk, nl), ret %= base;
	//(0 and 1) or (1 and 0)
	if (!j) {
		nj = 0;
		if (getbit(n, i) == 1) nk = k, nl = l;
		else nk = 1, nl = 1;
	} else {
		nj = 1;
		if (getbit(n, i) == 0) nk = k, nl = 1;
		else nk = 0, nl = l;
	}
	ret += solve(i + 1, nj, nk, nl), ret %= base;
	//1 and 1
	if (j) {
		nj = 1;
		if (getbit(n, i) == 1) nk = k, nl = 0;
		else nk = 1, nl = l;
	} else {
		nj = 1;
		if (getbit(n, i) == 0) nk = k, nl = l;
		else nk = 0, nl = 0;
	}
	ret += solve(i + 1, nj, nk, nl), ret %= base;
	return ret;
}

int main() {
	scanf("%lld", &n);
	memset(dp, -1, sizeof(dp));
	printf("%lld", solve(0, 0, 0, 0));
	return 0;
}


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

long power(long base, int exponent){
    if(exponent % 2){
        return power(base, exponent - 1) * base % long(1e9 + 7);
    }else if(exponent){
        long root_ans = power(base, exponent / 2);
        return root_ans * root_ans % long(1e9 + 7);
    }else{
        return 1;
    }
}

vector<long> factorial{1};

long combination(int n, int r){
    return factorial[n] * power(factorial[r], 1e9 + 5) % long(1e9 + 7) * power(factorial[n - r], 1e9 + 5) % long(1e9 + 7);
}

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for(int i = 1; i <= 2e5; i++){
        factorial.push_back(factorial.back() * i % long(1e9 + 7));
    }
    long ans = 0;
    for(int i = 0; i < min(H - A, W - B); i++){
        ans += combination(H - A + B - 1, B + i) * combination(W - B + A - 1, A + i);
        ans %= long(1e9 + 7);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<string.h>

int search(int arr[], int n, int x);
void mergeSort(int arr[], int l, int r);
void merge(int arr[], int l, int m, int r);


int main(void){
	char n[1001];
	scanf("%s", n);
	int len = strlen(n);
	if(n[len-1]=='s'){
	    printf("%ses", n);
	}
	else{
	    printf("%ss", n);
	}
}

int search(int arr[], int n, int x)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == x)
            return i;
    return -1;
}

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        }
        else {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1) {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2) {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r) {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l + (r - l) / 2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m + 1, r);

        merge(arr, l, m, r);
    }
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using l = long long;
using P = pair<int,int>;
int main(){
  int n;
  scanf("%d",&n);
  if(30<=n) printf("Yes");
  else printf("No");
    return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename W>
struct N008 {
   typedef std::vector<long> LI;
   typedef std::vector<W>    LW;
   long n, e;
   const LI &ss, &ds;
   const LW &ws;
   std::vector<LI> fi;
   std::vector<LI> ri;
   N008(long n_, const LI& ss_, const LI& ds_, const LW& ws_)
      : n(n_), e(ss_.size()), ss(ss_), ds(ds_), ws(ws_) {
      ri.resize(n+1);
      fi.resize(n+1);
      for(long i = 0; i < e; ++i) {
         fi[ss[i]].push_back(i);
         ri[ds[i]].push_back(i);
      }
   }
};

template<typename W>
struct N010 {
   typedef std::vector<long> LI;
   const N008<W>& g;
   LI xs, ys;
   long id;
   N010(const N008<W>& g_) : g(g_), xs(g.n+1, -1), id(0) {
      for(long i = 0; i < g.n + 1; ++i) dfs(i);
      std::reverse(ys.begin(), ys.end());
   }
   void dfs(long t) {
      if( xs[t] != -1 ) return;
      for(long i : g.fi[t]) {
         long to = g.ds[i];
         dfs(to);
      }
      if( xs[t] == -1 ) xs[t] = id, id += 1, ys.push_back(t);
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long v, e;
      scan(v, e);
      std::vector<long> ss(e), ds(e), ws(e);
      for(long i = 0; i < e; ++i) {
         scan(ss[i], ds[i]);
      }
      N008<long> g(v, ss, ds, ws);
      N010<long> topsort(g);
      for(long y : topsort.ys) {
         if( y < v ) printf("%ld\n", y);
      }
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll P, Q, R;

    cin >> P >> Q >> R;

    cout << min({P + Q, Q + R, R + P}) << endl;

    return 0;
}

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

int main() {
    ll n, ans = 0;;
    cin >> n;

    if((n%2) != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll q = 5;
    while(q <= n) {
        ans += n/(2*q);
        q *= 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137A
{
	class Program
	{
		static void Main(string[] args)
		{

			string[] n = Console.ReadLine().Split(' ');
			int a = int.Parse(n[0]);
			int b = int.Parse(n[1]);
			int s = 0;

			if ((a + b) >= (a - b) && (a + b) >= (a * b))
				Console.WriteLine(a + b);

			else if ((a - b) >= (a + b) && (a - b) >= (a * b))
				Console.WriteLine(a - b);

			else
				Console.WriteLine(a * b);
		}
	}
}


Measured memory_bytes: 13140
N = int(input())
H = tuple(map(int, input().split(' ')))

max_move = 0

move = 0
for h1, h2 in zip(H, H[1:]):
    if h1 >= h2:
        move += 1
    else:
        move = 0
    max_move = max(max_move, move)

print(max_move)


Measured memory_bytes: 14352