akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int N,M;
int L,R;
int ans=0;
int main(){
    cin >> N >> M;
    vector<int> le(M+1);
    vector<int> ri(M+1);
    for(int i=0;i<M;i++){
        cin >> le.at(i) >> ri.at(i);
    }
    L=le.at(0);
    R=ri.at(0);
    for(int i=1;i<M;i++){
    //    if(ri.at(i)>=L || le.at(i)<=R){
            if(L<le.at(i)){
                L=le.at(i);
            }
            if(R>ri.at(i)){
                R=ri.at(i);
            }
        }
    // }
    if(L<=R){
        ans=R-L+1;
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n;
    cin >> n;
    int flag = 0;
    for (int i = 1; i <= 9; i++)
    {
        for (int q = 1; q <= 9; q++)
        {
            if (i * q == n)
            {
                flag = 1;
            }
        }
    }

    if (flag == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

//　if文
// if (num == 0)
// {
//     cout << "0";
// }
// else if (num == 1)
// {
//     cout << "1"; // 1が表示される
// }
// else
// {
//     cout << "01以外";
// }

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <list>
#define pb push_back
using namespace std;
struct guys{
  int sum;
  long long max;
};
int main(){
  int N,M,L,s,e;
  while(true){
    cin>>N;
    if(N==0) return 0;
    int guy[N+1];
    //    int tmpsum,tmp;
    long long guysat[N+1];
    long long guymax[200000];
    for(int i=0;i<N+1;i++){
      guy[i]=guysat[i]=0;
    }
    for(int k=1;k<N+1;k++){
      cin>>M>>L;
      guysat[k]=L;
      for(int i=0;i<M;i++){
	cin>>s>>e;
	for(int j=s;j<e;j++){
	  guy[k]=guy[k]+(1<<(j-6));
	  //  	cout<<guy[k]<<"d "<<endl;	 
	} 
      }
    }
    for(int j=0;j<70000;j++)
      guymax[j]=0;
    for(int i=1;i<N+1;i++){
      for(int j=0;j<70000;j++){
	if((j&guy[i])) continue;
	// 
	// if(guymax[j+guy[i]]<guymax[j]+guysat[i])
	//   cout<<"debug\n";
	guymax[j+guy[i]]=max(guymax[j+guy[i]],guymax[j]+guysat[i]);
      }
    }
    long long answer=0;
    for(int j=0;j<70000;j++)
      answer=max(guymax[j],answer);
    // for(int j=0;j<70000;j++)
    //   cout<<guymax[j]<<endl; 
   cout<<answer<<endl;
  }
  return 0;
}

Measured memory_bytes: 2184
n, m, l = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for j in range(m)]

for i in range(n):
    for k in range(l):
        if k != 0:
            print(" ", end="")
        tmp = 0
        for j in range(m):
            tmp += a[i][j] * b[j][k]
        print(tmp, end="")
    print()


Measured memory_bytes: 6564
#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() {
  double t, x;
  cin >> t >> x;
  printf("%0.5f\n", t / x);
  return 0;
}

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

int main() {
//	freopen("data.in", "r", stdin);
//	freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
    int src,to;
    T cost;

    edge() = default;
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

double f(double x, double y, double z) {
    return sqrt(x*x+y*y+z*z);
}


struct UnionFind {
    vector<int> node;

    UnionFind() = default;
    UnionFind(int x) {init(x);}

    void init(int x) {
        node.assign(x,-1);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (node[x] > node[y]) swap(x,y);
        node[x] += node[y];
        node[y] = x;
        return true; 
    }

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

    int root(int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N; cin >> N;
        if (!N) break;
        vector<double> x(N),y(N),z(N),r(N);

        vector<edge<double>> A;
        rep(i,N) cin >> x[i] >> y[i] >> z[i] >> r[i];
        rep(i,N) {
            for (int j = i+1; j < N; ++j) {
                double d = max(0.0,f(x[i]-x[j],y[i]-y[j],z[i]-z[j]) - r[i] - r[j]);
                A.emplace_back(i,j,d);
            }
        }

        UnionFind uf(N);
        sort(all(A));
        double ans = 0;
        for (auto &e : A) {
            if (uf.same(e.src,e.to)) continue;
            uf.merge(e.src,e.to);
            ans += e.cost;
        }

        cout << fixed << setprecision(3) << ans << ln;
    }
}


Measured memory_bytes: 3404
S = input()
exp = len(S)-1

res = 0
for i in range(2**exp):
    eS = list("+".join(S))
    for j in range(exp):
        if (i >> j) & 1:
            eS[2*j+1] = "-"
    ans = "".join(eS)
    if eval(ans) == 7:
        res = ans + "=7"
        break

print(res)

Measured memory_bytes: 3060
import re
N,M=map(int, input().split())

A=[]
B=[]

for n in range(N):
    A.append(input())

for m in range(M):
    B.append(input())
        
if N<M:
    print("No")
    exit()
# check
for n in range(N):
      # Bのm行目と一致
      # Bのm+1行目と一致するかチェック
      span =[m.span() for m in re.finditer(B[0], A[n])]
      #print(span)
      if span==[]:
          continue
      allgood=False
      for sp in span:
        for i in range(min(M,N)):
            if n+i>=N:
                allgood=False
                break
            #print(n)
            #print((B[i],A[n+i][span[0][0]:span[0][1]]))
            if (B[i]==A[n+i][sp[0]:sp[1]]):
                allgood=True
                continue
            else:
                allgood=False
                break
        if allgood==True:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3188
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# (X - Y) (X^4 + X^3 Y + X^2 Y^2 + X Y^3 + Y^4)
X = ir()

def make_divisors(n):  # 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

U = 5 * 10 ** 6
div = make_divisors(X)
for b in range(U):
    for d in div:        
        a = b + d
        if a ** 5 - b ** 5 == X:
            print(a, b)
            exit()
        a = b - d
        if b ** 5 - a ** 5 == X:
            print(b, a)
            exit()


Measured memory_bytes: 80020
#include<iostream>
using namespace std;
#include<cstdio>
#include<cstring>
#include<vector>
#define N 201
vector<int>G[N];
int n,m,low[N],dfn[N];
bool is_cut[N];
int father[N];
int tim=0;
int a,b;
void input()
{
    scanf("%d%d",&n,&m);
    int a,b;
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d",&a,&b);
        G[a].push_back(b);/*邻接表储存无向边*/
        G[b].push_back(a);
    }
}
void Tarjan(int i,int Father)
{
    father[i]=Father;/*记录每一个点的父亲*/
    dfn[i]=low[i]=tim++;
    for(int j=0;j<G[i].size();++j)
    {
        int k=G[i][j];
        if(dfn[k]==-1)
        {
            Tarjan(k,i);
            low[i]=min(low[i],low[k]);
        }
        else if(Father!=k)/*假如k是i的父亲的话，那么这就是无向边中的重边，有重边那么一定不是桥*/
            low[i]=min(low[i],dfn[k]);//dfn[k]可能！=low[k]，所以不能用low[k]代替dfn[k],否则会上翻过头了。
    }
}
void count()
{
    int rootson=0;
    Tarjan(1,0);
    for(int i=2;i<=n;++i)
    {
        int v=father[i];
        if(v==1)
        rootson++;/*统计根节点子树的个数，根节点的子树个数>=2,就是割点*/
        else{
            if(low[i]>=dfn[v])/*割点的条件*/
            is_cut[v]=true;
        }
    }
    if(rootson>1)
    is_cut[1]=true;
   /* for(int i=1;i<=n;++i)
    if(is_cut[i])
    printf("%d\n",i);*/
    int re=0;
    for(int i=1;i<=n;++i)
    {
        int v=father[i];
        if(v>0&&low[i]>dfn[v])/*桥的条件*/
        re++;
    }
    printf("%d\n",re);
}
int main()
{

    while(scanf("%d%d",&n,&m)==2){
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d",&a,&b);
        G[a].push_back(b);/*邻接表储存无向边*/
        G[b].push_back(a);
    }
    memset(dfn,-1,sizeof(dfn));
    memset(father,0,sizeof(father));
    memset(low,-1,sizeof(low));
    memset(is_cut,false,sizeof(is_cut));
    count();
    }
    return 0;
}


Measured memory_bytes: 256
S=input()
T=input()
sn=len(S)
tn=len(T)

n=sn-tn+1

n_matches=[]
for i in range(n):
  Si=S[i:i+tn]
  n_match=0
  for j in range(tn):
    if Si[j]==T[j]:
      n_match+=1
  n_matches.append(n_match)

print(tn-max(n_matches))


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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 1000000007
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back
#define p 31

using namespace std;

ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    if(n%2==0)
        return power((x*x)%hell,n/2)%hell;
    else
        return (x*(power((x*x)%hell,n/2)%hell))%hell;
}

ll check(string &s,ll k)
{
    /*mp stores the hash value and ending index of corresponding hash value\
     i.e the ending index of the substring*/
    unordered_map <ll,ll> mp;
    ll h=0;
    //for rolling hash
    ll pp=power(p,k-1);
    rep(i,0,k)
        h=(h*p+s[i]-'a'+1)%hell;
    mp[h]=k-1;
    rep(i,k,s.length())
    {
        h=(h-pp*(s[i-k]-'a'+1)+hell)%hell;
        h=(h*p+s[i]-'a'+1)%hell;
        /* if the starting point of current susbtring is greater
            than the ending point of previously seen hash then this string is repeating
        */
        if(mp.count(h)&&i-k+1>mp[h])
            return mp[h]-k+1;
        mp[h]=i;
    }
    return -1;
}

void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector < vi > dp(n+1,vi (n+1,0));
    ll ans=0;
    rep(i,0,n+1)
    {
        rep(j,i+1,n+1)
        {
            if(i==0)
                dp[i][j]=0;
            else if(s[i-1]==s[j-1]&&(j-i)>dp[i-1][j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=0;
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 195840
#include <iostream>

using namespace std;

void call(int n);

void call(int n)
{
  int x;
  for(int i = 1; i <= n; i++){
    x = i;
    if(x % 3 == 0){
      cout << " " << i;
    }else{
      do{
	if(x % 10 == 3){
	  cout << " " << i;
	  break;
	}
	x/=10;
      }
      while(x);
    }
  }
  cout << endl; 
}

int main(void)
{
  int n;
  cin >> n;
  call(n);
}

Measured memory_bytes: 1160
n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range (n):
  s = input()
  if s == "AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s =="TLE":
    tle += 1
  else:
    re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9200
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	vector<int> n(3);
	rep(i, 3)	cin >> n[i];
	sort(all(n));
	if (n[0] + n[1] == n[2])
		cout << "Yes";
	else
		cout << "No";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var P = Console.ReadLine().Replace(" ", "");
            var Q = Console.ReadLine().Replace(" ", "");

            var s = string.Empty;
            for (int i = 1; i < N + 1; i++)
            {
                s += i.ToString();
            }

            var l = Permutation(s);

            var a = 0;
            var b = 0;
            for (int i = 0; i < l.Count; i++)
            {
                if (l[i] == P)
                {
                    a = i;
                }
                if (l[i] == Q)
                {
                    b = i;
                }
            }
            Console.WriteLine(Math.Abs(a - b));
        }

        static List<string> Permutation(string s)
        {
            if (s.Length == 1)
            {
                return new List<string>() { s };
            }
            var result = new List<string>();
            for (int i = 0; i < s.Length; i++)
            {
                foreach (var t in Permutation(s.Remove(i, 1)))
                {
                    result.Add(s[i] + t);
                }
            }
            return result;
        }
    }
}

Measured memory_bytes: 24384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int a, b;
  cin >> a >> b;

  double taxa = 0.08;
  double taxb = 0.1;

  int ans = -1;  

  int i = 1;
  while(true) {
    if ((int(i * taxa) == a) && (int(i * taxb) == b)) {
      ans = i;
      break;
    }

    if ((int(i * taxa) > a) && (int(i * taxb) > b)) break;
    
    i++;
  } 
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//The number of Parks are repaired from 0 to n-1.
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#define int long long
using namespace std;

const int inf = 1e+12;

int n, m, c;
vector<int> et[100000];
vector<int> ec[100000];
int cost[100000];

int allCost;				//allCost = Sum length of all edges.
map<int, int> ecost;		//ecost[x] = Sum cost of the edges which are deleted if we choose integer x and are not deleted if we choose integer u(u < x).

void Dijkstra(){
	typedef pair<int, int> P;
	static priority_queue<P, vector<P>, greater<P> > que;
	int i;
	
	for( i = 0; i < n; i++ ) cost[i] = inf;
	que.push(P(0, 0));
	while(!que.empty()){
		P now = que.top();
		int dist = now.first;
		int pos = now.second;
		que.pop();
		if( cost[pos] <= dist )
			continue;
		cost[pos] = dist;
		
		for( i = 0; i < et[pos].size(); i++ ){
			int npos = et[pos][i];
			int ndist = dist + ec[pos][i];
			que.push(P(ndist, npos));
		}
	}
}

void set_allCost(){
	int i, j;
	
	//Convert vector to non-vector. So I have to divide 2 in last steps.
	allCost = 0;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < et[i].size(); j++ ){
			allCost += ec[i][j];
		}
	}
	allCost /= 2;
}

void set_ecost(){
	int i, j;
	
	//Convert vector to non-vector. So I have to divide 2 in last steps.
	ecost[0] = 0;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < et[i].size(); j++ ){
			int u = i;
			int v = et[i][j];
			int x = max(cost[u], cost[v]);
			if( ecost.find(x) == ecost.end() ){ ecost[x] = 0; }
			ecost[x] += ec[i][j];
		}
	}
	for( map<int, int>::iterator it = ecost.begin(); it != ecost.end(); it++ ){
		(*it).second /= 2;
	}
}

signed main()
{
	int i;
	
	cin >> n >> m >> c;
	for( i = 0; i < m; i++ ){
		int a, b, d;
		cin >> a >> b >> d;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
		ec[a].push_back(d);
		ec[b].push_back(d);
	}
	Dijkstra();
	set_allCost();
	set_ecost();
	
	int ans = inf;
	int cst = 0;
	
	//Search for x.
	for( map<int, int>::iterator it = ecost.begin(); it != ecost.end(); it++ ){
		int x = (*it).first;
		cst += (*it).second;
		ans = min(ans, allCost + c * x - cst);
	}
	cout << ans << endl;
}

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

int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}

int main(){
  int n,k,i;
  int ans=0;
  int a[200005],b[200005];
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    b[i]=0;
  }
  for(i=0;i<n;i++){
    b[a[i]] += 1;
  }
  qsort(b,n,sizeof(b[0]),ascSort);
  for(i=0;i<k;i++){
    ans += b[i];
  }
  printf("%d",n-ans);
  return 0;
}

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

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

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

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

inline void read() {}

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

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

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

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

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

    int N;
    i64 X = 1, Y = 1;
    read(N);
    rep(i, N) {
        i64 t, a;
        read(t, a);
        const i64 g = __gcd(t, a);
        t /= g; a /= g;

        const i64 k1 = (X + t - 1) / t;
        const i64 k2 = (Y + a - 1) / a;
        X = t * max(k1, k2);
        Y = a * max(k1, k2);
        trace(X, Y);
    }

    print(X + Y);

    return 0;
}


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

const long long INF = 1LL << 60;
const ll MOD = ll(1e9)+7;

bool has_key(unordered_map<string, ll> &m, string s){
    if (m.find(s) == m.end()){
        return false;
    }
    else{
        return true;
    }
}


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


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}


void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

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

ll count_black(vector<vector<string>> C) {

  ll num = 0;
  for (ll i = 0; i < C.size(); i++) {
    for (ll j = 0; j < C.at(i).size(); j++) {
      if (C.at(i).at(j) == "#") num++;
    }
    
  }

  return num;
  
}

vector<vector<string>> paint(vector<vector<string>> C, vector<ll> x, vector<ll> y) {

  vector<vector<string>> C_painted = C;

  for (ll i = 0; i < x.size(); i++) {
    if(x.at(i) == 1) {
      for (ll j = 0; j < C_painted.size(); j++) {
        C_painted.at(j).at(i) = "r";
      }
    }
  }

  for (ll i = 0; i < y.size(); i++) {
    if(y.at(i) == 1) {
      for (ll j = 0; j < C_painted.at(0).size(); j++) {
        C_painted.at(i).at(j) = "r";
      }
    }
  }

  return C_painted;
  
}

vector<vector<ll>> vec_x;

void sublistx(vector<ll> tmp, ll n) {
    if (n == 0) {
      vec_x.push_back(tmp);
    }
    if (n > 0) {
      vector<ll> tmp0 = tmp;
      vector<ll> tmp1 = tmp;
      tmp0.push_back(0);
      tmp1.push_back(1);
      sublistx(tmp0, n - 1);
      sublistx(tmp1, n - 1);
    }
}

vector<vector<ll>> vec_y;

void sublisty(vector<ll> tmp, ll n) {
    if (n == 0) {
      vec_y.push_back(tmp);
    }
    if (n > 0) {
      vector<ll> tmp0 = tmp;
      vector<ll> tmp1 = tmp;
      tmp0.push_back(0);
      tmp1.push_back(1);
      sublisty(tmp0, n - 1);
      sublisty(tmp1, n - 1);
    }
}


int main() {

  ll X, K, D;
  ll ans;

  cin >> X >> K >> D;

  if (X >= 0) {
    if ((X/D - K) >= 1) {
      ans = abs(X - D*K);

      cout << ans << endl;
      return 0;
    }
  } else if (X <= 0) {
    if ((X/D + K) <= -1) {
        
      ans = abs(X + D*K);

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

  ll tmp = K - abs(X)/D;
  
  if (tmp % 2 == 0) {
    ans = abs(X) % D;
  } else {
    ans = D - (abs(X) % D);
  }

 
  


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3584
d = ['','a','b','c','d','e','f','g','h','i','j']
N = int(input())
if N == 1:
  print("a")
elif N == 2:
  print("aa")
  print("ab")
else:
  ans = [[[]]for _ in range(N - 1)]
  ans[0][0] = [1]
  ans[1][0] = [1,1]
  ans[1].append([1,2])
  ansstr = []
  for i in range(N -2):
    for i2 in range(len(ans[i + 1])):
      for i3 in range(max(ans[i + 1][i2]) + 1):
        if i == N - 3:
          ansstr.clear()
          for i4 in range(N - 1):
            ansstr.append(d[ans[i + 1][i2][i4]])
          ansstr.append(d[i3 + 1])
          print("".join(ansstr))
        else:
          ans[i + 2].append(ans[i + 1][i2] + [i3 + 1])
    if i < N - 3:
      ans[i + 2].pop(0)
    

Measured memory_bytes: 8356
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;
int n;
string s[204];
vector<int> g[500];vector<int> col (500,-1);
bool ans=true;int dis[205][205];
void dfs(int idx)
{
for(auto it : g[idx])
{
	if(col[it]==-1)
	{
		col[it]=col[idx]^1;
		dfs(it);
	}
	else
	{
		if(col[it]+col[idx]!=1){
		ans=false;}
	}
}
}

int main()
{  fast
cin>>n;
for(int i=0;i<n;i++)
cin>>s[i];

for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		if(s[i][j]=='1')
		{
			g[i+1].emplace_back(j+1);
		
		}
	}
}
col[1]=0;
dfs(1);
if(!ans)
{
	cout<<-1;
	return 0;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
	if(i==j)
	dis[i][j]=0;
	else if(s[i-1][j-1]=='1')
	dis[i][j]=1;
	else
	dis[i][j]=inf;
}
for(int k=1;k<=n;k++)
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
int val=0;
for(int i=1;i<n;i++)
for(int j=1;j<=n;j++)
val=max(val,dis[i][j]);
cout<<val+1;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int ans = 111;

    while (true) {
      if (((ans - 111) < n) && (n <= ans)) {
        System.out.println(ans);
        return;
      } else {
        ans += 111;
      }
    }

  }
}

Measured memory_bytes: 35768
#include <stdio.h>


int main() {
    int x, y, x0, y0, x1, y1;
    int q;
    double v0x, v0y, vx, vy, k, v0d;

    scanf("%d %d %d %d", &x0, &y0, &x1, &y1);
    scanf("%d", &q);

    v0x = x1 - x0;
    v0y = y1 - y0;
    v0d = v0x*v0x+v0y*v0y;
    while (q--) {
        scanf("%d %d", &x, &y);
        vx = x - x0;
        vy = y - y0;
        k = (v0x * vx + v0y * vy)/v0d;
        printf("%.10f %.10f\n", 2*(k*v0x-vx)+x, 2*(k*v0y-vy)+y);
    }
}

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

int N, K, A, ans = 2e9, minNum=2e9;
vector<int> h;

int main(){
    cin >> N >>K;    
    h.resize(N);
    for(int i=0; i<N; i++)
	cin >> h[i];

    sort(h.begin(), h.end());

    
    for(int i=K; i<=N; i++)
	minNum = min(minNum, h[i-1]-h[i-K]);

    cout << minNum<<endl;
}



Measured memory_bytes: 640
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
int n, cnt[1<<21], ans, m, viz[69];
int up[69][7], in[69], out[69], idx; //LCA shit 
vector<int> g[69]; vector<pi> r;

int dfs(int p, int nod){
	in[nod]=++idx;
	up[nod][0]=p;
	for(int i=1; i<=6; i++) up[nod][i]=up[up[nod][i-1]][i-1];
	for(int i : g[nod]){
		if(i!=p) dfs(nod, i);
	}
	out[nod]=++idx;
}

bool check(int p, int nod){
	if(in[p]<=in[nod] && out[nod]<=out[p]) return 1;
	return 0;
}

int lca(int l, int r){
	if(check(l, r)) return l;
	if(check(r, l)) return r;
	for(int i=6; i>=0; i--) if(check(up[l][i], r)==0) l=up[l][i];
	return up[l][0];
}

void dfs1(int p, int nod){
	for(int i: g[nod]){
		if(i!=p) dfs1(nod, i), viz[nod]+=viz[i];
	}
}

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n;
	for(int i=1; i<n; i++){
		int a, b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1, 1);
	cin>>m;
	for(int i=1; i<=m; i++){
		int u, v;
		cin>>u>>v;
		r.pb({u, v});
	}
	for(int mask=0; mask<(1<<m); mask++){
		for(int i=1; i<69; i++) viz[i]=0;
		int bits=0;
		for(int i=0; i<m; i++){
			if(((1<<i)&mask)){
				bits++;
				int u=r[i].x, v=r[i].y;
				viz[u]++, viz[v]++, viz[lca(u, v)]-=2;
			}
		}
		dfs1(1, 1);
		int cnt=0;
		for(int i=1; i<=n; i++) if(viz[i]>0) cnt++;
		int val=pow(2, n-1-cnt);
		if(bits%2) ans-=val;
		else ans+=val;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct Node{
 
  int key;
  struct Node *parent;
  struct Node *left;
  struct Node *right;
 
};
 
struct Node *root,*NIL;
void insert(int );
void preorder(struct Node *);
void inorder(struct Node *);
struct Node *find(struct Node *, int);
int main(){
 
  int sumnode,inputdata,i,findnumber;
  char string[10];
 
 
  scanf("%d",&sumnode);
 
  for(i = 0; i < sumnode; i++){
 
    scanf("%s",string);
 
    if((strcmp(string,"insert")) == 0){
 
      scanf("%d",&inputdata);
      insert(inputdata);
 
    }
 
 
    else if((strcmp(string,"print"))==0){
 
      inorder(root);
 
      printf("\n");
 
      preorder(root);
 
      printf("\n");
    
         
    }
 
    else if((strcmp(string,"find")) == 0){
 
 
      struct Node *answer;
      scanf("%d",&findnumber);
 
      answer =  find(root,findnumber);
       
 
      if(answer !=NIL){
 
	printf("yes\n");
 
      }
 
      else{
 
	printf("no\n");
 
      }
    }
 
  }
  return 0;
}
void insert(int inputdata){
 
  struct Node *correntNode; 
  struct Node *beforeNode; 
  struct Node *newNode;
 
  newNode = (struct Node*)malloc(sizeof(struct Node));
 
  newNode -> key = inputdata;
 
  newNode->parent = NIL;
 
  newNode->left = NIL;
 
  newNode->right = NIL;
 
  correntNode = root;
  beforeNode = NIL;
 
  while(correntNode != NIL){
 
    beforeNode = correntNode;
 
    if(newNode->key < correntNode->key){
 
      correntNode = correntNode->left;
 
    }
 
    else{
 
      correntNode =  correntNode->right;
 
    }
  } 
 
  newNode->parent = beforeNode;
 
 
  if(beforeNode == NIL){ 
 
    root = newNode;;
 
  }
 
  else if(newNode->key > beforeNode->key){
 
    beforeNode->right = newNode;
 
  }
 
  else{
 
    beforeNode->left = newNode;
 
  }
 
}
 
void preorder(struct Node *inputdata){
 
  if(inputdata != NIL){
 
    printf(" %d",inputdata->key);
 
    preorder(inputdata->left);
    preorder(inputdata->right);
 
  }
 
}
 
void inorder(struct Node *inputdata){
 
  if(inputdata != NIL){
 
    inorder(inputdata->left);
 
    printf(" %d",inputdata->key);
 
    inorder(inputdata->right);
 
  }
 
}
 
 
struct Node * find(struct Node *inputdata ,int findnumber){
 
  int flag = 0;
 
  while( inputdata != NIL && inputdata->key != findnumber){
 
    if(inputdata->key < findnumber){
 
      inputdata = inputdata->right;
 
    }
 
    else if(inputdata->key > findnumber){
 
      inputdata = inputdata->left;
 
    }
  }
 
 
 
  return inputdata;
 
}

Measured memory_bytes: 19360
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[set() for i in range(N)]
#例2を見ると、同じ展望台を結ぶ複数の道がある
for i in range(M):
  A,B=map(int,input().split())
  A-=1
  B-=1
  AB[A].add(B)
  AB[B].add(A)
ans=0
for i in range(N):
  res=True
  for x in AB[i]:
    if H[i]<=H[x]:#同じ高さの展望台は条件を満たさない
      res=False
      break
  if res:
    ans+=1#チェックした結果、OKの展望台だけ、答に加える
print(ans)

Measured memory_bytes: 45152
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val line1 = readLine.trim.split(' ').map(_.toInt)
  val line2 = readLine.trim.split(' ').map(_.toInt)
  for (i ← line1.indices.tail) line1(i) += line1(i - 1)
  for (i ← line2.indices.reverse.tail) line2(i) += line2(i + 1)
  println(
    line1.zip(line2).map{case (a, b) ⇒ a + b}.max
  )
}

Measured memory_bytes: 25496
#include<stdio.h>

int main(){
  int k=0;
  int a=0;
  int b=0;
  int ans=1;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);
  b++;
  while(a!=b){
    ans=a%k;

    if(ans==0){
      printf("OK");
      return 0;
    }
    a++;
  }
  printf("NG");
  return 0;
}


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

int n;
unordered_map<int, int> cnt[2];
vector<pair<int, int>> v[2];

int main() {
    ios::sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        cnt[i & 1][x]++;
    }

    for (int p = 0; p < 2; ++p) {
        for (auto &x: cnt[p]) {
            v[p].push_back({x.second, x.first});
        }
        v[p].push_back({0, -1});
    
        sort(v[p].begin(), v[p].end(), [](const pair<int, int> &a, const pair<int, int> &b) {
            return a.first > b.first;
        });
    }

    if (v[0][0].second != v[1][0].second) {
        cout << n - v[0][0].first - v[1][0].first << "\n";
        return 0;
    }

    int sol = n - max(v[0][0].first + v[1][1].first, v[0][1].first + v[1][0].first);

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 5524
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val snackHolders = (0 until K).map {
        readLine() // needless value
        readLine()!!.split(" ").map { it.toInt() } }
  
    val population = snackHolders.fold(setOf<Int>(), { acc, list -> acc + list.toSet() } )
    val mischiefs = (1..N).filterNot { population.contains(it) }
    
    println(mischiefs.count())
}



Measured memory_bytes: 40736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n;
int a[100010];
map<int, int> mp;
int res;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=0;i<n;i++)
	{
		mp[a[i]]++;
		mp[a[i]-1]++;
		mp[a[i]+1]++;
	}
	for (map<int, int>::iterator it=mp.begin();it!=mp.end();it++)
	    res=max(res,it->second);
	cout <<res;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    unordered_map<int, unordered_map<int, int>> um;
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        um[a][b] = c;
        um[b][a] = c;
    }
    int q, k;
    cin >> q >> k;
    vector<long long int> dist(n + 1, -1);
    dist[k] = 0;
    priority_queue<pair<long long int, int>> pq;
    pq.push(make_pair(0, k));
    while (pq.size() > 0) {
        auto p = pq.top();
        pq.pop();
        long long int d = -p.first;
        int index = p.second;
        if (dist[index] != d) continue;
        for (auto pp : um[index]) {
            if (dist[pp.first] == -1 || pp.second + d < dist[pp.first]) {
                dist[pp.first] = pp.second + d;
                pq.push(make_pair(-dist[pp.first], pp.first));
            }
        }
    }
    for (int i = 0; i < q; i++) {

        int a, b;
        cin >> a >> b;
        cout << dist[a] + dist[b] << endl;
    }
}


Measured memory_bytes: 25624
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;


int main() {
	int a, b, c, d;
	while(scanf("%d%d%d%d", &a, &b, &c, &d) != EOF) {
		printf("%d\n", max(a * b, c * d));
	}
	return 0;
}


Measured memory_bytes: 128
//#include<bhaai.h>
#include<bits/stdc++.h>
using namespace std;
#define to int64_t
#define mo 1000000007
#define fr(a,e) for(int i=a;i<=e;i++)
#define yah_faster_baby ios_base::sync_with_stdio(0);cin.tie(0);

to a,b,c;
//vector <int> v[100005];
char s[100005];
int main()
 {  yah_faster_baby
	cin>>s;
	if(s[0]!='h'||s[1]!='i')
	{cout<<"No";return 0;}
	int i;
	for(i=2;s[i]!='\0';i++)
	{if(i%2)
	 {if(s[i]!='i')
	  {cout<<"No";return 0;}
	 }
	 else
	 {if(s[i]!='h')
	  {cout<<"No";return 0;}
	 }
	}
	if(s[i-1]!='i')
	cout<<"No";
	else
	cout<<"Yes";
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll n = max(a * c, a * d);
  ll n1 = max(b * c, b * d);
  cout << max(n1, n) << endl;
}

Measured memory_bytes: 3636
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	lines = readlines()
	n = parse(shift!(lines))
	e = [Tuple[] for i in 1:n]
	for i=lines
		u,v,w = map(parseInt, split(i))
		push!(e[u],(v,w%2))
		push!(e[v],(u,w%2))
	end
	vst = -ones(Int,n)
	stack = [1]
	now = 1
	vst[1] = 0
	while !isempty(stack)
		now = shift!(stack)
		for i in 1:length(e[now])
			if vst[e[now][i][1]] < 0
				push!(stack,e[now][i][1])
				vst[e[now][i][1]] = (vst[now]+e[now][i][2])%2
			end
		end
	end
	for i in 1:n
		println(vst[i])
	end
end
main()


Measured memory_bytes: 176240
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
l = list(map(int, input().split()))
# 文字列の入力

cnt = 1
for i, v in enumerate(l):
  if i >= 1:
    #print(i,v)
    #print(l[:i])
    if max(l[:i]) <= v:
      cnt += 1

print(cnt)
# 出力
#print("{} {}".format(l, a))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int s[1001];
int main(){
    int n,m,a,b;
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        s[i]=a;
    }
    sort(s,s+m,greater<int>());
    int sum=0;
    rep(i,m-1){
        sum+=max(0,n-s[i]);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3172
#include <cstdio>
#include <numeric>
#include <cmath>
#include <iostream>
using namespace std;

const int maxn = 1e2;
const int maxk = 1e5;
int a[maxn], n, k;
int who[maxk + 1];
const int taro = 0;
const int jiro = 1;

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];  
  for (int s = 0; s <= k; s++) {
    who[s] = jiro;
    for (int i = 0; i < n; i++)
      if (s >= a[i] && who[s - a[i]] == jiro)
        who[s] = taro;
  }
  cout << (who[k] ? "Second" : "First") << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int a, b, c;
	while(scanf(" %d %d %d", &a, &b, &c) != EOF){
		int i, now=a+b;
		int count=0;
		
		for(i=1; i<=10; i++){
			if(i==a || i==b || i==c) continue;
			else{
				if(now+i<=20) count++;	
			}
		}

		if(count>=4) printf("YES\n");
		else printf("NO\n");

	}

	return 0;
}

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

int main(){
	ll n;
	cin >> n;
	ll a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(n % min(a, min(b, min(c, min(d, e)))) == 0) cout << 4 + n / min(a, min(b, min(c, min(d, e)))) << endl;
	else cout << 5 + n / min(a, min(b, min(c, min(d, e)))) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
void solve(){
    string s;
    cin >> s;
    sort(all(s));
    cout << (s == "abc" ? "Yes\n" : "No\n");
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        solve();
    }
}

Measured memory_bytes: 34600
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n,y;
	cin>>n>>y;
	
	for(int i=n;i>=0;--i){
		if(10000*i>y) continue;
		for(int j=n-i;j>=0;--j){
			if(10000*i+5000*j==y-1000*(n-i-j)){
				printf("%d %d %d\n",i,j,n-i-j);
				return 0;
			}
		}
	}
	
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
start = [0] * (k + 1)
c = '1'
ret = 0
for i in range(len(s)):
    if c == '0' and s[i] == '1':
        start.append(i)
    elif c == '1' and s[i] == '0':
        ret = max(ret, i - start.pop(0))
    c = s[i]
ret = max(ret, n - start.pop(0))
print(ret)

Measured memory_bytes: 4340
import __pypy__
import sys

B, W = map(int, sys.stdin.readline().split())
MOD = 10**9 + 7

L = B+W
fact = [1]*(L+1)
rfact = [1]*(L+1)
for i in range(L):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

rev2 = pow(2, MOD-2, MOD)

p = q = 0
base = 1
bl = __pypy__.builders.StringBuilder(B+W)
bl.append("%d\n" % rev2)
for i in range(1, B+W):
    base = rev2 * base % MOD
    if i-B >= 0:
        p = (p + ((fact[i-1]*rfact[B-1] % MOD)*rfact[i-B] % MOD)*base % MOD) % MOD
    if i-W >= 0:
        q = (q + ((fact[i-1]*rfact[W-1] % MOD)*rfact[i-W] % MOD)*base % MOD) % MOD
    bl.append("%d\n" % ((1-p+q)*rev2 % MOD))
sys.stdout.write(bl.build())

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (s.size() == n)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}

Measured memory_bytes: 9600
import sys
input = sys.stdin.readline
 
H, W = [int(x) for x in input().split()]
c = []
for _ in range(10):
    c.append([int(x) for x in input().split()])
A = []
for _ in range(H):
    A.append([int(x) for x in input().split()])

def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

N = 10
cost = warshall_floyd(c)
ans = 0

for i in A:
    for j in i:
        if j >= 0:
            ans += cost[j][1]

print(ans)


Measured memory_bytes: 40412
// Problem : B - Two Arrays
// Contest : AtCoder - AtCoder Petrozavodsk Contest 001
// URL : https://atcoder.jp/contests/apc001/tasks/apc001_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin >> n;
	vi a(n), b(n);
	ll suma=0,sumb=0;
	loop(i, n)
		cin >> a[i];
	loop(i, n)
	{
		cin >> b[i];
		if(b[i]>a[i])
			sumb+=(b[i]-a[i])/2;
		else
			suma+=a[i]-b[i];
	}
	if(sumb>=suma)
		cout<<"Yes"<<nl;
	else
		cout<<"No"<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3712
N, A, B = list(map(int,input().split()))

if A == 0:
    print(0)
elif A+B >= N:
    print(min(A,N))
else:
    cnt = A * (N // (A+B))
    N -= (A+B) * (N // (A+B))
    cnt += min(A,N)
    print(cnt)

Measured memory_bytes: 9192
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    //1の位が0,9,8,7,6,5,4,3,2,1の順に優先して頼むのが良い
    //かかる時間はそれぞれ10で割った商+リードタイムの数
    int a1 = a%10;
    int b1 = b%10;
    int c1 = c%10;
    int d1 = d%10;
    int e1 = e%10;
    int a2 = a/10;
    int b2 = b/10;
    int c2 = c/10;
    int d2 = d/10;
    int e2 = e/10;
    int answer = (a2+b2+c2+d2+e2)*10;
    //0の数カウント
    int zeroCnt=0;
    int one[] = new int[5];
    one[0]=a1;
    one[1]=b1;
    one[2]=c1;
    one[3]=d1;
    one[4]=e1;
    for(int i=0;i<5;i++){
      if(one[i]==0){
        one[i]=10;
        zeroCnt++;
      }
    }
    //答えはmax(0,(0じゃない数-1))*10を足して、0じゃない数で一番小さい数を足したもの
    Arrays.sort(one);
    if(one[0]==10){
      one[0]=0;
    }
    answer=answer+Math.max(0,4-zeroCnt)*10+one[0];
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    int x;cin>>x;
    vector<bool> dp(1000000, 0);
    vector<int> vec{100,101,102,103,104,105};
    dp[0]=1;
    rep(i,0,5)rep(j,0, 100000){
        if(dp[j])dp[j+vec[i]]=true;
    }
    cout<<dp[x]<<endl;
}


Measured memory_bytes: 384