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

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

    string s;
    cin >> s;
    int k;
    cin >> k;

    int n = s.size();
    map<string, bool> mp;
    vector<string> T;
    for(char c = 'a'; c <= 'z'; c++){
        for(int i = 0; i < n; i++){
            string tmp = "";
            if(s[i] == c){
                for(int j = i; j < min(i + k, n); j++){
                    tmp += s[j];
                    if(!mp[tmp]){
                        T.push_back(tmp);
                        mp[tmp] = true;
                    }
                }
            }
        }
        if(T.size() >= k) break;
    }

    sort(T.begin(), T.end());
    cout << T[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 384
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    s = ns()
    print(s[:3])
    return


if __name__ == '__main__':
    main()

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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);
	
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int ans = 0;

	ans = min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans += -1 * min(c, k);

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<vector>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const int mx=90+10,mo=1000000007;
const ll inf=1000000000000000000;
ll fib[mx];
vector<pi> a[mx];
vector<pi>::iterator it;
ll x,y,n,m,num;
int i,j,k,l,t,tot,ca,ans;
int main(){
	fib[0]=fib[1]=1;
	tot=1;
	while (1){
		fib[tot+1]=fib[tot]+fib[tot-1];
		if (fib[tot+1]>inf) break;
		tot++;
	}
	a[1].pb(mp(1,2));a[1].pb(mp(1,3));a[1].pb(mp(1,4));
	fo(i,1,tot-3){
		it=a[i].begin();
		while (it!=a[i].end()){
			x=(*it).xx;y=(*it).yy;
			x+=y;
			while (x<=fib[i+3]+fib[i]){
				a[i+1].pb(mp(y,x));
				x+=y;
			}
			it++;
		}
	}
	scanf("%d",&ca);
	while (ca--){
		scanf("%lld%lld",&n,&m);
		if (n>m) swap(n,m);
		ans=1;
		while (fib[ans+1]<=n&&fib[ans+2]<=m) ans++;
		printf("%d ",ans);
		if (ans==1){
			printf("%lld\n",n*m%mo);
			continue;
		}
		else{
			num=0;
			it=a[ans-1].begin();
			while (it!=a[ans-1].end()){
				x=(*it).xx;y=(*it).yy;
				if (y<=n) (num+=(m-x)/y)%=mo;
				if (y<=m) (num+=(n-x)/y)%=mo;
				it++;
			}
			printf("%d\n",num);
		}
	}
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
ll d[100000];
ll A[100000];
int main(){
  ll N;
  cin >> N;
  ll sum = 0;
  REP(i,N){
    cin >> A[i];
    sum += A[i];
  }
  if(sum%(N*(N+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }
  ll k = sum/(N*(N+1)/2);
  d[0] = A[0] - A[N-1] - k;
  REPS(i,N-1) d[i] = A[i] - A[i-1] - k;
  bool ans = true;
  REP(i,N){
    if(d[i] > 0 || d[i]%N != 0){
      ans = false;
      break;
    }
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    string a;
    cin>>a;
    if(a=="Sunny")
    {
        cout<<"Cloudy";
    }else if(a=="Cloudy")
    {
        cout<<"Rainy";
    }else
    {
        cout<<"Sunny";
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include<cstring>
using namespace std;
int gcd(int a,int b,int &x,int &y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    int ans=gcd(b,a%b,x,y);
    int temp=x;
    x=y;
    y=temp-a/b*y;
    return ans;
}
int main()
{
    int s,n,y,flag=1;
    scanf("%d%d",&n,&s);
    s/=1000;
    for(y=0; y<=n; y++)
    {
        if((s-4*y-n)%9==0&&(s-4*y-n)/9>=0&&n-y-(s-4*y-n)/9>=0)
        {
            printf("%d %d %d",(s-4*y-n)/9,y,n-y-(s-4*y-n)/9);
            flag=0;
            break;
        }
    }
    if(flag) printf("-1 -1 -1");
    return 0;
}


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

int main(){
	int a,b,c;cin>>a>>b>>c;
	int ans=-2,cnt=0;
	int a1=a%2,b1=b%2,c1=c%2;
	if(a1==1 || b1==1 || c1==1)ans=0;
	if(ans==0)cout<<ans<<endl,exit(0);	
	int a0=a/2,b0=b/2,c0=c/2;
	if(a0==b0 && b0==c0){cout<<-1<<endl,exit(0);}
	while(true){	
	cnt++;
	a1=b0+c0,b1=c0+a0,c1=a0+b0;
	if(a1%2==1 || b1%2==1 || c1%2==1)break;
	a0=a1/2,b0=b1/2,c0=c1/2;

	}

	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }
ll MOD = 1000000007;

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> A(N), Ten(N, 0), Rank(N, 0);
	for (auto& a : A) cin >> a;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[j] > A[i]) {
				if(j<i)Ten[i]++;
				Rank[i]++;
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += Ten[i]*K;
		ans %= MOD;
		ans += Rank[i] * ((K * (K -1ll)/2) % MOD);
		ans %= MOD;
	}
	print(ans);


}


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

int has_no(string &str,bool arr[]){
	for(int i=0;i<str.length();i++){
		if(arr[str[i]-'0'])return false;
	}
	return true;
}
int main() {
	int num,n;
	cin>>num>>n;
	
	bool arr[10] ={};
	for(int i=0;i<n;i++){
		int n2;
		cin>>n2;
		arr[n2] =true;
	}
	for(int j=num;j<100000;j++){
		string str =to_string(j);
		if(has_no(str,arr)){
			cout<<str<<endl;
			break;
		}
	}
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
     
    int a,b,i;
    cin>>a>>b;
    for(i=1;i<=3;++i)
     {
         if((a*b*i)%2==1)
           break;
     }
     
     if(i==4)
        cout<<"No";
        
     else
       cout<<"Yes";
    
    
	return 0;
	
} 

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define VV(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int a, b, c; cin >> a >> b >> c;
	int cnt = 0;
	rep(i, a, b + 1) {
		if(c % i == 0) ++cnt;
	}
	P(cnt);
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int N, K, C;
void calc(vint &dat, string S) {
	ll prev = -INF;
	ll cnt = -1;
	for (int i = 0; i < S.size(); i++) {
		if (i-prev > C && S[i] == 'o') {
			cnt++;
			prev = i;
		}
		if (S[i] == 'o') {
			dat[i] = cnt;
		}
	}
}

void Main() {
	cin >> N >> K >> C;
	string S; cin >> S;
	vint left(N, -1), right(N, -1);

	calc(left, S);
	reverse(begin(S), end(S));
	calc(right, S);
	reverse(begin(right), end(right));
	
	map<int, vint> mp;
	for (int i = 0; i < N; i++) {
		//cout << left[i] << " " << right[i] << endl;
		if (left[i] + right[i] >= K) {
			return;
		}
		if (left[i] + right[i] == K-1) {
			mp[left[i]-right[i]].push_back(i);
		}
	}
	
	for (auto &v : mp) {
		if (v.second.size() == 1) {
			cout << v.second[0]+1 << el;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main(void) {
    string S, T;
    cin >> S >> T;

    int s = S.size();
    int t = T.size();

    bool result = true;
    if ((s+1) != t) result = false;
    if (S != T.substr(0, S.size())) result = false;

    if (true  == result) cout << "Yes" << endl;
    if (false == result) cout << "No"  << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int s,t;
int color[100];
bool cycle = false;
int M[100][100];

void DFS(int u){
    color[u] = GRAY;
    for(int v = 0; v < s; v++){
        if(M[u][v] == 0) continue;
        if(color[v] == GRAY){
            cycle = true;
            return;
        }
        if(color[v] == WHITE) DFS(v);
    }
    color[u] = BLACK;
}

int main(){
    int u,v;
    scanf("%d %d",&s, &t);
    for(int i = 0; i < s; i++){
        color[i] = WHITE;
        for(int j = 0; j < s; j++){
            M[i][j] = 0;
        }
    }
    for(int i = 0; i < t; i++){
        scanf("%d %d", &u, &v);
        M[u][v] = 1;
    }
    for(int i = 0; i < s; i++){
        if(color[i] == WHITE) DFS(i);
        if(cycle){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    
    return 0;
}


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

// 二部グラフ判定
vector<int> color;
void dfs(const Graph &G,int v,int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        // 隣接頂点がすでに色確定していた場合
        if (color[next_v.first] != -1) {
         
            //if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
            continue;
        }else{
          if(next_v.second%2==0)
            dfs(G,next_v.first,cur);
          else
            dfs(G,next_v.first,1-cur);
        }

        // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
       // if (!dfs(G, next_v , 1 - cur)) return false;
    }
    //return true;
}

int main(){

  int n,a,b,c;
  cin >> n;
   Graph G(n);

  //cout << "a" << endl;
  rep(i,n-1){
    cin >> a >> b >> c;
    pair<int, int> p(a-1,c);
    //cout << "a" << endl;
    G[b-1].push_back(p);
    p.first=b-1;
    G[a-1].push_back(p);
    //cout << "a" << endl;
  }
  //cout << "a" << endl;
   // 探索
    color.assign(n, -1);
   
    for (int v = 0; v < n; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        dfs(G, v);
    }
//cout << "a" << endl;
  rep(i,n)
    cout << color.at(i) << endl;
}

Measured memory_bytes: 11116
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	ll i,j,k,l,m,n,x,y,z,a,b,c;
 
	ll d,t,s;

	cin >> d >> t >> s;
 
	if(d <= s*t)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
	
 
}

Measured memory_bytes: 3656
def solve(n, h):
    cnt = 0
    best = 0
    for i in range(1, n):
        if h[i-1] < h[i]:
            cnt = 0
            best = max(cnt, best)
        else:
            cnt += 1
        best = max(cnt, best)
    return best

n = int(input())
h = list(map(int, input().split()))
print(solve(n, h))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n;
	 cin>>n;
	 int arr[n],i,j,k;
     int brr[n];
     for(i=0;i<n;i++)
     cin>>arr[i];
     brr[0]=0;
     brr[1]=brr[0]+abs(arr[1]-arr[0]);
     for(i=2;i<n;i++)
     brr[i]=min(brr[i-1]+abs(arr[i]-arr[i-1]),brr[i-2]+abs(arr[i]-arr[i-2]));
     cout<<brr[n-1];
     return 0;
}

Measured memory_bytes: 1024
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + [int(input()) for _ in range(N)]

    cnt = 1
    pushed = set([1])
    q = deque()
    q.append(1)
    while len(q) > 0:
        a = q.popleft()
        b = A[a]
        if b == 2:
            return cnt
        elif b in pushed:
            return -1
        else:
            pushed.add(b)
            cnt += 1
            q.append(b)


if __name__ == '__main__':
    print(main())


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

ll gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        gcd(b, a % b);
    }
}

void solve() {
    int A, B;
    cin >> A >> B;

    ll ans = ll(A) * B / gcd(A, B);
    print(ans);
}

signed main() {
    solve();
}


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


int main(void){
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            sum += v[i];
        } else {
            sum -= v[i];
        }
    }
    vector<int> v2(N);
    v2[0] = sum;
    for (int i = 1; i < N; i++) {
        v2[i] = (v[i - 1] - v2[i - 1] / 2) * 2; 
    }
    for (int i = 0; i < N - 1; i++) {
        cout << v2[i] << " ";
    }
    cout << v2[N - 1] << endl;
    
    
    return 0;
}

Measured memory_bytes: 2048
fc=->x,y{
  (1..y).reduce(1){|s,i|
    s*(x-y+i)/i
  }
}
f0=->d,x{
  fc[d,x]*9**x
}
f=->n,k{
  return 1 if k==0
  nstr=n.to_s
  d=nstr.size
  return 0 if d<k
  return n if d==1
  f0[d-1,k]+(nstr[0].to_i-1)*f0[d-1,k-1]+f[nstr[1..-1].to_i,k-1]
}
puts f[*$<.map(&:to_i)]

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

int main() {
  int n;string s;cin>>n>>s;
  int ans=0;
  rep(i,1000){
    string t;int x=i;
    rep(j,3){
      t+=(char)(x%10+'0');
      x/=10;
    }
    int cnt=0;
    rep(j,n){
      if(t[cnt]==s[j])cnt++;
      if(cnt==3){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTION ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll N;
	cin >> N;
	vector<ll> a(N), b(N), c(N);

	REP(i, N)cin >> a[i] >> b[i] >> c[i];

	//dp[x][i]:=x日目にiを選んだ時の幸福度の最大値 i{0,1,2}

	vector<vector<ll>> dp(N, vector<ll>(3, 0));

	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];


	FOR(x,1, N-1) {
		dp[x][0] = max(dp[x - 1][1] + a[x], dp[x - 1][2] + a[x]);
		dp[x][1] = max(dp[x - 1][0] + b[x], dp[x - 1][2] + b[x]);
		dp[x][2] = max(dp[x - 1][0] + c[x], dp[x - 1][1] + c[x]);
	}

	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;;









	return 0;
}


Measured memory_bytes: 11096
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

def main(N, A, B, S):
    if N == 1:
        return 2
    INF = 1 << 62
    S = np.append(S, INF)
    if A > B:
        A, B = B, A
    if np.min(S[2:] - S[:-2]) < A:
        return 0
    # A 未満でたどって、Xがどこまで置けるか
    X = np.zeros_like(S)
    for i in range(1, N + 1):
        if S[i] - S[i - 1] >= A:
            X[i] = X[i - 1]
        else:
            X[i] = i
    # 直前の Y としてありうる最も右
    Y = np.searchsorted(S, S - B, side='right') - 1
    dp = np.zeros_like(S)
    dp_cum = np.zeros_like(S)

    dp[0] = 1
    dp_cum[0] = 1
    for n in range(1, N + 1):
        if X[n - 1] == 0:
            # 初出の Y
            dp[n] = 1
        # 直前の Y の範囲
        l, r = max(0, X[n - 1] - 1), min(n - 1, Y[n])
        if l <= r:
            dp[n] += dp_cum[r] - dp_cum[l] + dp[l]
        dp[n] %= MOD
        dp_cum[n] = (dp_cum[n - 1] + dp[n]) % MOD
    return dp[-1]

signature = '(i8,i8,i8,i8[:],)'
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main

N, A, B = map(int, readline().split())
S = np.array(read().split(), np.int64)

print(main(N, A, B, S))

Measured memory_bytes: 35972
import java.util.Scanner;

public class Main {
//test3
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		long[] a = new long[n];
		
		int dirright = -1;
		int dirleft = -1;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			if(a[i] == 0)k--;
			
			if(a[i] > 0)
			{
				if(dirright == -1)dirright=i;
			}
			else if(a[i] < 0)
				dirleft = i;
		}
		if(k==0)
		{
			System.out.println(0);
			return;
		}
		
//		long[] costl = new long[k+1];
//		long[] costr = new long[k+1];
		long an = 99999999999999l;
		int curcan = 0;
		
		if(dirleft != -1)
		for(int i = dirleft; i >= 0 && curcan < k; i--)
		{ //assume we go here first... then go back
			curcan++;
			long curd = -a[i];
			if(curcan < k)
			{
				curd += -a[i];
				if(dirright != -1 && dirright + (k-curcan) - 1 < n)
				{
					curd += a[dirright + (k-curcan) - 1];
					an = Math.min(an, curd);
				}
			}
			else an = Math.min(an, curd);
		}
		curcan = 0;
		
		if(dirright != -1)
		for(int i = dirright; i < n && curcan < k; i++)
		{ //assume we go here first... then go back
			curcan++;
			long curd = a[i];
			if(curcan < k)
			{
				curd += a[i];
				if(dirleft != -1 && dirleft - (k-curcan) + 1 >= 0)
				{
					curd += -a[dirleft - (k-curcan) + 1];
					an = Math.min(an, curd);
				}
			}
			else an = Math.min(an, curd);
		}
		System.out.println(an);
	}

}


Measured memory_bytes: 48968
h, w, k = map(int, input().split())
X = [[1 if a == "#" else 0 for a in input()] for _ in range(h)]
ans = 0
for ii in range(1 << h):
  for jj in range(1 << w):
    if sum([sum([X[i][j] for j in range(w) if jj >> j & 1]) for i in range(h) if ii >> i & 1]) == k:
      ans += 1
print(ans)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i=0;i<n;++i)
    {
        if(i==k-1)
        {
            s[i] = s[i]-'A'+'a';
        }
        cout << s[i];
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    travel_plan = input()
    S = 0
    W = 0
    N = 0
    E = 0
    for t in travel_plan:
        if t == "S":
            S += 1
        elif t == "W":
            W += 1
        elif t == "N":
            N += 1
        else:
            E += 1
    
    if S*N == 0 and S+N != 0:
        print('No')
        return
    
    if W*E == 0 and W+E != 0:
        print('No')
        return
    
    print('Yes')
    return

if __name__ == '__main__':
    main()


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

typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef vector<P> pvec;
typedef vector<pvec> pmat;
typedef vector<int> vec;
typedef vector<vec> mat;

const int INF = 1 << 28;
int N, M, L, K, A, H;

void solve() {
    vec lf(L); for (auto &i : lf) cin >> i;
    lf.push_back(A);
    lf.push_back(H);

    mat wfroid(N, vec(N, INF));
    mat path(N, vec(N, INF));
    for (int i = 0; i < N; i++) wfroid[i][i] = 0;
    pmat v(N);
    for (int i = 0; i < K; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        v[x].push_back(P(y, z));
        v[y].push_back(P(x, z));
        wfroid[x][y] = wfroid[y][x] = z;
    }

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            for (int k = 0; k < N; k++) wfroid[j][k] = min(wfroid[j][k], wfroid[j][i] + wfroid[i][k]);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            if (wfroid[i][j] > M) wfroid[i][j] = INF;

    for (int i = 0; i < lf.size(); i++)
        for (int j = 0; j < lf.size(); j++)
            for (int k = 0; k < lf.size(); k++)
                wfroid[lf[j]][lf[k]] = min(wfroid[lf[j]][lf[k]], wfroid[lf[j]][lf[i]] + wfroid[lf[i]][lf[k]]);

    if (wfroid[A][H] == INF) cout << "Help!" << endl;
    else cout << wfroid[A][H] + max(0, (wfroid[A][H] - M)) << endl;
}

int main() {
    while (cin >> N >> M >> L >> K >> A >> H, N || M || L || K || A || H) solve();

    return 0;
}

Measured memory_bytes: 3148
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a * 500 + b * 100 + c * 50 == X:
        ans += 1
print(ans)

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long x = 0;
        long y = 0;
        long min;

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            y += a[i];
        }
        x = a[0];
        y -= a[0];
        min = Math.max(x, y) - Math.min(x, y);

        for (int i = 1; i < n - 1; i++) {
            x += a[i];
            y -= a[i];
            long tmp = Math.abs(x - y);
            if (min > tmp) {
                min = tmp;
            }
        }

        System.out.println(min);

    }
}

Measured memory_bytes: 64360
a,b=map(int,input().split())
l = list(map(int,input().split()))
dp = [0]*a
ep = [0]*a
s = 0
MOD = 10**9 + 7
for n,x in enumerate(l):
    for m,y in enumerate(l[n+1:]):
        if x > y:dp[n]+=1
    
for n,x in enumerate(l):
    for m,y in enumerate(l[:n]):
        if x > y:ep[n]+=1
for n,x in enumerate(dp):
    ep[n]+=x
# print(dp,ep)

s  = (sum(dp)*b)%MOD
s  += (sum(ep)*(b-1)*b//2)%MOD
print(s%MOD)


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            char[] disks = in.next().toCharArray();

            int black = 0;
            long ans = 0;
            for (char disk : disks) {
                if (disk == 'W') {
                    ans += black;
                } else {
                    black += 1;
                }
            }

            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 27060
/**
    Remember: sigma nx^(n-1), n = 1..inf equals 1/(1 - x^2) for |x| < 1.
*/

#include <cstdio>

int n, m;

int main()
{
    scanf("%d %d", &n, &m);
    printf("%d", (m * 1900 + (n - m) * 100) * (1 << m));
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (x, _) = readLine()!!.split(" ").map { it.toInt() }

    val buf = 150
    val arr = IntArray(300)

    readLine()!!.split(" ").forEach {
        val p = it.toIntOrNull() ?: run {
            println(x)
            return
        }

        arr[p + buf]++
    }

    val baseIndex = x + buf

    if (arr[baseIndex] == 0) {
        println(x)
        return
    } else {
        var diff = 1

        while (true) {
            if (arr[baseIndex - diff] == 0) {
                println(x - diff)
                return
            }

            if (arr[baseIndex + diff] == 0) {
                println(x + diff)
                return
            }
            diff++
        }
    }
}


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

using namespace std;
int main(){
  string s;
  int j=0;
  cin >> s;
  
  for(size_t i=0;i<s.size()-1;i++){
    if(s.at(i)==s.at(i+1)) j=1;
  }
  
  if(j==1) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll h, w;
	cin >> h >> w;
	if (h == 1 or w == 1)cout << 1 << endl;
	else if ((h * w) % 2 == 0)cout << h * w / 2 << endl;
	else cout << h * w / 2 + 1 << endl;
}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n)     for(int i=0;i<n;i++)
#define frr(i,n)    for(int i=1;i<=n;i++)

#define ms(x,i) memset(x,i,sizeof(x))
#define dbg(x)  cout << #x << " = " << x << endl
#define all(x)  x.begin(),x.end()

#define gnl cout << endl
#define chapa cout << "oi meu chapa" << endl
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
//cout << setprecision(9)<<fixed;

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

const int INF = 0x3f3f3f3f;
const ll llINF = (long long)(1e18) + 100;   
const int MAXN = 100100;
const int MAXM = 1001000;
const ll mod=1e9+7;
const int LMAXN = 25;

int main(){
	fastio;
	string s;
	int a, z;
	
	cin>>s;

	a = z = 0;
	for (a = 0; a < s.size(); a++)
		if (s[a] == 'A')
			break;

	for (z = s.size() - 1; z >= 0; z--)
		if (s[z] == 'Z')
			break;

	cout<< z - a + 1 <<endl;			

}

Measured memory_bytes: 720
n = input()
place_1 = 0
if len(n) == 1:
    place_1 = n[0]
elif len(n) == 2:
    place_1 = n[1]
else:
    place_1 = n[2]

p = int(place_1)
if p == 3:
    print('bon')
elif p == 0 or p == 1 or p == 6 or p == 8:
    print('pon')
else:
    print('hon')


Measured memory_bytes: 9164
#!/usr/bin/env python3

import array


P_NUM = 1000000007


def solv(n, m, a):
    comb = array.array('I', [1] * (n+1))
    for i in a:
        comb[i] = 0

    for i in range(2, n+1):
        comb[i] *= (comb[i-1] + comb[i-2]) % P_NUM

    return comb[-1]


if __name__ == '__main__':

    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]

    ans = solv(n, m, a)

    print(ans)


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

#define MOD (1.0e9 + 7)

using namespace std;

int main(void)
{
    long long int k;
    int n = 50;
    vector<long long int> a;

    for(int i = 0;i < n;i++)
	a.push_back(i);

    cin>>k;

    for(int i = 0;i < n;i++)
	a[i] += (n+1)*(k/n)-k;

    for(int i = 0;i < k % n;i++)
	a[i] += (n+1);

    cout<<n<<endl;
    for(int i = 0;i < n;i++)
    {
	cout<<a[i]<<" ";
    }
    

    return 0;
}


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

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, K, C, T[100100] = { 0 }, time = 0, pass = 0;

	cin >> N >> C >> K;
	for (i; i < N; i++)cin >> T[i];

	sort(T, T + N);
	for (i = 0; i <N-1; i++) {
		time += T[i+1] - T[i];
		pass++;
		if (time > K) {
			time = 0;
			pass = 0;
			ans++;
		}
		if (pass == C) {
			ans++;
			time = 0;
			pass = 0;
		}
	}

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

Measured memory_bytes: 1024
N, X, M = map(int, input().split())

visited = [False] * M

tmp = X
total_sum = X
visited[tmp] = True

total_len = 1
while True:
    tmp = (tmp ** 2) % M
    if visited[tmp]:
        loop_start_num = tmp
        break
    total_sum += tmp
    visited[tmp] = True
    total_len += 1

path_len = 0
tmp = X
path_sum = 0

while True:
    if tmp == loop_start_num:
        break
    path_len += 1
    path_sum += tmp
    tmp = (tmp ** 2) % M

loop_len = total_len - path_len
loop_sum = total_sum - path_sum


result = 0
if N <= path_len:
    tmp = X
    for i in range(N):
        result += X
        tmp = (tmp ** 2) % M
    print(result)
else:
    result = path_sum
    N -= path_len
    loops_count = N // loop_len
    loop_rem = N % loop_len
    result += loop_sum * loops_count
    tmp = loop_start_num
    for i in range(loop_rem):
        result += tmp
        tmp = (tmp ** 2) % M
    print(result)

# print("loop_start_num", loop_start_num)
# print("path_sum", path_sum)
# print("loop_sum", loop_sum)


Measured memory_bytes: 65604
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int insertionSort(int a[], int n, int g)
{
	int count = 0;
	for (int i = g; i < n; i++) {
		int v = a[i];
		int j;
		for (j = i - g; j >= 0 && a[j] > v; j -= g) {
			a[j + g] = a[j];
			count++;
		}
		a[j + g] = v;
	}
	return count;
}
int shellSort(int a[], int n)
{
	vector<int> g;
	int count = 0;

	for (int i = 1; i <= n && g.size() < 100; i = i * 3 + 1) {
		g.push_back(i);
	}
	//debug
	cout << g.size() << endl;
	for (int i = g.size() - 1; i >= 0 ; i--) {
		cout << g[i] << (i == 0 ? '\n': ' ');
	}
	
	for (int i = g.size() - 1; i >= 0; i--) {
		count += insertionSort(a, n, g[i]);
	}
	
	return count;
}

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

	cout << shellSort(A, N) << endl;
	
	for (int i = 0; i < N; i++) {
		cout << A[i] << endl;
	}

	return 0;
}


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

template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
    }
    inline T queryf(T& x,T& y){
        return max(x,y);
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    SegmentTree<int> sg(606060,0);
    rep(i,n){
        int x;cin>>x;
        auto res = sg.get(max(0,x-k),x+k+1);
        sg.update(x,res+1);
    }
    cout<<sg.get(0,303030)<<endl;
    return 0;
}

Measured memory_bytes: 11392
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while( sc.hasNext() ){
            String[] line = sc.nextLine().split(" ");
            int line_x = Integer.parseInt(line[0]);
            int line_y = Integer.parseInt(line[1]);

            System.out.println(line_x*line_y +" "+ 2*(line_x+line_y));
        }
    }
}

Measured memory_bytes: 26224
import { readFileSync } from 'fs'

function main(input: string) {
  const [[n, d], ...lines] = input.split('\n').map(v => v.split(' ').map(BigInt))

  const border = d ** 2n
  const result = lines.filter(([x, y]) => x ** 2n + y ** 2n <= border).length

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 110144
import sys
if sys.platform=='ios':
	sys.stdin=open('input_file.txt')
	
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ans=0
if sum(A)<sum(B):
	ans=-1
	
else:
	cnt=0
	res=[]
	for i in range(N):
		if A[i]>=B[i]:
			res.append(A[i]-B[i])
		else:
			cnt+=B[i]-A[i]
			ans+=1
	if cnt>0:
		ans+=1
		res=sorted(res)[::-1]
		for i in range(len(res)):
			if res[i]<cnt:
				ans+=1
				cnt-=res[i]
			else:
				break

print(ans)

Measured memory_bytes: 24284
h,w = map(int, input().split())
d = h * w
S = []
if (h % 3 == 0) or (w % 3 == 0):
    print(0)
else:
    i = 1
    a = 0
    b = 1
    while a < b:
        a = w * i
        b = ((w // 2) + (w % 2)) * (h - i)
        c = (w // 2) * (h - i)
        abc = [a, b, c]
        S += [max(abc) - min(abc)]
        i += 1

    i = 1
    a = 0
    b = 1
    while a < b:
        a = h * i
        b = ((h // 2) + (h % 2)) * (w - i)
        c = (h // 2) * (w - i)
        abc = [a, b, c]
        S += [max(abc) - min(abc)]
        i += 1

    a = h // 3
    b = (h - a) // 2
    c = h - a - b
    abc = [a * w, b * w, c * w]
    S += [max(abc) - min(abc)]

    a = w // 3
    b = (w - a) // 2
    c = w - a - b
    abc = [a * h, b * h, c * h]
    S += [max(abc) - min(abc)]
    
    print(min(S))


Measured memory_bytes: 5784
A = int(input())
B = int(input())
C = int(input())

X = int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X==(i*500+j*100+k*50):
                count = count+1

print(count)

Measured memory_bytes: 67488
r,c=map(int,input().split())
R=list()
L=list()
M=list()
sum=0
for i in range(r):
    R=list(map(int,input().split()))
    L.append(R)
for j in range(r):
    for k in range(c):
        sum+=L[j][k]
    L[j].append(sum)
    sum=0
for l in range(c):
    for m in range(r):
        sum+=L[m][l]
    M.append(sum)
    sum=0
for n in range(c):
    sum+=M[n]
M.append(sum)
L.append(M)
for o in range(r+1):
    print(" ".join(map(str,L[o])))




Measured memory_bytes: 5692
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
using namespace std;


int main() {
	int n, m,a,tmp;
	vector<int> x;
	x.push_back(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		x.push_back(tmp);
	}

	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		if (a == n)
		{
			if (x[a] != 2019)
			{
				x[a]++;
			}
		}
		else
		{
			if(x[a]!=2019&&x[a+1]!=x[a]+1)
			x[a]++;
		}
		
	}
	for (int i = 1; i < n + 1; i++)
	{
		cout << x[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3156
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] sp = line.split("");
        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        int c = Integer.parseInt(sp[2]);
        if(a == 7 || b == 7 || c == 7) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 10004
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
void solve()
{
    ll n;
    cin >> n;
    pll p[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> p[i].ff >> p[i].ss;
    }
    for (ll i = 0; i < n; i++)
    {

        if (i >= 2)
        {
            if (p[i].ff == p[i].ss && p[i - 1].ff == p[i - 1].ss && p[i - 2].ff == p[i - 2].ss)
            {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
    return;
}
int main()
{
    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {

        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1300005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
        int dp[100001];
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n,w;
        cin>>n>>w;
        pair<int,int> a[n];
        rep(i,0,n){
            int b,c;
            cin>>b>>c;
            a[i] = {b,c};
        }
        dp[0] = 0;
        rep(i,1,100001) dp[i] = -INF;
        rep(i,0,n){
            for(int j=100000; j>=0; j--){
                if(dp[j]!=-INF){
                    if(a[i].fr+j>w) continue;
                    dp[a[i].fr+j] = max(dp[a[i].fr+j], dp[j]+a[i].sc);
                }
            }
        }
        int ans=-INF;
        rep(i,0,w+1) ans = max(ans,dp[i]);
        cout<<ans;
    }       
}     

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();

		Arrays.sort(line);

		int ans = 0;
		line[0] = line[2] - line[0];
		line[1] = line[2] - line[1];


		if (line[0] % 2 == 1 && line[1] % 2 == 1) {
			line[0]--;
			line[1]--;
			ans++;
		}else if ((line[0] % 2 == 1 && line[1] % 2 == 0)||(line[0] % 2 == 0 && line[1] % 2 == 1)) {
			if (line[0] % 2 == 1) {line[0]++;}
			if (line[1] % 2 == 1) {line[1]++;}
			ans++;
		}
		ans += (line[0] + line[1])/2;

		System.out.println(ans);

	}
}


Measured memory_bytes: 36104
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    r,g,b = inputMap()
    
    tmp = str(r) + str(g) + str(b)
    tmp1 = int(tmp)
    
    if tmp1 % 4 == 0:
        print("YES")
    else:
        print("NO")
    
        
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include <iostream>

using namespace std;

static const int MAX = 100;

int main () {

  int N, A[MAX];

  cin >> N;

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

  bool flag = 1;
  int count = 0;

  for (int i = 0; flag; i++) {
    flag = 0;

    for (int j = N-1; i < j; j--) {
      if (A[j] < A[j-1]) {
        int a = A[j-1];
        A[j-1] = A[j];
        A[j] = a;
        flag = 1;
        count ++;
      }
    }

  }

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

  cout << endl;
  cout << count << endl;


}

Measured memory_bytes: 3100
// Aizu Vol0 0052: Factorial II
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char buf[100];

int pow5[8] = { 1, 5, 25, 125, 625, 3125, 15625, 78125 };

int main()
{
	int i, n;
	int ans;

	while (1) {
		gets(buf);
		if ((n = atoi(buf)) == 0) break;
		ans = 0;
		for (i = 1; n >= pow5[i]; i++) ans += n / pow5[i];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll x,y;
  cin>>x>>y;
  ll k=0;
  while(k<=x)
  {
    if(2*(2*x-k)==y)
    {
      Yes
      return 0;
    }
    k++;
  }
  No
}


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

int main() {

	int dishes[5];
	int min = 9;
	int num = 0;
	int rstime = 0;

	for (int n = 0; n < 5; n++) {
		cin >> dishes[n];
		if (min > dishes[n] % 10 && dishes[n] % 10) {
			min = dishes[n] % 10;
			num = n;
		}
	}


	for (int n = 0; n < 5; n++) {
		if (n == num)continue;
		if (dishes[n] % 10) {
			rstime += dishes[n] - (dishes[n] % 10) + 10;
		}
		else {
			rstime += dishes[n];
		}
	}
	rstime += dishes[num];

	cout << rstime;

	return 0;
}

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

ll n,m,x,y;
string s,t;

int main() {
  cin >> x >> y;
  ll ans=1e16;
  if(x<=y) chmin(ans,y-x);
  if(-x<=y) chmin(ans,y+x+1);
  if(x<=-y) chmin(ans,-y-x+1);
  if(-x<=-y) chmin(ans,-y+x+2);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        x = 1, y = 1;
        rep(i, n){
            cin >> a >> b;
            cnt = max((x + a - 1) / a, (y + b - 1) / b);
            x = cnt * a, y = cnt * b;
        }
        print(x + y);
    }
}


Measured memory_bytes: 256