akhauriyash/Code-Regression huggingface dataset:
MOD, ans = 10**9+7, 0
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
kai, gai = [1], [1]
for i in range(n):
	kai.append((kai[i] * (i+1)) % MOD)
	gai.append(pow((kai[i] * (i+1)) % MOD, MOD-2, MOD))
for i in range(n):
	x, y = 0, 0
	if i <= (n-k):
		x = (a[i] * kai[n-i-1] * gai[n-i-k] * gai[k-1]) % MOD
	if i >= (k-1):
		y = (a[i] * kai[i] * gai[i-k+1] * gai[k-1]) % MOD
	ans = (ans + y - x) % MOD
print(ans)

Measured memory_bytes: 71208
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0)
#define MAX_V 200005

using namespace std;

int p[MAX_V], s[MAX_V], v[MAX_V];

int main()
{
    FAST_IO;
    int n;
    scanf("%d", &n);
    scanf("%d", v+0);
    p[0] = v[0];
    for (int i = 1; i < n; i++) {
        scanf("%d", v+i);
        p[i] = __gcd(v[i], p[i-1]);
    }
    s[n-1] = v[n-1];
    for (int i = n-2; i >= 0; i--)
        s[i] = __gcd(v[i], s[i+1]);

    int ans = max(s[1], p[n-2]);
    for (int i = 1; i < n - 1; i++)
        ans = max(__gcd(p[i-1], s[i+1]), ans);

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

Measured memory_bytes: 1408
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int maxW = sc.nextInt();

        int maxV = 100000;

        long[][] dp = new long[n + 1][];
        dp[0] = new long[maxV + 1];

        for (int i = 1; i <= n; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            dp[i] = dp[i - 1].clone();
            for (int j = 1; j <= v; j++) {
                if (dp[i - 1][j] == 0) {
                    dp[i][j] = w;
                } else {
                    dp[i][j] = Math.min(dp[i - 1][j], w);
                }
            }
            for (int j = v + 1; j <= maxV; j++) {
                if (dp[i - 1][j - v] == 0) {
                    break;
                } else {
                    if (dp[i][j] == 0) {
                        dp[i][j] = dp[i - 1][j - v] + w;
                    } else {
                        dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - v] + w);
                    }
                }
            }
        }

        int ans = 0;

        for (int i = 1; i <= maxV; i++) {
            if (dp[n][i] == 0 || dp[n][i] > maxW) {
                continue;
            }
            ans = Math.max(ans, i);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 126564
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
using namespace std;
const LL MOD=1e9+7;
LL n,a,b,mx,sum,h[100010];
bool check(LL mid)
{
	LL sum=0;
	rep(i,n)
	{
		if(h[i]-mid*b>0) 
			sum+=(h[i]-mid*b+(a-b-1))/(a-b);
	}
	return sum<=mid;
}
int main()
{
	cin>>n>>a>>b;
	LL mid;
	rep(i,n)
	{
		cin>>h[i];
		sum+=h[i];
		mx=max(h[i],mx);
	}
	LL lb=(mx+a-1)/a,ub=(mx+b-1)/b;
	while(lb<ub)
	{
		mid=(lb+ub)/2;
		if(check(mid)) ub=mid;
		else lb=mid+1;
	}
	cout<<lb<<endl;
  rt0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1e9+7;
ll dp[1007][10009];
vector<vector<ll>> box;
vector<ll> v;
ll solve(int i,int w)
{
  if(w>10000)
  return 0;
  if(i==0)
    return (w<=box[i][1])?box[i][2]:0;//w<=s[i]
  if(dp[i][w]!=-1)
    return dp[i][w];
  ll ans=solve(i-1,w);
  if(box[i][1]>=w)
    ans=max(ans,box[i][2]+(solve(i-1,w+box[i][0])));
  return dp[i][w]=ans;
}
bool cmp(vector<ll>& a,vector<ll>& b)
{
  return (a[0]+a[1])>(b[0]+b[1]);
}
int main()
{
  memset(dp,-1,sizeof(dp));
  int n;
  cin>>n;
  box.resize(n,vector<ll>(3));// w and s
  for(int i=0;i<n;i++)
    cin>>box[i][0]>>box[i][1]>>box[i][2];
  sort(box.begin(),box.end(),cmp);
  cout<<solve(n-1,0)<<endl;
  return 0;
}


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

template <typename T, T (*op)(T, T), T (*ie)()> class SegmentTree {
private:
  int N, size, log;
  vector<T> D;
  void apply(int k) { D.at(k) = op(D.at(2 * k), D.at(2 * k + 1)); }
  int ceil_pow(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
  }

public:
  SegmentTree() : SegmentTree(0) {}
  SegmentTree(int n) : SegmentTree(vector<T>(n, ie())) {}
  SegmentTree(const vector<T> &v) : N((int)v.size()) {
    log = ceil_pow(N);
    size = 1 << log;
    D = vector<T>(2 * size, ie());
    for (int i = 0; i < N; i++) D.at(size + i) = v.at(i);
    for (int i = size - 1; i >= 1; i--) apply(i);
  }
  void set(int p, T x) {
    p += size;
    D.at(p) = x;
    for (int i = 1; i <= log; i++) apply(p >> i);
  }
  T get(int p) { return D.at(p + size); }
  T query(int l, int r) {
    r++;
    T sml = ie(), smr = ie();
    l += size, r += size;
    while (l < r) {
      if (l & 1) sml = op(sml, D.at(l++));
      if (r & 1) smr = op(D.at(--r), smr);
      l >>= 1, r >>= 1;
    }
    return op(sml, smr);
  }
  T query_all() { return D.at(1); }
  template <bool (*f)(T)> int max_right(int l) {
    return max_right(l, [](T x) { return f(x); });
  }
  template <class F> int max_right(int l, F f) {
    if (l == N) return N;
    l += size;
    T sm = ie();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!f(op(sm, D.at(l)))) {
        while (l < size) {
          l = (2 * l);
          if (f(op(sm, D.at(l)))) sm = op(sm, D.at(l++));
        }
        return l - size;
      }
      sm = op(sm, D.at(l++));
    } while ((l & -l) != l);
    return N;
  }
  template <bool (*f)(T)> int min_left(int r) {
    return min_left(r, [](T x) { return f(x); });
  }
  template <class F> int min_left(int r, F f) {
    if (r == 0) return 0;
    r += size;
    T sm = ie();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!f(op(D.at(r), sm))) {
        while (r < size) {
          r = (2 * r + 1);
          if (f(op(D.at(r), sm))) sm = op(D.at(r--), sm);
        }
        return r + 1 - size;
      }
      sm = op(D.at(r), sm);
    } while ((r & -r) != r);
    return 0;
  }
};

using mono = int;
mono op(mono a, mono b) { return max(a, b); };
mono ie() { return 0; };

void cmin(auto &a, auto b) { if (a > b) a = b; }
void cmax(auto &a, auto b) { if (a < b) a = b; }

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

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int MX = 3e5;
  SegmentTree<mono, op, ie> ST(MX + 1);
  for (int i = 0; i < N; i++) {
    int l = max(0, A.at(i) - K);
    int r = min(MX, A.at(i) + K);
    ST.set(A.at(i), ST.query(l, r) + 1);
  }
  cout << ST.query_all() << "\n";
}

Measured memory_bytes: 9800
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>
#include <map>
#include <queue>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  int n; cin>>n;
  int a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int w = a[n-1];
  int ng=-1, ok=w/2;
  while(ok - ng > 1) {
    int r = (ng+ok)/2;
    if (w-r > r+1) ng=r;
    else ok=r;
  }
  int an = -1, df = 1e9;
  for(int i=0;i<n;i++) {
    int s;
    if (w % 2 == 1) {
      // 1 5 10 10 5 1
      if (w/2 >= a[i]) s=w/2-a[i];
      else s=a[i]-(w/2+1);
    } else {
      if (w/2 >= a[i]) s=w/2-a[i];
      else s=a[i]-w/2;
    }
    if (df>s) an=a[i], df=s;
  }
  cout<<w<<" "<<an<<endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
s = input()[::-1]

mod = 10 ** 9 + 7
dp = [[0] * 13 for _ in range(len(s)+1)]

dp[0][0] = 1
keta = 1
for i in range(len(s)):
    for j in range(13):
        if s[i] == '?':
            for k in range(10):
                dp[i+1][(k*keta+j)%13] += dp[i][j] 
                dp[i+1][(k*keta+j)%13] %= mod 
        else:
            dp[i+1][((int(s[i]))*keta+j)%13] += dp[i][j] 
            dp[i+1][((int(s[i]))*keta+j)%13] %= mod
    keta = (keta * 10) % 13

print(dp[-1][5]%mod)

Measured memory_bytes: 96080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		for (int i=0;i<N;i++) {
			int temp =sc.nextInt();
			if (i%2==0&&temp%2==1) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Vec{
public:
  double x, y;
  Vec(double x = 0, double y = 0):x(x),y(y){}

  Vec &read(){
    cin >> x >> y;
    return *this;
  }

  void print(){
    printf("%.10lf %.10lf\n", x, y);
  }

  bool operator<(const Vec &other){
    if(x < other.x)return true;
    if(x == other.x && y < other.y)return true;
    return false;
  }
  
  Vec operator+(const Vec &other)
  {
    Vec result = *this;
    result.x += other.x;
    result.y += other.y;
    return result;
  }

  Vec operator-(const Vec &other)
  {
    Vec result = *this;
    result.x -= other.x;
    result.y -= other.y;
    return result;
  }

  Vec operator*(const double &k)
  {
    Vec result = *this;
    result.x *= k;
    result.y *= k;
    return result;
  }

  Vec operator/(const double &k)
  {
    Vec result = *this;
    result.x /= k;
    result.y /= k;
    return result;
  } 
  
  double cross(const Vec &other)
  {
    return x*other.y - y*other.x;
  }

  double dot(const Vec &other){
    return x*other.x + y*other.y;
  }
  
  bool operator==(const Vec &other) const
  {
    return abs(x - other.x) < EPS && abs(y - other.y) < EPS;
  }

  double norm()
  {
    return sqrt(x*x+y*y);
  }

  double norm2()
  {
    return x*x+y*y;
  }

  Vec standard(){
    Vec result = *this;
    return result/result.norm();
  }
};

//cw:1, ccw:-1, other:0
Int CCW(Vec a, Vec b, Vec c){
  b = b - a;
  c = c - a;
  if(b.cross(c) > EPS)return -1;
  if(b.cross(c) < -EPS)return 1;
  return 0;
}

double dist(Vec a, Vec b){
  return (a-b).norm();
}


int main(){
  Vec c1, c2;
  double r1, r2;
  c1.read();cin >> r1;
  c2.read();cin >> r2;
  Vec d = c1 - c2;

  if(d.norm2() > (r1+r2)*(r1+r2))cout << 4 << endl;
  else if(d.norm2() == (r1+r2)*(r1+r2))cout << 3 << endl;
  else if(d.norm2() == (r1 - r2)*(r1 - r2))cout << 1 << endl;
  else if(d.norm2() < (r1 - r2)*(r1 - r2))cout << 0 << endl;
  else cout << 2 << endl;  
  return 0;
}


Measured memory_bytes: 3236
#include<iostream>
using namespace std;
int main() {
	int a, b;
	
	cin >> a >> b;
	
	if (b < 0) {
		if ((b - a) % 2 == 0) {
			cout << "Negative";
		}
		else {
			cout << "Positive";
		}
	}
	else if (b == 0 || a == 0 || b > 0 && a < 0) {
		cout << "Zero";
	}
	else{
		cout << "Positive";
		
	}
	
	return 0;
}

Measured memory_bytes: 256
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
#define fat 998244353 
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
double dp[3005][3005];
int main()
{
    ll n;
    cin>>n;
    double p[n];

    for(ll i = 0 ; i < n ; i++)cin>>p[i];

    dp[0][0]=1;

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

            else
            {
                dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
            }
        }
    }
    double ans = 0;

    for(ll i = n/2+1 ; i <= n ; i++)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(9)<<ans<<endl;

}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin >> n;
    set<lli> s;
    REP(i, 0, n) {
        lli d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 256
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
let a = Int(split[0])!
let b = Int(split[1])!
let c = Int(split[2])!

var takoyaki = 0
var zikan = 0

while a > takoyaki {
    takoyaki += b
    zikan += c
}

print(zikan)


Measured memory_bytes: 14176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	static int n, m;
	static ArrayList<Integer>[] g;
	static boolean[] gVisited;
	static int[] memo;
	static boolean[] mVisited;

	static int dfs(int s) {

		if (g[s].size() == 0) {
			return 0;
		}

		if (gVisited[s]) {
			return memo[s];
		}

		gVisited[s] = true;

		int max = Integer.MIN_VALUE;

		for (int i = 0; i < g[s].size(); i++) {
			int n = g[s].get(i);
			max = Math.max(max, 1 + dfs(n));
		}

		return memo[s] = max;

	}

	public static void main(String[] args) throws IOException {

		n = input.nextInt();
		m = input.nextInt();

		gVisited = new boolean[n + 1];
		g = new ArrayList[n + 1];
		memo = new int[n + 1];
		mVisited = new boolean[n + 1];

		for (int i = 0; i <= n; i++) {
			g[i] = new ArrayList<>();
		}

		for (int i = 0; i < m; i++) {
			g[input.nextInt()].add(input.nextInt());
		}

		int max = Integer.MIN_VALUE;

		for (int i = 1; i < gVisited.length; i++) {
			if (!gVisited[i]) {
				max = Math.max(dfs(i), max);
			}
		}

		System.out.println(max);

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}

}

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


int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(a-x) > abs(b-x)){
    cout << 'B';
  }
  else{
    cout << 'A';
  }
  return 0;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n;
    cin >> n;

    ll ans = (n - 1) * n / 2;
    cout << ans << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long a, b, n;
    cin >> a >> b >> n;
    if (n < b) {
        cout << (a * n) / b << endl;
    } else {
        cout << (a * (b - 1)) / b << endl;
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <set>

int n,head[100010],nxt[200010],b[200010],k,ans;
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
std::set<int>set[100010];
void dfs(int x,int f){
	int mx=0;
	for(int i=head[x];i;i=nxt[i])
		if(b[i]!=f){
			dfs(b[i],x);
			if(set[b[i]].size()>mx)mx=b[i];
		}
	set[x]=set[mx];
	int v=0;
	for(int i=head[x];i;i=nxt[i])
		if(b[i]!=mx){
			for(auto it=set[b[i]].begin();it!=set[b[i]].end();++it)
				if(set[x].count(*it)){
					set[x].erase(*it);
					v=std::max(v,*it+1);
				}
				else if(v<=*it){
					set[x].insert(*it);
				}
		}
	while(set[x].count(v))++v;
	while(!set[x].empty()&&*set[x].begin()<v)set[x].erase(*set[x].begin());
	set[x].insert(v);
//	printf("%d %d\n",x,v);
	ans=std::max(ans,v);
}
int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),push(u,v),push(v,u);
	dfs(1,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 51072
open Printf
open Scanf

let print_frame n = String.make (n+2) '#' |> printf "%s\n"

let () =
  let h, w = scanf "%d %d\n" (fun x y -> (x, y)) in
  let rec loop n =
    if n = 0 then ()
    else
      begin
        let s = scanf "%s\n" (fun x -> x) in
        print_char '#';
        print_string s;
        print_char '#';
        print_newline ();
        loop (n-1)
      end in
  print_frame w;
  loop h;
  print_frame w


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


signed main(){
    int n;
    cin >> n;
   double p = sqrt(2*n);
    int k = p +1;
    if(k*(k-1)!= n*2){
        cout << " No ";
    }else{
        int a[k][k];
        int t =1;
        for(int i =0;i<k;i++){
            for(int j =i+1;j<k;j++){
                a[i][j]=t;
                a[j][i]=t;
                t++;
            }
        }
        cout << " Yes " << endl;
        cout << k << endl;
        for(int i =0;i<k;i++){
            cout << k-1 << " ";
            for(int j =0;j<k;j++){
                if(i!=j){
                    cout << a[i][j]<< " ";
                }
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vp vector<pair<ll,ll> >
#define se second
#define fi first
#define vi vector<ll>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<=b;i++)
#define inp(n,a) for(int i=0;i<n;i++){cin>>a[i];}
#define FASTER std::ios::sync_with_stdio(false)
#define DEBUG(x) cout<<#x<<" = "<<x<<endl
#define MOD 1000000007
#define strToInt(x,z) istringstream y(x);y>>z  //(string,integer)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b / __gcd(a,b);
#define INF 1e10
#define pi 3.14159265

using namespace std;

map<ll,ll> freq;
bool v[1000001];
int len, sp[1000001];

void Sieve(){
	for (int i = 2; i < 1000001; i += 2)	sp[i] = 2;//even numbers have smallest prime factor 2
	for (ll i = 3; i < 1000001; i += 2){
		if (!v[i]){
			sp[i] = i;
			for (ll j = i; (j*i) < 1000001; j += 2){
				if (!v[j*i])	v[j*i] = true, sp[j*i] = i;
			}
		}
	}
}


void factorize(int k) 
{
	//vector <int> ans;
	while(k>1) {
		//ans.push_back(sp[k]);
		freq[sp[k]]++;
		k/=sp[k];
	}

}


int main()
{
    FASTER;
    Sieve();
   	ll n;
   	cin>>n;
   	fab(i,2,n)
   	{
   		factorize(i);
   	}

   	ll ans =1;
   	for(map<ll,ll> :: iterator it = freq.begin(); it!=freq.end();it++)
   	{
   		ans= ans*((it->second)+1);
   		ans%=MOD;
   	}

   	cout<<ans<<endl;

   
    return 0;
}


Measured memory_bytes: 5120
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for m1 := 0; m1 <= n; m1++ {
		for m2 := 0; m2 <= n-m1; m2++ {
			m3 := n - m1 - m2
			if 10000*m1+5000*m2+1000*m3 == y {
				fmt.Println(m1, m2, m3)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	int N, K;
	std::cin >> N >> K;
	std::string str;
	std::cin >> str;
	str[K - 1] += 'a' - 'A';
	std::cout << str << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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



Measured memory_bytes: 3092
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = 0
for i in range(n):
    ai = a[i]
    bi = b[i]
    if ai < bi:
        c += (bi-ai)//2
    else:
        c -= (ai-bi)
print('Yes' if c >= 0 else 'No')

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

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

typedef
    boost::adjacency_list<
                boost::vecS,
                boost::vecS,
                boost::undirectedS,
                boost::no_property,
                boost::property<boost::edge_weight_t,int>
        >
Graph;
typedef std::pair<int,int> Edge;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int N,M,R;
vector<int> r;

vector<int> shortest_dist(Graph g,int from){
    vector<Vertex> v(boost::num_vertices(g));
    vector<int> d(boost::num_vertices(g));

    boost::dijkstra_shortest_paths(g,from,
            boost::predecessor_map(&v[0]).distance_map(&d[0]));

    return d;
}

vector<vector<int>> dist;

int distance(vector<int> v){
    int sum=0;
    for(int i=0;i<v.size()-1;i++){
        int d=dist[v[i]][v[i+1]];
        sum+=d;
    }
    return sum;
}

int search(){
    vector<int> v(R);
    for(int i=0;i<R;i++){
        v[i]=i;
    }
    int min=distance(v);
    while(std::next_permutation(v.begin(),v.end())){
        min=std::min(min,distance(v));
    }
    return min;
}

void make_table(Graph g){
    dist=vector<vector<int>>(R,vector<int>(R));
    for(int i=0;i<R;i++){
        vector<int> d=shortest_dist(g,r[i]);
        for(int j=0;j<R;j++){
            dist[i][j]=d[r[j]];
        }
    }
}

int main(){
    cin >> N >> M >> R;

    for(int i=0;i<R;i++){
        int _r;
        cin >> _r;
        _r--;
        r.push_back(_r);
    }

    vector<Edge> edge;
    vector<int> weight;

    for(int i=0;i<M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge.push_back(Edge(a,b));
        weight.push_back(c);
    }

    Graph graph(edge.begin(),edge.end(),weight.begin(),M);

    make_table(graph);
    
    cout << search() << endl;

    return 0;
}



Measured memory_bytes: 8032
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean clash[] = new boolean[n + 1];
		Arrays.fill(clash, true);

		for (int i = 0; i < m; i++) clash[sc.nextInt()] = false;

		int dp[] = new int[n + 1];
		dp[0] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j <= Math.min(i + 2, n); j++) {
				if (clash[j]) {
					dp[j] += dp[i];
					dp[j] %= 1000000007;
				}
			}
		}

		System.out.println(dp[n]);

		sc.close();

	}

}


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

int main(){
    ll n,x,a[10],count[10],k;
    rep(i,9){
        cin>>a[i];
        count[i]=0;
    }
    cin>>n;
    rep(i,n){
        cin>>x;
        rep(j,9){
            if(a[j]==x){
                count[j]=1;
                break;
            }
        }
    }
    k=max({count[0]+count[1]+count[2],count[3]+count[4]+count[5],count[6]+count[7]+count[8],count[0]+count[3]+count[6],count[1]+count[4]+count[7],count[2]+count[5]+count[8],count[0]+count[4]+count[8],count[2]+count[4]+count[6]});
    if(k==3){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int cipher(string s){
    string tmp;
    REP(i, 26){
        //tmp = s;
        REP(j, s.length()){
            s[j]++;
            if (s[j] > 'z') s[j] = 'a';
        }
        if (s == "the" || s == "this" || s == "that") return i+1;
    }
    return -1;
}

string convert(string s, int num){
    string con = s;
    REP(i, s.length()){
        if (s[i] >= 'a' && s[i] <= 'z'){
            if (s[i]+num > 'z') s[i] = 'a' + (s[i] + num - 'z' - 1);
            else s[i] += num;
        }
    }
    return s;
}

int main(){
    string s;
    int num;
    while (getline(cin, s)){
        string word = "";
        REP(i, s.length()){
            if (s[i] < 'a' || s[i] > 'z') {
                num = cipher(word);
                if (num >= 0) break;
                else word = "";
            } else {
                word += s[i];
            }
        }
        cout << convert(s, num) << endl;
    }
}


Measured memory_bytes: 2992
def days(y, m, d) :
    cnt = 0
    for i in range(1, y) :
        if i % 3 == 0 :
            cnt += 200
        else :
            cnt += 195
    for i in range(1, m) :
        if y % 3 == 0 :
            cnt += 20
        else :
            if i % 2 == 0 :
                cnt += 19
            else :
                cnt += 20
    cnt += d-1
    return cnt

n = int(input())
for i in range(n) :
    y, m, d = map(int, input().split())
    print(days(1000, 1, 1) - days(y, m, d))


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

int main() {
	ll N, K;
	cin >> N >> K;
	vector<P> vec;
	for (int i = 0; i < N; i++) {
		ll a, b;  cin >> a >> b;
		vec.push_back(P(a, b));
	}
	sort(vec.begin(), vec.end());

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll a = vec[i].first, b = vec[i].second;
		K -= b;
		if (K <= 0) {
			ans = a;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        double val = 0, cur = 0;
        int y;
        cin >> y;
        for (int i = 0; i < n; ++i) {
            double r; int b, t;
            cin >> b >> r >> t;
            auto x = t == 1 ? 1+y*r/100 : pow((1+r/100), y);
            if(val < x){
                val = x;
                cur = b;
            }
        }
        cout << cur << "\n";
    }
    return 0;
}



Measured memory_bytes: 3544
import std.stdio, std.algorithm, std.string;
void main()
{
    int[string] count;
    int maxCount;
    string maxWord;

    auto input = readln.split;

    foreach(str; input)
    {
        ++count[str];
        if(maxCount < count[str])
        {
            maxCount = count[str];
            maxWord = str;
        }
    }

    size_t maxLen = 0;
    string maxLenWord;
    foreach(str; input)
    {
        if(maxLen < str.length)
        {
            maxLen = str.length;
            maxLenWord = str;
        }
    }
    writeln(maxWord, " ", maxLenWord);
}

Measured memory_bytes: 1032
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	set := make(map[int]int, n)
	for i := 0; i < n; i++ {
		set[nextInt(sc)]++
	}
	m := nextInt(sc)
	var v int
	for i := 0; i < m; i++ {
		v = nextInt(sc)
		if _, ok := set[v]; ok {
			set[v]++
		}
	}
	ans := make([]int, 0, max(n, m))
	for k, v := range set {
		if v == 1 {
			ans = append(ans, k)
		}
	}
	sort.Ints(ans)
	wtr := bufio.NewWriter(os.Stdout)
	for _, v := range ans {
		fmt.Fprintln(wtr, v)
	}
	wtr.Flush()
}



Measured memory_bytes: 12680
n = int(input())
ps = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    p0 = ps[i]
    p1 = ps[i+1]
    p2 = ps[i+2]
    if p0 < p1 and p1 < p2:
        cnt += 1
    elif p2 < p1 and p1 < p0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = {0,1,0};

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{

	int a[3] = {}, b[3] = {};
	int c[3][3] = {};

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	a[0] = 0;
	for(int i = 0; i < 3; i++)
		b[i] = c[i][0];
	a[1] = c[1][1] - b[1];
	a[2] = c[2][2] - b[2];

	bool flag = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (c[i][j] != b[i] + a[j]) {
				flag = false;
			}
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 256
a = int(input())
alist = set()
count = 1
def f(a):
    if a%2==1:
        return 3*a+1
    else:
        return a//2

def check(a,alist):
    if a in alist:
        return False
    else:
        return True
while check(a,alist):
    count += 1
    alist.add(a)
    a = f(a)

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A[3], res;
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<3;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(3==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=1;KL2GvlyY<3;KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, A[KL2GvlyY]);
      }
    }
    {
      int cTE1_r3A, e98WHCEY;
      if(3==0){
        cTE1_r3A = 0;
      }
      else{
        cTE1_r3A = A[0];
        for(e98WHCEY=1;e98WHCEY<3;e98WHCEY++){
          cTE1_r3A += A[e98WHCEY];
        }
      }
      res =cTE1_r3A+ 9*Q5VJL1cS;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// {
//   int A[3], res;
//   rd(A(3));
//   res = sum(A(3)) + 9 max(A(3));
//   wt(res);
// }


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

int value[100];
int sp = 0;

void push(const int val)
{
    value[sp++] = val;
}

int pop()
{
    return value[--sp];
}

void operand(const char operand)
{
    int ch, val = operand - '0';
    while( (ch = getchar()) != ' ' ){
        val = val * 10 + (ch - '0'); 
    }
    push(val);
}

void operator(const char operator)
{
    int tmp1 = pop(), tmp2 = pop();

    switch( operator ){
    case '+': push(tmp2 + tmp1); break;
    case '-': push(tmp2 - tmp1); break;
    case '*': push(tmp2 * tmp1); break;
    default : break;
    }
}

int main()
{
    while( 1 ){
        int ch = getchar();
        if( ch == ' ' || ch == '\n' ) continue;
        if( ch == EOF ) break;

        switch( ch ){
        case '+': case '-': case '*': operator(ch); break;
        default : operand(ch); break;
        }
    }

    printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 524
import Control.Monad
import Text.Printf
import Control.Applicative

main :: IO()
main = do
  n <- getLine
  s <- getLine
  printf "%s" $ slv s

slv :: String -> String
slv s = show $ minimum $ zipWith (+) countListW (tail (reverse countListE)) 
  where countListW = scanl (+) 0 $ map (conv 'W') s
        countListE = scanl (+) 0 $ map (conv 'E') (reverse s)
        
conv :: Char -> Char -> Int
conv c d | c == d = 1
         | otherwise = 0 

Measured memory_bytes: 57724
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<string>
using namespace std;
typedef long long ll;
int n, k, a[200010], b[200010];
int main() {
	cin >> n >> k;
	int kazu = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (b[a[i]] == 0)kazu++;
		b[a[i]]++;
	}
	sort(b, b + n + 1);
	int sum = 0;
	int l = 0;
	while (b[l] == 0)l++;
	for (int i = l; i < l + kazu - k; i++) {
		sum += b[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
struct inputoutputfaster{
    inputoutputfaster(){
        ios::sync_with_stdio(false);\
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
}inputoutputfaster_;
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T divup(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    INT(n);
    VEC(int, v, n);
    sort(all(v));
    v.erase(unique(v.begin(), v.end()), v.end());
    print(SZ(v));
}

Measured memory_bytes: 3652
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (200010)
int n,k,c,f[N],g[N],st[N],e[N],p(1);
char s[N];
stack<int>ans;
signed main(){
	Rd(n),Rd(k),Rd(c),cin>>s+1,Mst(g,0x3f);
	Frn1(i,1,n){
		if(i>c+1)p=max(p,f[i-c-1]+1);
		if(s[i]=='o'){
			if(p>k)exit(0);
			f[i]=p;
		}
	}
	Frn_(i,n,1){
		if(i+c<n)p=min(p,g[i+c+1]-1);
		if(s[i]=='o')g[i]=p;
	}
	Frn1(i,1,n)if(f[i]==g[i])e[f[i]]=i;
	Frn_(i,n,1)if(f[i]==g[i])st[f[i]]=i;
	Frn1(i,1,k)if(st[i]==e[i])wr(st[i]),Pe;
	exit(0);
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N; cin >> N;
    string S; cin >> S;
    
    vector<int> num_R(N), num_G(N), num_B(N);
    int count_R, count_G, count_B;
    count_R = 0;
    count_B = 0;
    count_G = 0;
    for(int i = 0; i < N; i++){
        if (S[i] == 'R') count_R++;
        if (S[i] == 'G') count_G++;
        if (S[i] == 'B') count_B++;
        num_R[i] = count_R;
        num_G[i] = count_G;
        num_B[i] = count_B;
    }

    long long ans = 0;
    for(int i = 1; i < N-1; i++){
        if (S[i] == 'R'){
            ans += (num_G[i-1] * (num_B[N-1] - num_B[i]));
            ans += (num_B[i-1] * (num_G[N-1] - num_G[i]));
            for(int j = 1; j < N-1; j++){
                if (i-j < 0 || i+j > N-1) break;
                if (S[i-j]=='G' && S[i+j]=='B') ans--;
                if (S[i-j]=='B' && S[i+j]=='G') ans--;
            }
        }
        if (S[i] == 'G'){
            ans += (num_R[i-1] * (num_B[N-1] - num_B[i]));
            ans += (num_B[i-1] * (num_R[N-1] - num_R[i]));
            for(int j = 1; j < N-1; j++){
                if (i-j < 0 || i+j > N-1) break;
                if (S[i-j]=='R' && S[i+j]=='B') ans--;
                if (S[i-j]=='B' && S[i+j]=='R') ans--;
            }
        }
        if (S[i] == 'B'){
            ans += (num_G[i-1] * (num_R[N-1] - num_R[i]));
            ans += (num_R[i-1] * (num_G[N-1] - num_G[i]));
            for(int j = 1; j < N-1; j++){
                if (i-j < 0 || i+j > N-1) break;
                if (S[i-j]=='R' && S[i+j]=='G') ans--;
                if (S[i-j]=='G' && S[i+j]=='R') ans--;
            }
        }
    }
    cout << ans << endl;
}


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

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


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

    int n; cin >> n;
    ll a[n]; rep(i,n) cin >> a[i];
    ll ans = a[0];
    rep(i,n-1) ans = gcd(ans, a[i+1]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
temp=input()
n=int(temp.split(" ")[0])
h=int(temp.split(" ")[1])
a=[]
b=[]
for i in range(n):
    temp=input()
    ta=int(temp.split(" ")[0])
    tb=int(temp.split(" ")[1])
    a.append(ta)
    b.append(tb)
p=max(a) #ふるのは全部これ
c=[]
for temp in b:
    if temp>p:
        c.append(temp)
c.sort(reverse=True)
count=0
for temp in c:
    h-=temp
    count+=1
    if h<=0:
        print (count)
        break

if h>0:
    if h%p==0:
        count+=int(h/p)
        print(count)
    else :
        count+=(int(h/p)+1)
        print(count)

Measured memory_bytes: 12064
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	int result = 0;
	if (a >= b) {
		result += b;
	}
	else {
		result += a;
	}
	if (c >= d) {
		result += d;
	}
	else {
		result += c;
	}
	cout << result;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
   ll n;cin>>n;
   bool ok=0;
   ll cnt=0;
   f(i,0,n){
       ll a,b;cin>>a>>b;
       if(a==b)cnt++;
       else cnt=0;
       if(cnt==3){ok=1;break;}
   }
   if(ok)cout<<"Yes";
   else cout<<"No";
    return 0;  
} 



Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define MAX_H 2
#define MAX_W 100

int H,W;
int table[MAX_H][MAX_W],dp[MAX_H][MAX_W];

int main(){

	H = 2;

	scanf("%d",&W);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d",&table[row][col]);
		}
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			dp[row][col] = -1;
		}
	}

	dp[0][0] = table[0][0];
	dp[1][0] = table[0][0]+table[1][0];

	for(int col = 1; col < W; col++){

		dp[0][col] = dp[0][col-1]+table[0][col];
		dp[1][col] = max(dp[0][col],dp[1][col-1])+table[1][col];
	}

	printf("%d\n",dp[1][W-1]);

	return 0;
}


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

using namespace std;

int main(){
    int n;
    long long int sum=0;
    vector<long long int> a;
    cin >> n;
    for(int i=0;i<n;i++){
        long long int tmp;
        cin >> tmp;
        a.push_back(tmp);
        sum += tmp-1;
    }
    cout << sum << endl;
    return 0;
}

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

int32_t main(){
	string s; cin>>s;
	string y = s.substr(0, 3);
	int year = stoi(y);
	string m = s.substr(5, 6);
	int month = stoi(m);
	string d = s.substr(8 ,9);
	int day = stoi(d);
	if(month <= 4 && day <= 30 && year <= 2019){
		puts("Heisei");
	}
	else puts("TBD");
}


Measured memory_bytes: 256
def main():
    K = int(input())
    S = input()
    N = len(S)
    mod = 10**9 + 7
    r = 0
    t = pow(26, K, mod)
    s = 1
    inv26 = pow(26, mod - 2, mod)
    inv = [0] * (K + 2)
    inv[1] = 1
    for i in range(2, K + 2):
        inv[i] = -inv[mod % i] * (mod // i) % mod
    for i in range(K + 1):
        r = (r + t * s) % mod
        t = (t * 25 * inv26) % mod
        s = (s * (N + i) * inv[i + 1]) % mod
    return r

        
print(main())


Measured memory_bytes: 49400