akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

struct not_found {};

string join(const vector<string>& v)
{
  string s = "";
  for (vector<string>::const_iterator it(v.begin()); it != v.end(); ++it) {
    s += "/" + *it;
  }
  return s;
}

string expand(const set<string>& s, string path)
{
  vector<string> parts;
  string::iterator it = path.begin()+1;
  string base;
  while (true) {
    string::iterator jt = find(it, path.end(), '/');
    if (jt == path.end()) {
      base = string(it, jt);
      break;
    }
    parts.push_back(string(it, jt));
    it = jt+1;
  }

  vector<string> ans;
  for (vector<string>::const_iterator jt(parts.begin()); jt != parts.end(); ++jt) {
    if (*jt == ".") {
    } else if (*jt == "..") {
      ans.pop_back();
    } else {
      ans.push_back(*jt);
    }
    if (!s.count(join(ans) + "/")) {
      throw not_found();
    }
  }
  if (base == ".") {
    base = "";
  } else if (base == "..") {
    if (ans.empty()) {
      throw not_found();
    }
    base = "";
    ans.pop_back();
  }

  string dir = join(ans);
  //cerr << "dir=" << dir << ", base=" << base << endl;
  if (s.count(dir+"/"+base+"/")) {
    dir += "/"+base;
    base = "";
  }
  if (base.empty()) {
    base = "index.html";
  }
  string a = dir+"/"+base;
  if (!s.count(a)) {
    throw not_found();
  }
  return a;
}

int main()
{
  int N, M;
  while (cin >> N >> M && N != 0) {
    set<string> s;
    for (int i = 0; i < N; i++) {
      string t;
      cin >> t;
      for (string::iterator it = t.begin(); it != t.end(); ++it) {
        if (*it == '/') {
          s.insert(string(t.begin(), it) + "/");
        }
      }
      s.insert(t);
    }

    for (int i = 0; i < M; i++) {
      string s1, s2;
      cin >> s1 >> s2;
      try {
        cout << (expand(s, s1) == expand(s, s2) ? "yes" : "no") << endl;
      } catch (const not_found&) {
        cout << "not found" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
MIS = lambda: map(int,input().split())
from math import acos

def ccw(p1, p2, p3):
    # positive -> ccw; negative -> cw; 0 -> collinear
    return (p2[0]-p1[0])*(p3[1]-p1[1]) - (p2[1]-p1[1])*(p3[0]-p1[0])

def ConvexHull(p):
    U = []; L = []; p.sort()
    for q in p:
        while len(U)>1 and ccw(U[-2], U[-1], q) >= 0: U.pop()
        while len(L)>1 and ccw(L[-2], L[-1], q) <= 0: L.pop()
        U.append(q); L.append(q)
    return U + L[-2:0:-1]

def angle(v1, v2):
    inner = v1[0]*v2[0] + v1[1]*v2[1]
    v1s = (v1[0]**2 + v1[1]**2) ** .5
    v2s = (v2[0]**2 + v2[1]**2) ** .5
    return acos(inner / v1s / v2s)

n = int(input())
if n == 1: print(1); exit()
if n == 2: print(0.5); print(0.5); exit()

p = [tuple(MIS())+(i,) for i in range(n)]
CH = ConvexHull(p)
bsc = []
for i in range(len(CH)):
    x1, y1, i1 = CH[i]
    x2, y2, i2 = CH[i-1]
    bsc.append((y1-y2, x2-x1))
if len(CH) == 2: angles = [1, 1]
else: angles = [angle(bsc[i], bsc[i-1]) for i in range(len(CH))]
S = sum(angles)

ans = [0] * n
for i in range(len(CH)):
    x, y, ind = CH[i-1]
    ans[ind] = angles[i] / S
for x in ans: print(x)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3005;
int n,M,dp[N][N],fac2[N],val[N],ans,fac[N],inv[N];
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
int C(int x,int y){
	if (x<y)return 0;
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
signed main(){
	scanf("%lld%lld",&n,&M);
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=i;j++)
			dp[i][j]=((j==0?0:dp[i-1][j-1])+dp[i-1][j]*j+dp[i-1][j])%M;
	fac[0]=fac2[0]=inv[0]=1;
	for (int i=1;i<=n;i++)fac2[i]=fac2[i-1]*2%(M-1),fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	for (int i=0;i<=n;i++)val[i]=ksm(2,fac2[n-i]);
	for (int i=0;i<=n;i++){
		for (int k=0;k<=i;k++)
			if (!(i&1))(ans+=val[i]*dp[i][k]%M*C(n,i)%M*ksm(2,(n-i)*k))%=M;
			else (ans+=M-val[i]*dp[i][k]%M*C(n,i)%M*ksm(2,(n-i)*k)%M)%=M;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 69248
import java.io._
import java.util.StringTokenizer
import java.math.BigInteger

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val X = new BigInteger(in.next())
  println(X.add(new BigInteger("-1")).nextProbablePrime)
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 27452
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    c=max(c,a-b);
    c=max(c,a*b);
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;

int main(){
  ll A,B,C,ans;
  cin>>A>>B>>C;
  if(A%2==0 || B%2==0 || C%2==0){
    ans=0;
  }else{
    ans=min(A*B,B*C);
    ans=min(ans,C*A);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

struct segtree {
	ll size;
	vl sums; // the required segtree

	void init (ll n) {
		// while initialising the segtree we make sure that the size is a power of 2
		// because, we compare everything in pairs.
		size = 1;
		while(size < n) size*=2;
		// we initialise all the elements to 0 (in this case)
		sums.assign(2*size, 0LL);
	}

	void build (vl &a, ll x, ll lx, ll rx) {
		// we build the segtree in linear time, using a vector which is passed as an argument to build
		if(rx-lx==1) {
			if(lx < a.size()) {
				sums[x] = a[lx];
			}
			return;
		}
		ll m = (lx+rx)/2;
		build(a, 2*x+1, lx, m);
		build(a, 2*x+2, m, rx);
		sums[x] = sums[2*x+1] + sums[2*x+2];
	}

	void build(vl &a) {
		build(a, 0, 0, size);
	}

	void set (ll i, ll v, ll x, ll lx, ll rx) {
		if(rx - lx == 1) {
			sums[x] = v;
			return;
		}
		ll m = (lx + rx)/2;
		if(i<m) {
			set(i, v, 2*x+1, lx, m);
		}
		else {
			set(i, v, 2*x+2, m, rx);
		}
		sums[x] = sums[2*x+1] + sums[2*x+2];
	}

	void set (ll i, ll v) {
		set(i, v, 0, 0, size);
	}

	ll sum (ll l, ll r, ll x, ll lx, ll rx) {
		// querying for the sum of the segment [l,r) will take logn time which can't be optimised
		if(lx>=r or l>=rx) return 0;
		if(lx>=l and rx<=r) return sums[x];
		ll m = (lx+rx)/2;
		return sum(l,r,2*x+1,lx,m)+sum(l,r,2*x+2,m,rx);
	}

	ll sum (ll l, ll r) {
		return sum(l,r,0,0,size);
	}
};


void check()
{
	ll n, sum = 0;
	cin >> n;
	ll q;
	umap m;
	for(int i=0;i<n;i++) {
		ll x;
		cin >> x;
		m[x]++;
		sum+=x;
	}
	cin >> q;
	while(q--) {
		ll x, y;
		cin >> x >> y;
		sum += (m[x]*(y-x));
		m[y] += m[x];
		m[x] = 0;
		cout << sum << endl;
	}
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


Measured memory_bytes: 7092
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
ll dice[200005]={0};
int main(){
  ll n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>dice[i];
  ll first=0,ans=0;
  for(int i=1;i<=k;i++) first+=dice[i]+1;
  ans=first;
  for(int i=1;i+k<=n;i++){
    first-=dice[i];
    first+=dice[i+k];
    ans=max(ans,first);
  }
  cout<<fixed<<setprecision(4)<<((double)ans/2)<<endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define LL long long

int n;
vector<LL> a;

void input() {
	scanf("%d", &n);
	a = vector<LL>(n + 1);
	for (int i = 0; i <= n; ++i) {
		// scanf("%lld", &a[i]);
		cin >> a[i];
	}
}

void work() {
	LL leafN = 0;
	LL maxLeafN = 0;
	vector<LL> h(n + 1);
	vector<LL> limit(n + 1);
	limit[0] = (LL)(1);
	for (int i = 1; i <= n; ++i) {
		if (limit[i - 1] >= ((LL)(1) << 62)) {
			limit[i] = limit[i - 1];
		} else {
			limit[i] = (limit[i - 1] - a[i - 1]) * (LL)(2);
		}
		if (limit[i] <= (LL)(0)) {
			cout << (-1) << endl;
			// cout << "at height " << i << endl;
			return ;
		}
	}
	for (int i = n; i >= 0; --i) {
		leafN += a[i];
		maxLeafN += a[i];
		if ((leafN > limit[i])) {
			cout << (-1) << endl;
			// cout << "at height " << i << endl;
			return ; 
		}
		if (true) {
			maxLeafN = min(maxLeafN, limit[i]);
		}
		h[i] = maxLeafN;
		leafN = (leafN + (LL)(1)) / (LL)(2);
	}
	LL res = (LL)(0);
	for (int i = 0; i <= n; ++i) {
		res += h[i];
		// cout << h[i] << ' ';
	}
	cout << res << endl;
}

int main() {
	input();
	work();
	return 0;
}

Measured memory_bytes: 5696
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int A, B; cin >> A >> B;
	string S; cin >> S;
	bool flag = true;

	if (S[A] != '-')flag = false;
	else {
		rep(i, 0, A + B + 1) {
			if (i == A)continue;
			if (!(S[i] >= '0'&&S[i] <= '9')) {
				flag = false;
				break;
			}
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

string b;

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

  if (b == "A") {
    cout << "T" << endl;
  } else if (b == "T") {
    cout << "A" << endl;
  } else if (b == "C") {
    cout << "G" << endl;
  } else if (b == "G") {
    cout << "C" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  int ans = H*W - h*W - w*H + h*w;
  OUT(ans);
}	

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<long long,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    int sum = 0;
    for(int i = 0;i<=10;i++){
        if(sum >= N){
            cout << sum-N << endl;
            return 0;
        }
        sum += 1000;
    }
}


Measured memory_bytes: 3648
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 11:49:42
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

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

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

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int a, b;
    cin >> a >> b;

    int c = a + b;
    if (c % 2 == 0) cout << c/2 << endl;
    else cout << c/2 + 1 << endl;

    return 0;
}


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

const int INF = 1e9;
int h, n;
int a[10000], b[10000];
int dp[10001];

int main() {
    scanf("%d %d", &h, &n);
    for (int i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    
    for (int i = 1; i <= h; i++) dp[i] = INF;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < n; j++) {
            int k = (i + a[j] < h) ? i + a[j] : h;
            dp[k] = min(dp[k], dp[i] + b[j]);
        }
    }
    
    printf("%d\n", dp[h]);
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(a, x) memset(a, x, sizeof(a))
#define len(x) (x).size()
#define pb push_back
#define eb emplace_back
#define f first
#define s second

const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 1e9 + 7;
const int maxn = 1e5+5;

int n, k;
int h[maxn];
bool seen[maxn];
int dp[maxn];

int solve(int idx) {
    if (idx == n-1) return 0;
    if (seen[idx]) return dp[idx];
    seen[idx] = true;
    int ans = inf;
    for (int i = 1; i <= k; ++i) {
        if (idx + i >= n) break;
        ans = min(ans, solve(idx + i) + abs(h[idx] - h[idx + i]));
    }
    return dp[idx] = ans;
}

int main() {
    fastIO();
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h[i];
    
    for (int idx = n-2; idx >= 0; --idx) {
        int &ans = dp[idx];
        ans = inf;
        for (int i = 1; i <= k; ++i) {
            if (i + idx >= n) break;
            ans = min(ans, dp[idx + i] + abs(h[idx] - h[idx + i]));
        }
    }

    cout << dp[0] << "\n";
    return 0;
}



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

int main()
{
  int a, b;
  for (int i = 0; i < 10000; i++) {
    cin >> a >> b;
    if (a == 0 && b == 0) break;
    
    for (int j = 0; j < a; j++) {
      for (int k = 0; k < b; k++) {
        if (j == 0 || j == a-1 || k == 0 || k == b-1)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl; 
    }
    cout << endl;
  }
  return 0;
}



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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VL a(n);
    VI f(n);
    REP(i,n) cin >> a[i];
    VL inc;
    inc.push_back(0);
    ll ma = 0;
    REP(i,n){
        if (a[i] > ma){
            f[i] = 1;
            ma = a[i];
            inc.push_back(ma);
        }
    }
    VL b(a);
    sort(ALL(b), greater<ll>());
    int m = inc.size();
    int j = m-1;
    ll s = 0;
    map<ll, ll> mp;
    REP(i,n){
        if (b[i] > inc[j-1]){
            s += b[i] - inc[j-1];
        }else{
            mp[inc[j]] = s;
            j--;
            s = (i+1)*(inc[j]-inc[j-1]);
        }
    }
    mp[inc[j]] = s;
    VL ans(n);
    REP(i,n){
        if (f[i]) ans[i] = mp[a[i]];
    }
    REP(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 10740
n, ma, mb = gets.chomp.split(' ').map(&:to_i)
items = []
n.times do
  items << gets.chomp.split(' ').map(&:to_i)
end
sa, sb, sc = items.inject([0, 0, 0]) do |acc, i|
  [acc[0] + i[0], acc[1] + i[1], acc[2] + i[2]]
end
dp = Array.new(n + 1)
(n + 1).times do |i|
  dp[i] = Array.new(sa + 1)
  (sa + 1).times { |j| dp[i][j] = Array.new(sb + 1, sc + 1) }
end
dp[0][0][0] = 0
n.times do |i|
  a, b, c = items[i]
  (sa + 1).times do |j|
    (sb + 1).times do |k|
      if j - a >= 0 && k - b >= 0
        dp[i + 1][j][k] = [dp[i][j][k], dp[i][j - a][k - b] + c].min
      else
        dp[i + 1][j][k] = [dp[i + 1][j][k], dp[i][j][k]].min
      end
    end
  end
end
min = sc + 1
(1..n).each do |i|
  (1..sa).each do |j|
    (1..sb).each do |k|
      min = [min, dp[i][j][k]].min if j * mb == k * ma
    end
  end
end
puts min == sc + 1 ? -1 : min

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

using namespace std;

int main()
{
    while(1){
        string s,t;
        cin >> s;
        if(s == ".") break;
        cin >> t;
        if(s == t){
            cout << "IDENTICAL\n";
            continue;
        }
        vector<string> a[2];
        vector<string> b[2];
        int st = -1, nw = 0;
        s.push_back('\"');
        rep(i,len(s)){
            if(s[i] == '\"'){
                a[nw].push_back(s.substr(st+1,i-st-1));
                st = i;
                nw ^= 1;
            }
        }
        st = -1, nw = 0;
        t.push_back('\"');
        rep(i,len(t)){
            if(t[i] == '\"'){
                b[nw].push_back(t.substr(st+1,i-st-1));
                st = i;
                nw ^= 1;
            }
        }
        if(a[0] != b[0]){
            cout << "DIFFERENT\n";
            continue;
        }
        if(len(a[1]) != len(b[1])){
            cout << "DIFFERENT\n";
            continue;
        }
        int dif = 0;
        rep(i,len(a[1])){
            if(a[1][i] != b[1][i]){
                if(dif){
                    cout << "DIFFERENT\n";
                    dif++;
                    break;
                }else{
                    dif++;
                }
            }
        }
        if(dif <= 1) cout << "CLOSE\n";
    }
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

int dp[200005][2];

void Main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n == 1) {
        cout << 1 << endl;
        return;
    } else {
        if (s[0] == s[1]) {
            dp[0][0] = 1;
            dp[0][1] = 0;
            dp[1][0] = 1;
            dp[1][1] = 1;
        } else {
            dp[0][0] = 1;
            dp[0][1] = 0;
            dp[1][0] = 2;
            dp[1][1] = 1;
        }
    }
    rep2(i, 2, n) {
        if (s[i] == s[i - 1]) {
            dp[i][0] += dp[i - 1][1] + 1;
            dp[i][1] += dp[i - 2][0] + 1;
        } else {
            dp[i][0] += dp[i - 1][0] + 1;
            dp[i][1] += dp[i - 2][0] + 1;
        }
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
}

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


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i, j, k) for(register int i = j; i <= k; ++i)
#define D(i, j, k) for(register int i = j; i >= k; --i)
#define random(x) (rand() % (x)) + 1
#define pb push_back
#define fi first
#define se second
#define pp pair<int, int>
#define mp make_pair
#define error(x) cerr << #x << "=" << x << endl
//***********var defination*********
const int maxn = 5;
int n, m, x, y, z;
char a[maxn][maxn];
//**********Code by Gengchen********
//WA RE TLE MLE 10 pts
//Always look up the code afeter programming
//Keep Calm
//by GengChen================
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    scanf("%s", a[1]+1);
    scanf("%s", a[2]+1);
    if(a[1][1] == a[2][3] && a[1][2] == a[2][2] && a[1][3] == a[2][1]) return puts("YES"), 0;
    puts("NO");
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  string a, b;
  cin >> a >> b;

  if (a == b) {
    cout << "EQUAL" << endl;
    return 0;
  }

  if (a.size() > b.size()) {
    cout << "GREATER" << endl;
    return 0;
  }
  if (a.size() < b.size()) {
    cout << "LESS" << endl;
    return 0;
  }

  for (ll i = 0; i < a.size(); ++i) {
    int an = a[i] - '0';
    int bn = b[i] - '0';
    if (an > bn) {
      cout << "GREATER" << endl;
      return 0;
    } else if (an < bn) {
      cout << "LESS" << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
# 解答
def abc173_a(lines):
    N = int(lines[0])
    results = list()
    for i in range(10000):
        results.append(0)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if tmp <= 10000:
                    results[tmp-1] += 1
    answers = list()
    for i in range(N):
        answers.append(results[i])
    return answers


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['20']
        lines_export = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = abc173_a(lines_input)

    for line_result in lines_result:
        print(line_result)

    if mode > 0:
        print(f'lines_input=[{lines_input}]')
        print(f'lines_export=[{lines_export}]')
        print(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            print('OK')
        else:
            print('NG')


# 起動処理
if __name__ == '__main__':
    main()


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(auto &i : p) cin >> i;
    vector<int> b(n+1, 0);
    for(int i = 0; i < p.size(); i++){
        b.at(i+1) = b.at(i)+p.at(i);
    }
    int sum_max = 0;
    for(int i = 0; i < b.size()-k; i++){
        sum_max = max(sum_max, b.at(i+k)-b.at(i));
    }
    cout <<fixed << setprecision(8) << (sum_max+k)/2.0 << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
data = [list(map(int,input().split())) for i in range(N)]
mod = 10**9+7
ans = 0

from math import gcd

A = []

for i in range(N):
    if data[i][0] == 0 and data[i][1] == 0:  #(0,0)の場合は以降取り除いて考える
        ans += 1
    else:                                 #各々の成分をgcdで割り、第1成分が非負になるように調整
        if data[i][0] < 0:
            data[i][0] *= -1
            data[i][1] *= -1
        g = gcd(data[i][0],data[i][1])
        data[i][0] //= g
        data[i][1] //= g
        if data[i][0] == 0:
            A.append((0,1))
        elif data[i][1] == 0:
            A.append((1,0))
        else:
            A.append((data[i][0],data[i][1]))


from collections import Counter

C = Counter(A)
D = []             #仲が悪いイワシの数の組

for i,j in list(C.keys()):
    if j <= 0:
        continue
    else:
        if j == 0:
            if C[(0,1)] > 0:
                D.append((C[(1,0)],C[(0,1)]))
        else:
            if C[(j,-i)] > 0:
                D.append((C[(i,j)],C[(j,-i)]))

r = 0  #仲が悪くなり得るイワシの数
for i,j in D:
    r += i+j

a = 1  #仲が悪くなり得るイワシたちの選び方
for i,j in D:
    a = (a*(pow(2,i,mod)+pow(2,j,mod)-1)) % mod

a = (a*pow(2,len(A)-r,mod)) % mod  #仲が悪くなり得ないイワシたちの選び方

ans += a-1  #全部選ばないものを除く

print(ans % mod)

Measured memory_bytes: 163000
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = ni()
print(l[k-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<bool>> a(h,vector<bool>(w));
    REP(i,h) REP(j,w){
        int A;
        cin>>A;
        a[i][j]=A%2;
    }
    vector<tuple<int,int,int,int>> moves;
    REP(i,h){
        if(i==h-1){
            REP(j,w){
                if(j!=w-1){
                    if(a[i][j]){
                        moves.push_back(make_tuple(j,i,j+1,i));
                        a[i][j]=false;
                        a[i][j+1]=!a[i][j+1];
                    }
                }
            }
        }else{
            REP(j,w){
                if(a[i][j]){
                    moves.push_back(make_tuple(j,i,j,i+1));
                    a[i][j]=false;
                    a[i+1][j]=!a[i+1][j];
                }
            }
        }
    }
    cout<<sz(moves)<<endl;
    REPARR(i,moves){
        cout<<get<1>(moves[i])+1<<" "<<get<0>(moves[i])+1<<" "<<get<3>(moves[i])+1<<" "<<get<2>(moves[i])+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 4340
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};
//template<class T>vector<T> var_vec(size_t a){return vector<T>(a);}
//template<class T, class... Ts>auto var_vec(size_t a, Ts... ts){return vector<decltype(var_vec<T>(ts...))>(a, var_vec<T>(ts...));}

//}

string s;
int ans;

main(){
	int n;cin>>n;
	int d[n];rep(i,n)cin>>d[i];
	sort(d,d+n);
	dump(d[n/2]-d[n/2-1]);
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			String[] nml = input.readLine().split(" ");
			int n = Integer.parseInt(nml[0]);
			int m = Integer.parseInt(nml[1]);
			int l = Integer.parseInt(nml[2]);
			String[][] matrix1 = new String[n][m];
			String[][] matrix2 = new String[m][l];
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			for (int i = 0; i < n; i++) {
				matrix1[i] = input.readLine().split(" ");
			}
			for (int i = 0; i < m; i++) {
				matrix2[i] = input.readLine().split(" ");
			}
			long sum;
			int s = l - 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < l; j++) {
					sum = 0;
					for (int k = 0; k < m; k++) {
						sum += Integer.parseInt(matrix1[i][k]) * Integer.parseInt(matrix2[k][j]);
					}
					answer.append(String.valueOf(sum)).append(j != s ? " "  : "");
				}
				answer.append(lb);
			}
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 32952
import sys
input=sys.stdin.readline
def main():
  n,m=map(int,input().split())
  a=tuple(int(input()) for _ in range(m))
  a=set(a)
  mod=10**9+7
  pattern=[0]*(n+1)
  pattern[0]=pattern[1]=1
  if 1 in a:
      pattern[1]=0
  for i in range(2,n+1):
      if i in a:
          pattern[i]=0
      else:
          pattern[i]=(pattern[i-1]+pattern[i-2])%mod
  print(pattern[n])
main()

Measured memory_bytes: 53596
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef long long ll;
// using i32=int;using i64=long long;using ll =i64;
// using uint=unsigned int;using ull=unsigned long long;
// template<typename T> using matrix=vector<vector<T> >;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

typedef int Cost; Cost CINF=1<<28;
struct Edge{
	int f,t;Cost c;
	Edge(int f,int t,Cost c) : f(f),t(t),c(c) {};
	bool operator<(Edge r) const{return c<r.c;}
	bool operator>(Edge r) const{return c>r.c;}
};
typedef vector<vector<Edge> >  Graph;
Cost prim(Graph g,int s){
	const int V=g.size();
	vector<bool> visited(V);
	priority_queue<Edge,vector<Edge>,greater<Edge>> que;que.push(Edge(-1,s,0));
	Cost res=0;
	while(!que.empty()){
		Edge task=que.top();que.pop();
		int pos=task.t;
		if(visited[pos])continue;
		visited[pos]=true;
		res+=task.c;
		for(Edge e:g[pos])if(!visited[e.t])que.push(e);
	}
	return res;
}


ll INF=1LL<<58;
class Main{
public:
	void run(){
		while(true){
			int N,M;cin >>N >>M;if(N==0)break;
			Graph g(N);
			REP(i,M){
				int f,t,c;cin >> f >> t >> c;
				g[f].push_back(Edge(f,t,c));
				g[t].push_back(Edge(t,f,c));
			}
			cout << prim(g,0)<<endl;
		}
	}
};
int main(){
  	Main().run();
  	return 0;
 }

Measured memory_bytes: 1220
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll l, r,mi=2020;
    cin>>l>>r;
    for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++){
            mi=min(mi,i*j%2019);
            if(mi==0){
                cout<<mi<<endl;
                return 0;
            }
        }
    }
    cout<<mi<<endl;
}

Measured memory_bytes: 256
/**
 *  author: mahfuzz
 *  created: 01.05.2020
**/
 
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
 
int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n; cin >> n;
    int arr[n + 1];
    
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    
    sort(arr, arr+n, greater<int>());
    int ans = 0;
    for(int i = 0; i < n; i++)
        ans += (i % 2 ? -arr[i] : arr[i]);
        
    cout << ans << "\n";
    
    return 0;
}


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

int main() {
  int n,cnt = 0,tmp = 0;
  cin >> n;
  rep(i,0,n){
    int a,b;
    cin >> a >> b;
    if(a == b) tmp++;
    else{
      cnt = max(cnt,tmp);
      tmp = 0;
    }
  }
  cnt = max(cnt,tmp);
  if(cnt >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <math.h>
#include <map>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void A_Serval_vs_Monster(void) {

	int H, A;
	cin >> H >> A;

	cout << ((H % A == 0) ? H / A : int(H / A) + 1);
	return;
}

int main(void) {

	A_Serval_vs_Monster();
	return 0;
}


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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  ll n;
  cin>>n;
  vector<ll> c(n);
  rep(i,n)cin>>c[i];
  sort(c.begin(),c.end());
  vector<mint> v(200005);
  mint temp=1;
  rep(i,200005){
    v[i]=temp;
    temp*=2;
  }
  mint ans=0;
  rep(i,n){
    mint now=0;
    int x=n-1-i;
    now+=(v[x]/2)*x;
    now+=v[x];
    now*=v[i];
    now*=c[i];
    ans+=now;

  //  cout<<x<<"x"<<i<<"i"<<now<<"now"<<endl;
  }
  ans*=v[n];

cout<<ans.x;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
	int n,d,x,a[105];
	int ans=0;
	
	cin >> n >> d >> x;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	
	for(int i=1;i<=n;i++){
		for(int j=0;;j++){
			if(j*a[i]+1<=d)ans++;
			else break;
		}
	}
	ans+=x;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var pss = primes(1e6 + 10)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	as := make([]int, n)
	pm := make(map[int]int)
	gg := make([]int, n+1)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
		gg[i+1] = gcd(gg[i], as[i])
		ps := primeFactorization(as[i])
		for p := range ps {
			pm[p]++
		}
	}

	if gg[n] != 1 {
		fmt.Println("not coprime")
		return
	}

	for k, v := range pm {
		if k == 1 {
			continue
		}
		if v > 1 {
			fmt.Println("setwise coprime")
			return
		}
	}

	fmt.Println("pairwise coprime")
}

func primes(n int) []int {
	np := make([]int, n+1)
	np[0] = 0
	np[1] = 1
	for i := 2; i*i <= n; i++ {
		if np[i] == 0 {
			np[i] = i
			for j := i + i; j <= n; j += i {
				if np[j] == 0 {
					np[j] = i
				}
			}
		}
	}
	return np
}

func primeFactorization(n int) map[int]int {
	ps := make(map[int]int)
	for n > 1 && pss[n] > 0 && n%pss[n] == 0 {
		ps[pss[n]]++
		n /= pss[n]
	}
	if n != 1 {
		ps[n]++
	}
	return ps
}

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

var sc = bufio.NewScanner(os.Stdin)

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


Measured memory_bytes: 55500
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A, B = [0]*N, [0]*N
# 力技はだめ
for i in range(N):
    A[i], B[i] = zz()
A, B = zip(*sorted(zip(A, B)))
all_num = 0
for i, b in enumerate(B):
    all_num += b
    if (all_num >= K):
        print(A[i])
        exit()


Measured memory_bytes: 48720
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7, M = 2501;
ll dp[52][52][5002];

int main() {
    int n, k;
    cin >> n >> k;
    dp[0][0][M] = 1;
    REP(i,n) REP(x,i+1) REP(s,5002){
        if (dp[i][x][s] == 0) continue;
        (dp[i + 1][x][s] += dp[i][x][s]) %= mod;
        (dp[i + 1][x + 1][s - 2 * i] += dp[i][x][s]) %= mod;
        (dp[i + 1][x][s] += x * dp[i][x][s]) %= mod;
        (dp[i + 1][x][s] += x * dp[i][x][s]) %= mod;
        if (x) (dp[i + 1][x - 1][s + 2 * i] += x * x * dp[i][x][s]) %= mod;
    }
    cout << dp[n][0][k + M] << endl;
    return 0;
}


Measured memory_bytes: 102656
N = int(input())
string = list(map(int,input().split()))
remain  = []
S1 = 0
S2 = 0

for T in range(1,N+1):
    for i in range(T):
        S1 += string[i]
    for j in range(T, len(string)):
        S2 += string[j]
    remain.append(abs(S1-S2))
    S1 = 0
    S2 = 0
print(min(remain))
              
          
        
              
      
        
        


Measured memory_bytes: 3064
n, m = map(int, input().split())
g = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

from collections import deque
arrow = [0]*n
def bfs(u, n):
    queue = deque([u]) # uからの距離の初期化
    d = [False]*n
    d[u] = 1
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i]:continue
            d[i] = True
            arrow[i] = v
            queue.append(i)
    return arrow

ans = bfs(0, n)
print('Yes')
for i in range(1,n):
    print(ans[i]+1)


Measured memory_bytes: 34464
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
int main()
{
    ll a, b, x;
    read(x);
    for (ll i = -120; i <= 120; ++i)
    {
        for (ll j = -120; j < i; ++j)
        {
            if (i * i * i * i * i - j * j * j * j * j == x)
            {
                a = i, b = j;
            }
        }
    }
    printf("%lld %lld\n", a, b);
}

Measured memory_bytes: 3768