akhauriyash/Code-Regression huggingface dataset:
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define po pop()
#define pu push
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;string st; char ch;
    while(cin>>n)
    {
        n+=(n*n)+(n*n*n);
        cout<<n<<en;
    }
}




Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  getv(v);
  sort(ALL(v));
  FOR(i, N - 1) { v[i + 1] = (v[i] + v[i + 1]) / 2.0; }
  printf("%.10f\n", v[N - 1]);
  return 0;
}
#include <algorithm>


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, y;
	cin >> n >> y;
	y /= 1000;
	rep(i, y/10+1){
		int t = y - i*10;
		rep(j, t/5+1){
			int tt = t - j*5;
			int x = n - i - j;
			if(x == tt){
				cout << i << " " << j << " " << x << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

const long long mod = 1e9 + 7;
long long fact[100001];

long long add_mod (long long a, long long b) {
	return (a + b) % mod;
}

long long sub_mod (long long a, long long b) {
	return (a + mod - b) % mod;
}

long long mul_mod (long long a, long long b) {
	return (a * b) % mod;
}

long long pow_mod (long long a, long long b) {
	long long res = 1LL, t = a;
	while (b) {
		if (b & 1)
			res = mul_mod(res, t);
		b >>= 1;
		t = mul_mod(t, t);
	}
	return res;
}

long long div_mod (long long a, long long b) {
	return mul_mod(a, pow_mod(b, mod - 2));
}

long long c (int n, int k) {
	if (k > n)
		return 0LL;
	return div_mod(fact[n], mul_mod(fact[k], fact[n - k]));
}

void precalc () {
	fact[1] = fact[0] = 1;
	for (long long i = 2; i <= 100000; ++i)
		fact[i] = mul_mod(fact[i - 1], i);
}

signed main () {
	precalc();
	
	int n, k;
	cin >> n >> k;
	vector < int > a(n);
	for (int &x: a)
		cin >> x;
	sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = 0; i < n; ++i) 
		ans = sub_mod(add_mod(ans, mul_mod(a[i], c(i, k - 1))), mul_mod(a[i], c(n - 1 - i, k - 1)));
	cout << ans << '\n';
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 mp(n);
  rep(i, n) {
    int p;
    cin >> p;
    p--;
    mp[p] = i;
  }
  int sum = 0;
  {
    int u = 0;
    while (u < n) {
      int c = 1;
      while (u + 1 < n && mp[u] < mp[u + 1]) {
        c++;
        u++;
      }
      amax(sum, c);
      u++;
    }
  }
  int ans = n - sum;
  cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
s_10 = []
s_not_10 = []

for _ in range(N):
    s = int(input())
    if s % 10 == 0:
        s_10.append(s)
    else:
        s_not_10.append(s)

if len(s_not_10) == 0:
    print(0)
    exit(0)

s_not_10_sum = sum(s_not_10)
if s_not_10_sum % 10 != 0:
    print(s_not_10_sum+sum(s_10))
    exit(0)

s_not_10.sort()
print(s_not_10_sum+sum(s_10)-s_not_10[0])


Measured memory_bytes: 3064
#include <stdio.h>
int sub(int m, int n);

int main(void) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    if(sub(a, c)<=d) {
        printf("Yes\n");
    }else if(sub(a, b)<=d && sub(b, c)<=d) {
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    return 0;
}

int sub(int m, int n) {
    return m>n? m-n : n-m;
}


Measured memory_bytes: 128
function main(input){
	const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);
    
    if ( (a * b) % 2 === 0){
    	console.log("Even");
    } else {
    	console.log("Odd");
    }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w) { this->w = w; }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo inline operator + (const modulo &b) { modulo r = *this; r += b; return r; }
	modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	
	modulo inline operator - (const modulo &b) { modulo r = *this; r -= b; return r; }
	modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	
	modulo inline operator * (const modulo &b) { modulo r = *this; r *= b; return r; }
	modulo& operator *= (const modulo &b) { w = (num) w * b.w % mod, fix(); return *this; }
	
	modulo inline operator / (const modulo &b) { modulo r = *this; r /= b; return r; }
	modulo& operator /= (const modulo &b) { *this *= b.inv(); return *this; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, res = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1)  res *= a;
		return res;
	}
};

typedef modulo<998244353> rem;

const int nsz = int(2e5);
rem n, m, k, fac[nsz + 5], ifc[nsz + 5], ans;

void inline init() {
	fac[0] = ifc[0] = 1;
	cont (i, n) {
		fac[i] = fac[i - 1] * rem(i);
		ifc[i] = fac[i].inv();
	}
}

rem inline C(int n, int m) { return fac[n] * ifc[m] * ifc[n - m]; }

rem inline f(int n, int k) { return C(n - 1, k) * m * (m - rem(1)).pow(n - k - 1); }

int main() {
	scanf("%d%d%d", &n, &m, &k);
	if (m == 1) {
		printf("%d\n", k == n - rem(1));
		return 0;
	}
	init();
	circ (i, 0, int(k)) {
		ans += f(n, i);
	}
	printf("%d\n", ans);
}


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

int main()
{
	string S; cin >> S;
	if (S[0] == S[1])
	{
		cout << "Bad" << endl;
	}
	else if (S[1] == S[2])
	{
		cout << "Bad" << endl;
	}
	else if (S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while(true) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a==0 && b==0) break;
		if(a<b) {
			System.out.println(a+" "+b);
		}else {
			System.out.println(b+" "+a);
		}
	}
 }
}



Measured memory_bytes: 35736
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define PI 3.141592653589793


int main(){
    int N; cin >> N; set<string> st;
  rep(i, N){
    string S;cin >> S; st.insert(S);
  }
  cout << st.size() << endl;
}

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

int main() {
    int N;
    scanf("%d",&N);

    char color=0, C;
    int i, slimes=0;
    scanf("%c", &C);
    for (i=0; i<N; i++) {
        scanf("%c", &C);
        if (C != color)  slimes++;
        color = C;
    }
    printf("%d", slimes);

    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from copy import deepcopy

def main():
    N,M = map(int,input().split())
    INF = 10**10
    l = [[INF for _ in range(N)] for _ in range(N)]
    X = [list(map(int,input().split())) for _ in range(M)]
    for i in range(M):
        l[X[i][0]-1][X[i][1]-1] = X[i][2]
        l[X[i][1]-1][X[i][0]-1] = X[i][2]
    d = deepcopy(l)
    for i in range(N):
        for j in range(N):
            for k in range(N):
                d[j][k] = min(d[j][k],d[j][i]+d[i][k])

    count = 0
    for i in range(N):
        for j in range(N):
            if l[i][j] == d[i][j]:
                count += 1

    print(M-count//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,M,Q;
vector <vector <int> > G;
vector <int > v,d,c;
vector <vector <int> > dp;

void func(int v,int d,int c){
	if(dp[v][d] != -1)
		return;
	dp[v][d] = -2;
	if(d == 0){
		dp[v][d] = c;
		return;
	} else {
		func(v,d-1,c);
		for(vector<int>::iterator itr_g = G[v].begin();itr_g!=G[v].end();++itr_g){
			func(*itr_g,d-1,c);
		}
	}
}

int main()
{

	cin >> N >> M;

	G.resize(N+1);

	REP(i,M){
		int a,b;
		cin >> a;
		cin >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	cin >> Q;
	v.resize(Q);
	d.resize(Q);
	c.resize(Q);
	REP(i,Q){
		cin >> v[i];
		cin >> d[i];
		cin >> c[i];
	}
	int maxd = *max_element(d.begin(),d.end());
	dp.resize(N+1);
	REP(i,N+1){
		dp[i].resize(maxd+1);
		REP(j,maxd+1){
			dp[i][j] = -1;
		}
	}

	RREP(i,Q){
		func(v[i],d[i],c[i]);
	}

	FOR(i,1,N+1){
		if(dp[i][0] < 0)
			cout << 0 << endl;
		else
			cout << dp[i][0] << endl;
	}

}



Measured memory_bytes: 16248
# inputs
n = int(input())
matches = []
for i in range(n):
    matches.append(input().split())

# output
point_a = 0
point_b = 0
for match in matches:
    if match[0] > match[1]:
        point_a += 3
    elif match[0] < match[1]:
        point_b += 3
    elif match[0] == match[1]:
        point_a += 1
        point_b += 1

print('{} {}'.format(point_a, point_b))



Measured memory_bytes: 5716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }

    multiset<int> st;
    st.insert(-a[0]);
    for(int i=1;i<n;++i) {
        auto itr = st.upper_bound(-a[i]);
        if(itr == st.end()) {
            st.insert(-a[i]);
        } else {
            st.erase(itr);
            st.insert(-a[i]);
        }
    }

    cout << st.size() << endl;
}


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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    if (str[0] == str[1] && str[2] == str[3] && str[0] != str[3]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 105
int main(){

  int i,j,n,k,y,A[N][N],B[N][N];

  for(i=1;i<=100;i++){
    for(j=1;j<=100;j++){
      A[i][j]=0;
      B[i][j]=0;
    }
  }
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&y,&k);
   
    for(j=1;j<=k;j++){
      scanf("%d",&A[i][j]);
    
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      B[i][A[i][j]]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",B[i][j]);
    }
    printf("%d\n",B[i][n]);
  }
  return 0;
}

Measured memory_bytes: 684
enum class Direction {
    HOL, VER
}
fun main(args: Array<String>) {
    val (w, h) = readLine()!!.split(' ').map(String::toInt)
    val p = Array(w) {
        Pair(Direction.HOL, readLine()!!.toLong())
    }
    val q = Array(h) {
        Pair(Direction.VER, readLine()!!.toLong())
    }

    val pq = Array(w + h){i->
        if(0 <= i && i< w){
            p[i]
        }else{
            q[i - w]
        }
    }

    val sortedPQ = pq.sortedBy { it.second }

    var mutW = w.toLong()+1
    var mutH = h.toLong()+1
    var sum = 0L

    for (pqElem in sortedPQ){
        if(pqElem.first == Direction.VER){
            //println(mutW * pqElem.second)
            sum += mutW * pqElem.second
            mutH --
        }else{
            //println(mutH * pqElem.second)
            sum += mutH * pqElem.second
            mutW --
        }
    }
    println(sum)
}

Measured memory_bytes: 105192
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int N;
vector<int> A, B;
void solve(int t, int start_offset, int n)
{
    if(t == 0)return;
    //const int start_offset = n/ 2 - t/2;
    B[start_offset] = A[t - 1];
    B[start_offset + t - 1] = A[t - 2];
    solve(t - 2, start_offset + 1, n);
}
int main(int, char *[])
{
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        int v;
        cin >> v;
        A.push_back(v);
    }
    B.resize(N / 2 * 2);

    solve(N / 2 * 2, 0, N / 2 * 2);
    if(N & 1)
    {
        cout << A.back();
        for(auto it = B.rbegin(); it != B.rend(); ++it)
            cout << " " << *it;
        cout << endl;
    }
    else
    {
        for(size_t i = 0; i < B.size(); ++i)
        {
            if(i > 0) cout << " ";
            cout << B[i];
        }
        cout << endl;
    }
    return 0;
}


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

    if (n <= 111) {
        cout << "111" << endl;
    } else if (n <= 222) {
        cout << "222" << endl;
    } else if (n <= 333) {
        cout << "333" << endl;
    } else if (n <= 444) {
        cout << "444" << endl;
    } else if (n <= 555) {
        cout << "555" << endl;
    } else if (n <= 666) {
        cout << "666" << endl;
    } else if (n <= 777) {
        cout << "777" << endl;
    } else if (n <= 888) {
        cout << "888" << endl;
    } else {
        cout << "999" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = []
for _ in range(N):
    A, B = map(int, input().split())
    AB.append((A,B))
t = 0
flag = True
for (A, B) in sorted(AB, key = lambda x:x[1]):
    t += A
    if t > B:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}

vi adj[100001];
bool vis[100001];

void dfs(int v)
{
	vis[v] = 1;
	for(auto x : adj[v])
	{
		if(!vis[x])
		{
			dfs(x);
		}
	}
}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,m;
    cin>>n>>m;

    make_graph(m);

    int cnt = 0;
    f1(i,1,n) vis[i] = 0;

    f1(i,1,n)
    {
    	if(!vis[i])
    	{
    		cnt++;
    		dfs(i);
    	}
    }
    cout<<cnt-1;
}

Measured memory_bytes: 9704
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

def double(n, k):
    num = n
    cnt = 0
    while True:
        if num < k:
            cnt += 1
            num *= 2
        else:
            break
    return cnt

N, K = getNM()
ans = max(0, N - K + 1) / N
for i in range(1, min(N + 1, K)):
    prob = double(i, K)
    ans += 1 / ((2 ** prob) * N)
print(ans)


Measured memory_bytes: 64876
a=[]
try :
    while True:
        a.append(int(input()))
except EOFError:
    pass


counts =[0] *101


for n in a: #nの中にaを入れる
    counts[n] +=1


for n in range(len(a)):
    if counts[n]==max(counts):
        print(n)
    


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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, m, d);
    int ans = 0;
    For(i, m) For(j, d){
        if((j+1) % 10 >= 2 && (j+1) / 10 >= 2 && (j+1) % 10 * ((j+1) / 10) == i+1){
            ans ++;
            // Cout(i+1, " ", j+1);
        }
    }
    Cout(ans);
}




Measured memory_bytes: 256
#include <stdio.h>

void p(int A[], int n) {
	int i;
	for (i = 0; i < n; i++) {
		if (i != 0) putchar(' ');
		printf("%d", A[i]);
	}
	putchar('\n');
}

int main(void) {
	int i, j, n, key, A[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++) 
		scanf("%d", A + i);
	for (j = 1; j < n; j++) {
		p(A, n);
		key = A[j];
		i = j - 1;
		while ((i >= 0) && (A[i] > key)) {
			A[i + 1] = A[i];
			i--;
		}
		A[i + 1] = key;
	}
	p(A, n);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char a[500000],b;
  long long c=0,d=0,e=0;
  cin>>a;
  for(int i=0;i<200000;i++){
    if(a[i]=='0')
      break;
    if(i==0)
      b=a[i];
    else if(b!=a[i]){
      c++;
      b=a[i];
    }
    d++; 
  }
for(int i=d-1;i>=0;i--){
  if(i==d-1)
    b=a[i];
  else if(b!=a[i]){
    e++;
    b=a[i];
  }
  
 }
 if(e<=c)
  cout<<e-1<<endl;
 else
   cout<<c-1<<endl;
 
  return(0);
}


Measured memory_bytes: 384
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
double dp[200][100];//動的計画法
int main(){
    int s1,s2,n,max,i;
    while(cin>>s1>>s2,s1){
        max=s1+s2;
        n=i=0;
        i++;
        while(i!=5){
            cin>>s1>>s2;
            if(max<s1+s2){
                max=s1+s2;
                n=i;
            }
            i++;
        }
        switch(n){
            case 0:
                cout<<"A ";
            break;
            case 1:
                cout<<"B ";
            break;
            case 2:
                cout<<"C ";
            break;
            case 3:
                cout<<"D ";
            break;
            default:
                cout<<"E ";
            break;
        }
        cout<<max<<endl;
    }
}


Measured memory_bytes: 3004
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<long long> p_decom(long long m){
  vector<long long> v;

  while(m % 2 == 0){
    v.push_back(2LL);
    m /= 2LL;
  }

  for(long long i = 3LL; i * i <= m; i += 2LL){
    while(m % i == 0){
      v.push_back(i);
      m /= i;
    }
  }

  if(m > 1LL){
    v.push_back(m);
  }

  sort(all(v));

  return v;
}

ll d[100];

int main(){
	ll ans = 0;
	clr(d,0);
	ll n;
	cin>>n;
	rep(t,1,n+1){
		vector<ll> v = p_decom(t);
		rep(i,0,v.sz){
			d[v[i]]++;
		}
	}
	rep(i,0,100){
		rep(j,i+1,100){
			rep(k,j+1,100){
				if(d[i]>=4&&d[j]>=4&&d[k]>=2){
					ans++;
				}
				if(d[i]>=4&&d[j]>=2&&d[k]>=4){
					ans++;
				}
				if(d[i]>=2&&d[j]>=4&&d[k]>=4){
					ans++;
				}
			}
		}
	}
	rep(i,0,100){
		rep(j,i+1,100){
			if(d[i]>=4&&d[j]>=14){
				ans++;
			}
			if(d[i]>=14&&d[j]>=4){
				ans++;
			}
			if(d[i]>=24&&d[j]>=2){
				ans++;
			}
			if(d[i]>=4&&d[j]>=24){
				ans++;
			}
		}
	}
	rep(i,0,100){
		if(d[i]>=74)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

namespace TestApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var str = Console.ReadLine()
                    .Split(' ')
                    .Select(x => long.Parse(x))
                    .ToList();
                var a = str[0];
                var b = str[1];
                var c = str[2];
                var k = str[3];
                var nokori = k % 2;

                var a1 = a - b;


                switch (nokori)
                {
                    case 0:
                        Console.WriteLine(a1);
                        break;
                    case 1:
                        Console.WriteLine(-a1);
                        break;

                }
            }
            catch
            {
                Console.WriteLine("Unfair");
            }
            Console.ReadLine();

        }
    }
}



Measured memory_bytes: 13396
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const ll MOD=1000000007;
ll N,T;
ll D[100005];
int main() {

    cin>>N>>T;
    rep(i,N) cin>>D[i];
    sort(D,D+N);
    ll ans=1;
    rep(i,N) {
        ll pos=upper_bound(D,D+N,D[i]+T)-D;
        //printf("%d %d : %d\n",i,pos,pos-i);
        ans=ans*(pos-i)%MOD;
    }


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

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

void fail(){
    cout << 0 << endl;
    exit(0);
}

int main(){
    int X, Y;
    cin >> X >> Y;
    int S = X+Y;
    if(S%3) fail();
    int T = S/3;
    int x = X-T, y = Y-T;
    if(x < 0 || y < 0) fail();
    create_mod_tables(T);
    cout << comb_mod(T, x) << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int weaklyLIS_length(int n, T a[], void *mem = wmem){
  T *arr=(T*)mem;
  int i, k, res;
  if(n==0){
    return 0;
  }
  arr[0] = a[0];
  res = 1;
  for(i=1;i<n;i++){
    k = upper_bound(arr, arr+res, a[i]) - arr;
    arr[k] = a[i];
    if(res==k){
      res++;
    }
  }
  return res;
}
char memarr[96000000];
int N;
int A[100000];
int main(){
  int res;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  reverse(A,A+N);
  res = weaklyLIS_length(N, A);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, A[1d5];
// {
//   int res;
//   rd(N,A(N));
//   reverse(A,A+N);
//   res = weaklyLIS_length(N, A);
//   wt(res);
// }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    ll N, K; cin >> N >> K;
    ll ans = 0;
    if(K % 2 == 1) {
        ans = (N / K) * (N / K) * (N / K);
    } else {
        K /= 2;
        ans += ((N / K + 1) / 2) * ((N / K + 1) / 2) * ((N / K + 1) / 2);
        ans += (N / K / 2) * (N / K / 2) * (N / K / 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = "";
        int n = in.nextInt();
        int l = in.nextInt();
        String [] str = new String[n];
        for (int i = 0; i < n; i++){
            str[i] = in.next();
        }
        Arrays.sort(str);
        for (int i = 0; i < n; i++){
            s += str[i];
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 22988
n = int(input())
d = []
for _ in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        d.append(1)
    else:
        d.append(0)
for i in range(len(d)-2):
    if sum(d[i:i+3]) == 3:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		int n = Integer.parseInt(br.readLine());
		int nums[] = new int[n];
		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			nums[i] = Integer.parseInt(str[i]);
		}
		for (int j = 0; j < n; j++) {
			int v = nums[j];
			int s = j - 1;
			while (s >= 0 && nums[s] > v) {
				nums[s + 1] = nums[s];
				s--;
			}
			nums[s + 1] = v;
			for (int p = 0; p < n; p++) {
				if (p == (n - 1)) {
					System.out.println(nums[p]);
				} else {
					System.out.print(nums[p] + " ");
				}
			}
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  f80 ans;
  if (d == 0) {
    ans = (f80) n * (m - 1) / ((f80) n * n);
  } else {
    ans = (f80) 2 * (n - d) * (m - 1) / ((f80) n * n);
  }
  cout << ans << endl;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint K,N;
	cin >> N >> K;
	vector<llint> H(N);
	rep(i,0,N) {
		cin >> H[i];
	}

	llint ans=0;

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

	llint sum=0;

	rep(i,0,N-K) {
		sum+=H[i];
	}

	ans = sum;

	//OUTPUT
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4820
#A
import copy

s=list(input())
times=[0]*26

ans=float('inf')


for i in s:
  temp=copy.deepcopy(s)
  tempans=0
  while True:
    #print(i,temp.count(i), len(temp))
    if temp.count(i)==len(temp):
      ans=min(ans,tempans)
      break
    else:
      for j in range(len(temp)-1):
        if temp[j+1]==i:
          temp[j]=i
      tempans+=1
      del temp[-1]
      #print(temp,tempans)
      
print(ans)

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int H,W;
vector<vector<char>> board;
vector<vector<bool>> check;

const vector<int> dy = {-1,0,0,1};
const vector<int> dx = {0,-1,1,0};

void dfs(int y, int x) {
    check[y][x] = true;
    rep(i,4) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (board[ny][nx] != '#' && !check[ny][nx]) dfs(ny,nx);
    }
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int W,H,N; cin >> W >> H >> N;
    vector<vector<bool>> A(H, vector<bool>(W));
    rep(k,N) {
        int x,y,a;
        cin >> x >> y >> a;
        rep(i,H) {
            rep(j,W) {
                if (a == 1 && j < x) A[i][j] = true;
                if (a == 2 && j >= x) A[i][j] = true;
                if (a == 3 && i < y) A[i][j] = true;
                if (a == 4 && i >= y) A[i][j] = true;
            }
        }
        
    }
    int count = 0;
    rep(i,H) rep(j,W) if (!A[i][j]) count++;

    cout << count << endl;
}


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

int main(){
    //入力
    int A, B, T, C;
    cin >> A >> B >> T;

    //T+0.5をAで割った商の整数部分
    C = floor((T + 0.5) / A);

    //出力
    cout << B * C << endl;
}

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

int main(void){
    // Your code here!
    int n;
    int x[101];
    int y[101];
    int i,j,sa;
    double res1,res2,res3,res4,max;
    res1 = res2 = res3 = res4 = max = 0;
    
    int *p1, *p2;
    
    p1 = x;
    p2 = y;
    
    scanf( "%d" , &n );
    
    
    for( i = 0; i < n; i++ ){
        scanf( "%d" , p1 + i );
    }
    for( i = 0; i < n; i++ ){
        scanf( "%d" , p2 + i );
    }
    for( i = 0; i < n; i++ ){
        sa    = abs( x[i] - y[i] );
        res1 += sa;
        res2 += pow( sa , 2.0 );
        res3 += pow( sa , 3.0 );
        if( max < sa ){
            max = sa;
        }
    }
    printf( "%f\n" , res1 );
    printf( "%f\n" , pow(res2 , 0.5 ) );
    printf( "%f\n" , pow( res3 , (double)1/3 ) );
    printf( "%f\n" , max );
}


Measured memory_bytes: 2112
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 23;
const int MOD = 1e9+7;
int dp[N][1 << N];
int a[N][N];



signed main(){
	IOS
	int n;	cin >> n;
	rep(i,n){
		rep(j,n)	cin >> a[i][j];
	}
	rep(i,1 << n)	dp[0][i] = 1;
	rep(i,n){
		rep(j,n){
			rep(k,1 << n){
				if(a[i][j] & (k >> j))	dp[i+1][k] = (dp[i+1][k] + dp[i][k ^ (1 << j)]) % MOD;
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << endl;

}


Measured memory_bytes: 405760
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
#define ipair pair<int,int>
#define mod 1000000007

int main()
{
    int n;
    cin>>n;
    long int dum;
    map<long int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>dum;
        if(m[dum]==0) m[dum]++;
        else m[dum]--;
    }
    map<long int,int>::iterator it=m.begin();
    int res=0;
    for(;it!=m.end();it++)
    {
        if(it->second>0) res++;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 6528
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    tmp = list(map(int, input().split()))
#    print(tmp)
    L.append(tmp[0])
    R.append(tmp[1])


kukan = [max(L), min(R)]
sa = kukan[1] - kukan[0] +1
if sa > 0:
    print(sa)
else:
    print("0")


Measured memory_bytes: 11144
#include<stdio.h>
long int a[200000];
int main()
{
	long int n, i,j,k,m,b;
	k = 0;
	m = 0;
	b = 0;
	scanf("%ld", &n);
	for (i = 0;i < n;i++)
	{
		scanf("%ld", &a[i]);
		if ((a[i] % 4) == 0)
			k++;
		else
			if ((a[i]%2)==0)
				b++;
			else
				m++;
	}
	if (k >= m)
		printf("Yes");
	else
		if ((k == (m - 1)) && (b == 0)&&(k>=1))
			printf("Yes");
		  else
			printf("No");
	return 0;
}


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

using namespace std;

int h,w,a,sum,c[15][15];
int main() {
    int i, j, k;
    int a[210][210];
    cin>>h>>w;
    for(i=0; i<10; i++) 
    	for(j=0; j<10; j++) 
			cin>>c[i][j];
    for(k=0; k<10; k++){ 
    	for(i=0; i<10; i++){ 
    		for(j=0; j<10; j++) {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
			}
		}
	}
	for(i=1; i<=h; ++i){
		for(j=1; j<=w; ++j) {
			cin>>a[i][j];
			if(a[i][j]!=-1) 
				sum+= c[a[i][j]][1];
		}
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long INF=2e9;
int main() {
    int n;
    cin >> n;
    vector<array<long long,2>> d{{-INF,INF},{-INF,INF}};
    for ( int i=0; i<n; i++ ) {
        long long x,y;
        cin >> x >> y;
        for ( int j=0; j<2; j++ ) {
            long long v=x+y;
            d[j][0]=max(d[j][0],v);
            d[j][1]=min(d[j][1],v);
            y*=-1;
        }
    }
    cout << max(d[0][0]-d[0][1], d[1][0]-d[1][1]);
    return 0;
}

Measured memory_bytes: 3640