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

void subBin(string str, int n);
bool contains(vector<int> vec, int number);

vector<string> perm;
int idx;

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

    vector<int> k(m);
    vector<vector<int>> s(m);
    for (size_t i = 0; i < m; i++)
    {
        cin >> k[i];

        vector<int> si(k[i]);
        for (size_t j = 0; j < k[i]; j++)
        {
            cin >> si[j];
        }
        s[i] = si;
    }

    vector<int> p(m);
    for (size_t i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    //n個のスイッチについて、on(1)/off(0)の組み合わせ
    vector<string> tmp(2 << (n - 1));
    perm = tmp;
    idx = 0;
    subBin("", n);

    int cnt = 0;
    for (size_t i = 0; i < 2 << (n - 1); i++)
    {
        bool light = true;
        for (size_t j = 0; j < m; j++)
        {
            int scnt = 0;
            for (size_t k = 0; k < perm.size(); k++)
            {
                if (contains(s[j], k + 1) && perm[i][k] == '1')
                {
                    scnt++;
                }
            }
            if (scnt % 2 != p[j])
            {
                //cout << j << " " << p[j] << " " << perm[i] << endl;
                light = false;
                break;
            }
        }
        if (light)
        {
            //cout << perm[i] << endl;
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

bool contains(vector<int> vec, int number)
{
    auto itr = find(vec.begin(), vec.end(), number);
    size_t index = distance(vec.begin(), itr);
    if (index != vec.size())
    {
        return true;
    }
    else
    {
        return false;
    }
}

void subBin(string str, int n)
{
    if (n == 0)
    {
        //cout << str << endl;
        perm[idx] = str;
        idx++;
    }
    if (n > 0)
    {
        subBin(str + "0", n - 1);
        subBin(str + "1", n - 1);
    }
}


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

int main() {
    int x,y;
    cin >> x >> y;

    if(y % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    if(2 * x <= y && y <= 4 * x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


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

void solve(long long s) {
  if (s == 1 || s == 2 || s == 4) {
    cout << 4 << endl;
    return;
  }
  int cnt = 0;
  while (s != 1) {
    if (s % 2 == 1)
      s = s * 3 + 1;
    else
      s /= 2;
    cnt++;
  }
  cout << cnt + 2 << endl;
}

int main() {
  long long s;
  scanf("%lld", &s);
  solve(s);
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
d={}
for i in range(N):
  if A[i] not in d:
    d[A[i]]=1
  else:
    d[A[i]]+=1
al=0
for k in d:
  al+=d[k]*(d[k]-1)//2

for i in range(N):
  ans=al
  print(al-(d[A[i]]*(d[A[i]]-1)//2)+((d[A[i]]-1)*(d[A[i]]-2)//2))

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

int main() {
  int a,cnt;
  cin>>a;
  if(a%10 == 1) cnt++;
  a /= 10;
  if(a%10 == 1) cnt++;
  a /= 10;
  if(a%10 == 1) cnt++;
  a /= 10;
  cout << cnt << endl;
  
}


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

#define nl "\n";

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// problem statements implementation
	int cas;
	cin >> cas;
	if(cas==0) {
		cout << 1 << nl;
	}
	else if(cas==1) cout << 0 << nl;

	return 0;
}

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


int main(){
	while (1) {
		int h,w;
		cin >> h >> w;
		if (h == 0 and w == 0)break;
		for (int i = 0 ; i < h; i++){
			for (int j = 0; j < w; j++)cout << "#";
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int h,w;
vector<string> mp;

int bfs(char sx,int sy,char goal){
  vector<vector<int> > D(h,vector<int>(w,INF));
  
  queue<P> Q;
  Q.push(P(sx,sy));
  D[sy][sx] = 0;

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

  auto in=[&](int x,int y){return !(x < 0 || y < 0 || x >= w || y >= h);};
  auto go=[&](int x,int y,int i,char ch){
    while(1){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!in(nx,ny)) return P(-1,-1);
      
      if((mp[ny][nx] != ch && !isupper(mp[ny][nx]))) return P(-1,-1);
      if(isupper(mp[ny][nx])) return P(nx,ny);
      x = nx;
      y = ny;
    }
  };
  
  while(!Q.empty()){
    P t = Q.front();Q.pop();
    int x = t.first;
    int y = t.second;

    if(mp[y][x] == goal) return D[y][x];
    
    for(int i=0;i<4;i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      auto to = go(nx,ny,i,mp[ny][nx]);
      if(to == P(-1,-1)) continue;
      tie(nx,ny) = to;
      if(D[ny][nx] != INF) continue;

      D[ny][nx] = D[y][x] + 1;
      Q.push(P(nx,ny));
    }
  }
  assert(0);
}

signed main(){

  char s,t;
  cin>>h>>w>>s>>t;
  mp.resize(h);
  cin>>mp;

  int sx,sy;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(!isupper(mp[i][j])) continue;
      mp[i-1][j] = mp[i+1][j] = '|';
      mp[i][j-1] = mp[i][j+1] = '-';
      if(mp[i][j] == s) sx = j, sy = i;
    }

  int ans = bfs(sx,sy,t);

  cout<<ans<<endl;

  
  return 0;
}



Measured memory_bytes: 3240
#include <cstdio>
int a,b;
char c;
int main() {
    scanf("%d",&a);
    c=getchar();
    c=getchar();
    while(c>='0'&&c<='9') {
        a=a*10+c-'0';
        c=getchar();
    }
    for(int i=1;;i++) {
        if(i*i==a) {printf("Yes");return 0;}
        if(i*i>a) {printf("No");return 0;}
    }
}

Measured memory_bytes: 128
encode = {
  "A" => "00000",
  "B" => "00001",
  "C" => "00010",
  "D" => "00011",
  "E" => "00100",
  "F" => "00101",
  "G" => "00110",
  "H" => "00111",
  "I" => "01000",
  "J" => "01001",
  "K" => "01010",
  "L" => "01011",
  "M" => "01100",
  "N" => "01101",
  "O" => "01110",
  "P" => "01111",
  "Q" => "10000",
  "R" => "10001",
  "S" => "10010",
  "T" => "10011",
  "U" => "10100",
  "V" => "10101",
  "W" => "10110",
  "X" => "10111",
  "Y" => "11000",
  "Z" => "11001",
  " " => "11010",
  "." => "11011",
  "," => "11100",
  "-" => "11101",
  "'" => "11110",
  "?" => "11111"
}
 
decode = {
  "101"      => " ",
  "000000"   => "'",
  "000011"   => ",",
  "10010001" => "-",
  "010001"   => ".",
  "000001"   => "?",
  "100101"   => "A",
  "10011010" => "B",
  "0101"     => "C",
  "0001"     => "D",
  "110"      => "E",
  "01001"    => "F",
  "10011011" => "G",
  "010000"   => "H",
  "0111"     => "I",
  "10011000" => "J",
  "0110"     => "K",
  "00100"    => "L",
  "10011001" => "M",
  "10011110" => "N",
  "00101"    => "O",
  "111"      => "P",
  "10011111" => "Q",
  "1000"     => "R",
  "00110"    => "S",
  "00111"    => "T",
  "10011100" => "U",
  "10011101" => "V",
  "000010"   => "W",
  "10010010" => "X",
  "10010011" => "Y",
  "10010000" => "Z"
}

while line = gets
  input = line.chomp
  encoded = input.split('').each.map do |i|
    encode[i]
  end.join

  i, j = 0, 0
  stack = []
  while j < encoded.length
    if decode.keys.index(encoded[i..j])
      stack << decode[encoded[i..j]]
      j += 1
      i = j
    else
      j += 1
    end
  end

  puts stack.join
end

Measured memory_bytes: 10404
# -*- coding: utf-8 -*-
from copy import deepcopy
N, W = tuple(map(int, input().split()))
items = []
for n in range(N):
    items.append(list(map(int, input().split()))) # value, weight

pre_costs = [0 for _ in range(W+1)]
post_costs = [0 for _ in range(W+1)]

for item in items:
    for w in range(item[1], W+1):
        post_costs[w] = max(pre_costs[w], pre_costs[w-item[1]] + item[0])
    pre_costs = deepcopy(post_costs)

print(post_costs[-1])

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

  int main() {
    int H, W;
    cin >> H >> W;
    vector<char> S(H*W);
    vector<int> sum(H*W,0);
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> S.at(W*i+j);
        if (S.at(W*i+j) == '#') {
          if (i != 0) {
            sum.at(W*(i-1)+j) += 1;
            if (j != 0) {
              sum.at(W*(i-1)+j-1) += 1;
            }
            if (j != W-1) {
              sum.at(W*(i-1)+j+1) += 1;
            }
          }
          if (j != 0) {
            sum.at(W*i+j-1) += 1;
          }
          if (j != W-1) {
            sum.at(W*i+j+1) += 1;
          }
          if (i != H-1) {
            sum.at(W*(i+1)+j) += 1;
            if (j != 0) {
              sum.at(W*(i+1)+j-1) += 1;
            }
            if (j != W-1) {
              sum.at(W*(i+1)+j+1) += 1;
            }
          }
          /*if (j != W-1) {
            if (i != 0) {
              sum.at(W*(i-1)+j+1) += 1;
            }
            if (i != H-1) {
              sum.at(W*(i+1)+j+1) += 1;
            }
            sum.at(W*i+j+1) += 1;
          }
          if (j != W*i) {
            if (i != 0) {
              sum.at(W*(i-1)+j-1) += 1;
            }
            if (i != H-1) {
              sum.at(W*(i+1)+j-1) += 1;
            }
            sum.at(W*i+j-1) += 1;
          }
          if (i != 0) {
            sum.at(W*(i-1)+j) += 1;
          }
          if (i != H-1) {
            sum.at(W*(i+1)+j) += 1;
          }*/
        }
      }
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (S.at(W*i+j) == '#') {
          cout << S.at(W*i+j);
        }
        else {
          cout << sum.at(W*i+j);
        }
      }
      cout << endl;
    }
  }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n,k,d[9];
    cin>>n>>k;
    string s;
    for(int i=0;i<k;i++)cin>>d[i];
    for(int i=n;;i++){
        s=to_string(i);
        for(int j=0;j<s.size();j++){
			for(int l=0;l<k;l++){
				if(s[j]-'0'==d[l])goto out;
			}
		}
		cout<<s<<endl;
		return 0;
		out:;
    }
    return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
l,r=1,10**9
v={}
import math
def f(n):
    s=0
    for h in H:
        s+=max(0,math.ceil((h-B*n)/(A-B)))
    return s
a=10**9
while 1:
    n=(r-l)//2+l
    if n in v:
        n+=1
    if n in v:
        break
    v[n]=1
    s=f(n)
    if s<n:
        a=min(a,n)
        r=n
    elif s>n:
        a=min(a,s)
        l=n
    else:
        a=s
        break
print(a)

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

    int main(){
      int n;
      cin >> n;
      cout << 1110-n << endl;
      return 0;}

Measured memory_bytes: 764
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){
    for (int v = nt[u]; v < n; v++){
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }
    return -1;
}

//DFS with stack
void dfs_visit(int r){
    for (int i=0; i<n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while( !S.empty()){
        int u = S.top();
        int v = next(u);
        if ( v != -1){
            if (color[v] == WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else { // v == -1
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    //initialization
    for (int i=0; i<n; i++){
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for (int u=0; u<n; u++){
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (int i=0; i<n; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    int u, k, v;

    cin >> n;

    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++) M[i][j] = 0;
    }

    for (int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for (int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1<<29;

int main(){
  int n;
  int dp[51];
  int c[6] = {380,550,850,1520,1870,2244};
  int d[6] = {2,3,5,10,12,15};

  fill(dp,dp+51,INF);
  dp[0] = 0;
  for(int i = 0 ; i < 51 ; i++){
    for(int j = 0 ; j < 6 ; j++){
      if(d[j] <= i){
	dp[i] = min(dp[i],dp[i-d[j]]+c[j]);
      }
    }
  }  

  while(cin >> n , n){
    n /= 100;
    cout << dp[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
class DoubleLinkedList:
    def __init__(self, v):
        self.value = v
        self.prev = None
        self.next = None


s = input().rstrip()

root = DoubleLinkedList(None)
current = root

count = 0
for i in range(len(s)):
    node = DoubleLinkedList(s[i])

    if (current.value == '0' and node.value == '1') or (current.value == '1' and node.value == '0'):
        current = current.prev
        count += 2
    else:
        current.next = node
        node.prev = current
        current = node

print(count)

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

int main(){
    int n, m;
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1;
    }else if(n == 1){
        cout << max(0, m-2);
    }else if(m==1){
        cout << max(0, n-2);
    }else{
        cout << (long long)(m-2)*(n-2);
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

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

signed main()
{
	ios::sync_with_stdio(false);
	int x;cin>>x;
	int g=gcd(x,360);
	cout<<360/g<<endl;
	return 0;
}

Measured memory_bytes: 3648
import heapq
n,m=map(int,input().split())
x=list(map(int,input().split()))
for k in range(n):
    x[k]-=2*x[k]
heapq.heapify(x)
ans=0
for i in range(m):
    maxvalue=heapq.heappop(x)*(-1)
    heapq.heappush(x,(maxvalue//2)*(-1))
ans=-1*sum(x)
print(ans)

Measured memory_bytes: 72300
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 25;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, a[MAXN], b[MAXN], c[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) cin >> b[i];
    FOR(i,1,n-1) cin >> c[i];
    int res = 0;
    FOR(i,1,n) {
        res += b[a[i]];
        if (i > 1) {
            int pre = a[i-1];
            int now = a[i];
            if (now == pre+1) res += c[pre];
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a,b,c;
  char op;

  while(1){

  scanf("%d %c %d", &a, &op, &b);

  if(op == '+'){

    c = a + b;

  }

  else if(op == '-'){

    c = a - b;

  }

  else if(op == '*'){

    c = a * b;

  }

  else if(op == '/'){

    c = a / b;

  }

  else{

    break;

  }

  printf("%d\n",c);

  }

  return 0;

}

Measured memory_bytes: 600
def main():
    cost_list = [int(input()) for _ in range(5)]
    amari_list = [cost % 10 for cost in cost_list]

    last_order = 0
    min_amari = 10
    for index, amari in enumerate(amari_list):
        if amari == 0:
            continue
        if amari < min_amari:
            min_amari = amari
            last_order = index

    ans = 0
    for index, cost in enumerate(cost_list):
        if index == last_order:
            ans += cost_list[index]
        else:
            if cost % 10 == 0:
                ans += cost
            else:
                cost = (cost // 10 + 1) * 10
                ans += cost

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61984
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}
ll MOD=1000000007;

int main(){
    ll N;cin>>N;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    vector<ll>B(N);
    B[N-1]=A[N-1];
    rep(i,N-1){
        B[N-2-i]=(A[N-2-i]+B[N-1-i])%MOD;
    }
    ll ans=0;
    rep(i,N-1){
        ans+=(A[i]*B[i+1])%MOD;
        ans=ans%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6424
#include <algorithm>
#include <cstdint>
#include <iostream>

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

template <std::uint_fast64_t Mod>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 val;

  constexpr ModInt(const u64 x = 0) noexcept : val(x % Mod) {}
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    val += rhs.val;
    if (val >= Mod) {
      val -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (val < rhs.val) {
      val += Mod;
    }
    val -= rhs.val;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    val = val * rhs.val % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

template <typename T>
T nCk(int n, int k) {
  if (k > n) return 0;
  T ret = 1;
  for (auto i = 0; i < std::min(n - k, k); ++i) {
    ret *= n - i;
    ret /= i + 1;
  }
  return ret;
}

using mint = ModInt<MOD>;

int main() {
  ll S;
  cin >> S;
  mint ans{};
  for (int i = 1; 3 * i <= S; ++i)
    ans += nCk<mint>(S - 2 * i - 1, i - 1);
  cout << ans.val << endl;
}


Measured memory_bytes: 3640
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(s string) string {
	var res = ""
	for _, _ = range s {
		res += "x"
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	s := next()
	res := solve(s)
	fmt.Fprintln(out, res)
}

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

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[15],str2[15];
int main(){
	int i;
	scanf(" %s %s",str,str2);
	bool right=1;
	for(i=0;str[i];i++)
		if(str[i]!=str2[i])
			right=0;
	if(right)
		puts("Yes");
	else	
		puts("No");
}


Measured memory_bytes: 1608
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int n;

        public static void Main(string[] args)
        {
            input();

            switch (n % 10)
            {
                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
                default:
                    Console.WriteLine("hon");
                    break;
            }
        }

        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            n = int.Parse(buf[0]);
        }

    }
}

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


int main (){
    long long A, B, C,CC, D,DD, E, F;
    cin>>A>>B>>C>>D;
    E=C/D;
    F=C%D;
    CC=C;
    DD=D;
    while(F>0){
        E=CC/DD;
        F=CC%DD;
        CC=DD;
        DD=F;
    }
  	long long Lcm=C*D/CC;
    long long Ans=B-A+1-(B/C-(A-1)/C+B/D-(A-1)/D-B/Lcm+(A-1)/Lcm);
    cout<<Ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) 
{
    char c;
    int sum = 0;
    while ((c=getc(stdin))!= EOF) 
    {
        if('0' <= c && c <='9') 
        {
            sum += (c-'0');

            if(sum == 0)
            { 
                break;
            }
        } 
        else 
        {
            printf("%d\n", sum);
            sum = 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main() {
    int D;
    scanf("%d",&D);
    if (D == 25) printf("Christmas");
    else if (D == 24) printf("Christmas Eve");
    else if (D == 23) printf("Christmas Eve Eve");
    else if (D == 22) printf("Christmas Eve Eve Eve");
    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int t;
    cin >> t;
    if (t == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXM 12
#define MAXN 1000
#define INF 0x3f3f3f3f
vector<int> G[MAXN+5];
int n,m,a[MAXN+5],b[MAXN+5],ans=INF,f[MAXN+5][(1<<MAXM)+5];
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		a[i]=read(),b[i]=read();
		for(int j=1;j<=b[i];j++)
			G[i].push_back(read());
	}
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	for(int i=0;i<m;i++){
		int S0=0;
		for(int j=0;j<int(G[i].size());j++)
			S0|=(1<<(G[i][j]-1));
		for(int S=0;S<(1<<n);S++){
			f[i+1][S]=min(f[i+1][S],f[i][S]);
			f[i+1][S|S0]=min(f[i+1][S|S0],f[i][S]+a[i]);
		}
	}
	if(f[m][(1<<n)-1]==INF)
		puts("-1");
	else printf("%d\n",f[m][(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 16512
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 23:07:39 2019

@author: Yamazaki Kenichi
"""

A,B = map(int,input().split())

def a(A):
    if A % 2 == 0:
        return A ^ (A%4//2)
    else:
        return ((A+1)%4//2)

ans = a(A-1)^a(B)      
      
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
 
int main(){

    int a,b;
    cin >> a >> b;

    int c = 0;

    if(a > b){
        c = c + a;
        a--;
    }else{
        c = c + b;
        b--;
    }

    if(a > b){
        c = c + a;
        a--;
    }else{
        c = c + b;
        b--;
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=1LL<<50;
const int maxn=3010;
int n,a[maxn];
ll dp[maxn][maxn][2];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int len=1;len<=n;len++)
	for (int l=1,r;l+len-1<=n;l++) {
		r=l+len-1;
		dp[l][r][0]=max(dp[l+1][r][1]+a[l],dp[l][r-1][1]+a[r]);
		dp[l][r][1]=min(dp[l+1][r][0]-a[l],dp[l][r-1][0]-a[r]);
	}
	printf("%lld\n",dp[1][n][0]);
	return 0;
}

Measured memory_bytes: 141568
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

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

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, m, k, x;
    cin >> n >> m;
    unordered_map < ll, ll > mpp;
    rep(i, n){
        cin >> k;
        while(k--){
            cin >> x;
            mpp[x]++;
        }
    }
    ll c = 0;
    for(auto it : mpp){
        if(it.ss == n){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, X, Y;
vector<int> B[202020];

i64 modpow(i64 v, int p = MOD - 2)
{
	if (p == 0) return 1;
	i64 tmp = modpow(v, p / 2);
	tmp = tmp * tmp % MOD;
	if (p % 2 == 1) tmp = tmp * v % MOD;
	return tmp;
}

i64 fact(int n)
{
	i64 ret = 1;
	for (int i = 1; i <= n; ++i) ret = ret * i % MOD;
	return ret;
}

int main()
{
	scanf("%d%d%d", &N, &X, &Y);
	for (int i = 0; i < N; ++i) {
		int c, w;
		scanf("%d%d", &c, &w);
		B[--c].push_back(w);
	}
	for (int i = 0; i < N; ++i) sort(B[i].begin(), B[i].end());

	pair<int, int> lig{ 1001001001, 0 }, lig2{ 1001001001, 0 };
	for (int i = 0; i < N; ++i) if (B[i].size() > 0) {
		pair<int, int> top{ B[i][0], i };
		if (lig > top) {
			lig2 = lig;
			lig = top;
		} else if (lig2 > top) {
			lig2 = top;
		}
	}

	vector<int> mixing;
	int mixsum = 0;
	i64 ret = 1;

	for (int i = 0; i < N; ++i) if (B[i].size() > 0) {
		if (lig.first + B[i][0] > Y) continue;

		int thresh = X - B[i][0];
		if (i == lig.second) {
			thresh = max(thresh, Y - lig2.first);
		} else {
			thresh = max(thresh, Y - lig.first);
		}

		int cnt = 0;
		for (int v : B[i]) if (v <= thresh) ++cnt;

		ret = ret * fact(cnt) % MOD;
		mixsum += cnt;
	}

	ret = fact(mixsum) * modpow(ret) % MOD;
	printf("%lld\n", ret);

	return 0;
}


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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e12+5

int main(){
  string S2, T;
  cin >> S2 >> T;
  vector<string> ans;
  REP(i, S2.size()-T.size()+1){
    string s = S2;
    bool flag = true;
    REP(j, T.size()){
      if(S2[i+j] == T[j] || S2[i+j] == '?'){
        s[i+j] = T[j];
      }
      else{
        flag = false;
        break;
      }
    }
    if(flag){
      ans.push_back(s);
    }
  }
  if(ans.size() == 0){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  sort(ans.begin(), ans.end());
  REP(i, S2.size()){
    if(ans[0][i] == '?'){
      ans[0][i] = 'a';
    }
  }
  cout << ans[0] << endl;

  return 0;
}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    string s;
    cin >> s;

    string ans = "Yes";

    bool flagA= false,flagB = false;
    REP(i,s.size()){
        if(s[i] == 'A')flagA = true;
        else flagB = true;
    }

    if(!(flagA && flagB))ans = "No";

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

Measured memory_bytes: 256
def main():
    n = int(input())
    l = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if 0<= i < j < k <= n-1 \
                    and 2 * max([l[i], l[j], l[k]]) < sum([l[i], l[j], l[k]]) \
                    and len(set([l[i], l[j], l[k]]))==3:
                    ans += 1
    print(ans)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int a,b,t; cin >> a >> b >> t;
	int ans = 0;
	FOR(i,1,t+1){
		if(i%a==0) ans += b;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3652
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string S; cin >> S;
    int ans = (S.size()+1)/2;
    int i=1;
    if(S.size()%2)
        while(ans-i-1 >= 0 && ans+i-1 < S.size() && S[ans-1] == S[ans-i-1] && S[ans-i-1] == S[ans+i-1]) i++;
    else
        while(ans-i >= 0 && ans+i-1 < S.size() && S[ans-1] == S[ans-i] && S[ans-i] == S[ans+i-1]) i++;
    ans += i-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
pii p[200010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  REP(i,N) {
    cin >> p[i].second >> p[i].first;
  }
  sort(p,p+N);
  int sum = 0;
  REP(i,N) {
    sum += p[i].second;
    if (sum <= p[i].first) continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  return 0;
}

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

int n;
vector<int> v;
int s;

int solve(){
	for(int i=0; i<n; ++i)
		s ^= v[i];
	if(s == 0) return 0;
	int t = 0;
	while((s >> t) > 0) ++t;
	--t;
//	cout << t << "\n";
	int f = 1;
	vector<int> w(1, t);
	for(int i=t-1; i>=0; --i){
		if(((s>>i)&1) != f){
			w.push_back(i);
			f = 1 - f;
		}
	}
	vector<int> x(w.size(), 0);
	int res = 0;
	for(int i=0; i<n; ++i){
		int u = 0;
		while(((v[i]>>u)&1) == 0) ++u;
		for(int j=0; j<w.size(); ++j){
			if(w[j] == u && x[j] == 0){
				++res;
				x[j] = 1;
			}
		}
	}
	for(int i=0; i<x.size(); ++i)
		if(x[i] == 0)
			return -1;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	v.resize(n);
	for(auto &i:v) cin >> i;
//	sort(v.begin(), v.end());
	cout << solve() << "\n";
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!
#import collections
# c = collections.Counter()
#import itertools as it
import math
#import numpy as np
#import sys 
#sys.exit()
 
#k = input()
#s = input()
#k = int(input())
a, b, h, m  = map(int, input().split())
if h>=12:
    h=h-12
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
'''
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
'''
 
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])

#print(abs(h*30-m*6),abs(360-(h*30-m*6)))

t=min(abs((h+m/60)*30-m*6),abs(360-((h+m/60)*30-m*6)))
u=pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(t))
#print(u,math.cos(math.radians(t)),h*30,m*6,pow(a,2)+pow(b,2),math.sqrt(pow(a,2)+pow(b,2)),math.sqrt(u),2*math.cos(math.radians(t)))
print(math.sqrt(u))

Measured memory_bytes: 9532
#include <stdio.h>
int main(void){
  int n,a[100000],r[100000]={},t=0,i,ans=0;
  bool k=true;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
    a[i]--;
  }
  r[0]=1;
  while (1){
    ans++;
    t=a[t];
    if (t==1) break;
    if (r[t]){
      k=false;
      break;
    }
    r[t]=1;
  }
  printf("%d\n",(k)? ans:-1);
  return 0;
}

Measured memory_bytes: 896
using System;
using static System.Console;
public class Hello{
    public static void Main(){
//        string[] a = ReadLine().Split(' ');
//        int x = int.Parse(a[0]);
//        int y = int.Parse(a[1]);
//        int z = int.Parse(a[2]);
        string b = ReadLine();
//        int count = 0;
//        if(b[0] == 'o'){ count++; }
//        if(b[1] == 'o'){ count++; }
//        if(b[2] == 'o'){ count++; }
        b = b.Replace("2017","2018");
        WriteLine(b);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, T;
  cin>>N>>T;
  ll ans = 0;
  ll tmp1=0, tmp2;
  for(int i=0;i<N;++i) {
    cin>>tmp2;
    if(tmp1+T<=tmp2) ans += T;
    else ans += tmp2-tmp1;
    tmp1 = tmp2;
  }
  ans += T;
  cout<<ans<<endl;
}



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

int main() {
    int c[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }
    int a[3] = {-1, -1, -1};
    int b[3] = {-1, -1, -1};

    for (int i = 0; i < 101; ++i) {
        for (int j = 0; j < 101; ++j) {
            for (int k = 0; k < 101; ++k) {
                if ((j - i == c[0][1] - c[0][0]) &&
                    (k - i == c[0][2] - c[0][0]) &&
                    (i - j == c[1][0] - c[1][1]) &&
                    (k - j == c[1][2] - c[1][1]) &&
                    (i - k == c[2][0] - c[2][2]) &&
                    (j - k == c[2][1] - c[2][2])
                ) {
                    bool ok = true;
                    b[0] = i;
                    b[1] = j;
                    b[2] = k;

                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N  = scanner.nextInt();
        int[] count = new int[8];
        int over = 0;
        for(int i=0;i<8;i++){
            count[i] = 0;
        }
        for(int i=0; i<N; i++){
            int a = scanner.nextInt();
            if(a <= 399){
                count[0] = Math.min(1, count[0] + 1); 
            }else if(a<=799){
                count[1] = Math.min(1, count[1] + 1); 
            }else if(a<=1199){
                count[2] = Math.min(1, count[2] + 1); 
            }else if(a<=1599){
                count[3] = Math.min(1, count[3] + 1);
            }else if(a<=1999){
                count[4] = Math.min(1, count[4] + 1);
            }else if(a<=2399){
                count[5] = Math.min(1, count[5] + 1);
            }else if(a<=2799){
                count[6] = Math.min(1, count[6] + 1);
            }else if(a<=3199){
                count[7] = Math.min(1, count[7] + 1);
            }else{
                over++;
            }
        }
        int min = 0;
        for(int i=0; i<8; i++){
            min += count[i];
        }
        int max = min+over;
        if(min==0 && over>=1){
            min=1;
        }
        System.out.println(String.valueOf(min) + " " + String.valueOf(max));
    }
}

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

ll dp[100010][2] = {0};

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

    string l;
    cin >> l;
    ll mod = 1e9 + 7;
    dp[0][0] = 1;
    bool x = false;

    rep(i, l.size())
    {
        dp[i + 1][1] = dp[i][1] * 3LL % mod;

        if (l[i] == '1')
        {
            dp[i + 1][0] = dp[i][0] * 2LL % mod;
            dp[i + 1][1] += dp[i][0];
        }
        else
        {
            dp[i + 1][0] = dp[i][0];
        }
    }
    cout << (dp[l.size()][0] + dp[l.size()][1]) % mod << endl;

    return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q,a,b,c;

struct UnionFind{
	vector<int> data;
	
	UnionFind(int sz){
		data.assign(sz, -1);
	}
	
	bool unite(int x,int y){
		x = find(x); y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	
	bool same(int x,int y){
		if(find(x) == find(y)) return true;
		else return false;
	}
	
	int size(int k){
		return -data[find(k)];
	}
};

int main(){
	cin >> n >> q;
	UnionFind data(n);
	REP(i,0,q){
		cin >> a >> b >> c;
		if(a==0) data.unite(b,c);
		else cout << data.same(b,c) << endl;
	}
	return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;

int main() {
	string S;
	cin >> S;

	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}


	return 0;
}

Measured memory_bytes: 256