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

map<int, int> mp;

int gcd(int x, int y);
bool c_moon(int x);

signed main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int n, a[1000000], r_gcd;
    bool st;
    
    cin >> n;
    for (int i=0 ;i<n ;i++ ) {
        cin >> a[i];
    }
    
    st = true;
    r_gcd = a[0];
    for (int i=0 ;i<n ;i++ ) {
        
        if (r_gcd > 1) {
            r_gcd = gcd(a[i], r_gcd);
        }
        
        if (st == true) {
            st = c_moon(a[i]);
        }
    }

    if (st == true) {
        cout << "pairwise coprime\n";
    } else if (r_gcd == 1) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }

    
    return (0);
}

int gcd(int x, int y) {
    if (y > x) {
        swap(x, y);
    }
    
    int z = x % y;
    while (z != 0) {
        x = y;
        y = z;
        z = x % y;
    }
    
    return (y);
}

bool c_moon(int x) {
    bool ans = true;
    
    for (int i=2 ;i*i<=x && x > 1 && ans == true; i++ ) {
        if (x % i == 0) {
            while (x % i == 0) {
                x = x / i;
            }
            
            if (mp[i] == 1) {
                ans = false;
            } else {
                mp[i] = 1;
            }
        }
    }

    if (x > 1) {
        
        if (mp[x] == 1) {
            ans = false;
        } else {
            mp[x] = 1;
        }
    }
    
    return (ans);
}

Measured memory_bytes: 7596
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 200007, alph = 26;
int n, last[alph][N], suf[N];
string s;

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

    cin >> s;
    n = s.size();
    memset(& last, -1, sizeof(last));

    int mask = 0;
    for (int i = n; i >= 1; i--) {
        for (int j = 0; j < alph; j++) {
            last[j][i] = last[j][i + 1];
        }
        int ch = (s[i - 1] - 'a');
        last[ch][i] = i;
        suf[i] = suf[i + 1];

        mask |= (1 << ch);
        if (mask == (1 << alph) - 1) {
            mask = 0;
            suf[i]++;
        }
    }
    int len = suf[1] + 1, cur = 1;
    string ans = "";
    for (int i = 1; i <= len; i++) {
        for (int j = 0; j < alph; j++) {
            if (last[j][cur] == -1) {
                if (len == i) {
                    ans += char('a' + j);
                    break;
                }
            }
            if (len - i > suf[last[j][cur] + 1]) {
                cur = last[j][cur] + 1;
                ans += char('a' + j);
                break;
            }
        }
    }
    cout << ans;
}


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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long H;
        H = sc.nextLong();
        long W;
        W = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(H, W);
    }
}

class Solver {
    public void solve(long H, long W) {
        if (H == 1 || W == 1) {
            System.out.println(1);
            return;
        }
        long total = (long) Math.ceil(H / 2.0 * W);
        System.out.println(total);
    }
}



Measured memory_bytes: 21844
haveTrumps = [[0 for i in range(13)] for j in range(4)]
allCards = int(input())
for i in range(0, allCards):
    cardType, cardNum = input().split()
    if cardType == "S":
        haveTrumps[0][int(cardNum) - 1] = 1
    elif cardType == "H":
        haveTrumps[1][int(cardNum) - 1] = 1
    elif cardType == "C":
        haveTrumps[2][int(cardNum) - 1] = 1
    elif cardType == "D":
        haveTrumps[3][int(cardNum) - 1] = 1
for i in range(0, 4):
    for j in range(0, 13):
        if haveTrumps[i][j] == 0:
            if i == 0:
                print("S ", end="")
            elif i == 1:
                print("H ", end="")
            elif i == 2:
                print("C ", end="")
            elif i == 3:
                print("D ", end="")
            print("{0}".format(j + 1))

Measured memory_bytes: 7720
#include <bits/stdc++.h>
using namespace std; 
const int N = 2e5 + 9;
typedef long long ll;
ll n, L, ans, a[N], b[N], Sa[N], Sb[N];
ll Qa(int l, int r) { return Sa[r] - Sa[l - 1]; }
ll Qb(int l, int r) { return Sb[r] - Sb[l - 1]; }
void Solve() { 
    for (int i = n; i; -- i) { 
        int blen = (n - i) >> 1, alen = n - i - blen;
		ans=max(ans,((n - i) & 1 ? b[n - blen] : a[n - alen]) + (Qb(n - blen + 1, n) + Qa(i, i + alen - 1)) * 2);
    }
}
int main() {
    scanf("%lld%lld", &L, &n); for (int i = 1; i <= n; ++ i) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; ++ i) { b[i] = L - a[i]; Sa[i] = Sa[i - 1] + a[i]; Sb[i] = Sb[i - 1] + b[i]; } Solve();
    for (int i = 1; i <= n; ++ i) a[i] = b[n - i + 1];
    for (int i = 1; i <= n; ++ i) { b[i] = L - a[i]; Sa[i] = Sa[i - 1] + a[i]; Sb[i] = Sb[i - 1] + b[i]; } Solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 4005
#define MD 2002
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;

ll dp[SIZE][SIZE];
ll fac[SIZE*2],finv[SIZE*2],inv[SIZE*2];
int A[SIZE*50],B[SIZE*50];

void make()
{
	inv[1]=1;
	fac[0]=fac[1]=finv[0]=finv[1]=1;
	for(int i=2;i<SIZE*2;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d %d",&A[i],&B[i]);
		dp[MD-A[i]][MD-B[i]]++;
	}
	for(int i=0;i<SIZE;i++)
	{
		for(int j=0;j<SIZE;j++)
		{
			if(i>0) dp[i][j]+=dp[i-1][j];
			if(j>0) dp[i][j]+=dp[i][j-1];
			if(dp[i][j]>=MOD) dp[i][j]-=MOD;
		}
	}
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		ret+=dp[MD+A[i]][MD+B[i]];
		if(ret>=MOD) ret-=MOD;
		ret-=C(2*(A[i]+B[i]),2*A[i]);
		if(ret<0) ret+=MOD;
	}
	ret*=inv[2];
	ret%=MOD;
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 127232
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.range;
import std.c.stdio;
import core.memory;

int h,w,k;
int[][] board;

int[][] dp;
ref int getdp(int l,int a,int b,int c,int d,int e,int y,int x){
	return dp[l][((((((a*4+b)*4)+c)*4+d)*4+e)*h+y)*w+x];
}

void main(){
	GC.disable;
	scanf("%d%d%d\n",&h,&w,&k);
	dp = new int[][](k+1,4*4*4*4*4*h*w);
	foreach(int g;0..k+1){
		dp[g][] = int.min;
	}
	char[] rbuf = new char[64];
	board = new int[][](h,w);
	foreach(int i;0..h){
		readln(rbuf);
		foreach(int j;0..w){
			if(rbuf[j] == '#')
				board[i][j] = -1;
			else if(rbuf[j] == '.')
				board[i][j] = 0;
			else
				board[i][j] = rbuf[j]-'0';
		}
	}
	int[5][1024] dirs;
	int[1024] backc;
	backc[] = 0;
	foreach(int i;0..1024){
		foreach(int j;0..5){
			int d = (i / (1<<(j*2)))%4;
			dirs[i][j] = d;
			if(d<2)
				backc[i]++;
		}
	}
	int[4] dx = [0,-1,0,1];
	int[4] dy = [-1,0,1,0];
	foreach(i;0..1024){
		dp[0][i*w*h] = 0;
	}
	foreach(int g;0..k+1){
		foreach(int i;0..h){
			foreach(int j;0..w){
				foreach(int t;0..1024){
					foreach(int d;0..4){
						if(d<2 && g == k)
							continue;
						if(i+dy[d]>=0&&i+dy[d]<h&&j+dx[d]>=0&&j+dx[d]<w){
							if(board[i+dy[d]][j+dx[d]]>=0){
								int pls = board[i+dy[d]][j+dx[d]];
								int nx=j;
								int ny=i;
								foreach(p;0..5){
									nx += dx[(dirs[t][p]+2)%4];
									ny += dy[(dirs[t][p]+2)%4];
									if(ny == i+dy[d] && nx == j+dx[d]){
										pls = 0;
									}
								}
								getdp(g + (d<2?1:0),dirs[t][3],dirs[t][2],dirs[t][1],dirs[t][0],d,i+dy[d],j+dx[d]) = max(getdp(g + (d<2?1:0),dirs[t][3],dirs[t][2],dirs[t][1],dirs[t][0],d,i+dy[d],j+dx[d]),dp[g][t*h*w+i*w+j] + pls);
							}
						}
					}
				}
			}
		}
	}
	/*foreach(g;0..k+1){
		g.writeln;
		foreach(i;0..h){
			int[] tmpline;
			foreach(j;0..w){
				int tmpmax=0;
				foreach(t;0..1024){
					if(backc[t] == g)
						tmpmax = max(tmpmax,dp[g][t*w*h+i*w+j]);
				}
				tmpline ~= tmpmax;
			}
			tmpline.writeln;
		}
	}*/
	int res=0;
	foreach(int g;0..k+1){
		foreach(int i;0..1024){
			res = max(res,dp[g][i*h*w+(h-1)*w+w-1]);
		}
	}
	res.writeln;
}

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

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

#define ll long long  int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e6+5;

ll a[N];
ll chk[N],siv[N];
int main()
{
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    for(i=0; i<N; i++)
        siv[i]=i;

    for(i=2; i<N; i++)
    {
        if(siv[i]==i)
        {
        for(j=i*i; j<N; j+=i)
        {
            if(siv[j]==j)
                siv[j]=i;
        }
        }
    }
    while(tc--)
    {
      ll n;
      cin>>n;
      for(i=0; i<n; i++)
      {
          cin>>a[i];
      }
      ll gc=a[0];
      for(i=1; i<n; i++)
      {
          gc=__gcd(gc,a[i]);
      }
      if(gc!=1)
      {
          cout<<"not coprime"<<"\n";
          return 0;
      }

      for(i=0; i<n; i++)
      {
          map<ll,ll>mp;
          ll val=a[i];
          while(val!=1)
          {
              mp[siv[val]]++;
              val/=siv[val];

          }
          for (auto it: mp)
          {
              chk[it.first]++;
          }
      }
      for(i=0; i<N; i++)
      {
          if(chk[i]>1)
          {
              cout<<"setwise coprime";
              return 0;
          }
      }

      cout<<"pairwise coprime"<<"\n";

    }

    return 0;
}


Measured memory_bytes: 26944
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N];
  
  for(int i=0; i < N; ++i){
    cin >> a[i];
  }
  int app = 1;
  for(int i=0; i < N; ++i){
    if(a[i] % 2 == 0) {
      if(a[i] % 3 != 0  && a[i] % 5 != 0) app = 0;
    }
  }
  if(app == 1) cout << "APPROVED" << endl;
  else if(app == 0) cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli b[10000007];
lli sieve (int n)
{
    for (int i=2;i<n;i++)
    {
        if (b[i]==0)
        {
            for (int j=i;j<=n;j+=i)
            {
                if (b[j]==0)
                {
                    b[j]=i;
                }
            }
        }
    }
    return 0;
}
lli find(lli n)
{
    lli sum=0,ans=1;
    vll v;
    lli z;
    while (1)
    {
        if (n==1)
        {
            break;
        }
        sum=0;
        z=b[n];
        //cout<<n<<" "<<b[n]<<"\n";
        while (n%z==0)
        {
            n/=z;
            sum++;
        }
        v.pb(sum);
    }
    for (int i=0;i<v.size();i++)
    {
        ans*=(v[i]+1);
    }
    //cout<<ans<<"\n";
    return ans;
}
int main()
{
    fio;
    sieve(10000000);
    lli n;
    cin>>n;
    lli ans=1;
    for (int i=2;i<=n;i++)
    {
        //cout<<i<<"\n";
        ans+=i*(find(i));
        //cout<<ans<<"\n";
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 81688
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;


int main() {
	int H, W;
	cin >> H >> W;
	int a[8][8];
	int count = 0;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			char c; cin >> c;
			if (c == '#') { count++; }
		}
	}

	if (count == H + W - 1) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}
	return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
s = list(map(int, input().split()))
s.sort()
q = int(input())
t = list(map(int, input().split()))

ans = 0
for num in t:
    index = bisect.bisect_left(s, num)
    # indexが超えた場合
    if index >= n:
        continue
    if num == s[index]:
        ans += 1

print(ans)



Measured memory_bytes: 16740
#include<stdio.h>
int prime[100001];
int p[30000];
int main(){
	prime[0]=prime[1]=-1;
	for(int i=2;i<100001;i++){
		if(~prime[i]){
			prime[i]=1;
			for(int j=i*2;j<100001;j+=i){
				prime[j]=-1;
			}
		}
	}
	int now=0;
	for(int i=0;i<100001;i++)if(~prime[i])p[now++]=i;
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a+b+c){
		int res=0;
		int ret=0;
		int val=0;
		for(int i=0;i<now;i++){
			for(int j=i;j<now&&(long long)p[j]*p[i]<=(long long)a;j++){
				if(b*p[j]<=c*p[i]&&val<p[i]*p[j]){
					val=p[i]*p[j];
					res=p[i];
					ret=p[j];
				}
			}
		}
		printf("%d %d\n",res,ret);
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int PRIMES[10000] = {0};

void make_prime() {
	PRIMES[0] = 2;
	int i, j;
	
	for (i = 3; i < 10000; ++i) {
		for (j = 0; PRIMES[j] != 0; ++j) {
			if ((i % PRIMES[j]) == 0) {
				break;
			}
		}
		if (PRIMES[j]) {
			continue;
		} else {
			PRIMES[j] = i;
		}
	}
	return;
}

int main(void)
{
	int i, j, n, cnt;
	int tmp[10001] = {0};
	make_prime();
	scanf("%d", &n);
	cnt = 0;
	for (i = 0; i < n; ++i) {
		scanf("%d", &tmp[i]);
		for (j = 0; PRIMES[j] != 0; ++j) {
			if ((tmp[i] % PRIMES[j]) == 0) {
				break;
			}
		}
		if (PRIMES[j] == 0 || PRIMES[j] == tmp[i]) {
			cnt++;
		}
	}

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

Measured memory_bytes: 648
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int a=0,b=0,ab=0,o=0;
  int n;

  while(scanf("%d",&n)!=EOF){
    cin>>str;
    if(str[1]=='A'){
      if(str[2]=='B')
	ab++;
      else
	a++;
    }
    else if(str[1]=='B')
      b++;
    else
      o++;  
  }
  cout<<a<<endl;
  cout<<b<<endl;
  cout<<ab<<endl;
  cout<<o<<endl;
}

Measured memory_bytes: 1232
object Main extends App {
  val Seq(_, _, x, y): Seq[Int] = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val Seq(xs, ys) = Range(0,2).map(_ => scala.io.StdIn.readLine.split(" ").map(_.toInt))
  println(
    if(Seq(x, xs.max).max < Seq(y, ys.min).min) "No War"
    else "War"
  )
}


Measured memory_bytes: 25672
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if (n <= k) {
        cout << n * x << endl;
    } else {
        cout << k * x + (n - k) * y << endl;
    }

    return 0;
}

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

int main(int argc, const char * argv[]) {
    int K, X;
    int i, start, goal;
    cin >> K >> X;
    
    start = X - K + 1;
    if(start < -100000) start = -100000;
    goal = X + K - 1;
    if(goal > 100000) goal = 100000;
    
    for(i=start; i<goal; i++){
        cout << i << " ";
    }
    cout << goal;
    
    return 0;
}



Measured memory_bytes: 384
n = int(input())
h = [int(i) for i in input().split()]
ans = 0
s = 0
t = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        if t == 1:
            s += 1
            if ans < s:
                ans = s
        else:
            t = 1
            s = 1
    else:
        s = 0
        t = 0
print(ans)

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

int main(){
  int k;
  cin >> k;
  int ans=-1;
  if(7%k==0) cout << 1 << endl;
  else if(77%k==0) cout << 2 << endl;
  else{
    long long x=77%k;
    for(int i=3;i<=k;i++){
      x*=10;
      x+=7;
      x%=k;
      if(x==0){
        ans=i;
        break;
      }
    }
    cout << ans << endl;
  }
}

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

const int N = 200005;
const int LK = 42;

int n;
long long k;
int a[N];

int first[N];
int lst[N];
int nxt[N];

int sp[LK][N];

int main() {
  memset(first, -1, sizeof first);
  memset(nxt, -1, sizeof nxt);
  
  scanf("%d %lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    
    if (first[a[i]] == -1) first[a[i]] = i;
    else {
      nxt[lst[a[i]]] = i + 1;
    }
    
    lst[a[i]] = i;
  }
  
  sp[0][n] = 0;
  for (int i = n-1; i >= 0; --i) {
    if (nxt[i] == -1) sp[0][i] = first[a[i]] + 1;
    else sp[0][i] = sp[0][nxt[i]];
  }
  
  for (int i = 1; i < LK; ++i) for (int j = 0; j <= n; ++j) sp[i][j] = sp[i-1][sp[i-1][j]];
  
  --k;
  int cur = 0;
  while (k > 0) {
    int ctz = __builtin_ctzll(k);
    k -= 1LL << ctz;

    cur = sp[ctz][cur];
  }
  
  bool space = false;
  for (; cur < n;) {
    if (nxt[cur] != -1) cur = nxt[cur];
    else {
      if (space) printf(" ");
      space = true;

      printf("%d", a[cur++]);
    }
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 37376
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Global Variables begin ======

// ====== Global Variables end ======

void speed_solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a + n);
    ll ans = 0;
    rep(i,n){
        repe(j,i + 1, n){
            repe(k,j + 1, n){
                if(a[i] + a[j] > a[k] and (a[i] != a[j] and a[j] != a[k])){
                    ans++;
                }
            }
        }
    }
    cout << ans;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
int lcs[3005][3005];
int main()
{
	 boost
	int t=1;
	//cin>>t;
	while(t--)
	{
              string s,t;
              cin>>s>>t;
              for(int i=0;i<s.length();i++){
                  for(int j=0;j<t.length();j++){
                      if(s[i]==t[j]){
                          lcs[i+1][j+1] = 1+lcs[i][j];
                      }
                      else{
                          lcs[i+1][j+1] = max(lcs[i][j+1],lcs[i+1][j]);
                      }
                  }
              }

              string res;
              int i = s.length() ,j = t.length();
              while(i>=1 && j>=1){
                  //cout<<i<<" "<<j<<"\n";
                  if(s[i-1]==t[j-1]){
                      res.push_back(s[i-1]);
                      i--; j--;
                  }
                  else{
                      if(lcs[i-1][j]>=lcs[i][j-1]) i--;
                      else j--;
                  }
              }
              reverse(res.begin(),res.end());
              cout<<res<<"\n";
	}
    return 0;
}


Measured memory_bytes: 38892
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n = gets.chomp.to_i
    k = gets.chomp.to_i

    xs = gets.chomp.split.map(&:to_i)

    ans = 0
    xs.each do |x|
      ans += [x, (x - k).abs].min * 2
    end

    puts ans

  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2044
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    aaa=sum(arr)

    n-=aaa
    if n<0:
        print(-1)
    else:
        print(n)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16992
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

vector<int> g[MAX_N];
int visit[MAX_N];
vector<int> G[MAX_N];
bool vis[MAX_N];

void dfs(int u, int kind){
    visit[u] = kind;
    each(v, g[u]){
        if(visit[v] < 0){
            dfs(v, kind);
        }
    }
}

class UF {
private:
    int sz; vector<int> par,nrank;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz,0); rep(i,sz) par[i] = i; }
    int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } }
    void unite(int x,int y)
    { x = find(x),y = find(y); if(x == y) return;
    	if(nrank[x] < nrank[y]) swap(x,y); par[y] = x; if(nrank[x] == nrank[y]) nrank[x]++; }
    bool same(int x,int y){ return find(x) == find(y); }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K, L;
    cin >> n >> K >> L;
    rep(i,K){
        int u,v;
        cin >> u >> v;
        g[u-1].pb(v-1), g[v-1].pb(u-1);
    }
    rep(i,n){
        visit[i] = -i-1;
    }
    int kind = 0;
    rep(i,n){
        if(visit[i] < 0){
            dfs(i, kind);
            kind++;
        }
    }
    UF uf(n);
    rep(i,L){
        int u,v;
        cin >> u >> v;
        uf.unite(u-1, v-1);
    }
    map<P, int> mp;
    rep(i,n){
        mp[P(visit[i], uf.find(i))]++;
    }
    rep(i,n){
        cout << mp[P(visit[i], uf.find(i))] << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 25856
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int n;
	cin >> n;
	double p[n];
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	double dp[n + 1][n / 2 + 1];

	dp[0][0] = 1;
	for(int j = 1; j <= n / 2; ++j) {
		dp[0][j] = 0;
	}

	for(int i = 1; i <= n; ++i) {
		dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]);

		for(int j = 1; j <= n / 2; ++j) {
			dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1];
		}
	}

	double lessProb = 0.0;

	// for(int i = 0; i <= n; ++i) {
	// 	for(int j = 0; j <= n / 2; ++j) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	for(int j = 0; j <= n / 2; ++j) {
		lessProb += dp[n][j];
	}
	cout << fixed << setprecision(10) << 1 - lessProb << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

int main()
{
    int n{}, k{};
    std::cin >> n >> k;
    std::vector<int> enemy(n);
    for (int i = 0; i < n; i++) {
        std::cin >> enemy[i];
    }
    if (enemy.size() <= k) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::sort(enemy.begin(), enemy.end());
    enemy.resize(enemy.size() - k);
    std::cout << std::accumulate(enemy.begin(), enemy.end(), 0LL) << std::endl;

    return 0;
}


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

int main(){

    string S;
    cin >> S;

    string N[S.length()];
    for(int i = 0;i<S.length();i ++ ){
        N[i] = S[i];
    }

    int i = S.length();

    while(true){
        bool flag = false;
        N[i-1] = "xxxxx";
        i = i -1;
        if(i%2 == 0){
            for(int j = 0;j < i/2; j++){
                if(N[j] != N[j + i/2]){
                    flag = false;
                    break;
                }
                flag = true;
            }
        }
        if(flag){
            break;
        }
    }

    cout << i << endl;


    return 0;
}

Measured memory_bytes: 256
// AOJ 2642: Dinner
// 2017.11.9 bal4u@uu
// 2018.1.5

#include <stdio.h>
#include <stdlib.h>

long long a[500003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define THRESHOLD 10
#define STACKSIZE 64		// 2^432 for long long int

void quicksort(long long *a, int n)
{
	int i, j, l, r, p;
	int lsp[STACKSIZE], rsp[STACKSIZE];
	long long m, t;
	
	l = 0, r = n-1, p = 0;
	while (1) {
		if (r-l <= THRESHOLD) {
			if (!p--) break;
			l = lsp[p], r = rsp[p];
		}
		m = a[(l+r)>>1];
		i = l, j = r;
		while (1) {
			while (a[i] > m) i++;
			while (m > a[j]) j--;
			if (i >= j) break;
			t = a[i], a[i] = a[j], a[j] = t;
			i++, j--;
		}
		if (i-l > r-j) {
			if (i-l > THRESHOLD) {
				lsp[p] = l;
				rsp[p] = i-1;
				p++;
			}
			l = j+1;
		} else {
			if (r-j > THRESHOLD) {
				lsp[p] = j+1;
				rsp[p] = r;
				p++;
			}
			r = i-1;
		}
	}
	
	// insert sorting
	for (i = 1; i < n; i++) {
		m = a[i];
		for (j = i-1; j >= 0 && a[j] < m; j--) a[j+1] = a[j];
		a[j+1] = m;
	}
}

int main()
{
	int n, q, c, i;
	long long p, s, t, ans;

	n = in(), p = in(), q = in();
    for (s = 0, t = p*q, i = 0; i < n; i++, t -= p) {
		c = in(), a[i] = t - c, s += c;
    }

	quicksort(a, n);
    for (ans = s, t = 0, p <<= 1, i = 0; i < n; i++, t += p) {
		s += a[i] + t;
		if (s > ans) ans = s;
	}
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5752
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<vector<ll>> dp(n + 20, vector<ll>(4, -1e18));
	dp[0][0] = 0;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	int sz = 1;
	sz += n % 2;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < sz + 1; j++) {
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
			ll add = dp[i][j];
			if ((i + j) % 2 == 0) add += a[i];
			dp[i + 1][j] = max(add, dp[i + 1][j]);
		}
	}
	cout << dp[n][sz];
}

Measured memory_bytes: 18776
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>













const int N=2e5+10;
ll n,a[N],sum,sum2,res,d;

void solve()
{
	cin>>n;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sum2=0;
	for(int i=1;i<n;i++)
	{
		sum2+=a[i];
		d=sum2-(sum-sum2);
		if(d<0)d*=-1;
		if(i==1||res>d)res=d;
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  
  if (N == 1){
    cout << 1 << endl;
    return 0;
  }
  
  vector<long long>so(N,0);
  for (int i = 2; i <= N; i++) {
    int M = i;
    for (int j = 2; j <= N; j++) {
      if (i % j == 0){
        for (int k = 0; k < 10; k++) {
          if (M % j == 0){
            so.at(j-1)++;
            M /= j;
          }
          else {
            break;
          }
        }
      }
    }
  }
  
  long long ans = 1;
  
  for (int i = 0; i < N; i++) {
    ans *= (so.at(i)+1);
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
import static java.util.Arrays.sort;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int scoreCard[] = new int[N];
        
        for(int i = 0; i < N; i++){
            scoreCard[i] = sc.nextInt();
        //    System.out.println(scoreCard[i]);
        }
        
        sort(scoreCard);
        /*
        for(int num : scoreCard){
            System.out.println(num);
        }
        */
        int Alice = 0, Bob = 0;
        boolean flg = true;
        for(int i = scoreCard.length -1; i >= 0; i--){
            if(flg){
                Alice += scoreCard[i];
        //        System.out.println("A" + Alice);
                flg = false;
            }else{
                Bob += scoreCard[i];
        //        System.out.println("B" + Bob);
                flg = true;
            }
        }
        System.out.println(Alice - Bob);
        
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, d;
	std::cin >> n >> d;
	d += d + 1;
	std::cout << (n + d - 1) / d << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int x,y,z,k;	cin >> x >> y >> z >> k;
	vector<long long int> a,b,c;
	for(int i=0;i<x;i++){
		long long int sub;	cin >> sub;
		a.push_back(sub);
	}
	for(int i=0;i<y;i++){
		long long int sub;	cin >> sub;
		b.push_back(sub);
	}
	for(int i=0;i<z;i++){
		long long int sub;	cin >> sub;
		c.push_back(sub);
	}
	sort(a.begin(),a.end(),greater<long long int>());
	sort(b.begin(),b.end(),greater<long long int>());
	sort(c.begin(),c.end(),greater<long long int>());
	vector<long long int> ab;
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			ab.push_back(a[i]+b[j]);
		}
	}
	sort(ab.begin(),ab.end(),greater<long long int>());
	vector<long long int> abc;
	int sub = min(x*y,k);
	for(int i=0;i<sub;i++){
		for(int j=0;j<z;j++){
			abc.push_back(ab[i]+c[j]);
		}
	}
	sort(abc.begin(),abc.end(),greater<long long int>());
	for(int i=0;i<k;i++)	cout << abc[i] << endl;
	return 0;
}

Measured memory_bytes: 43128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

vector <ll> pri;
ll n, ans = 1e18;

void exgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) { x = 1; y = 0; return; }
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}

int main() {
    read(n); n *= 2;
    ll tmp = 1;
    while (n % 2 == 0) tmp *= 2, n /= 2;
    if (tmp != 1) pri.push_back(tmp);
    for (int i = 3; 1ll * i * i <= n; i += 2) {
        ll pw = 1;
        while (n % i == 0) pw *= i, n /= i;
        if (pw != 1) pri.push_back(pw);
    }
    if (n != 1) pri.push_back(n);
    int len = (int)pri.size();
    for (int i = 0; i < (1 << len); i++) {
        ll d1 = 1, d2 = 1;
        for (int j = 0; j < len; j++) {
            if ((i >> j) & 1) d1 *= pri[j];
            else d2 *= pri[j];
        }
        ll a, b;
        exgcd(d1, d2, a, b);
        if (a < 0) {
            ll cnt = (-a - 1) / d2 + 1;
            a += d2 * cnt; b -= d1 * cnt;
        }
        if (a > 0) {
            ll cnt = a / d2;
            a -= d2 * cnt; b += d1 * cnt;
        }
        if (a == 0) a += d2, b -= d1;
        if (b == 0) a += d2, b -= d1;
        // cout << "!" << a << " " << b << " " << d1 << " " << d2 << endl;
        ans = min(ans, a * d1 - 1);
    }
    print(ans, '\n');
    return 0;
}

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

public class Main {

	static String BLOOD_A_ = "A";
	static String BLOOD_B_ = "B";
	static String BLOOD_AB = "AB";
	static String BLOOD_O_ = "O";
	static String DELIM = ",";

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

		int[] sum = new int[4];
		StringTokenizer st;
		String blood;

		while ((line = br.readLine()) != null) {

			st = new StringTokenizer(line, DELIM);
			st.nextToken();
			blood = st.nextToken();

			if (blood.equals(BLOOD_A_)) {
				sum[0]++;
			} else if (blood.equals(BLOOD_B_)) {
				sum[1]++;
			} else if (blood.equals(BLOOD_AB)) {
				sum[2]++;
			} else if (blood.equals(BLOOD_O_)) {
				sum[3]++;
			}
		}
		for (int i : sum) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = n;
  int sum = 0;
  while(x>0){
    sum += x % 10;
    x = x/10;
  }
  if(n % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
  const int digits_num = 4;
  char s[digits_num];
  cin >> s;
  for (int i = 0; i < digits_num - 1; ++i) {
    if (s[i] == s[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    const int MOD = 1E9 + 7;
    int n, m;
    cin >> n >> m;
    vector<bool> can(n+1, true);
    int a;
    for (int i = 0; i < m; i++){
        cin >> a;
        can[a] = false;
    }
    int c[n+1];
    c[0] = 1;
    c[1] = can[1];
    for (int i = 2; i < n+1; i++){
        c[i] = 0;
        if (can[i]){
            if (can[i-1]) c[i] = ((c[i]%MOD) + (c[i-1]%MOD))%MOD;
            if (can[i-2]) c[i] = ((c[i]%MOD) + (c[i-2]%MOD))%MOD;
        } 
    }
    cout << c[n] << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 4000
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	NN = inputInt()

	ki = 0
	gu = 0
	for i in range(1, NN+1):
		if i % 2 == 1:
			ki += 1
		else:
			gu += 1

	print(ki / NN)


if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);   t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}
     
void solve(){
    ll n,k,s;cin>>n>>k>>s;
    if(s != 1e9)
    {
        forn(i, k)
        {
            cout<<s<<" ";
        }
        forn(i, n-k)
        {
            cout<<s+1<<" ";
        }
    }
    else
    {
        forn(i, k)
        {
            cout<<s<<" ";
        }
        forn(i, n-k)
        {
            cout<<1<<" ";
        }
    }
    cout<<ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    //cin>>t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    
  int string_length;
  int string_num;
  cin >> string_num >> string_length;
 
  vector<std::string> strings;
  
  int i;
  for(i=0; i < string_num; i++){
    string input;
    cin >> input;
    strings.push_back(input);
  }
  
  sort(strings.begin(), strings.end());
  
  for(i=0;i<string_num;i++){
    cout << strings[i];
  }
  
  return 0;
}

Measured memory_bytes: 256
import bisect
a, b , q= map(int, input().split())
INF = 10**18
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s = [-INF] + s + [INF]
t = [-INF] + t + [INF]
for q in x:
    b, d = bisect.bisect(s, q), bisect.bisect(t, q)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1, d2 = abs(S-q) + abs(S-T), abs(T-q) + abs(S-T)
            res = min(res, d1, d2)
    print(res)


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;
const double pi = 3.14159265358979;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta = abs(30*h+m/2-6*m)*pi/180;
    double ans = sqrt(a*a+b*b-2*a*b*cos(theta));
    cout << fixed << setprecision(11) << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 4296
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  int ai=0,c=1;
  for(int i=0;i<n;i++){
    if(a[ai]==2){
      printf("%d",c);
      return 0;
    }
    ai = a[ai] - 1;
    c++;
  }
  printf("-1");
}

Measured memory_bytes: 512
N = int(input())
a = list(int(i) for i in input().split())
x =a[0]
y =a[1]
for j in range(N-1):
    a = list(int(i) for i in input().split())
    if a[0]>x:
        if a[1]>y:
            x =a[0]
            y =a[1]
        else:
            q=(y-1)//a[1]+1
            x =a[0]*q
            y =a[1]*q
    else:
        if a[1]>y:
            p=(x-1)//a[0]+1
            x = a[0]*p
            y = a[1]*p
        else:
            q=(y-1)//a[1]+1
            p=(x-1)//a[0]+1
            if p > q:
                x =a[0]*p
                y =a[1]*p
            else:
                x = a[0]*q
                y = a[1]*q
print(x+y)

Measured memory_bytes: 3064