akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


const int MAX = 300000;
int a[MAX], dp[MAX][5];
signed main(){
  int n;
  scanf("%lld", &n);
  rrep(i,n)scanf("%lld", &a[i]);
  rrep(i,n){
    int x[] = {dp[i-1][0]+a[i], max(2-a[i], a[i]%2), a[i]%2==0, max(2-a[i], a[i]%2), a[i]};
    repi(j,1,5)x[j] = min(x[j-1], dp[i-1][j]+x[j]);
    rep(j,5)dp[i][j] = x[j];
  }
  printf("%lld\n", dp[n][4]);
  return 0;
}








Measured memory_bytes: 11520
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let (n, y): (isize, isize);
    let mut ans = (-1, -1, -1);
    input!(n, y);
    for z in 0..n + 1 {
        let r = y - 10000 * z;
        let a = (r - 1000 * (n - z)) / 4000;
        let b = n - z - a;
        if 10000 * z + 5000 * a + 1000 * b == y && r >= 0 && a >= 0 && b >= 0 {
            ans = (z, a, b);
            break;
        }
    }
    println!("{} {} {}", ans.0, ans.1, ans.2);
}

Measured memory_bytes: 4352
s = str(input())
n = len(s)
 
A = str(s[:(n-1)//2])
B = str(s[(n+3)//2-1:])
 
if s ==(s[::-1]) and A == (A[::-1]) and B == (B[::-1]):
    print("Yes")
else:
    print ("No")

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

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

C.sort()

ans = 0

mod = 10 ** 9 + 7
two = [1]

for i in range(N+10):
    two.append(two[-1] * 2 % mod)

for i in range(N):

    ans += C[i] * ((two[N-1] * two[N-1] * (N-1-i)) + two[N-1] * two[N] )
    ans %= mod

print (ans)


Measured memory_bytes: 100172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,sum=0;
    cin >> a;
    map<string ,int>mp;
    while(a--)
    {
        string s;
        cin >> s;
        mp[s]++;





    }
    cout << mp.size() << endl;






}


Measured memory_bytes: 19228
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll N, W; cin >> N >> W;
  vector<ll> v(N), w(N);
  rep(i, N) cin >> v[i] >> w[i];
  const ll MAX = 100*100;
  ll dp[MAX+1];
  for (int i = 1; i <= MAX; i++) dp[i] = W+1;

  dp[0] = 0;
  rep(i, N) {
    for (int j = MAX-v[i]; j >= 0; j--) {
      if (dp[j] + w[i] <= W) {
        dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
      }
    }
  }

  for (int i = MAX; i >= 0; i--) {
    if (dp[i] <= W) {
      outl(i);
      return;
    }
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

bool check(vi &A, double cut_size, int k)
{
	int k_needed;
	for(int i : A)
	{
		k_needed = ceil(i/(cut_size)) -1;
		if(round(i/ (k_needed + 1)) > cut_size)
			k_needed++;

		k -= k_needed;
	}

	return k >= 0;
}

int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	ll n,k;
	cin>>n;
	cin>>k;
	vi A(n);
	rep(i,0,n-1)
		cin>>A[i];

	int l = 0;
	int r = 1000000001;
	int m;
	while(l < r-1)
	{
		m = l+(r - l)/2;
		if(check(A,m,k))
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
	cout<<r;


}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> A(N), C(M);
  vector<int> B(M);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  vector<pair<ll, int> > CB(M);
  rep(i, M) cin >> CB[i].second >> CB[i].first;
  sort(CB.begin(), CB.end(), greater<pair<ll, int> >());
  vector<ll> D;
  rep(i, M) {
    if(D.size() >= N) break;
    rep(j, CB[i].second)
      D.push_back(CB[i].first);
  }
  ll sum = 0;
  rep(i, N)
    sum += (D.size() > i && A[i] <= D[i]) ? D[i] : A[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6004
N = int(input())
X = list(map(int, input().split()))

X.sort()
ans = sum(X) // len(X)
ans1 = ans + 1

tmp = 0
tmp1 = 0
for i in X:
    tmp = tmp + (i - ans) ** 2
    tmp1 = tmp1 + (i - ans1) ** 2
print(min(tmp, tmp1))

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

int main(){
	int N, D, i, j, k, ans = 0;
	scanf("%d%d", &N, &D);
	vector<vector<int>> X(N, vector<int>(D));
	for(i = 0; i < N; i++){
		for(j = 0; j < D; j++){
			scanf("%d", &X[i][j]);
		}
	}
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
//			printf("(i, j) = (%d, %d)\n", i, j);
			int now = 0;
			for(k = 0; k < D; k++){
				now += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
//			printf("now = %d\n", now);
			for(k = 0; k <= now; k++){
				if(k * k == now){
					ans++;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[300001];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=3*n ;i++) cin >> a[i];
	sort(a+1,a+3*n+1);
	long long ans=0;
	for(int i=n+1; i<=3*n ;i+=2) ans+=a[i];
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
  int a,b;
  char sign;
  scanf("%d %c %d",&a,&sign,&b);
  if(sign!='+'){
    printf("%d",a-b);
    return 0;
  }
  else{
    printf("%d",a+b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
bool f[100001];
int c[100002];
int N, L, R;
int main()
{
    for (int i = 2; i <= 100000; i++)
        if (!f[i])
            for (int j = i + i; j <= 100000; j += i)
                f[j] = true;
    for (int i = 3; i <= 100000; i += 2)
        if (!f[i] && !f[(i + 1) / 2])
            c[i]++;
    for (int i = 3; i <= 100000; i++)
        c[i] += c[i - 1];
    cin >> N;
    while (N--)
    {
        cin >> L >> R;
        cout << "\n"
             << c[R] - c[L - 1];
    }
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, ll> Pl;
const ll mod = (ll)1e9 + 7;
const int N = 3005;

int n,q;
int num[N];
int a[N], b[N];

ll dp[N][N];

ll fac[N], facinv[N];
ll inv[N];

ll fp(ll x, ll k){
    if(k == 0) return 1;
    ll hf = fp(x, k/2);
    return k % 2 ? hf * hf % mod * x % mod: hf * hf % mod;
}

int main(){
    inv[1] = 1;
    for(int i = 2; i < N; i++) inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
    fac[0] = 1;
    for(int i = 1; i <= N-1; i++) fac[i] = fac[i-1] * i % mod;
    facinv[N-1] = fp(fac[N-1], mod - 2);
    for(int i = N-1 - 1; i >= 0; i--) facinv[i] = facinv[i+1] * (i+1) % mod;

    cin >> n >> q;
    for(int i = 0; i < n; i++) cin >> num[i];
    for(int i = 0; i < q; i++) cin >> a[i] >> b[i], a[i]--, b[i]--;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            dp[i][j] = (num[i] > num[j]);
        }
    }
    for(int i = 0; i < q; i++){
        vector<Pl> upd;
        for(int k = 0; k < n; k++){
            if(k != a[i] && k != b[i]) {
                upd.push_back({{a[i], k}, inv[2] * (dp[a[i]][k] + dp[b[i]][k]) % mod});
                upd.push_back({{k, a[i]}, inv[2] * (dp[k][a[i]] + dp[k][b[i]]) % mod});
            }
            if(k != b[i] && k != a[i]){
                upd.push_back({{b[i], k}, inv[2] * (dp[b[i]][k] + dp[a[i]][k]) % mod});
                upd.push_back({{k, b[i]}, inv[2] * (dp[k][a[i]] + dp[k][b[i]]) % mod});
            }
        }
        upd.push_back({{a[i], b[i]}, inv[2] * (dp[b[i]][a[i]] + dp[a[i]][b[i]]) % mod});
        upd.push_back({{b[i], a[i]}, inv[2] * (dp[b[i]][a[i]] + dp[a[i]][b[i]]) % mod});
        for(auto p : upd){
            dp[p.first.first][p.first.second] = p.second;
        }
    }
    ll res = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            res += dp[i][j];
            res %= mod;
        }
    }
    for(int i = 0; i < q; i++) res = (res * 2) % mod;
    cout << res << endl;
}

Measured memory_bytes: 71232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
inline ll mod(ll val, ll m) {long long res = val % m;if (res < 0) res += m;return res;}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1000000007;
int main(){
    INT(n);
    ll ans = 0LL;
    vec(ll,f,10000000,0);
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j<=n; j+=i){
            f[j]++;
        }
    }
    for(int i = 1; i<=n; ++i) {
        ans += i*f[i]; 

    }

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

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

int main(){
	int hand[5], result[5];
	int rock, scissors, paper, win;
	
	while(cin >> hand[0], hand[0]){
		cin >> hand[1] >> hand[2] >> hand[3] >> hand[4];
		
		rock = scissors = paper = 0;
		for(int i = 0; i < 5; ++i){
			switch(hand[i]){
				case 1: ++rock; break;
				case 2: ++scissors; break;
				case 3: ++paper; break;
				default: break;
			}
		}
		
		if(rock == 5 || scissors == 5 || paper == 5 || (rock > 0 && scissors > 0 && paper > 0)){
			for(int i = 0; i < 5; ++i) result[i] = 3;
		}else{
			if(rock == 0) win = 2;
			else if(scissors == 0) win = 3;
			else win = 1;
			
			for(int i = 0; i < 5; ++i){
				if(hand[i] == win) result[i] = 1;
				else result[i] = 2;
			}
		}
		
		for(int i = 0; i < 5; ++i) cout << result[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	typedef pair<string, LL> P;
	queue<P> q;
	q.push(P(string(""), 0));
	string alphabet[10] = {
		string("a"),string("b"),string("c"),string("d"),string("e"),string("f"),string("g"),string("h"),string("i"),string("j")
	};
	while (!q.empty()) {
		string str = q.front().first;
		LL used = q.front().second;
		q.pop();
		if (str.size() == N) {
			cout << str << "\n";
			continue;
		}
		for (LL u = 0; u < used; u++) {
			q.push(P(str + alphabet[u], used));
		}
		q.push(P(str + alphabet[used], used + 1));
	}
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	if (s == "Cloudy") cout << "Rainy" << endl;
	if (s == "Rainy") cout << "Sunny" << endl;
}



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


#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )


typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;


template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

/*end of header*/

int n,a;
int f,t,on;
int main()
{
    //freopen("input_file_name.in","r",stdin);
    //freopen("output_file_name.out","w",stdout);
    scanf("%d",&n);
    REP(i,1,n)
    {
        scanf("%d",&a);
        if(a%4==0)f++;
        else if(a%2==0)t++;
        else on++;
    }
    if((t==0 && f+1>=on)||(t>0 && f>=on))print("Yes");
    else print("No");
    return 0;
}



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

int n,m,ans;
vector<int>x,y,z,p;

int find(int x){
    if(p[x]==x)return x;
    return p[x]=find(p[x]);
}
void merge(int x,int y){
    x--,y--;
   int rootx=find(x);
   int rooty=find(y);
   if(rooty!=rootx){
       p[rootx]=rooty;
       ans--;
   }
}
int solve(){
   rep(i,m)merge(x[i],y[i]);
   return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

scanf("%d%d",&n,&m);
rep(i,m){
    int xi,yi,zi;
    scanf("%d%d%d",&xi,&yi,&zi);
    x.push_back(xi);
    y.push_back(yi);
    z.push_back(zi);
}
p.resize(n);
rep(i,n){
    p[i]=i;
}
ans=n;
cout<<solve()<<endl;
return 0;
}

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

void permutation(int k, int n, set<int> st, vector<int> row, vector<vector<int>> &matrix) {
    if (k < n-1) {
        for (auto itr = st.begin(); itr != st.end(); itr++) {
            set<int> copy_st = st;
            vector<int> copy_row = row;
            copy_row.push_back(*itr);
            copy_st.erase(*itr);
            permutation(k+1, n, copy_st, copy_row, matrix);
        }
    }
    if (k == n-1) {
        auto itr = st.begin();
        row.push_back(*itr);
        matrix.push_back(row);
    }
}


int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) {
        cin >> p[i];
    }
    rep(i,n) {
        cin >> q[i];
    }
    set<int> st;
    vector<int> row;
    vector<vector<int>> matrix;
    rep(i,n) {
        st.insert(i+1);
    }
    permutation(0, n, st, row, matrix);
    int a = 100, b = 10;
    rep(i,matrix.size()) {
        if (matrix[i] == p) a = i+1;
        if (matrix[i] == q) b = i+1;
    }
    int ans = abs(a - b);
    cout << ans << endl;
}

Measured memory_bytes: 3384
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;

ll solveRB(const vector<vector<ll>>& xy) {
  const int N = xy.size();
  ll rmax = 0, rmin = INF;
  ll bmax = 0, bmin = INF;
  for (int i = 0; i < N; i++) {
    rmax = max(rmax, xy[i][1]);
    rmin = min(rmin, xy[i][1]);
    bmax = max(bmax, xy[i][0]);
    bmin = min(bmin, xy[i][0]);
  }
  return (rmax - rmin) * (bmax - bmin);
}

ll solveRR(const vector<vector<ll>>& xy) {
  const int N = xy.size();
  ll rmax = 0, rmin = INF;
  for (int i = 0; i < N; i++) {
    rmin = min(rmin, xy[i][0]);
    rmax = max(rmax, xy[i][1]);
  }
  ll bmax = 0, bmin = INF;
  ll res = INF;
  for (int i = 0; i < N; i++) {
    bmax = max(bmax, xy[i][1]);
    bmin = min(bmin, xy[i][1]);
    if (i + 1 < N) {
      res = min(res, (rmax - rmin) *
                         (max(bmax, xy[N - 1][0]) - min(bmin, xy[i + 1][0])));
    }
  }
  res = min(res, (rmax - rmin) * (bmax - bmin));
  return res;
}

int main() {
  int N;
  while (cin >> N) {
    vector<vector<ll>> xy(N, vector<ll>(2));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 2; j++) {
        cin >> xy[i][j];
      }
      if (xy[i][0] > xy[i][1]) {
        swap(xy[i][0], xy[i][1]);
      }
    }
    sort(xy.begin(), xy.end(),
         [&](const vector<ll>& a, const vector<ll>& b) { return a[0] < b[0]; });
    cout << min(solveRB(xy), solveRR(xy)) << endl;
  }
  return 0;
}


Measured memory_bytes: 11264
import math
A, B, H, M = map(int, input().split())
hour = complex(0, A)
minute = complex(0, B)
hourTheta = math.pi / 180 * (360 // 12 * (3 - H) - M / 2)
minuteTheta = math.pi / 180 * (360 // 60 * (15 - M))
hour *= complex(math.cos(hourTheta), math.sin(hourTheta))
minute *= complex(math.cos(minuteTheta), math.sin(minuteTheta))
print(abs(hour - minute))

Measured memory_bytes: 9340
#include<stdio.h>
int main()
{
          long int T,i,j,x,y,z,A[10000],sum=0;
          scanf("%d",&T);
          for(i=0;i<T;i++)
          {
                    scanf("%ld",&A[i]);
                    sum=sum+A[i];
          }
          for(i=0;i<T-1;i++)
          {
                    for(j=0;j<T-i-1;j++)
                    {
                              if(A[j]>A[j+1])
                              {
                                  y=A[j];
                                  A[j]=A[j+1];
                                  A[j+1]=y;
                              }

                    }
          }
          printf("%ld %ld %ld\n",A[0],A[T-1],sum);
          return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int A[] =new int[N];
    int B[] =new int[N];
    for(int j=0;j<N;j++){
      B[j]=0;}
    for(int i=0;i<N-1;i++){
      A[i]=sc.nextInt();
      B[A[i]-1]=B[A[i]-1]+1;}
    for(int k=0;k<N;k++){
      System.out.println(B[k]);}
  }
}

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

typedef pair<int,int> P;
const int MAX = 201;

int main(){
  int n;

  while(cin >> n ,n){
    vector<P> v;

    int x,y;
    for(int i = 0 ; i < n ; i++){
      cin >> x >> y;
      v.push_back(P(x,y));
    }
    int m;
    cin >> m;
    for(int i = 0 ; i < m ; i++){
      cin >> x >> y;
      v.push_back(P(x,y));
    }

    sort(v.begin(),v.end());
    int dp[MAX] = {0};
    int ans = 0;

    for(int i = 0 ; i < n+m ; i++){
      dp[i] = 1;
      for(int j = 0 ; j < i ; j++){
	if(v[j].first < v[i].first && v[j].second < v[i].second){
	  dp[i] = max(dp[i],dp[j]+1);
	}
      }
      ans = max(ans,dp[i]);
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>

static int INFTY = (1<<21);
static int MAX=100;
static int WHITE=0;
static int GRAY=1;
static int BLACK=2;

int M[100][100],n;

void dijikstra(){
    int min,i,v,u;
    int d[MAX],color[MAX];
    
    for(i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    
    d[0]=0;
    color[0]=GRAY;
    while(1){
        min=INFTY;
        u=-1;
        for(i=0;i<n;i++){
            if(min>d[i] && color[i] != BLACK){
                u=i;
                min=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v]>d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d %d",i,(d[i]==INFTY ? -1 : d[i]));
        printf("\n");
    }
}


int main(){
   
    int i,j,k,c,u,v;
    
    scanf("%d",&n);
    for(i=0;i<=n;i++){
       for(j=0;j<=n;j++){
            M[i][j] = INFTY;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            M[u][v]=c;
        }
    }
    
    dijikstra();
    
    return 0;
}



Measured memory_bytes: 2052
#include <stdio.h>

using namespace std;

struct Node{
	Node(){
		left_child = right_child = parent = -1;
	}
	int left_child,right_child,parent;
};

class Heap{
public:
	Heap(int H){
		index = 0;
		array = new long long[H];
		struct_array = new Node[H];
	}
	~Heap(){
		delete[] array;
	}
	void push(long long data){
		array[index] = data;
		if(index != 0){
			if(index%2 == 0){
				struct_array[(index-1)/2].right_child = index;
				struct_array[index].parent = (index-1)/2;
			}else{
				struct_array[index/2].left_child = index;
				struct_array[index].parent = index/2;
			}
		}
		index++;
	}

	void print(){
		for(int i = 0; i < index; i++){
			printf("node %d: key = %d, ",i+1,array[i]);
			if(struct_array[i].parent != -1) printf("parent key = %lld, ",array[struct_array[i].parent]);
			if(struct_array[i].left_child != -1) printf("left key = %lld, ",array[struct_array[i].left_child]);
			if(struct_array[i].right_child != -1) printf("right key = %lld, ",array[struct_array[i].right_child]);
			printf("\n");
		}
	}

private:
	long long* array;
	Node* struct_array;
	int index;
};

int main(){
	int H;
	long long tmp;
	scanf("%d",&H);
	Heap heap(H);

	for(int i = 0; i < H; i++){
		scanf("%lld",&tmp);
		heap.push(tmp);
	}
	heap.print();
}



Measured memory_bytes: 2688
a,b,c,d = list(map(int,input().split()))
if c<=a<=d<=b:
    print(d-a)
elif c<=a<=b<=d:
    print(b-a)
elif a<=c<=d<=b:
    print(d-c)
elif a<=c<=b<=d:
    print(b-c)
else:
    print(0)

Measured memory_bytes: 3060
from collections import defaultdict
from heapq import heappop, heappush

n, m, s, t = map(int, input().split())
c = 10**15
graph = defaultdict(list)
for _ in range(m):
  u, v, a, b = map(int, input().split())
  graph[u].append((v, a, b))
  graph[v].append((u, a, b))

dyen = defaultdict(lambda:float("INF"))
dsnuuk = defaultdict(lambda:float("INF"))
dyen[s] = 0
dsnuuk[t] = 0

def dijkstra(s, m):
  used = defaultdict(bool)
  q = []
  heappush(q, (0, s))

  while len(q):
    v = heappop(q)
    cost, cur = v[0], v[1]

    if used[v]:
      continue
    used[v]=True

    for to, a, b in graph[cur]:
      if m==0 and dyen[to]>cost+a:
        dyen[to] = cost+a
        heappush(q, (cost+a, to))
      elif m==1 and dsnuuk[to]>cost+b:
        dsnuuk[to] = cost+b
        heappush(q, (cost+b, to))

dijkstra(s, 0)
dijkstra(t, 1)

costs = [float("INF")]*(n+1)
min_ = float("INF")
for i in range(n, 0, -1):
  min_ = min(min_, dyen[i]+dsnuuk[i])
  costs[i] = min_

for i in range(1, n+1):
  print(c-costs[i])

Measured memory_bytes: 92920
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

const int MOD = 100000;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    int* point = new int[n];
    fill(point, point + n, k - q);
    rep(i, q) {
        int a;
        cin >> a;
        point[a - 1]++;
    }
    rep(i, n) {
        cout << (point[i] > 0? "Yes" : "No") << endl;
    }
}


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

int main()
{
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if (N - K >= 0)
    {
        cout << K * X + (N - K) * Y << endl;
    }else{
        cout << N*X << endl;
    }
}

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


int main() {
  int N;
  cin >> N;
  vector<int> h(N);

  for(int i = 0; i < N; i++) cin >> h[i];
    int ans = h[0];
  for(int i = 0; i < N - 1; i++) {
    if(h[i + 1] > h[i]) ans += (h[i + 1] - h[i]);

  }

    cout << ans;
    return 0;
}

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

string s;
string t = "yuiophjklnm";

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> s;
		if(s == "#") return 0;
		for(int i=0; i<s.size(); ++i){
			bool f = false;
			for(int j=0; j<t.size(); ++j)
				if(s[i] == t[j])
					f = true;
			if(f) s[i] = '0';
			else s[i] = '1';
		}
		int ans = 0;
		for(int i=1; i<s.size(); ++i)
			if(s[i] != s[i-1])
				++ans;
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
using namespace std;
string T,F;
void fuego() {string ans,g;int i,j,k=1;T+='-';F="";for (i=1,j=T.size();i<j;i++) if (T[i]!=T[i-1]) {while (k) g=k%10+'0',ans=g+ans,k/=10;F+=ans+T[i-1];k=1,ans="";} else k++;T=F;}
int main() {int N;while (1) {cin>>N;if (!N) return 0;cin>>T;while (N--) fuego();cout<<T<<endl;}}

Measured memory_bytes: 0
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let (h, w) = readl!(i32, i32);
    let s: Vec<Vec<_>> = (0..h).map(|_| readl!(String).into_bytes().into_iter().map(|c|
        if c == '#' as u8 {
            true
        } else {
            false
        }
    ).collect()).collect();

    let dx = [-1, 0, 1, 0];
    let dy = [0, -1, 0, 1];
    let mut ans = true;
    for i in 0..h {
        for j in 0..w {
            if s[i as usize][j as usize] {
                let check = |x, y| 0 <= x && x < h && 0 <= y && y < w;
                let mut f = false;
                for k in 0..4 {
                    let ni = i+dx[k];
                    let nj = j+dy[k];
                    if check(ni, nj) && s[ni as usize][nj as usize] {
                        f = true;
                    }
                }
                if !f {
                    ans = false;
                }
            }
        }
    }
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

typedef long long ll;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    int len=s.length();
    // dp[i][j] := i 文字見て j 文字決定済み組み合わせ
    vector<vector<ll>> dp(len+1,vector<ll>(4,0));
    dp[0][0]=1;
    for(int i=0;i<len;i++){
      if(s[i]=='A'){
        dp[i+1][0]=dp[i][0];
        dp[i+1][1]=dp[i][1];
        dp[i+1][2]=dp[i][2];
        dp[i+1][3]=dp[i][3];

        dp[i+1][1]+=dp[i][0];
        dp[i+1][1]%=MOD;
      }
      else if(s[i]=='B'){
        dp[i+1][0]=dp[i][0];
        dp[i+1][1]=dp[i][1];
        dp[i+1][2]=dp[i][2];
        dp[i+1][3]=dp[i][3];

        dp[i+1][2]+=dp[i][1];
        dp[i+1][2]%=MOD;
      }
      else if(s[i]=='C'){
        dp[i+1][0]=dp[i][0];
        dp[i+1][1]=dp[i][1];
        dp[i+1][2]=dp[i][2];
        dp[i+1][3]=dp[i][3];

        dp[i+1][3]+=dp[i][2];
        dp[i+1][3]%=MOD;
      }
      else{
        dp[i+1][0]=3*dp[i][0];
        dp[i+1][0]%=MOD;
        dp[i+1][1]=3*dp[i][1];
        dp[i+1][1]%=MOD;
        dp[i+1][2]=3*dp[i][2];
        dp[i+1][2]%=MOD;
        dp[i+1][3]=3*dp[i][3];
        dp[i+1][3]%=MOD;

        dp[i+1][1]+=dp[i][0];
        dp[i+1][1]%=MOD;
        dp[i+1][2]+=dp[i][1];
        dp[i+1][2]%=MOD;
        dp[i+1][3]+=dp[i][2];
        dp[i+1][3]%=MOD;
      }
    }
    cout<<dp[len][3]<<endl;
}


Measured memory_bytes: 7376
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;

    long long ans = n;
    for( long long d=1; d<=sqrt(n); d++){
        if( n%d==0){
            ans = min(ans,d+n/d-2);
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
X, Y, Z, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

sorted_a = A.sort_by { |n| -n }
sorted_b = B.sort_by { |n| -n }
sorted_c = C.sort_by { |n| -n }

candidates = []
sorted_a.each.with_index do |a, i|
  i += 1
  sorted_b.each.with_index do |b, j|
    j += 1
    sorted_c.each.with_index do |c, k|
      k += 1
      break if i * j * k > K
      candidates.push(a + b + c)
    end
  end
end
candidates.sort_by { |n| -n }.take(K).each do |n|
  puts n
end


Measured memory_bytes: 6264
package main                                
                                            
import (                                    
        "fmt"                               
)                                           
                                            
func calc(n int) int {                      
        ans := 0                            
        for i := 1; i <= n/2; i++ {         
                if n%i == 0 {               
                        ans += 1            
                }                           
        }                                   
        return ans + 1                      
}                                           
func main() {                               
        var N int                           
        fmt.Scanf("%d", &N)                 
                                            
        ans := 0                            
        for i := 105; i <= N; i = i + 2 {         
                if calc(i) == 8 {           
                        ans += 1            
                }                           
        }                                   
        fmt.Println(ans)                    
}                                           

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

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

  vector<tuple<int,int,int>> a(N);

  int i,j;
  for(i=0;i<N;i++){
    int s,l,p;
    cin>>s>>l>>p;
    get<0>(a.at(i))=s;
    get<1>(a.at(i))=l;
    get<2>(a.at(i))=p;
  }

  int k,m;
  bool chek=0;
  cin>>m;
  vector<int> ans(m);
  for(k=0;k<m;k++){
    cin>>W;
    vector<vector<long long>> dp(N+1,vector<long long>(W+1,0));
    for(i=0;i<N;i++){
      for(j=0;j<=W;j++){
        if(j-get<0>(a.at(i))<0){
          dp.at(i+1).at(j)=dp.at(i).at(j);
        }else{
          dp.at(i+1).at(j)=max(dp.at(i).at(j),dp.at(i+1).at(j-get<0>(a.at(i)))+get<2>(a.at(i)));
        }
      }
    }
    if(dp.at(N).at(W)==0){
      chek=1;
      break;
    }
    ans.at(k)=dp.at(N).at(W);
  }
  if(chek)
  cout<<-1<<endl;
  else{
    for(k=0;k<m;k++)
    cout<<ans.at(k)<<endl;
  }

}



Measured memory_bytes: 4124
// 19/09/2020  @ 17:34:52
// *****************************************************************
// *****************************************************************
#include <bits/stdc++.h>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define Pi 3.1415926535897932384626
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
#define pb push_back
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define printer(a, n) fr(i,n) cout << a[i] << " ";
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
bool rev(ll a, ll b) {
    return a > b;
}
// *****************************************************************
void solution() {
    int n;
    cin >> n;
    int ans = 0;
    int x, y;
    fr(i, n) {
        cin >> x >> y;
        if(x == y) {
            ans++;
        }
        else ans = 0;
        if(ans == 3) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";

}
// *****************************************************************
int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    //     freopen("C:/Users/Mr.Tanishq/Desktop/noc/input.txt", "r", stdin);
    //     freopen("C:/Users/Mr.Tanishq/Desktop/noc/output.txt", "w", stdout);
    //     freopen("C:/Users/Mr.Tanishq/Desktop/noc/error.txt", "w", stderr);
    // #endif
    // *****************************************************************
    // *****************************************************************
    int t = 1;
    // cin >> t;
    while(t--) {

       solution();
       cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int k, s, count = 0;
	cin >> k >> s;
	for (int i = 0; i <= k; ++i) {
		for (int j = 0; j <= k; ++j) {
			if (0 <= s - i - j && s - i - j <= k)
				++count;

		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X - A) % B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

vector<vector<int>> G;
bool used[101010];
ll dp[101010][2];
int root[101010];

void dfs(int v){
    for(auto nv : G[v]) if(nv != root[v]){
        root[nv] = v;
        dfs(nv);
    }
}

void solve(int i){
    if(used[i]) return;
    used[i] = true;
    dp[i][0] = 1;
    dp[i][1] = 1;
    for(auto ni : G[i]){
        if(ni == root[i]) continue;
        solve(ni);
        dp[i][0] = dp[i][0] * (dp[ni][0] + dp[ni][1]) % MOD;
        dp[i][1] = dp[i][1] * dp[ni][0] % MOD;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    G.resize(N+1);
    REP(i,N-1){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    REP(i,N) root[i] = -1;
    dfs(1);
    solve(1);
    ll ans = (dp[1][0] + dp[1][1]) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 13312
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,m;
  cin>>n>>m;
  ll ans=n*2+m;
  cout<<min(m/2,ans/4)<<endl;
}



Measured memory_bytes: 256
def isPrime(n):
    j = 2
    while j * j <= n:
        if n % j == 0:
            return False
        j += 1
    return True

if __name__ == '__main__':
    n = int(input())
    ans = 0
    for i in range(n):
        m = int(input())
        if isPrime(m):
            ans += 1
    print(ans)


Measured memory_bytes: 5612