akhauriyash/Code-Regression huggingface dataset:
/**    Name        : Sourav Roy
       Institution : Hajee Mohammad Danesh Science & Technology University  (H S T U) **/


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff                          first
#define ss                          second
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define maX(a,b)                    ( (a) > (b) ? (a) : (b))
#define miN(a,b)                    ( (a) < (b) ? (a) : (b))
#define FasterIO                    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define yes                         cout << "YES" << endl
#define no                          cout << "NO" << endl
#define endl                        "\n"
#define int                         long long
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{
    FasterIO;
    int i,d,x,mn;
    string s;
    cin >> d >> s;
    if(s.length()>d)
    {
        for(i=0; i<d; i++)
            cout << s[i];
        cout << "..." << endl;
    }
    else
        cout << s << endl;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
//const int INF = 1001001001;
//const int INF = 1073741823;
const int INF = numeric_limits<int>::max();


template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    WeightedGraph<int> g(N*3);

    REP(i,M){
        int u,v; cin >> u >> v;
        u--; v--;
        //g[u].eb(v,1);
        g[u*3].eb(v*3+1,1);
        g[u*3+1].eb(v*3+2,1);
        g[u*3+2].eb(v*3,1);
    }
    int S,T; cin >> S >> T;
    S--; T--;
    auto ans = dijkstra(g,S*3);
    if(ans[T*3] == INF) cout << -1 << endl;
    else cout << ans[T*3]/3 << endl;



}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n, x;
    cin >> n >> x;
    vll l(n);
    REP(i, n) {
      cin >> l[i];
    }

    ll dist = 0;
    ll count = 1;
    REP(i, n) {
      dist += l[i];
      if (dist > x) {
        COUT(count);
        return;
      }
      count++;
    }
    COUT(count);
}

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

/*
3 6
3 4 5
*/


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

int n,k,x,pos;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i=1;i<=n;i++){
		cin >> x;
		if (x==1){
			pos=i;
		}
	}
	int ans=INT_MAX;
	for (int i=max(1,pos-k+1);i<=pos;i++){
		int now=(i-1+k-1-1)/(k-1)+1;
		if (i+k-1<n){
			now+=(n-(i+k-1)+k-1-1)/(k-1);
		}
		ans=min(ans,now);
	}
	cout << ans << "\n";
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n); for (auto &item : p)cin >> item;

    int ret = 0;
    int m = INT_MAX;
    for (int i = 0; i < n; ++i) {
        m = min(m, p[i]);
        if (p[i] <= m) { ++ret; continue; }
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    int f=(n/x);
    if(n%x!=0)
    f++;
    int res=(f*t);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3608
s = list(input())
ans = 0
if len(s)%2==0:
    for i in range(len(s)//2):
        if s[2*i]=="L" or s[2*i+1]=="R":
            ans += 1
            break
        else:
            continue
elif len(s)%2!=0:
    for i in range(len(s)//2):
        if s[2*i]=="L":
            ans += 1
            break
        elif s[2*i+1]=="R":
            ans += 1
            break
        else:
            continue
    if s[-1]=="L":
        ans += 1

if ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int) Math.sqrt(n);
		int ans = 1;
		int max = 0;
		for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		}
		
		System.out.println(ans);
	}
}

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

int main() {
    long long n,m;
    cin >> n >> m;
    long long ans;
    if(2*n==m){
        ans=n;
    }
    else if(2*n>m){
        ans=m/2;
    }
    else{
        ans=(m+2*n)/4;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())

e = [set() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a].add(b)
    e[b].add(a)

dq = deque()
dq.append(0)

p = [None] * n
p[0] = 0

is_bipartite = True
while dq:
    v = dq.popleft()
    for u in e[v]:
        if p[u] is None:
            p[u] = 1 ^ p[v]
            dq.append(u)
        elif p[u] == p[v]:
            is_bipartite = False
            break
        else:
            # p[u] == p[v] ^ 1
            pass

if is_bipartite:
    # 同じ色の頂点には辺を張らない
    sp = sum(p)
    print(sp * (n - sp) - m)
else:
    # 全ての頂点間に辺を張る
    print(n * (n - 1) // 2 - m)


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

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

int main() {
	string a, b;
	
	while (cin >> a >> b) {
		if (a == "0") break;
		
		int hit = 0, blow = 0;
		
		for_(i,0,4) if (a.find(b[i]) != a.npos) ++blow;
		for_(i,0,4) if (a[i] == b[i]) { ++hit; --blow; }
		
		cout << hit << " " << blow << endl;
	}
}

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

AC = 0
WA = 0
TLE = 0
RE = 0

Z = 0

for i in range(N):
    Z = input()
    if Z == 'AC':
        AC += 1
    elif Z == 'WA':
        WA += 1
    elif Z == 'TLE':
        TLE += 1
    elif Z == 'RE':
        RE += 1
    else:
        continue

print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

Measured memory_bytes: 9096
S = input()


if S[1] == "S":
    if S[0] == "R" or S[2] == "R":
        print(1)
    else:
        print(0)
else:
    if S[0] == "R" and S[2] == "R":
        print(3)
    elif S[0] == "R" or S[2] == "R":
        print(2)
    else:
        print(1)


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

vector<ll> parent, size, depth;
void init(ll n){
  for(ll i = 0; i < n; i++){
    parent.push_back(i);
    depth.push_back(0);
    size.push_back(1);
  }
}

ll root(ll x){
  if(parent[x] == x)return x;
  else return root(parent[x]);
}

void unite(ll x, ll y){
  x = root(x);
  y = root(y);
  if(x == y) return; //一緒の連結成分であった時
  if(depth[x] < depth[y]){
    parent[x] = y; //yの方が深いので，xの親をyに変更
    size[y] += size[x];
  }else{
    parent[y] = x;
    size[x] += size[y];
    if(depth[x] == depth[y])depth[x]++; //xとyの深さが同じ時は，xの下にyを付け加えることに
  }
}
ll treesize(ll x){
  return size[root(x)];
}

//Union-find部分ここまで


int n, m, k;
int main(){
	cin >> n >> m >> k;
	vector<ll>a(m), b(m);
	vector<ll>c(k), d(k);
	vector<ll>block[n+1];
	vector<ll>tomodachi[n+1];
	rep(i,0,m){
		cin >> a[i] >> b[i];
		tomodachi[a[i]].push_back(b[i]);
		tomodachi[b[i]].push_back(a[i]);
	}
	rep(i,0,k){
		cin >> c[i] >> d[i];
		block[c[i]].push_back(d[i]);
		block[d[i]].push_back(c[i]);
	}
	init(n);
	rep(i,0,m){
		// cout << a[i] << " " << b[i] << endl;
		unite(a[i], b[i]);
	}
	rep(i, 1, n+1){
		int ans = treesize(i);
		for(auto& j : block[i]){
			if(root(i) == root(j)) ans--;
		}
		for(auto& j : tomodachi[i]){
			if(root(i) == root(j)) ans--;
		}
		cout << ans -1 << " ";
	}
}

Measured memory_bytes: 18548
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);

  rep (i, n) cin >> v[i];
  rep (i, n) cin >> c[i];

  int ans = 0;
  rep (i, n) {
    if (v[i] > c[i]) ans += v[i] - c[i];
  }
  P(ans);

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll mod = 998244353;
    int n, s;
    cin >> n >> s;
    vector<int> arr(n, 0);
    for(int& val: arr)
        cin >> val;
    vector<ll> dp(s+1, 0);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = s; j >= 0; j--) {
            if (dp[j] > 0 && j+arr[i] <= s) {
                dp[j+arr[i]] += dp[j];
                dp[j+arr[i]] %= mod;
            }
        }
        if (arr[i] <= s) { // multiply first element to extend LHS
            dp[arr[i]] += i+1;
        }
        ans += dp[s]; // extend right each time
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//modint 2^61-1
class RHint {
private:
	const ull MASK30 = (1UL << 30) - 1;
	const ull MASK31 = (1UL << 31) - 1;
	const ull RMOD = (1UL << 61) - 1;
	inline ull Mul(ull a, ull b) {
		ull au = a >> 31;
		ull ad = a & MASK31;
		ull bu = b >> 31;
		ull bd = b & MASK31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30;
		ull midd = mid & MASK30;
		return (au * bu * 2 + midu + (midd << 31) + ad * bd);
	}
	//mod 2^61-1を計算する関数
	inline ull CalcMod(ull a) {
		a = (a & RMOD) + (a >> 61);
		if (a > RMOD) a -= RMOD;
		return a;
	}
public:
	ull val;

	RHint() { val = 0; };
	RHint(ull a) {
		val = CalcMod(a);
	}

	inline RHint operator+(const RHint& r) {
		return RHint(CalcMod(this->val + r.val));
	}
	inline RHint operator*(const RHint& r) {
		return RHint(Mul(this->val, r.val));
	}
	inline RHint& operator=(const RHint& r) {
		val = r.val;
		return *this;
	}
	inline RHint& operator+=(const RHint& r) {
		*this = *this + r;
		return *this;
	}
	inline RHint& operator*=(const RHint& r) {
		*this = *this * r;
		return *this;
	}
};
inline bool operator==(const RHint& l,const RHint& r) {
	return l.val == r.val;
}
inline bool operator!=(const RHint& l, const RHint& r) {
	return l.val != r.val;
}
class RollingHash {
private:
	const ull RMOD = (1UL << 61) - 1;
	const ull PV = RMOD * 3;
	RHint base;
public:
	vector<RHint> hash, pow;
	RollingHash(string s,ull b) {
		int l = s.size();
		base = RHint(b);
		hash = vector<RHint>(l + 1, 0);
		pow = vector<RHint>(l + 1, 1);
		for (int i = 0; i < l; i++) {
			hash[i + 1] = (hash[i] + RHint(s[i])) * base;
			pow[i + 1] = pow[i] * base;
		}
	}
	RHint get(int l, int r) {
		return RHint(hash[r].val + PV - (hash[l] * pow[r - l]).val);
	}
	RHint connect(RHint h1, RHint h2, int h2l) {
		return  (h1 * pow[h2l] + h2);
	}
};

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

	random_device r;
	int rnd = r();
	string s, t;
	cin >> s >> t;
	RollingHash S(s, rnd), T(t, rnd);
	if (s.size() < t.size())return 0;
	for (int i = 0; i <= s.size() - t.size(); i++) {
		if (S.get(i, i + t.size()) == T.get(0, t.size())) printf("%d\n", i);
	}
}


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

int main(){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if(x+r <= w && x-r >= 0){
    if(y+r <= h && y-r>=0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

const int MOD = 1e9+7;

void solve()
{
	string S;
	cin >> S;
	vector<long> dp(4);
	dp[0] = 1;
	for (char c : S)
	{
		vector<long> nx = dp;
		(nx[0] *= (c == '?' ? 3 : 1)) %= MOD;
		if (c == 'A' || c == '?')
		{
			(nx[1] += dp[0] + (c == '?' ? dp[1]*2 : 0)) %= MOD;
		}
		if (c == 'B' || c == '?')
		{
			(nx[2] += dp[1] + (c == '?' ? dp[2]*2 : 0)) %= MOD;
		}
		if (c == 'C' || c == '?')
		{
			(nx[3] += dp[2] + (c == '?' ? dp[3]*2 : 0)) %= MOD;
		}
		dp = nx;
		//cout << dp[0] << ' ' << dp[1] << ' ' << dp[2] << ' ' << dp[3] << endl;
	}
	cout << dp[3] << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main() {
  int H,N;
  cin >> H >> N;
  long long sum=0;
  
  vector<int> a(N);
  
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum +=a[i];
   // cout << sum << endl;
  }
 // cout << sum << endl;
  if(sum<H){
    cout << "No" << endl;
  }
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int arr[55]={0};
    int n=0;
    int k=0;
    scanf("%d %d", &n,&k);
    int sum=0;
    for(int i=0;i<n;i++){
        int a=0;
        scanf("%d", &a);
        arr[i]=a;
        sum+=a;
    }
    sort(&arr[0], &arr[n]);
    for(int i=0;i<n-k;i++){
        sum-=arr[i];
    }
    printf("%d", sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    string s;
    cin>>s;
    if (s.at(0)==s.at(1) || s.at(1)==s.at(2) || s.at(0)==s.at(2)) {
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int a[9],b[9];
double sum;
int win;
int pnt;
bool used[9];
void DFS(int len){
	if(len==9){
		sum+=1;
		if(pnt>85){
			win++;
		}
		return;
	}
	for(int i=0;i<9;i++){
		if(used[i]==false){
			if(a[len]<b[i]){
				pnt+=a[len]+b[i];
			}
			used[i]=true;
			DFS(len+1);
			if(a[len]<b[i]){
				pnt-=a[len]+b[i];
			}
			used[i]=false;
		}
	}
}
int main(){
	int t;
	cin>>t;
	for(int u=0;u<t;u++){
	sum=0,win=0,pnt=0;
	for(int i=0;i<9;i++)cin>>a[i];
	for(int i=0;i<9;i++){
		cin>>b[i];
		used[i]=false;
	}
	DFS(0);
	if(win==0)cout<<"1.0 0.0"<<endl;
	else{
	double ans=win/sum;
	cout<<fixed<<setprecision(10)<<1-ans<<" ";
	cout<<fixed<<setprecision(10)<<ans<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(ll)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    vector<pair<ll,ll>> p(m);
    vector<vector<ll>> x(n+10);
    rep(i,m){
        ll a,b;cin>>a>>b;
        p[i]={a,b};
        x[a-1].push_back(b);
    }
    rep(i,n) sort(x[i].begin(),x[i].end());
    rep(i,m){
        ll a=p[i].first,b=p[i].second;
        string P=to_string(a);
        while(P.size()<6) P="0"+P;
        auto itr= lower_bound(x[a-1].begin(),x[a-1].end(),b);
        ll k=itr-x[a-1].begin();
        k++;
        string Y=to_string(k);
        while(Y.size()<6) Y="0"+Y;
        cout<<P<<Y<<endl;
    }
}


Measured memory_bytes: 8576
#14:14
n = int(input())
work = []
for _ in range(n):
  work.append(list(map(int,input().split())))
work.sort(key= lambda x:x[1])
a = 0
b = 0
#print(work)
for i in range(n):
  a += work[i][0]
  b = work[i][1]
  #print(a,b)
  if a > b:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 53720
import fractions
from functools import reduce

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

xi.append(X)
xi.sort()

diffs = []
for i in range(N):
    diffs.append(xi[i+1] - xi[i])

ans = reduce(fractions.gcd, diffs)
print(ans)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


int M, N, Q;
vector<int> a_(50, 0);
vector<int> b_(50, 0);
vector<int> c_(50, 0);
vector<ll> d_(50, 0);

ll maxScore(vector<int> A) {
	ll score = 0;
	for (int i = 0; i < Q; i++) {
		if (A[b_[i] - 1] - A[a_[i] - 1] == c_[i]) {
			score += d_[i];
		}
	}
	return(score);
}

ll loop(vector<int> A, int depth) {
	ll m = 0;
	for (int i = ((depth == 0) ? 1 : A[depth - 1]); i <= M; i++) {
		A[depth] = i;
		ll x = (depth == N - 1) ? maxScore(A) : loop(A, depth + 1);
		if (m < x) m = x;
	}
	return(m);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> a_[i] >> b_[i] >> c_[i] >> d_[i];
	}
	vector<int> A(N,0);
	cout << loop(A, 0) << endl;

}


Measured memory_bytes: 3632
# include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m],sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>ar[i];
        sum+=ar[i];
    }
    if(sum<=n)
    {
        cout<<n-sum<<endl;
    }
    else
        cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 3628
r=range
d=[0]*13
d[0]=1
for s in input():
	e=[0]*13
	for j in r(13):
		for k in([s],r(10))[s>'9']:e[(j*10+int(k))%13]+=d[j]
	d=[e%(10**9+7)for e in e]
print(d[5])

Measured memory_bytes: 43756
n = int(input())
A = list(map(int, input().split()))
array_sum_square = sum(A)**2
individual_square_sum = 0
for i in range(0, n, 1):
    individual_square_sum += A[i]**2
print((array_sum_square - individual_square_sum) // 2 % (7 + 10 ** 9))


Measured memory_bytes: 31540
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

int imos[200000];
int mae[200000];
int gyaku[200000];
void solve() {
    int n;
    cin >> n;
    pair<int, int> ans = mp(0, 0);
    vector<pair<int, int>> inputs;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        imos[a]++;
        imos[b]--;
        mae[b]++;
        gyaku[a]++;
        inputs.push_back(mp(a, b));
    }
    REP(i, 150000) {
        imos[i + 1] += imos[i];
        mae[i + 1] += mae[i];
        ans.second = max(ans.second, imos[i]);
    }
    for (int i = 120000; i >= 0; --i) {
        gyaku[i] += gyaku[i + 1];
    }
    REP(i, n) {
        ans.first = max(ans.first, n - mae[inputs[i].first] - gyaku[inputs[i].second]);
    }
    cout << ans.first << " " << ans.second << endl;
}

#undef int
int main() {
    init();
    solve();
}



Measured memory_bytes: 9436
#include<cstdio>

int main()
{
	int n; scanf("%d", &n);
	
	if(n % 2 == 0 or n % 5 == 0) printf("-1\n");
	else {
		int now = 7, i = 1;
		
		for(i = 1; now % n != 0; i++){
			now = (now * 10) % n + 7;
		}
		printf("%d\n", i);
	}
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int sum = 0;
  REP(i, N) sum += A[i];

  vector<int> dd;
  for(int i = 1; i * i <= sum; ++i) {
    if(sum % i == 0) {
      dd.push_back(i);
      if(sum / i != i) dd.push_back(sum / i);
    }
  }

  sort(dd.rbegin(), dd.rend());
  for(int d : dd) {
    vector<int> res(N);
    REP(i, N) res[i] = A[i] % d;
    sort(res.rbegin(), res.rend());

    int tmpsum = 0;
    REP(i, N) tmpsum += res[i];

    REP(i, N) {
      if(tmpsum == 0) break;
      if(tmpsum > 0) {
        res[i] -= d;
        tmpsum -= d;
      }
    }

    int ktmp = 0;
    REP(i, N) ktmp += abs(res[i]);
    ktmp /= 2;

    if(ktmp <= K) {
      cout << d << endl;
      break;
    }
  }
  return 0;
}



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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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; }

int main() {
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(pair<string,int>p:mp) mx = max(mx,p.second);
    for(pair<string,int>p:mp) {
        if(mx!=p.second) continue;
        cout << p.first << endl;
    }
}

Measured memory_bytes: 25216
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  int res = inf;
  rep(i, 0, t.size() + 1){
    string u = s + t.substr(i, t.size() - i);
    if (u.substr(0, n) == s && u.substr(u.size() - n, n) == t){
      chmin(res, u.size());
    }
  }
  cout << res << endl;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()


row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
            
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = '')
        print()


Measured memory_bytes: 4468
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())


num_lists = make_divisors(N)
ans = 10**12
for num in num_lists:
  x = N//num
  y = num
  ans = min(x-1+y-1,ans)

print(ans)


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        int l, r;
        cin >> l >> r;
        sum += r-l+1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    int cnt=0;
    for(auto c:s){
        cnt=cnt+c-'0';
    }
    if(cnt%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{
    int h, w, k; cin >> h >> w >> k;
    char c[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++) cin >> c[i][j];
    }

    char dummy_c[h][w];
    int ans = 0;
    for(int i=0; i<1<<h; i++){
        for(int j=0; j<1<<w; j++){
            for(int i1=0; i1<h; i1++){
                for(int j1=0; j1<w; j1++) dummy_c[i1][j1] = c[i1][j1];
            }
            for(int i2=0; i2<h; i2++){
                if(i>>i2&1){
                    for(int j2=0; j2<w; j2++) dummy_c[i2][j2] = '.';
                }
            }
            for(int j3=0; j3<w; j3++){
                if(j>>j3&1){
                    for(int i3=0; i3<h; i3++) dummy_c[i3][j3] = '.';
                }
            }
            int cnt = 0;
            for(int i4=0; i4<h; i4++){
                for(int j4=0; j4<w; j4++){
                    if(dummy_c[i4][j4] == '#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }

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

Measured memory_bytes: 3588
def matrix(X):
    m = [[0 for i in range(len(X))] for j in range(len(X))]

    for l in range(2, len(X)+1):
        for i in range(0, len(X)-l+1):
            j = i + l - 1
            m[i][j] = min(m[i][k] + m[k+1][j] + X[i][0]*X[k][1]*X[j][1] for k in range(i, j))

    print m[0][len(X)-1]

n = input()
X = []

for i in range(n):
    X.append(map(int, raw_input().split()))

matrix(X)

Measured memory_bytes: 6520
n = int(input())
x = tuple(map(int,input().split()))

mod = 10**9 + 7
mul_l = [1] * (n+1)
mul_r = [1] * (n+1)
for i in range(1,n+1):
    mul_l[i] = mul_l[i-1] * i % mod

for i in range(n-1,-1, -1):
    mul_r[i] = mul_r[i+1] * i % mod

ans = 0
right = x[-1]
for i in range(n-1):
    tmp = right - x[i]
    tmp = tmp * mul_l[i] * mul_r[i+2] % mod
    ans = (ans + tmp)% mod

print(ans)

Measured memory_bytes: 15248
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll count=0,ans=0;
    for(size_t i=0;i<s.size();++i){
        if(s[i]=='B') count++;
        else ans+=count;
    }
    cout << ans << "\n";
    return 0;
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

//r本再利用されない時、N本から再利用して売れる本数
int rec(int m,int n,int N,int r){
  if(N == 0) return 0;

  int k = N/m * n;//新たに作り出す本数
  r = N%m;//再利用されない本数
  int res = N + k;//売った本数
  
  while(1){
    k = k/m * n;//k本からk/m本再利用
    res += k;
    r += k%m;
    if(k < m){//k本で再利用できなくなったら
      k += r;
      res += rec(m,n,k,r);
    }
  }
}

int main(){
  int N;
  cin >> N;
  cout << (N-2) * 180 << endl;
}

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

long long i,o,t,j,l,s,z;
long long temp1,temp2;

int main()
{
	scanf("%lld%lld%lld%lld%lld%lld%lld",&i,&o,&t,&j,&l,&s,&z);
	
	temp1=o+(i-1)/2*2+(j-1)/2*2+(l-1)/2*2+3;
	temp2=o+i/2*2+j/2*2+l/2*2;
	printf("%lld\n",(i==0 || j==0 || l==0)?temp2:max(temp1,temp2));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int pos = 0, ans = 1;
    rep(i, n)
    {
        pos = pos + l[i];
        if (pos <= x)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	ll a,b,c,d; cin >> a >> b >> c >> d;
	cout << max({a*c, a*d, b*c, b*d}) << endl;
}

Measured memory_bytes: 3660
#include<stdio.h>

int main(){
  int n, i, max, min;
  int A[200000];

  scanf("%d",&n);

  for(i = 0; i < n; i++) scanf("%d",&A[i]);

  max = A[1] - A[0];
  min = A[0];

  for(i = 1; i < n; i++){
    if(i != 1){
      if(A[i] - min > max) max = A[i] - min;
    }
    if(A[i] < min ) min = A[i];
  }

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

  return 0;
}

Measured memory_bytes: 1376
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val hs = readLine.split(" ").map(_.toInt)

  def check(i: Int, pre: Int): Boolean = {
    if (i == n) true
    else {
      if (hs(i) < pre) false
      else if (hs(i) == pre) check(i + 1, pre)
      else check(i + 1, hs(i) - 1)
    }
  }

  println(if (check(0, 0)) "Yes" else "No")
}

Measured memory_bytes: 47968
n = int(input())
a = []
b = 0
for i in range(n):
  l,r=map(int, input().split())
  a.append((l,r))
  b = max(b,r)
  
acc = [0 for i in range(b+2)]
for l,r in a:
  acc[l] += 1
  acc[r+1] += -1
for i in range(b+1):
  acc[i+1] += acc[i]
print(sum(acc))


Measured memory_bytes: 4016
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        bool prime[1000000] = {false};
        prime[1] = true;
        prime[2] = false;
        int count = 0;
      
        for(int j = 2; j * j <= n ; j++){
            if(!prime[j]){
                for (int k = 2; k*j <= n;k++){
                   prime[j*k] = true;
                }
            }
        }
        for(int i = 1;i<=n;i++){
            if(!prime[i]) count = count +1;
        }
        cout << count << endl;
    }
    return 0;
}

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

int main()
{
  int64_t N, a, all = 1, odds = 1;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    all *= 3;
    if (a % 2 == 0)
    {
      odds *= 2;
    }
  }
  cout << all - odds << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

ll x, y;

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

	cin >> x >> y;
	ll ans = inf;
	if (x <= y)
		ans = min(ans, y - x);
	if (-x <= y)
		ans = min(ans, y + x + 1);
	if (x <= -y)
		ans = min(ans, -y - x + 1);
	if (-x <= -y)
		ans = min(ans, x - y + 2);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int[] freq = new int[26];
    for (int i = 0; i < H; i++) {
      char[] line = scanner.next().toCharArray();
      for (int j = 0; j < W; j++) freq[line[j] - 'a']++;
    }

    int cnt4 = (H / 2) * (W / 2);
    int cnt2 = (W % 2) * (H / 2) + (H % 2) * (W / 2);

    for (int i = 0; i < 26; i++) {
      int f = Math.min(cnt4, freq[i] / 4);
      cnt4 -= f;
      freq[i] -= f * 4;
    }
    for (int i = 0; i < 26; i++) {
      int f = Math.min(cnt2, freq[i] / 2);
      cnt2 -= f;
      freq[i] -= f * 2;
    }
    if (cnt2 == 0 && cnt4 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int64_t a,b,n;
    cin >> a >> b >> n;
    int64_t c;
    if(n >= b-1) c = (b-1)*a/b;
    else c = n*a/b;
    cout << c << endl;
}


Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int X[301];
int ps[7]={2,3,5,7,11,13,17};
int p[55]={19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293};
int ans;
void dfs(int id,long now)
{
	if(id<7)
	{
		int tmp=1;
		while(tmp<=300)
		{
			dfs(id+1,now*tmp);
			tmp*=ps[id];
		}
		return;
	}
	int ret=0;
	for(int i=2;i<=300;i++)if(now%i==0)ret+=X[i];
	for(int i=0;i<55;i++)
	{
		int tmp=0;
		for(int j=1;j*p[i]<=300;j++)if(now%j==0)tmp+=X[j*p[i]];
		if(tmp>0)ret+=tmp;
	}
	if(ans<ret)ans=ret;
}
main()
{
	int Q;cin>>Q;
	for(;Q--;)
	{
		int m;cin>>m;
		cin>>X[m];
	}
	dfs(0,1);
	cout<<ans<<endl;
}


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

int keta_goukei (int n){
    int sum=0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    
    int cnt=0;
    for (int i=1;i<=N;i++){
        int sum = keta_goukei(i);
        if(sum >= A && sum <= B){
            cnt += i;
        }
    }

    cout << cnt <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;



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

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

    int ans = 1;
    if (a == ans || b == ans) {
        ans = 2;
    }
    if (a == ans || b == ans) {
        ans = 3;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long fn(long A){
	return (((A+(A%2))/2)%2)^(((A+1)%2)*A);
}

int main(){
	long A,B,i;

	cin >> A >> B;
	if(A!=0){
		i=fn(A-1)^fn(B);
	}else{
		i=fn(B);
	}
	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; ++i)  s[i] = 'x';
    cout << s << endl;
}

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

using namespace std;

const int MaxN = 2e3 + 23;
const int INF = 1e9;
const int MOD = 998244353;

int maxR[MaxN][MaxN * 2];

int dp[MaxN * 2][MaxN * 2];
int sumr;

void up(int & x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    string s;
    cin >> s;



    int cR[MaxN * 2] = {}, cB[MaxN * 2] = {};

    int n = s.size();

    vector <int> a(n), b(n);

    for(int i = 0; i < n; ++i)
    {
        if(s[i] == '0')
            a[i] = 2;
        else
        if(s[i] == '1')
            a[i] = b[i] = 1;
        else
            b[i] = 2;

        sumr += a[i];
    }

    for(int i = 1; i <= n + n; ++i)
    {
        cR[i] = cR[i - 1];
        cB[i] = cB[i - 1];
        if(a[0])
        {
            --a[0];
            ++cR[i];
        }
        if(b[0])
        {
            --b[0];
            ++cB[i];
        }
        for(int j = 1; j < n; ++j)
        {
            if(a[j])
            {
                --a[j];
                ++a[j - 1];
            }
            if(b[j])
            {
                --b[j];
                ++b[j - 1];
            }
        }
    }

    dp[0][0] = 1;
    for(int i = 1; i <= 2 * n; ++i)
    {
        for(int j = 0; j < i; ++j)
            if(dp[i - 1][j])
            {
                if(cR[i] > j)
                    up(dp[i][j + 1], dp[i - 1][j]);
                if(cB[i] >= (i - j))
                    up(dp[i][j], dp[i - 1][j]);
            }
    }

    cout << dp[2 * n][sumr] << '\n';

    return 0;
}


Measured memory_bytes: 62336
N=int(input())
c=[]
d=[]
for i in range(1,10**8):
  if (N%i)==0 and (int(N/i)-i)>=0:
    c.append(int(N/i)-i)
    d.append(int(N/i))

for l in range(0,len(c)):
  if min(c)==c[l] and len(c)>1:
    m=N/d[l]
    print(int((m-1)+(d[l]-1)))
  elif len(c)==1:
    print(N-1)
  

Measured memory_bytes: 42524
#[allow(unused_imports)]
use std::cmp::{min,max};


fn main() {
    let (a,b,c,x,y) = {
        let xs = read_vec_i64();
        (xs[0],xs[1],xs[2],xs[3],xs[4])
    };
    let mut res = 1<<53;
    for p in 0..x+1 {
        let q = (x-p)*2;
        let (q2,r) = if c * 2 < b {
            (max(0,(y-(q/2))*2), 0)
        }
        else {
            (0, max(0,y-(q/2)))
        };
        let t = p*a + (q+q2)*c + r*b;
        res = min(res, t);
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352