akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, a, b, sumA, sumB;
		while((n = sc.nextInt()) != 0){
			sumA = sumB = 0;
			for(int i = 0; i < n; i++){
				a = sc.nextInt();
				b = sc.nextInt();
				if(a > b){
					sumA += a + b;
				}else if(a < b){
					sumB += a + b;
				}else{
					sumA += a;
					sumB += b;
				}
			}
			System.out.println(sumA + " " + sumB);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int bord[11][5];
int H;
void solve(){
  int score = 0;
  int comboStart;
  int comboEnd;
  int tmp;
  bool combo ;

  while(true){
    //combo_check
    // cout << endl << "score =" << score << endl;
    // for(int height = H-1 ;height >= 0 ; height--){
    //   for(int width = 0; width < 5; width++){
    //     cout << bord[height][width] << " ";
    //   }
    //   cout << endl;
    // }
    combo = false;
    for(int height = H - 1 ;height >= 0 ; height--){
      for(int width = 2; width < 5; width++){
        if(bord[height][width-2] == bord[height][width-1] && bord[height][width-1] ==  bord[height][width] && bord[height][width] != -1 &&bord[height][width] != 0){
          combo = true;
          //combo 長さ確認
          comboStart = width - 2;
          comboEnd = width;
          while(true){//combo 長さ決定
            if(comboEnd+1 < 5 && bord[height][comboEnd] == bord[height][comboEnd+1]){
              comboEnd++;
            }else{
              break;
            }
          }

          score += bord[height][comboStart] * (comboEnd - comboStart + 1);
          for(int w = comboStart; w <= comboEnd; w++) bord[height][w] = -1;
        }
      }
    }
    if(!combo) break; //これ以上コンボが無いなら終了

    //コンボしたブロックをずらす
    for(int height = 0 ;height < H ; height++){
      for(int width = 0; width < 5; width++){
        if(bord[height][width] == -1){
          for(int h = height ; h < H; h++){
            bord[h][width] = bord[h+1][width];
          }
          height -- ;
        }
      }
    }
  }
  cout << score << endl;
  for(int height = 0 ;height < 11 ; height++){
    for(int width = 0; width < 5; width++){
      bord[height][width] = 0;
    }
  }
}

int main(){
  while(true){
    cin >> H;
    if(H == 0)break;
    for(int height = H - 1 ;height >= 0 ; height--){
      for(int width = 0; width < 5; width++){
        cin >> bord[height][width];
      }
    }
    solve();
  }
  return 0;
}



Measured memory_bytes: 3072
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1000
    for i in range(1, N):
        x, y = A[i-1], A[i]
        if (x < y):
            ans = y*(ans//x) + ans % x
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
using namespace std;
ll N, M, Q, ans;
vector<ll> NumArray(10);
vector<ll> A(50),B(50),C(50),d(50);

void dfs(int start, int n){
    if ( n == N ){
        ll Score = 0;
        REP(ll,k,0,Q){
            if ( NumArray.at(B.at(k)-1) - NumArray.at(A.at(k)-1) == C.at(k) ){
                Score += d.at(k);
            }
        }
        ans = max(ans,Score);
        return;
    }
    for ( int i = start; i <= M; i++ ){
        NumArray.at(n) = i;
        dfs(i,n+1);
    }
}

int main (void) {
    cin >> N >> M >> Q;

    REP(ll,i,0,Q){
        cin >> A.at(i) >> B.at(i) >> C.at(i) >> d.at(i);
    }
    ans = 0;
    dfs(1,0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K, L;
    cin >> N >> K >> L;
    vvc<ll> GK(N), GL(N);
    rep(i, K) {
        ll p, q;
        cin >> p >> q;
        p--, q--;
        GK[p].eb(q), GK[q].eb(p);
    }
    rep(i, L) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        GL[a].eb(b), GL[b].eb(a);
    }

    ll cnt = 0;
    auto dfs = [&](auto&& dfs, ll& now, vvc<ll>& G, vl& D, vc<bool>& used) -> void{
        used[now] = true;
        D[now] = cnt;
        repa(to, G[now]) {
            if (used[to]) continue;
            used[to] = true;
            dfs(dfs, to, G, D, used);
        }
    };

    vl DK(N), DL(N);
    vc<bool> useK(N), useL(N);

    rep(i, N) if (!useK[i]) dfs(dfs, i, GK, DK, useK), cnt++;
    cnt = 0;
    rep(i, N) if (!useL[i]) dfs(dfs, i, GL, DL, useL), cnt++;


    map<pair<ll, ll>, ll> mp;
    vl ans(N);
    rep(i, N) mp[{DK[i], DL[i]}]++;
    rep(i, N) ans[i] = mp[{DK[i], DL[i]}];

    rep(i, N) cout << ans[i] << (i == N - 1 ? '\n' : ' ');
}

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

#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)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll MOD = 998244353;

const int MAXN = 2e5 + 10;
vll fact (MAXN);
vll invfact (MAXN);
vll inv (MAXN);

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        res %= MOD;
        a = a * a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}

ll choose(ll n, ll k) {
    return fact[n] * invfact[k] % MOD * invfact[n-k] % MOD;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	fact[0] = 1;
    FOR(i, 1, MAXN) fact[i] = fact[i-1] * i % MOD;

    inv[1] = 1;
    FOR(i, 2, MAXN) inv[i] = (MOD - (MOD/i) * inv[MOD%i] % MOD) % MOD;

    invfact[0] = 1;
    FOR(i, 1, MAXN) invfact[i] = invfact[i-1] * inv[i] % MOD;

	ll N, M, K; cin >> N >> M >> K;

	ll ways = 0;
	F0R(k, K+1) {
		ways += choose(N-1, k) * M % MOD * binpow(M-1, N-k-1) % MOD;
		ways %= MOD;
	}
	print(ways);
}

Measured memory_bytes: 7868
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

a,b,c = map(int, input().split())
if a + b + c >= 22:
  print('bust')
else:
  print('win')


Measured memory_bytes: 13896
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll x;
  cin >> x;
  if(x>=1200){
    print("ARC");
  }
  else{
    print("ABC");
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int*t,n,m,d,i,s[99999];
main(){
	for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){
		for(;--i;)
			scanf("%d",s+i);
		for(std::sort(s,s+n);m--;i+=std::min(*t - d, d - t[-1] ))
			scanf("%d",&d),
			t = std::upper_bound( s, s+n, d );
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

ll c, d;

ll f(ll x){
    ll ret = x - ((x / d) + (x / c));
    ret += x / (c * d / __gcd(c, d));
    return ret;
}

int main(){
    ll a, b;
    cin >> a >> b >> c >> d;
    cout << f(b) - f(a - 1); 
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
static long ans = 0;
static String string;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		
		string = sc.next();
		dfs(1,0,0);
		System.out.println(ans);
		
		
	}
	
	static void dfs(int p,long sum,int kireme){
		long num =  Long.parseLong(string.substring(kireme, p));	
	//	System.out.println(" p "+p);
	//	System.out.println(num);

		if(p == string.length()){
			ans += sum+num;
			return;
		}
		
		
		dfs(p+1, sum,kireme);
		
		dfs(p+1, sum+num,p);

		
		
		
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <bitset>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr if(true) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }

ll solve(long long n, vector<long long> a , bool f){
	ll ans = 0;
	ll add = 0;

	REP(i,n){
		add += a[i];

		bool need = f ^ (i % 2 == 0);
		bool p = add > 0;

		if(add == 0){
			if(need)add++;
			else add--;
			ans++;continue;
		}

		if(p != need){
			if(need){
				ans += abs(add)+1;
				add += abs(add)+1;
			}else{
				ans += abs(add)+1;
				add -= abs(add)+1;
			}
		}
	}

	return ans;
}




int main(){
	ios::sync_with_stdio(false);
	long long n;
	cin >> n;
	vector<long long> a(n-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		cin >> a[i];
	}
	ll ans = min(solve(n, a,true),solve(n, a,false));

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


Measured memory_bytes: 2560
import math

a=input().rstrip().split(" ")
n=int(a[0])
m=int(a[1])
sum=0
if(n==1 and m==1):
    print(1)
elif(n==2 or m==2):
    print(0)
elif(n==1 or m==1):
    print(n*m-2)
else:
    print((n-2)*(m-2))



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

int main() {
    std::string a, b, c;
    std::cin >> a >> b >> c;

    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;


#define int long long

typedef long long ll;

const int N = 3009;
const int MOD = 998244353;


int add(int a, int b) {
    ll res = (ll)a + b;
    return res % MOD;
}

int sub(int a, int b) {
    ll res = (ll)a - b;
    res %= MOD;
    res += MOD;
    return res % MOD;
}

int mul(int a, int b) {
    ll res = (ll)a * b;
    return res % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int dp[N][N];

int a, b, c, d;

int solve(int f, int s) {
	if (f < a || s < b) return 0;
	if (dp[f][s] == -1) {
		dp[f][s] = 0;
		dp[f][s] = add(dp[f][s], mul(s, solve(f - 1, s)));
		dp[f][s] = add(dp[f][s], mul(f, solve(f, s - 1)));
		dp[f][s] = sub(dp[f][s], mul(mul(f - 1, s - 1), solve(f - 1, s - 1)));
	}
	return dp[f][s];
}

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

	cin >> a >> b >> c >> d;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = -1;
		}
	}
	dp[a][b] = 1;
	cout << solve(c, d) << endl;
	// cout << C(c * d - a * b, c + d - a - b) << endl;
}

Measured memory_bytes: 74148
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        var t = a.Sum() - a[n - 1];
        if (a[n - 1] < t) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm> // std::sort(begin,end)
#include <utility> // std::swap

using namespace std;
using ll = long long;

int main(int argc, char const* argv[])
{
  int a, n;

  cin >> a >> n;

  cout << (a*3+n)/2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main() {


   int n;
   cin>>n;
    string S,T;
    cin>>S;
    cin>>T;
    char c,m;

for(int i=0;i<n;i++){
    c=S[i];
    m=T[i];
    cout<<c<<m;
   }


        return 0;
}

Measured memory_bytes: 3568
import datetime
 
days = [
    'Monday',
    'Tuesday',
    'Wednesday',
    'Thursday',
    'Friday',
    'Saturday',
    'Sunday'
        ]
 
while True:
    m, d = map(int, input().split(' '))
    if m == 0: break
    print(days[datetime.date(2004, m, d).weekday()])

Measured memory_bytes: 8076
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int INF = 1 << 30;
int n,m,r;
vector<vector<int>> d;


void warshall_floyd(int n){ //nはノード数
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        if(d[j][i] == INF || d[i][k] == INF) continue;
        d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
}


int main(){
  cin >> n >> m >> r;
  vector<int> need(r);
  rep(i,r){
    cin >> need[i]; need[i]--;
  }
  
  d.resize(n,vector<int>(n,INF));
  rep(i,n) d[i][i] = 0;
  
  rep(i,m){
    int from,to,cost; cin >> from >> to >> cost;
    from--;to--;
    d[from][to] = cost;
    d[to][from] = cost; //無向グラフなら
  }
  
  warshall_floyd(n);
  
  sort(need.begin(),need.end());
  
  int ans = INF;
  do{
    int from,to,cost=0;
    rep(i,r){
      if(i==0){
        from = need[i];
      }else{
        to = need[i];
        cost += d[from][to];
        from = to;
      }
    }
    chmin(ans,cost);
  }while(next_permutation(need.begin(), need.end()));// 次の順列を生成
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            int ans = 0;

            boolean ok = false;
            int day = S.length();
            for (int i = 0; i < day; i++) {
                if (S.charAt(i) == 'o') ans++;
            }
            ans += 15 - day;
            if (ans >= 8) ok = true;


            out.println(ok ? "YES" : "NO");

        }

    }
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;cin>>n;
  if(n<=1){cout<<0<<endl;return 0;}
  int64_t tmp1=1,tmp2=1,tmp3=1,mod=1000000007;
  for(int i=0;i<n;i++){
    tmp1*=10;
    tmp1%=mod;
    tmp2*=9;
    tmp2%=mod;
    tmp3*=8;
    tmp3%=mod;
  }
  tmp2*=2;tmp2%=mod;
  tmp1-=tmp2;
  if(tmp1<0)tmp1+=mod;
  int64_t ans=(tmp1+tmp3)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a); i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"debug"<<endl
 
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int NINF = 0x3f3f3f40;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0x3f3f3f3f3f3f3f40;
const int mxN = 200001;
int n;
string s;
ll ans = 0;
int res[mxN];
int arr[mxN];
ll go(int cnt) {
    ll curr= 0;
    owo(i, 0, cnt) {
        curr = (curr*2+arr[i])%MOD;
    }
    string firstn = s.substr(0, cnt);
    string firstr;
    owo(i, 0, cnt) {
        firstr.append(firstn[i%cnt]=='0' ? "1" : "0");
    }
    string entire;
    for(int i=0; i*cnt<n; i++) {
        if(i&1) {
            entire.append(firstr);
        }else {
            entire.append(firstn);
        }
    }
    //cout<<cnt<<"\n";
    //cout<<entire<<"\n";
    curr+=(entire<=s);
    //cout<<curr<<"\n";
    return curr;
}
int main()
{
    //freopen("filename.in", "r", stdin);
    //freopen("filename.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>s;
    owo(i, 0, n) {
        arr[i] = s[i]=='1';
    }
    owo(i, 1, n+1) {
        if(n%i==0&&((n/i)&1)) {
            res[i]=(res[i]+ go(i));
            for(int j=2*i; j<n+1; j+=i) {
                res[j] = (res[j]+MOD-res[i])%MOD;
            }
            ans = (ans+res[i]*2LL*i)%MOD;
        }
    }
    cout<<(ans<0 ? ans+MOD : ans)<<"\n";
    return 0;
}


Measured memory_bytes: 5896
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
typedef pair<ll,ll> P;
ll flower[105];
ll water(int r,int l){
    ll a = INF;
    if (r == l) return 0;
    FOR(i,r,l){
        if (flower[i] == 0){
            return water(r,i)+water(i+1,l);
        }
        else{
            chmin(a,flower[i]);
        }
    }
    FOR(i,r,l) flower[i] -= a;
    return water(r,l)+a;
}
int main(){
    ll n,h;
    cin >> n;
    rep(i,n){
        cin >> h;
        flower[i] = h;
    }
    PRINT(water(0,n));
}


Measured memory_bytes: 256
int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }
    if(a<b){
        printf("a < b\n");
    }
    if(a==b){
        printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
using namespace std;
int main(void){
    long n;
    cin>>n;
    long n2=n;
    long mod=0;
    while (n){
        mod+=n%10;
        n/=10;
    }
    if (n2%mod!=0){
    cout<<"No";}
    else{
        cout<<"Yes";
    }
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] c = new int[4];
        String[] str = {"AC", "WA", "TLE", "RE"};
        for(int i = 0; i < n; i++) {
            String s = sc.next();
            for(int j = 0; j < 4; j++) {
                if(s.equals(str[j])) {
                    c[j]++;
                    break;
                }
            }
        }
        for(int i = 0; i < 4; i++) {
            System.out.println(str[i] + " x " + c[i]);
        }
    }
}


Measured memory_bytes: 59168
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val S = ns().toCharArray()
    for (i in 0 until S.size) {
      if (S[i] == '?') {
        S[i] = 'D'
      }
    }
    out.println(S.joinToString(""))
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 998244353
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

mint dp[64][2][2][2];
//keta
//xがLより大きい確定 = 1
//yがRより小さい確定 = 1
//先頭ビットがすでに現れたか

int main() {
	long long L, R;
	cin >> L >> R;
	dp[60][0][0][0] = 1;
	for (int i = 59; i >= 0; --i) {
		int lb = (L >> i) & 1;
		int rb = (R >> i) & 1;
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				for (int l = 0; l < 2; ++l) {
					mint pre = dp[i + 1][j][k][l];
					for (int x = 0; x < 2; ++x) {
						for (int y = 0; y < 2; ++y) {
							if ((1 == x) && (0 == y)) {//(1,0)
								continue;
							}
							int nj = j;
							int nk = k;
							int nl = l;
							//nl
							if ((0 == l)) {
								if (x != y) {
									continue;
								}
								if ((1 == x) && (1 == y)) {
									nl = 1;
								}
							}
							//j: L<=X
							if ((1 == lb) && (0 == x) && (0 == j)) {
								continue;
							}
							if (0 == j) {
								if ((1 == x) && (0 == lb)) {
									nj = 1;
								}
							}
							//k: Y <=R
							if ((0 == rb)&&(1 == y)&&(0 == k)) {
								continue;
							}
							if (0 == k) {
								if ((0 == y)&&(1 == rb)) {
									nk = 1;
								}
							}

							dp[i][nj][nk][nl] += pre;
						}
					}
				}
			}
		}
	}
	mint ans = 0;
	for (int j = 0; j < 2; ++j) {
		for (int k = 0; k < 2; ++k) {
			for (int l = 0; l < 2; ++l) {
				ans += dp[0][j][k][l];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
int n;
std::vector<int>a,ans;
int main(){
	scanf("%d",&n),a.push_back(0);
	for(int i=1,x;i<=n;++i)
		scanf("%d",&x),a.push_back(x);
	for(int i=n;i;--i){
		bool flag=false;
		for(int j=i;j;--j)
			if(a[j]==j){
				a.erase(a.begin()+j);
				flag=true,ans.push_back(j);
				break;
			}
		if(!flag)return!puts("-1");
	}
	std::reverse(ans.begin(),ans.end());
	for(size_t i=0;i<ans.size();++i)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    REP(i, S.length())
        cout << "x";
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
enter = []
upenter = []
ans = "Yay!"
for i in 0..5 do
    enter[i] = gets.chomp.to_i 
    if i == 1
        upenter[0] = enter[i] - enter[i-1]
         
    elsif i == 2
        upenter[1] = enter[i] - enter[i-1]
        upenter[2] = enter[i] - enter[i-2]
    elsif i == 3
        upenter[3] = enter[i] - enter[i-1]
        upenter[4] = enter[i] - enter[i-2]
        upenter[5] = enter[i] - enter[i-3]
    elsif i == 4
        upenter[6] = enter[i] - enter[i-1]
        upenter[7] = enter[i] - enter[i-2]
        upenter[8] = enter[i] - enter[i-3]
        upenter[9] = enter[i] - enter[i-4]
    end
end
upenter.select do |x|
    if x > enter[5]
        ans = ":("
        break
    end
end
puts ans

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

int main(){
	int a,b,tmp;
	cin >> a;
	cin >> b;
	while(1){
		if(b==0){
			cout << a <<endl;
			break;
		}else{
			tmp = a;
			a = b;
			b = tmp % b;
		}
	}	
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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

  ll first0cnt = 0, first1cnt = 0;

  rep(i,S.size()){
    if(i % 2 == 0){
      if(S[i] == '0'){
        first1cnt++;
      }else{
        first0cnt++;
      }
    }else{
      if(S[i] == '0'){
        first0cnt++;
      }else{
        first1cnt++;
      }
    }
  }
  cout << min(first0cnt,first1cnt) << endl;
  return 0;
}


Measured memory_bytes: 512
N=int(input())
S=str(input())
s=list(S)
t=['']*len(s)
#print(len(s))
#print(t)
for i in range(len(s)):
    if ord(s[i])+N>90:
        t[i]=chr(ord(s[i])+N-26)
        #print(s[i])
    else:
        #print(s[i])
        t[i]=chr(ord(s[i])+N)
A=''.join(t)
print(A)


Measured memory_bytes: 3188
# Aizu Problem 00138: Track and Field Competition
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


top3 = []
for run in range(3):
    field = []
    for runner in range(8):
        s = input().split()
        field.append([runner, int(s[0]), float(s[1])])
    field = sorted(field, key=lambda x: (x[2], x[0]))
    print("%d %.2f" % (field[0][1], field[0][2]))
    print("%d %.2f" % (field[1][1], field[1][2]))
    top3.append(field[2])

top3 = sorted(top3, key=lambda x: (x[2], x[0]))
print("%d %.2f" % (top3[0][1], top3[0][2]))
print("%d %.2f" % (top3[1][1], top3[1][2]))

    

Measured memory_bytes: 8220
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;


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

    int n;
    cin >> n;

if (n == 1){
    cout << "Hello World";
    return 0;
}else{
    int a,b;
    cin >> a >> b;
    cout << a+b;
    return 0;
}

   
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long int ll;

const int MAXN = 2005;
const int mod = 1e9 + 7;

int n, k;
ll C[MAXN][MAXN];

ll get_C(int x, int y) {
	if (x < y)
		return 0;
	if (C[x][y])
		return C[x][y];
	if ((y == 0) || (y == x))
		C[x][y] = 1;
	else
		C[x][y] = (get_C(x - 1, y) + get_C(x - 1, y - 1)) % mod;
	return C[x][y];
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= k; ++i) {
		printf("%lld\n", get_C(k - 1, i - 1) * get_C(n - k + 1, i) % mod);
	}
	return 0;
}

Measured memory_bytes: 30080
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> v;
    copy(istream_iterator<int>{cin}, istream_iterator<int>{}, back_inserter(v));
    sort(v.begin(), v.end());
    cout << (v[0] == 5 && v[1] == 5 && v[2] == 7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 1e6;
const int mod = 1e9+7;
map<string, int>m;
map<string ,int>p;
int n;
string s[N];

int main(void)
{
    cin >> n;
    for(int i = 1; i<=n;++i){
        cin >> s[i];
        m[ s[i] ]++;
    }
    vector<string>v;
    int mx = 0;
    for(int i =1;i<=n;++i)
        mx=max(mx, m[ s[i] ] );
    for(int i = 1; i <=n;++i){
        if( m[ s[i] ] == mx && p[ s[i] ] == 0){
            v.pb(s[i]);
            p[ s[i] ]=1;
        }
    }
    sort(v.begin(),v.end());
    for(auto i : v)
            cout << i << endl;
    return 0;
}


Measured memory_bytes: 47088
#include<cstdio>
#include<vector>
typedef std::vector<std::vector<int>> Graph;
typedef std::pair<int,int> pii;
// visit(p,v,g)=Graph g上でvからp以外の方向に探索したときの(最遠点までの距離,最遠点の番号)の組
pii visit(int p,int v, const Graph &g){
    pii r={0,v};
    for(auto itr=g[v].begin();itr!=g[v].end();itr++){
        if(*itr==p)continue;
        pii t=visit(v,*itr,g);
        t.first++;
        if(r.first<t.first)r=t;
    }
    return r;
}
int diameter(const Graph &g){
    pii r=visit(-1,0,g);
    pii t=visit(-1,r.second,g);
    return t.first;
}
int main(){
    int n;
    scanf("%d",&n);
    Graph g(n);
    for(int i=1;i<n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    int d=diameter(g)+1;
    if(d==0 || d%3==2)printf("Second\n");
    else printf("First\n");
    return 0;
}

Measured memory_bytes: 26752
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a, b, c;
	//int m;
	int h, w;
	int k;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	//string s[111111];
	//string s[100000];
	//string c[7];
	int a[100000];///////////////////////////////////////////////
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	int box[20000] = { 0 };/////////////////////////////////////////
	//int box = 0;
	//int box[7][7] = { 0 };
	//int box2;
	//int p[1111];

	//long double aaa;

	int count = 0;
	//int k, d;
	//int a = 0;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	bool flag = true;
	//bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	cin >> n;
	//cin >> a >> b >> c;
	//cin >> k;
	//cin >> h >> w >> k;
	//cin >> x;
	/*for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		box[i] = 1;
	}*/

	//for (int i = 0; i < (n - k + 1); i++)
	//{
	//	for (int j = 0; j < k; j++)
	//	{
	//		box[i] = box[i] * a[i + j];
	//	}
	//	//cout << box[i] << "\n";
	//	if (i != 0 && box[i] <= box[i - 1])
	//	{
	//		cout << "No\n";
	//	}
	//	else if (i != 0 && box[i] > box[i - 1])
	//	{
	//		cout << "Yes\n";
	//	}
	//}

	if (n>=30)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';

	//for (int i = 0; i < 1000; i++)
	//{
	//	if (n < 1000)
	//	{
	//		all = 1000 - n;
	//		break;
	//	}
	//	n -= 1000;
	//	if (n == 0)
	//	{
	//		all = 0;
	//		break;
	//	}
	//}

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	/*cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";*/

	//cout << all << "\n";
	//cout << box << "\n";
	//cout << a << b << c << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
	//return 0;
}


Measured memory_bytes: 3632
# 分からない

K = int(input())

if K == 1:
    print(1)
    print(1)
else:
    n = ((K + 3) // 4) * 2
    print(n)
    for r in range(n):
        line = []
        for c in range(n):
            if r % 2 == 0:
                t = (r + c) % n + 1
            else:
                t = n + (r + c) % n + 1
            if t > K:
                t -= n
            line.append(t)
        print(*line)


Measured memory_bytes: 4388
def resolve():
    from scipy.sparse.csgraph import floyd_warshall
    import numpy as np
    import sys
    input = sys.stdin.readline
    n, m, l = map(int, input().split())
    inf = 10 ** 20
    ar = [[0] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        ar[a - 1][b - 1] = c
        ar[b - 1][a - 1] = c
    x = floyd_warshall(ar)
    br = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if x[i, j] <= l:
                br[i][j] = 1
                br[j][i] = 1
    y = floyd_warshall(br)
    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        p = y[s - 1, t - 1]
        print(int(p) - 1 if p < inf else -1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 18948
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<ll, ll> > v;
    for (int i = 0; i < n; ++i)
    {
        ll a, b;
        cin >> a >> b;
        v.emplace_back(b, a);
    }
    ll t = 0;
    sort(all(v));
    for (pair<ll, ll> p : v)
    {
        ll b, a;
        tie(b, a) = p;
        if (t + a > b)
            return cout << "No", 0;
        t += a;
    }
    cout << "Yes";
}


Measured memory_bytes: 6512
n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100002
for i in range(n):
    s,t,x=map(int,input().split())
    d[x-1].append((s,t))
for i in range(c):
    d[i].sort()
    e=0
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e!=d[i][j][0]:
                w[e+1]-=1
                w[d[i][j][0]]+=1
            w[d[i][j][1]+1]-=1
        else:
            if e!=d[i][j][0]:
                w[e+1]-=1
                w[d[i][j][0]]+=1
            e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)

Measured memory_bytes: 56844
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;
 
int main(void) {
    string S;
    cin >> S;
    int n = S.size();
    int ans = n;
    for(int k=0; k<n; ++k) {
        if(S[k] != S[k+1]) {
            ans = min(ans, max(k+1, n-k-1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#define int long long

int N,M;
int s,t;

i64 A[101010];
i64 B[101010];

struct edge{
  int to;
  int idx;
};

vector<edge> G[101010];
vector<i64> money(101010,1e18);
vector<i64> snuuk(101010,1e18);
signed main(){
  cin >> N >> M;
  cin >> s >> t;
  rep(i,0,M - 1){
    int u,v;
    cin >> u >> v >> A[i] >> B[i];
    G[u].push_back({v,i});
    G[v].push_back({u,i});
  }
  money[s] = 0;
  {
    using P = pair<i64,i64>;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({money[s],s});
    while(!que.empty()){
      int v = que.top().second;
      int d = que.top().first;
      que.pop();
      if(money[v] < d) continue;
      for(auto e : G[v]){
        if(money[e.to] > money[v] + A[e.idx]){
          money[e.to] = money[v] + A[e.idx];
          que.push({money[e.to],e.to});
        }
      }
    }
  }
  snuuk[t] = 0;
  {
    using P = pair<i64,i64>;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({snuuk[t],t});
    while(!que.empty()){
      int v = que.top().second;
      int d = que.top().first;
      que.pop();
      if(snuuk[v] < d) continue;
      for(auto e : G[v]){
        if(snuuk[e.to] > snuuk[v] + B[e.idx]){
          snuuk[e.to] = snuuk[v] + B[e.idx];
          que.push({snuuk[e.to],e.to});
        }
      }
    }
  }
  i64 ans = 0;
  vector<i64> res;
  i64 base = 1e15;
  for(int i = N;i >= 1;i--){
    ans = max(ans , base - money[i] - snuuk[i]);
    res.push_back(ans);
  }
  reverse(all(res));
  for(auto x : res){
    cout << x << endl;
  }
}


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

int main() {
  string s;
  cin >> s;
  if (s == "SUN") cout << 7 << endl;
  else if (s == "MON") cout << 6 << endl;
  else if (s == "TUE") cout << 5 << endl;
  else if (s == "WED") cout << 4 << endl;
  else if (s == "THU") cout << 3 << endl;
  else if (s == "FRI") cout << 2 << endl;
  else cout << 1 << endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

//AtCoder解説動画(https://www.youtube.com/watch?v=TdR816rqc3s&feature=youtu.be)からもらった
// (https://atcoder.jp/contests/abc157/submissions/10472433)
struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {} //このコロンってなんですか
	int find(int x){
		if (d[x] < 0) return x; //x:根
		return d[x] = find(d[x]);//x:子 -> xの親の根を返す
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//根同士をくっつける。
		if ( x ==  y) return false ; 
		/*連結成分が一致してるんだったらfalse返す。
		  minimum spanning tree (クラスカル法と言うのをやるときに、くっつけたかどうかを取れると嬉しい.
		  chmin/chmaxみたいなノリかな
		 */
		if ( d[x] > d[y]) swap(x,y);//xの方が大きいようにする（ただしサイズは負デモっているので不等号が逆）
		d[x] += d[y] ; //xにyをくっつける.
		d[y] = x;
		return true; 
	}
	bool same(int x, int y) { return find(x) == find(y) ; }
	int size(int x) { return -d[find(x)];}
};
int main()
{
	int n;
	cin >> n;
	UnionFind uf(n);
	int q;
	cin >> q;
	rep(i,q){
		int com;
		cin >> com;
		int a, b;
		cin >> a >> b;
		if(com == 0){
			uf.unite(a,b);
		} else {
			if(uf.same(a,b)){
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}
}



Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int x,y,z;cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
  return 0;
}


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

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

  // M要素の配列
  vector<int> A(M);

  //宿題にかかる日数の合計
  int sum = 0;

  for(int i = 0; i < M;i++){
    cin >> A.at(i);
    sum += A.at(i);
  }

  if( (N-sum) < 0){
    cout << -1 << endl;
  }
  else{
    cout << N - sum << endl;
  }


}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
int arr[100000];
int compare(int a,int b)
{
    if(a<b) return 0;
    else return 1;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n,compare);
    int sum1=0;
    for(int i=0;i<n;i+=2)
        sum1+=arr[i];
    for(int i=1;i<n;i+=2)
        sum1-=arr[i];
    cout<<sum1;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program{
    static void Main(string[] args){
        string str = Console.ReadLine();
        char[] cha = new char[str.Length];
        for(int i=0;i<str.Length;i++){
            cha[i] = str[i];
        }
        int cCount = 0;
        int cNumber = 0;
        for(int i=2;i<cha.Length-1;i++){
            if(cha[i].ToString() == "C"){cCount++; cNumber = i;}
        }
        bool isLow = true;
        for(int i=1;i<cha.Length;i++){
            if(i==cNumber){
                continue;
            }
            if(cha[i].ToString().CompareTo(cha[i].ToString().ToLower()) != 0){
                isLow = false;
            }
        }
        if(cCount == 1 && isLow && cha[0].ToString() == "A"){
            Console.WriteLine("AC");
        }else{
            Console.WriteLine("WA");
            
        }
    }
}

Measured memory_bytes: 13396