akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h> 
int main()
{
	int a[99999],b[99999],q,p,i=0,j,k,h;
	scanf("%d %d",&q,&p);
	while(q!=0 || p!=0)
	{
		i++;
		a[i]=q;
		b[i]=p;
		scanf("%d %d",&q,&p);
	}
	for(j=1;j<=i;j++)
	{
		for(h=1;h<=a[j];h++)
		{
			for(k=1;k<=b[j];k++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long int ll;
const int maxn=1E7+5; 
const int limit=10000000;
ll fac[maxn],inv[maxn],P2[maxn];
inline ll qpow(ll x,ll y)
{
	ll ans=1,base=x;
	while(y)
	{
		if(y&1)
			ans=ans*base%mod;
		base=base*base%mod;
		y>>=1;
	}
	return ans;
}
inline void init()
{
	fac[0]=1;
	for(int i=1;i<=limit;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[limit]=qpow(fac[limit],mod-2);
	for(int i=limit-1;i>=0;--i)
		inv[i]=inv[i+1]*(i+1)%mod;
	P2[0]=1;
	for(int i=1;i<=limit;++i)
		P2[i]=P2[i-1]*2%mod;
}
inline ll C(int x,int y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	ios::sync_with_stdio(false);
	init();
	int n;
	cin>>n;
	ll ans=qpow(3,n),s=0;
	for(int i=n/2+1;i<=n;++i)
		s=(s+P2[n-i]*C(n,i))%mod;
	cout<<((ans-s*2)%mod+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 237988
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	int N = S.length();
	int ans = 0;
	rep(i, 0, N / 2) if (S[i] != S[N - 1 - i]) ans++;
	cout << ans << endl;
}







Measured memory_bytes: 256
def ngcd(lista):
    from fractions import gcd
    res = lista[0]
    for i in range(1,len(lista)):
        if res != 1:
            res = gcd(lista[i],res)
    return res

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(ngcd(a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 81640
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == 500 * a + 100 * b + 50 * c:
                cnt += 1
print(cnt)


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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;
}

typedef long long ll;
// dp[i][j]は，i-1番目までの品物を選んで重さj以下の制約をかけたときの価値の最大値
vector<vector<ll>>
    dp(110, vector<ll>(100010));
vector<ll> w(110);
vector<ll> v(110);

int main()
{
    int N, W;
    cin >> N >> W;
    rep2(i, 0, N)
    {
        cin >> w.at(i);
        cin >> v.at(i);
    }

    rep2(j, 0, W)
    {
        dp.at(0).at(j) = 0;
    }
    rep2(i, 1, N + 1)
    {
        rep2(j, 0, W + 1)
        {
            chmax(dp.at(i).at(j), dp.at(i - 1).at(j)); // i番目を選ばないとき
            if (j - w.at(i - 1) >= 0) {
                chmax(dp.at(i).at(j), dp.at(i - 1).at(j - w.at(i - 1)) + v.at(i - 1));
            }
        }
    }

    cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 87424
#include <iostream>

int main(void)
{
    while(true) {
	int h, w;
        std::cin >> h >> w;
        if(h == 0 && w == 0) { break; }
        for(int i_h = 0; i_h < h; i_h++) {
            for(int i_w = 0; i_w < w; i_w++) {
                if(i_h == 0 || i_h == h - 1 || i_w == 0 || i_w == w - 1) {
                    std::cout << "#";
		} else {
                    std::cout << ".";
                }
            }
            std::cout << std::endl;
	}
        std::cout << std::endl;
    }
}

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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    long long dist = abs(B-A);
    if (dist % 2 == 0) {
        cout << dist/2 << endl;
        return 0;
    }
    
    
    long long toA = A-1, toB = N-B;
    long long ans = max(toA, toB);
    if (toA < toB) {
        ans = toA;
        B -= toA;
        ans += (B+1)/2;
    } else {
        ans = toB;
        ans += (N-A-toB+1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++){
        if(s[i] == '1') cout << 9;
        else cout << 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 764
import math 
def num_divisors_table(n):
  maxnum=math.floor((n + 1)/2) #3
  #table = [0 for _ in range(n+1)]
  length=n-maxnum
  aftersum=int(maxnum*length+length*(length+1)/2)
  aftersum+=(1+n)*n/2
  if n>=2:
    if n%2==0:
      aftersum+=(1+n/2)*n/2
    else:
      aftersum+=(1+(n-1)/2)*(n-1)/2

  for i in range(3, maxnum+1):
    for j in range(i, n+1, i):
      aftersum += j
      #print(i,j)
  return aftersum

N=int(input())
#Nlist,ans_1=num_divisors_table(N)
#print(Nlist)
print(int(num_divisors_table(N)))
#print(int(sum(Nlist)+ans_1))

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

// 配列内のある要素の個数を返す関数
int vector_counter(vector<string> a, string b){
	int cnt = 0;
	for(int i = 0; i < a.size(); i++){
		if(a.at(i) == b){
			cnt++;
		}
	}
	return cnt;
}

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	for(int i = 0; i < N; i++){
		cin >> s.at(i);
	}
	int M;
	cin >> M;
	vector<string> t(M);
	for(int i = 0; i < M; i++){
		cin >> t.at(i);
	}
	int maximum = 0;
	for(int i = 0; i < N; i++){
		maximum = max(vector_counter(s, s.at(i)) - vector_counter(t, s.at(i)), maximum);
	}
	cout << maximum << endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return 1; } else { return 0; }}
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return 1; } else { return 0; }}


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

ll gcd(ll x, ll y) { return x % y ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

/*
* 積が負になる数: 負数 * 正数
* 積が正になる数: 正数 * 正数 or 負数 * 負数
* 答えが0になる数: 0 * 何でも
*/

int main() {
  ll N;
  int K;
  cin >> N >> K;
  int dig = 0;
  while(N) {
    N /= K;
    ++dig;
  }
  cout << dig << endl;
}
/*
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  
  //まず，正，0，負になるペアの個数を数える
  int posct = 0;
  int zeroct = 0;
  int negct = 0;
  rep(i, N) {
    if(A[i] < 0)  ++negct;
    if(A[i] == 0) ++zeroct;
    if(A[i] > 0)  ++posct;
  }
  
  //各符号の組
  int pos_pairct = (posct * posct - posct) / 2 + (negct * negct - negct) / 2;
  int neg_pairct = negct * posct;
  int zero_pairct = (zeroct * zeroct - zeroct) / 2 + (posct * zeroct + negct * zeroct);
  
  sort(A.begin(), A.end());
  
  //順番を区別していったん数えることにする
  //同じインデックス同士は掛けないが，別のインデックスで同じ数なら掛ける
  if(K <= neg_pairct) {
    //負の領域
    //負 * 正 で二分探索
    //負を全部正にして，全部ソートすれば良いのか．筆はなくて生徒みなせばよい．順番が逆になるくらいか
    // int mid = neg_pairct / 2;
    // while(true) {
    //   if(A) 
    // }
  } else if(K <= neg_pairct + zero_pairct) {
    //ゼロの領域
    cout << 0 << endl;
    return 0;
  } else {
    //正の領域
    //昇順
    
    //二分探索で解いてみる    
    int beginIndex = -1;
    rep(i, N) {
      if(A[i] > 0) beginIndex = i;
    }
    int endIndex = N - 1;
    
    int mid = (endIndex - beginIndex) / 2 + beginIndex;
    while(true) {
       
    }
    
  }
}
*/

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
vector<ll> d;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    ll N,K;
    cin>>N>>K;
    ll tot=0;
    for(ll i=0;i<N;i++){
      ll a;
      cin>>a;
      v.push_back(a);
      tot+=a;
    }
    for(ll j=1;j<=sqrt(tot);j++){
      if(tot%j==0){
        d.push_back(tot/j);
        if(j!=sqrt(tot))d.push_back(j);
      }
    }
    sort(d.begin(),d.end(),greater<ll>());
    for(ll i=0;i<d.size();i++){
      ll sol=0,p=0;
      vector<int> t;
      for(ll j=0;j<v.size();j++){
        ll k=min(v[j]%d[i],d[i]-(v[j]%d[i]));
        sol+=k;
        if(v[j]%d[i]<d[i]-(v[j]%d[i])){
          p-=k;
          t.push_back(-k);
        }else{
          p+=k;
          t.push_back(k);
        }
      }
      if(p!=0){
        sort(t.begin(),t.end());
        if(p>0)reverse(t.begin(),t.end());
        int pos=0;
        p=abs(p);
        while(p!=0){
          int o=abs(t[pos]);
          sol+=d[i]-o-o;
          p-=d[i];
          pos++;
        }
      }
      if(sol/2<=K){
        cout<<d[i];
        return 0;
      }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b= sc.nextInt();
        int c=sc.nextInt();
        int temp;
        temp=a;
        a=b;
        b=temp;
        temp=a;
        a=c;
        c=temp;
        System.out.println(a+" "+" "+b+" "+" "+c);


    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:05:17 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
K, N = map(int,input().split())
A = list(map(int,input().split()))
A.append(K+A[0])
B = []
for i in range(N):
    B.append(A[i+1] - A[i])

ans = K - max(B)

print(ans)


Measured memory_bytes: 26444
from collections import deque
#import sys
#sys.setrecursionlimit(10**6)
#input = sys.stdin.buffer.readline
n,m=map(int,input().split())
g = [[] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
q = deque([(0,-1)])
d=[-1]*n
d[0]=0
res={}
while len(q)>0:
    u,r = q.popleft()
    for v in g[u]:
        if d[v] == -1 and r != v:
            d[v] = d[u] + 1
            q.append((v,u))
            if not v-1 in res:
                res[v-1] = u+1
res = sorted(res.items())
if len(res) != n-1:
    print("No")
    exit()
print("Yes")
for i,j in res:
    print(j)


Measured memory_bytes: 111860
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <bitset>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{

    int N, K;
    cin >> N >> K;
    vector<ll> v(N, 0);
    rep(i, N) cin >> v[i];
    ll ans = 0;

    rep(k, 1, min(K + 1, N + 1))
    {
        ll right = k, left = 0;

        for (; left != k + 1; right--, left++)
        {
            ll tmpsum = 0;
            vector<ll> tmpvec;
            rep(i, left)
            {
                tmpsum += v[i];
                tmpvec.push_back(v[i]);
            }
            rep(i, right)
            {
                tmpsum += v[N - 1 - i];
                tmpvec.push_back(v[N - 1 - i]);
            }
            sort(ALL(tmpvec));
            rep(i, min(K - k, (ll)tmpvec.size()))
            {
                if (tmpvec[i] < 0)
                    tmpsum -= tmpvec[i];
            }
            cerr << k << " : " << left << "," << right << "," << tmpsum << endl;

            ans = max(ans, tmpsum);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int w, h, n; cin >>w >>h >>n;
  vector<int> x(n), y(n), a(n);
  for (int i=0; i<n; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  int x1 = 0;
  int x2 = w;
  int y3 = 0;
  int y4 = h;
  for (int i=0; i<n; i++){
    if (a.at(i) == 1) x1 = max(x.at(i), x1);
    if (a.at(i) == 2) x2 = min(x.at(i), x2);
    if (a.at(i) == 3) y3 = max(y.at(i), y3);
    if (a.at(i) == 4) y4 = min(y.at(i), y4);
  }
  
  if (x1>x2) x1 = x2;
  if (y3>y4) y3 = y4;
  
  int ans = max((x2 - x1) * (y4 - y3), 0);
  cout <<ans <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
 	public static void main(String[] args)
    {
     	 Scanner sc = new Scanner(System.in);
      	String[] word = sc.nextLine().split(" ");
      	int[] num = new int[4];
      	for(int i = 0; i < 4; i++)
        {
         	num[i] = Integer.parseInt(word[i]); 
        }
      
      	int a = num[0] / num[3];
      	int b = num[2] / num[1];
      
      	if(num[0] % num[3] != 0)
        {
         	a++; 
        }
      
      	if(num[2] % num[1] != 0)
        {
         	b++; 
        }
      
      	if(a >= b)
        {
          	System.out.println("Yes");
        }else{
          	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	cat N, M;
	cin >> N >> M;
	if(N == 1 && M == 1) {
		cout << "1\n";
		return 0;
	}
	if(min(N, M) == 1) {
		cout << max(N, M) - 2 << "\n";
		return 0;
	}
	cout << (N-2)*(M-2) << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9
int Amax_index(int *p,int size){
   int _max = 0;
   int _i;
   for(int i = 0;i < size;i++)
      if(p[i] > _max){
         _max = p[i];
         _i = i;
      }
   return _i;
}
int main(){
   int a[3],k;scanf("%d%d%d%d",&a[0],&a[1],&a[2],&k);
   for(int i = 3;i < k+3;i++){
      a[Amax_index(a,3)]*=2;
   }
   printf("%d",a[0]+a[1]+a[2]);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <string>
using namespace std;

int main() {
  string S;
  cin >> S;
  int V[20010];
  vector<int> ike;
  stack<int> S_up;
  stack<int> S_down;
  for (unsigned int i=0; i<S.size(); i++) {
    if (S[i] == '\\') {
      S_down.push(i);
      V[i] = 1;
    } else if (S[i] == '/') {
      V[i] = -1;
      if (S_down.empty()) {
	S_up.push(i);
      } else {
	S_down.pop();
      }
    } else {
      V[i] = 0;
    }
  }
  while (!S_up.empty()) {
    int x = S_up.top();
    S_up.pop();
    V[x] = 0;
  }
  while (!S_down.empty()) {
    int x = S_down.top();
    S_down.pop();
    V[x] = 0;
  }
  for (unsigned int i=1; i<S.size(); i++) {
    V[i] = V[i-1] + V[i];
  }
  for (unsigned int i=1; i<S.size(); i++) {
    if (V[i] == 0 && V[i-1] != 0) {
      ike.push_back(V[i-1]);
    } else {
      V[i] = V[i-1] + V[i];
    }
  }
  int sum = 0;
  for (unsigned int i=0; i<ike.size(); i++) {
    sum += ike[i];
  }
  cout << sum << endl;
  cout << ike.size();
  for (unsigned int i=0; i<ike.size(); i++) {
    cout << " " << ike[i];
  }
  cout << endl;
}

Measured memory_bytes: 1388
// c++ arc086_c_sub.cpp

#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <deque>
#include <algorithm>
#define PB push_back
#define MP make_pair
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef deque<ll> di;
typedef deque<pii> dii;

const int MAX_N = 200001;
const ll MOD = 1000000007;

ll N, p;
ll l2[MAX_N], max_depth = 0;

vi tree[MAX_N];

class Children {
public:
  di children_cnts;
  dii one_zero;
  int second_length;

  Children():second_length(0) {
    this->children_cnts.resize(0);
    this->one_zero.resize(0);
  }

  int size() {
    return this->one_zero.size();
  }

  void firstMarge(Children* cld) {
    for (int i=0; i<cld->size(); i++) {
      this->one_zero[i].first  = (this->one_zero[i].first  * cld->one_zero[i].second) % MOD
                                + (this->one_zero[i].second * cld->one_zero[i].first) % MOD;
      this->one_zero[i].first %= MOD;
      this->one_zero[i].second = (this->one_zero[i].second * cld->one_zero[i].second) % MOD;
      this->children_cnts[i] += cld->children_cnts[i];
    }
    second_length = max(second_length, cld->size());
  }

  void lastMarge(pii ab) {
    for (int i=0; i<this->second_length; i++) {
      this->one_zero[i].second = (l2[this->children_cnts[i]] + MOD - this->one_zero[i].first) % MOD;
    }
    this->children_cnts.push_front(ab.first);
    this->one_zero.push_front(ab);
    second_length = 0;
  }
};

ll inv(ll x) {
  ll res = 1, n = MOD - 2;
  while (0 < n) {
    if (n & 1) {
      res = x * res % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

void swap(Children** a, Children** b) {
  Children* tmp = *a; *a = *b; *b = tmp;
}

Children* dfs(ll x) {
  ll a = tree[x].size();
  Children* res = new Children();
  if (a == 0) return res;

  res = dfs(tree[x][0]);
  for (int i=1; i<tree[x].size(); i++) {
    Children* dfs_res = dfs(tree[x][i]);
    if (res->size() < dfs_res->size()) swap(&res, &dfs_res);
    res->firstMarge(dfs_res);
  }
  res->lastMarge(MP(a, (l2[a] + MOD - a) % MOD));
  return res;
}

void init() {
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> p;
    tree[p].PB(i + 1);
  }
  l2[0] = 1;
  for (int i=1; i<MAX_N; i++) {
    l2[i] = (l2[i-1] * 2) % MOD;
  }
}

ll solve() {
  ll ans = l2[N];
  Children* res = dfs(0);
  for (int i=0; i<res->size(); i++) {
    ans += res->one_zero[i].first * l2[N+1-res->children_cnts[i]] % MOD;
    ans %= MOD;
  }
  return ans;
}

int main() {
  init();
  cout << solve() << endl;
  return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long P, string S) {
    int ans = 0;
    if (P == 2 or P == 5) {
        unordered_map<int, int> dp;
        rep(i, N) {
            unordered_map<int, int> dpn;
            int m = (S[i] - '0') % P;
            dpn[m]++;
            for (auto p : dp) {
                auto x = p.first;
                dpn[(x * 10 + m) % P] += dp[x];
            }

            dp = dpn;
            ans += dp[0];
        }
    } else {
        map<int, int> mp;
        reverse(all(S));
        mp[0] = 1;
        ll cur = 0, p10 = 1;
        rep(i, N) {
            cur += (S[i] - '0') * p10;
            cur %= P;
            ans += mp[cur];
            mp[cur]++;
            p10 = (p10 * 10) % P;
        }
    }
    cout << ans << endl;
}

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

    long long N;
    long long P;
    string S;
    cin >> N >> P >> S;
    solve(N, P, S);
    return 0;
}


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

int main() {
  int h,w;
  cin>>h>>w;
  char s[h][w];
  int black=0;
  int ans[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) {
      cin>>s[i][j];
      ans[i][j]=-1;
      if(s[i][j]=='#') black++;
    }
  }
  if(s[0][0]=='#') {
    cout<<-1<<endl;
    return 0;
  }
  ans[0][0]=0;
  queue<int> memo;
  memo.push(0);memo.push(0);
  while(!memo.empty()){
    int y=memo.front();memo.pop();
    int x=memo.front();memo.pop();
    int dy[4]={0,1,0,-1},dx[4]={1,0,-1,0};
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny<0 || ny>=h || nx<0 || nx>=w || s[ny][nx]=='#') continue;
      if(ans[ny][nx]!=-1) continue;
      ans[ny][nx]=ans[y][x]+1;
      memo.push(ny);memo.push(nx);
    }
  }
  if(ans[h-1][w-1]==-1) cout<<-1<<endl;
  else cout<<h*w-1-ans[h-1][w-1]-black<<endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  int ans = 0, N = S.size();
  char L = S[0];
  for (int i = 1; i < N; i++) {
    if (S[i] != L) {
      ans++;
      L = S[i];
    }
  }
  cout << ans << endl;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

struct state {
    int y;
    int x;
    ll score;
    int pick;
};

ll memo[3000][3000][4];
ll vll[3000][3000];
int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    REP(i, K)
    {
        int y, x;
        ll v;
        cin >> y >> x >> v;
        y--;
        x--;
        vll[y][x] = v;
    }
    REP(i, H)
    {
        REP(j, W)
        {
            if (i - 1 >= 0) {
                REP(k, 4)
                memo[i][j][0] = max(memo[i][j][0], memo[i - 1][j][k]);
            }
            if (j - 1 >= 0) {
                REP(k, 4)
                memo[i][j][k] = max(memo[i][j][k], memo[i][j - 1][k]);
            }
            if (vll[i][j] > 0) {
                REPD(k, 3)
                memo[i][j][k + 1] = max(memo[i][j][k + 1], memo[i][j][k] + vll[i][j]);
            }
        }
    }
    ll ans = 0;
    REP(i, 4)
    ans = max(ans, memo[H - 1][W - 1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 355048
#include<stdio.h>
int main(void)
{
	int n,a,b,c;
	scanf("%d",&n);
	a=n/100;
	n=n%100;
	b=n/10;
	c=n%10;
	if(a==7||b==7||c==7){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w,m;
  cin>>h>>w>>m;
  int num[w],numh[h];
  for(int i=0;i<w;i++) num[i]=0;
  for(int i=0;i<h;i++) numh[i]=0;
  int maxw=0;
  int maxh=0;
  set<pair<int,int>> mm;
  for(int i=0;i<m;i++){
    int hi,wi;
    cin>>hi>>wi;
    hi--;
    wi--;
    num[wi]++;
    numh[hi]++;
    maxw=max(maxw,num[wi]);
    mm.insert(make_pair(hi,wi));
    maxh=max(maxh,numh[hi]);
  }
  int res=maxh+maxw-1;
  vector<int> hm;
  for(int i=0;i<h;i++)
  {
    if(numh[i]==maxh) hm.push_back(i);
  }
  int ttt=hm.size();
  for(int i=0;i<w;i++){
    if(num[i]==maxw){
      for(int j=0;j<ttt;j++){
        if(mm.count(make_pair(hm[j],i))==0){
          cout<<res+1<<endl;
          return 0;
        }
      }
    }
  }
  cout<<res<<endl; 
}


Measured memory_bytes: 21740
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const long long MAXN=405,MOD=1e9+7;
long long n,c;
long long dp[MAXN][MAXN];
long long ycl[MAXN][MAXN];
long long a[MAXN],b[MAXN];
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
void Init()
{
	for(long long i=0;i<=400;i++)
	{
		for(long long j=0;j<=400;j++)
		{
			ycl[i][j]=ksm(i,j);
		}
	}
	for(long long j=0;j<=400;j++)
	{
		for(long long i=0;i<=400;i++)
		{
			ycl[i][j]+=ycl[i-1][j];
			ycl[i][j]%=MOD;
		}
	}
}
int main()
{
	Init();
	scanf("%lld %lld",&n,&c);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
	}
	dp[0][0]=1;
	for(long long i=1;i<=n;i++)
	{
		for(long long j=0;j<=c;j++)
		{
			for(long long l=0;l<=j;l++)
			{
				dp[i][j]+=(dp[i-1][j-l]*(ycl[b[i]][l]-ycl[a[i]-1][l]))%MOD;
				dp[i][j]%=MOD;
			}
		}
	}
	printf("%lld\n",(dp[n][c]+MOD)%MOD);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
    ll n;
    ll cnt=0;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    
   
    return 0;
}

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

int main(){
  int n,k;
  int d[110];
  int a[110][110];
  int b[110];
  cin>>n>>k;
  rep(i,k){
    cin>>d[i];
    rep(j,d[i]){
      cin>>a[i][j];
      b[a[i][j]-1]=1;
    }
  }
  int cnt=0;
  rep(i,n){
    if(b[i]==1)cnt++;
  }
  cout<<n-cnt;



  return 0;
}

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


typedef long long ll;
int main() {
  int n; cin >> n;
  vector<ll> la(n+1);
  vector<int> aa;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    aa.push_back(a);
    ++la[a];
  }
  ll sum = 0;
  for (int i = 0; i <= n; ++i) {
    if (la[i] > 1) sum += la[i]*(la[i]-1)/2;
  }
  for (int i = 0; i < n; ++i) {
    int a = aa[i];
    cout << sum-(la[a]-1) << endl;
  }
}


Measured memory_bytes: 5108
#include<stdio.h>
int main()
{
    int N,A;
    scanf("%d%d",&N,&A);
    if(N<500)
    {
    if(N>A)
        printf("No");
    else if(N<=A)
        printf("Yes");
    }
    else if(N>=500)
    {
        if(N%500>A)printf("No");
        else
            printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
def main():
	n,k,c=MI()
	s=input().rstrip().decode()
	
	kk=k
	i=0
	L=[]
	while kk:
		if s[i]=="o":
			L.append(i+1)
			i+=c+1
			kk-=1
		else:
			i+=1
		
	kk=k
	i=n-1
	R=[]
	while kk:
		if s[i]=="o":
			R.append(i+1)
			i-=c+1
			kk-=1
		else:
			i-=1
	R.sort()
	
	for i,j in zip(L,R):
		if i==j:
			print(i)
	
	
	
	
	
	
	
	

if __name__=="__main__":
	main()


Measured memory_bytes: 100912
import java.util.ArrayList;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int times = sc.nextInt();
			TreeMap<String, ArrayList<Long>> map = new TreeMap<>();
			for (int i = 0; i<times; i++){
				int query = sc.nextInt();
				String key = sc.next();
				switch (query) {
				case 0:
					long x = sc.nextLong();
					if (map.get(key)==null) map.put(key, new ArrayList<Long>());  //初めは空のArrayListを作成
					map.get(key).add(x);  //ArrayListにxを追加
					break;
				case 1:
					if (map.get(key)!=null) {
						for (Long l : map.get(key))	System.out.println(l);  //ArrayListの中身を全て出力
					}
					break;
				case 2:
					map.remove(key);
					break;
				case 3:
					String large = sc.next();
					SortedMap<String,ArrayList<Long>> submap = map.subMap(key,true,large,true);
					for (String s : submap.keySet()) {
						for (long l : submap.get(s)) {
							System.out.println(s +" " + l);
						}
					}
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 200464
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")

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

int main()
{
    int n; cin>>n; n= n%10;
    if(n==3) cout<<"bon"<<"\n";
    else if(n==0 || n==1 || n==6 || n==8) cout<<"pon"<<"\n";
    else cout<<"hon"<<"\n";
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N;

unordered_map<i64, int> memo;
inline int depth(const int u) {
    if (memo.count(u)) return memo[u];
    int cur = u;
    i64 d = 0;
    while (cur > 0) ++d, cur = (cur - 1) / N;
    return memo[u] = d;
}

inline i64 findLCA(int a, int b) {
    if (N == 1) {
        return min(a, b);
    }
    while (a != b) {
        const int depA = depth(a);
        const int depB = depth(b);
        if (depA > depB) {
            rep(i, 0, depA - depB) a = (a - 1) / N;
        } else if (depA < depB) {
            rep(i, 0, depB - depA) b = (b - 1) / N;
        } else {
            a = (a - 1) / N;
            b = (b - 1) / N;
        }
    }
    return a;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int Q;
    read(N, Q);

    while (Q--) {
        VAR(int, a, b);
        --a, --b;
        print(findLCA(a, b) + 1);
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

int n;
ll dis[100005];
vector<pair<ll,ll> > g[100005];

void dfs(int i,int fa)
{
    for(int j=0;j<g[i].size();j++)
    {
        int to = g[i][j].first;
        ll val = g[i][j].second;

        if(to==fa) continue;
        dis[to] = dis[i] +val;
        dfs(to,i);
    }
}

int main()
{
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        g[x].push_back(make_pair(y,z));
        g[y].push_back(make_pair(x,z));
    }

    int q,k;
    cin>>q>>k;
    dfs(k,0);
    while(q--)
    {
        int x,y;
        cin>>x>>y;
        cout<<dis[x]+dis[y]<<endl;
    }
}


Measured memory_bytes: 14336
# include<stdio.h>
# include<string.h>
int main(void)
{
    char s1[107], s2[107], s3[107];
    scanf("%s%s", s1, s2);
    int i, j, flag = 0;
    for(i = 0; s1[i] != '\0'; ++i)
    {
        int cnt = 0;
        for(j = i+1; s1[j] != '\0'; ++j)
            s3[cnt++] = s1[j];
        for(j = 0; j <= i; ++j)
            s3[cnt++] = s1[j];
        s3[cnt] = '\0';
        if(strcmp(s2, s3) == 0)
        {
            flag = 1;
            break;
        }
    }
    if(flag == 1)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
A = LIST()
A.sort()

if A == [5, 5, 7]:
	print("YES")
else:
	print("NO")

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

int main() {
	ll n;
	cin >> n;
	for (ll i = 1; i < 10; ++i) {
		for (ll j = 1; j < 10; ++j) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += a - 1;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
std::string S;
int solve(){
  int res1=INF,ss=S.size();
  rep(i,ss){
    if(S[i]=='1'){
      int temp=std::max(std::max(i,ss-1-i),std::min(i+1,ss-i));
      res1=std::min(res1,temp);
    }
  }
  int res2=INF;
  rep(i,ss){
    if(S[i]=='0') S[i]='1';
    else S[i]='0';
  }
  rep(i,ss){
    if(S[i]=='1'){
      int temp=std::max(std::max(i,ss-1-i),std::min(i+1,ss-i));
      res2=std::min(res2,temp);
    }
  }  
  int res=std::max(res1,res2);
  if(res==INF) res=ss;
  return res;
}
int main(){
  cin>>S;
  prin(solve());
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int k = S.size();
	int cnt = 0;
	rep(i,k){
		if(S[i] == 'o')cnt++;
	}
	string ans = "NO";
	if(15-k + cnt >= 8)ans ="YES";
	cout<<ans<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int s, w;
    cin >> s >> w;
    if (w >= s)
    {
        OP("unsafe");
    }
    else
    {
        OP("safe");
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> s(n, 0);
    for (int i = 0; i < k; i++) {
        int di;
        cin >> di;
        for (int j = 0; j < di; j++) {
            int aij;
            cin >> aij;
            s[aij-1]++;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (s[i] == 0)
            ans++;
        
    cout << ans << endl;
    
    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   int a;
   cin >> a;
   cout <<  a + a*a + a*a*a;
}

int32_t main(){
   fast;
   int t = 1;
   // cin >> t;
   while(t--)  solve();   
}

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

int main() {
  int N;
  int data[100];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  int max = 0;
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < N; k++) {
      int z = abs(data[i] - data[k]);
      if (z > max) max = z;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
def main():
    # import sys
    # readline = sys.stdin.readline
    # readlines = sys.stdin.readlines

    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))

    pos = X[0]
    cnt = 0
    for x in X:
        walk = (x - pos) * A
        tele = B
        if walk < tele:
            cnt += walk
        else:
            cnt += tele
        pos = x
    
    print(cnt)


if __name__ == "__main__":
    main()


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

using namespace std;
const long long mod=2019;

int main()
{
    long long L,R;
    long long ans=10000000000000000;
    cin>>L>>R;
    if(R-L<2019){
        for(long long i=L;i<R;i++){
            for(long long j=i+1;j<=R;j++){
                ans=min(ans,(i*j)%mod);
            }
        }
        cout<<ans<<endl;
    }else{
       
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
using System;

class plogram
{
    static void Main()
    {

        string[] array = Console.ReadLine().Split(' ');
        var A = int.Parse(array[0]);
        var B = int.Parse(array[1]);
        var T = int.Parse(array[2]);

        var sum = ((T)/A)*B ;

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>

using namespace std;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int n,y;
  cin>>n>>y;
  int ans=0,flag=false;
  rep(i,0,n+1){
    rep(j,0,n+1){
        if(n-i-j>=0 && i*10000+j*5000+(n-i-j)*1000==y){
            cout<<i<<" "<<j<<" "<<n-i-j;
            flag=true;
            break;
        }
    }
    if(flag) break;
  }
  if(!flag) cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    hList = list(map(int, input().split()))
    hAns = [1] * n
    for i in range(m):
        a, b = map(int, input().split())
        if hList[a - 1] > hList[b - 1]:
            hAns[b - 1] = 0
            continue
        if hList[a - 1] < hList[b - 1]:
            hAns[a - 1] = 0
            continue
        hAns[a - 1] = 0
        hAns[b - 1] = 0
    print(sum(hAns))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

const int maxN = 100000;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
    int N; cin >> N;
    vector<int> v(maxN+3, 0);
    REP(i, N) {
        int a, b; cin >> a >> b;
        ++v[a];
        --v[b+1];
    }
    REP(i, v.size()-1) {
        v[i+1] += v[i];
    }
    int ans = 0;
    FOR(i, 1, N+2) {
        if (v[i+1] >= i) {
            ans = max(ans, (int)i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = 0;
  
  if (n % x) ans = (n/x + 1) * t;
  else ans = n/x * t;
    
  cout << ans << endl;
  
return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  char s[100001];
  scanf("%s",s);

  int len = strlen(s);
  int a=0,b=0;
  for(int i = 0; i < len; ++i){
    if(s[i] == '0') a++;
    else b++;
  }
  a = min(a,b);

  printf("%d",a*2);

  return 0;
}


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

int main() {
  int N, x;
  string S;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> S;
    if(S=="Y"){
      x++;
    }
  }
  if(x>=1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
n = int(raw_input())
while n != 0:
    input_list = []
    for x in range(n):
        input_list.append(map(int, raw_input().split(' ')))
    for x in range(n):
        input_list[x].append(sum(input_list[x]))
        print ''.join(map(lambda n:"{:>5}".format(n), input_list[x]))

    input_len = len(input_list[0])
    column_list = []
    for x in range(input_len):
        tmp = 0
        for y in range(n):
            tmp += input_list[y][x]
        column_list.append(tmp)
    print ''.join(map(lambda n:"{:>5}".format(n), column_list))
    n = int(raw_input())

Measured memory_bytes: 6344
import heapq


class Reverse:
    def __init__(self, val):
        self.val = val

    def __lt__(self, other):
        return self.val > other.val

    def __repr__(self):
        return repr(self.val)


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        if len(self.hq) == 0:
            return None
        if self.desc:
            return heapq.heappop(self.hq).val
        else:
            return heapq.heappop(self.hq)

    def push(self, a):
        if self.desc:
            heapq.heappush(self.hq, Reverse(a))
        else:
            heapq.heappush(self.hq, a)


N, M = map(int, input().split())
q = Heapq(list(map(int, input().split())), desc=True)

while M > 0:
    a = q.pop() // 2
    q.push(a)
    M -= 1

tmp = 0
while True:
    try:
        a = q.pop()
        tmp += a
    except:
        break
print(tmp)


Measured memory_bytes: 23724