akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
typedef long long ll;


int main() {

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n;i++)
        ans += (n - 1) / i;

    cout << ans;

    return 0;
}

Measured memory_bytes: 3628
<?php
$tmp = [];
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}

list($A, $B, $C, $D) = explode(' ', $tmp[0]);

$alice = range($A, $B);
$bob = range($C, $D);

$section = array_intersect($alice, $bob);

$end = end($section);
reset($section);
$start = current($section);

echo $end - $start;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() 
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<ll> x;
    x.push_back(a * c);
    x.push_back(a * d);
    x.push_back(b * c);
    x.push_back(b * d);

    cout << *max_element(x.begin(), x.end()) << endl;

}

Measured memory_bytes: 3624
def main():

    N, M = map(int, input().split())
    bridges = [None] * M
    for m in range(M):
        bridges[m] = tuple(map(int, input().split()))

    tree = UnionFind(N)
    increments = [0] * M

    for m in range(M)[::-1]:

        if tree.is_same(*bridges[m]):
            continue

        increments[m] += tree.get_size(bridges[m][0]) * tree.get_size(bridges[m][1])
        tree.unite(*bridges[m])

    cumsum = 0
    for i in increments:
        cumsum += i
        print(cumsum)


class UnionFind:

    def __init__(self, n):
        self.par = list(range(n+1))
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.rank[y] += 1

    def get_size(self, x):
        return self.size[self.find(x)]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

main()


Measured memory_bytes: 24044
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int ans = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (max <= tmp) {
                ans++;
            }
            if (max < tmp) {
                max = tmp;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

h1,m1,h2,m2,k = mapi()
delta =m2+h2*60-(m1+h1*60)-k
print(delta)


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

int main(){
  int n,k;
  cin >>n >>k;
  vector<int> h(n);
  rep(i,n) cin >>h[i];
  int ans = 1e10;
  sort(h.begin(), h.end());
  for(int i = 0; i<n-k+1; i++){
    int curans = h[i+k-1]-h[i];
    ans = min(ans, curans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;
using ll = long long;

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

int main() {
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    ll g = gcd(N, M);
    ll a = N / g, b = M / g;
    for (ll i = 0; i < g; ++i) {
        if (S[a * i] != T[b * i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << N * M / g << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){

int W,H;

while(scanf("%d %d\n", &H, &W)){

if(W == 0 && H == 0) return 0;

for (int i = 0 ; i < H; i++){
for (int j = 0; j < W; j++){
if ( (i % 2 == 0 && j % 2  == 0) || (i % 2 == 1 && j % 2  == 1))
printf("#");
else printf(".");
}
printf("\n");

}
printf("\n");
}

}


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

int main(){
	int a[4][4],n,f[4][4];
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	cin>>n;
	int b;
	memset(f,0,sizeof(f));
	for(int k=1;k<=n;k++){
				cin>>b;
		for(int i=1;i<=3;i++)
			for(int j=1;j<=3;j++){
			
				if(a[i][j]==b){
					f[i][j]=1;
				}
			}
		}
	if(f[1][1]==1&&f[1][2]==1&&f[1][3]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[2][1]==1&&f[2][2]==1&&f[2][3]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[3][1]==1&&f[3][2]==1&&f[3][3]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[1][1]==1&&f[2][1]==1&&f[3][1]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[1][2]==1&&f[2][2]==1&&f[3][2]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[1][3]==1&&f[2][3]==1&&f[3][3]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[1][1]==1&&f[2][2]==1&&f[3][3]==1){
		cout<<"Yes";
		return 0;
	}
	if(f[1][3]==1&&f[2][2]==1&&f[3][1]==1){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a <= b <= c:
    print(a , b , c)
    
elif a <= c <= b:
    print(a , c , b)

elif b <= a <= c:
    print(b , a , c)
    
elif b <= c <= a:
    print(b , c , a)
    
elif c <= a <= b:
    print(c , a , b)
    
elif c <= b <= a:
    print(c , b , a)


Measured memory_bytes: 5596
n = int(input())
lis = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
    val = list(str(i))
    lis[int(val[-1])][int(val[0])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += lis[i][j] * lis[j][i]
# print(lis)
print(ans)

Measured memory_bytes: 3316
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    n = int(input())
    P = list(map(int, input().split()))

    count = 0
    for i in range(len(P) - 2):
        
        if P[i] < P[i + 1] and P[i + 1] < P[i + 2] or \
                P[i] > P[i + 1] and P[i + 1] > P[i + 2]:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
  int N; cin >> N;
  vector<bool> flag(8,false);
  int cnt = 0;

  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if( a < 400){ flag[0] = true;}
    else if( 400 <= a && a < 800){ flag[1] = true;}
    else if(800 <= a && a < 1200){ flag[2]= true;}
    else if(1200 <= a&& a < 1600){ flag[3] = true;}
    else if(1600 <= a && a < 2000){flag[4] = true;}
    else if(2000 <= a && a < 2400){ flag[5] = true;}
    else if(2400 <= a && a < 2800){ flag[6] = true;}
    else if(2800 <= a && a < 3200){flag[7] = true;}
    else{ cnt++;}}
   int cnt2 = 0;
  for(int i = 0; i < 8; i++){
    if(flag[i]){cnt2++;}} //色の確定している種類数
  
  if(cnt == 0){
    cout << cnt2 << " " << cnt2 << endl;}// 3200以上が存在しない時は、変化しようがない
  else{
    if(cnt2 > 0){
      cout << cnt2 << " " << cnt2 + cnt << endl;}
    else{
      cout << 1 << " " << cnt << endl;}}
  
  return 0;}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1e9
#define MOD 1e9+7
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,T;
    cin>>N>>T;
    vector<ll> t(N);
    REP(i,N) cin>>t[i];
    ll ans=0;
    REP(i,N-1){
        ans += min(T,t[i+1]-t[i]);
    }
    ans += T;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
K=int(input())
A_B=list(map(int,input().split()))
A=A_B[0]
B=A_B[1]
m=1
c=0
for i in range(A,(B+1)):
  if(i%K==0):
    c=1
    break
if(c==1):
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

vector<int> xc;

int L[200000];
int R[200000];
int X[200000];
int D[200000];

vector<int> E[600000];
int ans[600000];

int main() {
    int n, q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> L[i] >> R[i] >> X[i];
        xc.push_back(L[i] - X[i]);
        xc.push_back(R[i] - X[i]);
    }

    for(int i = 0; i < q; i++) {
        cin >> D[i];
        xc.push_back(D[i]);
    }

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

    for(int i = 0; i < n; i++) {
        int s = lower_bound(xc.begin(), xc.end(), L[i] - X[i]) - xc.begin();
        int t = lower_bound(xc.begin(), xc.end(), R[i] - X[i]) - xc.begin();

        E[s].push_back(X[i]);
        E[t].push_back(-X[i]);
    }

    map<int, int> count;
    set<int> mx;
    for(int i = 0; i < xc.size(); i++) {
        for(int j = 0; j < E[i].size(); j++) {
            if(E[i][j] > 0) {
                int e = E[i][j];
                if (count[e] == 0) mx.insert(e);
                count[e]++;
            }
            else {
                int e = -E[i][j];
                count[e]--;
                if (count[e] == 0) mx.erase(e);
            }
        }

        if (mx.empty()) ans[i] = -1;
        else ans[i] = *(mx.begin());
    }

    for(int i = 0; i < q; i++) {
        int d = lower_bound(xc.begin(), xc.end(), D[i]) - xc.begin();
        printf("%d\n", ans[d]);
    }
    return 0;
}

Measured memory_bytes: 54508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    string s,t; cin >> s >> t;
    int n = s.size(),m = t.size();
    vector<char> ss(n),tt(m);

    rep(i,n){
        ss[i] = s[i];
    }
    sort(ss.begin(),ss.end());
    rep(i,m){
        tt[i] = t[i];
    }
    sort(tt.begin(),tt.end());
    reverse(tt.begin(),tt.end());
    string s_dash,t_dash;
    rep(i,n){
        s_dash += ss[i];
    }
    rep(i,m){
        t_dash += tt[i];
    }
    if(s_dash < t_dash){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair
#define clamp(v,lo,hi) min(max(v,lo),hi)

template <typename T>
inline bool found(set<T> &s, T elem) { return s.find(elem) != s.end(); }
template <typename T>
inline bool found(unordered_set<T> &s, T elem) { return s.find(elem) != s.end(); }
template <typename T, typename U>
inline bool found(map<T,U> &s, U elem) { return s.find(elem) != s.end(); }
template <typename T, typename U>
inline bool found(unordered_map<T,U> &s, U elem) { return s.find(elem) != s.end(); }
template <typename T>
inline bool found(vector<T> &s, T elem) { return find(s.begin(), s.end(), elem) != s.end(); }
inline int found(string &s, string t) { return (int)s.find(t); }
inline int found(string &s, int c) { return (int)s.find(c); }

template<typename T1, typename T2> inline void amin(T1 & a, T2 const & b) { if (a>b) a=b; }
template<typename T1, typename T2> inline void amax(T1 & a, T2 const & b) { if (a<b) a=b; }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }

int main() {
    int N; cin >> N;
    vi b(N-1); rep(i,N-1) cin >> b[i];
    vi a(N,0);
    a[0] = b[0];
    a[N-1] = b[N-2];
    for(int i=1; i<=N-2; ++i){
        a[i] = min(b[i-1], b[i]);
    }
    int x = accumulate(ALL(a), 0);
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int n;
  cin >> n;
  int ret = powerexp(n, 3);
  cout << ret << endl;	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3204
n = int(input())
abc=[[]]*n
dp = [[0]*3 for _ in range(n)]

for i in range(n):
  abc[i] = list(map(int,input().split()))

for i in range(3):
  dp[0][i] = abc[0][i]

for i in range(1,n):
  dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + abc[i][0]
  dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + abc[i][1]
  dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + abc[i][2]
          
print(max(dp[-1]))          

Measured memory_bytes: 52340
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 100000;

struct UnionFind
{
	int N;
	vector<int> parent;
	vector<int> size_r;
	int num_of_sets;

	UnionFind(int N) :  N(N), parent(N), size_r(N, 1), num_of_sets(N) {
		for (int i = 0; i < N; ++i) parent[i] = i;
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (size_r[x] < size_r[y]) swap(x, y);
		parent[y] = x;
		size_r[x] += size_r[y];
		size_r[y] = 0;
		num_of_sets--;
		return true;
	}

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

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

	vector<int> roots() {
		vector<int> v(N);
		for (int i = 0; i < N; ++i) v[i] = root(i);
		return v;
	}
};

int main() {
	long long n, m;
	cin >> n >> m;
	int A[m], B[m];
	for (int i = 0; i < m; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	UnionFind U(n);
	vector<long long> ans;
	long long x = 0;
	for (int i = m-1; i >= 0; i--) {
		ans.push_back(x);
		int a = A[i], b = B[i];
		if (U.same(a, b)) continue;
		x += (long long)U.size(a) * U.size(b);
		U.merge(a, b);
	}
	for (int i = m-1; i >= 0; i--) {
		cout << x - ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5772
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  cout << pow(N,3) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
using namespace std;

int gcd(int x, int y) {
	if (y == 0)
		return x;
	else
		return gcd(y, x%y);
}

int main()
{
	int n, t, x;
	cin >> n;
	cin >> x;
	for (int i = 1; i < n; i++){
		cin >> t;
		x = gcd(x, t);
	}
	cout << x << endl;
}

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

using namespace std;

#define ll long long int
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2(x,y) scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%lld",n)
#define prln(n) printf("%lld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)

#define TC(n) printf("Case %d:\n",n)

const int N=1000005;

int a[N];
int vis[N];
int node[N];

int main()
{

    int n,x;
    read2(n,x);

    n=n*2;

    if(x==1 || x==(n-1) ){
        puts("No");
        return 0;
    }
    else{

        int m=n/2;
        a[m]=x;
        a[m+1]=x+1;
        a[m-1]=x-1;
        vis[x]=vis[x+1]=vis[x-1]=1;
        node[m]=node[m+1]=node[m-1]=1;

        int pos=1;

        for(int i=1;i<n;i++)
        {
            if(node[i])continue;
            else{
                while(vis[pos]){
                    pos++;
                    if(pos>=n)pos=1;
                }
                a[i]=pos;
                vis[pos]=1;
                 pos++;
                if(pos>=n)pos=1;
            }
        }

        puts("Yes");
        fo(i,1,n)
        prn(a[i]);


    }


    return 0;
}














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

int main(){
 times(i,9) times(j,9) printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
 return 0;
}

Measured memory_bytes: 1096
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

L = [-1] * (n + 1)
for i in range(n + 1):
  if L[a[i]] == -1:
    L[a[i]] = i
  else:
    l = L[a[i]]
    r = i

s = n - r + l
com = comb(n + 1, MOD)
for i in range(1, n + 2):
  #lrを使わない
  if i < n:
    ans = com.com(n - 1, i)
  else:
    ans = 0
  #lrのうち片方を使う
  if 1 <= i <= n:
    ans+= com.com(n - 1, i - 1) * 2
    if i - 1 <= s:
      ans -= com.com(s, i - 1)
    ans %= MOD
  #lrを両方使う
  if 1 < i:
    ans = (ans + com.com(n - 1, i - 2)) % MOD
  print(ans)

Measured memory_bytes: 26980
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    if(a==0&&b==0) break; 
    unsigned long long int data[a+1][b+1];
    int n,x,y;
    bool k = true;
    cin >> n;
    for(int i=1;i<=a;i++){
      for(int j=1;j<=b;j++) data[i][j] = 0;
    }
    for(int i=0;i<n;i++){
      cin >> x >> y;
      data[x][y] = -1;
    }
    for(int i=1;i<=a;i++){
      if(data[i][1]==-1||!k){
	data[i][1] = 0;
	k = false; 
      }
      else data[i][1] = 1;
    }
    k = true;
    for(int i=1;i<=b;i++){
      if(data[1][i]==-1||!k){
	data[1][i] = 0;
	k = false;
      }
      else data[1][i] = 1;

    }
    for(int i=2;i<=a;i++){
      for(int j=2;j<=b;j++){
	if(data[i][j]==-1){
	  data[i][j] = 0;	 
	  continue;
	}
	else data[i][j] = data[i-1][j] + data[i][j-1];
      }
    }
    cout << data[a][b] << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
n, x = map(int, input().split())
A = [1]
P = [1]
for i in range(n):
    A.append(A[i] * 2 + 3)
    P.append(P[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= A[n - 1] + 1:
        return f(n - 1, x- 1)
    else:
        return P[n - 1] + 1 + f(n - 1, x - A[n - 1] -2)
    
print(f(n, x))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    
}

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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  V a;
  ll n;
  ll a_min = 1000000000000000;
  ll min_idx = 0;
  cin >> n;
  for(ll i=0; i<5; i++) {
    ll temp;
    cin >> temp;
    a.push_back(temp);
    if(temp < a_min) {
      a_min = temp;
      min_idx = i;
    }
  }

  cout << n / a_min + ((n % a_min == 0) ? 0:1) + (4-min_idx) + min_idx << endl;

  return 0;
}


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

string S[55];
int cou[255];

int main(){
	long long N;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}

	for(int i = 0; i < 255; i++){
		cou[i] = 100;
	}

	for(int i = 0; i < N; i++){
		string curstr = S[i];
		int tmp[255];
		for(int j = 0; j < 255; j++){
			tmp[j] = 0;
		}
		for(int j = 0; j < curstr.size(); j++){
			tmp[curstr[j]]++;
		}

		for(int j = 0; j < 255; j++){
			cou[j] = min(cou[j], tmp[j]);
		}
	}


	for(int i = 'a'; i <= 'z'; i++){
		for(int j = 0; j < cou[i]; j++){
			cout << char(i);
		}
	}
	cout << endl;




}


Measured memory_bytes: 256
import qualified Data.Set as S

f::String->S.Set Char
f t1 =S.fromList t1

f2::Int->String->[Int]
f2 n t
   |null (drop n t)==True =[]
   |otherwise=let s1=f (take n t)
                  s2=f (drop n t)
                  s3=S.intersection s1 s2
              in S.size s3 : f2 (n+1) t

main =do
        e<-getLine
        e2<-getLine
        putStrLn $ show $ maximum $ f2 1 e2

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;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;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  int ans;
  if(a+b==3){
    ans=3;
  }else if(a+b==4){
    ans=2;
  }else{
    ans=1;
  }
  PRN(ans);
  return 0;
}


Measured memory_bytes: 128
<?php
  
	$N = trim(fgets(STDIN));
	$Vs = explode(' ',trim(fgets(STDIN)));
	$Cs = explode(' ',trim(fgets(STDIN)));

	$sales = 0;
	for ($i=0; $i<$N; $i++){
      	$margin = $Vs[$i]-$Cs[$i];
    	if ($margin > 0){
          $sales += $margin;
        }
    }

	echo $sales;

?>

Measured memory_bytes: 4732
S=input()
result1=0
result2=0
if S[0]=='1':
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                result1+=1
            if S[i]=='1':
                result2+=1
        else:
            if S[i]=='1':
                result1+=1
            if S[i]=='0':
                result2+=1
    print(min(result1,result2))
else:
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                result1+=1
            if S[i]=='1':
                result2+=1
        else:
            if S[i]=='1':
                result1+=1
            if S[i]=='0':
                result2+=1
    print(min(result1,result2))

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	int a[n]={};
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	std::sort(a,a+n);
	int ans=0;
	int x=0;
	for(int i=0;i<n;i++){
		if(x!=a[i]){
			x=a[i];
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
int read()
{
	int s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
}
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
char ss[111111];
int main()
{
	int N=read(),M=read();
	scanf("%s",ss+1);
	if(ss[N]=='L') ss[++N]='R';
	else ss[++N]='L';
	int ans=0,lst=0;
	for(int i=1;i<=N;++i)if(ss[i]!=ss[i-1]) ans+=i-lst-1,lst=i;
	ans+=M<<1;
	printf("%d",min(ans,N-2));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int ll
void test_case(){
	int n , m; cin >> n >> m;
	vector<int> hash(n);
	int sum = 0;
	for(auto &x:hash){
		cin >> x;
		sum+=x;
	}
	int count = 0;
	//~ int k = sum/(4*m);
	for(auto x : hash)
		if(x*4*m >= sum)
			count++;
	if(count >= m)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS        = 1e-10;
const double    PI         = acos(-1.0);
const int       INFTY_INT  = (1<<21);
const ll        INFTY_LL   = (1LL<<60);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    int n; cin >> n;
    ll ans = 0;
    REP(i, n) {
        ll a; cin >> a;
        while (a % 2LL == 0LL) {
            a /= 2LL;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;


const long mod=1000000007;

long modPower(long v,long N){
    long tmp=1;
    for(long i=0;i<N;i++){
        tmp = ( (tmp % mod) * (v % mod) ) % mod;
    }
    return tmp;
}


int main(){

    long N;
    cin >> N;

    // 10^N - 8^N - (9^N-8^N)*2
    // N=2 -> 100-64-(81-64)*2 = 36-34=2

    long ten = modPower(10,N);
    long nine = modPower(9,N);
    long eight = modPower(8,N);
    
    long nine_eight = ( (nine%mod) + ((mod-eight)%mod) )%mod;
    long nine_eight2 = ( (nine_eight % mod) * (2 % mod) ) % mod;
    long ten_eight = ( (ten % mod) + ( (mod - eight) % mod) ) % mod;
    long result = ( (ten_eight % mod) + ( (mod - nine_eight2) % mod) ) % mod;
    cout << result << endl;

    
    return 0;
}

Measured memory_bytes: 3632
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-07 20:37:30
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 200000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

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

    vector<int> b = a;
    sort(all(b));

    int p, q;
    p = b[n/2 - 1];
    q = b[n/2];

    for (int i = 0; i < n; i++) {
        if (a[i] <= p) cout << q << endl;
        else cout << p << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	string str;
	cin >> str;
	int count = 0;
	char currentCh = str[0];
	for (int i = 1; i < str.length(); i++) {
		if (currentCh != str[i]) {
			count++;
			currentCh = str[i];
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    long double a,b,c;
    scanf("%Lf%Lf%Lf",&a,&b,&c);
    long double d=c-a-b;
    if(d>0&&d*d>4*a*b)
    printf("Yes");
    else
    printf("No");
    return 0;
}

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

ans = 0
flag = True
while flag:
    for i in range(len(A)):
        if A[i]%2 == 0:
            A[i] = A[i]/2
        else:
            flag = False
            break
    if flag:
        ans += 1

print(ans)
            
        



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

bool isPalindromeNumber(int x){
    std::string s = std::to_string(x);

    for(int i=0;i<2;++i){
        if(s[i] != s[4 - i]){
            return false;
        }
    }

    return true;
}

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

    std::cin >> A >> B;

    int cnt = 0;

    for(int i=A;i<=B;++i){
        if(isPalindromeNumber(i)){
            cnt += 1;
        }
    }

    std::cout << cnt << std::endl;
}


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

int main(){
  int N ; cin >> N ;
  string S ; cin >> S ;
  int ans = 0 ;
  for(int i =0 ; i<N-2;i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    string base="MARCH";
    map<char,ll>mp;
    int n; cin>>n;
    rep(i,n){
        string temp;cin>>temp;
        mp[temp.front()]++;
    }
    ll ans=0;
    rep(i,5)rep(j,5)rep(k,5){
        if(i==j||j==k||k==i)continue;
        ll temp=mp[base[i]]*mp[base[j]]*mp[base[k]];
        ans+=temp;
    }
    cout<<ans/6<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>12){
        cout<<b<<endl;
    }else if(a<=12&&a>=6){
        cout<<b/2<<endl;
    }else{
        cout<<0<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,c=0;
	cin>>a;
	char b[a];
	for(int i=0;i<a;i++){
		cin>>b[i];
		if(b[i]=='Y'){
			c++;
		}
	}
	if(c>0){
		cout<<"Four";
	}
	else{
		cout<<"Three";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  string s;
  cin>>s;
  vi b(n+1,0);
  vi nx(n+1,0);
  FOR(i,0,n+1){
    if(s[i]=='1'){
      b[i]=1;
    }
  }
  int bfr=n;
  FORD(i,n,0){
    if(b[i]==1){
      nx[i]=bfr;
    }else{
      bfr=i;
      nx[i]=i;
    }
  }
  vi ans;
  int nw=n;
  while(nw!=0){
    if(nw<=m){
      ans.PB(nw);
      break;
    }
    if(b[nw-m]==1){
      int t=nx[nw-m];
      if(nw==t){
        cout<<-1<<endl;
        return 0;
      }
      ans.PB(nw-t);
      nw=t;
    }else{
      ans.PB(m);
      nw=nw-m;
    }
  }

  int ansl=ans.size();
  FORD(i,ansl,0){
    cout<<ans[i]<<" ";
  }
}


Measured memory_bytes: 1912
#include<iostream>
using namespace std;
int N,i,dp[1<<7];
int main(void){
  cin>>N;
  dp[0]=1;
  for(i=0;i<=N;i++){
    if(dp[i])dp[i+4]=1,dp[i+7]=1;
  }
  cout<<(dp[N]?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for(int i=0;i<N;i++) std::cin >> A[i];
  sort(A.begin(), A.end());
  bool flag = true;
  int now = A[0], count=1;
  for(int i=1;i<N;i++) {
    if(A[i]-A[i-1]>=2) flag = false;
    if(A[i]==A[i-1])count++;
    else if(now!=A[0]&&count<2) flag = false;
    now = A[i];
  }
  if(N>=3 && A[0]==A[2]) flag = false;
  if(A[0]==A[1] && A[N-1]%2!=1) flag = false;
  if(A[0]!=A[1] && A[N-1]%2!=0) flag = false;
  std::cout << (flag?"Possible":"Impossible") << '\n';
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y[ohara],sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
V g[ohara];
ll dat[ohara];
ll dp[ohara];
queue<ll> que;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,m){
        cin>>x[i]>>y[i];
        x[i]--;y[i]--;
        g[x[i]].push_back(y[i]);
        dat[y[i]]++;//向かってくる辺の数
    }
    rep(i,n){
        if(dat[i]==0)que.push(i);
    }
    while(!que.empty()){
        ll pa=que.front();
        que.pop();
        rep(i,Size(g[pa])){
            ll to=g[pa][i];
            dp[to]=max(dp[to],dp[pa]+1);
            dat[to]--;
            if(dat[to]==0)que.push(to);
        }
    }
    rep(i,n)ans=max(ans,dp[i]);
    Cout(ans);
    return 0;
}


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

typedef int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_N = 111111;
int prime[MAX_N];
bool flag[MAX_N+1];
int m, a, b;
int p, q;

int SieveOfEratosthenes(const int& MAX_N = MAX_N, bool* flag = flag, int* prime = prime)
{
  int ptr = 0;
  prime[ptr++] = 2;
  flag[0] = flag[1] = true;
  for(int i=4; i<=MAX_N; i+=2) flag[i] = true;
  for(int i=3; i<=MAX_N; i+=2){
    if(!flag[i]){
      prime[ptr++] = i;
      for(int j=2*i; j<=MAX_N; j+=i) flag[j] = true;
    }
  }
  return ptr;
}


int main()
{
  int ptr = SieveOfEratosthenes();

  while(cin >> m >> a >> b, m){
    int p, q;
    int mx = -INF;
    rep(i, ptr){
      if(prime[i] * prime[i] > m) break;
      int mn = min(m / prime[i], b * prime[i] / a);
      int t = upper_bound(prime + i, prime + ptr, mn) - prime - 1;
      if(maxup(mx, prime[i] * prime[t])){
        p = i;
        q = t;
      }
    }
    cout << prime[p] << ' ' << prime[q] << endl;
  }

  return 0;
}

Measured memory_bytes: 1308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100005];
ll vis[100005];
vector<ll>arr[100005];
ll n,m;
void dfs(ll i){
			
	vis[i]=1;
	for(auto k:arr[i]){
		if(!vis[k]){
			dfs(k);
		}
		dp[i]=max(dp[i],dp[k]+1);
	}
	
		
}
int main(){
	
	cin>>n>>m;

	
for(int i=0;i<m;i++){
	int x,y;
	cin>>x>>y;
	
	arr[x].push_back(y);
}

memset(dp,0,sizeof(dp));
memset(vis,0,sizeof(vis));
for(int i=1;i<=n;i++){
	if(vis[i]==0){
		dfs(i);
		
	}
}
	cout<<*max_element(dp,dp+n+1);
	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n;
    cin>>n;
    lli a[n], b[n], c[n], dp[n][3];
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=a[0], dp[0][1]=b[0], dp[0][2]=c[0];
    for(int i=1; i<n; i++)
        dp[i][0]=max(dp[i-1][1], dp[i-1][2])+a[i], dp[i][1]=max(dp[i-1][0], dp[i-1][2])+b[i], dp[i][2]=max(dp[i-1][0], dp[i-1][1])+c[i];
    cout<<(max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])));
    return 0;
}

Measured memory_bytes: 8276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define PI acos(-1)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());

	vi v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(all(v));
	if(v[0] == v[1] && v[1] != v[2]) {
		cout << "Yes";
	}
	else if(v[1] == v[2] && v[0] != v[1]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

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


int main()
{
    int l, r, n;
    cin >> l >> r >> n;
    int cnt=0;
    for(l;l<=r;l++)
    {
        if(!(l%n))
        {
            cnt++;
            break;
        }
    }
    cnt+=(r-l)/n;
    cout << cnt;
	return 0;
}



Measured memory_bytes: 3632