akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define pq priority_queue
#define MZ 1000000007

int nums[30][200005];
int init[30];
int num[30];

int main()
{
    init[0]=1;
    for(int i=1;i<29;i++)
        init[i]=init[i-1]*2;
    int n,now,temp,l,r,mid,ans=0,gl,gr;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&now);
        temp=0;
        for(int j=0;j<29;j++)
        {
            temp+=(now%2)*init[j];
            nums[j][i]=temp;
            now/=2;
        }
    }
    for(int i=0;i<29;i++)
        sort(nums[i],nums[i]+n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&now);
        temp=0;
        for(int j=0;j<29;j++)
        {
            temp+=(now%2)*init[j];
            if(temp+nums[j][n-1]>=init[j] && temp+nums[j][0]<2*init[j])
            {
                l=0;
                r=n-1;
                while(l!=r)
                {
                    mid=(l+r)/2;
                    if(temp+nums[j][mid]>=init[j])
                        r=mid;
                    else
                        l=mid+1;
                }
                gl=l;
                if(temp+nums[j][n-1]<2*init[j])
                    gr=n;
                else
                {
                    l=0;
                    r=n-1;
                    while(l!=r)
                    {
                        mid=(l+r)/2;
                        if(temp+nums[j][mid]>=2*init[j])
                            r=mid;
                        else
                            l=mid+1;
                    }
                    gr=l;
                }
                num[j]+=gr-gl;
            }
            if(temp+nums[j][n-1]>=3*init[j])
            {
                l=0;
                r=n-1;
                while(l!=r)
                {
                    mid=(l+r)/2;
                    if(temp+nums[j][mid]>=3*init[j])
                        r=mid;
                    else
                        l=mid+1;
                }
                num[j]+=n-l;
            }
            now/=2;
        }
    }
    for(int i=0;i<29;i++)
    {
        if(num[i]%2)
            ans+=init[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 22912
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int ans = t;
    rep(i,n-1){
        int time = a[i+1]-a[i];
        ans += min(t,time);
    }
    cout << ans;
}

Measured memory_bytes: 4040
X, N = map(int, input().split())
P = set(map(int, input().split()))

d = 10 ** 9
ans = 0
for i in range(120):
    if (i in P):
        continue
    if (abs(X - i) < d):
        ans = i
        d = abs(X - i)
print(ans)

Measured memory_bytes: 9112
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int s[200005];
    while(~scanf("%d",&n))
    {
        int a,b,c[200005];
        for(int i=0; i<n; i++)
        {
            scanf("%d",&s[i]);
            c[i]=s[i];
        }
        sort(s,s+n);
        a=s[n/2-1],b=s[n/2];
        for(int j=0; j<n; j++)
        {
            if(c[j]<=a)
            {
                printf("%d\n",b);
            }
            else if(c[j]>a)
            {
                printf("%d\n",a);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

map<string,int> name;
vector<string> x[40];
vector<int> v[40];
vector<int> pow(40), res(41);
int n;
ll ans;

void dfs(int pos, ll bit, ll score){
    ans = max(ans, score);
    if(pos == n)    return;
    if(score + res[pos] <= ans)    return;
    ll tmp = 1ll<<pos;
    for(int x : v[pos])  tmp += 1ll<<x;
    if(((bit>>pos)&1) == 0)    dfs(pos+1, bit|tmp, score+pow[pos]);
    dfs(pos+1, bit, score);
}

int main(){
    while(cin >> n, n){
        name.clear();
        for(int i = 0; i < n; i++)  v[i].clear(), x[i].clear();
        for(int i = 0; i < n; i++){
            string s;
            int c;
            cin >> s >> pow[i] >> c;
            name[s] = i;
            while(c-- > 0){
                string t;   cin >> t;
                x[i].push_back(t);
            }
        }
        for(int i = 0; i < n; i++){
            for(string s : x[i])    v[i].push_back(name[s]);
        }
        ans = 0;
        res[n] = 0;
        for(int i = n-1; i >= 0; i--)   res[i] = res[i+1]+pow[i];
        ll start = 1;
        for(int x : v[0])    start += 1ll<<x;
        dfs(1, start, pow[0]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           string ns="";
           int n=s.size();
           rep(i,0,n-1){
             if(s[i]=='B'&&s[i+1]=='C'){
              ns+='D';
               i++;
             }
             else{
              ns+=s[i]; 
             }
           }
           //cout<<ns<<endl;
           ll ans=0;
           int m=ns.size();
           ll cnt=0;
           rep(i,0,m){
             if(ns[i]=='A'){
              cnt++; 
             }
             else if(ns[i]=='D'){
              ans+=cnt; 
             }
             else{
              cnt=0; 
             }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3908
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int i,j,k;
	int N,M,T;
	set<int> s;
	cin >> N;
	k = 1;
	for(i=0;i<N;++i)
	{
		cin >>  j;
		if(s.find(j) != s.end())
			k = 0;
		s.insert(j);
	}
	cout << (k?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 9600
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {
        n: usize,
        a: [u32; n],
    }
    println!("{}", if a.iter().filter(|&x| *x%2!=0).count() > 0 {"first"} else {"second"});
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  map<int, int> m;
  REP(i, N) m[A[i]] = i;

  sort(ALL(A));

  int ans = 0;
  REP(i, N){
    if(i%2 != m[A[i]]%2) ans++;
  }

  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 7296
def solve():
    N, K = map(int, input().split())
    S = input()
    
    cur = S[0]
    start = [0]
    end = []
    for i, char in enumerate(S):
        if cur == '0' and char == '1':
            start.append(i)
        elif cur == '1' and char == '0':
            end.append(i)
        cur = char
    end.append(len(S))
    
    ans = 0
    for s, e in zip(start, end[K+int(S[0])-1:]):
        ans = max(ans, e - s)
    if ans == 0:
        ans = len(S)
    print(ans)


if __name__ == '__main__':
    solve()


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

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

    long long n, p;
    cin >> n >> p;
    
    map<long long, long long> mp;

    // 素因数分解
    long long tmp = p;
    for(long long i = 2; i * i <= p; i++){
        while(tmp % i == 0){
            mp[i]++;
            tmp /= i;
        }
    }

    mp[tmp]++;

    long long ans = 1;
    for(auto x : mp){
        for(int i = 0; i < x.second / n; i++){
            ans *= x.first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

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

int main() {
    string s;
    cin >> s;
    ll ans=0;
  	ll m=0;
  	rep(i,3) {
      if (s[i] == 'R') {
        m++;
        updatemax(ans, m);
      } else {
        updatemax(ans, m);
        m = 0;
      }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Sz size
#define Ins insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
ll f[105][105][2];
ll h[105];
ll pw(ll a,ll b)
{
	if(b==1)return a;
	if(b==0)return 1;
	ll t=pw(a,b/2);
	if(b&1)return t*t*a%LMOD;
	return t*t%LMOD;
}
ll K(ll l,ll r,ll bt)
{
	//cout<<l<<" "<<r<<" "<<bt<<endl;
	ll mn=BIGER;
	for(ll i=l;i<r;i++)
	{
		//mn=min(mn,h[i]);
		if(h[i]!=h[i+1])
		{
			for(ll i=l;i<=r;i++)mn=min(mn,h[i]);
			ll g=0;
			for(ll i=l;i<=r;i++)if(h[i]==mn)g++;
			ll lq=l,rq=l,res[2];
			res[0]=2;
			res[1]=1;
			while(lq<=r)
			{
				//cout<<">"<<lq<<" "<<rq<<" "<<l<<" "<<r<<" "<<mn<<endl;
				while(lq<=r&&h[lq]==mn)lq++,rq++;
				while(rq<=r&&h[rq]>mn)rq++;rq--;
				if(lq<=r)
				{
					K(lq,rq,mn+1);
					res[0]=res[0]*f[lq][rq][0]%MOD;
					res[1]=res[1]*(f[lq][rq][0]*2+f[lq][rq][1])%MOD;
				}
				rq++;
				lq=rq;
			}
			//cout<<"!"<<res[1]<<" "<<res[0]<<"!"<<endl;
			res[1]=res[1]*pw(2,g)%MOD;
			res[1]=(res[1]+MOD-res[0])%MOD;
			res[0]=res[0]*pw(2,mn-bt)%MOD;
			f[l][r][0]=res[0];
			f[l][r][1]=res[1];
			return 0;
		}
	}
	//cout<<"!";
	f[l][r][1]=(pw(2,r-l+1)+MOD-2)%MOD;
	f[l][r][0]=pw(2,h[l]-bt+1)%MOD;
	//cout<<"!";
	return 0;
}
int main()
{
	ll n;
	Sf("%lld",&n);
	for(ll i=1;i<=n;i++)
	{
		Sf("%lld",&h[i]);
	}
	K(1,n,1);
	cout<<(f[1][n][0]+f[1][n][1])%MOD<<endl;
	/*
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			cout<<f[i][j][0]<<","<<f[i][j][1]<<" ";
		}
		cout<<endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 384
import numpy as np

N,X,M = list(map(int, input().split()))

ans = 0

check = np.zeros(M+1, dtype = int)
suuretu = []

#print(check)

for i in range(N):
    if(check[X] == 1):
        detatoko = suuretu.index(X)
        loop_sum = sum(suuretu[detatoko:])
        loop_kaisu = i - detatoko
#        print(loop_sum, loop_kaisu)

        plus_kaisu = (N - i) // loop_kaisu
        mod_plus = (N - i) % loop_kaisu

#        print(plus_kaisu, mod_plus)
        ans += loop_sum * plus_kaisu
        ans += sum(suuretu[detatoko:detatoko+mod_plus])
        break


    else:
        check[X]  = 1

    ans += X
    suuretu.append(X)

#    if(X == 0):
#        break

#    if(X == 1):
#        ans += N - 1 - i
#        break
    X = (X * X) % M

#print(check)
print(ans)
#print(suuretu)


Measured memory_bytes: 29796
#include<bits/stdc++.h>
using namespace std;
#define int long long
int inf=1e18;

struct graph{

struct edge{int to,cst;};
struct pos{int i,d;
	pos(){};
	pos(int i_,int d_){i=i_,d=d_;};
	bool operator<(const pos& r)const{return d>r.d;}
};


vector<vector<edge>>g;
vector<bool>used;
int n;
int o;
vector<int>dist;
priority_queue<pos> pq;

	graph(){};
	graph(int n_,int o_){
	n=n_,o=o_;
	g.resize(n);
	used.assign(n,false);
	dist.resize(n,inf);
	};

	void add_edge(int x,int y,int cst){
		g[x].push_back(edge({y,cst}));
		g[y].push_back(edge({x,cst}));
	}

	void set_dist(){
		dist[o]=0;
		 pq.push(pos(o,0));
		while(!pq.empty()){
			pos x=pq.top();pq.pop();
			if(dist[x.i]<x.d)continue;
			for(auto&& w:g[x.i]){
				if(dist[w.to]> x.d+w.cst){
					dist[w.to]=x.d+w.cst;
					pq.push(pos(w.to,dist[w.to]));
				}
			} 
		}	
	}

};


signed main(){
	int n,m,s,t;cin>>n>>m>>s>>t;s--;t--;
	graph g1(n,s),g2(n,t);
	for(int i=0;i<m;i++){
		int x,y,a,b;cin>>x>>y>>a>>b;x--;y--;
		g1.add_edge(x,y,a);
		g2.add_edge(x,y,b);
	}
	g1.set_dist();
	g2.set_dist();	
	int money=1e15;
	int cst=inf;
	vector<int>cs(n);
	for(int i=n-1;i>=0;i--){
		cst=min(cst,g1.dist[i]+g2.dist[i]);
		cs[i]=cst;
	}
	for(auto&& w:cs)cout<<money-w<<endl;
}


Measured memory_bytes: 20216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b;
  cin >> a >> b;
  if(a == 1) a+= 13;
  if(b == 1) b += 13;
  if(a == b) cout << "Draw" << endl;
  else if(a > b) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 256
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Matrix.zero(n, m + 1)
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[i, j] = b[j]
  end
end
1.upto(m) do |j|
  if (a.column(j).covector * Vector.elements(Array.new(n, 1)))[0] < x
        puts "-1"
    exit
  end
end
min = Float::INFINITY
[0, 1].repeated_permutation(n) do |bit|
  ans = 0
  sum = 0
  1.upto(m) do |j|
    sum = 0
    n.times do |i|
      if bit[i] == 1
        sum += a[i, j]
      end
    end
    break if sum < x
  end
  if sum >= x
    n.times do |i|
      if bit[i] == 1
        ans += a[i, 0]
      end
    end
    min = ans if min > ans
  end
end
puts min

Measured memory_bytes: 15160
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(void){
  int ans = 700;
  for(int i = 0; i < 3; i++){
    char c;
    cin >> c;
    if(c == 'o') ans += 100;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    while(N--) {
        int a;
        cin >> a;
        if(a%2) {
            cnt1++;
        } else if(a%4) {
            cnt2++;
        } else {
            cnt4++;
        }
    }

    if(cnt2 == 0) {
        if(cnt1 <= cnt4+1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if(cnt1 <= cnt4) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> h(N); REP(i,N) cin >> h[i];
    SORT(h);
    ll ans = LL_INF;
    REP(i,N-K+1){
        chmin(ans, h[i+K-1]-h[i]);
    }
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main(){
	int a[999999]={0},i,j;
	a[1]=1;
	for(i=2;i<=999999;i++){
		if(a[i]==0)for(int j=i*2;j<=999999;j+=i)a[j]=1;}
	int n;
	while(~scanf("%d",&n)){
		int sum=0;
		for(i=1;i<=n;i++){
			if(a[i]==0)sum++;}
		printf("%d\n",sum);}
	return 0;}


Measured memory_bytes: 6552
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e9 + 7, N = 5100;

int n, m, p[N], fa[N], sz[N];
ll f[N];
vector<int> a;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int find(int x) {
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}

inline void unite(int x, int y) {
	x = find(x), y = find(y);
	if (x == y) return;
	fa[x] = y, sz[y] += sz[x];
	return;
}

int main() {
	read(n), m = n;
	for (R int i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;
	for (R int i = 1; i <= n; ++i) {
		read(p[i]);
		if (p[i] != -1) unite(i, p[i]);
	}
	int sum = 0;
	for (R int i = 1; i <= n; ++i) {
		if (fa[i] != i) continue;
		if (p[i] == -1) a.push_back(sz[i]), sum += sz[i];
		--m;
	}
	if (!a.size()) {
		cout << m * quickpow(n - 1, a.size()) << endl;
		return 0;
	}
	int cur = 0;
	ll ans = ((n * a.size() - sum) * quickpow(n - 1, a.size() - 1) + m * quickpow(n - 1, a.size())) % mod;
	f[0] = 1;
	for (auto &v : a) {
		++cur;
		ll s = 0, w = quickpow(n - 1, a.size() - cur);
		for (R int i = cur; i; --i) {
			s = (s + f[i] * w) % mod;
			f[i] = (f[i] + f[i - 1] * v % mod * i) % mod;
			if (i != cur) w = w * (n - 1) % mod;
		}
		ans = (ans - s * v % mod + mod) % mod;
	}
	cout << ans << endl;
	return 0;
}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void dfs(int a, const vector<vector<int>>& fri, vector<bool>& vis, vector<int>& cc) {
        vis[a] = 1;
        cc.emplace_back(a);
        for (auto b: fri[a]) {
                if (!vis[b]) dfs(b, fri, vis, cc);
        }
}


void _main() {
        int n, m, k; cin >> n >> m >> k;
        vector<vector<int>> fri(n+1), block(n+1);
        while (m--) {
                int a, b; cin >> a >> b;
                fri[a].emplace_back(b);
                fri[b].emplace_back(a);
        }

        while (k--) {
                int a, b; cin >> a >> b;
                block[a].emplace_back(b);
                block[b].emplace_back(a);
        }

        for (int i = 1; i <= n; i++) {
                sort(all(fri[i])), sort(all(block[i]));
        }


        vector<bool> vis(n+1);
        vector<ll> ans(n);
        for (int from = 1; from <= n; from++) {
                if (vis[from]) continue;
                vector<int> cc;
                dfs(from, fri, vis, cc);
                sort(all(cc));
                for (auto u: cc) {
                        ans[u-1] += sz(cc) - sz(fri[u]) - 1;
                        for (auto b: block[u]) {
                                if (binary_search(all(cc), b) && !binary_search(all(fri[u]), b)) ans[u-1]--;
                        }
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 16680
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if H[N-1-i] < H[N-1-i-1]:
        H[N-1-i-1] -= 1

imp = 0
for i in range(1,N):
    if H[i] < H[i-1]:
        imp += 1

if imp == 0:
    print('Yes')
else:
    print('No')



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

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            var X = imp[0];
            var Y = imp[1];
            int x = 0;
            int y = 0;
            if ((X == "A"))
            {
               x = 10;
            }
            if ((X == "B"))
            {
                x = 11;
            }
            if ((X == "C"))
            {
               x = 12;
            }
            if ((X == "D"))
            {
                x = 13;
            }
            if ((X == "E"))
            {
                x = 14;
            }
            if ((X == "F"))
            {
                 x = 15;
            }


            if ((Y == "A"))
            {
                 y = 10;
            }
            if ((Y == "B"))
            {
                y = 11;
            }
            if ((Y == "C"))
            {
                 y = 12;
            }
            if ((Y == "D"))
            {
                 y = 13;
            }
            if ((Y == "E"))
            {
                y = 14;
            }
            if ((Y == "F"))
            {
              y = 15;
            }



            if (x < y)
            {
                Console.Write("<");

            }
            if (x > y)
            {
                Console.Write(">");
            }

            if (x == y)
            {
                Console.Write("=");
            }
        }
    }
}

Measured memory_bytes: 13140
n=int(input())
A=[int(i) for i in input().split()]
T=[]

flg=-1
for i in range(n-1):
    if A[i]<A[i+1] and flg==-1:
        flg=1
        T.append(A[i])
    elif A[i]>A[i+1] and flg==1:
        flg=-1
        T.append(A[i])

if A[-2]<=A[-1]:
    T.append(A[-1])

kab=0
mon=1000

for i in range(len(T)):
    if i%2==0:
        kosuu=mon//T[i]
        kab+=kosuu
        mon-=kosuu*T[i]
    else:
        mon+=kosuu*T[i]
        kab=0

if len(T)>0:
    mon+=kab*T[i]

print(mon)

Measured memory_bytes: 9168
#include<iostream>
#include<complex>
#include<cstdio>
using namespace std;
typedef complex<double> Point;
typedef complex<double> Vector;
 
#define EPS 0.00001
 
Point A, B, C;
 
void getR(double alpha, double beta, double l, double r, double R, double &ans, bool &suc){
    double a, b, c;
    a = 1.0/((tan(beta)*tan(beta)));
    b = 2*r/(tan(alpha)*tan(beta)) - 2*l/tan(beta) - 4*r;
    c = l*l - 2*r*l/tan(alpha) + r*r/(tan(alpha)*tan(alpha));
    double rr1 = (-b - sqrt(b*b-4*a*c))/(2*a);
    double rr2 = (-b + sqrt(b*b-4*a*c))/(2*a);
    suc = false;
    if ( 0 <= rr1 && rr1 <= R ) { ans = rr1; suc = true;}
    if ( 0 <= rr2 && rr2 <= R ) { ans = rr2; suc = true;}
}
 
void compute(){
    double a = abs(B - C), b = abs(A-C), c = abs(A-B), r1, r2, r3;
    double s = (a + b + c)/2.0;
    double R = sqrt(s*(s-a)*(s-b)*(s-c))/s;
    double X = acos((c*c + b*b - a*a)/(2*c*b));
    double Y = acos((c*c + a*a - b*b)/(2*c*a));
    double Z = acos((a*a + b*b - c*c)/(2*a*b));
    double l = 0, r = 2*R;
    bool suc1, suc2;
    while(1){
        r1 = (l + r)/2.0;
        getR(X/2, Y/2, c, r1, R, r2, suc1);
        getR(X/2, Z/2, b, r1, R, r3, suc2);
        Vector v1 = A - B;
        Vector v2 = A - C;
        v1 = polar(r2/sin(Y/2), arg(v1) - Y/2) + B; 
        v2 = polar(r3/sin(Z/2), arg(v2) + Z/2) + C; 
        double d = abs(v1 - v2);
        if ( fabs(d - (r2+r3)) < EPS ) break;
        if ( d < r2+r3 || !suc1 || !suc2) l = r1;
        else r = r1;
    }
     
    printf("%.5lf %.5lf %.5lf\n", r1, r2, r3);
}
 
main(){
    while(1){
    cin >> A.real() >> A.imag();
    cin >> B.real() >> B.imag();
    cin >> C.real() >> C.imag();
    if ( A.real() == 0 && A.imag() == 0 && 
         B.real() == 0 && B.imag() == 0 && 
         C.real() == 0 && C.imag() == 0 ) break;
    compute();
    }
}

Measured memory_bytes: 1420
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <iterator>
#include <map>
 
using namespace std;
 
int N;
vector<int> h;
vector<int> a;
vector<size_t> dp;
 
void update_max(int i, size_t val)
{ 
  for (; i < N; i = (i | (i+1)))
    dp[i] = max(dp[i], val);
}
 
size_t get_max(int r)
{ 
  size_t res = 0;
  for (; r >= 0; r = (r & (r+1)) - 1)
    res = max(res, dp[r]);
  return res;
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
 
  cin >> N;
 
  h.resize(N);
  a.resize(N);
 
  dp = vector<size_t>(N+1, 0);
 
  for (int i = 0; i < N; ++i)
  { 
    cin >> h[i];
  }
  for (int i = 0; i < N; ++i)
  { 
    cin >> a[i];
  }
  size_t res = 0;
 
  for (int i = 0; i < N; ++i)
  {
    size_t cur_max = get_max(h[i]-1);
    update_max(h[i], a[i] + cur_max);
    res = max(res, a[i] + cur_max);
  }
  cout << res << endl;
 
  return 0;
}

Measured memory_bytes: 6056
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int date = sc.nextInt(); //整数の入力
		System.out.print("Christmas");
		for (int x = date; x < 25; x++) {
			System.out.print(" Eve");
		}
		System.out.println();
	}
}

Measured memory_bytes: 20948
N = int(input()) + 1

memo = [0] * N
for i in range(N):
  if i == 0:
    memo[i] = 2
  elif i == 1:
    memo[i] = 1
  else:
    memo[i] = memo[i-1] + memo[i-2]

print(memo[N-1])

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b)System.out.print("a > b");
        else if(a < b)System.out.print("a < b");
        else{System.out.print("a == b");}
        System.out.println();
    }
}


Measured memory_bytes: 26140
#include "stdio.h"

int main(){
    int a[5];
    int i,j,k;
    int ret = 0;
    int min = 10;
    int minIndex = 0;
    scanf("%d",&a[0]);
    scanf("%d",&a[1]);
    scanf("%d",&a[2]);
    scanf("%d",&a[3]);
    scanf("%d",&a[4]);
    //1の位の最小を求める(0は除く)
    for(i=0;i<5;i++){   
        if (min > (a[i]-(a[i]/10)*10)){
            if (0 < (a[i]-(a[i]/10)*10)){
                min = (a[i]-(a[i]/10)*10);
                minIndex = i;
            }
        } 
    }
    //最後に頼む注文切り上げる
    for(i=0;i<5;i++){
        if (i != minIndex){
            a[i]= ((a[i]+9)/10)*10;
        }
        ret = ret + a[i];
    }
    printf("%d\n",ret);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int a,b;
    cin >> a >> b;
    REP(i,max(a,b))cout << min(a,b);
    cout << endl;
    return 0;
}

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

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

  int n;
  string s;
  cin >> n >> s;
  string ans = "No";
  if (n % 2 == 0) {
    n /= 2;
    if (s.substr(0, n) == s.substr(n, n)) ans = "Yes";
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
  long long ans = 0;
  int N, c = 0;
  cin >> N;
  vector<long long> A(N), dp0(N+1), dp1(N+1);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  dp0.at(0) = 0;
  dp1.at(0) = -1000000000000000000;
  for(int i = 0; i < N; i++) {
    dp0.at(i+1) = max(dp0.at(i) + A.at(i), dp1.at(i) - A.at(i));
    dp1.at(i+1) = max(dp1.at(i) + A.at(i), dp0.at(i) - A.at(i));
  }
  cout << dp0.at(N);
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a := getInts(3)
	sort.Ints(a)
	out(a[0] + a[1])
}


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

int main(){
    
    long long a, b, c, n, ii; //最小:a, 最大:b, 合計:c
    
    cin >> n;
    
    c = 0;
    
    a = 1000000;
    
    b = -1000000;
    
    for(int i = 0; i < n; i++){
        
        
        cin >> ii;
        
        
        c = c + ii;
        
        b = (b < ii) ? ii : b;
    
        a = (a > ii) ? ii : a;
    }
    

    
    
    
    cout << a << " " << b << " " << c << endl;
    return 0;
}


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

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<6;i++){
    if(s[i]=='1'){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int n,m;
vector<pair<int,int> > e[100010];
long long pos[100010];
bool vis[100010]; 

inline void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<e[x].size();i++)
	{
		pair<int,int> cur=e[x][i];
		if(vis[cur.first])
		{
			if(pos[cur.first]-pos[x]!=cur.second) {cout<<"No";exit(0);}
		}
		else
		{
			pos[cur.first]=pos[x]+cur.second;
			dfs(cur.first);
		}
	}
}

int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d;
		e[l].push_back({r,d});
		e[r].push_back({l,-d});
	}
	
	for(int i=0;i<n;i++) if(!vis[i]) dfs(i);
	
	cout<<"Yes";
	
	return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        ans += b;
    }
    vector<int> C(N - 1);
    for (auto& c : C) {
        cin >> c;
    }
    for (int i = 0; i < N - 1; i++) {
        if (A.at(i) + 1 == A.at(i + 1)) {
            ans += C.at(A.at(i) - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int n, i;
	int c4=0, c1=0;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		if(a%4==0) c4++;
		else if(a%2!=0) c1++;
	}
	if(c1+c4==n) puts(c1<=c4+1?"Yes":"No");
	else puts(c1<=c4?"Yes":"No");
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<ll> n;
};

Vertex V[100005];
bool U[100005];

int main()
{
    ll N, K;
    cin >> N >> K;
    REP(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].n.push_back(b);
        V[b].n.push_back(a);
    }

    memset(U, 0, sizeof(U));
    queue<ll> q;
    q.push(0);
    U[0] = true;

    ll ans = K;
    while (!q.empty())
    {
        ll t = q.front();
        q.pop();
        ll mul = K - 2;
        if (t == 0)
            mul++;
        REP(i, V[t].n.size())
        {
            ll n = V[t].n[i];
            if (U[n])
                continue;
            ans = (ans * std::max(0LL, mul--)) % MOD;
            U[n] = true;
            q.push(n);
        }
    }

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

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


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    
    ch += 1
    cw += 1
    dh += 1
    dw += 1
    
    
    s = ["#"*(w+4)]
    s.append("#"*(w+4))
    for i in range(h):
        s.append("##" + input()[:-1] + "##")
    s.append("#"*(w+4))
    s.append("#"*(w+4))
    
    
    ans = [[-1]*(w+4) for _ in range(h+4)]
    for i in range(h+4):
        for j in range(w+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ans[ch][cw] = 0
    
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    move2 = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), \
             (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), \
             (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), \
             (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), \
             (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]
        
    not_yet = deque([(ch, cw)])
    one_time = deque([])
    
    while len(not_yet) > 0:
        x, y = not_yet.popleft()
        one_time.append((x, y))
        for (p, q) in move:
            if ans[x+p][y+q] == -1:
                not_yet.append((x+p, y+q))
                ans[x+p][y+q] = ans[x][y]
                
        if len(not_yet) == 0:
            while len(one_time) > 0:
                x2, y2 = one_time.popleft()
                for (v1, v2) in move2:
                    i, j = x2+v1, y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        not_yet.append((i, j))
          
    print(ans[dh][dw])
    
    
    
if __name__ == "__main__":
    main()


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define all(x) (x).begin() ,(x).end()

const ll mod = 1e9 + 7;

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}
const int N = 1e5 + 5;
void solve() {

	int px , py;
	int n;
	cin >> n;

	bool ok = false;
	int cnt = 0;
	for (int i = 0 ; i < n ; i++) {
		int x , y;
		cin >> x >> y;

		if (x == y)
			cnt++;
		else
			cnt = 0;
		if (cnt == 3)
		{
			ok = true;
		}
	}

	if (ok)
		cout << "Yes\n";
	else
		cout << "No\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 3648
#include <stdio.h>
  
#define MAX 100000
#define N -1
  
struct Node{
  int y; 
  int l; 
  int r; 
};

void preorder(int);
void inorder(int);
void postorder(int);

 
struct Node T[MAX];
  
int main(){
  int i,j,a,b,n;
  
  scanf("%d",&n); 
  
  for(i=0;i<n;i++){
    T[i].y=N;
    T[i].l=N;
    T[i].r=N;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&a); 
  
    for(j=0;j<2;j++){
      scanf("%d",&b); 
  
      if(j==0){
    T[a].l=b;  
      } else {
    T[a].r=b;
      }
    T[b].y=a;       
    }
  }
  
  for(i=0;i<n;i++){
    if(T[i].y==N){
      a=i;
      break;
    }
  }
  
  printf("Preorder\n");
  preorder(a);
  printf("\nInorder\n");
  inorder(a);
  printf("\nPostorder\n");
  postorder(a);
  printf("\n");
   
  return 0;
}

void preorder(int x){
  
  printf(" %d",x);
  if(T[x].l!=N) preorder(T[x].l);
  if(T[x].r!=N) preorder(T[x].r);
  
}
  
void inorder(int y){
  
  if(T[y].l!=N) inorder(T[y].l);
  printf(" %d",y);
  if(T[y].r!=N) inorder(T[y].r);
}
  
void postorder(int z){ 
   
  if(T[z].l!=N) postorder(T[z].l);
  if(T[z].r!=N) postorder(T[z].r);
  printf(" %d",z);
  
}
 

Measured memory_bytes: 616
// Problem : D - Floor Function
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll a,b,n;
	cin >> a >> b >> n;
	n=min(n,b-1);
	cout << (a*n)/b << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int w[105], v[105];
ll dp[maxn];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    REP(i, n) scanf("%d%d", w + i, v + i);
    memset(dp, inf, sizeof(dp));
    dp[0] = 0;
    REP(i, n) for (int j = maxn; j > 0; j--) {
        if (j >= v[i]) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
    int ans = 0;
    REP(i, maxn) if (dp[i] <= k) ans = i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner reader=new Scanner(System.in);
		String s=reader.next();
		int total=0;
		if(s.charAt(0)=='1') total++;
		if(s.charAt(1)=='1') total++;
		if(s.charAt(2)=='1') total++;
		System.out.println(total);
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin >> s;
    for (char q: s){
        cout << (q == '?' ? 'D' : q);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
#include<ctype.h>
int main(void)
{
  char str[1200],*p,*q;
  int i;
gets(str);
 for(p=str ;*p;p++ ){
 if('A'<=*p && *p<='Z')
   {
     *p=tolower(*p);
   }
 else {*p=toupper(*p);}
 }
 printf("%s\n",str);
 
 return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,t;
    cin >> n >> t;
    vector<pair<ll,ll>> ab(n);
    for(i = 0;i < n;++i){
        cin >> ab.at(i).first >> ab.at(i).second;
    }
    sort(all(ab));
    vector<vector<ll>> dp(n+1,vector<ll>(t,0));
    for(i = 1;i <= n;++i){
        rep(j,t){
            if(j < ab.at(i-1).first) dp.at(i).at(j) = dp.at(i-1).at(j);
            else dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i-1).at(j - ab.at(i-1).first) + ab.at(i-1).second);
        }
    }
    ll ans = 0;
    for(i = n-1;i >= 0;--i){
        ans = max(ans, dp.at(i).at(t-1) + ab.at(i).second);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int n;
int a1[105];
int a2[105];
int suma1[105];
int suma2[105];
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a1[i];
  for(int i = 0; i < n; i++) cin >> a2[i];
  for(int i = 1; i <= n; i++) suma1[i] += a1[i-1] + suma1[i-1];
  for(int i = 1; i <= n; i++) suma2[i] += a2[i-1] + suma2[i-1];

  int ans = 0;

  for(int i = 1; i <= n; i++) {
    ans = max(ans,suma1[i] + suma2[n] - suma2[i-1]);
  }

  cout << ans << endl;
}

  
  


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int can1[210000];
int can2[210000];

int main()
{
  int i,j,n,m,x,y;
  scanf("%d%d",&n,&m);
  memset(can1,0,sizeof(can1));
  memset(can2,0,sizeof(can2));
  for (i=0;i<m;i++)
  {
    scanf("%d%d",&x,&y);
    if (x==1) can1[y]=1;
    if (y==n) can2[x]=1;
  }
  for (i=2;i<n;i++)
    if ((can1[i]==1)&&(can2[i]==1))
    {
      printf("POSSIBLE\n");
      return 0;
    }
  printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 1920