akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using LL = long long;

constexpr int MAXN = 55;

struct Node {
    Node() = default;
    Node(LL _c, string& _l, string& _r) : c(_c), l(_l), r(_r) {}
    LL c;
    string l, r;
    friend inline bool operator<(const Node& lhs, const Node& rhs) {
        return lhs.c > rhs.c;
    }
};
LL n, cost[MAXN];
string s[MAXN], emps("");

inline bool isPalindrome(const string& tmp) {
    for (int i = 0; i < tmp.size() /2 + 1; i++)
        if (tmp[i] != tmp[tmp.size() - 1 - i]) return false;
    return true;
}
/*@return l, r第一个不同的位置*/
inline int check(string& l, string& r) {
    int i = 0;
    for (; i < min(l.size(), r.size()); i++)
        if (l[i] != r[r.size() - 1 - i]) break;
    l = l.substr(i), r = r.substr(0, r.size() - i);
    return i;
}

priority_queue<Node, vector<Node>> q;
map<string, map<string, bool>> vis;
inline void search() {
    while (!q.empty()) {
        auto cur = q.top();
        q.pop();
        if (vis[cur.l][cur.r]) continue;
        if (isPalindrome(cur.l) && cur.r.empty()) {
            cout << cur.c << endl;
            return;
        } else if (isPalindrome(cur.r) && cur.l.empty()) {
            cout << cur.c << endl;
            return;
        } else if (cur.l.empty() && cur.r.empty()) {
            cout << cur.c << endl;
            return;
        } else {
            for (int i = 1; i <= n; i++) {
                Node tmp(cur.c, cur.l, cur.r);
                if (tmp.l.size() >= tmp.r.size()) {
                    tmp.r = s[i] + tmp.r, tmp.c += cost[i];
                    int id = check(tmp.l, tmp.r);
                    if (id && (tmp.l.empty() || tmp.r.empty())) q.push(tmp);
                } else {
                    tmp.l = tmp.l + s[i], tmp.c += cost[i];
                    int id = check(tmp.l, tmp.r);
                    if (id && (tmp.l.empty() || tmp.r.empty())) q.push(tmp);
                }
            }
        }
        vis[cur.l][cur.r] = true;
    }
    cout << -1 << endl;
}

int main () {
   // freopen("test.in", "r", stdin);
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s[i] >> cost[i];
        q.push(Node(cost[i], s[i], emps));
        q.push(Node(cost[i], emps, s[i]));
    }
    search();
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int sx, sy, tx, ty, i, j, k, x, y;
	cin >> sx >> sy >> tx >> ty;
	x = tx - sx; y = ty - sy;

	for (i = 0; i < y; i++) cout << "U";
	for (i = 0; i < x; i++) cout << "R";
	
	for (i = 0; i < y; i++) cout << "D";
	for (i = 0; i < x; i++) cout << "L";

	cout << "L";
	for (i = 0; i < y + 1; i++) cout << "U";
	for (i = 0; i < x + 1; i++) cout << "R";
	cout << "D";

	cout << "R";
	for (i = 0; i < y + 1; i++) cout << "D";
	for (i = 0; i < x + 1; i++) cout << "L";
	cout << "U";


	return 0;
}



Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    int N,K;
    cin>>N>>K;
    
    if((N+1)/2>=K) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main(void){
    // Your code here!
    
    double pi = 3.141592653589793238;
    
    long long a, b, h, m;
    cin >> a >> b >> h >> m;
    
    
    m = 60.0*h + m;
    
    double distance;
    
    //短針は７２０分で2pi
    //長針は60分で2pi
    
    
    distance = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0*a*b*cos((2.0/60 - 2.0/720) * m * pi) );
    
    
    //cout <<  distance << endl; //4.56426
    
    cout<<setprecision(21)<<fixed;//めっちゃびっくり!!!!!!!!!!!
    cout << distance << endl;; //4.564257194330076039535
 
    return 0;

}


Measured memory_bytes: 4168
K=io.read"*n"

a={{}}
for i=1,9 do table.insert(a[1],{i}) end
function lunlun()
	local d=1
	while true do
		a[d+1]={}
		for i=1,#a[d] do
			local l=a[d][i][#a[d][i]]
			for k=math.max(0,l-1),math.min(9,l+1)do
				local b={}
				for j=1,d do
					table.insert(b,a[d][i][j])
				end
				table.insert(b,k)
				table.insert(a[d+1],b)
				coroutine.yield(b)
			end
		end
		d=d+1
	end
end

if(K<10)then print(K) return end

co=coroutine.create(lunlun)
for i=10,K do
	_,b=coroutine.resume(co)
end
print(table.concat(b))

Measured memory_bytes: 17788
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();;
		for(int i=0; i<N; i++) B[i] = sc.nextInt();
		for(int i=0; i<N; i++) C[i] = sc.nextInt();
		Arrays.sort(A); Arrays.sort(C);
		long ans = 0;
		for(int i=0; i<N; i++) {
			ans += (nibutan(A, B[i]))*(N-nibutan(C, B[i]+1));
		}
		System.out.println(ans);
	}
	
	static long nibutan(int[] A, int b) {
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 94876
from math import sqrt

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]


count = 0
for n1 in range(N - 1):
    for n2 in range(n1 + 1, N):
        summary = 0
        for d in range(D):
            summary += (X[n1][d] - X[n2][d]) ** 2
        if sqrt(summary).is_integer():
            count += 1
print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  string s;
  cin >> n >> s;

  vec a(n+1);
  for(ll i=0;i<n;i++){
    a[i+1]=a[i];
    if(s[i]=='W')a[i+1]++;
  }

  ll ans=inf;
  ans=min(ans,n-1-a[n]+a[1]);
  //cout << ans << " " <<  0 << endl;
  for(ll i=1;i<n-1;i++){
    ans=min(ans,a[i]+(n-i-1)-(a[n]-a[i+1]));
    //cout << ans << " " << i << " " << a[i]+(n-i-1)-(a[n]-a[i+1]) << endl;
  }
  ans=min(ans,a[n-1]);
  //cout << ans << " " << n-1 << endl;

  cout << ans << endl;


}

Measured memory_bytes: 6120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INFI 987654321
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false);
    list<int> lst;
    int N, dir = 1;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        int here;
        cin >> here;
        if(dir == 1)
            lst.push_back(here);
        else
            lst.push_front(here);
        dir = -dir;
    }
    if(dir > 0) {
        for(auto iter = lst.begin(); iter != lst.end(); ++iter)
            printf("%d ", *iter);
    }
    else {
        for(auto iter = lst.rbegin(); iter != lst.rend(); ++iter)
            printf("%d ", *iter);
    }
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int N,D; cin >> N >> D;
    cout << (N+D*2) / (D*2+1) << endl;
    return 0;
}

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

signed main(){
  int n;
  cin >> n;
  int s[n];
  for(int i=0;i<n;i++) cin >> s[i];
  int ans=0;
  for(int i=1;i<n;i++){
    int l=i,r=n-1-i;
    int dp[n/i];
    dp[0]=0;
    int j=1;
    while(r>0&&l!=r&&l!=r+i&&r>i){
      dp[j]=dp[j-1]+s[l]+s[r];
      ans=max(ans,dp[j]);
      //cout << dp[j] << " ";
      j++;
      l+=i;
      r-=i;
    }
    //cout << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, w;
    cin >> s >> w;
    if(s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

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

struct unionfind{
	vector<int> data;
	
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		data[x]=y;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
};


int main(){
	int N,M;
	cin>>N>>M;
	unionfind uf(M);
	vector<vector<int>> lang(N);
	
	for(int i=0;i<N;i++){
		int K;
		cin>>K;
		for(int j=0;j<K;j++){
			int x;
			cin>>x;
			x--;
			lang[i].push_back(x);
			if(j!=0)uf.unite(x,lang[i][j-1]);
		}
	}
	
	bool flag = true;
	for(int i=1;i<N;i++){
		if(uf.check(lang[0][0],lang[i][0])==false){
			flag=false;
			break;
		}
	}
	
	if(flag)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin  >> a.at(i);
    for(int i=0;i<n-k;i++){
        if(a.at(i)<a.at(i+k)) cout << "Yes" << endl;
        else cout << "No" << endl;       
    }
}
   


Measured memory_bytes: 4788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int w; cin >> w;
    for (int i = 0; i < s.size(); i += w) cout << s[i];
    cout << "\n";
    /***************************************************/
    /* Use "submit code (with ACL v1)" when using ACL! */
    /***************************************************/
    return 0;
}

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

typedef unsigned long long ull;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const ull mod = 1e9 + 7;

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

	int N,K,d,A,count;	cin>>N>>K;
	bool s[N+1];
  FOR(i,1,N+1)	s[i]=0;
	
	while(K--){
		cin>>d;
		while(d--){
			cin>>A;
			s[A]=1;
		}
	}
	
	FOR(i,1,N+1){
		if(s[i]==0) count++;
	}

	cout<<count<<endl;

    return 0;
}




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

int main() {
  int N,Z=0;
  cin>>N;
  vector<int> p(N);
  vector<int> q(N);
  vector<int> r(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    r[p[i]-1]++;
    Z=max(Z,r[p[i]-1]);
  }
  for(int i=0;i<N;i++){
    cin>>q[i];
    r[q[i]-1]++;
    Z=max(Z,r[q[i]-1]);
  }
  if(Z>N){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  reverse(q.begin(),q.end());
  int A=0,B=N-1;
  for(int i=0;i<N;i++){
    if(p[i]!=q[i]){
      continue;
    }
    if(p[i]!=q[A]&&p[A]!=q[i]){
      swap(q[A],q[i]);
      A++;
    }
    else{
      swap(q[B],q[i]);
      B--;
    }
  }
  for(int i=0;i<N;i++){
    cout<<q[i];
    if(i+1==N){
      cout<<endl;
    }
    else{
      cout<<" ";
    }
  }
}

Measured memory_bytes: 5616
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var ans = Min(c, b / a);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var acgt = new[] {'A', 'C', 'G', 'T'};
            var input = Console.ReadLine();
            var max = 0;
            var count = 0;
            foreach (var c in input)
            {
                var equal = false;
                foreach (var a in acgt)
                {
                    if (c == a)
                    {
                        equal = true;
                        break;
                    }
                }

                count++;
                if (!equal)
                {
                    count = 0;
                    equal = false;
                }

                if (max < count)
                {
                    max = count;
                }
            }

            Console.WriteLine(max);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

ll dp[10002][2][100];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d;
	string s;
	cin>>s>>d;
	dp[0][0][0]=1;
	rep(i,s.size()){
		rep(j,2){
			int t=(j?9:s[i]-'0');
			rep(k,d){
				rep(l,t+1){
					dp[i+1][j||l!=t][(k+l)%d]+=dp[i][j][k];
					dp[i+1][j||l!=t][(k+l)%d]%=MOD;
				}
			}
		}
	}
	ll ans=0;
	rep(i,2){
		ans+=dp[s.size()][i][0];
	}
	ans--;
	ans=(ans+MOD)%MOD;
	cout<<ans<<endl;	
}

Measured memory_bytes: 15872
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();

        // 主処理
        int[] countW = new int[n];
        int[] countE = new int[n];
        char[] array = s.toCharArray();

        if (array[0] == 'W') {
            countW[0]++;
        }
        if (array[n - 1] == 'E') {
            countE[n - 1]++;
        }

        for (int i = 1; i < n; i++) {
            countW[i] = array[i] == 'W' ? countW[i - 1] + 1 : countW[i - 1];
            countE[n - 1 - i] = array[n - 1 - i] == 'E' ? countE[n - i] + 1 : countE[n - i];
        }

        int[] counts = new int[n];
        for (int i = 0; i < n; i++) {
            int count = countW[i] + countE[i];
            counts[i] = count;
        }
        int min = Arrays.stream(counts).min().getAsInt();
        int result = min - 1;

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int n, m; cin >> n >> m;
  int64_t sum = 0;
  vector<tuple<int64_t, int64_t, int64_t>> data;
  rep(i, n) {
    int64_t x, y, z; cin >> x >> y >> z;
    data.emplace_back(x, y, z);
    //xsum += x, ysum += y, zsum += z;
    sum += x + y + z;
  }

  int64_t max_sum = 0;

  for (int xf = -1; xf < 2; xf += 2)
  for (int yf = -1; yf < 2; yf += 2)
  for (int zf = -1; zf < 2; zf += 2) {
    const auto xyzsummer = [&](tuple<int64_t, int64_t, int64_t> const& t) {
      return get<0>(t) * xf + get<1>(t) * yf + get<2>(t) * zf;
    };
    sort(data.begin(), data.end(), [&](const auto& lhs, const auto& rhs) {
      return xyzsummer(lhs) < xyzsummer(rhs);
    });
    int64_t xsum = 0;
    REP(i, n - m, n) {
      xsum += get<0>(data[i]);
    }
    int64_t ysum = 0;
    REP(i, n - m, n) {
      ysum += get<1>(data[i]);
    }
    int64_t zsum = 0;
    REP(i, n - m, n) {
      zsum += get<2>(data[i]);
    }
    maximize(max_sum, abs(xsum) + abs(ysum) + abs(zsum));
  }
  cout << max_sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    long long d1 = a1 * t1 + a2 * t2, d2 = b1 * t1 + b2 * t2,
        denom = d1 - d2, numer = b1 * t1 - a1 * t1;
    if (denom == 0) cout << "infinity\n";
    else {
        if (denom < 0) { denom *= -1; numer *= -1; }
        if (numer < 0) { cout << "0\n"; }
        else {
            long long lim = numer / denom, rem = numer % denom;
            long long ans = 2 * lim + 1;
            if (rem == 0) ans--;
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 256
n,*a=$<.map &:to_i
c,*g=l=0
g.unshift l while n>=l=3*l+1
m=g.size
(0...m).map{|k|h=g[k]
(h...n).map{|i|v=a[i]
j=i-h
while j>=0&&a[j]>v
a[j+h]=a[j]
j-=h
c+=1
end
a[j+h]=v}}
puts m,g*' ',c,a

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

using namespace std;

int main()
{
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	if (A1 + A2 + A3 >= 22) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define deb(x) cerr<<#x<<" : "<<x<<endl;
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order
#define ook order_of_key
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base);
		base=(base*base);
		exponent/=2;
	}
	return ans;
}
const int N=300005;
int segtree[4*N];
//void build(int node,int start,int end)
//{
//	if(start==end)
//	{
//		segtree[node]=ar[start];
//	    return ;	
//	}
//   int mid= start+end;
//   mid/=2;
//   build(2*node+1,start,mid);
//   build(2*node+2,mid+1,end);
//   segtree[node]=max(segtree[2*node+1],segtree[2*node+2]);
//}
void update(int node,int start,int end,int idx,int value)
{
	if(start==end)
	{
		segtree[node]=value;
		return ;
	}
	int mid=start+end;
	mid/=2;
	if(idx>=start && idx<=mid)
	{
		update(2*node+1,start,mid,idx,value);
	}
	else update(2*node+2,mid+1,end,idx,value);
	segtree[node]=max(segtree[2*node+1],segtree[2*node+2]);
}
int query(int node,int start,int end,int l,int r)
{
	if(l<= start && r >= end)
		return segtree[node];
	if (l > end || start > r)
		return 0;
	int q1, q2;
	int mid = (start + end) / 2;
	q1 = query(2 * node + 1, start, mid, l, r);
	q2 = query(2 * node + 2, mid + 1, end, l, r);
	return max(q1,q2);
}
signed main()
{
  fast
  int n,k;
  cin>>n>>k;
  int ans1=0;
  f(i,0,n)
  {
  	int x;
  	cin>>x;
  	int l=max(0LL,x-k);
  	int r=x+k;
  	int ans=query(0,0,300000,l,r);
  	ans1=max(ans1,ans+1);
  	update(0,0,300000,x,ans+1);
  }
  cout<<ans1;
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
}
 

Measured memory_bytes: 11976
n = int(input())


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def is_favorite(n, m):
    if x == 0:
        return False
    else:
        return n // m == n % m


li = make_divisors(n)
li = [x - 1 for x in li]


ans = 0
for x in li:
    if is_favorite(n, x):
        ans += x

print(ans)

Measured memory_bytes: 3528
while True:
    n = int(input())
    if n == 0:
        break
    
    s = input().strip().split()
    s = [float(i) for i in s]
    Sum = sum(s)
    m = Sum/n
    aa = 0
    
    for i in range(n):
        aa += (s[i]-m)**2
    arfa = (aa/n)**0.5
    
    print(arfa)
        


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (6 <= A && A <= 12)
    {
        B /= 2;
    }
    else if (A <= 5)
    {
        B = 0;
    }
    cout << B << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
*/
using namespace std;

#define mod 1000000007
#define INF 1000000000

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

using dbl = double;
using ll = long long;
using ull = unsigned ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pi = pair<int,int>;

#define log(x) cout << x << endl;
#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main() {

	ll n, k, a, b;
	cin >> n >> k;

	map<int, ll> cnt;

	vi ar;
	rep (i, n) {
		cin >> a >> b;
		if (!cnt[a]) ar.eb(a);
		cnt[a] += b;
	}
	sort(all(ar));

	ll l = 0;
	rep (i, n) {
		l += cnt[ar[i]];
		if (l >= k) {
			log(ar[i]);
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 4476
#0121
n, m, c = (int(_) for _ in input().split())
b = [int(_) for _ in input().split()]
ans = 0
for i in range(n):
    a = [int(_) for _ in input().split()]
    solve = c
    for j in range(m):
        solve += a[j]*b[j]
    if solve > 0:
        ans += 1
print(ans)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 #define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define vll vector<long long>
#define F     first
#define S    second
#define all(x) x.begin(), x.end()

int main()
{
    fast();
 	int n;
 	cin >> n;
 	int h[n];
 	for(int i = 0 ; i < n; i++)
 		cin >> h[i];
 	int cost[n] = {0};
 	cost[0] = 0;
 	cost[1] = abs(h[1] - h[0]);
 	for(int i = 2; i < n; i++)
 		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));   
 	cout << cost[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define MOD 1e9+7
#define ll long long
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||

signed main(){
	acc_io;
	int n,k;
	cin>>n>>k;
  	vl snk(n,1);
  	ll d,a;
  	rep(i,0,k){
	  	cin>>d;
	  	rep(i,0,d){
			cin>>a;
          	snk[a-1]=0;
        }
    }
  	int cnt=0;
  	rep(i,0,n){
		if(snk[i])cnt++;
    }
  	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
const int mod = 1e9+7;
int pw[405][405];
int pre[405][405];
int a[405], b[405];
int add(int a, int b) { return (a+b)%mod; }
int binpw(int a,int e) {
}
int sub(int a, int b){
return (a-b+mod)%mod;}
int dp[405][405];
int dp2[405][405];
int dp3[405][405];
int multiple(int a, int b) {return (long long) a * b % mod; }
int main() {
int N;
int C;
cin >> C >> N;
for(int i=0;i<C;i++) cin >> a[i];
for(int i=0;i<C;i++) cin >> b[i];
swap(N, C);
for(int i=0;i<=400;i++) {
pw[i][0] = 1;
for(int j=1;j<=400;j++) pw[i][j] = multiple(pw[i][j-1],i);
}
for(int i=0;i<=400;i++){
for (int j=1;j<=400;j++) pre[j][i] = add(pre[j-1][i],pw[j][i]);
}
for (int i = 0; i < N; i++) {
for(int j=0;j<=C;j++){
for (int take=0;take<=C-j;take++) {
dp[i][j+take] = add(dp[i][j+take],multiple(((i>0)?dp[i-1][j]:(j==0)),sub(pre[b[i]][take],pre[a[i]-1][take])));
}}}
cout << dp[N-1][C] << endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

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


Measured memory_bytes: 27628
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int n[4];
  cin>>n[0];
  for(int i=1;i<3;i++){
    cin>>n[i];
    if(n[0]<n[i]){
      n[3]=n[i];
      n[i]=n[0];
      n[0]=n[3];
    }
  }
  cout<<n[1]+n[2]<<endl;  
}

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

int main() {
  int n;
  ll m;
  cin>>n>>m;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int l=2;
  int r=2e5+1;
  while(l<r){
    int x=(l+r)/2;
    int b=0;
    ll c=0;
    rep(i,0,n){
      while(b<n && a[i]+a[n-1-b]>=x) b++;
      c+=b;
    }
    if(c>m) l=x+1;
    else r=x;
  } 
  int d=0;
  ll e=0;
  ll cur=0;
  ll ans=0;
  rep(i,0,n){
    while(d<n && a[i]+a[n-1-d]>=r){
      cur+=a[n-1-d];
      d++;
    }
    e+=d;
    ans+=a[i]*d+cur;
  }
  cout<<ans+(r-1)*(m-e)<<endl;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n, a, b, ans int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		SOD := sumsOfDigits(i)
		if a <= SOD && SOD <= b {
			ans += i
		}
	}
	fmt.Println(ans)
}

func sumsOfDigits(x int) int {
	result := 0
	for x != 0 {
		result += x % 10
		x /= 10
	}
	return result
}


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

// B - Papers, Please
int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
}


Measured memory_bytes: 3552
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long

int main() {
    ll n, m;
    cin >> n;
    m = sqrt(n);
    while(n%m) m--;
    n = (n/m) - 1, m--;
    cout << m + n << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

ll cnt(ll bit){
    ll res=0;
    while(bit){
        if(bit%2) res++;
        bit/=2;
    }
    return res;
}

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

  ll n;
  while(cin>>n,n){
      std::vector<int> sche[31];
      int memo[31][n];
      for(int i=0;i<=30;i++)for(int j=0;j<n;j++) memo[i][j]=0;
      for(int i=0;i<n;i++){
          int f;cin>>f;
          for(int j=0;j<f;j++){
              int d;cin>>d;
              sche[d].push_back(i);
              memo[d][i]=1;
          }
      }
      VVI dp(31,vector<ll>(n,0));
      ll tmp=1;
      for(int i=0;i<n;i++){
          dp[0][i]=tmp;
          tmp*=2;
      }
      for(int day=1;day<=30;day++){
          for(int j=0;j<n;j++){
              if(memo[day][j]){
                  for(int k=0;k<(int)sche[day].size();k++){
                      if(memo[day][j])dp[day][j]|=dp[day-1][sche[day][k]];
                  }
              }
              else{
                  dp[day][j]=dp[day-1][j];
              }
          }
      }
      int res=INF;
      for(int day=1;day<=30;day++){
          for(int j=0;j<n;j++){
              if(cnt(dp[day][j])==n) res=min(res,day);
          }
      }
      if(res==INF) cout<<-1<<endl;
      else cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	lint K;
	cin >> K;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());


	auto judge = [&](auto idx) {

		lint cnt = 0;

		if (idx >= 0) {
			for (int i = 0; i < N; i++) {
				if (A[i] == 0) cnt += N - i - 1;
				else if (A[i] < 0) cnt += A.end() - lower_bound(A.begin() + i + 1, A.end(), idx / A[i]);
				else cnt += upper_bound(A.begin() + i + 1, A.end(), idx / A[i]) - (A.begin() + i + 1);
			}
		}
		else {
			for (int i = 0; i < N; i++) {
				if (A[i] < 0) cnt += A.end() - lower_bound(A.begin() + i + 1, A.end(), (idx + 1) / A[i] + 1);
				else if (A[i] != 0)cnt += upper_bound(A.begin() + i + 1, A.end(), (idx + 1) / A[i] + 1) - (A.begin() + i + 1);
			}
		}

		return cnt >= K;
	};

	auto binary_search = [&](auto f) {

		auto ng = -LINF;
		auto ok =  LINF;

		while (abs(ok - ng) > 1) {
			auto mid = (ok + ng) / 2;

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	lint ans = binary_search(judge);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<numeric>
using namespace std;

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

  vector<int> A(N);
  for(auto &a: A)
  {
    cin >> a;
  }

  double ave = accumulate(A.begin(), A.end(), 0.0) / A.size();

  int avei = round(ave);

  int sum=0;
  for(auto a: A)
    sum += (a-avei) * (a-avei);

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>


int bubbleSort(int A[], int N){
  int i, j, sw=0,s=0;

  for (i = 0; i < N - 1 ; i++) {
    for (j = N - 1; j > i; j--) {
      if (A[j-1] > A[j]) {
        s = A[j-1];
        A[j-1] = A[j];
        A[j] = s;
	sw++;
  }
}

  }

  return sw;
}




int main(){

  int A[100],N=0,sw=0,i;
  scanf("%d",&N);

  for(i =0; i < N; i++) scanf("%d",&A[i]);

  sw = bubbleSort(A,N);

  printf("%d",A[0]);
  for(i =1; i < N; i++) printf(" %d",A[i]);
    
   printf("\n");

   printf("%d\n",sw);

   return 0;
}





Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int r = N % 10;
		String str = " ";
		if (r == 3) {
			str = "bon";
		} else if (r == 0 || r == 1 || r == 6 || r == 8) {
			str = "pon";
		} else {
			str = "hon";
		}

		System.out.println(str);

	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string n = "0", m;
  cin >> m;
  auto add = [&] (string x, string y) {
    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    int n = x.length(), m = y.length();
    x.resize(max(n, m), '0');
    y.resize(max(n, m), '0');
    vector<int> s(max(n, m) + 1, 0);
    for (int i = 0; i < max(n, m); ++i) {
      s[i] += x[i] - '0' + y[i] - '0';
      if (s[i] >= 10) {
        s[i + 1] += s[i] / 10;
        s[i] %= 10;
      }
    }
    string result = "";
    for (int i = 0; i <= max(n, m); ++i) {
      result += s[i] + '0';
    }
    while (result.length() > 1 && result[result.length() - 1] == '0') {
      result.pop_back();
    }
    reverse(result.begin(), result.end());
    return result;
  };
  for (int i = 1; i <= 9; ++i) {
    n = add(n, m);
  }
  int l = 1, r = m.length();
  while (l != r) {
    int mid = l + r >> 1;
    auto check = [&] (int x) {
      string number = add(n, to_string(9 * x));
      int len = number.length(), all = 0;
      for (int i = 0; i < len; ++i) {
        all += number[i] - '0';
      }
      return all <= 9 * x;
    };
    if (check(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << l << '\n';
  return 0;
}

Measured memory_bytes: 6708
def main():
    N, C, *STC = map(int, open(0).read().split())

    T = [[0] * 10 ** 5 for _ in range(C + 1)]
    for s, t, c in zip(*[iter(STC)] * 3):
        T[c][s - 1:t] = [1] * (t - s + 1)

    print(max(map(sum, zip(*T))))

main()

Measured memory_bytes: 36468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rev(i,n,a) for(ll i=n-1;i>=a;i--)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define secreterror() ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve(){

    ll a,v1;
    cin>>a>>v1;
    ll b,v2;
    cin>>b>>v2;

    ll time;
    cin>>time;

    ll fin=v1-v2;
    if(fin<=0){
        cout<<"NO"<<endl;
    }
    else
    {
        double take=abs(a-b)/double(fin);

        if(take<=time){
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
        
    }
    
    
}


int main()
{
    secreterror()
    // ll t;
    // cin>>t;
    //while(t--){
        solve();
        
    //}

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector <int> d(n);
  for (int i = 0; i < n; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  if (d.at(n/2 - 1)==d.at(n/2)){
    cout<< 0;
  }
  else{
    cout << d.at(n/2)-d.at(n/2-1)<<endl;
  }
}
  

Measured memory_bytes: 640
#include<iostream>
#include<map>

using namespace std;

int main()
{
  map<int, bool>table;
  for(int i = 1; i <= 9; i++)
    for(int j = i; j <= 9; j++)
       table[i * j] = true;
  
  int num;
  cin >> num;
  
  if(table[num])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int n,k;
int a[N];
bool check(int x)
{
    int ans=0;
    for(int i=0;i<n;i++)
    {   if(a[i]<=x)continue;
        ans+=(a[i]/x);
    }
    if(ans<=k)
        return true;
    else
        return false;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   int l=1,r=2*1e9;
   while(r-l>1)
   {
       int mid=(l+r)/2;
       if(check(mid))
       {
           r=mid;
       }
       else
       {
           l=(mid + 1);
       }
   }
   for(int i=l;i<=r;i++)
   {
       if(check(i))
       {
           cout<<i<<endl;
           return 0;
       }
   }

}


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

int main()
{
	uint64_t N, K, a;
	vector<uint64_t> A;
	uint64_t x = 0;
	uint64_t ans = 0;
	uint32_t o = 1;
	vector<uint64_t> num1(64, 0);

	cin >> N >> K;

	// 読み込んだ数値の各桁ごとの1の数を取得する
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		A.push_back(a);
		uint32_t idx = 0;
		while (a)
		{
			if (a & 1)
			{
				num1[idx]++;
			}
			a = a >> 1;
			idx++;
		}
	}
	// Kの2進数での桁数を調査
	uint64_t tmpK = K;
	while (tmpK)
	{
		tmpK = tmpK >> 1;
		o++;
	}

	// Kの上位桁数から計算結果をあてはめる
	for (int i = o - 1; i >= 0; i--)
	{
		// 1の数がNの半分より少ないときは最大値を取る値の当該ビットは1となる
		if (num1[i] <= N / 2)
		{
			if (K >= x + ((uint64_t)1 << i))
			{
				x = x + ((uint64_t)1 << i);
			}
		}
	}
	// 最大値を求める
	for (auto itr = A.begin(); itr != A.end(); itr++)
	{
		ans = ans + (x ^ *itr);
	}

    cout << ans << endl; 

	return(0);
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll  long long  int
#define ld   long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 998244353;
const ll N = 1e5+5;


int main()
{
    FAST
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        ll n,k;
        cin>>n>>k;
        ll pre[n+5]={0};
        ll ans[n+5]={0};
        vector< pair <ll,ll> >v;
        for(i=0; i<k; i++)
        {
            ll u,v1;
            cin>>u>>v1;
            v.pb({u,v1});
        }
        pre[1]=1;
        ans[1]=1;
        for(i=2; i<=n; i++)
        {
            pre[i]=pre[i-1];
            for(j=0; j<k; j++)
            {
                ll ri=i-v[j].first;
                ll le=i-v[j].second;
                if(ri>=1)
                {
                    ll add=pre[ri];
                    if(le>=1)
                        add=(add-pre[le-1]+mod)%mod;
                    pre[i]+=add;
                    ans[i]+=add;
                    pre[i]%=mod;
                    ans[i]%=mod;
                }
            }
            //cout<<pre[i]<<" "<<ans[i]<<"\n";
        }
        cout<<ans[n]<<"\n";



    }

    return 0;
}


Measured memory_bytes: 6728
[n,k]=[int(x) for x in input().split()]

x=((n-1)*(n-2))//2 - k

if x<0:
  print(-1)
else:
  print(n-1+x)
  for i in range(2,n+1):
    print(1,i)
  for i in range(2,n):
    for j in range(i+1,n+1):
      if x == 0:
        exit()
      print(i,j)
      x -= 1

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    int ans = n%2 == 0?n/2-1:n/2;
    ans = ans > 0 ? ans : 0;

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

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());

  int ans1 = d[n / 2 - 1];
  int ans2 = d[n / 2];

  if (ans1 == ans2) {
    cout << "0" << endl;
  } else {
    int ans = ans2 - ans1;
    cout << ans << endl;
  }
}


Measured memory_bytes: 640