akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k, r, s, p;
  vector<int> ans_r(n + k), ans_s(n + k), ans_p(n + k);
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  for (int i = 0; i < n; i++) {
    if (t[i] == 'r') {
      ans_p[i + k] = max(ans_r[i], ans_s[i]) + p;
      ans_r[i + k] = max(ans_s[i], ans_p[i]);
      ans_s[i + k] = max(ans_p[i], ans_r[i]);
    } else if (t[i] == 's') {
      ans_r[i + k] = max(ans_s[i], ans_p[i]) + r;
      ans_s[i + k] = max(ans_p[i], ans_r[i]);
      ans_p[i + k] = max(ans_r[i], ans_s[i]);
    } else {
      ans_s[i + k] = max(ans_p[i], ans_r[i]) + s;
      ans_p[i + k] = max(ans_r[i], ans_s[i]);
      ans_r[i + k] = max(ans_s[i], ans_p[i]);
    }
  }
  int ans = 0;
  for (int i = n; i < n + k; i++) {
    ans += max(ans_r[i], max(ans_s[i], ans_p[i]));
  }
  cout << ans << endl;
}


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

typedef long long ll;
ll n, a, b;
int main()
{
	ll i;
	cin >> n >> a >> b;
	if (b - a <= 2) {
		cout << n + 1;
	} else {
		if (n < a + 1) {
			cout << n + 1;
		} else {
			cout << b + (b - a) * ((n - a - 1) / 2) + (n - a + 1) % 2;
		}
	}
    return 0;
}


Measured memory_bytes: 256
import java.io.File

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

var n: Int = 0

fun main(args: Array<String>) {
    val n = readInt()
    val a = readInts()

    val num = IntArray(n) {0}
    (0 until n).forEach {
        num[a[it] - 1]++
    }
    val t:Long = num.filter { it > 1 }.map { it * (it - 1L) / 2L }.sum()

    println(a.map {
        val x = num[it - 1]
        if (x > 1) {
            t - (x * (x - 1) / 2) + ((x - 1) * (x - 2) / 2)
        } else {
            t
        }
    }.joinToString("\n"))
}


Measured memory_bytes: 100592
#include <stdio.h>

#define MIN(x,y) ((x)<(y)?(x):(y))

typedef long long int ll;

int a[2000];

int dp[2000];
ll dp2[2];

int main(){
  int n, x, i, j;
  scanf("%d%d", &n, &x);
  for(i=0;i<n;i++){
    scanf("%d", a+i);
    dp2[0] += dp[i] = a[i];
  }

  for(j=1;j<n;j++){
    int b = j&1;
    dp2[b] = (ll) j*x;
    for(i=0;i<n;i++){
      int k = i + n - j;
      if(k >= n) k -= n;
      dp2[b] += dp[i] = MIN(dp[i], a[k]);
    }
    dp2[b] = MIN(dp2[b^1], dp2[b]);
  }

  printf("%lld\n", dp2[~n&1]);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;

LL a, b;

LL Get(LL x)
{
	if (x <= 0) return 0;
	if (x & 1) return ((x + 1) >> 1 & 1);
	return Get(x + 1) ^ (x + 1);
}

int main()
{
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", Get(a - 1) ^ Get(b));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int h,m,s;
	int sum;
	
	scanf("%d",&sum);
	
	h=sum/3600;
	
	m=(sum-h*3600)/60;
	
	s=(sum-h*3600-m*60);
	
	printf("%d:%d:%d\n",h,m,s);
	
	return(0);
	
}

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

const int N_MAX = 300000;
int W[N_MAX];
int E[N_MAX];

int main() {
	int n;
	string s;
	cin >> n >> s;
	int w = 0;
	for(int i=0;i<n;i++) {
		W[i] = w;
		if(s[i] == 'W') w++;
	}
	int e = 0;
	for(int i=n-1;i>=0;i--) {
		E[i] = e;
		if(s[i] == 'E') e++;
	}
	int m = N_MAX+1;
	for(int i=0;i<n;i++) {
		if(m > W[i] + E[i]) m = W[i] + E[i];
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 3076
# D - Christmas
import sys
sys.setrecursionlimit(10**7)

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

burger = [[0, 0] for _ in range(N)]
burger[0] = [1, 1]

for i in range(1, N):
    burger[i][0] = burger[i-1][0] * 2 + 3
    burger[i][1] = burger[i-1][1] * 2 + 1

ans = 0
while True:
    if N == 0:
        if X > 0:
            ans += 1
        break
    if X > burger[N-1][0]+2:
        ans += burger[N-1][1] + 1
        X -= burger[N-1][0]+2
        N -= 1
    elif X == burger[N-1][0]+2:
        ans += burger[N-1][1] + 1
        break
    elif X < burger[N-1][0]+2:
        X -= 1
        N -= 1
print(ans)

Measured memory_bytes: 3064
#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>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#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 shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

bool compare(vl x, vl y){
  return sz(x) > sz(y);
}

ll a[200],b[200],c[200],d[200];
ll n;

ll getMaxPair(vector<vl> v){
  sort(all(v),compare);

  ll pivot = -1;
  F0R(i,v.size()){
    if(v[i].size() == 1){
      pivot = i;
      break;
    }

  }
  if(pivot != -1) v.resize(pivot);
  if(v.size() == 0) return 0;

  //generate vr
  vector<vl> vr;
  F0R(i,n){
    vl temp;
    vr.pb(temp);
  }
  F0R(i,v.size()){
    FOR(j,1,v[i].size()){
      vr[v[i][j]].pb(v[i][0]);
    }
  }
  //end

  ll rp = v[v.size()-1][0];
  ll bp = -1;
  ll mnPeer = INF;

  FOR(i,1,v[v.size()-1].size()){
    if(mnPeer > vr[v[v.size()-1][i]].size()){
      mnPeer = vr[v[v.size()-1][i]].size();
      bp = v[v.size()-1][i];
    }
  }
  v.erase(v.begin()+v.size()-1);
  F0R(i,v.size()){
    FOR(j,1,v[i].size()){
      if(v[i][j] == bp) {v[i].erase(v[i].begin()+j);break;}
    }
  }
  return 1 + getMaxPair(v);
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    cin >> n;
    F0R(i,n) cin >> a[i] >> b[i];
    F0R(i,n) cin >> c[i] >> d[i];
    vector<vl> v;
    F0R(i,n){
      vl nw;nw.pb(i);
      v.pb(nw);
      F0R(j,n){
        if(c[i] >a[j] && d[i] > b[j])
          v[i].pb(j);
      }
    }

    ll ans = getMaxPair(v);

    cout << ans << endl;



    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 2560
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
import fractions
#gcd=fractions.gcd
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
show_flg=False
show_flg=True
def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

ans=0

n,k=LI()
a=LI()
ac=[0]
for i in range(n):
    ac.append(ac[-1]+a[i])

X=43
v=[]
for l in range(n):
    for r in range(l+1,n+1):
        t=ac[r]-ac[l]
        s=[1 if t&(1<<i) else 0 for i in range(X)]
        v.append(s)
#v=sorted(v)[::-1]

#ans=v[0]
for i in range(X-1,-1,-1):
    nx=[]
    for j in v:
        if j[i]==1:
            nx.append(j)
    if len(nx)>=k:
        ans+=(1<<i)
        v=[l for l in nx]
    else:
        0
    
print(ans)


Measured memory_bytes: 270792
#include <stdio.h>
int main(void){
   int n,i,ans=0,m=0;
   scanf("%d",&n);
   int a[n];
   for(i=0;i<n;i++){
       scanf("%d",&a[i]);
   }
   for(i=0;i<n-1;i++){
      if(m==1&&a[i]>a[i+1]){
          ans+=1;
          m=0;
      }
      else if(m==-1&&a[i]<a[i+1]){
          ans+=1;
          m=0;
      }
      else if(m==0){
           if(a[i]<a[i+1])
           m=1;
           else if(a[i]>a[i+1])
           m=-1;
       }
   }
   printf("%d\n",ans+1);
   return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

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

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

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

    int sum = 0;
    rep(i, m){
        int a;
        cin >> a;

        sum += a;
    }

    if(sum > n){
        cout << -1 << endl;
    }else{
        cout << n- sum << endl;
    }


    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define vl vector<long long int>
#define vvl vector<vector<ll> > 
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b)  for(int i=b;i>=a;i--)
using namespace std;
ll mod=1000000007;

int main()
{
    ll n,w;cin>>n>>w;
    ll ww[n],vv[n];
    fo(i,0,n)
        cin>>ww[i]>>vv[i];
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    fo(i,0,n)
        dp[0][i]=dp[i][0]=0;
    fo(i,1,n+1)
    {
        fo(j,1,w+1)
        {
            if(ww[i-1]<=j)
                dp[i][j] = max(dp[i-1][j],vv[i-1]+dp[i-1][j-ww[i-1]]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][w];
}



Measured memory_bytes: 82484
n, k = [int(i) for i in input().split()]
if n % k  == 0:
    print(0)
elif n < k:
    print(min(n, k-n))
else:
    n = n - int(n//k) * k
    n = min(abs(n-k), n)
    n = min(abs(n-k), n)
    print(n)

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
 
template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e5 + 5;
const int mod = 1e9 + 7;

int solve(int a,int b,int c){
	
	a = a % c;	
	if(b == 0) return 1;
	else if((b % 2) == 0) return solve((a * a) % c,b / 2,c) % c;
	else return (a * solve((a * a) % c,b / 2,c) % c) % c;
}

int n;
double dp[3005][3005];
bool vis[3005][3005];
double fun(int index,double* arr,int heads){
	
	if(index < 0){
		if(heads > n / 2) return 1.0;
		return 0.0;
	}
	
	if(vis[index][heads] == true) return dp[index][heads];
	double ans1 = fun(index - 1,arr, heads + 1) * arr[index];
	double ans2 = fun(index - 1,arr, heads) * (1 - arr[index]);
	double ans = ans1 + ans2;
	dp[index][heads] = ans;
	vis[index][heads] = true;
	return ans;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
		
	double prob[n];
	for(int i = 0; i < n; ++i) cin >> prob[i];
	
	memset(dp,0, sizeof(dp));
	memset(vis,false,sizeof(vis));
	cout.setf(ios::fixed);
	cout << setprecision(10) << fun(n - 1,prob,0);
	
	return 0;
}


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

namespace {
  template<class T>constexpr T gcd(T a, T b) {return b == 0 ? a : gcd(b, a % b);}
}

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c % gcd(a, b) == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
S=list(input())

ans = "Yes"
for i in range(len(S)):
    if i %2 ==0:
        if S[i]=="L":  
            ans = "No"
            break
    if i %2 != 0:
        if S[i]=="R":
            ans = "No"
            break
        
print(ans)


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

template <uint32_t mod>
class Modular {
private:
    uint32_t n;

public:
    Modular(int64_t _n = 0) : n((_n >= 0 ? _n : mod - (-_n) % mod) % mod) {}

    uint32_t get() const {
        return n;
    }

    bool operator==(const Modular &o) const {
        return n == o.n;
    }

    bool operator!=(const Modular &o) const {
        return n != o.n;
    }

    Modular& operator+=(const Modular &o) {
        n += o.n;
        n = (n < mod ? n : n - mod);
        return *this; 
    }

    Modular& operator-=(const Modular &o) {
        n += mod - o.n;
        n = (n < mod ? n : n - mod);
        return *this;
    }

    Modular& operator*=(const Modular &o) {
        n = uint64_t(n) * o.n % mod;
        return *this;
    }

    Modular& operator/=(const Modular &o) {
        return (*this) *= o.inv();
    }

    Modular operator+(const Modular &o) const {
        return Modular(*this) += o;
    }

    Modular operator-(const Modular &o) const {
        return Modular(*this) -= o;
    }

    Modular operator*(const Modular &o) const {
        return Modular(*this) *= o;
    }

    Modular operator/(const Modular &o) const {
        return Modular(*this) /= o;
    }

    Modular pow(uint64_t b) const {
        Modular ans(1), m = Modular(*this);
        while (b) {
            if (b & 1) {
                ans *= m;
            }
            m *= m;
            b >>= 1;
        }
        return ans;
    }

    Modular inv() const {
        int32_t a = n, b = mod, u = 0, v = 1;
        while (a) {
            int32_t t = b / a;
            b -= t * a;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        assert(b == 1);
        return Modular(u);
    }

    friend string to_string(const Modular &m) {
        return to_string(m.get());
    }
};

using Mint = Modular<int(1e9 + 7)>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> X(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> X[i];
    }
    Mint ans = 0;
    Mint mul = 0;
    for (int i = 2; i <= n; ++i) {
        mul += Mint(1) / Mint(i - 1);
        ans += Mint(X[i] - X[i - 1]) * mul;
    }
    for (int i = 1; i < n; ++i) {
        ans *= i;
    }
    cout << ans.get() << "\n";
    return 0;
}



Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  bool cond = false;
  for (int i = 0; i <= X; ++i) {
    if ( i * 2 + (X-i)*4 == Y) cond = true;
  }
  cout << (cond?"Yes":"No") << endl;
}


Measured memory_bytes: 3636
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [String; n],
        b: [String; m]
    };

    let mut exists = 0;
    for h in 0..n {
        if h + m > n {
            break;
        }
        for w in 0..n {
            if w + m > n {
                break;
            }
            let mut ok = 1;
            for i in 0..m {
                if &a[h + i][w .. w + m] != &b[i] {
                    ok = 0;
                }
            }

            exists += ok;
        }
    }

    if exists > 0 {
        println!("Yes");
    }
    else {
        println!("No");
    }
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	vector<int> a;
	cin>>n;
	a.push_back(0);
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		a.push_back(x);
	}
	a.push_back(0);
	int total=0;
	for(int i=1;i<n+2;++i)
		total+=abs(a[i]-a[i-1]);
	for(int i=1;i<n+1;++i){
		int cost=total;
		cost-=abs(a[i]-a[i-1]);
		cost-=abs(a[i+1]-a[i]);
		cost+=abs(a[i+1]-a[i-1]);
		cout<<cost<<'\n';
	}
}



Measured memory_bytes: 3844
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[]a=new int[m],b=new int[m];
        for(int i=0;i<m;++i){
            a[i]=sc.nextInt()-1;
            b[i]=sc.nextInt()-1;
        }
        int ans=0;
        for(int i=0;i<m;++i){
            UnionFind u=new UnionFind(n);
            int con=n;
            for(int j=0;j<m;++j)
                if(i!=j)
                    if(u.root(a[j])!=u.root(b[j])){
                        u.unify(a[j],b[j]);
                        con--;
                    }
            if(con!=1)ans++;
        }
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
class UnionFind {
    int[] parent;
    int[] rank;
    UnionFind(int n) {
	this.parent = new int[n];
	this.rank = new int[n];
	this.clear();
    }
    void clear() {
	int n = this.parent.length;
	for (int i = 0; i < n; ++i) {
	    this.parent[i] = i;
	    this.rank[i] = 0;
	}
    }
    void unify(int x, int y) {
	int rootX = this.root(x);
	int rootY = this.root(y);
	if (rootX == rootY) {
	    return;
	}
	if (this.rank[rootX] < this.rank[rootY]) {
	    this.parent[rootX] = rootY;
	} else {
	    this.parent[rootY] = rootX;
	    if (this.rank[rootX] == this.rank[rootY]) {
		this.rank[rootX]++;
	    }
	}
    }
    int root(int x) {
	if (this.parent[x] == x) {
	    return x;
	}
	return this.parent[x] = this.root(this.parent[x]);
    }
}


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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           200005
#define ll            long long int
#define ldb           long double
#define forn(n)       for(int i=0 ; i<n ; i++)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const ll inf = LLONG_MAX;

ll power_mod(int a, int n, int mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll power(ll a,ll n){if(n==0){return 1;}ll p=power(a,n/2);p = (p * p);if (n%2==1){p=(p*a);}return p;}
int gcd(int a,int b){ return __gcd(a,b);}
int lcm(int a,int b){return a*b/__gcd(a,b);}
vector<vi> adj;
bool vis[mxn];

void run(ll test){

    ll n;
    cin >> n;
    ll a[n];

    ll maxi = 0;
    forn(n){
        cin >> a[i];
        maxi = max(a[i],maxi);
    }

    vi cnt(maxi+1,0);

    bool ok = 1;
    for(int i=n-1 ; i>=0 ; i--) {
        for(int j=2 ; j<=sqrt(a[i]) ; j++) {
            if(a[i]%j == 0) {
                if(cnt[j]) ok = 0;
                cnt[j]++;
                while(a[i]%j == 0) {
                    a[i]/=j;
                }
            }
        }
        if(a[i] > 2) {
            if(cnt[a[i]])
                ok = 0;
            cnt[a[i]]++;
        }
    }

    if(ok) {
        cout << "pairwise coprime";
        return ;
    }

    ok = 1;
    forn(maxi) {
        if(cnt[i] >= n) {
            ok = 0;
            break;
        }
    }

    if(ok) {
        cout << "setwise coprime";
        return ;
    }

    cout << "not coprime";

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        run(i);
        cout << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1,0);
  
  for(int i=1; i<105; i++){
    for(int j=1; j<105; j++){
      for(int k=1; k<105; k++){
        int count= i*i + j*j + k*k + i*j + j*k + k*i;;
        if(count <=N) a.at(count)++;
      }
    }
  }
  for(int i=1; i<=N; i++) cout << a[i] << endl;
}

Measured memory_bytes: 3568
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
l = list(set(l))
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    l.append(0)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
    for i in l:
      if i % min(l) != 0:break
    else:
      l[0] = min(l)
      break
  ans = l[0]
print(ans)

Measured memory_bytes: 14252
/**
* Author: Luis Alberto Herrera Gomez
* Tags: 
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ii;

int main()
{

    int N, K;

    cin >> N >> K;

    vi V(N);
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }

    int R = min(N, K);
    int max_total = 0;
    for (int a = 0; a <= R; ++a) {
        for (int b = 0; b <= R; ++b) {
            if (a + b > R)
                break;

            vi neg;
            int curr_total = 0;
            for (int i = 0; i < a; ++i) {
                curr_total += V[i];
                if (V[i] < 0)
                    neg.push_back(V[i]);
            }
            for (int i = 0; i < b; ++i) {
                curr_total += V[N - i - 1];
                if (V[N - i - 1] < 0)
                    neg.push_back(V[N - i - 1]);
            }

            sort(neg.begin(), neg.end());
            for (int i = 0; i < min((int)neg.size(), K - (a + b)); ++i) {
                curr_total -= neg[i];
            }

            max_total = max(max_total, curr_total);
        }
    }

    cout << max_total << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
/********** UnionFind ***************
struct UnionFInd {
vector<ll> par;
UnionFInd(ll N) : par(N) {
for (ll i = 0; i < N; i++) {
par[i] = i;
}
}
ll root(ll x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
if (rx == ry) return;
par[rx] = par[ry];
}
bool same(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
return rx == ry;
}
};
*************************************/
/***********************************
ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  ll r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
***********************************/
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  ll x;
  cin >> x;
  if(x >= 30){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
def larger(x, y):
	if x > y:
		return x
	return y

def euc(x, y):
	if y == 0:
		return x
	return euc(y, x%y)

N = int(input())
A = list(map(int, input().split()))
gcdL = [A[0]]
for i in range(1, N):
	gcdL.append(euc(gcdL[-1], A[i]))
gcdR = [A[-1]]
for i in range(1, N):
	gcdR.append(euc(gcdR[-1], A[-1-i]))
gcdR.reverse()
max = gcdR[1]
for i in range(1, N-1):
	max = larger(max, euc(gcdL[i-1], gcdR[i+1]))
max = larger(max, gcdL[-2])
print(max)

Measured memory_bytes: 66924
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

vector<int> bi;

int d, g, ans, cst, mi=999999;
vector<int> p, c;

//0~pa-1を長さnで生成、合計pa^n個生成
void bitgen(int n) {
	//cout << "in" << endl;
	//生成完了時の処理
	if (n == 0) {
		ans = 0;
		cst = 0;
		for (int i = 0;i < bi.size();i++) {
			if (bi[i] == 0) continue;
			ans += (i + 1) * 100 * p[i] + c[i];
			cst += p[i];
		}
		//cout << cst <<" " << ans << endl;

		if (g - ans <= 0) {
			mi = min(mi, cst);
		}
		else {
			for (int i = d - 1;i >= 0;i--) {
				if (bi[i] == 1) continue;
				if (g - ans <= (i + 1) * 100 * p[i]) {
					cst += (g - ans + ((i + 1) * 100 - 1)) / ((i + 1) * 100);
					mi = min(mi, cst);
				}
			}
		}
		
		//cout << "end" << endl;
		return;
	}

	//再帰部分
	for (int i = 0;i<2;i++) {
		//cout << i << " " << n << endl;
		bi[n - 1] = i;
		bitgen(n - 1);
	}
}

int main(){

	cin >> d >> g;
	p.resize(d);
	c.resize(d);
	bi.resize(d);
	for(int i=0;i<d;i++) cin>> p[i] >> c[i];

	bitgen(d);

	cout<< mi << endl;


}

Measured memory_bytes: 256
from collections import defaultdict


def find_root(x):
    if parent[x] == x:
        return x
    else:
        return find_root(parent[x])


# x,yの属する集合の併合
def unite(x, y):
    x = find_root(x)
    y = find_root(y)

    if x != y:
        if rank[x] < rank[y]:
            parent[x] = y
            size[y] += size[x]
        else:
            parent[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1


def same(x, y):
    return find_root(x) == find_root(y)


def group_size(x):
    return size[find_root(x)]


dic1 = defaultdict(list)
dic2 = defaultdict(list)

n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]


parent = [i for i in range(n)]  # 根
rank = [1] * n  # 深さ
size = [1] * n  # iを根とするグループのサイズ

edge = [[ab[m - 1 - i][0] - 1, ab[m - 1 - i][1] - 1] for i in range(m)]

res = []
for i in range(m):
    a = find_root(edge[i][0])
    b = find_root(edge[i][1])
    if a == b:
        res.append(0)
    else:
        res.append(size[a] * size[b])
        unite(a, b)


for i in range(m):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    dic1[a].append(b)
    dic1[b].append(a)
for i in range(k):
    c = cd[i][0] - 1
    d = cd[i][1] - 1
    if same(c, d):
        dic2[c].append(d)
        dic2[d].append(c)

ans = []
for i in range(n):
    ans.append(group_size(i)-1 - len(dic1[i]) - len(dic2[i]))
print(' '.join(map(str, ans)))


Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

string change_to_s(int n){
    stringstream ss; ss<<n;
    return ss.str();
}

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    rep(i, 0, k) cin >> d[i];
    int ans = -1;
    for(int i = n;; i++){
        string s = change_to_s(i);
        bool f = true;
        rep(j, 0, s.size()){
            rep(l, 0, k){
                if(s[j] == '0' + d[l]) f = false;
            }
        }
        if(f){
            ans = i; break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll gcd(ll a,ll b) {
	if(b == 0)
		return a;
	return gcd(b,a % b);
}

ll n,a[200000],k;
int main(){
	cin >> n >> k;
	REP(i,n) {
		cin >> a[i];
	}

	if(n == 1) {
		if(k == a[0]) {
			cout << "POSSIBLE" << endl;
		}else {
			cout << "IMPOSSIBLE" << endl;
		}
		return 0;
	}

	bool f = true;
	REP(i,n) {
		if(a[i] >= k) {
			f = false;
			break;
		}
	}
	if(f) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	ll g = gcd(a[0],a[1]);

	FOR(i,2,n) {
		g = gcd(g,a[i]);
	}

	if(k % g == 0) {
		cout << "POSSIBLE" << endl;
	}else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    int k=0;
    while(1){
        cin>>H>>W;
        if(k>0)cout<<endl;
        if(H==0&&W==0)break;
        k++;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+j)%2==0)cout<<"#";
                else cout<<".";
            }cout<<endl;
        }
    }
}


Measured memory_bytes: 3096
def unbounded_knapsack(items, budget)
	table = [0]
	for i in 1..budget
		table[i] = -Float::INFINITY
		items.each{|c, v|
			next if c > i
			x = table[i-c] + v
			table[i] = x if x > table[i]
		}
	end
	table
end

d = Hash[*%w(^ v < >).zip([[-1, 0], [1, 0], [0, -1], [0, 1]]).flatten(1)]

ns = []
loop {
	n = gets.to_i
	break if n == 0
	ns << n
}

table = unbounded_knapsack([
	[200, -380],
	[300, -550],
	[500, -850],
	[1000, -1520],
	[1200, -1870],
	[1500, -2244]
	],ns.max)

ns.each{|n| p -table[n]}

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

int main()
{
    string st;
    cin >> st;

    if (st[st.size() - 1] == 's')
    {
        for (int i = 0; i < (st.size()); ++i)
        {
            cout << st[i];
        }
        cout << "es";
    }
    else
    {
        cout << st;
        cout << 's';
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;

int main() {
	int i, N, r, D;
	int x;
	cin >> r >> D >> x;
	rep(i, 10) {
		x = x * r - D;
		cout << x << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)

const int mod = 1000000007;

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

  long n, m, d;
  cin >> n >> m >> d;

  double res = 0.0;
  if (d == 0) {
    res = (double)1 / n * (m-1);
  } else {
    res += (double)d * 2 / n / n * (m-1);
    res += (double)(n-2*d) * 2 / n / n * (m-1);
  }

  printf("%.8f", res);


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0 && c>0){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int a[300010];
ll li[200010], li2[200010];
pq<int, vector<int>, greater<int>> que;
pq<int> qu;

int main(){
	int n; cin >> n;
	REP(i,0,3 * n) cin >> a[i];

	ll s = 0;
	REP(i,0,n) que.push(a[i]), s += a[i];
	li[n-1] = s;
	
	REP(i,n,2*n){
		que.push(a[i]);
		s -= que.top();
		s += a[i]; que.pop();
		li[i] = s;
	}
	
	s = 0;
	RREP(i,3*n-1,2*n) qu.push(a[i]), s += a[i];
	li2[2*n] = s;
	RREP(i, 2*n-1, n){
		qu.push(a[i]);
		s -= qu.top();
		s += a[i]; qu.pop();
		li2[i] = s;
	}
	
	ll ma = -LINF;
	REP(i,n-1,2*n){
		ma = max(ma, li[i] - li2[i + 1]);
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 4216
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x=0,y=0;
  scanf("%d",&x);
  scanf("%d",&y);
  x=x*500;
  if (x>=y) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> l(n);
    for(ll i=0;i<n;++i){
        cin>>l[i];
    }
    sort(l.begin(), l.end());

    ll ans = 0;
    for(ll i=0;i<n;++i){
        for(ll j=i+1;j<n;++j){
            if(l[j] == l[i])continue;
            for(ll k=j+1;k<n;++k){
                if(l[k] == l[j])continue;
                if(l[i] + l[j] > l[k]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
#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 ALL(a) a.begin(),a.end()
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    bool judge = true;
    if(N%2==1){
        judge = false;
    }
    else{
        REP(i,N/2){
            if(S[i]!=S[i+N/2]){
                judge = false;
            }
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long  
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

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

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

bool visited[MX1+1];

int main()
{
    opt;
    
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli X,A,B,i;
    cin>>X>>A>>B;
    
    if(A>=B)
    {
        cout<<"delicious";
        exit(0);
    }
    
    if(X<B-A)
    {
        cout<<"dangerous";
        exit(0);
    }
    
    cout<<"safe";
    
    
    
    
    
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	ll ans=1;
	rep(i,1,n+1){
		ans*=i%MOD;
		ans=ans%MOD;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct UnionFind{
  int num;
  vector<int> rs,ps;
  UnionFind(){}
  UnionFind(int n):num(n),rs(n,1),ps(n,0){iota(ps.begin(),ps.end(),0);}
  int find(int x){
    return (x==ps[x]?x:ps[x]=find(ps[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(rs[x]<rs[y]) swap(x,y);
    rs[x]+=rs[y];
    ps[y]=x;
    num--;
  }
  int size(int x){
    return rs[find(x)];
  }
  int count() const{
    return num;
  }
};

//INSERT ABOVE HERE
signed main(){
  int n,m,k;
  cin>>n>>m>>k;

  UnionFind uf(n);
  vector<int> ans(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf.unite(a,b);
    ans[a]--;
    ans[b]--;
  }

  vector<vector<int>> G(n);
  for(int i=0;i<k;i++){
    int c,d;
    cin>>c>>d;
    c--;d--;
    G[c].emplace_back(d);
    G[d].emplace_back(c);
  }

  for(int i=0;i<n;i++){
    ans[i]+=uf.size(i)-1;
    for(int j:G[i])
      if(uf.same(i,j)) ans[i]--;
  }

  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> void sort3a(T& a,T& b,T& c) {if (a>b) swap(a,b); if (b>c) swap(b,c); if (a>b) swap(a,b);}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int N,A,B; cin >> N>>A>>B;
    cout << min(A, B) << " " << max(A+B-N, 0) << endl;
}


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

using namespace std;

using ll = long long;
using Compare = function<bool(int, int)>;

ll solve(int n, vector<int>& l, vector<int>& r, int hoge, set<int, Compare> idx1, set<int, Compare> idx2) {
    ll ans = 0;
    int pos = 0;
    for (int i = 0; i < n; i++) {
        int j;
        if (hoge == 0) j = *idx1.begin();
        else j = *idx2.begin();
        if (pos < l[j]) {
            ans += l[j] - pos;
            pos = l[j];
        } else if (pos > r[j]) {
            ans += pos - r[j];
            pos = r[j];
        }
        idx1.erase(j);
        idx2.erase(j);
        hoge = 1 - hoge;
    }
    ans += abs(pos);

    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }

    auto c1 = [&](const int& i1, const int& i2){return (l[i1] != l[i2]) ? l[i1] > l[i2] : i1 < i2;};
    auto c2 = [&](const int& i1, const int& i2){return (r[i1] != r[i2]) ? r[i1] < r[i2] : i1 < i2;};
    set<int, Compare> idx1(c1), idx2(c2);

    for (int i = 0; i < n; i++) {
        idx1.insert(i);
        idx2.insert(i);
    }
    cout << max(solve(n, l, r, 0, idx1, idx2), solve(n, l, r, 1, idx1, idx2)) << endl;
    return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const pi dir[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

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

bool isPrime(int ttttttt) {
    for (int d = 2; d * d <= ttttttt; d++) if (ttttttt % d == 0) return false;
    return true;
}

int main(){
    IOS;
    int x;
    cin >> x;
    while(true){
        if(isPrime(x)){
            cout << x;
            return 0;
        }
        x++;
    }
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

Measured memory_bytes: 256
MOD = 10**9 + 7
N = int(input())

import numpy as np
is_prime = np.ones(1001,dtype=np.bool)
is_prime[:2] = 0
for p in range(2,100):
  is_prime[p*p::p] = 0
primes = is_prime.nonzero()[0]

def fact_ord(p,n):
  if n < p:
    return 0
  return fact_ord(p,n//p) + n//p

answer = 1
for p in primes:
  answer *= (fact_ord(p,N)+1)
  answer %= MOD
  
print(answer)

Measured memory_bytes: 20028
#include <stdio.h>

int main(void){
  int m, f, r, mf;

  while(1){
    scanf("%d%d%d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1)  break;
    mf = m + f;
    if(m == -1 || f == -1){
      printf("F\n");
    }else if(mf >= 80){
      printf("A\n");
    }else if(mf >= 65){
      printf("B\n");
    }else if(mf >= 50){
      printf("C\n");
    }else if(mf >= 30){
      if(r >= 50){
	printf("C\n");
      }else{
	printf("D\n");
      }
    }else{
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584