akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    sort(a.begin(), a.end());
    int ans = a[0] + a[1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if((x+r)<=W && (x-r)>=0 && (y+r)<=H && (y-r)>=0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


ll NcR(ll n,ll r)
{
    long long p = 1, k = 1; 
    if (n - r < r)
        r = n - r;
    if (r != 0) { 
        while (r) {
            p *= n;
            long long m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
            k *= r; 
        }
    }
    else
        p = 1;
    return p;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int maximum=INT_MAX;
    for(int i=0;i<=s.length()-t.length();i++)
    {
        int count=0;
        for(int j=0;j<t.length();j++)
        {
            if(s[i+j]==t[j])
                count++;
        }
        if(maximum>(t.length()-count))
            maximum=t.length()-count;
    }
    cout<<maximum;
    return 0;
}

Measured memory_bytes: 10676
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=509,mod=998244353;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int f[N][N],g[N][N],h[N],n,pw[N];
	inline int get(int l,int r,int bas){
		if(l>r) return 0;
		
		int mid=l,ls,rs;
		for(int i=l+1;i<=r;i++) if(h[i]<h[mid]) mid=i;
		ls=get(l,mid-1,h[mid]),rs=get(mid+1,r,h[mid]);
		int lenl=mid-l,lenr=r-mid;

		for(int i=0;i<=lenl;i++)
			for(int j=0;j<=lenr;j++){
				int a=1LL*f[ls][i]*f[rs][j]%mod;
				int b=(1LL*add(f[ls][i],g[ls][i])*g[rs][j]+1LL*g[ls][i]*f[rs][j])%mod;
				f[mid][i+j]=add(f[mid][i+j],a);
				f[mid][i+j+1]=sub(f[mid][i+j+1],a);
				g[mid][i+j]=add(g[mid][i+j],b);
				g[mid][i+j+1]=add(g[mid][i+j+1],a);
			}
		
		for(int i=0;i<=r-l+1;i++){
			f[mid][i]=1LL*f[mid][i]*qpow(pw[r-l+1-i],h[mid]-bas)%mod;
			g[mid][i]=1LL*g[mid][i]*qpow(sub(pw[r-l+1-i],1),h[mid]-bas)%mod;
		}
		return mid;
	}

	int main(){
		f[0][0]=1,n=read<int>();
		for(int i=1;i<=n;i++) h[i]=read<int>();

		pw[0]=1;
		for(int i=1;i<=n;i++) pw[i]=add(pw[i-1],pw[i-1]);
		int rt=get(1,n,0),ans=0;
		for(int i=0;i<=n;i++) ans=add(ans,add(f[rt][i],g[rt][i]));
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 5320
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  string ans = "AC";
  
  if (S.at(0) != 'A') ans = "WA";
  if (isupper(S.at(1))) ans = "WA";
  
  int C = 0;
  
  for (int i = 2; i < N - 1; i++)
  {
    if (isupper(S.at(i)))
    {
      if (C >= 1) {ans = "WA"; break;}
      if (S.at(i) != 'C') {ans = "WA"; break;}
      C++;
    }
  }
  if (isupper(S.at(N - 1))) ans = "WA";
  if (C == 0) ans = "WA";
  
  cout << ans << endl;
}

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

using namespace std;

const int maxN = 101;
const int maxS = 1e5 + 10;
int v[maxN], w[maxN];
int dp[maxS];

int n, W;

int main()
{
	cin >> n >> W;
	int S = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i] >> v[i];
		S += v[i];
	}

	for (int i = 1; i <= S; ++i)
	{
		dp[i] = 1e9 + 10;
	}
	dp[0] = 0;

	for (int i = 0; i < n; ++i)
	{
		for (int j = S; j >= 0; --j)
		{
			int opt1 = dp[j];
			int opt2 = (j - v[i] >= 0) ? dp[j - v[i]] + w[i] : static_cast<int>(1e9 + 10);
			dp[j] = min(opt1, opt2);
		}
	}


	for (int j = S; j >= 0; --j)
	{
		if (dp[j] <= W)
		{
			cout << j << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 640
def main():
    H,W,K = map(int,input().split())
    board = [] #board[行][列]
    for h in range(H):
        board.append(list(input()))

    total = 0

    for bit_h in range(2 ** H):
        for bit_w in range(2 ** W):
            check_board = [[True for _ in range(W)] for _ in range(H)]
            for h_cheker in range(H):
                if (bit_h >> h_cheker) & 1:
                    for temp_w in range(W):
                        check_board[h_cheker][temp_w] = False
            for w_checker in range(W):
                if (bit_w >> w_checker) & 1:
                    for temp_h in range(H):
                        check_board[temp_h][w_checker] = False
            counter = 0
            for h in range(H):
                for w in range(W):
                    if check_board[h][w] and board[h][w] == "#":
                        counter += 1

            if counter == K:
                total += 1

    print(total)




if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
import io.{StdIn => in}

object Main extends App {
  val n = in.readLine
  val ans = n match {
    case s if n.init.forall(_ == n.head) => "Yes"
    case s if n.tail.forall(_ == n.last) => "Yes"
    case _ => "No"
  }
  println(ans)
}

Measured memory_bytes: 25408
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String,Integer> vote = new HashMap<>();
        int n = sc.nextInt();

        for(int i=0;i<n;i++){
            String name = sc.next();
            if(vote.containsKey(name)){
                int temp = vote.get(name);
                vote.remove(name);
                vote.put(name,temp+1);
            }
            else{
                vote.put(name,1);
            }
        }
        int max = 0;
        for(String s:vote.keySet()){
            max = Math.max(max,vote.get(s));
        }
        ArrayList<String> names = new ArrayList<>();

        for(String s:vote.keySet()){
            if(vote.get(s)==max) names.add(s);
        }
        Collections.sort(names);

        for(String s:names) System.out.println(s);
    }

}




Measured memory_bytes: 81704
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int A, B, C, K;
  std::cin >> A >> B >> C >> K;
  if (A >= K) {
    std::cout << K << '\n';
  }
  else if (A + B >= K) {
    std::cout << A << '\n';
  }
  else {
    std::cout << A - (K - A - B) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,c,d;
  cin>>N;
  a=N/1000;
  b=(N-a*1000)/100;
  c=(N-a*1000-b*100)/10;
  d=N-a*1000-b*100-c*10;
  if(b==c&&(a==b||c==d))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <string.h>

#define N_MIN       (0)
#define N_MAX       (44)

typedef enum
{
    ERROR  =-1,
    SUCCESS= 0
} ResultType;

static ResultType checkRangeOfNum(int, int, int);
static int fib(int);

int main(void)
{
    int A[45], N;
    ResultType eResult;

    /* input */
    scanf("%d",&N);
    eResult = checkRangeOfNum(N, N_MIN, N_MAX);
    if(eResult < SUCCESS)
    {
        printf("Err: %d is out of range.", N);
        return eResult;
    }

    /* calcurate fib(n)  */
    printf("%d\n", fib(N));

    return SUCCESS;
}

static ResultType checkRangeOfNum(int n, int nMin, int nMax)
{
    if((n < nMin) || (nMax < n))
    {
        return ERROR;
    }
    return SUCCESS;
}

static int fib(int n)
{
    int fib1 = 1;
    int fib2 = 1;
    int tmp, i;

    if(n < 2)
    {
        return 1;
    }
    else
    {
        for(i=2; i<=n; i++)
        {
            tmp  = fib1 + fib2;
            fib1 = fib2;
            fib2 = tmp;
        }
        return tmp;
    }
}



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

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N),c(N);
  for(int i =0;i<N;i++)cin >>a.at(i);
  for(int i =0;i<N;i++)cin >> b.at(i);
  for(int i =0;i<N-1;i++)cin >> c.at(i);
  int rel;
  for(int i =0;i<N;i++)rel+=b.at(i);
  for(int i =0;i<N-1;i++){
    if(a.at(i)+1 == a.at(i+1)){
      rel+=c.at(a.at(i)-1);
    }
  }
  cout << rel << endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
	
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		
		int left_max = 0;
		int right_min = Integer.MAX_VALUE;
		
		for(int i=0; i<M;i++){
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			left_max = Math.max(left_max, L);
			right_min = Math.min(right_min,R);
		}
		int ans = right_min - left_max + 1;
		if(ans<0)ans = 0;
		
		System.out.println(ans);
			
		
		
		
		
	}
	
	
	
}

Measured memory_bytes: 49096
local N = io.read("n")
local a = 0
for i=1,N do
    if i < 10 then
        a = a + 1
    elseif i >= 100 then
        if i < 1000 then
            a = a + 1
        elseif i >= 10000 then
            if i < 100000 then
                a = a + 1
            end
        end
    end
end
print(a)

Measured memory_bytes: 760
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
x = [0] * 26
for _ in range(d):
    for i in range(26):
        x[i] += c[i]
    y = x.index(max(x))
    print(y + 1)
    x[y] = 0

Measured memory_bytes: 74780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll n;
    cin >> n;
    set<ll> ans;
    for(ll k = 2; k * k <= n; k++){
        if(n % k == 0){
            ll m = n;
            while(m % k == 0)m /= k;
            if(m % k == 1)ans.insert(k);
            ll l = n;
            if(m == 1)continue;
            while(l % m == 0)l /= m;
            if(l % m == 1)ans.insert(m);
        }
    }
    ll m = n - 1;
    for(ll k = 2; k * k <= n; k++){
        if(m % k == 0){
            if(n % k != 0)ans.insert(k);
            if(n % (m / k) != 0)ans.insert(m/k);
        }
    }
    if(n>2)ans.insert(n-1);
    ans.insert(n);
    cout << ans.size() << endl;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10000)

K = int(input())

NL = {}

def nextLunlun(n):
    if n in NL:
        return NL[n]
    if n < 9:
        ans = n + 1
    else:
        k = n + 1
        sk = str(k)
        a = int(sk[-2])
        b = int(sk[-1])
        if b == 0 or b - a > 1:
            l = nextLunlun(n // 10)
            l1 = l % 10
            if l1 == 0:
                ans = l * 10
            else:
                ans = l * 10 + l1 - 1
        else:
            ans = k
    NL[n] = ans
    return ans

def lunlun(n):
    if n < 10:
        ans = n
    else:
        ans = 10
        for i in range(n-10):
            ans = nextLunlun(ans)
    return ans

print(lunlun(K))


Measured memory_bytes: 15176
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);

int main() {
	int n;
	string s;
	cin >> n >> s;
	int  ans = 0;
	rep(i,10) {
		rep(j,10) {
			rep(k,10) {
				int count = 0;
				rep(l, s.size()) {
					if (s[l] - '0' == i&&count==0) count++;
					else if (s[l] - '0' == j && count == 1)count++;
					else if (s[l] - '0' == k && count == 2) {
						count++;break;
					}
				}if (count == 3)ans++;

			}
		}
	}

	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
using multiInt = boost::multiprecision::cpp_int;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  int x, t;
  cin >> x >> t;
  cout << max(0, x - t) << endl;
  return 0;
}


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

int main() {
  ll n; cin >> n;
  if(n % 2 == 0)
    cout << 0.5000000 << endl;
  else{
    double c = (double) n;
    cout << (int)(c/2+1) / c << endl;
  }
}

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

using namespace std;

bool compare(const string& a, const string& b)
{
  return (a[1] < b[1]);
}

int main()
{
  const string
    stable = "Stable",
    not_stable = "Not stable";
  const int N_max = 100;
  int N;
  string a[N_max], b[N_max];
  cin >> N;
  for(int i = 0; i<N ; ++i){
    cin >> a[i];
    b[i] = a[i];
  }

  //bubble sort
  for(int i = 0; i<N; ++i){
    for(int j = N-2; j >= 0; --j){
      if(compare(a[j+1], a[j])){
	swap(a[j], a[j+1]);
      }
    }
  }
  
  for(int i = 0; i<N ; ++i){ cout << ( i==0 ? "" : " ") << a[i]; }
  cout << endl;
  cout << stable << endl;
  
  //insertion sort
  bool execution_was_stable = true;
  for(int i = 0; i<N; ++i){
    string* min_ptr = min_element(b+i, b+N, compare);
    if(min_ptr != b+i){
      for(int j = i+1; b+j<min_ptr; ++j){
	if (!compare(b[j],b[i]) && !compare(b[i],b[j])){
	  execution_was_stable = false;
	}
      }
      swap(b[i], *min_ptr);
    }
  }
  
  for(int i = 0; i<N ; ++i){ cout << ( i==0 ? "" : " ") << b[i]; }
  cout << endl;
  cout << (execution_was_stable ? stable : not_stable)
       << endl;

  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans;
  if(k <= a)
  ans = k;
  if(k > a && k <= a + b)
  ans = a;
  if(k > a + b && k <= a + b + c)
  ans = a - (k - a - b);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3188
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 200005;
const ll mod = 2000000011;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
vector<int>c;
vector<vector<int> >a;
int n,m,x;
//1. Ends here

//2. Extra Functions here

//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n,m;
    cin>>n>>m;
    int h[n+1];

    for(int i=1;i<=n;i++){
        cin>>h[i];
    }

    vector<int>maxh(n+1,0);

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;

        maxh[x]=max(maxh[x],h[y]);
        maxh[y]=max(maxh[y],h[x]);   
    }

    int cnt=0;

    for(int i=1;i<=n;i++){
        if(h[i]>maxh[i])cnt++;
    }

    cout<<cnt<<"\n";
    return;

}
// how r u bro

Measured memory_bytes: 4744
#include<bits/stdc++.h>
//***** Jai Gurudev *****//
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define all(x) x.begin(),x.end()
#define vii vector<pair<int,int> >
#define vll vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI 3.1415926535897932384626433832795
#define inf 1e18+5
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n) {bool flag=true;for(ll i=2; i<=sqrt(n);i++){if(n%i==0){flag=false;break;}}return flag;}
using namespace std;
int main()
{
	ll n;
	cin>>n;
	vl a(n);
	for(ll i=0;i<n;i++)
	cin>>a[i];
	map<ll,ll> mp;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		if(mp.count(a[i])==0)
		mp[a[i]]=1;
		else
		mp[a[i]]+=1;
		sum+=a[i];
	}
//	for(auto i=mp.begin();i!=mp.end();i++)
//	cout<<i->fi<<" "<<i->se<<"\n";
	int q;
	cin>>q;
	while(q--)
	{
		int q,w;
		cin>>q>>w;
		if(mp.count(q)==1)
		{
			if(mp.count(w)==0)
			mp[w]=mp[q];
			else
			mp[w]+=mp[q];
			sum-=mp[q]*q;
			sum+=mp[q]*w;
			mp.erase(q);
		}
		cout<<sum<<"\n";
//		for(auto i=mp.begin();i!=mp.end();i++)
//	cout<<i->fi<<" "<<i->se<<"\n";
	}
	return 0;
}


Measured memory_bytes: 8064
N = int(input())
A = [-1] + [int(x) for x in input().split()]
B = [0] + [int(x) for x in input().split()]
C = [0] + [int(x) for x in input().split()]

ans = 0

for i in range(1, N + 1):
    ans += B[A[i]]
    if A[i] == A[i - 1] + 1:
        ans += C[A[i - 1]]

print(ans)


Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		Main main = new Main();

		int n = scan.nextInt();
		int count = 0;
		for(int i = 0 ; i < n ; i++) {
			int num = scan.nextInt();
			if(num !=1 && main.test(num)) {
				count++;
			}
		}
		System.out.println(count);

	}

	boolean test(int n){
		for (int i = 2 ; i*i <= n ; i++) {
			if(n % i == 0) {
				return false;
			}
		}
		return true;
	}

}



Measured memory_bytes: 40676
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return((list(sys.stdin.readline()))[:-1])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    s = S()
    for i in range(len(s)):
        if i%2==0 and s[i] == "L":
            return "No"
        if i%2==1 and s[i] == "R":
            return "No"
    return "Yes"

if __name__ == "__main__":
    print(main())


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

int main(){
    ll  n ;
    cin >> n ;
    ll ans = 2000 ;
    for(ll i = 1 ; i <= 100 ; i++ ){
      if(i*1000 >= n ){
        ll tem = abs( i*1000 - n ) ;
        ans = min(ans,tem) ;
      } 
    }
    cout << ans << endl ;
}

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


int main(){

  int a1,a2,a3,a4,b1,b2,b3,b4;
  cin >> a1 >> a2 >> a3 >> a4;
  cin >> b1 >> b2 >> b3 >> b4;

  int sa = a1 + a2 + a3 + a4;
  int sb = b1 + b2 + b3 + b4;

  if(sa > sb) cout << sa << endl;
  else cout << sb << endl;

}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    string s;
    cin >> s >> n;
    REP(i,n){
        string t;
        cin >> t;
        if(t == "replace"){
            int x,y;
            string r;
            cin >> x >> y >> r;
            FOR(j,x,y+1){
                s[j] = r[j-x];
            }
        }
        else if(t == "reverse"){
            int x,y;
            cin >> x >> y;
            reverse(s.begin()+x,s.begin()+y+1);
        }
        else{
            int x,y;
            cin >> x >> y;
            FOR(j,x,y+1){
                cout << s[j];
            }
            cout << "\n";
        }
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}





Measured memory_bytes: 3164
# EDPC A Frog 1

N = int(input())
H = list(map(int,input().split()))

cost = [0]*N
cost[1] = abs(H[1]-H[0])

for i in range(2,N):
    cost[i] = min(cost[i-1]+abs(H[i]-H[i-1]),cost[i-2]+abs(H[i]-H[i-2]))

print(cost[N-1])

Measured memory_bytes: 20652
#include<stdio.h>
int main()
{
 int N,i,j,sum,tmp;
  int a[100]={0};
  scanf("%d",&N);
  sum=N;
  for(i=0;i<N;i++)
  {
    scanf("%d",&a[i]);
  }
  for(i=0;i<N-1;i++)
  {
    for(j=0;j<N-1;j++)
    {
     if(a[j]<=a[j+1])
     {
       tmp=a[j];
       a[j]=a[j+1];
       a[j+1]=tmp;
     } 
    }
  }
  for(i=0;i<N-1;i++)
  {
  if(a[i]==a[i+1])
  {
    sum=sum-1;
  }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,k,j;
	vector<int> a;
	cin>>n>>k;
	for (int i = 0; i < n; ++i)
	{
		cin>>j;
		a.push_back(j);

	}
	int cnt=0;
	for (int i = 0; i< n; ++i)
	{
		if(a[i]>=k){
		 cnt++;	
		}
	}
	cout<<cnt;

   return 0;
}


Measured memory_bytes: 3872
#include <iostream>
#include <algorithm>

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main() {
  while (1) {
    int m, nmin, nmax, p[202], ans, maxgap;
    maxgap = -1;
    cin >> m >> nmin >> nmax;
		if (m==0 && nmin==0 && nmax==0) break;
    REP(i, m) cin >> p[i];
    sort(p, p + m);
    for (int i = m - nmax; i <= m - nmin; i++) {
      if (p[i] - p[i - 1] > maxgap) {
        ans = m - i;
        maxgap = p[i] - p[i - 1];
      }
    }
    cout << ans << endl;
  }
	return 0;
}



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

int abs(int x){return x>0?x:(-x);}
int min(int a,int b){return a>b?b:a;}

int H,W;
int A[51][51];

int main()
{
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			scanf("%d",&A[i][j]);
		}
	}
	int res=(1<<30);
	for(int x=0;x<H;x++)
	{
		for(int y=0;y<W;y++)
		{
			int sum=0;
			for(int i=0;i<H;i++)
			{
				for(int j=0;j<W;j++)
				{
					sum+=min(abs(i-x),abs(j-y))*A[i][j];
				}
			}
			if(res>sum)res=sum;
		}
	}
	printf("%d\n",res);
}


Measured memory_bytes: 2744
n,m=map(int,input().split())
arr = list(map(int, input().split()))
A=[]
suM=0
for i in arr:
  A.append(i)
for i in A:
  suM+=i
if suM>n:
  print(-1)
elif (suM==n) or (suM<n):
  print(n-suM)


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

int main(){
    ll n; cin >> n;
    map<ll,ll> mp;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                mp[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout << mp[i] << endl;
    }
}

Measured memory_bytes: 6028
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

vector<vector<i64>> f;
i64 H, W;
i64 d[] = {1, 0, -1, 0};

i64 bfs(i64 s, i64 t) {
  using P = pair<i64, i64>;
  queue<P> que;
  que.push({ s, t });
  vector<vector<i64>> dist(H, vector<i64>(W, 1e18));
  dist[s][t] = 0;
  i64 MAX = 0;
  while(!que.empty()) {
    i64 x = que.front().first;
    i64 y = que.front().second;
    que.pop();
    rep(k,0,4) {
      i64 i = x + d[k];
      i64 j = y + d[k ^ 1];
      if(!(0 <= i && i < H && 0 <= j && j < W)) continue;
      if(f[i][j]) continue;
      if(dist[i][j] > dist[x][y] + 1) {
        dist[i][j] = dist[x][y] + 1;
        que.push({ i, j });
        MAX = std::max(dist[i][j], MAX);
      }
    }
  }
  return MAX;
}

int main() {
  cin >> H >> W;
  f.resize(H, vector<i64>(W));
  rep(i,0,H) {
    string s;
    cin >> s;
    rep(j,0,W) {
      if(s[j] == '#') f[i][j] = 1;
    }
  }
  i64 res = 0;
  rep(i,0,H) {
    rep(j,0,W) {
      if(f[i][j]) continue;
      i64 ans = bfs(i, j);
      res = std::max(res, ans);
    }
  }
  cout << res << endl;
}


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

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i,n){
        char p = a[i];
        char q = b[i];
        char r = c[i];
        if(p == q && q == r) continue;
        else if(p == q || q == r || r == p){
            ans++;
        }
        else ans += 2;
    }
    cout << ans << endl;
}


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

const int INF = 1 << 29;
const int MAX = 10;
int as[MAX][MAX];
int n, m;

void floyd() {
    for (int k = 0; k < m; k++) {
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                as[i][j] = min(as[i][j], as[i][k] + as[k][j]);
            }
        }
    }
}

int main() {
    while (cin >> n, n) {
        for (int i = 0; i < MAX; i++) {
            for (int j = 0; j < MAX; j++) {
                as[i][j] = (i == j) ? 0 : INF;
            }
        }
        m = 0;
        for (int i = 0; i < n; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            as[a][b] = as[b][a] = c;
            m = max(m, a);
            m = max(m, b);
        }
        m++;
        floyd();
        int ans = INF, ans_i;
        for (int i = 0; i < m; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += as[i][j];
            }
            if (ans > sum) {
                ans = sum;
                ans_i = i;
            }
        }
        cout << ans_i << " " << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> s(n+1,0);
    for(ll i=1;i<=n;i++){
        s[i]=(modpow(i,mod-2)+s[i-1])%mod;
    }
    ll ret=0;
    for(int i=0;i<n;i++){
        ret+=a[i]*(s[i+1]+s[n-i]-1)%mod;
        ret%=mod;
    }
    for(ll i=1;i<=n;i++){
        ret*=i;
        ret%=mod;
    }
    ret+=mod;
    ret%=mod;
    cout << ret<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
#define PI 3.14159265359
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int h, a; cin >> h >> a;
	if (h%a == 0) {
		cout << h / a << endl;
	}
	else {
		cout << h / a + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = fst $ foldl' f (0, 0) s
  where f (a, b) c
          | c == 'I' = (max a (b+1), b+1)
          | c == 'D' = (max a (b-1), b-1)


------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


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

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

  int A; cin >> A;
  int B; cin >> B;
  if (A > B) swap(A, B);

  int ans;
  if (A == 1 && B == 2) ans = 3;
  if (A == 1 && B == 3) ans = 2;
  if (A == 2 && B == 3) ans = 1;
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}


int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  n--;
  int cnt = 0;
  while(n > 0) {
    n /= 3;
    cnt++;
  }

  cout << cnt << endl;

}



Measured memory_bytes: 3096
// failed to generate code

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

int a[22][22];


long long dp[22][1<<22];
int MOD = 1000000007;
int main(){
    int N;
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            cin >> a[i][j];
        }
    }
    long long ans = 0;
    dp[0][0] = 1;
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < (1<<N) ; j++){
            if( dp[i][j] == 0 ) continue;
            dp[i][j] %= MOD;
            for(int k = 0 ; k < N ; k++){
                if( (j >> k & 1) == 0 && a[i][k]){
                    dp[i+1][j | (1<<k)] += dp[i][j];
                }
            }
        }
    }
    cout << dp[N][(1<<N) - 1] % MOD << endl;

}


Measured memory_bytes: 321792
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



def main():
	N,K=map(int,input().split())
	
	for i in range(1,K+1):
		if i<=N-K+1:
			print(comb(N-K+1,i,MOD)*comb(K-1,i-1,MOD)%MOD)
		else:
			print(0)
	





if __name__ == '__main__':
	main()


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

B = [0]*N
for i in range(N):
    X = N-i
    P = B[X-1]
    Q = A[X-1]
    if P==Q:
        B[X-1] = 0
    else:
        XDL = make_divisors(X)
        for XD in XDL:
            if XD==X:
                B[XD-1] = 1
            else:
                B[XD-1] = 1 - B[XD-1]
out = []
cnt = 0
for i in range(N):
    if B[i]==1:
        out.append(i+1)
        cnt+=1
print(cnt)
if len(out)>0:
    print(*out)

Measured memory_bytes: 99776
#include<bits/stdc++.h>
using namespace std;
 
#define       pb(a)             push_back((a))
#define       mp(a,b)           make_pair((a),(b))
#define       REP(a,b)          for(ll i=(a);i<(b);i++)
#define       REP2(a,b)         for(ll j=(a);j<(b);j++)
#define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
#define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
#define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
#define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
#define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
#define       all(v)            (v).begin(),(v).end()
#define       Trvs(c)           for (auto it = (c).begin(); it != (c).end(); it++)
#define       INF               INT_MAX
#define       sz(x)             x.size()
#define       flash             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define       F                 first
#define       S                 second
#define       MOD               1000000007
 
using         ll     = long long;
using         vi     = vector<int>;
using         vvi    = vector<vi>;
using         vll    = vector<ll>;
using         vvll   = vector<vll>;
using         vb     = vector<bool>;
using         vd     = vector<double>;
using         vs     = vector<string>;
using         pii    = pair<int, int>;
using         pll    = pair<ll, ll>;
using         pdd    = pair<double, double>;
using         vpii   = vector<pii>;
using         vvpii  = vector<vpii>;
using         vpll   = vector<pll>;
using         vvpll  = vector<vpll>;
using         vpdd   = vector<pdd>;
using         vvpdd  = vector<vpdd>;
 
 
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 solve(){
    const ll Size = 1000000;
	vector<bool> prime (Size,1);
    prime[0]=prime[1]=0;
    
    REP(2,Size){
        if(i*i <= Size)
        if(prime[i]){
            for(ll j=i*i;j<Size;j+=i){
                prime[j]=0;
            }
        }
    }
    ll x;
    cin>>x;
    REP(x,Size){
        if(prime[i]==1){
            cout<<i<<endl;
            return;
        }
    }
}
 
 
int main(){
 
	flash
	/*
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("output.txt","w",stderr);
	#endif
 	*/
   
	//ll t;cin>>t;while(t--)
	solve();
 
 
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B;
    cin >> A >> B;

    char S[A+B+1];
    for (int i = 0; i < A+B+1; i++){
        cin >> S[i];
    }

    int count = 0;
    for (int i = 0; i < A + B + 1; i++){
        if ( i < A && !('0' <= S[i] && S[i] <= '9') ){
            count++;
        }
        else if (S[A] != '-'){
            count++;
        }
        else if ( A+1 <= i && i < A+B+1 && !('0' <= S[i] && S[i] <= '9')){
            count++;
        }
    }

    if (count > 0){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

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

//白色の連結成分がAつ、黒色の連結成分が1つになるような49*49グリッドを作る
void grid(int A,vector<vector<char>> &color){

  for(int i=0;i<49;++i){
    for(int j=0;j<49;++j){
      if(i==0 || i==48 || j==0 || j==48) color[i][j]='#';
      else color[i][j]='.';
    }
  }

    int count=0;
    while(count<24 && count<A){
      for(int i=0;i<49;++i) color[i][2*count]='#';
      ++count;
    }

    if(A-24>=0){
      int p=(A-24)/24;
      int r=(A-24)%24;
      for(int i=0;i<p;++i){
        for(int j=0;j<49;++j){
        color[2*i+2][j]='#';
        }
      }

      for(int j=0;j<r;++j){
      color[2*p+2][2*j+1]='#';
      }
    }
}

int main(){
  //in
  int A,B;
  cin>>A>>B;
  vector<vector<char>> white(49,vector<char>(49)),black(49,vector<char>(49));

  //paint
  grid(A,white);
  grid(B,black);
  for(int i=0;i<49;++i){
    for(int j=0;j<49;++j){
      if(black[i][j]=='#') black[i][j]='.';
      else if(black[i][j]=='.') black[i][j]='#';
    }
  }

  //out
  if(A==1){
    cout<<49<<" "<<49<<endl;
    for(int i=0;i<49;++i){
      for(int j=0;j<49;++j){
        if(j==48) cout<<black[i][j]<<endl;
        else cout<<black[i][j];
      }
    }
  }
  else if(B==1){
    cout<<49<<" "<<49<<endl;
    for(int i=0;i<49;++i){
      for(int j=0;j<49;++j){
        if(j==48) cout<<white[i][j]<<endl;
        else cout<<white[i][j];
      }
    }
  }
  else{
    cout<<98<<" "<<49<<endl;
    grid(A-1,white);
    grid(B-1,black);

    for(int i=0;i<49;++i){
      for(int j=0;j<49;++j){
        if(black[i][j]=='#') black[i][j]='.';
        else if(black[i][j]=='.') black[i][j]='#';
      }
    }
    for(int i=0;i<49;++i){
      for(int j=0;j<49;++j){
        if(j==48) cout<<white[i][j]<<endl;
        else cout<<white[i][j];
      }
    }
    for(int i=0;i<49;++i){
      for(int j=0;j<49;++j){
        if(j==48) cout<<black[i][j]<<endl;
        else cout<<black[i][j];
      }
    }
  }

}

Measured memory_bytes: 256
import java.util.Scanner;

  class Main {
    public static void main(String[]args){
        Scanner scan= new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        
        boolean H[] = new boolean[h];
        boolean W[] =new boolean[w];
        char arr[][] = new char[h][w] ;
         
        for(int  i = 0 ; i < h ; i++){
            
            String T = scan.next();
            
            for(int j = 0 ; j <w ;j++){
                arr[i][j] = T.charAt(j);
                
                if(arr[i][j] == '#'){
                    H[i] = true ;
                    W[j] = true ;
                }
            }          
        }
        
        for(int i = 0 ; i<h ; i++){
            boolean k = false; 
            for(int j = 0 ; j <w ; j++){
                if(H[i] && W[j]){
                     k = true ;
                    System.out.print(arr[i][j]);
                }
            }
            if(k){
                System.out.println("");
            }
        }
    }
}


Measured memory_bytes: 28864
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n,b,f,r,v;
        n=sc.nextInt();
        int A[][][] =new int[4][3][10];
        for(int i=0;i<n;i++){
            b=sc.nextInt();
            f=sc.nextInt();
            r=sc.nextInt();
            v=sc.nextInt();
            A[b-1][f-1][r-1]+=v;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    System.out.print(" "+A[i][j][k]);
                }
                System.out.println();
            }
            if(i!=3)
                System.out.println("####################");
        }
    }
}                   


Measured memory_bytes: 29144