akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];

    vector<P> ap(n), bp(n);
    for(int i=0; i<n; i++){
        ap[i] = P(a[i], i);
        bp[i] = P(b[i], i);
    }
    sort(ap.begin(), ap.end());
    sort(bp.begin(), bp.end());

    bool valid = true;
    for(int i=0; i<n; i++){
        if(ap[i].first > bp[i].first) valid = false;
    }

    vector<int> index(n);
    for(int i=0; i<n; i++){
        index[ap[i].second] = i;
    }

    vector<bool> used(n, false);
    int cycle_cnt = 0;
    for(int i=0; i<n; i++){
        int cur = i;
        bool cycle_in = false;
        while(!used[cur]){
            cycle_in = true;
            used[cur] = true;
            cur = bp[cur].second;
            cur = index[cur];
        }
        cycle_cnt += cycle_in;
    }

    if(cycle_cnt == 1){
        bool can_change = false;
        for(int i=0; i<n-1; i++){
            if(bp[i].first >= ap[i+1].first) can_change = true;
        }
        if(!can_change) valid = false;
    }

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

    return 0;
}

Measured memory_bytes: 3072
(N,),r,*L=$<.map{|l|l.split.map &:to_i};l=(n=*0..N).map{[1e9]*N*2};L.map{|a,b,c|l[a][b]=l[b][a]=c};n.map{|k|n.map{|i|n.map{|j|(l[i][j]>t=l[i][k]+l[k][j])&&l[i][j]=t}}};p r.permutation.map{|a|s=0;a.inject{|b,c|s+=l[b][c];c};s}.min

Measured memory_bytes: 71292
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        sc.close();
        int a = (H - h) * (W - w);
        System.out.println(a);
    }
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i,t) cin >> a[i];
  sort(a.rbegin(),a.rend());
  int rest = k - a[0];
  cout << max(a[0] - rest - 1,0) << endl;
  
  
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 500005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int n, k;
int p[maxn], q[maxn], w[maxn];
int d[maxn];
int lb(int a) {
	return a & -a;
} 
void ch(int pl) {
	while (pl < maxn)
		d[pl]++, pl += lb(pl);
}
int cal(int pl) {
	int ans = 0;
	while (pl) ans += d[pl], pl -= lb(pl);
	return ans;
}
int qq(int l, int r) {
	l = max(l, 1), r = min(r, maxn - 1);
	return cal(r) - cal(l - 1);
}
struct ST {
	int l, r;
	ST *ch[2];
	int mns, lz;
}stp[maxn << 1], *root;
int stcnt = 0;
void upd(ST *a) {
	a->mns = min(a->ch[0]->mns, a->ch[1]->mns);
}
void bdtree(ST *a, int l, int r) {
	a->l = l, a->r = r;
	if (l == r) {
		a->mns = w[l];
		return ;
	}
	int mid = (a->l + a->r) >> 1;
	a->ch[0] = &stp[stcnt++], 
	a->ch[1] = &stp[stcnt++];
	bdtree(a->ch[0], l, mid), 
	bdtree(a->ch[1], mid + 1, r);
	upd(a);
}
void actlz(ST *a, int lz) {
	a->mns += lz, a->lz += lz;
}
void pushdown(ST *a) {
	if (!a->lz) return ;
	actlz(a->ch[0], a->lz), 
	actlz(a->ch[1], a->lz);
	a->lz = 0;
}
void pushlz(ST *a, int l, int r, int lz) {
	if (a->l == l && a->r == r) {
		actlz(a, lz);
		return ;
	}
	int mid = (a->l + a->r) >> 1;
	pushdown(a);
	if (r <= mid) pushlz(a->ch[0], l, r, lz);
	else if (l > mid) pushlz(a->ch[1], l, r, lz);
	else pushlz(a->ch[0], l, mid, lz), 
		pushlz(a->ch[1], mid + 1, r, lz);
	upd(a);
} 
int qpl(ST *a) {
//	cout << a->mns << ' ' << a->l << ' ' << a->r << endl;
	if (a->l == a->r) return a->l;
	pushdown(a);
	if (a->ch[1]->mns <= 0) return qpl(a->ch[1]);
	else return qpl(a->ch[0]);
}
int ans[maxn];
int main() {
	cin >> n >> k;
	k--;
	for (int i = 1; i <= n; i++)
		scanf("%d", &p[i]), 
		q[p[i]] = i;
	for (int i = n; i >= 1; i--)
		w[q[i]] = qq(q[i] - k, q[i] + k), 
		ch(q[i]);
	root = &stp[stcnt++];
	bdtree(root, 1, n);
	for (int i = n; i >= 1; i--) {
		int nr = qpl(root);
		pushlz(root, nr, nr, 10 * maxn);
		pushlz(root, max(1, nr - k), min(n, nr + k), -1);
		ans[nr] = i;
	}
	for (int i = 1; i <= n; i++)
		printf("%d\n", ans[i]);
	return 0;
}


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

using namespace std;

#define int long long

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

signed main(void) {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; ++i) { cout << s[i] << t[i]; }
  cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Competitive
{
    internal class Solution
    {
        private int[,] A;
        private int N;
        
        public void Run()
        {
            N = 3;
            A = new int[N, N];
            for (int i = 0; i < N; i++)
            {
                int[] ary = Input.ReadIntArray();
                for (int j = 0; j < N; j++)
                    A[i, j] = ary[j];

            }

            Console.WriteLine(Solve() ? "Yes" : "No" );

        }

        private bool Solve()
        {
            
            for (int i = 1; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                    if (A[i, j] + A[0, 0] != A[0, j] + A[i, 0])
                        return false;
            }

            return true;

        }

    }

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
#include<queue>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
long N,P;
string S;
vector<tuple<string,long,long>>t;
inline void solve(void){
  in(N);
  rep(i,N){
    in(S,P);
    t.pb(mt(S,-P,i+1));
  }
  sort(all(t));
  for(auto e:t)out(get<2>(e));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#define _DEBUG
#ifdef _DEBUG
#define _GLIBCXX_DEBUG -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -fmax-errors=2
#endif

#pragma warn +xxx
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define ln "\n"
#define forn(i,e) for( i=0; i<e; i++)
#define forsn(i,s,e) for( i=s; i<e; i++)
#define rforn(i,e) for( i=e; i>=0; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<int>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln


#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};

ll exp(ll n, ll m, ll md){
        ll a = 1;
        while (m > 0){
                if (m&1) a = (a * n%md) % md;
                m /= 2;
                n = (n*n) % md;
        }
        return a % md;
}

void disp(vi v){
        for(auto u:v)
                cout<<u<<" ";
        cout<<"\n";
}

#define DEBUG
#ifdef DEBUG

#endif


void go1() {
        int n, k;
        cin >> n>>k;
        int i,j, a[n];
        forn(i,n) cin >> a[i];
        sort(a, a+n);
        ll ans = 0;
        forn(i,k)ans+=a[i];
cout << ans << ln;
}

int main(){
        fio;
        //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
        ll tt = 1;
/*

        cin >> tt;


        //*/
        while(tt--){
                go1();
        }

        return 0;
}

Measured memory_bytes: 3604
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())

n = len(S)//2
cnt = 0
for i in range(n):
    if S[i] == S[-(i+1)]:
        pass
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 6860
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    double t,x;
    cin>>t>>x;
    
    printf("%f\n",t/x);
    
return 0;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
k -= 1
mod = 1000000007
 
if w==1:
    print(1)
    exit()
 
dp = [[0 for _ in range(w)] for _ in range(h+1)]
dp[0][0] = 1
 
for hi in range(1,h+1):
    for b in range(2**(w-1)):
        judge = False
        for i in range(w-2):
            if (b>>i)&3 == 3:
                judge = True
                break
        if judge:
            continue
 
        perm = [i for i in range(w)]
        for i in range(w-1):
            if (b>>i)&1==1:
                perm[i],perm[i+1] = perm[i+1],perm[i]
        for i in range(w):
            dp[hi][perm[i]]  = (dp[hi][perm[i]]+dp[hi-1][i])%mod
 
print(dp[h][k])

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

using namespace std;

string::const_iterator it;

int number();
int factor();
int term();
int expression();

int number()
{
    int ret = 0;
    
    while(isdigit(*it)) {
        ret *= 10;
        ret += *it - '0';
        it++;
    }
    
    return ret;
}

int factor()
{
    int ret;

    if (*it == '(') {
        it++;
        ret = expression();
        it++;
    } else {
        return number();
    }
    
    return ret;
}

int term()
{
    int ret = factor();
    
    for (;;) {
        
        if (*it == '*') {
            it++;
            ret *= factor();
        } else if (*it == '/') {
            it++;
            ret /= factor();
        } else {
            break;
        }
    }
    
    return ret;
}

int expression()
{
    int ret = term();
    
    for (;;) {
        
        if (*it == '+') {
            it++;
            ret += term();
        } else if (*it == '-') {
            it++;
            ret -= term();
        } else {
            break;
        }
    }
    
    return ret;
}

int main()
{
    int data_num;

    cin >> data_num;
    cin.ignore();
    
    for (int i = 0; i < data_num; ++i) {
        string calc_formula;

        cin >> calc_formula;

        it = calc_formula.begin();

        cout << expression() << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
  int l,x=0,max=0;
  string s;
  cin >> l >> s;

  for(int i=0; i<l; ++i){
    if(s[i] == 'I'){
      x++;
    }else if(s[i] == 'D'){
      x--;
    } 

    if(x > max) max = x;
  }

  cout << max << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i):
        for k in range(j):
            ans += abs(l[i] - l[j]) < l[k] < abs(l[i] + l[j]) and len({l[i], l[j], l[k]}) == 3
print(ans)

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

using namespace std;

int main()
{
	int n,m;
	int i,j;
	char ch[100];
	string str;
	
	for(;;)
	{
		cin >> m >> n  ;
		if(n==0 && m==0)
			break;
		
		int ans[1024]={0};
		for(i=0;i<m;i++)
			ans[i]=i+1;
		
		j=0;
		for(i=1;i<=n;i++)
		{
			cin >> str ;
			
			sprintf(ch,"%d",i);
			int flag=0;
			for(int l=0;l<m;l++)
			{
				if(ans[l]!=0)
				flag++;
			}
			if(flag>1)
			{
				if(i%3==0 && i%5==0)
				{
					if(str!="FizzBuzz")
						ans[j]=0;
				}
				else if(i%3==0)
				{
					if(str!="Fizz")
						ans[j]=0;
				}
				else if(i%5==0)
				{
					if(str!="Buzz")
						ans[j]=0;
				}
				else
				{
					if(str!=ch)
						ans[j]=0;
				}
				j++;
				int c;
				for(c=j;ans[c]==0;)
				{
					c++;
					if(c>m-1)
						c=0;
				}
				j=c;
			}
		}
		int las;
		for(i=0;i<m;i++)
			if(ans[i]!=0)
				las=i;
		
		for(i=0;i<m;i++)
		{
			if(ans[i]!=0)
			{
				cout << ans[i] ;
				if(i<las)
					cout << " " ;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 960
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,C = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

T_MAX = 10**5
time = [[0]*C for i in range(T_MAX)]

for s,t,c in L:
    time[s-1][c-1] += 1
    time[t-1][c-1] -= 1
 
ans = 0
tmp = 0
for i in range(T_MAX):
    tmp += time[i].count(1)
    ans = max(ans,tmp)
    tmp -= time[i].count(-1)

print(ans)

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

using namespace std;
int N, s;
int a[2005];

int CautBin(int st, int dr) {
    int mid = (st + dr) / 2;
    if (st == dr)return st;
    if (a[mid + 1] >= s) return CautBin(st, mid);
    else return CautBin(mid + 1, dr);
}

int main() {
    int i, j , ct=0;
    cin >> N;
    for (i = 1; i <= N; i++)
        cin >> a[i];
    sort(a + 1, a + N + 1);
    for (i = 1; i <= N; i++)
        for (j = i + 1; j <= N; j++) {
            s = a[i] + a[j];
            ct+=CautBin(j, N)-j;
        }
    cout<<ct;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long sum = 0;
        for(int i = 1; i <= n; i++)
        {
            if(i % 3 == 0 || i % 5 == 0)
            {
                continue;
            }
            sum += i;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;

int main(){
    int k,x;
    cin >> k >> x;
    rep(i,k*2-2) cout << x-(k-1)+i << " ";
    cout << x+k-1 << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstddef>
#include <cstdio>
#include <limits>
#include <queue>

using namespace std;

int const kHeight = 800;
int const kWidth = 800;

int const kDRow[] = {-1, 1, 0, 0};
int const kDCol[] = {0, 0, -1, 1};

struct State {
  State() = default;
  State(int row, int col, int steps) : m_row(row), m_col(col), m_steps(steps) {}

  int m_row = 0;
  int m_col = 0;
  int m_steps = 0;
};

char g_maze[kHeight][kWidth + 1];
bool g_used[kHeight][kWidth];

int Evaluate(int h, int w, int k, int row, int col) {
  int const toLeft = (col + k - 1) / k;
  int const toRight = (w - col - 1 + k - 1) / k;
  int const toUp = (row + k - 1) / k;
  int const toDown = (h - row - 1 + k - 1) / k;
  return 1 + min(min(toLeft, toRight), min(toUp, toDown));
}

int main() {
  int h, w, k;

  scanf("%d%d%d", &h, &w, &k);
  for (int i = 0; i < h; ++i)
    scanf("%s", g_maze[i]);

  int srow = -1, scol = -1;
  for (int row = 0; row < h; ++row) {
    for (int col = 0; col < w; ++col) {
      if (g_maze[row][col] == 'S') {
        srow = row;
        scol = col;
        g_maze[row][col] = '.';
      }
    }
  }

  int best = numeric_limits<int>::max();

  queue<State> states;
  states.emplace(srow, scol, 0);
  g_used[srow][scol] = true;

  while (!states.empty()) {
    State const s = states.front();
    states.pop();

    assert(g_maze[s.m_row][s.m_col] == '.');

    best = min(best, Evaluate(h, w, k, s.m_row, s.m_col));
    if (s.m_steps == k)
      continue;
    for (int k = 0; k < 4; ++k) {
      int const row = s.m_row + kDRow[k];
      int const col = s.m_col + kDCol[k];
      if (row < 0 || row >= h || col < 0 || col >= w)
        continue;
      if (g_maze[row][col] == '.' && !g_used[row][col]) {
        g_used[row][col] = true;
        states.emplace(row, col, s.m_steps + 1);
      }
    }
  }

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


Measured memory_bytes: 1536
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {
      h1:isize,m1:isize,h2:isize,m2:isize,k:isize
   }
   let buf = (h2 - h1) * 60 + m2 - m1 - k;
   println!("{}", buf);
}


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

const int MOD = 1000000007;
const int INF = 1001001001;

int main(){
    string s;
    ll k;
    cin>>s>>k;
    
    if(k<=s.size()){
        int nmin = 1;
        for(int i=0; i<k; i++){
            nmin = max(nmin, s[i]-'0');
        }
        if(nmin==1){
            cout<<1<<endl;
            return 0;
        }
    }
    
    for(int i=0; i<s.size(); i++){
        if(s[i]!='1'){
            cout << s[i] << endl;
            break;
        }
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int n,m;
	cin >> n >> m;
	bool s[200005] = {},e[200005] = {};

	rep(i,0,m){
        int a,b;
        cin >> a >> b;
        if(a == 1){
            s[b] = true;
        }else if(b == n){
            e[a] = true;
        }
	}
	
	rep(i,1,n+1){
        if(s[i] == true && e[i] == true){
            P("POSSIBLE");
            ret 0;
        }
	}

	P("IMPOSSIBLE");

	return  0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> cnt(26, 1e9);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		vector<int> v(26);
		for (char c : s) {
			v[c - 'a']++;
		}
		for (int i = 0; i < 26; i++) {
			cnt[i] = min(cnt[i], v[i]);
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << string(cnt[i], i + 'a');
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll a[100005];
ll psum1[100005], psum2[100005];
int main() {
  IOS;
  ll sum = 0, ans1 = 0, ans2 = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    psum1[i] = psum1[i - 1] + a[i];
    psum2[i] = psum2[i - 1] + a[i];
    if (i % 2 == 1 && psum1[i] <= 0)
      ans1 += 1 - psum1[i], psum1[i] = 1;
    else if (i % 2 == 0 && psum1[i] >= 0)
      ans1 += psum1[i] + 1, psum1[i] = -1;
    if (i % 2 == 0 && psum2[i] <= 0)
      ans2 += 1 - psum2[i], psum2[i] = 1;
    else if (i % 2 == 1 && psum2[i] >= 0)
      ans2 += psum2[i] + 1, psum2[i] = -1;
  }
  cout << min(ans1, ans2) << endl;
}

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

int main()
{
        ll N; cin >> N;
        vector<ll> s(N, 0);
        ll sum = 0;
        rep(i,N) {
                cin >> s[i];
                sum += s[i];
        }
        sort(s.begin(), s.end());
        bool ok = false;
        rep(i, N) {
                if (sum % 10) {
                        ok = true;
                        break;
                }
                else {
                        if (s[i] % 10) {
                                sum -= s[i];
                        }
                }
        }
        if (ok)
        cout << sum << endl;
        else
        cout << 0 << endl;





}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int xa = min(a, k);
  k -= xa;
  int xb = min(b, k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        int A = 0;
        int B = 0;
        for(int a = 0; a < 1001; a++){
        	for(int b = -1000; b < 1001; b++){
        		if(N == Math.pow(a, 5) - Math.pow(b, 5)){
        			A = a;
        			B = b;
        			break;
        		}
        	}
        }
        System.out.printf("%d %d", A, B);
    }
}

Measured memory_bytes: 35876
#include <iostream>
#include <memory.h>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll A, B;
ll D[80][2][2];
bool bit_set(ll n, int k) {
  return n & (1LL << k);
}

ll solve(int n, int less, int greater) {
  if (n == -1) {
    return 1;
  }
  if (D[n][less][greater] != -1) {
    return D[n][less][greater];
  }
  ll res = 0;
  if (less) {
    if (greater) {
      res = (3 * solve(n - 1, 1, 1)) % MOD;
    } else {
      if (bit_set(A, n)) {
        res = solve(n - 1, 1, 0);
      } else {
        res = (solve(n - 1, 1, 1) + 2 * solve(n - 1, 1, 0)) % MOD;
      }
    }
  } else {
    if (greater) {
      if (bit_set(B, n)) {
        res = (solve(n - 1, 1, 1) + 2 * solve(n - 1, 0, 1)) % MOD;
      } else {
        res = solve(n - 1, 0, 1);
      }
    } else {
      if (bit_set(B, n)) {
        if (bit_set(A, n)) {
          res = solve(n - 1, 0, 0);
        } else {
          res = (solve(n - 1, 1, 0) + solve(n - 1, 0, 0) + solve(n - 1, 0, 1)) % MOD;
        }
      } else {
        if (!bit_set(A, n)) {
          res = solve(n - 1, 0, 0);
        }
      }
    }
  }
  return D[n][less][greater] = res;
}

int main() {
  scanf("%lld %lld", &A, &B);
  memset(D, -1, sizeof(D));
  ll res = 0;
  for (int i = 61; i >= 0; i--) {
    ll maxVal = (1LL << (i + 1)) - 1;
    ll minVal = (1LL << i);
    if (minVal <= B && maxVal >= A) {
      if (maxVal < B && minVal > A) {
        res += solve(i - 1, 1, 1);
      } else if (minVal > A) {
        res += solve(i - 1, 0, 1);
      } else if (maxVal < B) {
        res += solve(i - 1, 1, 0);
      } else {
        res += solve(i - 1, 0, 0);
      }
      res %= MOD;
    }
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str;
      	int[] a = new int[5];
        for(int i=0;i<5;i++){
          a[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        boolean flg = true;
        for(int i=0;i<4;i++){
          for(int j=i+1;j<5;j++){
            if(a[j]-a[i] > k){
              flg=false;
              break;
            }
          }
          if(!flg)break;
        }
        if(flg){
          System.out.println("Yay!");
        }else{
          System.out.println(":(");
        }
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int>> PP;

int n;
int a[100010],b[100010];


 
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
 
const ll MOD = 1000000007;
const ll INF = 1000000000;
 
int main(void){
    
    int n;
    vector<int> v;
    ll ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        v.push_back(a+b);
        ans -= b;
    }

    sort(v.begin(),v.end(),greater<int>());

    for(int i=0;i<n;i+=2){
        ans += v[i];
    }
    cout << ans << endl;
    
}

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


using namespace std;
using ll = long long;

const int N = 2e5 + 5;

vector < int > adj[N];
ll ans[N];
int n , q;

void dfs(int u , int p){
    ans[u] += ans[p];

    for(int v : adj[u])if(v != p)dfs(v , u);
}

main(){
    scanf("%d %d" , &n , &q);

    for(int i = 1 ; i < n ; i ++){
        int u , v;
        scanf("%d %d" , &u , &v);

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    while( q -- ){
        int u , x;
        scanf("%d %d" , &u , &x);

        ans[u] += x;
    }

    dfs(1 , 0);

    for(int i = 1 ; i <= n ; i ++){
        printf("%lld%c" , ans[i] , i == n ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 24320
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
const int MaxN = 1e5;
using namespace std;

ll n, m, a, b;
int main()
{
	cin >> a >> b;
	m = max(a, b);
	n = min(a, b);

	if(n > 2 && m > 2)
	{
		cout << (n-2) * (m-2) << endl;
	}
	else if(n > 2 && m  == 2)
	{
		cout << 0 << endl;
	}
	else if(n > 2 && m == 1)
	{
		cout << m - 2 << endl;
	}
	else if(n == 2)
	{
		cout << 0 << endl;
	}
	else if(n == 1 && m >= 2)
	{
		cout << m - 2 << endl;
	}
	else if(n == 1 && m == 1)
	{
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e6+5;
long long dp[maxn][2];
char str[maxn];
int main(){
    scanf("%s",str+1);
    int len=strlen(str+1);
    str[0]='0';
    dp[len][0]=str[len]-'0';
    dp[len][1]=10-(str[len]-'0');
    for(int i=len-1;i>=0;i--){
        dp[i][0]=min(dp[i+1][0]+str[i]-'0',dp[i+1][1]+str[i]-'0'+1);
        dp[i][1]=min(dp[i+1][0]+10-(str[i]-'0'),dp[i+1][1]+10-(str[i]-'0'+1));
    }
    printf("%lld\n",min(dp[0][0],dp[0][1]));
    return 0;
}

Measured memory_bytes: 16896
n = int(input())
a = list(map(int, input().split()))

total_length = 0
for i in range(n):
    total_length += a[i]

dis = 10000000000000000000000000000000000000000
sum_length = 0
for i in range(n):
    sum_length += a[i]
    if abs(total_length/2 - sum_length) < dis:
        dis = abs(total_length/2 - sum_length)
    else:
        sum_length -= a[i]
        break
print(abs(total_length - 2 * sum_length))

Measured memory_bytes: 26060
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::{max, min, Ordering};
use std::collections;
use std::io::{stdin, BufRead};
use std::fmt;

macro_rules! get
{
  ($rd:ident; V; $t:ty) => {
    scanl($rd, b'\n')
      .split_whitespace()
      .map(|w| get_inner!{w; $t})
      .collect::<Vec<_>>()
  };
  ($rd:ident; T; $($t:ty),+) => {
    {
      let s = scanl($rd, b'\n');
      let mut i = s.split_whitespace();
      ( $( get_inner!{i.next().unwrap(); $t}),+ )
    }
  };
  ($rd:ident; $t:ty) => (get_inner!{scanl($rd, b'\n'); $t});
}

macro_rules! get_inner
{
  ($src:expr; $t:ty) => {
    $src.parse::<$t>().expect("Parse Error")
  };
}

macro_rules! gets
{
  ($rd:ident; $n:expr; $($tok:tt)*) => {
    (0..)
      .take($n)
      .map(|_| get!{$rd; $($tok)*})
      .collect::<Vec<_>>()
  };
}

fn solve(rd: &mut BufRead)
{
  let (a, b, k) = get!(rd; T; i64, i64, i64);
  if k > a {
    println!("{} {}", 0, max(0, b-k+a));
  } else {
    println!("{} {}", a-k, b);
  }
}

fn scanl(rd: &mut BufRead, delim: u8) -> String
{
  let mut buf = Vec::new();
  let _ = rd.read_until(delim, &mut buf).expect("Read Failed");
  String::from_utf8(buf)
    .expect("Invalid UTF-8 String")
    .trim_right()
    .to_string()
}

fn main()
{
  let rd = stdin();
  let mut rd = rd.lock(); // std::io::StdinLock
  solve(&mut rd);
}


Measured memory_bytes: 4352
MOD = 10**9+7

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

min_list = [sum([i for i in range(K)])]
for i in range(K, N+1):
    min_list.append((min_list[-1]+i) % MOD)

max_list = [sum([N-i for i in range(K)])]
for i in range(K, N+1):
    max_list.append((max_list[-1]+N-i) % MOD)


count = 0
for i in range(len(min_list)):
    count = (count+(max_list[i]-min_list[i]+1)) % MOD

print((count) % MOD)

Measured memory_bytes: 24784
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>

using namespace std;

long long N,T,a,b,c,big;
long long sc;
long long result[101] = {};

typedef pair<long long, long long> pl;
vector<pl> re;
vector<pl> bl;
pl buf;

long long Answer[200] = {};


int main() {

	cin >>N;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		result[i] = 0;
		if (a*b > 2) {
			sc = a*b - 1;
			big = max(a, b);
			c = sqrtl(sc);
			result[i] = c * 2-1;
			if (c < min(a, b)) {
				result[i]++;
			}
			if (c*(c + 1) > sc) {
				result[i]--;
			}
			
		}
		

	}

	
	for (int i = 0; i < N; i++) {
		cout << result[i] << endl;
	}

	/*for (int i = 0; i < T; i++) {
		if (Answer[i] == -1) {
			cout << "Case #" << i + 1 << ": OK" << endl;
		}
		else {
			cout << "Case #" << i + 1 << ": " << Answer[i] << endl;
		}

	}*/
	



	//cout << result << endl;

return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    int h,k,w;
    cin>>h>>w>>k;
    vector<vector <int> > c(h,vector<int> (4));
    rep(i,h)
    {
        rep(j,w)
        {
            char s;
            cin>>s;
            if(s=='#') c[i][j]=1;
            else c[i][j]=0;
        }
    }

    int ans =0;

    int n = h+w;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) 
    {
        int sum=0;
        
        vector<int> S;
        S.push_back(-1);
        for (int i = 0; i < n; ++i) 
        {
            if (bit & (1<<i)) 
            { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        sort(S.begin(),S.end());

        for (int hc = 0;hc<h;hc++)
        {
            for (int wc = 0;wc<w;wc++)
            {
                if(find(S.begin(),S.end(),hc) == S.end())
                {
                    if(find(S.begin(),S.end(),wc+h)==S.end())
                    {
                        if(c[hc][wc]==1) sum++;
                    }

                }
            }
        }
        if(sum==k) ans ++;
    }



    cout<<ans<<endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  int i;
  string s;
  cin>>s;
  if(s=="ABC")
  cout<<"ARC"<<endl;
  else
  {
    cout<<"ABC"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
#define gcd __gcd
using namespace std;

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c) {
    cout<<b+c<<endl;
  }
  else {
    cout<<a+2*b+1<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//template
#define int long long
int H,W,ans=1e9,K=2;
void f(int a,int b){
  int c=H*W-a-b;
  ans=min(ans,max({a,b,c})-min({a,b,c}));
}
//main
signed main(){
  cin>>H>>W;
  while(K--){
    f((H+1)/3*W,(H+1)/3*W);
    for(int j=1;j<W;j++)f(j*H,H/2*(W-j));
    swap(H,W);
  }
  cout<<ans<<endl;
}


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

int main(){
  double q,x;
  while(cin>>q){
    if (q==-1)break;
    x = q/2;
    while(abs(x*x*x-q)>=0.00001*q){
      x = x-(x*x*x-q)/(3*x*x);
    }
    printf("%.6f\n",x);
  }
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

int a[N],b[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    while(k--)
    {
        bool ok=true;
        for(int i=1;i<=n;i++)
            if(a[i]!=n)
                ok=false;
        if(ok)
            break;
        for(int i=1;i<=n;i++)
            b[i]=0;
        for(int i=1;i<=n;i++)
        {
            int l=max(1ll,i-a[i]);
            int r=min(n,i+a[i]);
            b[l]++,b[r+1]--;
//            cout<<l<<" .. "<<r<<"\n";
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+b[i];
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
}


Measured memory_bytes: 6780
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int res = 0;
        String[] inputs = scanner.nextLine().split("\\s+");
        String[] friends = scanner.nextLine().split("\\s+");
        int N = Integer.parseInt(inputs[0]), K = Integer.parseInt(inputs[1]);
        for (String f : friends) {
            if (Integer.parseInt(f) >= K) res++;
        }
        System.out.println(res);

    }
}


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

typedef struct {
  char suit;
  char value;
  int ID;
}Card;

int main(){
  Card C1[37], C2[37],temp;
  int N,i,j,mini,flag;
  char ch,tempc,tempc2;

  scanf("%d%c", &N,&ch);
  if(N<1||N>36){
    printf("N ha 1-36 death!\n");
    exit(1);
  }

  for (i=0;i<N;i++){
    scanf("%c%c%c",&C1[i].suit,&C1[i].value,&ch);
    C1[i].ID=i;
    C2[i]=C1[i];
  }

  //Bubble
  for (i=0;i<N-1;i++){
    for (j=N-1;j>=i+1;j--){
      if(C2[j].value < C2[j-1].value){
        temp=C2[j];
        C2[j]=C2[j-1];
        C2[j-1]=temp;
      }
    }
  }

  for (i=0;i<N;i++){
    printf("%c%c",C2[i].suit,C2[i].value);
    if(i<N-1){
      printf(" ");
    }
  }
  printf("\n");

  flag=0;	
  for (i=0;i<N;i++){
    for (j=i+1;j<=N;j++){
      if (C2[i].value==C2[j].value){
        if(C2[i].ID>C2[j].ID){
          printf("Not stable\n");
          flag=1;
        }
      }
    }
  }
  if(flag==0){
    printf("Stable\n");
  }

  for (i=0;i<N;i++){
    C2[i]=C1[i];
  }

  //SelectionSort
  for (i=0;i<=N-1;i++){
    flag=0;
    mini=i;
    for (j=i;j<=N-1;j++){
      if (C2[j].value < C2[mini].value){
        mini = j;
        flag=1;
      }
    }
    if(flag==1){
      temp=C2[i];
      C2[i]=C2[mini];
      C2[mini]=temp;
    }
  }
  for (i=0;i<N;i++){
    printf("%c%c",C2[i].suit,C2[i].value);
    if(i<N-1){
      printf(" ");
    }
  }
  printf("\n");

  for (i=0;i<N;i++){
    for (j=i+1;j<=N;j++){
      if (C2[i].value==C2[j].value){
        if(C2[i].ID>C2[j].ID){
          printf("Not stable\n");
          return 0;
        }
      }
    }
  }

  printf("Stable\n");

  return 0;
}

Measured memory_bytes: 612
import math

N, M = map(int, input().split())
P = [tuple(map(int, input().split())) for i in range(N)]

ans = 0

for i in range(N):
    d = math.sqrt(P[i][0]**2 + P[i][1]**2)
    if d <= M:
        ans += 1

print(ans)


Measured memory_bytes: 36000
#include<bits/stdc++.h>
typedef long long ll;
const int N = 2e5+1;
using namespace std;
int n;
struct ft{
    ll a[N];
    ll qry(int r){
        ll ret = 0;
        for(;r>=0;r=(r&(r+1))-1)ret=max(ret,a[r]);
        return ret;
    }
    void upd(int i,long long v){
        for(;i<=n;i=(i|(i+1)))a[i]=max(a[i],v);
    }
}f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    vector<int> h(n),a(n);
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n;i++)cin>>a[i];
    //This is a O(nlogn) solution using a fenwick tree
    for(int i=0;i<n;i++){
        ll prefix_max = f.qry(h[i]-1);
        f.upd(h[i],prefix_max+a[i]);
    }
    ll ans=f.qry(n);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N;
cin >> N;
vi p(N);
rep(i,N) {
    cin >> p[i];
    p[i]--;
}

int cur = 0;
int ans = 0;
rep(i,N+1) {
    if(i == N) {
        ans += (cur+1)/2;
        break;
    }
    if(p[i] != i ) {
        ans += (cur+1)/2;
        cur = 0;
    }
    else cur++;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_064
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string s = Read();
            int requireLeft = 0;
            int requireRight = 0;
            for(int i = 0; i < n; i++)
            {
                if (s[i] == ')')
                {
                    if (requireRight > 0)
                    {
                        requireRight--;
                    }
                    else
                    {
                        requireLeft++;
                    }
                }
                else
                {
                    requireRight++;
                }
            }

            string res = "";
            for(int i = 0; i < requireLeft; i++)
            {
                res += "(";
            }
            res += s;
            for(int i = 0; i < requireRight; i++)
            {
                res += ")";
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  vector<int64_t> SUM(N);
  SUM[0] = A[0];
  for (int i = 1; i < N; ++i) {
    SUM[i] = SUM[i - 1] + A[i];
  }

  int64_t answer = 1;
  for (int i = N - 2; i >= 0; --i) {
    if (2 * SUM[i] < A[i + 1]) break;
    ++answer;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
int main() {
  long a, b, c, d;
  long long ans;

  std::cin >> a >> b >> c >> d;
  ans = std::max(a * c, a * d);
  ans = std::max(ans, (long long)b * c);
  ans = std::max(ans, (long long)b * d);

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

  return 0;
}


Measured memory_bytes: 3636
#F
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left, bisect_right
N = int(input())
a = list(map(int, input().split()))
lists=[[] for i in range(N)]
for i in range(N-1):
    u, v = map(int, input().split())
    lists[u-1].append(v-1)
    lists[v-1].append(u-1)

def search(v,LIS):
    if len(lists[v])==0:
        return
    for u in lists[v]:
        if check[u] == False:
            check[u] = True
            if a[u] > LIS[-1]:
                LIS.append(a[u])
                ans[u] = len(LIS)
                search(u,LIS)
                LIS.pop()
            else:
                ind = bisect_left(LIS,a[u])
                stack = LIS[ind]
                LIS[ind]=a[u]
                ans[u] = len(LIS)
                search(u,LIS)
                LIS[ind]=stack
    return

ans = [0]*N
check = [False]*N
check[0]=True
LIS = [a[0]]
ans[0]=1
search(0,LIS)
print(*ans, sep="\n")

Measured memory_bytes: 224484
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int K,S;
	cin >> K >> S;
	int count=0;
	for(int i=0; i<=K; i++){
		for(int j=0; j<=K; j++){
				if(i+j+K>=S && i+j<=S)count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(K, X):
    ans = []
    for i in range(X-K+1, X+K):
        ans.append(i)
    return ' '.join(map(str, ans))


def main():
    K, X = read_int_n()
    print(slv(K, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6476