akhauriyash/Code-Regression huggingface dataset:
/*
    g++ -std=c++14 -O2 -Wall a.cpp -o a && a
    g++ -std=c++14 -O2 -Wall a.cpp -o a && a < in.txt > out.txt
    */

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
    std::ifineam inFile("input.txt");
    std::ofineam outFile("output.txt");
    std::cin.rdbuf(inFile.rdbuf());
    std::cout.rdbuf(outFile.rdbuf());
    */

ll lcm(ll &c, ll &d)
{
    return ((c * d) / __gcd(c, d));
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    ll divs = (b / c - a / c) + (b / d - a / d);
    divs -= (b / lcm(c, d) - a / lcm(c, d));
    cout << (b - a) - divs;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

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

    std::set<std::string> got;
    std::string tmp;

    while (n-- > 0)
    {
        std::cin >> tmp;
        got.insert(tmp);
    }
    std::cout << got.size() << std::endl;

    return 0;
}


Measured memory_bytes: 15664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n,m; cin>>n>>m;
	priority_queue<pair<int64_t,int64_t>> pq1;
	rep(i,n){
		int a,b; cin>>a>>b;
		pq1.push({-a, b});
	}
	priority_queue<int64_t> pq2;
	int64_t ans=0;
	for(int day=m;day>=0;day--){
		while(pq1.size()){
			int64_t a,b;
			tie(a,b)=pq1.top();
			a=-a;
			if(day+a<=m){
				pq1.pop();
				pq2.push(b);
			}else{
				break;
			}
		}
		while(pq2.size()){
			int64_t b=pq2.top();
			pq2.pop();
			ans+=b;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N, M, h[1501], w[1501];
    while(cin >> N >> M){
    if(N == 0 && M == 0)    break;
    for(int i=0;i<N;i++) cin >> h[i];
    for(int i=0;i<M;i++) cin >> w[i];
 
    int mxh=accumulate(h,h+N,0); 
    int mxw=accumulate(w,w+M,0); 
    
    vector<int>th(mxh+1,0),tw(mxw+1,0); 
    
    for(int i=0; i<N; i++){
        int sum =0;
        for(int j=i; j<N; j++){
            sum += h[j]; 
            th[sum]++;
        }
    }
    for(int i=0; i<M; i++){
        int sum =0;
        for(int j=i; j<M; j++){
            sum += w[j]; 
            tw[sum]++;
        }
    }
    long long count = 0;
    for(int i=0; i<=min(mxh,mxw); i++){
        count += (long long)th[i]*tw[i];
    }
    cout << count << endl;
    }
    return 0;
}


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

int main() {
    vector<int> cnt(4);
    for (int i=0; i<6; ++i) {
        int num; cin >> num;
        num--;
        cnt[num]++;
    }
    sort(cnt.begin(), cnt.end());
    bool ans = false;
    vector<int> can = {1, 1, 2, 2};
    if (cnt == can) ans = true;
    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

 public static void main(String[] args) {
  Scanner scan = new Scanner(System.in);
  int a = scan.nextInt();
  int b = scan.nextInt();
  int c = scan.nextInt();
  scan.close();
  if(a < b && b < c && a < c) {
   System.out.println("Yes");
   
  }else {
   System.out.println("No");
  }
  
  // TODO 自動生成されたメソッド・スタブ

 }

}



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

int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    int ans = 0;
    rep(i,n) rep(j,d) cin >> x[i][j];
    rep(i,n) for(int j = i + 1; j < n; j++){
        int dist = 0;
        rep(k,d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        rep(k,150) if(k*k == dist) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


int main(){
   ll n;
   cin >> n;
   llv a(n), b(n), c(n-1);
   rep(i,n) cin >> a[i];
   rep(i,n) cin >> b[i];
   rep(i, n-1) cin >> c[i];
   ll ans = b[a[0]-1];
//    cout << ans << endl;
   for (ll i=1;i<n;i++){
       if (a[i] == (a[i-1] + 1)) {
           ans += b[a[i]-1];
           ans += c[a[i-1]-1];
        //    cout << ans << endl;
       }
       else{
           ans += b[a[i]-1];
        //    cout << ans << endl;
       }
   }
   cout << ans << endl;
}

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


void Permutation(char *num_box, char *out_num, int n, int count)
{
	char remove;
	int i;

	if(count == n){
		for(i = 0; i < n; i++){
			printf("%d", out_num[i]);
			if(i != n - 1)
				printf(" ");
		}
		printf("\n");
		return;
	}

	for(i = 0; i < n; i++){
		if(num_box[i] != -1){
			remove = num_box[i];
			num_box[i] = -1;
			out_num[count] = remove;
			Permutation(num_box, out_num, n, count + 1);
			num_box[i] = remove;
		}
	}
}


int main()
{
	int n;
	char temp;
	char *num_box, *out_num;
	int i, j;

	scanf("%d", &n);

	num_box = (char *)malloc(sizeof(char) * n);
	for(i = 0; i < n; i++)
		num_box[i] = i + 1;

	out_num = (char *)malloc(sizeof(char) * n);

	Permutation(num_box, out_num, n, 0);

	return 0;
}


Measured memory_bytes: 2148
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    k = input()
    modulo = int(input())
    dp = [[0] * 2 for _ in range(modulo)]
    dp[0][0] = 1

    for d in k:
        d = int(d)
        ndp = [[0] * 2 for _ in range(modulo)]
        for r, lt in product(range(modulo), range(2)):
            for x in range(10):
                if (not lt) and x > d:
                    continue
                nlt = max(lt, x < d)
                nr = (r + x) % modulo
                ndp[nr][nlt] += dp[r][lt]
                if ndp[nr][nlt] >= MOD:
                    ndp[nr][nlt] -= MOD
        dp = ndp

    print((dp[0][0] + dp[0][1] - 1) % MOD)
resolve()

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

int main() {
  int N,x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ans;
  for (int i=0; i<N; i++) {
    if (i == N-1) {
      if (a[i] == x) {
        ans = N;
      }
      else {
        ans = N-1;
      }
    }
    else if (a[i] > x) {
      ans = i;
      break;
    }
    x -= a[i];
  }
  cout << ans << endl;
}


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

int n;
int d[10];

void func(int c, int m) {
    if (c == n) {
        for (int i = 0; i < n; i++) {
            cout << (char)('a' + d[i]);
        }
        cout << endl;
        return;
    }

    for (int i = 0; i <= m + 1; i++) {
        d[c] = i;
        if (i <= m) func(c + 1, m);
        else func(c + 1, m + 1);
    }
    return;
}

int main() {
    cin >> n;

    func(0, -1);
    return 0;
}


Measured memory_bytes: 1536
# 空白区切の入力を数値(整数)の配列で返す
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

A, B = gets_i_list

if B == 1
  puts 0
else
  count = 1
  total = A
  while true
    break if total >= B
    count += 1
    total = (A * count) - (count - 1)
  end
  puts count
end


Measured memory_bytes: 1916
=begin
－－－－－－－－－－－－－－
  N = 入力値
  cnt = 桁数
  ans = 答え
－－－－－－－－－－－－－－
  digitsメソッドを作成(num)
    1: cnt += 1
    2: num /10
    3. num < 0 になったら cnt を返す
  メソッド－－－－－－－－－－

  1: 1 ~ N まで繰り返す(i)
  2: digits(i) % 2 が 0 以外なら ans += 1
  3: ans を出力
=end

def digits(num)
  cnt = 0;
  while num > 0
    cnt += 1;
    num /= 10;
  end
  return cnt;
end

n = gets.to_i;
ans = 0;

for i in 1..n do
  ans += 1 unless digits(i) % 2 == 0
end

puts ans

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long p, q, a, n, ans = 0, pq = 0;

void solve(long long child, long long mother,
           long long maxnum, long long now);

int main() {
  while(1) {
    cin >> p >> q >> a >> n;
    if(p + q + a + n == 0) break;
    ans = 0;
    pq = GCD(p, q);
    p /= pq;
    q /= pq;
    solve(0, 1, 1, 0);
    cout << ans << endl;
  }
  return 0;
}

void solve(long long child, long long mother,
           long long maxnum, long long now) {
  // check ans
  long long momq = mother * q, momp = mother * p,
            chilq = child * q, x;
  if(momq % (momp - chilq) == 0) {
    x = momq / (momp - chilq);
    if(x * mother <= a && x >= maxnum) ++ans;
  }
  if(now == n - 1) return;
  // dfs
  long long fin = (n - now) * (momq + momp - chilq - 1) /
                  (momp - chilq);
  for(int i = maxnum; mother * i <= a; ++i) {
    long long nextchil = child * i + mother,
              nextmom = mother * i;
    if(nextmom * p <= nextchil * q) continue;
    solve(nextchil, nextmom, i, now + 1);
  }
}


Measured memory_bytes: 3008
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <random>
#define INF 1000000007
using namespace std;

int main(void){
	int n;
	cin >> n;
	int base=0,temp=n;
	while(temp){
		base+=temp%10;
		temp/=10;
	}
	cout << (n%base==0?"Yes":"No") << endl;
	return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

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

    int n,m;
    cin>>n>>m;

    int correct = 0;
    int penalties = 0;

    vector<int> ac(n + 1);
    vector<int> pen(n + 1);

    for(int i = 0; i < m; i++) {
        int x;
        cin>>x;
        string s;
        cin>>s;

        if(s[0] == 'A') {
            ac[x]++;
            if(ac[x] == 1) {
                correct++;
                penalties += pen[x];
            }
        } else {
            pen[x]++;
        }
    }

    cout<<correct<<" "<<penalties<<endl;

    


}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int rec(int v, vector<vector<int>> &G, vector<int> &dp) {
    if(dp[v] != -1)
        return dp[v];
    if(G[v].size() == 0) {
        return dp[v] = 0;
    }
    int res = 0;
    for(auto nv : G[v]) {
        res = max(rec(nv, G, dp) + 1, res);
    }
    return dp[v] = res;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
    }
    vector<int> dp(N, -1);
    int res = 0;
    rep(i, N) { res = max(res, rec(i, G, dp)); }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11708
#include<stdio.h>
int main()
{
    long long a,b,sum=0;
    scanf("%lld%lld",&a,&b);
    sum=(a+b)/2;
    if(a+b==2*sum)
        printf("%lld\n",sum);
    else
        printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
const ll p = 1e9+7;
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
class dsu{
    public:
    unordered_map<int,int> p,sz;
    void make_set(int x)
    {
        p[x] = x;
        sz[x]+=1;
    }
    int find(int x)
    {
        if(x == p[x])return x;
        return p[x] = find(p[x]);
    }
    void merge(int a,int b)
    {
        a = find(a);
        b = find(b);
        if(a == b)return;
        if(sz[a]<sz[b])swap(a,b);
        p[b] = a;
        sz[a]+=sz[b];
        sz.erase(b);
    }
};
ll power(ll x,ll y){
    ll res = 1;
    
    while(y>0){
        if(y&1)res = (res*x);
        y>>=1;
        x = (x*x);
    }
    return res;
}

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}


int kmp(string s){
    vector<int> lps(s.size(),0);
    for(int i = 1; i<lps.size(); ++i){
        int prev_index = lps[i-1];
        while(prev_index>0&&s[i]!=s[prev_index]){
            prev_index = lps[prev_index-1];
        }
        lps[i] = prev_index+(s[i] == s[prev_index]?1:0);
    }
    return lps[lps.size()-1];
}
ll modi(ll x,ll y){
    return power(x,y-2,y);
}

int main()
{
    fastio();
    int n;
    ll k,m;
    cin>>n>>k;
    vector<int> a(n+1);
    for(int i = 1; i<=n; i++)cin>>a[i];
    if(k<=n){
        int ans = 1;
        while(k>0){
            ans = a[ans];
            k-=1;
        }
        cout<<ans<<"\n";
    }
    else{
        map<int,int> mp;
        int cycle,ans;
        ll count = 0;
        int i = 1;
        while(true){
            if(mp.find(a[i])!=mp.end()){
                ans = a[i];
                cycle = ++count-mp[a[i]];
                break;
            }
            mp[a[i]] = ++count;
            i = a[i];
        }
        k-=count;
        k%=cycle;
        while(k>0){
            ans = a[ans];
            k-=1;
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 11228
// https://atcoder.jp/contests/abc125/tasks/abc125_c

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

// マイナスの個数が奇数の場合、右端か左端の片方がマイナスになり、他はプラス
// 上記以外の場合、全部プラス
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, ans = 0, minusCnt = 0, minv = INF;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += abs(a[i]);
        minv = min(minv, abs(a[i]));
        if (a[i] < 0) {
            minusCnt++;
        }
    }

    if (minusCnt % 2 != 0) {
        ans -= 2 * minv;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> pae(n);

	int i, j, x, y;
	for (i = 0; i < k; i++) {
		cin >> x;
		for (j = 0; j < x; j++) {
			cin >> y;
			pae[y - 1] = 1;
		}
	}
	x = 0;
	for (i = 0; i < n; i++) {
		x += pae[i];
	}
	x = n - x;

	cout << x << endl;
	return 0;

}

Measured memory_bytes: 3624
n,p=map(int,input().split())

if n==1:
    print(p)
    exit()

def prime_fact(x):
    fact=[]
    for i in range(2, int(x**(0.5))+1):
        while x%i==0:
            fact.append(i)
            x//=i
    if x!=1:
        fact.append(x)
    if not fact:
        fact=[x]
    return fact

l=prime_fact(p)

from collections import Counter
c=Counter(l)
ans=1
for key in c:
    fa=c[key]//n
    if fa>=1:
        ans*=key**fa
print(ans)


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

int main(){
  int n,m;
  cin >> n >> m;
  
  vector<vector<int>> city(m, vector<int>(2));
  for(int i=0; i<m; i++){
    for(int j=0; j<2; j++){
      cin >> city.at(i).at(j);
    }
  }
  
  vector<int> num(n,0);
  for (int i=0; i<m; i++){
    for (int j=0; j<2; j++){
      num.at(city.at(i).at(j)-1)++;
    }
  }
  
  for (int i=0; i<n; i++){
    cout << num.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
using namespace std;
int N;							//number of tosses
int n;							// N/2
double heads;					//probability of heads
double tails;
vector <double> current;	//current number of values

int main(){
	cin>>N;
	n=N/2;

	current.resize(n+1,0);
	current[0]=1;

	for(int i=1;i<=N;i++){
		cin>>heads;
		tails = 1-heads;
		for(int j=min(n,i);j>=1;j--){
			current[j] = current[j-1]*tails + current[j]*heads;
		}
		current[0] = current[0]*heads;
	}

	double pro=0;
	for(int i=0;i<=n;i++)
		pro += current[i];
	printf("%0.10lf\n",pro);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, MOD = 1e9 + 7;
int ex1[N], ex2[N], les1[N], les2[N], a[N], b[N];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &a[i]);
		les1[i] = a[i];
		if (a[i] > a[i - 1]) ex1[i] = a[i];
	}
	for (int i = 1; i <= n; ++ i) scanf("%d", &b[i]);
	for (int i = n; i >= 1; -- i) {
		les2[i] = b[i];
		if (b[i] > b[i + 1]) ex2[i] = b[i];
	}
	int ans = 1;
	for (int i = 1; i <= n; ++ i) {
		if (ex1[i] && ex2[i] && ex1[i] != ex2[i]) {
			ans = 0;
			break;
		}
		if (!ex1[i] && !ex2[i]) ans = 1LL * ans * min(les1[i], les2[i]) % MOD; else {
			if (max(ex1[i], ex2[i]) > min(les1[i], les2[i])) {
				ans = 0;
				break;
			}
		}
	}
	printf("%d\n", ans);
}



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

X = INT()

for i in range(-205, 205):
	for j in range(-205, 205):
		if i**5-j**5 == X:
			print(i, j)
			exit()


Measured memory_bytes: 10616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] temp = br.readLine().split("\\s");

		int over = Integer.parseInt(temp[0]);
		int before = Integer.parseInt(temp[1]);
		int after = Integer.parseInt(temp[2]);
		int safe_line = before + over + 1;
		int day = before + after;

		if (day < safe_line) {
			System.out.println("delicious");
		} else {
			if (over < -before + after) {
				System.out.println("dangerous");
			} else {
				System.out.println("safe");
			}
		}
	}
}


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

div = 1
pairs = [[0] * 10 for i in range(10)]

for i in range(1,N+1):
    if i // div >= 10:
        div *= 10
        f = 1
    else:
        f = i//div
    pairs[f][i%10] += 1

res = 0
for i in range(1, 10):
    for j in range(1, 10):
        res += pairs[i][j] * pairs[j][i]
print(res)

Measured memory_bytes: 3064
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A_AC.exe A_AC.cpp 
Execute: ./A_AC
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	char S[3]; 
	
	cin >> S; 
	
	if( strcmp(S,"ABC") == 0 ) { 
		cout << "ARC" << endl; 
	} else { 
		cout << "ABC" << endl; 
	}
	
	return 0; 
} 


Measured memory_bytes: 3680
N = int(input())
h = list(map(int, input().split()))

dp= [0] * N

dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
    
print(dp[N-1])

Measured memory_bytes: 20616
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    int p[5] = {3,5,7,11,13};
    int ans = 0;
    for(int i = 0; i<5; ++i){
        for(int j = i+1; j<5; ++j){
            for(int k = j+1; k<5; ++k)if(p[i]*p[j]*p[k]<=n)ans++;
        }
    }
    if(n>=135)ans++; if(n>=189)ans++;
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 256
/*  UntilDeathDoesUsApart
    DO   NOT   GIVE   UP!
*/

#include <bits/stdc++.h>

using namespace std;

#define inc(a)           a.begin(), a.end()
#define dec(a)           a.rbegin(), a.rend()
#define Unique(n)        (n).erase(unique(in(n)), (n).end())
#define what_is(x)       cerr << #x << " is " << x << '\n';
#define to(i, a, n)      for(int i=a; i<n; i++)
#define fr(i, a, n)      for(int i=a; i>=n; i--)
#define read(arr, l, r)  for(int i=l; i<r; cin >> arr[i++])
#define prnt(arr, l, r)  for(int i=l; i<r; cout << arr[i++] << " \n"[i==r])

typedef long long ll;
typedef long double ld;

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

    int n; cin >> n;
    n %= 10;

    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout << "hon";
    else if(!n || n==1 || n==6 || n==8)
        cout << "pon";
    else cout << "bon";

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		sc.close();
		
		//3つの数の値の和で条件分岐
		int check = A + B + C;
		if(check <= 21) {
			System.out.println("win");
		}else {
			System.out.println("bust");
		}
	}
}

Measured memory_bytes: 21972
use std::io;
use std::cmp::Ordering;

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split(' ').flat_map(str::parse).collect()
}

fn main() {
    loop {
        let l1 = read::<i32>();
    
        let x = l1[0];
        let y = l1[1];

        if x == 0 && y == 0 {
            break
        }

        let (a, b) = match x.cmp(&y) {
            Ordering::Greater => (y, x),
            _ => (x, y)
        };

        println!("{} {}", a, b);
    }
}



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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, c;
  cin >> n >> c;
  
  vector<ll> x(n), v(n);
  for(int i = 0; i < n; i++) cin >> x.at(i) >> v.at(i);
  
  ll ans = 0, keep = 0;
  // 時計回りのみ
  for(int i = 0; i < n; i++){
    keep += v.at(i);
    ans = max(ans, keep - x.at(i));
  }
  // 反時計回りのみ
  keep = 0;
  for(int i = n - 1; i >= 0; i--){
    keep += v.at(i);
    ans = max(ans, keep - (c - x.at(i)));
  }
  
  // 反時計->時計
  vector<ll> benefit(n);
  benefit.at(0) = v.at(0) - x.at(0);
  for(int i = 1; i < n; i++){
    benefit.at(i) = benefit.at(i - 1) + v.at(i) - (x.at(i) - x.at(i - 1));
  }
  for(int i = 1; i < n; i++){
    benefit.at(i) = max(benefit.at(i), benefit.at(i - 1));
  }
  keep = 0;
  for(int i = n - 1; i > 0; i--){
    keep += v.at(i);
    ans = max(ans, keep - (c - x.at(i)) * 2 + benefit.at(i - 1));
  }
  
  // 時計->反時計
  vector<ll> benefit2(n);
  benefit2.at(n - 1) = v.at(n - 1) - (c - x.at(n - 1));
  for(int i = n - 2; i >= 0; i--){
    benefit2.at(i) = benefit2.at(i + 1) + v.at(i) - (x.at(i + 1) - x.at(i));
  }
  for(int i = n - 2; i >= 0; i--){
    benefit2.at(i) = max(benefit2.at(i), benefit2.at(i + 1));
  }
  keep = 0;
  for(int i = 0; i < n - 1; i++){
    keep += v.at(i);
    ans = max(ans, keep - x.at(i) * 2 + benefit2.at(i + 1));
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

vector<int>res;
vector<vector<int>>c;
map<P, int>mp;
vector<bool>f;

void dfs(int v ,int p,int pc){
	int color = 1;
	
	if (pc == color)color++;
	//cout << color << endl;
	//cout << v << endl;
	for (auto e : c[v]) {
		if (!f[e]) {
			f[e] = true;
		}
		else {
			continue;
		}
		if (v >= e)swap(v, e);
		P p = make_pair(v, e); 
		//cout << color << endl;
		mp[p] = color;
		dfs(e, v, color);
		color++;
		if (color == pc)color++;
	}
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n-1), b(n-1);
	c.resize(n);
	res.resize(n - 1, -1);
	f.resize(n, false);
	rep(i, n - 1) {
		int p, q;
		cin >> p >> q;
		p--, q--;
		a[i] = p; b[i] = q;
		c[p].push_back(q);
		c[q].push_back(p);
	}
	int m(0);
	f[0] = true;
	rep(i, n) {
		int k = c[i].size();
		m = max(m, k);
	}
	cout << m << endl;
	dfs(0, -1, -1);
	rep(i, n - 1) {
		int aa = a[i]; 
		int bb = b[i];
		if (aa >= bb)swap(aa, bb);
		P p = make_pair(aa,bb);
		cout << mp[p] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 17064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;

vector<ll> fact;

ll mypow(ll a, ll x)
{
	ll res = 1;
	while (x)
	{
		if (x & 1)
			res = (res * a) % mod;
		a = a * a % mod;
		x /= 2;

	}
	return res;
}

ll c(ll n, ll k)
{
	return fact[n] % mod * mypow(fact[k], mod - 2) % mod * mypow(fact[n - k], mod - 2) % mod;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ll r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	fact.resize(r2 + c2 + 2);
	fact[0] = 1;
	fact[1] = 1;
	for (int i = 2; i < sz(fact); i++)
	{
		fact[i] = fact[i - 1] * ll(i) % mod;
	}
	ll res = 0;
	for (int r = r1; r <= r2; r++)
	{
		res += c(c2 + r + 1, r + 1) - c(c1 + r, r + 1);
		if (res < 0)
			res += mod;
		res = res % mod;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
int a[10000];
int main(){
	int k;
	cin>>n>>k;
	for (int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	long long ans=0;
	for (int i=1;i<=k;i++)ans+=(long long)a[i];
	cout<<ans<<endl;
}



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

int main(){
    int k, s;
    cin >> k >> s;
    int count = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s - x - y;
            if(z >= 0 && z <= k) count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [list(input()) for _ in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    if s[i][0] == 'A':
        ac += 1
    elif s[i][0] == 'W':
        wa += 1
    elif s[i][0] == 'T':
        tle += 1
    elif s[i][0] == 'R':
        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: 19228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];

  int ans = 0;

  rep(i,n-2) FOR(j,i+1, n-1) FOR(k,j+1,n){
    int a = l[i];
    int b = l[j];
    int c = l[k];
    if(a == b || b == c || c == a) continue;
    if(abs(a-b) < c && abs(a+b)>c){
      ans++;
    }

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
	"strings"
)

func main() {
	var S string
	fmt.Scan(&S)
	S = reverse(S)
	words := []string{reverse("dream"), reverse("dreamer"), reverse("erase"), reverse("eraser")}
	ans := true
	for 0 < len(S) {
		ok := false
		for _, word := range words {
			if strings.HasPrefix(S, word) {
				ok = true
				S = S[len(word):]
				break
			}
		}
		if !ok {
			ans = false
			break
		}
	}

	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());

        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());

        int menseki=a*b;
		int gaisyu=2*(a+b);

		System.out.print(menseki);
		System.out.println(" "+gaisyu);

	}

}



Measured memory_bytes: 24176
#include <stdio.h>
#define N 1000000
int main()
{

  int i, j, num=0, n, q, key;
  int S[N], T[N];
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++)
    {
      scanf("%d",&T[i]);
    }

  for(i = 0 ; i < q ; i++)
    {
      key = T[i];
  for(j = 0 ; j < n ; j++)
    {
      if(key == S[j]){
	num++;
	break;
      }
    }

  }
    
      printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 2688
import std.stdio;

void main(){
	auto cin = new Cin();
	
	auto N = cin.line()[0];
	auto arr = cin.rect!(real)()[0];
	//writeln(S);
	auto ave = arr.ave().rint();
	
	
	long cost;
	
	foreach( elm ; arr ){
		cost += cast(long)(elm-ave)^^2;
	}
	
	//ave.writeln();
	cost.writeln();
	//(ave).writeln();
}
auto solve(){
}
unittest{
	
}


import std.stdio,std.conv,std.string;
import std.algorithm,std.array,std.math;

class Cin
{
	T[] line( T = size_t , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = size_t , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][](m);
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
}

pure T[] span(T)( in T begein , in T end , in T step = 1 ){
	assert( begin < end );
	assert( 0 < step );
	T[] arr;
	for( T i = begein ; i < end ; i += step ){
		arr ~= i;
	}
	return arr;
}

pure T[] map(T)( ref T[] args , T delegate(T)  dlg ){
	foreach( ref arg ; args ){
		arg.dlg();
	}
	return args;
}
pure T sum(T)( in T[] args ){
	T result = 0;
	foreach( arg ; args ){
		result += arg;
	}
	debug writeln( args , "\n" , arg );
	return result;
}
pure T ave(T)( in T[] args ){
	return args.sum()/args.length;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	char s[n+1];
	scanf("%s", s);

	int ans = 0;
	REP(i, 0, 1000){
		int ps[3], pos = 0;
		ps[2] = i%10;
		ps[1] = i/10%10;
		ps[0] = i/100;
		REP(j, 0, n){
			if(pos>2) break;
			if(s[j]-'0'==ps[pos]) pos++;
		}
		if(pos>2) ans++;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3808
import collections
n = int(input())
v_ls = list(map(int, input().split()))

v_ls0 = [0] * (n//2)
v_ls1 = [0] * (n//2)
for i in range(n):
    if i % 2 == 0:
        v_ls0[i//2] = v_ls[i]
    else:
        v_ls1[i//2] = v_ls[i]
counter0 = collections.Counter(v_ls0)
counter1 = collections.Counter(v_ls1)
value01, count01 = counter0.most_common(2)[0]
if len(counter0.most_common(2)) == 1:
    value02, count02 = 0,0
else:   
    value02, count02 = counter0.most_common(2)[1]
value11, count11 = counter1.most_common(2)[0]
if len(counter1.most_common(2)) == 1:
    value12, count12 = 0,0
else:
    value12, count12 = counter1.most_common(2)[1]

if value01 != value11:
    ans = n - count01 - count11
else:
    # v_ls0を最頻値で置き換える
    ans = n - count01 - count12
    ans = min(ans, n - count11 - count02)
print(ans)



Measured memory_bytes: 19040
N = int(input())
S = input()
r = g =  b = 0
for s in S:
    if s == 'R':
        r += 1
    elif s == 'G':
        g += 1
    else:
        b += 1

double = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = (j - i) * 2 + i
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            double += 1
print(r * g * b - double)

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

int isPrime(int num){
    int i;
    if(num<=1) return 0;

    else if(num==2) return 1;
    if(num%2==0) return 0;
    for(i=3;i<=sqrt(static_cast<double>(num));i+=2){
            if(num%i==0) return 0;
        }
    return 1;
}

int main(){
    const int max=10000;
    int i,size,A[max],count=0;
    cin >> size;
    for(i=0;i<size;++i){
        cin >> A[i];
        if(isPrime(A[i]))++count;
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 1196
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

int main ( ){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll a,b;
    cin >>a;
    ll x=1,y=a;
    for (ll i = 2; i *i<=a ; ++i) {
        if(a%i==0){
            x=i;
            y=a/i;
        }
    }
    cout << (x+y-2);
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n >= 18){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = 0; i <= 4; i++){
        for(int j = 0; j <= 2; j++){
            if(i * 4 + j * 7 == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m, q, ans = 0;
vector<ll> a, b, c, d;

void dfs(vector<int> x) {
  if (x.size() == n) {
    ll tmp = 0;
    for (int i = 0; i < q; i++) {
      if (x[b[i] - 1] - x[a[i] - 1] == c[i]) tmp += d[i];
    }
    ans = max(ans, tmp);
    return;
  }

  x.push_back(x.back());
  while (x.back() <= m) {
    dfs(x);
    x.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<ll>(q);
  for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  for (int i = 1; i <= m; i++) dfs(vector<int>(1, i));
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int X,A,B,C,count=0;
    std::cin >> A >> B >> C >> X;
    for(int i=0;i<=C;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=A;k++){
                if(500*k+100*j+50*i==X){
                    count++;
                }
            }
        }
    }
    
    std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstring>
#include <string>
using namespace std;
int main()
{
    int N,i,total=0;
    string S;
    cin>>N;
    cout<<endl;
    cin>>S;
for(i=0;i + 2<N; i++) {
              if(((char)S[i]=='A')&&((char)S[i+1]=='B')&&((char)S[i+2]=='C') ) {
                        total++;
                        i=i+2;}
    }
    cout<<total;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 

 
struct Dinic {
  struct edge {
    int to, cap, rever;
    edge(int to, int cap, int rever):to(to), cap(cap), rever(rever){}
  };
  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int V):graph(V), level(V), iter(V){}
  void add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
  }
  void bfs(int s) {
    fill(all(level), -1);
    queue<int> que;
    level[s] = 0;
    que.push(0);
    while(que.size()) {
      int v = que.front(); que.pop();
      for(edge& e : graph[v]) {
        if(e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int& i = iter[v]; i < graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
        int d = dfs(e.to, t, min(e.cap, f));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rever].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    while(true) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(all(iter), 0);
      int f; while((f = dfs(s, t, inf)) > 0) flow += f;
    }
  }
}; 

int main(){
    ll n;cin >> n;
    Dinic dn(2*n+2);
    ll s=0,t=2*n+1;
    vpl a(n),b(n);
    rep(i,n){
        cin  >> a[i].fi >> a[i].se;
    }
    rep(i,n){
        cin  >> b[i].fi >> b[i].se;
    }
    rep(i,n){
        dn.add_edge(s,i+1,1);
        dn.add_edge(i+1+n,t,1);
    }
    rep(i,n){
        rep(j,n){
            if(a[i].fi<b[j].fi&&a[i].se<b[j].se){
                dn.add_edge(i+1,n+1+j,1);
            }
        }
    }
    cout << dn.max_flow(s,t) <<endl;
}

Measured memory_bytes: 3704
n=int(input())
a=input().split()
a=list(map(int,a))
for j in range(1000000000):
    count=0
    for i in range(n):
        if a[i]%2!=0:
            break
        if a[i]%2==0:
            a[i]=a[i]/2
            count+=1
    if count!=n:
        break        
print(j)
        


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	int n, p;
	while (cin >> n >> p, n or p){
		int c = p, s[n], M = 1;
		for (int i = 0; i < n; ++i) s[i] = 0;
		while (M){
			for (int i = 0; i < n; ++i){
				if (c){
					c--;
					s[i]++;
					if (s[i] == p){
						cout << i << endl;
						M = 0;
						break;
					}
				}else{
					c += s[i];
					s[i] = 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3012
#include <iostream>

using namespace std;

// Using while loop to solve this time

int main(int argc, char const *argv[])
{
    long long base = 100;
    // Other people don't include this interest variable
    double interest = 0.01;
    long long years = 0;

    long long target; //103
    cin >> target;

    // How many years it take to get to or above target;

    while (true)
    {
        if (base >= target)
        {
            cout << years << "\n";
            return 0;
        }
        base += base * interest;
        ++years;
    }
    return 0;
}


Measured memory_bytes: 3180
import numpy as np
import math
from sys import stdin


def get_result(data):
    A, B, H, M = data
    h_deg = (H + M/60.0) * 30.0
    m_deg = M * 6.0
    theta = math.radians(abs(m_deg-h_deg))
    ans = np.sqrt(np.float128(A**2+B**2 - 2*A*B*math.cos(theta)))
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 27200
from sys import stdin, stdout
s = input()
n = len(s)


if len(s) <= 3:
    print(0)
    exit()

suffix_rems = [-1]*n
suffix_rems[-1] = int(s[-1])
suffix_rems[-2] = int(s[-2:])
suffix_rems[-3] = int(s[-3:])

rems_d = dict()
rems_d[0] = 1
rems_d[int(s[-1])] = 1
rems_d[int(s[-2:])] = 1
rems_d[int(s[-3:])] = 1

special_keys = set()
for i in range(n-3)[::-1]:
    rem = (pow(10, n-i-1, 2019) * int(s[i]) + suffix_rems[i + 1])%2019

    if rem in rems_d:
        rems_d[rem] += 1
        special_keys.add(rem)
    else:
        rems_d[rem] = 1

    suffix_rems[i] = rem

ans = 0
for key in special_keys:
    t = rems_d[key]
    ans += (t*(t-1))//2

print(ans)

Measured memory_bytes: 70272
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    
    ll x; cin >> x;
    ll sum = 100 , cnt=0;
    while(sum<x){
        sum += sum/100;
        cnt++;
    }
    cout << cnt;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3596