akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N = int(input())
A = np.fromiter(map(int, input().split()), np.int64)

m = 1000000007

result = 0
for bit in range(60):
    c = int((A & 1).sum())
    A >>= 1
    result = (result + c * (N - c) * (1 << bit)) % m
print(result)


Measured memory_bytes: 59156
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    n *= 2;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for(int i = 1; i < n; i+=2)
    {
        ans += a[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 3580
#include <stdio.h>
int a[55];
int check(int n){
    int ret = 1;
    for(int i = 1;i<n;i++) if(a[i-1]>a[i]) ret =0;
    return ret;
}
void swap(int i,int j){
    int c = a[i];
    a[i] = a[j];
    a[j] = c;
}
void MRoy(){
    int n;
    scanf("%d",&n);
    for(int i = 0;i<n;i++) scanf("%d",a+i);
    int t = check(n);
    for(int i = 0;i<n;i++){
        for(int j = i+1;j<n;j++){
            swap(i,j);
            t |= check(n);
            swap(i,j);
        }
    }
    if(t) printf("YES\n");
    else printf("NO\n");
    return;
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main(){
  ll n,m;cin>>n>>m;
  vl a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  UnionFind tree(n);
  vl count(n);
  rep(i,n)count[i]=1;
  vl ans(m);
  ans[0]=0;
  for(ll i=1;i<m;i++){
    if(!tree.same(a[i-1],b[i-1])){
      ans[i]=ans[i-1]+count[tree.root(a[i-1])]*count[tree.root(b[i-1])];
      ll d=count[tree.root(a[i-1])]+count[tree.root(b[i-1])];
      tree.unite(a[i-1],b[i-1]);
      count[tree.root(a[i-1])]=d;
    }
    else ans[i]=ans[i-1];
  }
  //rep(i,m)cout<<ans[i]<<" ";
  reverse(ans.begin(),ans.end());
  rep(i,m)cout<<n*(n-1)/2-ans[i]<<endl;
}
  

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

long long mod = 1000000007;
long long N, S[1 << 18], T[1 << 18];
long long M, F[1 << 18];
long long D;
long long cost1[1 << 18], fee1[1 << 18];
long long cost2[1 << 18], fee2[1 << 18];
long long cost3[1 << 18], fee3[1 << 18];

int main() {
	cin >> N >> M >> D;
	for (int i = 0; i < N; i++) cin >> S[i];
	for (int i = 0; i < N; i++) cin >> T[i];
	for (int i = 0; i < M; i++) cin >> F[i];

	// Step #1 - 最初の NM 回
	for (int i = 0; i < N; i++) { cost1[i] = 0; fee1[i] = S[i]; }
	for (int i = 0; i < N * M; i++) {
		for (int j = 0; j < N; j++) {
			cost1[(i + j) % N] += fee1[(i + j) % N] * T[j];
			cost1[(i + j) % N] %= mod;
		}
		fee1[i % N] += F[i % M];
		fee1[i % N] %= mod;
	}

	// Step #2 - 次の NM 回
	for (int i = 0; i < N; i++) { cost2[i] = 0; fee2[i] = fee1[i]; }
	for (int i = 0; i < N * M; i++) {
		for (int j = 0; j < N; j++) {
			cost2[(i + j) % N] += fee2[(i + j) % N] * T[j];
			cost2[(i + j) % N] %= mod;
		}
		fee2[i % N] += F[i % M];
		fee2[i % N] %= mod;
	}

	// Step #3 - 全体を計算
	long long Period = D / (N * M);
	for (int i = 0; i < N; i++) {
		fee3[i] = S[i] + (Period % mod) * ((fee2[i] - fee1[i] + mod) % mod) % mod;
		cost3[i] = 1LL * (Period % mod) * (cost1[i] % mod) % mod;
		
		long long R = (Period % mod) * ((Period + mod - 1) % mod) % mod;
		if (R % 2 == 1) R += mod; R /= 2;
		cost3[i] += 1LL * R * ((cost2[i] - cost1[i] + mod) % mod) % mod;
		cost3[i] %= mod;
	}

	// Step #4 - 残りを計算
	for (int i = 0; i < D - (N * M * Period); i++) {
		for (int j = 0; j < N; j++) {
			cost3[(i + j) % N] += fee3[(i + j) % N] * T[j];
			cost3[(i + j) % N] %= mod;
		}
		fee3[i % N] += F[i % M];
		fee3[i % N] %= mod;
	}

	long long FinalAns = 0;
	for (int i = 0; i < N; i++) FinalAns += cost3[i];
	cout << FinalAns % mod << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
char s[11][1100];
int main()
{
    int h,w,K;
    cin >> h >> w>>K;
    rep(i,h)rep(j,w)cin >> s[i][j];
    int ans = 1001001001;
    bool cutflag;
    rep(i,1<<(h-1)){
        int res = 0;
        vector<int> p[w];
        rep(j,w){
            int white = 0;
            rep(k,h-1){
                if(s[k][j] == '1')white++;
                if(i>>k&1){
                    p[j].push_back(white);
                    
                    white = 0;

                }
            }
            if(s[h-1][j] == '1')white++;
            p[j].push_back(white);
      
            

        }
        res += p[0].size()-1;
        bool ok = true;
        rep(j,w-1){
            rep(k,(int)p[j].size())if(p[j][k]>K)ok = false;
            cutflag = 0;
            rep(k,(int)p[j].size())if(p[j][k]+p[j+1][k] > K)cutflag = 1;

            if(cutflag)res++;
            else rep(k,(int)p[j].size())p[j+1][k] += p[j][k];
        }
        rep(k,(int)p[w-1].size())if(p[w-1][k] > K)ok = false;
        if(ok)ans = min(res,ans);
        


    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    if(N%2 == 0){
        cout << N/2;
    }else{
        int V;
        V = N/2;
        V += 1;
        cout << V;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	static int n;
	static int count = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		boolean[] array = new boolean[n + 1];
		int max = 0;
		int k = sc.nextInt();
		Set<Integer> b = new TreeSet<>();
		for (int i = 0; i < k; i++) {
			b.add(sc.nextInt());
		}
		if (k <= 0) {
			System.out.println("0:");
		}
		while (max < n) {
			array[max] = true;
			String str = ++count + ": ";
			int index = 0;
			int count = 0;
			Set<Integer> tmpList = new TreeSet<>();
			for (int i = 0; i < max; i++) {
				if (array[i]) {
					str += i + " ";
					++count;
					tmpList.add(i);
				}
			}
			str += max;
			tmpList.add(max);
			
			for (int i = 0; i < max; i++) {
				if (!array[i]) {
					array[i] = true;
					index = i;
					break;
				}
			}
			for (int j = 0; j < n - 2; j++) {
				for (int i = 0; i < index; i++) {
					if (array[i]) {
						array[i] = false;
						break;
					}
				}
			}
			
			if (tmpList.containsAll(b)) {
				System.out.println(str);
			}
			
			if (count >= max) {
				++max;
				array = new boolean[n + 1];
			}
		}
	}
}



Measured memory_bytes: 176804
from bisect import bisect_left, bisect_right
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0
for i in range(N):
    x = bisect_left(A,B[i])
    y = bisect_right(C,B[i])
    ans += x*(N-y)
print(ans)

Measured memory_bytes: 22592
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W;
	for (int i = 0; i < W + 2; i++)cout << '#';
	cout << endl;
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		s = "#" + s + "#";
		cout << s << endl;
	}
	for (int i = 0; i < W + 2; i++)cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s;
    cin >> s;
    int ans = 101;
    string os = s;
    cerr << s.size() << endl;
    int n = s.size();
    for(char c='a';c<='z';c++){
        //cout << c << endl;
        s = os;
        int cnt=0;
        while(1){
            //cout << s << endl;
            bool ok=true;
            for(int i=0;i<s.size();i++){
                if(s[i]!=c){
                    ok=false;
                    break;
                }
            }
            if(ok) break;
            string ss="";
            for(int i=0;i<s.size()-1;i++){
                if(s[i]==c or s[i+1]==c) ss.push_back(c);
                else ss.push_back(s[i]);
            }
            cnt++;
            s = ss;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

constexpr int N = 200009;
int n, m; 
ll x[N], dp[N], s[N << 2], lazy[N << 2];
vector<int> ending[N];
vector<pair<pair<int, int>, int>> seg;

inline int L(int v) {return v << 1;}
inline int R(int v) {return L(v) + 1;}

void build(int v, int l, int r) {
    if(l == r) {
        s[v] = x[l];
    } else {
        int m = l + r >> 1;
        build(L(v), l, m);
        build(R(v), m + 1, r);
        s[v] = max(s[L(v)], s[R(v)]);
    }
}
void push(int v) {
    if(!lazy[v]) return;
    lazy[L(v)] += lazy[v];
    s[L(v)] += lazy[v];
    lazy[R(v)] += lazy[v];
    s[R(v)] += lazy[v];
    lazy[v] = 0;
}
ll mx(int v, int l, int r, int ql, int qr) {
    if(l > qr || r < ql) return 0;
    if(ql <= l && r <= qr) return s[v];
    push(v);
    int m = l + r >> 1;
    return max(mx(L(v), l, m, ql, qr), mx(R(v), m + 1, r, ql, qr));
}
void add(int v, int l, int r, int ql, int qr, ll value) {
    if(l > qr || r < ql) return;
    if(ql <= l && r <= qr) {
        lazy[v] += value;
        s[v] += value;
    } else {
        push(v);
        int m = l + r >> 1;
        add(L(v), l, m, ql, qr, value);
        add(R(v), m + 1, r, ql, qr, value);
        s[v] = max(s[L(v)], s[R(v)]);
    }
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int l, r, a;
        cin >> l >> r >> a;
        x[l] += a;
        x[r + 1] -= a;
        seg.push_back({{l, r}, a});
        ending[r].push_back(i);
    }

    for(int i = 1; i < N; ++i) {
        x[i] += x[i - 1];
    }
    for(int i = 1; i < N; ++i) {
        x[i] = -x[i];
    }
    build(1, 1, n);
    for(int i = 1; i <= n; ++i) {
        dp[i] = -x[i];
        for(int j : ending[i - 1]) {
            add(1, 1, n, seg[j].fi.fi, seg[j].fi.se, seg[j].se);
        }
        dp[i] += mx(1, 1, n, 1, i - 1);
        add(1, 1, n, i, i, dp[i]);
    }
    cout << max(0LL, *max_element(dp + 1, dp + n + 1)) << '\n';   
}


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

using namespace std;

struct vec
{
    long double x,y;
    bool operator ==(const vec &a) const{
        return x==a.x&&y==a.y;
    }
    bool operator <(const vec &a) const{
        if(a.x!=x) return x<a.x;
        return y<a.y;
    }
    vec operator +(const vec &a) const{
        return {x+a.x,y+a.y};
    }
    vec operator *(const long double &a) const{
        return {x*a,y*a};
    }
    vec operator -(const vec &a) const{
        return {x-a.x,y-a.y};
    }
    vec operator /(const long double &a) const{
        return {x/a,y/a};
    }
    long double len() const{
        return sqrt(x*x+y*y);
    }
    long double dot(const vec &a) const{
        return x*a.x+y*a.y;
    }
    long double crs(const vec &a) const{
        return x*a.y-y*a.x;
    }
    vec proj(const vec &a) const{
        return (a/a.len())*(*this).dot(a)/a.len();
    }
};

struct P
{
    int x;
    int f;
    int r;
    bool operator <(const P &a)const{
        return x>a.x;
    }
};


bool as(P a,P b)
{
    //if(a.y!=b.y)
    //return a.y<b.y;
    return a.x<b.x;
}

long long x,y,z,mod=1000000007;
vector<P> v;
int i,n,m,k,a,d,b,c,dx[10]={1,0,-1,0},dy[10]={0,1,0,-1};
int e;
int o[1111];
int l[1111];
int j[1];
stack<int> s;
//set<int> s;
queue<int> q;
P u[1];
char r[111],r1[111];
//string r,r1;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p,p1;
//v.resize(unique(v.begin(),v.end())-v.begin());

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


int main()
{
    scanf("%s %d",r,&a);
    n=strlen(r);
    if(n==1)
    {
        printf("%d",a/2);
        return 0;
    }
    k='z'+1;
    for(int t=0;t<n;t++)
        o[t]=l[t+1]=r[t];
    for(int t=0;t<n-1;t++)
    {
        if(o[t]==o[t+1])
            o[t+1]=k,k++,d++;
    }
    if(a==1)
    {
        printf("%d",d);
        return 0;
    }
    if(o[n-1]!=r[0])
    {
        printf("%lld",(long long)d*a);
        return 0;
    }
    l[0]=o[n-1];
    e=k+1;
    for(int t=0;t<n;t++)
    {
        if(l[t]==l[t+1])
            l[t+1]=k,k++,c++;
    }
    if(l[n]!=r[0])
    {
        printf("%lld",(long long)d*(a-a/2)+(long long)c*(a/2));
        return 0;
    }
    printf("%lld",d+(long long)c*(a-1));

}



//czecycec
//czecxzec


Measured memory_bytes: 256
# roadwork
import heapq
N, Q = map(int, input().split())
que = []
ans = [-1 for i in range(Q)]
D = [0 for i in range(N)]
heap = []
heapq.heapify(heap)
Set = set([])
for i in range(N):
    s, t, x = map(int, input().split())
    que.append((s-x, 0, i))  # append
    que.append((t-x, 1, i))  # remove
    D[i] = x

for i in range(Q):
    d = int(input())
    que.append((d, 2, i))  # querie

que.sort(key=lambda x: x[0])

for x in que:
    demand = x[1]
    if demand == 0:
        # append
        heapq.heappush(heap, (D[x[2]], x[2]))
        Set.add(x[2])
    elif demand == 1:
        # remove
        Set.remove(x[2])
    else:
        # querie
        flag = True
        while heap and flag:
            distance, index = heapq.heappop(heap)
            if index in Set:
                ans[x[2]] = distance
                heapq.heappush(heap, (distance, index))
                flag = False
for i in range(Q):
    print(ans[i])

Measured memory_bytes: 120456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define PUTS(x) cout << (x) << endl;
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define perm(c)   \
    sort(ALL(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))
#define IntsIn(v, n)                                 \
    auto v = vector<Int>(0);                         \
    for (int v##_i = 0; v##_i < (int)(n); v##_i++) { \
        Int v##_a;                                   \
        cin >> v##_a;                                \
        v.push_back(v##_a);                          \
    }
void setPrecision(int num = 20) {
    std::cout << std::fixed << std::setprecision(num);
}
template <typename T>
T Max(T a) {
    return a;
}
template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}
template <typename T>
T Min(T a) {
    return a;
}
template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}
template <typename T>
bool vector_contains(std::vector<T> vec, T value) {
    return (std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value)) != vec.size());
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
int main() {
    string s;
    cin >> s;
    auto len = LEN(s);
    auto ans = 0;
    rep(i, len / 2) {
        if (s[i] != s[len - 1 - i]) ans++;
    }
    PUTS(ans);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int t,a, b;
    int nt,na, nb;
    t = a = b = 0;
    int n;
    cin >> n;
    rep(i,n){
        cin >> nt >> na >> nb;
        int distance = abs(na - a) + abs(nb - b);
        int dt = nt - t;
        if (dt>=distance && (dt-distance)%2==0){
            t = nt;
            a = na;
            b = nb;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int n; cin >> n;
    ve_vei cnt(4, vei(13));
    rep(i,n) {
        char s; int a; cin >> s >>a;
        if(s == 'D') cnt[3][a-1]++;
        else if(s == 'C') cnt[2][a-1]++;
        else if(s == 'S') cnt[0][a-1]++;
        else cnt[1][a-1]++;
    }
    rep(i,4) rep(j,13) {
        if(cnt[i][j] == 0) {
            if(i == 0) cout << "S " << j + 1 << endl;
            else if(i == 1) cout << "H " << j + 1 << endl;
            else if(i == 2) cout << "C " << j + 1 << endl;
            else cout << "D " << j + 1 << endl;
        }
    }

}




Measured memory_bytes: 3100
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut ab: Vec<(usize, usize)> = (0..m).map(|_| (read(), read())).collect();

    ab.sort_by_key(|k| k.1);

    let mut left = 0;
    let mut ans = 0;

    for &(a, b) in ab.iter() {
        if left <= a {
            ans += 1;
            left = b;
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using ll=long long;

ll MOD=998244353;
ll pow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=MOD;
        }
        b>>=1;
        a*=a;
        a%=MOD;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x,MOD-2);
}
const int SIZE=int(1e5)*4;
vector<ll> fact(SIZE);

void init(){
    fact[0]=1;
    for(int i=1;i<SIZE;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
    }
}
int n;
ll comb(ll n,ll r){
    ll res=fact[n];
    res*=mod_inv(fact[r]);
    res%=MOD;
    res*=mod_inv(fact[n-r]);
    res%=MOD;
    return res;
}
int main(){
    init();
    cin>>n;
    ll A,B,k;
    cin>>A>>B>>k;
    ll res=0;
    for(ll a=0;a<=n;a++){
        ll Bb=k-A*a;
        if(Bb%B!=0) continue;
        ll b=Bb/B;
        if(0<=b && b<=n){
            ll sc=comb(n,a)*comb(n,b);
            sc%=MOD;
            res+=sc;
            res%=MOD;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int k;
vector<long long> nums;
void f(long long tmp, long long cur, int rest) {
  if (rest == 0) {
    nums.push_back(tmp);
    if (nums.size() == k) {
      cout<<nums.back()<<endl;
      exit(0);
    }
    return;
  }
  if (cur > 0) {
    f(tmp*10+cur-1, cur-1, rest-1);
  }
  f(tmp*10+cur, cur, rest-1);
  if (cur < 9) {
    f(tmp*10+cur+1, cur+1, rest-1);
  }
}
int main() {
  cin>>k;
  for (int i=1; i<=12; i++) {
    for (int j=1; j<=9; j++) {
      f(j, j, i-1);
    }
  }
}

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

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

vector<pair<int,int> > tasks;

int main(){
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(a,b);
    tasks.push_back(p);
  }
  sort(tasks.begin(), tasks.end(), compare_by_b);
  long days =0;
  for(int i=0; i<N; i++){
    days += tasks[i].first;
    if(days>tasks[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 2420
n = gets.to_i
length = gets.split.map(&:to_i).sort
counts = 0

# 三辺は、a < b < c
# cを最大から繰り返す
(n-1).downto(2) do |c|
  a=0 #aは最小から
  b=c-1 #bは最大から(<c)
  while a<b
#p [l, r, i, (r-l)]
    # 条件通り三角形が作れる場合、a~bまでを加算して、bを下げる
    if length[c] < length[a]+length[b]
      counts += (b-a)
      b -= 1
    # 作れない場合は、aを上げて再チャレンジ
    else
      a += 1
    end
  end
end

puts counts

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

int	main()
{
    int64_t A, B, K;
    cin >> A >> B >> K;
    if (K < A) 
        cout << A - K << " " << B << endl;
    else if (K < A + B)
        cout << 0 << " " << A + B - K << endl;
    else
        cout << "0 0" << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    rep(j, 0, min(k, 50))
    {
        vector<ll> b(n + 1, 0);
        rep(i, 0, n)
        {
            int x = max((ll)0, i - a[i]);
            int y = min((ll)n, i + a[i] + 1);
            b[x]++;
            b[y]--;
        }

        rep(i, 0, n) b[i + 1] += b[i];
        b.pop_back();
        if (a == b)
            break;
        a = b;
    }
    rep(i, 0, n) cout << a[i] << " ";
}


Measured memory_bytes: 6336
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B, C, D;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B >> C >> D;

	while (0 < A && 0 < C) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return;
		}

		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return;
		}
	}
}







Measured memory_bytes: 3652
N = int(input())
W = [input() for i in range(N)]
setw = set(W)

ans = 'Yes'

if len(setw)!=len(W):
    ans='No'
    
for i in range(N):
    if i==0:
        continue
    if W[i][0] != W[i-1][-1]:
        ans='No'
        
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp62
{
    class Program
    {
        static void Main(string[] args)
        {
            string[]NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);

            string[] A = new string[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = Console.ReadLine();
            }

            string[] B = new string[M];
            for(int i = 0; i < M; i++)
            {
                B[i] = Console.ReadLine();
            }

            for(int n = 0; n <=N-M  ; n++)
            {
                for(int m = 0; m <= N-M; m++)
                {
                    bool maru = true;
                    for(int j = 0; j < M; j++)
                    {
                        for(int k = 0; k < M; k++)
                        {
                            if (A[n+j][m+k] != B[j][k])
                            {
                                maru = false;
                                break;
                            }
                        }
                        if (maru == false)
                        {
                            break;
                        }
                    }
                    if (maru)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
            return;
        }
    }
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int n, a, b; cin >> n >> a >> b;
  int minv = (n - 1) * a + b, maxv = a + (n - 1) * b;
  cout << max(0ll, maxv - minv + 1) << endl;
}

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

vector<int64_t> L(87, 5LL);

int64_t LX(int n){
    if(L[n] != 5LL){
        return L[n];
    }
    L[n] = LX(n-2) + LX(n-1);
    return L[n];
}

int main() {
    int N;
    scanf("%d", &N);
    L[0] = 2LL;
    L[1] = 1LL;
    cout << LX(N) << endl;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int w, h, n; cin >> w >> h >> n;
   char ch[h+2][w+2];
   for(int i = 1; i <= h; i ++)
   {
      for(int j = 1; j <= w; j++)
         ch[i][j] = 'W';
   }

   for(int i = 0; i < n; i++)
   {
      int x, y, a; cin >> x >> y >> a;
      if(a == 1)
      {
         for(int i = 1; i <= h; i ++)
         {
            for(int j = 1; j <= x; j++)
               ch[i][j] = 'B';
         }
      }

      if(a == 2)
      {
         for(int i = 1; i <= h; i ++)
         {
         for(int j = x+1; j <= w; j++)
            ch[i][j] = 'B';
         }

      }

      if(a == 3)
      {
         for(int i = 1; i <= y; i++)
         {
         for(int j = 1; j <= w; j++)
            ch[i][j] = 'B';
         }

      }

      if(a == 4)
      {
         for(int i = y+1; i <= h; i ++)
         {
         for(int j = 1; j <= w; j++)
            ch[i][j] = 'B';
         }
      }

   }

   int ans = 0;
    for(int i = 1; i <= h; i ++)
   {
      for(int j = 1; j <= w; j++)
      {
         if(ch[i][j] == 'W')
            ans++;
      }
   }
   cout << ans << nl;





	return 0;
}


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

int main()
{
    int a,b,c,k;
    int sum;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(a>=k)    sum=k;
    else if(a+b>=k) sum=a;
    else sum = a-(k-a-b);
    cout << sum;
    return 0;
}

Measured memory_bytes: 3688
N = int(input())

A = list(map(int,input().split()))
a = 0
for i in range(N):
  a -= ((-1)**(i+1))*A[i]
mt = [a] 
for i in range(1,N-1):
  mt.append(2*(A[i-1]-(mt[i-1]//2)))
  
mt.append(2*(A[N-1]-(mt[0]//2)))

print(" ".join(map(str,mt)))

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

int main() {
    char n[5];
	cin>>n[0]>>n[1]>>n[2];
	if(n[0]==n[2]){
	    cout<<"Yes"<<'\n';
	}
	else{
	    cout<<"No"<<'\n';
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  n;
double u[56];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>u[i];
	sort(u,u+n);
	for(int i=1;i<=n;i++){
		u[i]=(u[i]+u[(i-1)])/2.0;
	}
	printf("%lf",u[n-1]);
	cout<<endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	cout<<S.substr(0,3)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	double t, x; cin >> t >> x;
	cout << t / x << endl;
}

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

main()
{
  int N, M, Q;
  int *L, *R,*p,*q,*s;
  int **c,**x;
  int i, k, j;
  scanf("%d %d %d",&N,&M,&Q);

  L = (int*)malloc(sizeof (int)*M);
  R = (int*)malloc(sizeof (int)*M);
  p = (int*)malloc(sizeof (int)*Q);
  q = (int*)malloc(sizeof (int)*Q);
  s = (int*)malloc(sizeof (int)*Q);
  c = (int**)malloc(sizeof (int*)*N);
  for(i=0; i<N; i++)
    c[i] = (int*)malloc(sizeof (int)*N);
  x = (int**)malloc(sizeof (int*)*N);
  for(i=0; i<N; i++)
    x[i] = (int*)malloc(sizeof (int)*N);

  for(i=0; i<M; i++)
    scanf("%d %d",&L[i], &R[i]);
  for(i=0; i<Q; i++)
    scanf("%d %d",&p[i], &q[i]);
  for(i=0; i<N; i++)
    for(k=0; k<N; k++)
      {
        x[i][k] = 0;
        c[i][k] = 0;
      }

  for(i=0; i<M; i++)
    x[L[i]-1][R[i]-1]++;

  for(i=0; i<N; i++)
    for(j=0; j<N; j++)
      for(k=0; k<=j; k++)
        c[i][j] = c[i][j] + x[i][k];

  for(i=0; i<Q; i++)
    {
      s[i]=0;
      for(k=p[i]; k<=q[i]; k++)
        if(k!=1)
          s[i] = s[i] + (c[k-1][q[i]-1] - c[k-1][p[i]-2]);
        else
          s[i] = s[i] + c[k-1][q[i]-1];
      printf("%d\n",s[i]);
    }

  return 0;
}


Measured memory_bytes: 5504
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <set>

#define size_t int

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

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

struct Puzzle {
    vector<size_t> board;
    size_t cost, mdistance, gap;
    Puzzle(): board(16), cost(0), mdistance(0) {}
    Puzzle(vector<size_t> b): board(b), cost(0), mdistance(0) {}
    bool operator<(const Puzzle &rhs) const {
        for (size_t i=0; i<16; ++i)
            if (board[i] != rhs.board[i]) 
                return board[i] < rhs.board[i];

        return false;
    }
};

size_t calc_mdistance(Puzzle p, const vector<vector<size_t>> &dtable) {
    size_t mdistance=0;
    for (size_t i=0; i<16; ++i)
        if (p.board[i] < 16)
            mdistance += dtable[i][p.board[i]-1];

    return mdistance;
}

struct State {
    Puzzle puzzle;
    size_t hcost;
    State() {}
    State(Puzzle p): puzzle(p) {}
    State(Puzzle p, const vector<vector<size_t>> &dtable): puzzle(p) {
        hcost = calc_mdistance(p, dtable);
    }
    bool operator<(const State &rhs) const {
        return hcost > rhs.hcost;
    }
};

size_t astar(Puzzle p, const vector<vector<size_t>> &dtable) {
    p.mdistance = calc_mdistance(p, dtable);
    p.cost = 0;
    State init(p, dtable);

    set<Puzzle> visited;
    gp_queue<State> q; q.push(init);
    while (!q.empty()) {
        State s=q.top(); q.pop();
        Puzzle u=s.puzzle;

        if (!u.mdistance) return u.cost;

        visited.insert(u);
        size_t sx=u.gap/4, sy=u.gap%4;
        for (size_t r=0; r<4; ++r) {
            size_t tx=sx+dx[r], ty=sy+dy[r];
            if (!(0<=tx && tx<4 && 0<=ty && ty<4)) continue;

            Puzzle v=u;
            v.gap = tx*4+ty;
            v.mdistance -= dtable[tx*4+ty][v.board[tx*4+ty]-1];
            v.mdistance += dtable[sx*4+sy][v.board[tx*4+ty]-1];
            swap(v.board[sx*4+sy], v.board[tx*4+ty]);

            if (!visited.count(v)) {
                ++v.cost;
                State nstate(v);
                nstate.hcost = v.cost + v.mdistance;
                q.push(nstate);
            }
        }
    }
    return -1;
}

int main() {
    vector<vector<size_t>> dtable(16, vector<size_t>(16));
    for (size_t i=0; i<16; ++i)
        for (size_t j=0; j<16; ++j)
            dtable[i][j] = abs(int(i/4-j/4)) + abs(int(i%4-j%4));

    Puzzle in;
    for (size_t i=0; i<16; ++i) {
        scanf("%d", &in.board[i]);
        if (!in.board[i]) {
            in.board[i] = 16;
            in.gap = i;
        }
    }

    printf("%d\n", astar(in, dtable));
    return 0;
}

Measured memory_bytes: 246736
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!
    val alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    for (s in S) {
        var a = alpha.indexOf(s) + N
        if (a >= alpha.length) a %= alpha.length
        print(alpha[a])
    }
    println()
}

Measured memory_bytes: 33784
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = [collections.Counter(list(str(input().rstrip('\n')))) for _ in range(n)]
    f = s[0]
    ans = []
    for k, v in f.items():
        m_cnt = 10 ** 10
        for d in s:
            m_cnt = min(m_cnt, d[k])
        if m_cnt != 10 ** 10:
            for i in range(m_cnt):
                ans.append(k)
    ans.sort()
    print("".join(ans))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 39280
# n=int(input())
# lst=[int(input()) for _ in range(n)]
# ans1=sum(lst)
# max1=max(lst)
# print(ans1)
# print(0 if max1<=ans1-max1 else max1-(ans1-max1))
s=input()
n=len(s)
l=n-1
lst_1=[]
for i in range(1<<l):
    lst=[]
    for j in range(l):
        if ((i>>j)&1):
            lst.append("+")
        else:lst.append("_")
    lst_1.append(lst)

ans=0
for i in range(1<<l):
    temp=s[0]
    for j in range(l):

        if lst_1[i][j]=="+":
            temp+="+"
        temp += s[j+1]
    ans+=sum(map(int,temp.split("+")))
print(ans)

Measured memory_bytes: 9104
import java.util.*
import kotlin.comparisons.*

fun main(args: Array<String>){
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toLong() }

    val pQueue = PriorityQueue<Long>(N, compareByDescending { it })
    A.forEach { pQueue.add(it) }
    repeat(M){
        val a = pQueue.poll()
        pQueue.add(a/2)
    }
    println(pQueue.sum())
}

Measured memory_bytes: 71868
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
typedef string::const_iterator State;
string s;
int reff;
string expr(State& be){
	string ret;
	while(true){
		int x=1;
		if(isdigit(*be)){
			x=0;
			while(isdigit(*be)){
				x*=10;
				x+=(*be)-'0';
				be++;
			}
		}
		if(*be=='('){
			be++;
			string t=expr(be);
			rep(i,x){
				if(ret.size()>reff) break;
				ret+=t;
			}
			be++;
		}else if('A'<=*be && *be<='Z'){
			rep(i,x){
				if(ret.size()>reff) break;
				ret+=(*be);
			}
			be++;
		}else break;
		if(ret.size()>reff) break;
	}
	return ret;
}
int main(){
	while(true){
		cin>>s>>reff;
		if(s[0]=='0') break;
		State be=s.begin();
		string t=expr(be);
		if(t.size()<=reff) cout << "0\n";
		else cout << t[reff]<<endl;
	}
}

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

using namespace std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}cww;

#define rep(i,s,t) for(auto i=s;i<t;i++)

typedef long long LL;
const LL MOD=1e9+7;

template<typename T>
string debug(vector<T> v,string c){
    string res;
    for(int i=0,sz=v,size();i<sz;i++){
        if(i)res+=c;
        res+=v[i];
    }
    return res;
}

int main(){
    int N;LL L;
    cin>>N>>L;
    vector<LL> a(N);
    for(auto &it:a)cin>>it;
    int top=1;
    rep(i,1,N)
        if(a[top-1]+a[top]<a[i-1]+a[i])
            top=i;
    if(a[top-1]+a[top]<L)cout<<"Impossible"<<endl;
    else{
        cout<<"Possible"<<endl;
        rep(i,1,top)cout<<i<<endl;
        for(int i=N-1;i>top;i--)cout<<i<<endl;
        cout<<top<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>

using namespace std;

int main(){
    int N, n;
    string S;
    cin >> N;
    cin >> S;
    if( N/2 *2 != N ){
        cout << "No" << endl;
        return 0;
    } 
    else{
        n = N / 2;
        for(int i=0;i<n;i++){
            if(S[i]!=S[n+i]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s,t;
	cin>>s>>t;
	ll n=s.size(),mini=0;
	for(ll i=0;i<n;i++)
	if(s[i]!=t[i])
	mini++;
	cout<<mini;
	
}

Measured memory_bytes: 3828
n = int(input())
h = list(map(int, input().split()))
ans = 0
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
else:
    ans = max(ans, count)
print(ans)

Measured memory_bytes: 14252
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
ans = [1] * N


# print(H)

for i in range(M):
    a, b = map(int, input().split())
    AH = H[a - 1]
    BH = H[b - 1]
    # print(AH, BH)
    if AH >= BH:
        ans[b - 1] = 0
    if BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll K,A,B;
  cin>>K>>A>>B;
  for(ll i=K;i<=B;i+=K){
    if(i>=A){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");

  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
typedef long long LL;
const int MAXN = 100005;
LL a[MAXN];
int n;
LL judge(LL x)
{
    for(int i=1;i<=n;++i)
        x=x/a[i]*a[i];
    return x;
}
int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;++i)
        scanf("%lld", &a[i]);
    LL l=2, r=1e15;
    LL mid;
    LL Max=-1, Min=-1;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(judge(mid)>=2)
            r=mid-1, Min=mid;
        else
            l=mid+1;
    }
    l=2,r=1e15;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(judge(mid)>2)
            r=mid-1;
        else
            l=mid+1, Max=mid;
    }
    if(judge(Min)!=2||judge(Max)!=2)
        puts("-1");
    else
        printf("%lld %lld\n", Min, Max);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
 
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
 
typedef long long int64;
const double INF = 1e9;

int N, a[20];
double dp[20][200001];

int main(){

  fill_n( *dp, 20 * 200001, INF);

  cin >> N;
  for(int i = 0; i < N; ++i){
    cin >> a[i];
  }
  for(int i = 1; i < 200001; ++i){
    dp[0][i] = fabs(a[0] - i) / a[0];
  }
  for(int i = 0; i < N - 1; ++i){
    for(int j = 1; j < 200001; ++j){
      if(dp[i][j] != INF){
        for(int k = j; k < 200001; k += j){
          dp[i + 1][k] = min( dp[i + 1][k], max( dp[i][j], fabs( a[i + 1] - k) / a[i + 1]));
        }                
      }
    }
  }
  cout << fixed << setprecision(10) << *min_element( dp[N - 1], dp[N]) << endl;
}

Measured memory_bytes: 32488
import java.io.*;
import java.security.acl.Group;
import java.util.*;

//@0200  Z¶êl· ~ÂtÌÐ¹ØÒ~
public class Main {

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

		
		for(int loop = 0;; loop++) {

			String s = reader.readLine();
			String[] sp = s.split(" ");
			int N = Integer.parseInt(sp[0]);
			int M = Integer.parseInt(sp[1]);
			if (N == 0)
				break;

			int[][] senros = new int[N][]; 
			
			for(int i = 0; i < N; i++) {
				s = reader.readLine();
				sp = s.split(" ");
				int a = Integer.parseInt(sp[0]);
				int b = Integer.parseInt(sp[1]);
				int cost = Integer.parseInt(sp[2]);
				int time = Integer.parseInt(sp[3]);
				
				int[] senro = new int[] { a, b, cost, time };
				senros[i] = senro;
			}
			
			s = reader.readLine();
			int k = Integer.parseInt(s);

			for(int toi = 0; toi < k; toi++) {
				// â¢í¹
				
				s = reader.readLine();
				sp = s.split(" ");
				int p = Integer.parseInt(sp[0]);
				int q = Integer.parseInt(sp[1]);
				int r = Integer.parseInt(sp[2]);

				int[] eki = new int[M];
				for(int i = 0; i < M; i++) {
					eki[i] = 999999999;
				}
				eki[p - 1] = 0; // X^[gw 
			
				for(;;) { // Àè·éÜÅ
					
					boolean isChange = false;
					
					for(int i = 0; i < N; i++) { // ·×ÄÌüHÉÂ¢Ä
						int[] senro = senros[i];
						int cost = senro[2 + r]; // àzorÔ
						if (eki[senro[0] - 1] > eki[senro[1] - 1] + cost) {
							eki[senro[0] - 1] = eki[senro[1] - 1] + cost;
							isChange = true;
						}
						if (eki[senro[1] - 1] > eki[senro[0] - 1] + cost) {
							eki[senro[1] - 1] = eki[senro[0] - 1] + cost;
							isChange = true;
						}
					}
					
					if (!isChange)
						break; // Àèµ½
				}
				
				System.out.printf("%d\n", eki[q-1]);
				
			}
		}		
		
		reader.close();
	}

}

Measured memory_bytes: 14000