akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#define MAX 105
#define INF 1000000
using namespace std;

int n;
int M[MAX][MAX];
int d[MAX];
int p[MAX];
int color[MAX];//0 表示未进入 -1 表示在之中 1 表示已出去

int prim() {
	int u,min,i,j;
	d[0]=0;
	p[0]=-1;
	while(1) {
		min=INF;
		u=-1;
		for(i=0; i<n; i++) {
			if(min>d[i] && color[i]!=1) {
				u=i;
				min=d[i];
			}
		}
		if(u==-1) break;
		color[u]=1;
		for(j=0; j<n; j++) {
			if(color[j]!=1 && M[u][j]!=INF) {
				if(d[j]>M[u][j]) {
					d[j]=M[u][j];
					color[j]=-1;
					p[j]=u;
				}
			}
		}
	}
	int sum=0;
	for(i=0; i<n; i++) {
		if(p[i] != -1) sum+=M[i][p[i]];
	}
	return sum;
}

int main() {
	int i,j,a;
	memset(color,0,sizeof(color));
	memset(d,INF,sizeof(d));
	memset(p,-1,sizeof(p));
	scanf("%d",&n);
	for(i=0; i<n; i++) {
		for(j=0; j<n; j++) {
			scanf("%d",&a);
			if(a==-1) a=INF;
			M[i][j]=a;
		}
	}
	cout<<prim()<<endl;
	return 0;
}


Measured memory_bytes: 3172
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
int main()
{
    int x;
    cin >> x;
    int sum = 0;
    sum += (x / 500) * 1000;
    x = x - (x / 500) * 500;
    sum += (x / 5) * 5;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

pair<ll, ll> extgcd(ll a, ll b) {
    if (b == 0)return make_pair(a, 0);
    auto t = extgcd(b, a % b);
    return make_pair(t.second, t.first - t.second * (a / b));
}

ll invmod(ll n) {
    return extgcd(n, mod).first;
}

class modint {
public:
    ll n;

    modint() = default;

    explicit modint(ll number) {
        n = ((number % mod) + mod) % mod;
    }

    bool operator==(modint e) {
        return n == e.n;
    }

    modint operator+(modint e) {
        return modint(n + e.n);
    }

    modint operator-(modint e) {
        return modint(n - e.n);
    }

    modint operator-(ll e) {
        return modint(n - e);
    }

    modint operator*(modint e) {
        return modint(n * e.n);
    }

    modint operator/(modint e) {
        return modint(n * invmod(e.n));
    }

};

template<class T>
T f1(T n, T m) {
    return m * m * (n * n * (n + T(1)) - (n * (n + T(1)) * (T(2) * n + T(1))) / T(3));
}

template<class T>
T f2(T n, T m) {
    return (f1(n, m) + f1(m, n)) / T(2);
}

template<class T>
T comb(T n, T k) {
    return k == T(0) ? T(1) : comb(n - T(1), k - T(1)) * n / k;
}

int main() {
    modint n, m, k;
    cin >> n.n >> m.n >> k.n;
    cout << (f2(n, m) * comb(n * m - 2, k - 2)).n << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    char c;
    vector<int> v('z' - 'a' + 1);

    while(cin.get(c)){
        if(isalpha(c)) v[tolower(c) - 'a']++;
    }

    fore(i, 'a', 'z'){
        cout << (char)i << " : " << v[i - 'a'] << endl;
    }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, K;

int main()
{
    cin >> N >> K;
    vector<int> a(N);
    cin >> a;
    vector<int> dp(K + 1); // 0: 回ってきたら負け
    REP(k, K + 1) for (auto v : a) if (k - v >= 0 and dp[k - v] == 0) dp[k] = 1;

    cout << (dp[K] ? "First" : "Second") << endl;
}


Measured memory_bytes: 640
import java.util.*;

class Main{

    P[] es;
    int V, E;
    int INF = Integer.MAX_VALUE/2;
    int[] par, rank;

    void init(int n){
        par = new int[n];
        rank = new int[n];
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = i;
        }
    }

    int find(int x){
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    void unit(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;

        if(rank[x]<rank[y]) par[x] = y;
        else{
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    boolean same(int x, int y){
        return find(x) == find(y);
    }

    class P{
        int u, v, cost;
        P(int u, int v, int cost){
            this.u = u;
            this.v = v;
            this.cost = cost;
        }
    }

    void solve(){
        Scanner sc = new Scanner(System.in);
        while(true){
            V = sc.nextInt();
            E = sc.nextInt();
            if(V==0 && E==0) break;

            es = new P[E];
            for(int i=0; i<E; i++){
                int a = sc.nextInt()-1, b = sc.nextInt()-1;
                int w = sc.nextInt();
                es[i] = new P(a, b, w);
            }

            Arrays.sort(es, new Comparator<P>(){
                    public int compare(P p1, P p2){
                        return p1.cost - p2.cost;
                    }
                });

            int ans = INF;
            for(int i=0; i<E; i++){
                init(V);
                int cnt = 0;
                int max = 0, min = INF;
                for(int j=i; j<E; j++){
                    P p = es[j];
                    if(!same(p.u, p.v)){
                        unit(p.u, p.v);
                        max = Math.max(max, p.cost);
                        min = Math.min(min, p.cost);
                        cnt++;
                    }
                }
                if(cnt!=V-1) continue;
                ans = Math.min(ans, max - min);
            }
            if(ans==INF) ans = -1;
            System.out.println(ans);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 75580
from collections import deque
N = int(input())
C = []
M = {}
for i in range(N):
    *c, = map(int, input().split())
    c = tuple(min(c[j:] + c[:j] for j in range(1, 5)))
    C.append(c)
    if c not in M:
        M[c] = deque([i])
    else:
        M[c].append(i)
def count(p, q, r, s):
    if p == q == r == s:
        return 4
    if p == r and q == s:
        return 2
    return 1
def solve(ci, cj, k):
    R = {}
    for l in range(4):
        #  [l]   [l-1]
        # [l+k] [l+k+1]
        c = ci[l], ci[l-1], cj[k-l], cj[k-l-1]
        c = tuple(min(c[j:] + c[:j] for j in range(1, 5)))
        if c not in M:
            return 0
        R[c] = R.get(c, 0) + 1
    res = 1
    for c in R:
        m = M[c]
        cnt = len(m)
        if c == cj:
            cnt -= 1
        if cnt < R[c]:
            return 0
        k = count(*c)
        for p in range(cnt-R[c]+1, cnt+1):
            res *= p * k
    return res

ans = 0
for i in range(N):
    ci = C[i]
    q = M[ci]; q.popleft()
    if not q:
        del M[ci]
    for j in range(i+1, N):
        cj = C[j]
        for k in range(4):
            ans += solve(ci, cj, k)
print(ans)


Measured memory_bytes: 78556
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(ll i = 0; i < (ll) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void dfs(string s, vector<string> &ans, const ll &digit)
{
    if((ll)s.size() > digit) return;
    ans.push_back(s);
    for(ll i = 0; i < 10; i++)
    {
        ll a = s.back() - '0';
        ll d = abs(a - i);
        if(d > 1) continue;
        s.push_back(i + '0');
        dfs(s, ans, digit);
        s.pop_back();
    }
}

void solve()
{
    ll k; cin >> k;
    vector<string> ans;

    string M = "3234566667";
    for(ll i = 1; i < 10; i++)
    {
        string s  = "";
        s.push_back(i + '0');
        dfs(s, ans, (ll)M.size());
        s.pop_back();
    }

    vector<ll> num;
    for(ll i = 0; i < ans.size(); i++)
    {
        ll tmp = stoll(ans[i]);
        num.push_back(tmp);
    }
    sort(num.begin(), num.end());
    cout << num[k - 1] << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 17136
local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end
--
local N = io.read("n", "l")
local restaurants = {}
for i=1,N do
    local tmp = io.read("l")
    local tbl = str2tbl(tmp)
    local s, p
    for j=1, #tbl do
        if tbl[j] == ' ' then
            s = string.sub(tmp, 1, j-1)
            p = tonumber(string.sub(tmp, j+1))
            break
        end
    end
    --print(s, p)
    table.insert(restaurants, {i, s, p})
end

table.sort(restaurants, function(x, y)
    if x[2] ~= y[2] then
        return x[2] < y[2]
    else
        return x[3] > y[3]
    end
end)
for i=1, N do
    print(restaurants[i][1])
end

Measured memory_bytes: 760
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, K;
long long F[10100000], Inv[10100], Mod = 1000000007;
int Comb[5010][5010];
long long Pow(long long a, long long b){
    long long r=1;
    while(b){
        if(b&1)r=r*a%Mod;
        a=a*a%Mod;b>>=1;
    }
    return r;
}
long long Calc(int B){
    int i;
    long long r=0;
    int m = n-K;
    for(i=0;i<B;i++){
        long long t;
        if(B!=K) t = Comb[B][i]*F[n-i-1]%Mod*Inv[n-(B-i+m)]%Mod*(B-i)%Mod;
        else t = Comb[B][i]*F[n-i-1]%Mod*(B-i)%Mod;
        if(i&1)r+=Mod-t;
        else r+=t;
    }
    r%=Mod;
    //printf("%d %lld\n",B,r);
    return r;
}
int main(){
    scanf("%d%d",&n,&K);
    int i;
    F[0]=1;
    for(i=0;i<=5000;i++){
        Comb[i][0]=1;
        for(int j=1;j<=i;j++)Comb[i][j]=(Comb[i-1][j-1]+Comb[i-1][j])%Mod;
    }
    for(i=1;i<=n;i++)F[i]=F[i-1]*i%Mod;
    for(i=0;i<=10000;i++)Inv[i]=Pow(n-i,Mod-2);
    long long res=0;
    for(i=0;i<=K;i++){
        res+=Calc(i);
        res%=Mod;
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 146736
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define pb push_back
#define cin (type == 1 ? fin : cin)
#define cout (type == 1 ? fout : cout)
using namespace std;
double a , b , c;
string s , s1;
int type = 0;
int main(){
    ofstream fout("photo.out");
    ifstream fin("photo.in");
    ios_base::sync_with_stdio( false );
    cin >> a >> b >> c;
    cout << ceil(c / max( a , b ) ) ;
}


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

def dfs(n):
  ans = 0
  if n > N:
    return 0
  else:
    if all(str(n).count(c) > 0 for c in "357"):
      ans = 1
    ans += dfs(10*n + 3)
    ans += dfs(10*n + 5)
    ans += dfs(10*n + 7)
  return ans

print(dfs(0))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long

ll a, b;


int main(){
  cin >> a >> b;
  ll x1 = 1, y1= 0, x2 = 0, y2 = 1;
  while(1){
    if(x2 * a + y2 * b == 0)
      break;
    ll div = (x1 * a + y1 * b) / (x2 * a + y2 * b);
    ll tempx = x2;
    ll tempy = y2;
    x2 = x1 - x2 * div;
    y2 = y1 - y2 * div;
    x1 = tempx;
    y1 = tempy;
  }
  cout << x1 << ' ' << y1 << endl;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> n,n) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans /(n-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3176
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);

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

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

  int sum = accumulate(p.begin(), p.begin() + k, 0);

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main(void){
  int N,st[300000],i,j,k,l,m,n;
  scanf("%d",&N);
  j=1;
  k=1;
  m=2;
  for(i=1;i<=N;i++){
    j=j*2;
  }
  for(i=0;i<j;i++){
    scanf("%d",&st[i]);
  }
  for(l=1;l<=N;l++){
    for(i=0;i<j;i=i+m){
      if(st[i]<st[i+k]){
	n=st[i];
	st[i]=st[i+k];
	st[i+k]=n;
      }
      if(st[i]!=st[i+k]){
	st[i]=st[i]-st[i+k];
      }
    }
  k=k*2;
  m=m*2;
}
printf("%d\n",st[0]);
return 0;
}


Measured memory_bytes: 1152
from sys import stdin
from math import log10

gosen = 5e15

S = int(stdin.readline().strip())
K = int(stdin.readline().strip())

logK = log10(K)
Sstr = str(S)

Kres = K
for i in range(0, len(Sstr)):
    Si = int(Sstr[i])
    if Si == 1:
        Kres = Kres - 1
    else:
        print(Si)
        break
    if Kres <= 0:
        print(Si)
        break




Measured memory_bytes: 3060
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<double> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<vector<double>> dp(n+1,vector<double>(n+1));
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++)
        dp[0][i]=0;
    // for(int i=1;i<=n;i++)
    // {
    //     dp[i][0]=(1.0-arr[i-1])*dp[i-1][0];
    // }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j==0)
            dp[i][j]=(1.0-arr[i-1])*dp[i-1][j];
            else
            
          dp[i][j]=arr[i-1]*dp[i-1][j-1]+ (1.0-arr[i-1])*dp[i-1][j];  
        }
    }
    double res=0.0;
    for(int i=(n/2)+1;i<=n;i++)
        res+=dp[n][i];
    printf("%.12f\n",res);
    return 0;
}


Measured memory_bytes: 73812
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int L, R;
    cin >> L >> R;
    if(R-L == 1){
        cout << (L*R)%2019;
    }
    else if(R/2019 - L/2019 > 1){
        cout << 0;
    }
    else if(R/2019 - L/2019 == 1&&R%2019 != 0){
        cout << 0;
    }
    else if(R/2019 - L/2019 == 1&&R%2019 == 0){
        cout << 0;
    }
    else if(L%2019 == 0||R%2019 == 0){
        cout << 0;
    }
    else {
        long long int min = 2019;
        for(long long int i=L; i<R+1; i++){
          for(long long int j=i+1; j<R+1; j++){
              long long int h = (i*j)%2019;
              if(h < min){
                  min = h;
              }
          }
        }
        cout << min;
    }
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int C=in();
    int s[100000];
    int t[100000];
    int c[100000];
    int tt[200001];
    int sm[200001];
    REP(i,200001)sm[i]=0;
    REP(i,N)cin>>s[i]>>t[i]>>c[i];
    REP1(i,C){
        REP(j,200001)tt[j]=0;
        REP(j,N){
            if(c[j]==i){
                tt[2*s[j]-1]++;
                tt[2*t[j]]--;
            }
        }
        REP1(j,200000){
            tt[j]+=tt[j-1];
        }
        REP(j,200001){
            if(tt[j]!=0)sm[j]++;
        }
    }
    int ans=0;
    REP(i,200001){
        ans=max(ans,sm[i]);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 6272
N = int(input())
T, A = map(int,input().split())
log = list(map(int,input().split()))

D = float('inf')

for i,val in enumerate(log,1):
    iA = T - val * 0.006
    iD = abs(A - iA)
    if iD < D:
        D = iD
        idx = i

print(idx)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<stack>
using namespace std;

signed main() {
	string a; cin >> a;
	cout << a.substr(0, a.length() - 8) << endl;
}


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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

int main(){
    int ans=0;
    char w[11];
    char t[1001];
    scanf("%s",w);
    int ww=strlen(w);
    for (;;) {
        scanf("%s",t);
        if (!strcmp(t,"END_OF_TEXT")) break;
        int tt=strlen(t);
        for (int j=0;j<tt;j++) if (isupper(t[j])) t[j]=t[j]+32;
        if (!strcmp(t,w)) ans++;
    }
    printf("%d\n",ans);
    return 0;
}




Measured memory_bytes: 3224
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

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

const int N = 200007;
const double pi = acos(-1);

vi adj[N];

void solve(){    

    int n;
    cin>>n;

    for(int i = 2;i<=n;i++){
        int x;
        cin>>x;
        adj[x].pb(i);
    }
    for(int i = 1;i<=n;i++){
        cout<<adj[i].size()<<"\n";
    }
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 14484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MAXN=1e5+5;
int dp[MAXN][3];

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

    int n,k; cin>>n;

    FOR(i,n) {
        int a,b,c; cin>>a>>b>>c;
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + a;
        dp[i+1][1] = max(dp[i][0], dp[i][2]) + b;
        dp[i+1][2] = max(dp[i][0], dp[i][1]) + c;
    }

    cout<<*max_element(dp[n], dp[n]+3)<<endl;
    return 0;
}



Measured memory_bytes: 1408
def max_heapify(x = 1)
  l = 2*x
  r = 2*x+1
  if l <= $n && $heap[l][0] > $heap[x][0]
    maximum = l
  else
    maximum = x
  end
  if r <= $n && $heap[r][0] > $heap[maximum][0]
    maximum = r
  end
  if maximum != x
    $heap[x], $heap[maximum] = $heap[maximum], $heap[x]
    max_heapify(maximum)
  end
end

def extract
  key = $heap[1]
  $heap[1] = $heap[$n]
  $n -= 1
  max_heapify
  key
end

def insert(key)
  $n += 1
  $heap[$n] = key
  i = $n
  while i > 1 && $heap[i/2][0] < $heap[i][0]
    $heap[i], $heap[i/2] = $heap[i/2], $heap[i]
    i /= 2
  end
end

def dist(p0, p1)
  Math.sqrt( (p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2 )
end

def find(x)
  x == $sibling[x] ? x : $sibling[x] = find($sibling[x])
end

n, m = gets.split.map(&:to_i)
$sibling = Array.new(n + 1) { |i| i }
p = [0, *n.times.map { gets.split.map(&:to_f) }]
q = m.times.map { gets.split.map(&:to_i) }
sum = 0
$n = 0
$heap = []
q.each do |a, b|
  d = dist(p[a], p[b])
  sum += d
  insert( [d, a, b] )
end
until $n < 1
  ps = extract
  d, p1, p2 = ps
  if ( p1 = find(p1) ) != ( p2 = find(p2) )
    $sibling[p2] = p1
    sum -= d
  end
end
p sum < 0 ? 0 : sum

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

int main(){
  int n,k,s;
  cin >> n >> k >>s;
  if(s<1000000000){for(int i=0;i<n;i++){
                     if(i<k){cout << s ;}else{cout << s+1;}
                     if(i!=n-1){ cout << " ";}
  }}
    if(s==1000000000){for(int i=0;i<n;i++){
                     if(i<k){cout << s ;}else{cout << 1;}
                     if(i!=n-1){ cout << " ";}
  }}
}

Measured memory_bytes: 1280
# AtCoder Beginner Contest 079 D - Wall

import sys

H, W = map(int, sys.stdin.readline().strip().split())
C = []
for _ in range(10):
    c = list(map(int, sys.stdin.readline().strip().split()))
    C.append(c)

A = []
for h in range(H):
    a = list(map(int, sys.stdin.readline().strip().split()))
    A.append(a)

# コストをワーシャルフロイド
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

# 必要なコストは、各数字を1 に変化させる部分のみなので
cost = [c[1] for c in C]

# 壁の数字を順番に探索して必要なコストを足していく
ans = 0
for h in range(H):
    for w in range(W):
        # 壁に数字が存在しないとき
        if A[h][w] == -1:
            continue
        ans += cost[A[h][w]]

print(ans)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 500010
#define MAXM 44100
#define LOGMAXN 20
#define INF 1e9+7
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m;
	while(cin >> n >> m)
	{
		printf("%d\n", max(0, n-2*m));
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			if(h == 0 && w == 0) break;

			int switchFlag = 0;
			int startToken = 0;
			for(int i=0; i<h; i++) {
				if(startToken == 0) {
					switchFlag = 0;
					startToken = 1;
				} else {
					switchFlag = 1;
					startToken = 0;
				}
				for(int j=0; j<w; j++) {
					if(switchFlag == 0) System.out.print("#");
					else System.out.print(".");
					if(j != w-1) {
						switchFlag = Math.abs(switchFlag - 1);
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}

		sc.close();

	}

}



Measured memory_bytes: 33712
def s(n):
    sum=0
    for i in range(14):
        if n[i] == 1 : sum+=i
    if sum % 5 == 0 or sum == 47: return True
    return False

while True:
    try:
        l=map(int, input().split(","))
    except:
        break

    n=[0]*14
    for i in l:
        n[i]+=1

    if 4 in n:
        print("four card")
    elif 3 in n and 2 in n:
        print("full house")
    elif 3 in n:
        print("three card")
    elif 2 == n.count(2):
        print("two pair")
    elif 2 in n:
        print("one pair")
    elif s(n):
        print("straight")
    else:
        print("null")

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b,c=0,d=0,e=0,f=0;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            c++;
        else if(s=="WA")
            d++;
        else if(s=="TLE")
            e++;
        else
            f++;
    }
    cout<<"AC x "<<c<<endl;
    cout<<"WA x "<<d<<endl;
    cout<<"TLE x "<<e<<endl;
    cout<<"RE x "<<f<<endl;
}


Measured memory_bytes: 3624
W, H, x, y, r = map(int, input().split())
if x == 0 or y == 0 or x < 0 or y < 0:
    print("No")
elif W == x or H == y:
    print("No")

elif W < x or H < y:
    print("No")

elif W < x+r or H < y+r:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 7660
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    FAST;

    string s;
    cin >> s;

    int A = 0, B = 0;
    rep(i, size(s)){
        if(s[i] == 'A') A++;
        else B++;
    }

    if(A >= 1 && B >= 1){
        println("Yes");
    }else{
        println("No");
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void B();

int main()
{
	B();
	fflush(stdout);
	return 0;
}

static void B()
{
	std::string S, T;
	get(S, T);

	int slen = S.length();
	int tlen = T.length();

	int diffMin = 10001;
	for (int i = 0; i < slen; i++) {
		int diff = 0;
		if (slen - i < tlen) break;
		for (int j = 0; j < tlen; j++) {
			if (S[i + j] != T[j]) diff++;
		}
		diffMin = std::min(diffMin, diff);
	}
	printf("%d\n", diffMin);
}


Measured memory_bytes: 3704
#include<stdio.h>
int main(void)
{
	int i,a[7],b;
	for(i=0;i!=7;i++){
		scanf("%d%d",&a[i],&b);
		a[i]-=b;
	}
	for(i=0;i!=7;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

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

int main()
{
  ll k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; i++)
  {
    a.push_back(i);
  }
  while (1)
  {
    if (k <= a.size())
    {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(a, old);
    for (auto x : old)
    {
      for (int i = -1; i <= 1; i++)
      {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
        {
          continue;
        }
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
}



Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct advance_math{
	vector<int> _f, _fi;
	int max_n, _mod;
	int fp(int _x,int _y) {
		int _res = 1;
		while(_y){
			if(_y&1) _res = _res*_x%_mod;
			_x = _x*_x%_mod;
			_y >>= 1;
		}
		return _res;
	}
	int add(int _x, int _y){
		int _res = (_x + _y)%_mod;
		return (_res < 0 ? _res + _mod : _res);
	}
	int inv(int _){
		return fp(_, _mod - 2);
	}
	int mul(int _x, int _y){
		int _res = (_x * _y)%_mod;
		return (_res < 0 ? _res + _mod : _res);
	}
	void setup(int _ = 100003,int _m = 1000000007){
		_mod = _m;
		max_n = _;
		_f.assign(max_n + 1, 0);
		_fi.assign(max_n + 1, 0);
		_f[0] = 1;
		for(int i = 1 ; i <= max_n ; i ++) _f[i] = (_f[i - 1] * i)%_mod;
		_fi[max_n] = inv(_f[max_n]);
		for(int i = max_n - 1; i >= 0 ; i --) _fi[i] = (_fi[i + 1] * (i + 1))%_mod;
	}
	int C(int _x, int _y){
		if(_x > _y) return 0;
		return mul(_f[_y], mul(_fi[_x], _fi[_y - _x]));
	}
	int P(int _x, int _y){
		return mul(_f[_y], _fi[_y - _x]);
	}
	int CK(int _x, int _y){
		return C(_y - 1, _x + _y - 1);
	}
} mt;

signed main(){
	mt.setup(300000);
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int ans = mt.C(H - 1, H + W - 2);
	for(int i = 1 ; i <= B ; i ++)
		ans = mt.add(ans, - mt.mul(mt.C(H - A - 1, H - A - 1 + i - 1), mt.C(W - i, W - i + A - 1)));
	cout << ans;
}


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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> P(N);
	for(auto &i:P)cin >> i;
	int ans=N-K+1;
	
	vector<bool> sorted(N+1,false);
	vector<int> check(N,0);
	for(int i=0;i<N-1;i++)sorted[i+1]=(P[i]<P[i+1]);
	
	int p=0;
	int c=0;
	while(p<=N){
		if(sorted[p])c++;
		else{
			if(c>=K-1)for(int i=0;i<c-K+2;i++)check[p-i-1]=1;
			c=0;
		}
		p++;
	}
	
	int S=accumulate(check.begin(),check.end(),0);
	if(S>1)ans-=S-1;
	else for(int i=0;i<N;i++)check[i]=0;
	
	set<int> s;
	for(int i=0;i<K;i++)s.insert(P[i]);
	for(int i=K;i<N;i++){
		auto l=s.begin();
		auto r=s.end();
		r--;
		if(*l==P[i-K] && *r<P[i] && check[i]==0)ans--;
		s.erase(P[i-K]);
		s.insert(P[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	long long int sz = s.size();
	sz--;
	long long int ans = 0;
	for (long long int i = 0; i < (1 << sz); i++) {
		string s2 = "";
		for (long long int j = 0; j <= sz; j++) {
			s2 += s[j];
			if ((i&(1 << j)) != 0) {
				s2 += "+";
			}
		}
		//s2 += s[sz + 1];
		//cout << s2 << endl;
		//cout << endl;
		long long int p = 0;
		for (long long int j = 0; j < s2.size(); j++) {
			if (s2[j] != '+') {
				p *= 10;
				p += (s2[j] - '0');
				//cout << p << endl;
			}
			else {
				//cout << p << endl;
				ans += p;
				p = 0;
			}
		}
		//cout << p << endl;
		//cout << endl;
		ans += p;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) {
    // int x = a; a = b; b = x; の
    // 代わりにswap(a,b)が使える
    swap(a, b);
  }
  if (b > c) {
    swap(b, c);
  }
  // なぜもう一度 a>bなのかは
  // 紙とペンで考えてみて
  if (a > b) {
    swap(a, b);
  }
  cout << a << " ";
  cout << b << " ";
  cout << c << endl;
}



Measured memory_bytes: 3096
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n ; 
	cin >> n ; 
	int t = n ; 
	int ans = 0 ; 
	while(t!=0){
		ans += t % 10 ; 
		t/=10; 
	}
	if ( n % ans == 0 ) {
		cout << "Yes" << endl;
	}
	else cout << "No" << 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;
using ll = long long;

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        int j = s.size()-1-i;
        if(s[i] != s[j] && i<=j)++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A1 = IL()
A2 = IL()
ans = []

P(max(sum(A1[:i+1]+A2[i:]) for i in range(N)))

Measured memory_bytes: 38512
n = gets.to_i
arr = gets.split.map(&:to_i)
res = 1
i = 0
while i < n do
  if i == 0
    i += 1
    next
  end
  j = i - 1
  while j >= 0 do
    unless arr[j] <= arr[i]
      res -= 1
      break
    end
    j -= 1
  end
  i += 1
  res += 1
end
puts res

Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     int a = scanner.nextInt();
     int b = scanner.nextInt();
     int d=a/b;
     int r=a%b;
     double f=(double)a/b;
       System.out.print(d+" "+r+" ");
        System.out.print(String.format("%f", f));
   }   
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  int n,k;
  cin >> n >>k;
  vector<int>l(n);
  rep(i,n)cin >> l[i];
  sort(l.begin(),l.end(),greater<int>());
  ll sum=0;
  rep(i,k)sum+=l[i];
  cout << sum << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000
#define THROW     goto TRY_TAG_ERROR
#define CATCH     TRY_TAG_ERROR:

int Calc(int n);
void Inc(int a[MAX], int tmp);
int Max(int a[MAX]);

int main (){

	int n, i, ans;

	if(scanf("%d", &n) != 1){
		scanf("%*s");
		THROW;
	}

	ans = Calc(n);

	if(ans == -1)
		THROW;

	printf("%d", ans);
	return 0;

	CATCH{
		puts("入力エラー\n");
		return -1;
	}
}

int Calc(int n){
	int i;
	int a[MAX] = {0};
	int tmp;

	for(i = 0; i < n; i++){
		if(scanf("%d", &tmp) != 1){
			scanf("%*s");
			return -1;
		}

		Inc(a, tmp);
	}

	return Max(a);
}

void Inc(int a[MAX], int tmp){

	if(tmp > 0)
		a[tmp-1]++;
	if(tmp < MAX)
		a[tmp+1]++;
	a[tmp]++;
		
	return;
}

int Max(int a[MAX]){
	int ans = 0, i;

	for(i = 0; i < MAX; i++){
		if(ans < a[i])
			ans = a[i];
	}

	return ans;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def psa(s: list) -> list:
    res = [0]
    for i in range(len(s)): res.append(res[i] + s[i])
    return res
(n, m, k), a, b = map(int, input().split()), list(map(int, input().split())), list(map(int, input().split()))
a, b, res, j = psa(a), psa(b), 0, m
for i in range(n + 1):
    if a[i] > k: break
    while b[j] > k - a[i]: j -= 1
    res = max(res, j + i)
print(res)

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"

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

  deque<int> que;

  rep0(i, q) {
    int query; cin >> query;
    if (query == 0) {
      int d, x; cin >> d >> x;
      if (d == 0) que.push_front(x);
      else que.push_back(x);

    } else if (query == 1) {
      int p; cin >> p;
      cout << que[p] << BR;

    } else {
      int d; cin >> d;
      if (d == 0) que.pop_front();
      else que.pop_back();
    }
  }

  return 0;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

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

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

str S;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> S;
	bool strong = true;
	str rev = S;
	reverse(all(rev));
	if (S != rev) strong = false;
	str fS = S.substr(0, (sz(S) - 1) / 2); 
	str fSRev = fS; reverse(all(fSRev));
	if (fS != fSRev) strong = false;
	str sS = S.substr((sz(S) + 3) / 2 - 1);
	str sSRev = sS; reverse(all(sSRev));
	if (sS != sSRev) strong = false;
	if (strong) cout << "Yes";
	else cout << "No";
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <typeinfo>

using Graph = std::vector<std::vector<std::pair<int, int>>>;

void print(std::vector<int> vec){
    int n = vec.size();
    for(int i = 0; i < n; ++i){
        std::cout << vec.at(i) << std::endl;
    }
}

void dfs(std::vector<int> &color, Graph &g, int v){
    for(auto nextE : g.at(v)){
        int nextV = nextE.first;
        if(-1 == color.at(nextV)){
            if(0 == nextE.second % 2){
                color.at(nextV) = color.at(v);
            }else{
                color.at(nextV) = 1 - color.at(v);
            }
        }else{
            continue;
        }

        dfs(color, g, nextV);
    }
}

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

    Graph g(n);
    int a, b, c;
    while(std::cin >> a >> b >> c){
        g.at(a - 1).push_back(std::make_pair(b - 1, c));
        g.at(b - 1).push_back(std::make_pair(a - 1, c)); // for undirected graph
    }
    
    std::vector<int> color(n, -1);
    for(int i = 0; i < n; ++i){
        if(-1 == color.at(i)){
            color.at(i) = 0;
            dfs(color, g, i); // <- ここがおかしい．0 で 0-index を初期化するなりの dfs を考えねばだめ
        }
    }

    print(color);

    return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    int N,K;
    double q = 0.0;
    cin >> N >> K;
    for(int i=1;i<=N;i++){
        int p=i;
        int count = 1;
        while(p < K){
            p *= 2;
            count *= 2;
        }
        q += 1.0 / count;
    }
    q /= N;
    cout << setprecision(20) << q << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580