akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;



void main() {
    int n, h, w;
    scan(n, h, w);
    iota(n).map!(i => readln.split.to!(int[])).count!(a => a[0] >= h && a[1] >= w).writeln;
}



























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 508
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> S(N + 1);
  map<int64_t, int64_t> counts;
  S[0] = 0;
  counts[0] = 1;
  for (int64_t i = 1; i <= N; ++i) {
    int64_t a;
    cin >> a;
    S[i] = a + S[i - 1];
    if (counts.find(S[i]) == counts.end()) {
      counts[S[i]] = 1;
    } else {
      ++counts[S[i]];
    }
  }

  int64_t result = 0;
  for (const auto m : counts) {
    const int64_t count = m.second;
    result += count * (count - 1) / 2;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 17116
#include <iostream>

int main(void){
    int ans=0, tmp=0;
    std::string S;
    std::cin >> S;

    for (char c: S){
        if (c == 'A' || c == 'T' || c == 'G' || c == 'C'){
            ++tmp;
        } else {
            if (tmp != 0 && tmp > ans){
                ans = tmp;
                tmp = 0;
            }
        }
    }
    
    if (tmp != 0 && tmp > ans) ans = tmp;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3592
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
   double a,b,c,d;
   cin>>a>>b>>c;
   d=0.5*a*b;
   cout<<d<<endl;
return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    vector<vector<ar<ll,2>>> dp(n+1,vector<ar<ll,2>>(n+1,{0,0}));

    // dp[i][j][0] = for elements from i - j max score for first person picking
    // dp[i][j][1] = for elements from i - j max score for second person picking

    for(int i = n-1;i >=0;i--){
        for(int j = i;j < n;j++){
            if(i == j){
                dp[i][j] = {a[i],0};
            }else{
                ar<ll,2> op1 = {a[i]+dp[i+1][j][1], dp[i+1][j][0]};
                ar<ll,2> op2 = {a[j]+dp[i][j-1][1], dp[i][j-1][0]};
                dp[i][j] = max(op1,op2);
            }
        }
    }

    cout << dp[0][n-1][0] - dp[0][n-1][1] << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> x(N), minus, plus;
    for(int i = 0; i < N; i++){
        cin >> x[i];
        if(x[i] >= 0) plus.push_back(x[i]);
        else minus.push_back(x[i]);
    }
    auto itr = lower_bound(x.begin(), x.end(), 0);
    int pos = distance(x.begin(), itr);
    ll MIN = 1 << 30;
    for(int i = 0; i < N - K + 1; i++){
        if(i + K - 1 < pos){
            MIN = min(MIN, -x[i]);
        }else if(pos <= i){
            MIN = min(MIN, x[i + K - 1]);
        }else{
            MIN = min(MIN, (x[i + K-1] - x[i]) + min(llabs(x[i]),llabs(x[i + K -1])));
        }
    }
    cout << MIN << endl;
}

Measured memory_bytes: 2424
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353//1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int func(int a, int b)
{
	if (a < b)
		return func(b, a);
	int r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	int n;
	cin >> n;
	ll r = 0;

	for (int i = 1; i <= n; i++)
		if (i % 5 > 0 && i % 3 > 0)
			r += i;
	printf("%lld", r);
	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n, m;
		cin >> n >> m;
		if ( !( n | m ) )
		{
			break;
		}

		int r;
		cin >> r;
		VVI used_by( n + 1, VI( 1260 + 1, 0 ) ); // used_by[ PC ][ 時刻 ] := 誰
		REP( i, 0, r )
		{
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			used_by[n][t] = m * ( s ? 1 : -1 );
		}
		REP( i, 0, used_by.size() )
		{
			REP( j, 0, used_by[i].size() - 1 )
			{
				used_by[i][ j + 1 ] += used_by[i][j];
			}
		}

		int q;
		cin >> q;
		REP( query_num, 0, q )
		{
			int s, e, m;
			cin >> s >> e >> m;

			int res = 0;
			REP( t, s, e )
			{
				bool used = false;
				REP( i, 0, used_by.size() )
				{
					used |= used_by[i][t] == m;
				}
				res += used;
			}

			cout << res << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 5824
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 3000;

double dp[N][N];
double v[N];

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

	int n; cin >> n;

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

	for (int i = n/2+1; i <= n; i++) dp[n][i] = 1.0;

	for (int i = n-1; i >= 0; i--) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = dp[i+1][j+1]*v[i] + dp[i+1][j]*(1.0-v[i]) - 0*dp[i+1][j+1]*v[i] * dp[i+1][j]*(1.0-v[i]);
		}
	}

	cout.precision(10);
	cout << fixed << dp[0][0] << endl;

	return 0;
}



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

int main(void){
    int n;
    cin >> n;
    
    int cnt[100][1024] = {{0}};
    int input;
    int pow2[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
    int i, j, k;
    for(i = 0; i < n; i++){
        for(j = 0; j < 10; j++){
            cin >> input;
            for(k = 1; k < 1024; k++){
                if(k & pow2[j]){
                    cnt[i][k] += input;
                }
            }
        }
    }
    
    int profit[1024] = {0};
    int p[11];
    for(i = 0; i < n; i++){
        for(j = 0; j <= 10; j++){
            cin >> p[j];
        }
        for(j = 1; j < 1024; j++){
            profit[j] += p[cnt[i][j]];
        }
    }
    
    sort(profit + 1, profit + 1024);
    
    cout << profit[1023] << endl;
    
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=3e3+50;
const ll mod=998244353;
using namespace std;
ll a,b,c,d,i,j,f[nmax][nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>c>>d;
	f[a][b]=1;
	for(i=a;i<=c;i++)
	{
		for(j=b;j<=d;j++)
		{
			if(i==a && j==b)continue;
			f[i][j]=f[i-1][j]*j%mod+f[i][j-1]*i%mod-f[i-1][j-1]*(i-1)%mod*(j-1)%mod+mod;
			f[i][j]%=mod;
		}
	}
	cout<<f[c][d]<<endl;
	return 0;
}


Measured memory_bytes: 75036
import sys

def main():
    N = int(input())
    H = int(input())
    W = int(input())

    count = 0
    for i in range(0, N):
        for j in range(0, N):
            if i + H <= N and j + W <= N:
                count += 1
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

double A, B, H, M;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B >> H >> M;

  double m = M / 60.0 * 2 * M_PI;
  double h = H / 12.0 * 2 * M_PI + M / 60.0 * 2 * M_PI / 12;
  double rad = m - h >= 0 ? m - h : h - m;

  double ans = sqrt(A * A + B * B - 2 * A * B * cos(rad));
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, N, M, X);
	vector<bool> A(N + 1, false);
	loop(i, M) {
		in(ll, a);
		A[a] = true;
	}
	ll ans1 = 0, ans2 = 0;
	loop(i, N)
		if (i < X)
			ans1 += A[i];
		else
			ans2 += A[i];
	out(min(ans1, ans2));
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H, W, K = ZZ()
    c = [list(input()) for _ in range(H)]
    ans = 0
    for h in range(2 ** H):
        for w in range(2 ** W):
            hs = set()
            ws = set()
            for i in range(H):
                if h & (1 << i): hs.add(i)
            for i in range(W):
                if w & (1 << i): ws.add(i)
            cc = 0
            for i in range(H):
                for j in range(W):
                    if i in hs: continue
                    if j in ws: continue
                    if c[i][j] == '#': cc += 1
            if cc == K: ans += 1
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
anslist = []

while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    ans = 0
    ave = sum(a) / n
    for i in range(n):
        if a[i] <= ave:
            ans += 1

    anslist.append(ans)

for i in anslist:
    print(i)


Measured memory_bytes: 6616
[n,m,xp,yp]=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

x.append(xp)
y.append(yp)

xma=max(x)
ymi=min(y)


if xma < ymi:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

typedef struct{

  char n[10];
  int t;

}P;
 
void enqueue(P);
P dequeue(void);

int min(int a,int b){
  if(a >= b)
    return b;
  else return a;
}

int head,tail,n;

P Q[100000];
 
int main(){
  int q, i, total = 0, c;
  P u;
 
  scanf("%d%d", &n, &q);

  for( i = 0; i < n; i++)
    scanf("%s%d", Q[i].n, &Q[i].t);
 
  head = 0;
  tail = n;
 
  while( head != tail){

    u = dequeue();
    c = min( q, u.t);
    u.t -= c;
    total += c;

    if( u.t > 0)
      enqueue( u);
    else
      printf("%s %d\n", u.n, total);

  }

  return 0;
}
 
void enqueue(P x){

  Q[tail] = x;

  if(tail == n)
    tail = 0;

  else
    tail++;

}
 
P dequeue(void){
  P x;
  x = Q[head];
 
  if(head == n)
    head = 0;

  else
    head++;
 
 return x;
}
 

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int n,k;
std::vector<ll> h;
int main(){
  cin >> n >> k;
  h.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(all(h),std::greater<ll>());
  ll ans=0;
  for (size_t i = k; i < n; i++) {
    ans+=h[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod=1e9+7;
ll inf=1e18;


int main(void){
	double n,m,d,one,ans=0;
	cin>>n>>m>>d;
	if(2*d<=n){
		one=2*d;
		ans=(one/(n*n)+(n-one)*2/(n*n))*(m-1);
	}else{//0がある
		one=(n-d)*2;
		ans=one/(n*n)*(m-1);
	}
	if(d==0)ans/=2;
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li x,y,a,b,c;

    cin>>x>>y>>a>>b>>c;

    li p[a],q[b];
    vi r(c);

    f(i,0,a-1)
        cin>>p[i];

    f(i,0,b-1)
        cin>>q[i]; 

    f(i,0,c-1)
        cin>>r[i]; 

    sort(p,p+a,greater<li>());
    sort(q,q+b,greater<li>());

    f(i,0,x-1)
    {
        r.PB(p[i]);
    }

    f(i,0,y-1)
    {
        r.PB(q[i]);
    }

    sort(r.B,r.E,greater<li>());

    li ans=0;

    f(i,0,x+y-1)
    {
        ans+=r[i];
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define ll long long
#define MOD 1000000007
using namespace std;

int count(vector<vector<char>> &grid, int i, int j,vector<vector<int>> &dp){
    if(i == grid.size()-1 && j == grid[i].size()-1){
        return 1;
    }

    if(i==grid.size()){
        return 0;
    }

    if(j == grid[i].size()){
        return 0;
    }
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    if(grid[i][j] == '.'){
        int path1 = count(grid, i + 1, j,dp)%MOD;
        int path2 = count(grid, i, j + 1,dp)%MOD;
        dp[i][j] = (path1 + path2)%MOD;
        return (path1 + path2)%MOD;
    }
    else
    {
        return 0;
    }
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> dp(n, vector<int>(m, -1));
    vector<vector<char>> grid(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            char val;
            cin >> val;
            grid[i].push_back(val);
        }
    }
    cout << count(grid,0,0,dp);
}
int main()
{
    IOS;
    // int t;
    // cin>>t;
    // while(t>0)
    // {
    solve();
    // t--;
    // }
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[2][N];
    rep(i, 2) {
        rep(j, N) {
            cin >> A[i][j];
        }
    }
    int counter = 0;
    int ans = 0;

    rep(j, N) {
        rep(k, j+1) {
            counter += A[0][k];
        }
        for(int k = j; k < N; k++) {
            counter += A[1][k];
        }
        if(ans < counter) {
            ans = counter;
        }
        counter = 0;
    }

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

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

int main() {
    string s;
    cin >> s;
    vector<int> P(2);
    for (auto &&i : P) {
        cin >> i;
    }
    vector<int> d = {0, 0};
    for (auto &&i : s) {
        if (i == 'T')
            d.emplace_back(0);
        else
            ++d.back();
    }
    auto ans = true;
    for (auto &&k : {0, 1}) {
        unordered_set<int> dp;
        dp.emplace(d[k]);
        for (int i = k + 2; i < d.size(); i += 2) {
            unordered_set<int> next;
            for (auto &&j : dp) {
                next.emplace(j + d[i]);
                next.emplace(j - d[i]);
            }
            dp = next;
        }
        ans &= dp.count(P[1 - k]);
    }
    cout<<(ans?"Yes":"No");
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <ctype.h>

int main(void) {
  int A, B, i;
  char S[20];
  
  scanf("%d %d %s", &A, &B, S);
  for(i = 0; S[i] != '\0'; i++) {
    if(i == A && S[i] != '-') {
      printf("No\n");
      return 0;
    }
    if(i != A && isdigit(S[i]) == 0) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  
  return 0;
}
  

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		
		Arrays.sort(h);
		
		long time = 0;
		for(int i=0;i<n-k;i++) {
			time+=h[i];
		}
		
		System.out.println(time);
	}
}

Measured memory_bytes: 89008
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

//a<=b
int calc(int a,int b){
  if(a>0) return 1;
  //a<=0
  if(b>=0) return 0;
  //a<=b<0
  return (b-a)%2==1?1:-1;
}

void run(void){
  int a,b;
  scanf("%d%d",&a,&b);
  int c=calc(a,b);
  printf("%s\n",c==0?"Zero":c==1?"Positive":"Negative");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    int tmp = 1;
    while (true) {
        if (pow(tmp, 2) > N) {
            cout << (tmp-1)*(tmp-1) << endl;
            break;
        }
        tmp++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
    

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

  bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  {

    if(a.s==b.s)
    {
      return a.f<b.f;
    }
    return a.s<b.s;
  }
  int32_t main()
  {         

      IOS


      vector<pair<int,int> >v;


      int n;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
        int x,y;
        cin>>x>>y;
        v.PB(MP(x,y));
      }

      sort(all(v),sortbysec);


      int time=0;
      bool ok=true;
      for(auto i:v)
      {
        if(time + i.f <=i.s)
        {
          time+=i.f;
        }
        else
        {
          cout<<"No";
          return 0;

        }
      }

      cout<<"Yes";


      return 0;
  }           

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}
ll fanc(ll k){
    if (k==0) return 1;
    return k*fanc(k-1)%1000000007;
}
int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll N,M;
	cin>>N>>M;
	ll n,m;//n=N!,m=M!
    n=fanc(N);
    m=fanc(M);
	if(N==M){
		cout<<(n*m*2)%1000000007<<endl;
	}
	else if(N==M+1){
	    cout<<n*m%1000000007<<endl;
	}
	else if(N+1==M){
	    cout<<n*m%1000000007<<endl;
	}
	else{
		cout<<0<<endl;
	}
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF INT_MAX
#define cases(t) ll t; cin>>t; while(t--)
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define msi map<string,int>

int main(){
	IOS
	ll n;
	cin>>n;
	string s[n];
	ll a=0,w=0,t=0,r=0;
	for(ll i = 0; i < n; ++i){
		cin>>s[i];
		if(s[i]=="AC")
			a++;
		if(s[i]=="WA")
			w++;
		if(s[i]=="TLE")
			t++;
		if(s[i]=="RE")
			r++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
		
return 0;
}

Measured memory_bytes: 6744
n,d = map(int,input().split())
x = []
for i in range(n):
    x.append(list(map(int,input().split())))
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        dis = 0
        for k in range(d):
            dis += (x[i][k] - x[j][k])**2
        dis **=(0.5)
        if dis == int(dis):
            ans += 1
print(ans)


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  double r;
  cin >> r;
  double p = 3.1415;
  double ans = r*p*2;
  printf("%.10lf\n", ans);
}

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

int main(){
	unsigned int N;
	unsigned int a,b,c;
	std::vector<bool> ans;

	std::cin >> N;

	for(int i = 0; i < N; i++){
		std::cin >> a >> b >> c;
		if(	(a*a + b*b == c*c) ||
			(a*a + c*c == b*b) ||
			(c*c + b*b == a*a)){
			ans.push_back(true);
		}else{
			ans.push_back(false);
		}
	}

	for(auto&& a : ans){
		if(a){
			std::cout << "YES" << std::endl;
		}else{
			std::cout << "NO" << std::endl;
		}
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    if(n <= m) cout << "unsafe" <<endl;
    else cout << "safe" <<endl;
}

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

using namespace std;

int main(void) {
    int n;

    cin >> n;

    bool f = false;

    if (n < 10)
        f = true;

    for (int i = 2; i < 10; ++i) {
        if (n % i == 0) {
            if (n / i < 10)
                f = true;
        }
    }

    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


}


Measured memory_bytes: 256
N = gets.to_i
L = gets.split.map(&:to_i).sort
dp1 = Array.new(L[-1] + 1, 0)
dp2 = Array.new(2 * L[-1] + 1, 0)

ans = L.inject(0) do |count, l|
  dp2.each_with_index do |n, ab|
    count += n if ab > l
  end
  dp1.each_with_index do |n, a|
    dp2[a + l] += n
  end
  dp1[l] += 1
  count
end
puts ans


Measured memory_bytes: 1912
#include "bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[110]={0};
	for(int i=0;i<n;i++)cin>>a[i];

	sort(a, a+n, greater<int>());
	int alice=0,bob=0;
	for(int i=0;i<n;i+=2)	alice += a[i];
	for(int i=1;i<n;i+=2) bob += a[i];

	int ans = alice - bob;
	
	cout<< ans <<endl;

	return 0;
}

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

void ra(string &s){
  char tmp=s[0];
  s[0]=s[1];
  s[1]=s[5];
  s[5]=s[3];
  s[3]=tmp;
}

void rb(string &s){
  char tmp=s[0];
  s[0]=s[4];
  s[4]=s[5];
  s[5]=s[2];
  s[2]=tmp;
}

void rc(string &s){
  char tmp=s[1];
  s[1]=s[2];
  s[2]=s[3];
  s[3]=s[4];
  s[4]=tmp;
}

bool eq(string &a,string &b){
  for(int i=0;i<6;i++){
    if(i&1)ra(a);
    else rb(a);
    for(int j=0;j<4;j++){
      rc(a);
      if(a==b)return true;
    }
  }
  return false;
}

struct state{
  int y,x,c;
  string die;
};

int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
string str;
string tmp="rmbgyc";
int H,W,si,sj;
char t[30][30];
map<string,int> d[30][30][7];

void solve(){
  queue< state > Q;
  Q.push((state){si,sj,0,tmp});
  while(!Q.empty()){
    state s=Q.front();Q.pop();
    int cost=d[s.y][s.x][s.c][s.die];
    
    if(s.c==6){cout<<cost<<endl;return;}
    
    for(int i=0;i<4;i++){
      int ny=s.y+dy[i],nx=s.x+dx[i];
      int nc=s.c;
      string ndie=s.die;
      if(ny<0||nx<0||H<=ny||W<=nx)continue;
      
      if(i==0)ra(ndie);
      if(i==1)rb(ndie);
      if(i==2)ra(ndie),ra(ndie),ra(ndie);
      if(i==3)rb(ndie),rb(ndie),rb(ndie);
      
      if(t[ny][nx]!='w'){
        if(t[ny][nx]!=ndie[0])continue;
        if(t[ny][nx]!=str[s.c])continue;
        nc++;
      }

      if(d[ny][nx][nc].count(ndie))continue;
      d[ny][nx][nc][ndie]=cost+1;
      Q.push((state){ny,nx,nc,ndie});
    }
  }
  cout<<"unreachable"<<endl;
}

void init(){
  for(int i=0;i<30;i++)
    for(int j=0;j<30;j++)
      for(int k=0;k<7;k++)
        d[i][j][k].clear();
}

int main(){
  while(1){
    init();
    cin>>W>>H;
    if(W==0&&H==0)break;
    
    
    for(int i=0;i<H;i++){
      cin>>str;
      for(int j=0;j<W;j++){
        t[i][j]=str[j];
        if(t[i][j]=='#'){
          t[i][j]='w';
          si=i,sj=j;
        }
      }
    }
    cin>>str;
    solve();
  }
}

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

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

	vector<int> P;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		P.push_back(p);
	}

	vector<int> sortP = P;
	sort(sortP.begin(), sortP.end());
	
	int swapCount = 0;
	for (int i = 0; i < N; i++) {
		if (P[i] != sortP[i]) {
			swapCount++;
		}
	}

	if (swapCount == 2 || swapCount == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}


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

int main(){
    long N,M,K;cin>>N>>M>>K;
    vector<long> A(N+1,0);
    vector<long> B(M+1,0);
    for(int i=1;i<=N;i++){
        long a;cin>>a;
        A[i]=A[i-1]+a;
    }
    for(int i=1;i<=M;i++){
        long b;cin>>b;
        B[i]=B[i-1]+b;
    }
    long jbest=M;
    while(B[jbest]>K)jbest--;
    long res=jbest;
    for(int i=1;i<=N;i++){
        if(A[i]>K)break;
        while(A[i]+B[jbest]>K)jbest--;
        res=max(res,i+jbest);
    }
    cout<<res<<endl;
}

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

using ll = long long;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll res = 0;
    res = b / x + 1;
    res -= (a == 0 ? 0 : (a-1) / x + 1);
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        char[] c = (" "+n()).toCharArray();
        long[][] ways = new long[n][1+n], sum = new long[n][1+n];
        ways[0][1] = 1;
        for(int i = 1; i<= n; i++)sum[0][i] = 1;
        for(int i = 1; i< n; i++){
            for(int j = 1; j<= i+1; j++){
                if(c[i]=='<')ways[i][j] = sum[i-1][j-1];
                else ways[i][j] = (sum[i-1][n]-sum[i-1][j-1]+mod)%mod;
            }
            for(int j = 1; j<= n; j++)sum[i][j] = (sum[i][j-1]+ways[i][j])%mod;
        }
        pn(sum[n-1][n]);
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

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

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> house(n);
  
  for (int i = 0; i < n; i++) {
    cin >> house.at(i);
  }
  int distance;
  int maxdistance = 0;
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      distance = k - house.at(i) + house.at(0);
    }
    else {
    distance = house.at(i + 1) - house.at(i);
    }
    maxdistance = max(maxdistance, distance);
  }
  cout << k - maxdistance << endl;
  return 0;
 }

Measured memory_bytes: 1024
def bublleSort(A):
    cnt = 0

    for i in range(1, len(A)):
        for j in range(1, len(A) - i + 1):
            if  A[j - 1] > A[j]:
                A[j], A[j - 1] = A[j - 1], A[j]
                cnt += 1

    return A, cnt


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

A_sorted, cnt = bublleSort(A)

print(*A_sorted)
print(cnt)



Measured memory_bytes: 5604
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main()
{      
  fastio();
  int n,m,i,j,t;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
  	cin>>a[i];
  }
  a[0]--;
  bool pos=1;
  for(i=1;i<n;i++){
  	if(a[i]>=a[i-1]){
  		if(a[i]-1>=a[i-1])
  			a[i]--;
  	}
  	else{
  		pos=0;
  		break;
  	}
  }
  if(pos)
  	cout<<"Yes";
  else
  	cout<<"No";
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[100005];
int q;
int b[100005],c[100005];
ll cnt[100005];
ll sum;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		cnt[a[i]]++;
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d%d",&b[i],&c[i]);
		sum-=(ll)b[i]*cnt[b[i]];
		sum+=(ll)c[i]*cnt[b[i]];
		cnt[c[i]]+=cnt[b[i]];
		cnt[b[i]]=0;
		printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 5772
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int K, X; cin >> K >> X;
    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 2e6+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second


int a[maxN];
int c[maxN];
int b[maxN];
int tot = 0;
int n;


int main() {
	
	int N;
	scanf("%d",&N);
	for(int x=1;x<=N;x++)
	{
		double y = x*1.08;
		if((int)y == N)
		{
			printf("%d\n",x);
			return 0;
		}
	}
	puts(":(");
	return 0;
}

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

int main()
{
        string S, T;
        cin >> S >> T;

        string s = T.substr(0, S.length());
        if (S == s) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }



}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main() {
    int N,M,C;
    cin >> N >> M >> C;

    int B[M];
    for (int i=0; i<M; i++) {
        cin >> B[i];
    }

    int A[N][M];
    for (int i=0; i<N; i++) {
        for (int j=0; j<M; j++) {
            cin >> A[i][j];
        }
    }

    int cnt=0;
    for (int i=0; i<N; i++) {
        int ans=0;
        for (int j=0; j<M; j++) {
            ans += A[i][j] * B[j];
        }
        if ((ans+C) > 0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        String sp = sc.nextLine();
        int[] p;
        if (sp.equals("")) {
            p = new int[0];
        } else {
            p = Arrays.stream(sp.split(" ")).mapToInt(Integer::parseInt).toArray();
        }

        int ans = 0;
        int index = 0;
        boolean canBreak = false;
        if (p.length == 0) ans = x;
        else {
            while (true) {
                for (int i = 0; i < p.length; i++) {
                    if (p[i] == x - index) {
                        break;
                    }
                    if (i == p.length - 1) {
                        ans = x - index;
                        canBreak = true;
                    }
                }
                if (canBreak) break;
                for (int i = 0; i < p.length; i++) {
                    if (p[i] == x + index) {
                        break;
                    }
                    if (i == p.length - 1) {
                        ans = x + index;
                        canBreak = true;
                    }
                }
                if (canBreak) break;
                index++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36264
#include <bits/stdc++.h>
using namespace std;
int n,a[600000],vis[600000],mx[600000],mx2[600000],ans,inq[600000];
queue<int> q;
void upd(int x,int y) {
    if (mx[x]!=mx[y] and mx2[x]!=mx[y]) {
        if (a[mx[y]]>a[mx[x]]) {swap(mx[x],mx2[x]); mx[x]=mx[y];}
        else if (a[mx[y]]>a[mx2[x]]) mx2[x]=mx[y];
    }
    if (mx[x]!=mx2[y] and mx2[x]!=mx2[y] and a[mx2[y]]>a[mx2[x]]) mx2[x]=mx2[y];
}
int main() {
    cin>>n;
    for (int i=0; i<(1<<n); i++) cin>>a[i];
    for (int i=0; i<(1<<n); i++) {mx[i]=i; mx2[i]=(1<<n);}
    q.push(0);
    while (!q.empty()) {
        int cur=q.front();
        q.pop();
        if (vis[cur]) continue;
        vis[cur]=1;
        for (int i=0; i<n; i++) {
            if ((cur&(1<<i)) or vis[cur|(1<<i)]) continue;
            int nex=cur|(1<<i);
            if (!inq[nex]) q.push(nex);
            inq[nex]=1; upd(nex,cur);
        }
    }
    for (int i=1; i<(1<<n); i++) {
        ans=max(ans,a[mx[i]]+a[mx2[i]]);
        cout<<ans<<'\n';
    }
}

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

typedef long long ll;
typedef long double ld;

int main(){
	bool prime[1000001];
	int i,t,x,y;
	long long int arr[1000001];
	memset(prime,true,1000001);
	for(i=0;i<1000001;i++)
		arr[i]=0;
	for(x=2;x*x<=1000001;x++)
	{
		if(prime[x]==true)
		{
			for(y=x*2;y<=1000001;y+=x)
				prime[y]=false;
		}
	prime[1]=false;
	}
	for(i=1;i<1000001;i++)
	{
		arr[i]+=arr[i-1];
		if(prime[i]==true && prime[(i+1)/2]==true)
			arr[i]++;
	}
	ll q,l,r;
	cin>>q;
	for(i=0;i<q;i++){
		cin>>l>>r;
		cout<<arr[r]-arr[l-1]<<endl;
	}
	return 0;
}

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

int main() {
  string odd, even;
  cin >> odd >> even;
  even.insert(0, " ");

  string ans;
  for (int i=0; i< odd.size() + even.size() - 1; i++) {
    if(i%2==0) {
      ans += odd[i/2];
    } else {
      ans += even[i/2+1];
    }
  }

  cout << ans << endl;

  return 0;
}


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

double calc(int n){
  return (n+1)/2.0;
}

int main(){
  int n, k;
  cin >> n >> k;
  int p[n];
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }
  double sum;
  for ( int i = 0; i < k; i++){
    sum += calc(p[i]);
  }
  double maxV = sum;
  for (int i = 1; i <= n-k; i++){
    sum = sum - calc(p[i-1]) + calc(p[i+k-1]);
    maxV = max(sum, maxV);
  }

  cout << fixed << setprecision(10) << maxV << endl;

  return 0;
}

Measured memory_bytes: 1024