akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  for (auto &e : d)
    cin >> e;
  for (int i = n; i < 100000; ++i)
  {
    string s = to_string(i);
    bool flag = true;
    for (int j = 0; j < s.size(); ++j)
    {
      for (int l = 0; l < k; ++l)
        if ((s[j] - '0') == d[l])
          flag = false;
    }
    if (flag)
    {
      cout << s << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 + 7;
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; }

const int MAX = 1e5+1;
vector<vector<int>> edge(MAX);
//0:black, 1:white
vector<vector<ll>> dp(MAX, vector<ll>(2, 0));
vector<int> depth(MAX, 0);

ll dfs(int root, int color, int d){
  if(depth[root] != 0 && dp[root][color] != 0) {
    // cout << "visited" << endl;
    // DUMP(root);
    // DUMP(color);
    return dp[root][color];
  }
  depth[root] = d;
  ll ret = 1;
  bool is_leaf = true;
  FOREACH(child, edge[root]){
    if(depth[child] <= d  && depth[child] != 0) continue;
    ll tmp = 0;
    is_leaf = false;
    ll white = dfs(child, 1, d + 1);
    ll black = dfs(child, 0, d + 1);
    (tmp += white) %= MOD;
    if(color == 1) (tmp += black) %= MOD;
    (ret *= tmp) %= MOD;
  }

  if(is_leaf){
    // cout << "is_leaf" << endl;
    // DUMP(root);
    // DUMP(color);
    dp[root][0] =  1;
    dp[root][1] =  1;
    return 1;
  }
  // DUMP(root);
  // DUMP(color);
  // DUMP(ret);
  return dp[root][color] = ret;
}

int main() {
  int N;  cin >> N;
  REP(i, N-1){
    int x, y;
    cin >> x >> y;
    x; y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  edge[0].push_back(1);
  edge[1].push_back(0);

  cout << dfs(0,1,1)<< endl;

  // REP(i, N+1) REP(j, 2){
  //   DUMP(i); DUMP(j);
  //   DUMP(dp[i][j]);
  // }

  // REP(i, N+1){
  //   DUMP(i);
  //   DUMP(depth[i]);
  // }
}


Measured memory_bytes: 18560
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from functools import reduce

def segfunc(a,b):
    if a == 0 or b == 0:
        return max(a, b)
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return segfunc(b, r)

def gcd_list(numbers):
    return reduce(segfunc, numbers)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


n = ii()
#A = sorted(li())
A = li()

#####単位元######
'''
if n == 2:
    print(max(A))
    exit()
elif n == 3:
    ide_ele = max(segfunc(A[0], A[1]), segfunc(A[1], A[2]), segfunc(A[0], A[2]))
else:
    #ide_ele = max(segfunc(A[-1], A[-2]), segfunc(A[-3], A[-4]))
    ide_ele = max(segfunc(A[0], A[1]), segfunc(A[2], A[3]))
    print(segfunc(A[0], A[1]), segfunc(A[2], A[3]))
'''
ide_ele = 0
#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(A)
ans = 0

#ans = max(query(1, n), ans)
#for i in range(1, n-1):
for i in range(n):
    #print(i, query(0, i), query(i+1, n))
    ans = max(segfunc(query(0, i), query(i+1, n)), ans)
#ans = max(query(0, n-1), ans)

print(ans)

Measured memory_bytes: 114208
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int N,A,B;
    long long int sum,Ans=0;
    cin >> N >> A >> B;
    REP(i,N+1){
        if(i==0)continue;
        sum=i%10 + (i/10)%10 +(i/100)%10 +(i/1000)%10+(i/10000)%10;
        if(A<=sum && sum<=B){
            Ans+=i;
        }
    }
    cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
HPs = [tuple(map(int, input().split())) for i in range(N)]

HPs.sort(key=lambda x: x[0] + x[1])

INF = float('inf')
dp = [0]
for i, (H, P) in enumerate(HPs, 1):
    if dp[-1] != INF:
        dp += [INF]

    for j in range(1, len(dp))[::-1]:
        hgt = dp[j - 1]
        if hgt <= H:
            dp[j] = min(dp[j], hgt + P)

dp += [INF]
print(dp.index(INF) - 1)


Measured memory_bytes: 48088
fun main() {
    val (n, m) = readIntList()
    val a = readIntList()

    val sum = a.sum()
    if (a.count { it * 4 * m >= sum } >= m) println("Yes")
    else println("No")
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 37800
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    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};
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int N;
      cin >> N;
      string S;
      cin >> S;
      REP(i,S.size()){
        auto c = S[i]-'A';
        S[i] = (c+N)%26 + 'A';
      }
      cout << S;
      return 0;
    }

Measured memory_bytes: 256
while True:
  s = input().rstrip().split(' ')
  H = int(s[0])
  W = int(s[1])
  if H == 0 and W == 0:
    break;
  ans = ""
  for i in range(W):
    ans += "#"
  for j in range(H):
    print(ans)
  print("")


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100005][3];
int vacation(int mat[100005][3],int day,int flag)
{
	if(day==n) return 0;
	if(day!=-1 && flag!=-1 && dp[day][flag]!=-1) return dp[day][flag];
	int maxi=0;
	if(day==-1){
		maxi=max(maxi,vacation(mat,day+1,0));
		maxi=max(maxi,vacation(mat,day+1,1));
		maxi=max(maxi,vacation(mat,day+1,2));
	}
	else if(flag==0){
		maxi=max(maxi,mat[day][flag]+vacation(mat,day+1,1));
		maxi=max(maxi,mat[day][flag]+vacation(mat,day+1,2));
	}
	else if(flag==1){
		maxi=max(maxi,mat[day][flag]+vacation(mat,day+1,0));
		maxi=max(maxi,mat[day][flag]+vacation(mat,day+1,2));
	}
	else if(flag==2){
		maxi=max(maxi,mat[day][flag]+vacation(mat,day+1,0));
		maxi=max(maxi,mat[day][flag]+vacation(mat,day+1,1));
	}
	return dp[day][flag] = maxi;
}
int main() {
	cin>>n;
	int mat[100005][3];
	memset(dp,-1,sizeof dp);
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>mat[i][j];
		}
	}
	cout<<vacation(mat,-1,-1)<<'\n';
}


Measured memory_bytes: 8832
#include<iostream>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
#define fi first
#define sc second
typedef long long ll;

using namespace std;

int main(){
    string s;cin>>s;
    ll ans=0,cur=0;
    for(int i=0;i<s.size();i++){
	if(s[i]=='B')cur++;
	if(s[i]=='W')ans+=cur;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,size,ans;
  cin >> n;
  ll a[n],sum[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<ll>());
  sum[n-1]=a[n-1];
  for(int i=n-2;i>=0;i--){
    sum[i]=sum[i+1]+a[i];
  }
  ans=1;
  for(int i=1;i<n;i++){
    if(a[i-1]<=sum[i]*2){
      ans++;
    }else{
      break;
    }
  }
  cout <<ans<<endl;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  int sum = 1;
  
  for(int i=0; i<N; i++){
  	if(sum*2 < sum+K)sum *=	2;
  	else sum += K;
  }
  cout << sum << endl;
 
}

Measured memory_bytes: 3632
// 2020-08-02 14:53:51
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int n;
  cin >> n;
  puts(n >= 30 ? "Yes" : "No");
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3656
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
#include <random>

#pragma warning(disable: 4996)

using namespace std;
 
namespace Bigcat {
	template <typename T> inline void max_s(T&a, const T&b) { a = max(a, b); }
	template <typename T> inline void min_s(T&a, const T&b) { a = min(a, b); }

	template <typename T>  void sort_v(T & x) { sort(x.begin(), x.end()); }
	template <typename T>  void erase_dup(T & x) { x.erase(unique(x.begin(), x.end()), x.end()); }    // erase duplicate
	template <typename T, typename V>  int pos_l(const T & x, const V & v) { return lower_bound(x.begin(), x.end(), v) - x.begin(); }
	template <typename T, typename V>  int pos_u(const T & x, const V & v) { return upper_bound(x.begin(), x.end(), v) - x.begin(); }

	inline unsigned rand_g() {
		static mt19937 mt_rand((int)time(0));
		return mt_rand();
	}

	using LL = long long;


	using VI = vector<int>;
	using VVI = vector< VI >;
	using VL = vector<LL>;
	using PII = pair<int, int>;
	using VPII = vector< PII >;

}
using namespace Bigcat;
const int MAX = int ( 1e5 + 100 ) ;
const LL base = LL(1e9 + 7);
const LL INFL = 4223372036854775807LL;
const int INF = 1047483647;


struct Node {
	int x, y, w;
};
bool operator < (const Node & n0, const Node & n1) {
	return n0.x< n1.y;
}
int n, m;
VI gr0[MAX], gr1[MAX];
int ins[MAX], zr[MAX];
void solve1() {

	LL result = 0;

	cin >> n>>m;
	for (int i = 0; i < n - 1 + m; ++i) {
		int a, b;
		cin >> a >> b;
		gr0[a].push_back(b);
		gr1[b].push_back(a);
		ins[b]++;
	}
	int root = 0;
	for (int i = 1; i <= n; ++i) {
		if (ins[i] == 0) {
			root = i;
			break;
		}
	}

	VI bfs;
	bfs.push_back(root);
	int head = 0;
	while (head < bfs.size()) {
		int now = bfs[head];
		head++;
		for (auto x : gr0[now]) {
			ins[x] --;
			if (ins[x] == 0) {
				bfs.push_back(x);
				zr[x] = now;
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << zr[i] << '\n';
	}

}
void solve() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i) {
		solve1();
	}
    int x = 1;
}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);
		if (r == nullptr) {
			cerr << "invalid input file " << s << endl;;
			r = freopen("CON", "r", stdin);
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr << "invalid output file " << s << endl;;
			r = freopen("CON", "w", stdout);
		}
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}


Measured memory_bytes: 13052
#include<stdio.h>

struct node{
  int id,l,r;
};

struct node T[25];

void pre(int u){
  if(u == -1) return;

  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}

void in(int u){
  if(u == -1) return;

  in(T[u].l);
  printf(" %d",u);
  in(T[u].r);
}

void post(int u){
  if(u == -1) return;

  post(T[u].l);
  post(T[u].r);
  printf(" %d",u);
}

int main(){
  int i;
  int n,id,l,r,root;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    T[i].id = -1;
  }

  for(i=0; i<n; i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(T[id].l != -1) T[T[id].l].id = id;
    if(T[id].r != -1) T[T[id].r].id = id;
  }

  for(i=0; i<n; i++){
    if(T[i].id == -1) root = i;
  }

  printf("Preorder\n");
  pre(root);
  printf("\n");
  printf("Inorder\n");
  in(root);
  printf("\n");
  printf("Postorder\n");
  post(root);
  printf("\n");

  return 0;
}


Measured memory_bytes: 2112
// D - We Like AGC

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct ModInt {
	long long val;
	constexpr ModInt(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr ModInt operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr ModInt operator + (const ModInt& r) const noexcept { return ModInt(*this) += r; }
	constexpr ModInt operator - (const ModInt& r) const noexcept { return ModInt(*this) -= r; }
	constexpr ModInt operator * (const ModInt& r) const noexcept { return ModInt(*this) *= r; }
	constexpr ModInt operator / (const ModInt& r) const noexcept { return ModInt(*this) /= r; }
	constexpr ModInt& operator += (const ModInt& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr ModInt& operator -= (const ModInt& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr ModInt& operator *= (const ModInt& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr ModInt& operator /= (const ModInt& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const ModInt& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const ModInt& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const ModInt<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr ModInt<MOD> modpow(const ModInt<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

const int MOD = 1000000007;
using mint = ModInt<MOD>;

mint dp[101][4][4][4];
const int A = 0;
const int C = 1;
const int G = 2;
const int T = 3;

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

	for (int c2=0; c2<4; c2++) {
		for (int c1=0; c1<4; c1++) {
			for (int c0=0; c0<4; c0++) {
				if (c2 == A && c1 == G && c0 == C) continue;
				if (c2 == G && c1 == A && c0 == C) continue;
				if (c2 == A && c1 == C && c0 == G) continue;

				dp[3][c2][c1][c0] = 1;
			}
		}
	}

	for (int i=4; i<=N; i++) {
		for (int c3=0; c3<4; c3++) {
			for (int c2=0; c2<4; c2++) {
				for (int c1=0; c1<4; c1++) {
					for (int c0=0; c0<4; c0++) {
						if (c2 == A && c1 == G && c0 == C) continue;
						if (c2 == G && c1 == A && c0 == C) continue;
						if (c2 == A && c1 == C && c0 == G) continue;

						if (c3 == A && c2 == G && c0 == C) continue;
						if (c3 == A && c1 == G && c0 == C) continue;

						dp[i][c2][c1][c0] += dp[i-1][c3][c2][c1];
					}
				}
			}
		}
	}

	mint ans = 0;
	for (int c2=0; c2<4; c2++) {
		for (int c1=0; c1<4; c1++) {
			for (int c0=0; c0<4; c0++) {
				ans += dp[N][c2][c1][c0];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3652
input = gets
input.chomp!

s = input.split("")
n = s.size

oddB = 0
evenW = 0
for i in 1..n do
    if i % 2 == 1 and s[i-1] == "0"
        oddB += 1
    elsif i % 2 == 0 and s[i-1] == "1"
        evenW += 1
    end
end

bwb = oddB + evenW
wbw = n - bwb

if bwb > wbw
    p wbw
else
    p bwb
end

Measured memory_bytes: 9340
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
 
#define PI 3.141592653589793238
 
int main(int, char**)
{
    float n;
 
    cin >> n;
 
    cout << 2 * n * PI << endl;
 
    return 0;
}

Measured memory_bytes: 3784
import java.util.*;

class Main{
    static boolean fin(boolean[] searched){
        for(boolean b : searched){
            if(b==false) return false;
        }
        return true;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] graph = new int[n][n];
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                graph[i][j]=sc.nextInt();
            }    
        }

        int cost = 0;
        boolean[] searched = new boolean[n];
        for(boolean b : searched) b = false;
        searched[0] = true;

        while(!fin(searched)){
            int nextNode = -1;
            int minCost = Integer.MAX_VALUE;

            for(int i=0; i<n; i++){
                if(!searched[i]){
                    for(int j=0; j<n; j++){
                        if(graph[i][j]<minCost && graph[i][j]!=-1 && searched[j] ){
                            nextNode = i;
                            minCost = graph[i][j];
                        }
                    }
                }
            }
            searched[nextNode] = true;
            cost+=minCost;
        }
        System.out.println(cost);
    }
}


Measured memory_bytes: 40936
#include<stdio.h>

char S[2000001];
int A[2000001] = {0};
int Z[2000001] = {0};

int main()
{
    scanf("%s", S);

    int i;
    int ja = 0;
    int jz = 0;
    int j;
    int max = 0;

    for(i = 0; S[i]; i++){
        if(S[i] == 'A'){
            A[ja] = i;
            ja++;
        }
        else{
            if(S[i] == 'Z'){
                Z[jz] = i;
                jz++;
            }
        }
    }

    max = (Z[jz - 1] - A[0]);

    printf("%d\n", max + 1);

    return 0;
}

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

using P = pair<long long, int>;
const long long INF = 1e18 + 10;

struct Edge {
  int to, w;
  Edge(int t, int w) : to(t), w(w) {}
};

struct Graph {
  int N, M;
  vector<vector<Edge>> edges;

  Graph(int N, int M) : N(N), M(M), edges(N) {}

  void addEdge(int a, int b) { addEdge(a, b, 1); }
  void addEdge(int a, int b, int w) { edges[a].emplace_back(b, w); }

  vector<long long> dist;
  void dijkstra(int s) {
    dist = vector<long long>(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.emplace(0, s);
    while (!pq.empty()) {
      long long d, now;
      tie(d, now) = pq.top();
      pq.pop();
      if (dist[now] != INF) continue;
      dist[now] = d;
      for (Edge e : edges[now]) {
        if (dist[e.to] == INF) pq.emplace(d + e.w, e.to);
      }
    }
  }
};

int main() {
  cout << setprecision(15);
  int n, m, s, t; cin >> n >> m >> s >> t;
  s--; t--;
  Graph Ga(n, m), Gb(n, m);
  rep(i, m) {
    int u, v, a, b; cin >> u >> v >> a >> b;
    u--; v--;
    Ga.addEdge(u, v, a);
    Ga.addEdge(v, u, a);
    Gb.addEdge(u, v, b);
    Gb.addEdge(v, u, b);
  }
  Ga.dijkstra(s);
  Gb.dijkstra(t);

  vector<P> ans(n);
  rep(i, n) ans[i] = P(Ga.dist[i] + Gb.dist[i], i);
  sort(ans.begin(), ans.end());
  int now = 0;
  rep(i, n) {
    while (ans[now].second < i) now++;
    cout << 1e15 - ans[now].first << endl;
  }
}

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

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

const long long MOD = 1000000007;

int main(){
  long double a,b,d,t,n;
  int ans = 0;
  cin >> n >> d;
    rep(i,n){
      cin >> a >> b;
      t = sqrt(a*a+b*b);
      if(t<=d) ans++;
    }
  cout << ans << endl; 
    
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
 
class Segment_Tree{
	private:
	int n;
	vl date;
	ll Rec(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return date[k];
		int m=(l+r)/2;
		return Rec(a,b,k*2+1,l,m)+Rec(a,b,k*2+2,m,r);
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vl(2*n-1);
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]+=x;
		while(k>0){
			k=(k-1)/2;
			date[k]=date[k*2+1]+date[k*2+2];
		}
	}
	ll Query(int a,int b){
		return Rec(a,b,0,0,n);
	}
	int Open(int k){
		return date[k+n-1];
	}
};
 
ll n,N;
vl a;
 
ll f(int x){
	vl b(n+1);
	for(int i=1;i<=n;i++) b[i]=(a[i-1]>=x?1:-1);
	for(int i=1;i<=n;i++) b[i]+=b[i-1];
	Segment_Tree st(3*n);
	st.Update(n,1);
	ll t=0;
	for(int i=1;i<=n;i++){
		ll tmp=st.Query(0,b[i]+n+1);
		t+=tmp;
		st.Update(b[i]+n,1);
	}
	return t;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	a=vl(n);
	N=n*(n+1)/2;
	for(int i=0;i<n;i++) cin>>a[i];
	ll l=0,r=inf;
	while(r-l>1){
		ll m=(l+r)/2;
		if(f(m)>=(N+1)/2) l=m;
		else r=m;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 9992
num=list(map(int,input().split()))

if num[0]>num[1]:
    x=num[0]
    y=num[1]
elif num[0]<num[1]:
    x=num[1]
    y=num[0]
else:
    x=num[1]
    y=num[0]
    b=num[1]

a=x%y

while a!=0:
    b=a
    a=y%a
    y=b

print(b)



Measured memory_bytes: 5596
import numpy as np
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, W = map(int, input().split())
WV = [[int(x) for x in input().split()] for _ in range(N)]

INF = 10 ** 12
dp = [np.ones(10 ** 5 + 10, dtype=np.int64)*INF for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    w, v = WV[i]
    dp[i + 1][v:] = np.minimum(dp[i][v:], dp[i][:-v] + w)
    dp[i + 1][:v] = np.minimum(dp[i][:v], dp[i + 1][:v])

    # print(dp[i+1][:20])

r = dp[N]
ans = np.where(r <= W)[0].max()

print(ans)


Measured memory_bytes: 92908
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray(); 
        //int a=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        
        Console.WriteLine(Math.Max(input[0]*input[1],input[2]*input[3]));
        Console.ReadLine();
    }
}


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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int x = x2 - x1, y = y2 - y1;
	swap(x, y), x *= -1;
	x2 += x, y2 += y; cout << x2 << " " << y2 << " ";
	swap(x, y), x *= -1;
	x2 += x, y2 += y; cout << x2 << " " << y2 << "\n";
	
	return 0;
}


Measured memory_bytes: 3592
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N, W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]

wv.sort()

ans = 0
dp = np.zeros(W + 1, dtype=int)

for w, v in wv:
    np.maximum(dp[:-w] + v, dp[w:], out = dp[w:])

ans = dp[-1]
print(ans)



Measured memory_bytes: 14000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=300005;

int n,last,len;
ll ans;
int a[N],mx[N];

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=0;i<20;i++){
		last=0;
		for (j=1;j<=n;j++)
			if ((a[j]>>i)&1){
				mx[j]=max(mx[j],last);
				last=j;
			}
	}
	last=0;
	for (i=1;i<=n;i++){
		last=max(last,mx[i]);
		len=i-last;
		ans+=1ll*len;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int n,A,B,C;
int l[8];
int ans = 1e9;

void dfs(int depth, int a, int b, int c, int cost){
    if(depth == n) {
        if(a && b && c) ans = min(ans,abs(a-A) + abs(b-B) + abs(c - C) + cost);
    }
    else {
        dfs(depth + 1, a + l[depth], b, c, cost + (a ? 10 : 0));
        dfs(depth + 1, a, b + l[depth], c, cost + (b ? 10 : 0));
        dfs(depth + 1, a, b, c + l[depth], cost + (c ? 10 : 0));
        dfs(depth + 1, a, b, c, cost);
    }
}


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


    cin >> n >> A >> B >> C;    

    rep(i,n) cin >> l[i];
    dfs(0,0,0,0,0);


    cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll a,b;
        cin>>a>>b;
        cout<<max(0ll, a-2*b)<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k, a[100010], b[100010];
int ans;

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++) {
		bool bl = true;
		for (int j = 0; j < 30; j++)if (!(k&(1 << j)) && a[i] & (1 << j))bl = false;
		if (bl)ans += b[i];
	}
	for (int i = 0; i < 30; i++) {
		if (!(k&(1 << i)))continue;
		int x = k - (1 << i);
		for (int j = i - 1; j >= 0; j--)if (!(k&(1 << j)))x += (1 << j);
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			bool bl = true;
			for (int l = 0; l < 30; l++)if (!(x&(1 << l)) && a[j] & (1 << l))bl = false;
			if (bl)cnt += b[j];
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

int main(){
 	
	vector<char> x(3);
	cin >>x[0] >> x[1] >> x[2];
	sort(x.begin(), x.end());
  	if(x[0] =='a' && x[1] =='b' && x[2] =='c' )
  		cout << "Yes" << endl;
	else
      	cout << "No" << endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int n, W;
int weight[110], value[110];

int dp[110][10010];

int main() {
   cin >> n >> W;
   rep (i, n) cin >> value[i] >> weight[i];

   rep (i, W+1) dp[0][W] = 0;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j <= W; j++) {
         if (j >= weight[i]) {
            // dp[次の状態][今の重さ] = max(dp[1つ前の状態][今の重さ], dp[1つ前の状態][今の重さ-荷物の重さ]);
            // max(前の状態, 前の状態+value[i]);
            dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i]);
         } else {
            dp[i+1][j] = dp[i][j];
         }
      }
   }

   cout << dp[n][W] << endl;

   return 0;
}


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

int main(){
  int N,L;
  cin >> N >>L;
  string S = "";
  string d = "";
  vector <string> y (N,"");
  for (int i=0;i<N;i++){
    cin >> d;
    y.at(i) = d;
  }
  
  sort (y.begin(),y.end());
  
  for(int i=0;i<N;i++){
    S += y.at(i);
  }
  
  cout << S <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

ll powmod(ll x, ll i) {
  ll res = 1;
  REP(j,i) {
    res *= x;
    res %= MOD;
  }
  return res;
}

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  REP(i,n) cin>>a[i];
  vector<ll> sum(1<<20);
  vector<ll> oldsum(1<<20, 1);
  vector<ll> cnt(1<<20);
  vector<ll> dp(n);
  int x = 0;
  int zeros = 0;
  vector<pair<int, int>> v;
  REP(i,n) {
    x ^= a[i];
    if (x == 0) {
      for (auto p : v) {
        int j, y;
        tie(j, y) = p;
        oldsum[y] = dp[j];
        sum[y] += dp[j];
        sum[y] %= MOD;
        cnt[y] = zeros;
      }
      v.clear();
      ++zeros;
    } else {
      dp[i] = (zeros - cnt[x]) * sum[x];
      dp[i] %= MOD;
      dp[i] += oldsum[x];
      dp[i] %= MOD;
      v.emplace_back(i, x);
    }
  }
  ll res;
  if (x == 0) {
    res = powmod(2, zeros-1);
    FOR(i,1,1<<20) {
      res += sum[i];
      res %= MOD;
    }
  } else {
    res = dp.back();
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 30720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#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 each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll v[n];
        rep(i, n){
            cin >> v[i];
        }
        sort(v, v + n, greater<ll>());
        cnt = -1;
        a = 0;
        ll line[2];
        each(i, v){
            if(i == cnt){
                line[a] = i;
                a++;
                cnt = -1;
                if(a == 2){
                    print(line[0] * line[1]);
                    return 0;
                }
            }else{
                cnt = i;
            }
        }
        print(0);
    }
}


Measured memory_bytes: 1024
N, M = map(int, input().split())

lst = [list(map(int, input().split())) for _ in range(M)]

lower = 1
upper = N
for l, u in lst:
    if l > lower:
        lower = l

    if u < upper:
        upper = u

    if upper < lower:
        print(0)
        exit()

print(upper - lower + 1)


Measured memory_bytes: 27336
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n, cnt;
char ans[200];


void f(const set<int> &balance) {
	string res;
	rep(i, 2 * n) {
		if (balance.count(i) || ans[i] != 0)continue;
		cout << "?";
		for (int x : balance)cout << ' ' << x + 1;
		cout << ' ' << i + 1 << endl;
		cin >> res;
		if (res == "Red")ans[i] = 'R';
		else ans[i] = 'B';
	}
}


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

	cin >> n;
	
	string res;
	cout << '?';
	rep(i, n)cout << ' ' << i + 1;
	cout << endl;

	cin >> res;
	int lb = 0, ub = n;
	while (ub-lb>1) {
		int mid = (lb + ub) / 2;
		cout << '?';
		rep(i, n) {
			if (i < mid)cout << ' ' << i + n + 1;
			else cout << ' ' << i + 1;
		}
		cout << endl;
		string r;
		cin >> r;
		if (res == r)lb = mid;
		else ub = mid;
	}

	set<int> balance;
	rep(i, n) {
		if (i == lb)continue;
		if (i < lb)balance.insert(i + n);
		else balance.insert(i);
	}
	f(balance);

	set<int> balance2;
	int nr = 0, nb = 0;
	rep(i, 2 * n) {
		if (ans[i] == 'R' && nr < (n - 1) / 2) {
			balance2.insert(i);
			nr++;
		}
		else if (ans[i] == 'B' && nb < (n - 1) / 2) {
			balance2.insert(i);
			nb++;
		}
	}
	f(balance2);


	cout << "! ";
	rep(i, 2 * n)cout << ans[i];
	cout << endl;


	return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n, a, in = INF, ans = 0;
   cin >> n;
   vector<int> x;

   rep(i, n)
   {
      cin >> a;
      x.push_back(a);
      if (in > x[i])
      {
         ++ans;
         in = x[i];
      }
   }
   cout << ans << '\n';
}

Measured memory_bytes: 2420
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x[100002],a,sum,mx,i;
	scanf("%d",&n);
	for(i=0;i<=100001;i++)	x[i]=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&a);
		x[a]++;
	}
	mx=x[0]+x[1];
	for(i=1;i<=100000;i++)	{
		sum=x[i-1]+x[i]+x[i+1];
		mx=max(mx,sum);
	}
    printf("%d\n",mx);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define FOR(i,a,b) for (int i=a;i<b;i++)

bool isPrime[55560];
int res[5];
vi primes;
vi valid;
void sieve(){
    memset(isPrime,1,sizeof(isPrime));
    memset(res,0,sizeof(res));
    isPrime[0]=isPrime[1]=0;
    for (int i=2;i<55556;i++){
        if (isPrime[i]){
            for (int j=2*i;j<55556;j+=i){
                isPrime[j] = 0;
            }
            primes.push_back(i);
            res[i%5]++;
            if (i%5==4) valid.push_back(i);
        }
    }
}
int main(){
    sieve();
    // FOR(i,0,5) cout<<res[i]<<' ';
    // puts("");
    int N;
    cin>>N;
    FOR(i,0,N) cout<<valid[i]<<(i==N-1 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,a,b,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum<<endl;
    return 0;
}

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

int main()
{
    int N,M,X;
    cin>>N>>M>>X;

    vector<int> C(N),count(M,0);
    vector<vector<int>> A(N,vector<int>(M));

    for(int i = 0; i<N; i++)
    {
        cin>>C[i];
        for(int j = 0; j<M; j++)
        {
            cin>>A[i][j];
            count[j] += A[i][j];
        }
    }

    for(int i = 0; i<M; i++)
    {
        if(count[i]<X)
        {
            cout<<-1<<endl;
            return 0;
        }
    }

    int ans = 10000000;
    for(int bit = 0; bit<(1<<N); bit++)
    {
        int sum = 0;
        vector<int> algo(M,0);
        bool ok = true;
        for(int i = 0; i<N; i++)
        {
            if(bit & (1<<i))
            {
                sum += C[i];
                for(int j = 0; j<M; j++)
                {
                    algo[j] += A[i][j];
                }
            }
        }
        for(int k = 0; k<M; k++)
        {
            if(algo[k]<X)ok = false;
        }
        
        if(ok)
        {
            if(ans > sum)ans = sum;
        }
    }
    cout << ans <<endl;
    return 0;
}

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

char S[ 100 ];
char T[ 100 ];

bool bChk( const char *A, const char *B )
{
int i;
char C;

	i = 0;
	while( ( C = B[ i ] ) != '\0' )
	{
		if( A[ i ] != '?' && A[ i ] != C ) return false;

		i++;
	}

	return true;
}

void Conv( string &A, const char *B, int iPos )
{
int i;
char C;

	i = 0;
	while( ( C = A[ i ] ) != '\0' )
	{
		if( C == '?' ) A[ i ] = 'a';

		i++;
	}

	i = 0;
	while( ( C = B[ i ] ) != '\0' )
	{
		A[ i + iPos ] = C;
		i++;
	}
}

int main()
{
int i;
int iEnd;
char C;
string sChk;
string X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;
	cin >> T;

	iEnd = strlen( S ) - strlen( T );
	if( iEnd < 0 )
	{
		cout << "UNRESTORABLE" << endl;

		return 0;
	}

	X = "";
	for( i = 0; i <= iEnd; i++ )
	{
		if( ! bChk( S + i, T ) ) continue;

		sChk = S;
		Conv( sChk, T, i );
		if( X == "" || X > sChk ) X = sChk;
	}

	if( X == "" )
		cout << "UNRESTORABLE" << endl;
	else
		cout << X << endl;

	return 0;
}




Measured memory_bytes: 256
n = int(input())

#flag = True

cnt = 0

for i in range(n):
    a,b = map(int,input().split())
    if a == b:# and flag == True:
        cnt +=1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        #flag = False
        cnt = 0
print("No")

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d;
  cin>>a>>b;
  c=0;
  d=1;
  for(int i=0;i<a;i++){
    int x;
    cin>>x;
    c+=x;
    if(c<=b){
      d++;
    }
    else{
      break;
    }
  }
  cout<<d<<endl;
}

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

#define MAX_N (200000)
#define MAX_Q (200000)
#define SIZE_BUF (30)

using namespace std;

int binary_search(int N, int Q, const char *cs, const char *ts, const char *ds,
                  int x) {
  int le = -1, ri = N - 1;
  while (ri > le + 1) {
    const int m = (le + ri) / 2;
    int pos = m;
    for (int q = 0; q < Q; q++) {
      const char t = ts[q], d = ds[q];
      if (t == cs[pos]) {
        if (d == 'L') {
          pos--;
        } else {
          pos++;
        }
        if (pos < 0) {
          pos = -1;
          break;
        }
        if (pos >= N) {
          pos = N;
          break;
        }
      }
    }
    if (pos >= x) {
      ri = m;
    } else {
      le = m;
    }
    if (ri == le + 1 && pos < x) {
      ri = N;
    }
  }
  return ri;
}

int main(int argc, char *argv[]) {
  // read inputs
  int N, Q;
  char cs[MAX_N + 1], ts[MAX_Q], ds[MAX_Q], buf[SIZE_BUF];
  scanf("%d %d", &N, &Q);
  fgets(buf, SIZE_BUF, stdin);
  scanf("%s", cs);
  fgets(buf, SIZE_BUF, stdin);
  for (int q = 0; q < Q; q++) {
    ts[q] = fgetc(stdin);
    fgetc(stdin);
    ds[q] = fgetc(stdin);
    fgets(buf, SIZE_BUF, stdin);
  }

  // solve binary
  const int l = binary_search(N, Q, cs, ts, ds, 0),
            r = binary_search(N, Q, cs, ts, ds, N);
  // printf("l = %d, r = %d\n", l, r);
  printf("%d\n", r - l);

  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    string s[n];
    rep(i, n) { cin >> s[i]; }
    int count[26] = {};
    rep(i, 26) { count[i] = pow(10, 9); }

    rep(i, n) {
        int count_temp[26] = {};
        rep(l0, s[i].size()) { count_temp[s[i][l0] - 'a'] += 1; }

        rep(l0, 26) {
            count[l0] = min(count[l0], count_temp[l0]);
            if (count[l0] == pow(10, 9)) {
                count[l0] = 0;
            }
        }
    }

    string ans = "";
    rep(l0, 26) {
        rep(l1, count[l0]) { ans += char('a' + l0); }
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include<stdio.h>

long long search(long long min, long long max, int* w, int k, int n)
{
	int j;
	bool flag = 0;
	long long mid, sum;
	mid = (min + max) / 2;
	while (min < max)
	{
		flag = 0;
		sum = j = 0;
		mid = (min + max) / 2;
		for (int i = 0; i < k && j < n; i++)
		{
			sum = 0;
			while (j < n && mid >= sum + w[j] )
			{
				sum += w[j];
				j++;
			}
		}
		if (j == n)
			max = mid;
		else
			min = mid + 1;
	}
	return min;
}

int main()
{
	int n, k, w[100000] = { };
	long long min = 0, max = 0;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", w + i);
		if (w[i] > min)
			min = w[i];
		max += w[i];
	}
	if (min < max / k)
		min = max / k;
	printf("%ld\n", search(min, max, w, k, n));

	return 0;
}


Measured memory_bytes: 3148
#include <stdio.h>
#include<string.h>

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    char str[1500];
    
    

    scanf("%s",str);
    int len=strlen(str);

    if(str[len-1]=='s'){
        str[len]='e';
        str[len+1]='s';

    for(int i=0;i<len+2;i++){
          printf("%c",str[i]);
      }

    }else{
        str[len]='s';

        for(int i=0;i<len+1;i++){
          printf("%c",str[i]);
      }
    }
    
      printf("\n");
      
      
   


   
    
    return 0;
}

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

using namespace std;

int main(){
  int n,a, c;
  while((c=getchar_unlocked()-'0')>=0) n*=10,n+=c;
  
  unordered_set<int> appeared;
  for (int i = 0; i < n; i++){
    a=0;
    while((c=getchar_unlocked()-'0')>=0) a*=10,a+=c;
    if (appeared.find(a) != appeared.end()){
      cout << "NO";
      return 0;
    }
    appeared.emplace(a);
  }
  cout << "YES";
  return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
#define INF (1ll<<60)
typedef pair<li, li> PI;

li h[100100];
li dp[100100];

inline li cost(li from, li to) {
	return abs(h[from] - h[to]);
}

int main(void)
{
	li n, k;
	cin >> n >> k;
	rep(i, n) {
		cin >> h[i];
	}
	dp[0] = 0;
	for (li i = 1; i < n; ++i) {
		dp[i] = INF;
		for (li j = 1; j <= k; ++j) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + cost(i - j, i));
			}
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792