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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const int SIZE = 1e5+10;
ll n;
ll ans;

int main(){
    cin >> n;
    for(int i = n; i > 0; i--){
        int mem = i,cou = 0;
        while(mem != 0){
            mem/=10;
            ++cou;
        }
        if(cou % 2 == 1)    ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;

/*
  ???????????????
  ?????????????????????
*/

class RSQ2{
public:
  ll n,dat[2*MAX_N-1],td[2*MAX_N-1];
  //?????????
  RSQ2(){n=MAX_N,memset(dat,0,sizeof(dat)),memset(td,0,sizeof(td));};
  RSQ2(int n_){
    n=1;
    while(n<n_)n*=2; //????´???°n???2???????????????
    for(int i=0;i<2*n-1;i++)dat[i]=td[i]=0;
  }
  
  //[a,b)????????????x???????????????,query(a,b,x);
  ll add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if(r==-1) r=n;
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b){
      dat[k]+=(r-l)*x; 
      td[k]+=x;
      return dat[k];
    }
    dat[k]+=(min(r,b)-max(l,a))*x;
    ll kl=k*2+1,kr=k*2+2,t=td[k]*(r-l)/2;
    dat[kl]+=t, dat[kr]+=t;
    td[kl]+=td[k], td[kr]+=td[k];
    td[k]=0;

    ll vl=add(a,b,x,k*2+1,l,(l+r)/2);
    ll vr=add(a,b,x,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
  
  //[a,b)??????????????????
  ll sum(int a,int b){return add(a,b,0);}
};

int main(){
  int n,q;
  cin>>n>>q;
  RSQ2 T(n);
  while(q--){
    int cmd,s,t,x;
    cin>>cmd>>s>>t;
    if(cmd) cout << T.sum(s-1,t)<<endl;
    else cin>>x,T.add(s-1,t,x);
  }
  return 0;
}

Measured memory_bytes: 7204
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) > abs(x - b)) cout << "B" << endl;
    else cout << "A" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


int main()
{
    ll K;
    cin >> K;

    ll c = 0, L;
    queue<ll> Q;
    REP(i,1,10) Q.push(i);
    ll v;
    while(c < K) {
        v = Q.front(); Q.pop();
        ++c;
        if(v % 10 == 0) {
            Q.push(v * 10); 
            Q.push(v * 10 + 1);
        }
        else if(v % 10 == 9) {
            Q.push(v * 10 + 8); 
            Q.push(v * 10 + 9);
        }
        else {
            Q.push(v * 10 + v % 10 - 1); 
            Q.push(v * 10 + v % 10), 
            Q.push(v * 10 + v % 10 + 1);
        }
    }
    
    PR(v);


    return 0;
}

/*



*/

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

int main()
{
    int n;
    string X;
    cin >> X;
    n = X.length();
    int m;
    if(n % 2 == 1)
    {
        m = (n + 1)/2;
    }
    else
    {
        m = n/2;
    }
    char c[m] = {};
    for(int i = 0; i < m; i++)
    {
        cout << X[2*i];
    
    }
}

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

int main(){
  int64_t n,m;
  cin >> n >> m;
  int64_t ans=2018;
  if(m-n>2019){
    ans=0;
  }else{
    for(int64_t i=n;i<m;i++){
      for(int64_t j=i+1;j<=m;j++){
        ans=min((i*j)%2019,ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3536
N = parse(Int, readline())
as = parse.([Int], split(readline()))

dic = Dict()
for i in 0:8
    dic[i] = 0
end
for i in 1:N
    if as[i] < 3200
        dic[div(as[i], 400)] += 1
    else
        dic[8] += 1
    end
end

c = 0
for i in 0:7
    if 0 < dic[i]
        c += 1
    end
end
cmin = max(c, 1)
cmax = c + dic[8]
println(cmin, ' ', cmax)

Measured memory_bytes: 125676
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, w = [int(x) for x in input().split()]
    j = 0
    ok = 1
    for i in range(n):
        r = [x for x in input()]
        while r[j] == '#' and j+1 < w and r[j+1] == '#':
            r[j] = '.'
            j += 1
        if r[j] == '.' or r.count('#') != 1:
            ok = 0


    if ok:
        print("Possible")
    else:
        print("Impossible")

    




        
    

    
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

2 2 2 2 2

"""


Measured memory_bytes: 9376
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
typedef long long LL;
struct edge
{
	int u,v;
	edge(){};
	edge(int _u,int _v):u(_u),v(_v){};
};
vector<edge> G[MAXN+5],edges;
int setfa[MAXN+5],setsp[MAXN+5],d[MAXN+5];
int dist[MAXN+5],n,m;
bool vis[MAXN+5];
void Init()
{
	for(int i=0;i<=MAXN;i++)
		setfa[i]=i;
}
int Findfa(int x)
{
	if(x==setfa[x])
		return x;
	return setfa[x]=Findfa(setfa[x]);
}
void Union(int x,int y)
{
	int fx=Findfa(x),fy=Findfa(y);
	if(fx==fy)
		return;
	setfa[fx]=fy;
}
void DFS(int u)
{
	for(int i=0;i<(int)G[u].size();i++)
	{
		int v=G[u][i].v;
		if(dist[v]!=0)
		{
			int cirlen=dist[u]-dist[v]+1;
			if(cirlen%2==1)
				setsp[Findfa(u)]=true;
			continue;
		}
		dist[v]=dist[u]+1;
		DFS(v);
	}
}
int main()
{
//	freopen("squared.in","r",stdin);
//	freopen("squared.out","w",stdout);
	Init();
	scanf("%d %d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		G[u].push_back(edge(u,v));
		G[v].push_back(edge(v,u));
		edges.push_back(edge(u,v));
		d[u]++,d[v]++;
		Union(u,v);
	}
	for(int i=1;i<=n;i++)
		if(dist[i]==0)
		{
			dist[i]=1;
			DFS(i);
		}
	LL ans=0,num=0,num2=0;
	for(int i=1;i<=n;i++)
		if(vis[Findfa(i)]==false)
		{
			vis[Findfa(i)]=true;
			if(d[i]==0)
				continue;
			num++;
			if(setsp[Findfa(i)]==true)
				num2++;
			else
				num2+=2;
		}
	memset(vis,0,sizeof(vis));
	LL cnt=0;
	for(int i=1;i<=n;i++)
		if(vis[Findfa(i)]==false)
		{
			vis[Findfa(i)]=true;
			if(d[i]==0)
			{
				ans+=1LL*n;
				cnt+=1LL;
				continue;
			}
			if(setsp[Findfa(i)]==true)
				ans+=1LL*num;
			else
				ans+=1LL*num2;
		}
	ans+=cnt*(n-cnt);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15344
#include<math.h>
#include<iostream>
using namespace std;

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

    int k = sqrt(n);
    //cout << k << endl;

    int ans = 0;
    int j = 1;

    for(int i = 2; i <= k + 2; i++){
        if(n <= 3){
            ans = 1;
            break;
        }else{
            j = 1;
            while(1){
                if(pow(i, j) > n){
                    break;
                }else{
                    if(ans <= pow(i, j)){
                        ans = pow(i, j);
                    }
                }
                j++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 200005

char viz[NMAX];
vector<int> graph[NMAX];
int answer[NMAX], n, index_of[NMAX], ycoord[NMAX];

struct point {
    int x, y, index;  
    
    bool operator<(point B) {
        return x < B.x;
    }
};
point v[NMAX];

int dfs(int node) {
    if(viz[node])
        return 0;
    viz[node] = 1;
    int ans = 0;
    for(auto neight : graph[node]) {
        ans += dfs(neight);
    }
    return ans + 1;
}

void dfs2(int node, int val) {
    if(viz[node] == 2)
        return ;
    viz[node] = 2;
    answer[node] = val;
    for(auto neight : graph[node]){
        dfs2(neight, val);
    }
}

int main () {
    int cnt = 0;
    
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d%d", &v[i].x, &v[i].y);
        v[i].index = i;
    }
    sort(v + 1, v + n + 1);
    int last = 0;
    for(int i = 1; i <= n; i++) {
        int j = 0;
        for(j = last; j > 0; j--) {
            if(ycoord[j] < v[i].y) {
                graph[v[i].index].push_back(index_of[j]);
                graph[index_of[j]].push_back(v[i].index);
            }
            else {
                break;
            }
        }
        if(j == last) {
            ycoord[++last] = v[i].y;
            index_of[last] = v[i].index;
        }
        else {
            ycoord[j + 1] = ycoord[last];
            index_of[j + 1] = index_of[last];
        }
    }
    for(int i = 1; i <= n; i++) {
        if(!viz[i]) {
            cnt = dfs(i);
        }
        dfs2(i, cnt);
    }
    
    for(int i = 1; i <= n; i++) {
        printf("%d\n", answer[i]);
    }
    
    return 0;
}

Measured memory_bytes: 35008
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 998244353

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 10010
string a;
int cnt[26];

int main() {
    int tot = 0;
    ll res = 0;
    memset(cnt, 0, sizeof(cnt));

    cin >> a;
    for (char ch : a) {
        res += tot - cnt[ch - 'a'];
        ++tot;
        ++cnt[ch - 'a'];
    }

    cout << 1 + res;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int K[100010];
vector<int> G[100010];
int par[100010];

int root(int x) {
  return par[x] == x ? x : root(par[x]);
}

void merge(int x, int y) {
  x = root(x); y = root(y);
  if (x == y) return;
  par[y] = x;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      int L;
      cin >> L;
      G[L - 1].emplace_back(i);
    }
  }
  iota(par, par + N, 0);
  for (int i = 0; i < M; i++) {
    if (G[i].empty()) continue;
    for (int v : G[i]) {
      merge(G[i].front(), v);
    }
  }
  for (int i = 0; i < N; i++) {
    if (root(i) != root(0)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 4736
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b) << "\n";
   

    return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int ans = 0;
    vector<int> V(N);
    vector<int> C(N);
    for(int i=0; i<N; i++) {
        cin >> V.at(i);
    }
    for(int i=0; i<N; i++) {
        cin >> C.at(i);
    }
    for(int i=0; i<N; i++) {
        int diff = V.at(i) - C.at(i);
        if(diff > 0) {
            ans += diff;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int main()
{
	//File("");
    string s;
    getline(cin, s);
    if (s[2] == s[3] && s[4] == s[5]) puts("Yes");
    else puts("No");
	return 0;
}


Measured memory_bytes: 256
arg = input().split(' ')
n = int(arg[0])
c = int(arg[1])
k = int(arg[2])
t = []
for i in range(n):
  t.append(int(input()))
t.sort()

res = 1
first = t[0]
pas = 0

for ti in t:
  if ti <= first + k:
    if pas == c:
      res += 1
      first = ti
      pas = 0
    pas += 1
  else:
    res += 1
    first = ti
    pas = 1

print(res)


Measured memory_bytes: 7444
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int N;
pii A[100010];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	cin >> N;
	for (int i=0; i<N; i++) cin >> A[i].va >> A[i].vb;
	for (int i=0; i<N; i++) {
		A[i].va -= A[i].vb;
		A[i].vb = A[i].va + 2*A[i].vb;
	}

	sort(A, A+N, [&](pii a, pii b) {
		if (a.vb != b.vb) return a.vb < b.vb;
		return a.va > b.va;
	});

	int p = -2e9, c = 0;
	for (int i=0; i<N; i++) {
		if (A[i].va >= p) ++c, p = A[i].vb;
	}

	cout << c;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

a_max = 0

for ai in a:
    a_max = max(a_max, ai)

if a[0] != a_max:
    m = a[0]
else:
    m = a[1]

for ai in a:
    if ai == a_max or ai == m:
        continue

    if ai > m and ai < a_max - m:
        m = ai
    elif ai < m and ai > a_max - m:
        m = ai

print(a_max, m)


Measured memory_bytes: 14052
n, k = map(int, input().split())
mod = 10 ** 9 + 7


class ModInt:
    def __init__(self, num, mod):
        self.num = num
        self.mod = mod

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, self.mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def pow(self, times):
        pw = pow(self.num, times, self.mod)
        return ModInt(pw, self.mod)

    def inverse(self):
        return self.pow(self.mod - 2)

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num, self.mod)


class Combination:
    def __init__(self, n, mod):
        self.mod = mod
        self.fact = [ModInt(1, mod)]
        self.inverse = [ModInt(1, mod)]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * ModInt(i, mod))
            self.inverse.append(self.inverse[-1] * ModInt(i, mod).inverse())

    def comb(self, n, k):
        if k < 0 or n < k:
            return ModInt(0, self.mod)

        return self.fact[n] * self.inverse[k] * self.inverse[n-k]


mx = min(k, n - 1)
comb = Combination(n, mod)
ans = ModInt(0, mod)

for i in range(mx + 1):
    ans += comb.comb(n, i) * comb.comb(n - 1, i)

print(ans)


Measured memory_bytes: 82216
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	bool check = false;
	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			if (i*j == n)
			{
				check = true;
				break;
			}
		}
		if (check)
			break;
	}
	if (check)
		cout << "Yes";
	else
		cout << "No";

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    long long int t,n,i,j,k,l,sum,sum1,a,cnt,cnt1,flag,flag1,temp,temp1;
    cin>>n>>k;
    map<long long int,long long int>mp;
    for(i=1;i<=k;i++)
    {
        cin>>t;
        for(j=1;j<=t;j++)
        {
            cin>>a;
            mp[a]=t;

        }
    }
    cnt=n-mp.size();
    cout<<cnt<<endl;


    return 0;

}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=203,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    map<string,set<int>> MA;
    
    for(int i=0;i<N;i++){
        string S;cin>>S;
        int d;cin>>d;
        MA[S].insert(d);
    }
    
    int M;cin>>M;
    
    int now=0;
    
    bool ok=true;
    
    for(int i=0;i<M;i++){
        string S;cin>>S;
        if(MA[S].size()==0){
            ok=false;
        }else{
            auto it=MA[S].upper_bound(now);
            if(it==MA[S].end()) ok=false;
            else{
                now=*it;
            }
        }
    }
    
    if(!ok) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}





Measured memory_bytes: 23512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C, K, cnt = 0;
    cin >> A >> B >> C >> K;
    while(A >= B)
    {
        cnt += 1;
        B *= 2;
    }
    while(B >= C)
    {
        cnt += 1;
        C *= 2;
    }
    if(cnt <= K) cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3532
// Code for A - Station and Bus
#include <iostream>
using namespace std;

int main() {
	string S;
	cin>>S;
	if(S[0] == 'A' && S[1] == 'A' && S[2] == 'A')cout << "No";
	else if(S[0] == 'B' && S[1] == 'B' && S[2] == 'B')cout << "No";
	else cout << "Yes";
	return 0;
}

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


using namespace std;
using ll = long long;

vector < ll > v;

main(){
    int n;

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
        ll x; scanf("%lld" , &x);
        v.push_back(x);
    }

    while( true ){
        if(v.size() == 1)break;

        sort(v.begin() , v.end() , [&](ll x , ll y){return x > y;});

        ll x = v.back(); v.pop_back();
        ll y = v.back(); v.pop_back();

        int sz = v.size();
        for(int i = 0 ; i < sz ; i ++)v[i] *= 2ll;

        v.push_back(x + y);
    }

    ll div = (1ll << (n-1));

    double ans = double(v[0]) / (double(div));

    printf("%.9f\n" , ans);

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
S0 = [0 for i in range(60)]
S1 = [0 for i in range(60)]
for i in range(N):
  for j in range(60):
    if A[i] % 2  == 0:
      S0[j] += 1
    else:
      S1[j] += 1
    A[i] //= 2
ans = 0
c = 1
for j in range(60):
  ans = (ans + S0[j] * S1[j] * c) % mod
  c *= 2
print(ans)

Measured memory_bytes: 124488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

#define rep(i, n) for(int i = 0, end = (int)(n); i < end; i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    ll a, b;
    cin >> a >> b;
    ll aa = max(a, b);
    ll bb = min(a, b);

    ll r = aa % bb;
    while (r != 0) {
        aa = bb;
        bb = r;
        r = aa % bb;
    }
    cout << a * b / bb << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();

    int kind = 1;

    for (int i = 0; i < n; i++) {
      if (i != n - 1) {
        if (s.charAt(i) != s.charAt(i + 1)) {
          kind++;
        }
      }
    }
    System.out.println(kind);
  }
}

Measured memory_bytes: 24532
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

N = rri()
# 
ans = [0 for i in range(N)]
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            if i*i + j*j+k*k+i*j+j*k+i*k<=N:
                ans[i*i + j*j+k*k+i*j+j*k+i*k-1]+=1
for i in ans:
    print i


Measured memory_bytes: 73140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 10005;

int d[maxn];
int n;
int a[maxn];
vector<int>e[maxn];
int ans[maxn];
bool vis[maxn];
bool vis2[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  cin>>n;
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
    d[x]++;
    d[y]++;
  }
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  queue<int>que;
  for(int i=1;i<=n;i++){
    if(d[i]<=1){
      que.push(i);
      vis[i]=1;
    }
  }
  int ret = 0;
  int cnt = 0;
  while(!que.empty()){
    int x=que.front();
    vis2[x]=1;
    que.pop();
    ans[x]=a[cnt];
    for(int j=0;j<e[x].size();j++){
      int v= e[x][j];
      d[v]--;
      if(!vis2[v])ret+=a[cnt];
      if(d[v]<=1&&!vis[v]){
        vis[v]=1;
        que.push(v);
      }
    }
    cnt++;
  }
  cout<<ret<<endl;
  for(int i=1;i<n;i++)cout<<ans[i]<<" ";
  cout<<ans[n]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 300060
int n,v[N];
long long su[N],su1,su2;
bool check(long long l)
{
	long long mn=0;
	for(int i=1;i<=n;i+=2)
	if(su[i]-mn>=l)
	{
		if(mn>su[i+1])mn=su[i+1];
		if(i==n)return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	if(~n&1)
	{
		long long s1=0,s2=0;
		for(int i=1;i<=n;i+=2)s1+=v[i],s2+=v[i+1];
		printf("%lld %lld\n",max(s1,s2),min(s1,s2));
	}
	else
	{
		for(int i=1;i<=n;i++)su1+=v[i]*(i&1),su[i]=su[i-1]+v[i]*(i&1?1:-1),su2+=v[i]*(~i&1);
		long long lb=0,rb=2e10,as=0;
		while(lb<=rb)
		{
			long long mid=(lb+rb)>>1;
			if(check(mid))as=mid,lb=mid+1;
			else rb=mid-1;
		}
		printf("%lld %lld\n",su2+as,su1-as);
	}
}

Measured memory_bytes: 3712
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int mod = inf;
int n;
ll dp[(1 << 21) + 10];
int a[30][30];
int ppc[(1 << 21) + 10];
bool was[(1 << 21) + 10];

inline ll go(int mask) {
	if (mask == 0) re 1;
	if (was[mask]) re dp[mask];
	was[mask] = 1;
	int x = ppc[mask];
	for (int i = 0; i < n; i++)
		if ((mask & (1 << i)) && a[x - 1][i])
			dp[mask] = (dp[mask] + go(mask ^ (1 << i))) % mod;
	re dp[mask];
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	for (int i = 0; i < (1 << n); i++)
		ppc[i] = __builtin_popcount(i);
	cout << go((1 << n) - 1);
}

Measured memory_bytes: 26880
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=1001;
std::vector<int> adj[maxn];
std::vector<int> v1;
int ans,n,k,m,x,y,tt,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn][maxn],st[maxn],ft[maxn];
bool mark[maxn];



int32_t main(){
    cin>>n>>m;
    string a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<n;i++)
        if(a[i][0]=='.'&&a[i-1][0]=='.')
            dp[i][0]=dp[i-1][0];
    for(int j=1;j<m;j++)
        if(a[0][j]=='.'&&a[0][j-1]=='.')
            dp[0][j]=dp[0][j-1];
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i][j]=='.'){
                if(a[i-1][j]=='.')
                    dp[i][j]=dp[i-1][j];
                if(a[i][j-1]=='.')
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%M;
            }
        }
    }
    cout<<dp[n-1][m-1];
    return 0;

}


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

using namespace std;

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

    int s, w;
    
    cin >> s >> w;
    
    if(w>=s) cout << "unsafe";
    else cout << "safe";

	return 0;
}


Measured memory_bytes: 3640
x, y = [int(x) for x in input().split()]

if x == 0:
    ans = abs(y) + (y < 0)
else:
    ans = 1 if (x < 0 and abs(x) < abs(y)) or (x > 0 and abs(x) > abs(y)) else 0
    ans += abs(abs(y) - abs(x))
    ans += 1 if (-1 if (x < 0 and abs(x) < abs(y)) or (x > 0 and abs(x) > abs(y)) else 1) * x * y < 0 else 0

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
int pd[100010],arr[100010];
int main()
{
    int n,m,ans=0,T=0;
    memset(pd,0,sizeof(pd));
    cin>>n;
    
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }

    T=arr[2]-arr[1];
    for (int i=3; i<=n; i++) {
        if(T==0)T=arr[i]-arr[i-1];
        if(1LL* T * (arr[i]-arr[i-1])<0){
            ans++;
            T=0;
        }
    }
    
    cout<<ans+1<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

bool judge = 0;
long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

ll MAX = 2000000;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    ll gcd, m = 0;
    map<ll, bool> ma;
    map<ll, ll> cnt;
    rep(i, N) {
        cin >> A[i];
        ma[A[i]] = true;
        if (i == 0)
            gcd = A[i];
        else
            gcd = GCD(gcd, A[i]);
        m = max(m, A[i]);
    }

    int MAX = m + 1;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i])
            continue;
        for (ll j = i; j < MAX; j += i) {
            is_prime[j] = 0;
            if (ma[j]) {
                cnt[i]++;
                if (cnt[i] >= 2) {
                    judge = 1;
                    break;
                }
            }
        }
    }

    if (!judge && gcd == 1) {
        cout << "pairwise coprime" << endl;
    } else if (gcd == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 118940
#include <stdio.h>

int main(void) {
    
    int a;
    int b;
    
    scanf("%d %d", &a, &b);
    
    int area = a*b;
    int perimeter = 2*a+2*b;
    
    printf("%d %d\n", area, perimeter);
	
	
	return 0;
}



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

int main(int argc, const char * argv[]) {
    
    int A = 0;
    int B = 0;
    int C = 0;
    int count = 0;
    
    cin >> A;
    cin >> B;
    cin >> C;
    
    if (A == B) {
        count++;
    }
    if (A == C) {
        count++;
    }
    if (B == C) {
        count++;
    }
    
    if (count == 1) {
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d",&a,&b);
	d=a%b;
	if(b>=a)
	printf("1");
	else if(b<a&&d==0)
	{
		c=a/b;
		printf("%d",c);
	}
	else if(b<a&&d!=0)
	{
		c=a/b;
		printf("%d",c+1);
	}
}

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

int main(void){
	int n;
	int a[200];
	int swap = 0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	for(int i=0; i<n; i++){
		int mini = i;
		for(int j=i; j<n; j++){
			if(a[j] < a[mini]){
				mini = j;
			}
		}
		if(i != mini){
			int temp = a[i];
			a[i] = a[mini];
			a[mini] = temp;
			swap++;
		}
	}

	for(int i=0; i<n; i++){
		if(i!=n-1) printf("%d ", a[i]);
		else printf("%d\n", a[i]);
	}
	printf("%d\n", swap);

	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int gcd(int a,int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
    string s;
    cin>>s;
    if(s[1]=='B')
        s[1]='R';
    else
    {
        s[1]='B';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n, res = 0;
    std::cin >> n;
    for (int i = 1; i <= n; ++i) {
        res += i;
    }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;cin>>n;
    vector<int> ar;
    while(n>0) {
        ar.push_back(1);
        n--; 
        for(int i=0;i<ar.size() && n>0;i++) {
            ar[i]++;
            n--;
        }
    }
    for(auto i:ar) cout<<i<<"\n";
}

Measured memory_bytes: 3580
import java.io.*; 
import java.util.*; 

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}

	public static void main(String[] args) 
	{ 
        FastReader sc = new FastReader(); 
        PrintWriter out = new PrintWriter(System.out); 

        int n = sc.nextInt();
        int w = sc.nextInt();
        long[][] arr = new long[n+1][2], dp = new long[n+1][w+1];
        
        for(int i=1;i<=n;i++){
        	for(int j=0;j<2;j++){
        		arr[i][j] = sc.nextLong();	
        	}
        }

        
        for(int i=1;i<=n;i++){
        	for(int wt=0;wt<=w;wt++){
            	if(arr[i][0]<=wt)
            		dp[i][wt] = Math.max(dp[i-1][wt], dp[i-1][wt-(int)arr[i][0]]+arr[i][1]);
            	else
            		dp[i][wt] = dp[i-1][wt];
        	}
        }

        long ans = 0L;
        for(int wt=0;wt<=w;wt++)
        	ans = Math.max(ans, dp[n][wt]);

        out.println(ans);
        out.close();
	} 
} 


Measured memory_bytes: 140756
#include <string>
#include <vector>

struct KMP {
    const std::string& pattern;
    std::vector<int> table;

    explicit KMP(const std::string& p): pattern(p), table(p.size() + 1) {
        table[0] = -1;
        table[1] = 0;

        int i = 2;
        int j = 0;
        while (i < pattern.size()) {
            if (pattern[i - 1] == pattern[j]) {
                table[i] = j + 1;
                i += 1;
                j += 1;
            } else if (j > 0) {
                j = table[j];
            } else {
                table[i] = 0;
                i += 1;
            }
        }
        if (pattern.size() > 1) {
            table[pattern.size()] = j + 1;
        }
    }

    std::vector<int> search(const std::string& text) {
        std::vector<int> matches;
        int m = 0;
        int i = 0;
        while (m + i < text.size()) {
            if (i < pattern.size() && pattern[i] == text[m + i]) {
                i += 1;
            } else {
                if (i == pattern.size()) {
                    matches.push_back(m);
                }
                m = m + i - table[i];
                if (i > 0) {
                    i = table[i];
                }
            }
        }
        return matches;
    }
};


// verify: https://atcoder.jp/contests/abc135/tasks/abc135_f

#include <iostream>
#include <map>

using namespace std;

const int INF = 1e9;

map<int, int> nexts;
vector<bool> vis;
pair<int, int> trace(int pos, int init) {
    vis[pos] = true;
    if (pos == init) {
        return make_pair(pos, INF);
    } else if (nexts.count(pos) == 0) {
        return make_pair(pos, 1);
    } else {
        auto recur = trace(nexts[pos], init);
        return make_pair(recur.first, recur.second + 1);
    }
}

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

    string u;
    while (u.size() < s.size() + t.size()) {
        u.insert(u.end(), s.begin(), s.end());
    }

    KMP kmp(t);
    auto matches = kmp.search(u);
    for (const auto &fr : matches) {
        nexts[fr] = (fr + t.size()) % s.size();
    }
    vis = vector<bool>(s.size(), false);

    int ans = 0;
    for (int fr = 0; fr < s.size(); ++fr) {
        if (nexts.count(fr) == 0) {
            continue;
        }
        if (vis[fr]) {
            continue;
        }
        ans = max(ans, trace(nexts[fr], fr).second);
    }

    cout << ((ans >= INF) ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 86720
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b});
    return 0;
}

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

using namespace std;
void sample(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    //sample();
    long long int t,n,m,k,x,y,w,i,j,count=1,sum=0,ans,mod=1000000007;
    cin>>n;
    count=0;
    for(i=0;i<n;i++){
    	cin>>x>>y;
    	if(x==y){
    		count++;
    	}
    	else{
    		count=0;
    	}
    	if(count==3){
    		cout<<"Yes";
    		return 0;
    	}
    }
    cout<<"No"<<endl;

}



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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int zero = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '0')zero++;
    }
    cout << min(zero, n - zero) * 2<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){
    String input;
    int [] count = new int[26];
 
    Scanner in = new Scanner(System.in);

    while(in.hasNext()){
        input = in.nextLine();
        String tmp = input.toLowerCase();

        for(int i=0; i<tmp.length(); i++){
            
            int ch = tmp.charAt(i);
            if(Character.isAlphabetic(ch)){
                // debug int index = ch - 'a';
                // debug System.out.println(index);
                count[ch-'a']++;
            }
        }
    }

    for(int i=0; i<count.length; i++){

        int ch = 'a' + i;
        System.out.printf("%c : %d\n", ch, count[i]);
    }
  }
}

Measured memory_bytes: 26216
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int N,A,B;
  int Max,Min;
  cin>>N>>A>>B;

  if(A < B){
    cout<<A<<" ";
  }
  else{
    cout<<B<<" ";
  }

  Min = A + B - N ;

  if(Min < 0){
    cout<<0<<endl;
  }
  else{
    cout<<Min<<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

vector<vector<bool>> visited;
vector<string> gl, gr;
int w, h;

bool is_valid(int y, int x)
{

    return 0 <= y && y < h && 0 <= x && x < w;
}

int depth = 0;

bool bfs(int ly, int lx, int ry, int rx)
{

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

    deque<pair<pair<int, int>, pair<int, int>>> que;
    que.push_back({{ly, lx}, {ry, rx}});
    visited[ly * 50 + lx][ry * 50 + rx] = true;
    while (!que.empty())
    {
        //cerr << que.size() << endl;
        ly = que.front().first.first;
        lx = que.front().first.second;
        ry = que.front().second.first;
        rx = que.front().second.second;
        que.pop_front();

        if (gl[ly][lx] == '%' && gr[ry][rx] == '%')
        {
            return true;
        }

        if (gl[ly][lx] == '%' || gr[ry][rx] == '%')
        {
            continue;
        }

        rep(i, 4)
        {
            int nry = ry + dy[i];
            int nrx = rx + dx[i];

            if (is_valid(nry, nrx) == false || gr[nry][nrx] == '#')
            {
                nry = ry;
                nrx = rx;
            }

            int nly = ly + dy[i];
            int nlx = lx - dx[i];

            if (is_valid(nly, nlx) == false || gl[nly][nlx] == '#')
            {
                nly = ly;
                nlx = lx;
            }

            if (visited[nly * 50 + nlx][nry * 50 + nrx])
                continue;
            visited[nly * 50 + nlx][nry * 50 + nrx] = true;
            //cerr << depth << endl;
            que.push_back({{nly, nlx}, {nry, nrx}});
        }
    }

    return false;
}

void solve()
{
    visited = vector<vector<bool>>(2500, vector<bool>(2500, false));
    gl = vector<string>(h);
    gr = vector<string>(h);

    rep(i, h)
    {
        cin >> gl[i] >> gr[i];
    }
    int rx, ry, lx, ly;

    rep(i, h) rep(j, w)
    {
        if (gl[i][j] == 'L')
        {
            ly = i;
            lx = j;
            gl[i][j] = '.';
        }
    }
    rep(i, h) rep(j, w)
    {
        if (gr[i][j] == 'R')
        {
            ry = i;
            rx = j;
            gr[i][j] = '.';
        }
    }
    if (bfs(ly, lx, ry, rx))
    {

        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    while (cin >> w >> h, w)
    {
        solve();
    }

    return 0;
}



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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int x = 0; x < 1000; x++) {
        string num = to_string(x);
        if (x < 10)
            num = "00" + num;
        else if (x < 100)
            num = "0" + num;

        int index = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == num[index]) {
                index++;
            }
            if (index == 3) {
                break;
            }
        }
        if (index == 3) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int s,w;
  cin >> s >> w;
  if(w>=s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
want = STDIN.gets.chomp.to_i

shouhin = [100, 101, 102, 103, 104, 105]

attempt = want / 100

def check(attempt, want)
  max = attempt * 105

  if max < want
   return 0
  end

  min = attempt * 100
  if min == want
    return 1
  end
  return 1
end

puts check(attempt, want)


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

struct job{
	int a;
	int b;
}s[200010];

int cmp(job a,job b)
{
	if(a.b!=b.b)
	{
		return a.b<b.b;
	}
	else{
		return a.a<b.a;
	}
 } 
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].a>>s[i].b;
	}
	sort(s,s+n+1,cmp);
	int t=0;
	for(int i=0;i<=n;i++)
	{
		t+=s[i].a; 
	//	cout<<t<<' '<<s[i].b<<endl; 
		if(t>s[i].b)
		{
			cout<<"No"<<endl;
			return 0;
		 } 
	 } 
	 cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792
'use strict';
function* permutation(a,b,n){
  if ( n === 0 ) return yield b;
  for ( let i = 0; i < n; i++ ) {
    const _a = [...a];
    const c = _a.splice(i,1)[0];
    yield* permutation(_a, [...b,c], n-1);
  }
}
console.log(function(args){
  const _tmp = args.trim().split('\n');
  const N = _tmp[0]|0;
  const P = _tmp[1].split(' ').map(v=>v|0);
  const Q = _tmp[2].split(' ').map(v=>v|0);
  let a = 0, b = 0, c = 0;
  const O = Array(N).fill(0).map((a,i)=>i+1);
  for ( let o of permutation(O,[],N) ) {
    c++;
    if ( o.every((v,i)=>v===P[i]) ) a = c;
    if ( o.every((v,i)=>v===Q[i]) ) b = c;
    if ( a && b ) break;
  }
  return Math.abs(a-b).toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 11052