akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#define NUM 100
using namespace std;
int process_time;

typedef enum
{
    PRE,
    NOW,
} NodeStatus;

struct Node
{
    int num;
    int *p;
    int d;
    int f;

    int status;
    void Set(int num);
};

void Node::Set(int n)
{
    this->num = n;
    this->status = PRE;
    p = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
}

void Search(Node *vertex, int start)
{
    stack<Node *> st;

    st.push(&vertex[start]);
    vertex[start].status = NOW;
    vertex[start].d = process_time;
    while (!st.empty())
    {
        process_time++;
        int k = st.top()->num;
        int i;
        for (i = 0; i < k; i++)
        {
            if (vertex[st.top()->p[i]].status == PRE)
            {
                break;
            }
        }
        if (i == k)
        {
            Node *v;
            v = st.top();
            st.pop();
            v->f = process_time;
        }
        else
        {
            st.push(&vertex[st.top()->p[i]]);
            st.top()->d = process_time;
            st.top()->status = NOW;
        }
    }
}

int main()
{
    int n;
    Node vertex[NUM];
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int k, u;
        cin >> u >> k;
        vertex[u].Set(k);
    }

    process_time = 1;
    Search(vertex, 1);

    int count;
    for (count = 1; count <= n; count++)
    {
        if (vertex[count].status == PRE)
        {
            break;
        }
    }
    if (count != n + 1)
    {
        process_time++;
        Search(vertex, count);
    }

    for (int i = 1; i <= n; i++)
    {
        cout << i << ' ' << vertex[i].d << ' ' << vertex[i].f << endl;
    }
    /*for (int i = 1; i <= n; i++) //1オリジン
    {
        for (int j = 0; j < vertex[i].num; j++)
        {
            cout << vertex[i].p[j] << ' ';
        }
        cout << endl;
    }*/

    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;

int main() {
	int n, p[100000],ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (p[i] ==i+1) {
			ans++;
			swap(p[i], p[i + 1]);
		}
	}
	if (p[n - 1] == n)ans++;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second
using namespace std;
const int MAXN = 200005;
const LL MOD = 998244353;
int n;
PII rob[MAXN];
LL dp[MAXN], stop[MAXN];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> rob[i].f >> rob[i].s;
    }
    sort(rob, rob + n);

    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        stop[i] = i + 1;
        while (stop[i] < n && rob[i].f + rob[i].s - 1 >= rob[stop[i]].f) {
            stop[i] = stop[stop[i]];
        }
        dp[i] = (dp[i + 1] + dp[stop[i]]) % MOD;
    }

    cout << dp[0] << '\n';
}


Measured memory_bytes: 4992
from collections import*
n,m,*t=map(int,open(0).read().split())
*w,s,t=[t-1for t in t]
e=[[]for _ in range(n)]
for u,v in zip(w[::2],w[1::2]):
  e[u].append(v)
INF=10**18
f=[[INF]*3for _ in range(n)]
f[s][0]=0
q=deque([(s,0)])
while q:
  v,m=q.popleft()
  if v==t and m==0:
    print(f[v][0]//3)
    break
  for w in e[v]:
    if f[w][-~m%3]<INF:continue
    f[w][-~m%3]=f[v][m]+1
    q.append((w,-~m%3))
else:
  print(-1)

Measured memory_bytes: 38068
#include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int MAX_INT = 1000000;
string name;
int C[301],V[301],D[301],L[301];
int dp[301][301][3];
int N,M;
int solve(int a,int b,int s);
int main(){
  while(cin >> N >> M){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++){
      cin.ignore();
      getline(cin,name);
      cin >> C[i] >> V[i] >> D[i] >> L[i];
    }
    cout << max(solve(0,M,0),max(solve(0,M,1),solve(0,M,2))) << endl;
  }
}
int solve(int a,int b,int s){
  if(dp[a][b][s] != -1)return dp[a][b][s];
  else {if(a==N)return 0;
    else if(b < C[a])return dp[a][b][s] = solve(a+1,b,s);
    else {
      if(s == 0)return dp[a][b][s] = max(solve(a+1,b-C[a],s)+V[a],max(solve(a,b-C[a],s)+V[a],solve(a+1,b,s)));
      else if(s == 1)return dp[a][b][s] = max(solve(a+1,b-C[a],s)+D[a],max(solve(a,b-C[a],s)+D[a],solve(a+1,b,s)));
      else return dp[a][b][s] = max(solve(a+1,b-C[a],s)+L[a],max(solve(a,b-C[a],s)+L[a],solve(a+1,b,s)));
    }
  }
}

Measured memory_bytes: 2312
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);

	long long n;
	long long sol = 0;

	scanf("%lld", &n);

	for (long long i = 1; i <= n; i++)
	{
		long long q = n / i;

		sol += i*q*(q + 1) / 2;
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>
#define SIZE 100
int main(void)
{
	int r, c, sum;
	int i, j;
	int vc[SIZE], vsum[SIZE];

	for (i = 0; i < SIZE; i++)
	{
		vc[i] = 0;
		vsum[i] = 0;
	}

	scanf("%d%d", &r, &c);

	for (i = 0; i < r; i++)
	{
		sum = 0;
		for (j = 0; j < c; j++)
		{
			scanf("%d", &vc[j]);
			sum += vc[j];
			vsum[j] += vc[j];
		}
		for (j = 0; j < c; j++)
			printf("%d ", vc[j]);
		printf("%d\n", sum);
	}

	sum = 0;
	for (j = 0; j < c; j++)
	{
		printf("%d ", vsum[j]);
		sum += vsum[j];
	}

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

	return 0;
}

Measured memory_bytes: 600
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int N = std.nextInt();
        int[] A = IntStream.range(0, N).map(it -> std.nextInt()).toArray();
        long minusCount = Arrays.stream(A).filter(it -> it < 0).count();
//        long BMax = 0;
        BigInteger BMax = BigInteger.valueOf(0L);
        if (minusCount % 2 == 0) {
            int[] s = Arrays.stream(A).map(Math::abs).toArray();
            for (int i = 0; i < s.length; i++) {
                BMax = BMax.add(BigInteger.valueOf(s[i]));
            }
        } else {
            int[] arrays = Arrays.stream(A).map(Math::abs).sorted().toArray();
            int min = arrays[0];
            for (int i = 1; i < arrays.length; i++) {
                BMax = BMax.add(BigInteger.valueOf(arrays[i]));
            }

            BMax = BMax.subtract(BigInteger.valueOf(min));
        }

        System.out.println(BMax.toString());
    }
}


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

int main()
{
    int w,a,b;
    cin >> w >> a >> b;
    if(a < b) cout << max(0, b - a - w) << endl;
    else cout << max(0, a - b - w) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn = 1e5+10;
const ll mod = 1e9+7;
ll pw(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1) res=res*x%mod;
		x=x*x%mod;
		y/=2;
	}
	return res;
}
ll inv(ll x)
{
	return pw(x,(ll)(mod-2));
}
ll a[maxn];
int n,m;
ll tmp1=1;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<m;i++) tmp1=tmp1*inv((ll)i)%mod;
	sort(a+1,a+1+n);
	ll tmp2=1;
	ll ans=0;
	ll tmp3;
	ll res;
	for(int i=2;i<=n;i++)
	{
		tmp2=tmp2*(ll)(i-1)%mod;
		if(i<m) continue;
		res=(ll)(i-m);
	    if(i-m>1) tmp2=tmp2*inv(res)%mod;   
		tmp3=tmp1*tmp2%mod;
	    ans=(ans+(a[i]+mod)%mod*tmp3%mod)%mod;
	}
	tmp2=1;
	for(int i=n-1;i;i--)
	{
		tmp2=tmp2*(ll)(n-i)%mod;
		if(n-i<m-1) continue;
		res=(ll)(n-i+1-m);
		if(n-i-m>0) tmp2=tmp2*inv(res)%mod;
		tmp3=tmp1*tmp2%mod;
		ans=(ans+(-a[i]+mod)%mod*tmp3%mod)%mod;
	}
	if(m==1) 
	printf("0");
	else
	printf("%lld",ans);
	return 0;
}

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

// i, j 番目までの文字列のLCS
int dp[3005][3005];

int main() 
{
    string s, t;
    cin >> s >> t;

    dp[0][0] = dp[0][1] = dp[1][0] = 0;
    for(int i=0; i<s.size(); i++) {
        for (int j=0; j<t.size(); j++) {
            if (s[i] == t[j]) dp[i+1][j+1] = 1 + dp[i][j];
            else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
        }
    }

    string str = "";
    int i = s.size();
    int j = t.size();
    while(i>0 && j >0) {
        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else if (dp[i][j] == dp[i-1][j-1]+1) {
            str += s[i-1];
            i--;j--;
        }
    }
    reverse(str.begin(), str.end());
    
    cout << str << endl;

    return 0;
}


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

    vector<ll> dp(n+k, 1e9);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
            // cout << "i " << i << " j: " << j << " dp[" << i+j << "]: " << dp[i+j] << endl;
        }
    }

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

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const ll mod = 1e9 + 7;
const int mxN = 200005;
ll h, w, a, b, ans, f[mxN], inv[mxN];
 
ll binpow(ll a, ll b)
{
	if (b == 0)	return 1;
	if (b % 2 == 0) {
		ll temp = binpow(a, b/2) % mod;
		return (temp * temp) % mod;
	}
	else {
		return binpow(a, b-1)*a % mod;
	}
}
 
ll inverse(ll n) {
	return binpow(n, mod - 2);
}
 
void fact() {
	f[0] = inv[0] = 1;
	for(ll i = 1; i < mxN; i++){
		f[i] = (f[i-1]*i)%mod;
		inv[i] = inverse(f[i]);
	}
}
 
ll calc(ll n, ll m) {
	return ((f[m]*inv[n]%mod)*inv[m-n])%mod;
}
 
signed main() {
	fact();
	cin >> h >> w >> a >> b;
	for(ll i = 0; i <= h - a; i++){
		ans += (calc(i-1,i+b-2)% mod * calc(h - i,h - i + w - b - 1)) % mod;
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+'){
        cout<<(a+b)<<endl;
    }
    else{
        cout<<(a-b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = a; i <b; i++)
#define forn(i,a,b) for (int i = a; i >b; i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


ll fact(ll n)
{
  if(n==0 || n==1)
  return 1;
  else
  return (n*fact(n-1)%mod)%mod;
}

int prime(ll n)
{
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;
    }
  }
  return 1;
}

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

ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int check_palin(string s)
{
  string str=s;
  reverse(str.begin(),str.end());
  if(str==s)
  return 1;
  else 
  return 0;
}

vector<ll> divisors(ll n)
{
  vector<ll> v;
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(i==n/i)
      v.PB(i);
      else
      v.PB(i),v.PB(n/i);
    }
  }
return v;
}

ll bin_expo(int x,int n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_expo(x*x,n/2);
    else                             //n is odd
        return x*bin_expo(x*x,(n-1)/2);
}

ll modular_expo(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modular_expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modular_expo((x*x)%M,(n-1)/2,M))%M;
}

// <----- Actual solve() function to print output -----> //
void solve()
{
  ll n,ans=0,z=0;
cin>>n>>z;
  int a[n];
  forp(i,0,n)
    cin>>a[i];
  
  sort(a,a+n);
  
  forp(i,0,z)
    ans+=a[i];
  cout<<ans;
        //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
    single_testcase_t   //Uncomment this if only single testcase & single answer to print
   // multiple_testcases_t  //Uncomment this if t>1(t is given in question)(multiple testcases)      
return 0;
}
            
            
            
            

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())

    edge = [[] for i in range(n+1)]
    for i in range(m):
        u,v = map(int,input().split())
        edge[u].append(v)

    s,t = map(int,input().split())

    fi = [True]*(n+1)
    se = [True]*(n+1)
    th = [True]*(n+1)
    th[s] = False

    now = [s]
    tank = []
    cnt = 0

    while len(now) != 0:
        cnt += 1
        tank = []
        tank2 = []
        tank3 = []
        for e in now:
            for a in edge[e]:
                if fi[a]:
                    fi[a] = False
                    tank2.append(a)

        for e in tank2:

            for a in edge[e]:
                if se[a]:
                    se[a] = False
                    tank3.append(a)
        
        for e in tank3:
            for a in edge[e]:
                if th[a]:
                    th[a] = False
                    tank.append(a)
                if a == t:
                    print(cnt)
                    exit()

        now = tank
    print(-1)

if __name__ == '__main__':
    main()

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

using namespace std;

int main(void) {
    int r;
    string s;
    cin >> r;
    if (r < 1200) {
        s = "ABC";
    } else if (r < 2800) {
        s = "ARC";
    } else {
        s = "AGC";
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}
constexpr LL INF = 1LL << 60;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VVLL dp(n, VLL(2, -INF));
    dp[0][0] = a[0];
    REP(i,1,n) {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]) + a[i];
        dp[i][1] = max(dp[i-1][0] - 2 * a[i-1], dp[i-1][1] + 2 * a[i-1]) - a[i];
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main() {
  string s;
  cin >> s;
  if (s.at(s.size()-1) == 's') cout << s << "es" << endl;
  else cout << s << "s" << endl;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		try (Stream<String> lines = new BufferedReader(new InputStreamReader(System.in)).lines()) {
			new Main().exec(lines.toArray(String[]::new));
		}
	}

	void exec(String[] args) {
		int N = Integer.parseInt(args[0].split(" ")[0]);
		Map<Integer, Set<Integer>> map = new HashMap<>();
		IntStream
			.range(1, args.length)
			.mapToObj(i -> Stream
				.of(args[i].split(" "))
				.map(Integer::valueOf)
				.toArray(Integer[]::new))
			.forEach(is -> map.computeIfAbsent(is[0], i -> new HashSet<>()).add(is[1]));
		int[] a = IntStream
			.rangeClosed(1, N)
			.map(i -> !map.containsKey(i) ? -1 : map.get(i).size() != 1 ? 10 : map.get(i).toArray(new Integer[1])[0])
			.toArray();
		System.out.println(N > 1 && a[0] == 0 || IntStream.of(a).anyMatch(i -> i > 9) ? -1 : IntStream
			.range(0, N)
			.map(i -> (int)(Math.max(a[i], N > 1 && i == 0 ? 1 : 0) * Math.pow(10, N - i - 1)))
			.sum());
	}

}

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  map<string,int> mp;
  for(int i=0;i<=n-1;i++){ //始点
    for(int j=1;j<=n-i;j++){ //いくつ取り出すか
      string tmp = s.substr(i,j);
      if(tmp.size() <= k) mp[tmp] ++;
    }
  }
  vector<string> l(0);
  for(auto p : mp) l.push_back(p.first);
  sort(l);
  cout << l[k-1] << endl;
}

Measured memory_bytes: 2176
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	int reach;
	cin >> reach;
	int cur = 0, sum = 0;
	while (true) {
		cur++;
		sum += cur;
		if (sum >= reach) {
			cout << cur;
			return 0;
		}
	}
}


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

int main() { 
  int H,W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    cout << '#' << s << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}
      

Measured memory_bytes: 256
import qualified Data.Text as T
import Debug.Trace

main = do
    n <- readLn :: IO Int
    hs <- map read . words <$> getLine :: IO [Int]
    print $ solve 0 hs

solve :: Int -> [Int] -> Int
solve n hs = case hasZero of
    -- True -> trace ("spl : " ++ show splitted)$ foldl solve n splitted 
    True -> foldl solve n splitted 
        where 
            splitted = filter (/=[]) $ map (filter (/=0)) $ split hs [[0]]
    False -> solve n (waterALL hs) + 1 
    where 
        hasZero = 0 `elem` hs


waterALL :: [Int] -> [Int]
waterALL [] = []
waterALL (x:xs) = (x-1) : waterALL xs

split :: [Int] -> [[Int]] -> [[Int]]
split [] res = res
-- split (x:xs) ([]) = if x /= 0 then split xs [[x]] else split xs []
split (x:xs) (y:ys) = if x /= 0 then split xs ((x:y):ys) else split xs ([0]:y:ys) 


Measured memory_bytes: 1020
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll ideg[100010];//入次数

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	ll vcnt,ecnt;
	E  e[200010];//適宜変える
	ll id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,n+m-1){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[i].s=x;
		g.e[i].g=y;
		ideg[y]++;
	}
	g.vcnt=n;
	g.ecnt=n+m-1;
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//一応番兵
}

ll st[100010],ptr;//トポソした結果
void toposo(){
	rep(i,0,g.vcnt)if(ideg[i]==0)st[ptr++]=i;
	rep(i,0,g.vcnt){
		ll v=st[i];
		rep(j,g.id[v],g.id[v+1]){
			ideg[g.e[j].g]--;
			if(ideg[g.e[j].g]==0)st[ptr++]=g.e[j].g;
		}
	}
}

int flag[100010];
int dp[100010];
ll calc(int k){
	if(flag[k])return dp[k];
	flag[k]=1;
	ll ans=0;
	rep(i,g.id[k],g.id[k+1]){
		ll temp=calc(g.e[i].g)+1;
		ans=max(ans,temp);
	}
	return dp[k]=ans;
}

int ans[100010];
int cnt[100010];
int main(){
	readgraph();
	toposo();
	rep(i,0,g.vcnt)calc(st[i]);
	rep(i,0,g.ecnt){
		if(!ans[g.e[i].g]||dp[g.e[i].s]<cnt[g.e[i].g]){
			ans[g.e[i].g]=g.e[i].s+1;
			cnt[g.e[i].g]=dp[g.e[i].s];
		}
	}
	rep(i,0,g.vcnt)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 12512
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np
#import sympy

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    s = str(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if s[-1] != "s":
        print(s + "s")
    else:
        print(s + "es")

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9108
#include <iostream>

using namespace std;
typedef long long ll;
ll n,seg[600010],INF = 1000000000000;
void init(){
    for(int i=n - 1;i>0;i--){
        seg[i] = max(seg[i<<1],seg[i<<1|1]);
    }
}

void update(int p,ll val){
    for(seg[p += n] = val;p>1;p>>=1){
        seg[p>>1] = max(seg[p],seg[p^1]);
    }
}

ll query(int l,int r){
    ll res = 0;
    for(l += n,r += n; l<r;l>>=1,r>>=1){
        if(l&1) res = max(res,seg[l++]);
        if(r&1) res = max(res,seg[--r]);
    }
    return res;
}
int a[300010];
int main(){
    int i,m,k; cin >> m >> k;
    n = 300001;
    for(i=0;i<m;i++) cin >> a[i];
    for(i=0;i<m;i++){
        int l = max(0,a[i] - k),r = min(a[i] + k,300000);
        int c = query(l,r + 1);
        update(a[i],c + 1);
    }
    cout << query(0,n) << endl;
}

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

int main() {
    string S;
    cin >> S;
    bool flag = true;
    for (int i = 0; i < S.length(); i++){
        for (int j = i + 1; j < S.length(); j++){
            if (S[i] == S[j]){
                flag = false;
                cout << "no" << endl;
                break;
            }
        }
        if (flag == false) {
            break;
        }
    }
    if (flag) {
        cout << "yes" << endl;
    }
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int n, int s) {
    int ans = 0;
    foreach (e; combinations(iota(10).array, n)) {
        if (e.sum == s)
            ans++;
    }
    return ans;
}

void main() {
    while (true) {
        auto xs = readints;
        int n = xs[0], s = xs[1];

        if (n == 0 && s == 0) break;
        writeln(calc(n, s));
    }
}

Combinations!T combinations(T)(T[] xs, int n) {
    return Combinations!T(xs, n);
}

struct Combinations(T) {
    private T[] _source;
    private int _n;
    private T[][] _q;
    private int _state;

    this(T[] source, int n) {
        _source = source.dup;
        _n = n;
        _state = 0;

        pushNext();
    }

    @property T[] front() {
        return _q[0];
    }

    void popFront() {
        _q = _q[1..$];
        pushNext();
    }

    bool empty() {
        return _q.length == 0;
    }

    private void pushNext() {
        int len = cast(int)_source.length;
        while (_state < (1 << len)) {
            int[] buf;
            for (int j = 0; j < len; j++) {
                if (_state & (1 << j)) {
                    buf ~= _source[j];
                    if (buf.length > _n) break;
                }
            }

            _state++;
            if (buf.length == _n) {
                _q ~= buf;
                return;
            }
        }
    }
}



Measured memory_bytes: 3040
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

vector<vector<ll>> ki(100);
bool seen[100];
ll c;

void gra(ll i){
    for(ll j=0;j<ki[i].size();j++){
        if(seen[ki[i][j]]==false){
            seen[ki[i][j]]=true;
            c++;
            gra(ki[i][j]);
        }
    }
}

int main(){
    ll n,m;cin>>n>>m;
    ll a[m],b[m];
    for(ll i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    ll ans=0;
    for(ll j=0;j<m;j++){
        for(ll i=1;i<=n;i++){
            ki[i].clear();
        }
        c=0;
        for(ll i=1;i<=n;i++){
            seen[i]=false;
        }
        for(ll i=0;i<m;i++){
            if(i!=j){
                ki[a[i]].push_back(b[i]);
                ki[b[i]].push_back(a[i]);
            }
        }
        gra(1);
        if(c<n){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-11-01
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b){
    a += b;
    if (a >= md) a -= md;
}

inline void sub(int &a, int b){
    a -= b;
    if (a < 0) a += md;
}

inline int mul(int a, int b){
    return (int) ((ll) a * b % md);
}

inline int power(int a, long long b){
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

inline int dive(int a, int b){
    return mul(a, power(b, md - 2));
}

int main(){

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

    int N; cin >> N;
    int ans = 0;
    if(N % 2 == 1) ans = power(2,(N-1)/2);
    else ans = power(2,N/2);

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

    if(N % 2 == 1){
        for (int i = 0; i < N/2 + 1; ++i) {
            if(i == 0 && A[i] != 1){
                cout << 0 << "\n";
                return 0;
            }else if(i != 0 && i % 2 == 0 && A[i] != 2){
                cout << 0 << "\n";
                return 0;
            }
        }
    }else {
        for (int i = 0; i < N/2 + 1; ++i) {
            if(i % 2 == 1 && A[i] != 2){
                cout << 0 << "\n";
                return 0;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 x;

i32 main()
{
    cin >> x;
    i32 acc = 0;
    upto(1, x, i) {
        acc += i;
        if (acc >= x) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=max(map(int,input().split()))
y=min(map(int,input().split()))
P=0
for i in range(X+1,Y+1) :
  if X < i and i <=Y and x < i and i <= y :
    print("No War")
    break
else:
  print("War")

Measured memory_bytes: 3064
import qualified Control.Monad as C
import qualified Data.List as L

main :: IO ()
main = do
 n <- read <$> getLine :: IO Int
 ns <- map fst . filter (\(_, n) -> mod n 2 == 1) . map (\l->(head l, length l)) . L.group . L.sort <$> C.replicateM n (read <$> getLine) 
        :: IO [Int]
 print $ length ns


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

#n,m = 3,2
#a = [380,19,1]

x = sum(a) / (4*m)

b = [i for i in a if i >= x]

if len(b) >= m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9080
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
  char s;
  int ans[30] = {};
  while (cin >> s){
    s = tolower(s);
    if (isalpha(s)){
      ans[s - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++){
    printf("%c : %d\n", 'a' + i, ans[i]);
  }
  
  return 0;
}


Measured memory_bytes: 3136
function floor_sum(n, m, a, b)
  ans = 0
  if a >= m
    ans += (n - 1) * n * (a ÷ m) ÷ 2
    a %= m
  end
  if b >= m
    ans += n * (b ÷ m)
    b %= m
  end
  y_max = (a * n + b) ÷ m
  x_max = (y_max * m - b)
  if y_max == 0; return ans; end
  ans += (n - (x_max + a - 1) ÷ a) * y_max
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
  return ans
end
function main()
  for i=1:parse(Int,readline())
    println(floor_sum(parse.(Int,split(readline()))...))
  end
end
main()

Measured memory_bytes: 205524
from typing import List, Any
import math
import sys
input = sys.stdin.readline

class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = max(self.array[i<<1], self.array[i<<1|1])

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = max(self.array[p<<1], self.array[p<<1|1])

    def max(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer = max(answer, self.array[l])
                l += 1
            if r&1:
                r -= 1
                answer = max(answer, self.array[r])
            l >>= 1
            r >>= 1
        return answer


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N, K = read_ints()
    A = [read_int() for _ in range(N)]
    maxA = max(A)
    segment_tree = SegmentTree([0]*(maxA+1))
    for a in A:
        count = segment_tree.max(max(0, a-K), min(maxA, a+K)+1)
        segment_tree.set(a, count+1)
    return segment_tree.max(0, maxA+1)


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 116632
using System;

public class p0000{
	p0000(){
		for(int i = 1; i <= 9; ++i)
			for(int j = 1; j <= 9; ++j)
				Console.WriteLine("{0}x{1}={2}", i, j, i*j);
	}
	
	public static int Main(string[] args){
		new p0000();
		return 0;
	}
}

Measured memory_bytes: 5600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll h,w;
int main(){
	scanf("%lld%lld",&h,&w);
	if(h==1||w==1) printf("1\n");
	else printf("%lld\n",h/2*w+h%2*(w+1)/2);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[11],i,j,n,k,s,t=0,u=1;
  int b[10];
  a[0]=0;
  scanf("%d %d",&n,&k);
  for(i=0;i<10;i++)b[i]=1;
  for(i=0;i<k;i++){scanf("%d",&s);b[s]=0;}
  for(i=0;i<10;i++)if(b[i]){a[u]=i;u++;}
  k=10-k;
  for(i=0;i<5;i++)b[i]=0;
  while(1){
    t=a[b[0]]+a[b[1]]*10+a[b[2]]*100+a[b[3]]*1000+a[b[4]]*10000;
    if(t>=n){printf("%d",t);return 0;}
    b[0]+=1;
    for(i=0;i<5;i++)if(b[i]>k){b[i]=1;b[i+1]++;}
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    cin >> A;

    auto containOdd = [&]() {
        REP(i, N) {
            if (A[i] % 2 == 1)return true;
        }
        return false;
    };

    if (!containOdd()) {
        if (P == 0) {
            cout << (ll)pow(2, N) << endl;
        }
        else {
            cout << 0 << endl;
        }
        return 0;
    }

    cout << (ll)pow(2, N - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    
    ll pre = 0;
    rep(i,n){
        if(pre < h[i]){
            pre = h[i] - 1;
        } else if(pre > h[i]){
            cout << "No" << endl;
            return 0;
        } else {
            pre = h[i];
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3996
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> lst = new ArrayList<Integer>();
		for(int i = 1; i <= 2*n ; i++) {
			lst.add(sc.nextInt());
		}
		Collections.sort(lst);
		int sum = 0;
		for(int i=0; i<2*n;i+=2) {
			sum+=lst.get(i);
		}
		System.out.println(sum);
	}

}

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

int main (){
  string a , b[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"} ;
  cin >> a ;
  int pre = 10;
  for(int i = 0 ; i < 7; i++){
    if(a==b[i]){
      pre = i ;
      break ;
    }
  }
  cout << 7 - pre << endl ;
}

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;

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

	string s;
	cin >> s;

	for(char c : s){
		if(c == '9'){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, C, ans;
int a, b, c;
vector<int> in[N];
ii m[N];
int k;

int main() {
    cin >> n >> C;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b >> c;
        in[i] = {c, a, b};
    }
    sort(in, in + n);
    vector<int> &last = in[0];
    for (int i = 1; i < n; ++i) {
        vector<int> &cur = in[i];
        if (cur[0] == last[0] && cur[1] == last[2]) {
            last[2] = cur[2];
        } else {
            m[k++] = {last[1], last[2]};
            last = cur;
        }
    }
    m[k++] = {last[1], last[2]};
    priority_queue<int, vector<int>, greater<int>> que;
    sort(m, m + k);
    for (int i = 0; i < k; ++i) {
        int start = m[i].first;
        int end = m[i].second;
        if (!que.empty() && que.top() < start) {
            que.pop();
            que.push(end);
        } else {
            que.push(end);
        }
        int cnt = que.size();
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            
            List <string> s = new List<string>();
            string str;
            for(int i = 0; i < n ; i++)
            {
                str = Console.ReadLine();
                if(!s.Contains(str)) s.Add(str);
            }
            
            Console.WriteLine(s.Count);
            
        }
    }
}

Measured memory_bytes: 13148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char s[100000];
  scanf("%s\n",s);
  int sl = strlen(s);
  int a[sl]={}; int r=0; int l=0; int i=0; int ii;

  while(i<sl){
      if(s[i] == 'R'){
         r++;
         i++;
      }else{
          ii=i;
          while(s[i] == 'L'){
             l++;
             i++;
          }
          a[ii-1] += ((r+1)/2)+(l/2);
          a[ii] += (r/2)+((l+1)/2);
          r=0; l=0;
      }
  }
 
for(int j=0; j<sl; j++){
    printf("%d ",a[j]);
}
return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    int K; cin >> K;

    while( K > 0){
        if(A >= B){
            B *= 2;
        }else if(A >= C){
            C *= 2;
        }else if( B >= C){
            C *= 2;
        }
        K--;
    }

    string ans = "No";
    if( A < B && B < C){
        ans = "Yes";
    }

    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, long long> cnt;
    for(int i=0;i<N;i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    long long total = 0;
    for (auto it = cnt.begin();it != cnt.end();it++){
        long long v = it->second;
        total += v*(v-1)/2;
    }
    for(int i=0;i<N;i++) {
        long long c = cnt[A[i]];
        cout << total - c*(c-1)/2 + (c-1)*(c-2)/2 << endl;
    }
}

Measured memory_bytes: 10240
#include<stdio.h>
#define ll long long
int main(){
    int n;
    scanf("%d",&n);
    ll d[n];
    for(int i = 0; i < n; i++)
        scanf("%lld",&d[i]);
    int ans = 0;
    for(int i = n - 1; i > 0; i--){
        if(d[i] - d[i - 1] >= 0)
            ans ++;
        else if(d[i] - d[i - 1] == -1){
            ans ++;
            d[i - 1]--;
        }
    }
    if(ans == n - 1)
        puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 896
import math

isPrime = [True] * 1000000
primes = []
def eratos(n):
    isPrime[0] = isPrime[1] = False
    for i in range(2,int(math.sqrt(n))):
        if isPrime[i]:
            j = 2 * i
            while j <= n:
                isPrime[j] = False
                j = j + i
eratos(999999)

while True:
    try:
        num = int(input())
        ans = 0
        for i in range(0,num + 1):
            if isPrime[i]:
                ans += 1
        print(ans)
    except:
        break


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

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

int main(void){
    Cin(int, n, m);
    vc<pair<int, int>> t(n);
    For(i, n){
        cin >> t[i].first >> t[i].second;
    }
    Sort(t);
    // For(i, n) printf("%d %d\n", t[i].first, t[i].second);
    
    ll ans = 0;
    priority_queue<int> q;
    int i = 0;
    for(int d = 1; d <= m; d ++){
        while(i < n && t[i].first <= d) q.push(t[i].second), i ++;
        if(!q.empty()){
            ans += q.top();
            // Cout(d, " ", q.top());
            q.pop();
        }
    }
    Cout(ans);
}


Measured memory_bytes: 1660
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N, A[Nmax], B[Nmax];
ll K;

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];

	vector<pair<int, int> > v;
	for(int i=0; i<N; i++) v.push_back({A[i], B[i]});
	sort(v.begin(), v.end());

	vector<ll> c(N);
	c[0] = v[0].second;
	for(int i=1; i<N; i++) c[i] = c[i-1]+v[i].second;

	auto k = lower_bound(c.begin(), c.end(), K);
	cout << v[k-c.begin()].first << endl;

	return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int N;
    int H,W;
    cin >> N >> H >> W;
    int a = N - H+1;
    int b = N-W +1;
    int ans = a*b;
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<utility>
const int N=5e5+6;
std::pair<double,int>q[N];
int n,L,dlt,H,T;long long v;
double all,t;
int main(){
	scanf("%d%d%lf%d",&n,&L,&t,&v);
	printf("%.13f\n",t);
	q[0]=std::make_pair(t,v);
	all=t*v;
	for(int i=2;i<=n;++i){
		scanf("%lf%lld",&t,&v);
		dlt=v;
		while(dlt)if(dlt<q[H].second)all-=q[H].first*dlt,q[H].second-=dlt,dlt=0;else
		all-=q[H].first*q[H].second,dlt-=q[H++].second;
		while(H<=T&&t<q[T].first)all-=q[T].first*q[T].second,t=(t*v+q[T].first*q[T].second)/(v+q[T].second),v+=q[T--].second;
		q[++T]=std::make_pair(t,v);
		all+=t*v;
		printf("%.13f\n",all/L);
	}
	return 0;
}

Measured memory_bytes: 19712